diff --git a/StgSharp.C/x64/Debug/StgSharp.C.ilk b/StgSharp.C/x64/Debug/StgSharp.C.ilk index 83e1a0df..38099768 100644 Binary files a/StgSharp.C/x64/Debug/StgSharp.C.ilk and b/StgSharp.C/x64/Debug/StgSharp.C.ilk differ diff --git a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.command.1.tlog b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.command.1.tlog index f18958bf..39d34ba0 100644 Binary files a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.command.1.tlog and b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.command.1.tlog differ diff --git a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.read.1.tlog b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.read.1.tlog index 7d944fad..c3da481d 100644 Binary files a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.read.1.tlog and b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.read.1.tlog differ diff --git a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.write.1.tlog b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.write.1.tlog index 663701b6..fca4f9ba 100644 Binary files a/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.write.1.tlog and b/StgSharp.C/x64/Debug/StgSharp.C.tlog/CL.write.1.tlog differ diff --git a/StgSharp.C/x64/Debug/StgSharpC.log b/StgSharp.C/x64/Debug/StgSharpC.log index d6ef9e93..d995dc14 100644 --- a/StgSharp.C/x64/Debug/StgSharpC.log +++ b/StgSharp.C/x64/Debug/StgSharpC.log @@ -1,5 +1,62 @@ C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(517,5): warning MSB8004: Output 目录未以斜杠结尾。 此生成实例将添加斜杠,因为必须有这个斜杠才能正确计算 Output 目录。 - StgSharpC.c -D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\StgSharpC.c(14,30): warning C4244: “函数”: 从“uint64_t”转换到“GLuint”,可能丢失数据 -D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\StgSharpC.c(16,43): warning C4244: “函数”: 从“uint64_t”转换到“GLuint”,可能丢失数据 + mat4.c + string.c +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\string.c(21,54): warning C4267: “return”: 从“size_t”转换到“int”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(9,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\string.c(36,54): warning C4267: “return”: 从“size_t”转换到“int”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(9,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(11,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(11,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(20,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(20,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(22,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(22,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(24,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(24,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(26,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(26,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(36,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(36,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(38,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(38,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(40,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(40,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(42,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(42,62): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(51,54): warning C4028: 形参 1 与声明不同 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(51,84): warning C4028: 形参 2 与声明不同 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(53,22): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(54,22): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(55,22): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(56,22): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(59,28): warning C4013: “det_mat3_internal”未定义;假设外部返回 int +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(59,28): warning C4244: “函数”: 从“int”转换到“float”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(59,62): warning C4244: “函数”: 从“int”转换到“float”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(60,28): warning C4244: “函数”: 从“int”转换到“float”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(60,62): warning C4244: “函数”: 从“int”转换到“float”,可能丢失数据 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(61,36): warning C4133: “函数”: 从“const __m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(69,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(69,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(70,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(70,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(71,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(71,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(72,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(72,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(77,38): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(77,63): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(78,38): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(78,63): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(88,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(88,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(89,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(89,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(90,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(90,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(91,37): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(91,61): warning C4133: “函数”: 从“__m128 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(96,38): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(96,63): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(97,38): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 +D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\StgSharp.C\mat4.c(97,63): warning C4133: “函数”: 从“__m256 *”到“const float *”的类型不兼容 StgSharpC.vcxproj -> D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\内核源代码\build\StgSharp.C.dll diff --git a/StgSharp.C/x64/Debug/mat4.cod b/StgSharp.C/x64/Debug/mat4.cod index 054c0071..a7262572 100644 --- a/StgSharp.C/x64/Debug/mat4.cod +++ b/StgSharp.C/x64/Debug/mat4.cod @@ -1031,7 +1031,7 @@ $LN3: 00051 62 f1 7c 48 11 00 vmovups ZMMWORD PTR [rax], zmm0 -; 103 : } +; 103 : } 00057 48 8d a5 c8 00 00 00 lea rsp, QWORD PTR [rbp+200] diff --git a/StgSharp.C/x64/Debug/mat4.obj b/StgSharp.C/x64/Debug/mat4.obj index 0025b964..9d1dd289 100644 Binary files a/StgSharp.C/x64/Debug/mat4.obj and b/StgSharp.C/x64/Debug/mat4.obj differ diff --git a/StgSharp.C/x64/Debug/string.obj b/StgSharp.C/x64/Debug/string.obj index dee7e307..55835a0d 100644 Binary files a/StgSharp.C/x64/Debug/string.obj and b/StgSharp.C/x64/Debug/string.obj differ diff --git a/StgSharp.C/x64/Debug/vc143.idb b/StgSharp.C/x64/Debug/vc143.idb index 8ad7b582..502da69c 100644 Binary files a/StgSharp.C/x64/Debug/vc143.idb and b/StgSharp.C/x64/Debug/vc143.idb differ diff --git a/StgSharp.C/x64/Debug/vc143.pdb b/StgSharp.C/x64/Debug/vc143.pdb index 60ecf559..2f73bebc 100644 Binary files a/StgSharp.C/x64/Debug/vc143.pdb and b/StgSharp.C/x64/Debug/vc143.pdb differ diff --git a/StgSharp.Common/Data/RandomGenerator.cs b/StgSharp.Common/Data/RandomGenerator.cs index 4be8ca1d..83e840dd 100644 --- a/StgSharp.Common/Data/RandomGenerator.cs +++ b/StgSharp.Common/Data/RandomGenerator.cs @@ -32,42 +32,34 @@ using StgSharp.HighPerformance; using System; using System.IO; -using System.Security.Cryptography; using System.Text; using System.Xml.Serialization; namespace StgSharp.Data { - public class RandomGenerator + public unsafe class RandomGenerator { private byte[] currentKey; - private readonly byte[] originKey; private int cycleCount; - private SHA512 hash; public RandomGenerator() : this( DateTime.UtcNow.ToBinary() ) { } public RandomGenerator( object source ) { - try { - if( source == null ) { - throw new ArgumentNullException( nameof( source ) ); - } - XmlSerializer s = new XmlSerializer( source.GetType() ); - using( StringWriter sw = new StringWriter() ) { - s.Serialize( sw, source ); - string data = sw.ToString(); - originKey = Encoding.UTF8.GetBytes( data ); - } + ArgumentNullException.ThrowIfNull( source ); + XmlSerializer s = new XmlSerializer( source.GetType() ); + using( StringWriter sw = new StringWriter() ) + { + s.Serialize( sw, source ); + string data = sw.ToString(); + originKey = Encoding.Unicode.GetBytes( data ); } - catch( Exception ) { - throw; + currentKey = [0,0,0,0]; + fixed( byte* o = originKey, c = currentKey ) { + *( int* )c = UnsafeCompute.CityHashSimplify( ( char* )o, 0, originKey.Length / 2 ); } - hash = SHA512.Create(); - originKey = hash.ComputeHash( originKey ); - currentKey = originKey; cycleCount = 0; } @@ -78,53 +70,45 @@ namespace StgSharp.Data public unsafe int GenRandomInt() { - M128 source = PrivateRand(); + uint source = PrivateRand(); cycleCount++; - - /* - float d0 = MathF.Sin(1 / source.Read(0)); - float d1 = MathF.Sin(1 / source.Read(1)); - float d2 = MathF.Sin(1 / source.Read(2)); - float d3 = MathF.Sin(1 / source.Read(3)); - - source.Write(0, *( short*)&d3); - source.Write(2, *((short*)&d2+1)); - source.Write(4, *( short*)&d1); - source.Write(6, *((short*)&d0+1)); - - /**/ - - return source.Read( cycleCount % 4 ); + M64 m = new M64(); + m.Write( 0, source ); + m.Write( 1, source ); + return ( m << ( cycleCount % 32 ) ).Read( 1 ); } public byte GenRandomInt8() { cycleCount++; - if( cycleCount % 64 == 0 ) { + if( cycleCount % 4 == 0 ) { PrivateRand(); } - return currentKey[ cycleCount % 64 ]; + return currentKey[ cycleCount % 4 ]; } public float GenRandomSingle() { cycleCount++; - while( true ) { - M128 source = PrivateRand(); - + while( true ) + { uint - temp0 = source.Read( 0 ), - temp1 = source.Read( 2 ); + temp0 = PrivateRand(), + temp1 = PrivateRand(); - if( temp0 * temp1 != 0 ) { + if( temp0 * temp1 != 0 ) + { float ret = ( ( temp0 % temp1 ) * 1.0f ) / temp1; - if( ret < 0.335f ) { + if( ret < 0.335f ) + { ret = ret * ( ( ret * ( -0.7811934f ) ) + 1.4489113f ); - } else { + } else + { ret = ( ret * ( ( ret * ( -0.1158368f ) ) + 1.0580600f ) ) + 0.0590584f; } - if( ret > 1 ) { + if( ret > 1 ) + { continue; } return ret; @@ -138,27 +122,14 @@ namespace StgSharp.Data cycleCount = 0; } - private unsafe M128 PrivateRand() + private unsafe uint PrivateRand() { - currentKey = hash.ComputeHash( currentKey ); - M128 ret; - fixed( byte* bptr = currentKey ) { - switch( ( cycleCount % 16 ) / 4 ) { - case 0: - ret = *( ( ( M128* )bptr ) + 0 ); - break; - case 1: - ret = *( ( ( M128* )bptr ) + 1 ); - break; - case 2: - ret = *( ( ( M128* )bptr ) + 2 ); - break; - case 3: - ret = *( ( ( M128* )bptr ) + 3 ); - break; - default: - throw new InvalidOperationException(); - } + uint ret; + fixed( byte* bptr = currentKey ) + { + *( int* )bptr = UnsafeCompute.CityHashSimplify( + ( char* )bptr, currentKey.Length / 2 ); + ret = *( uint* )bptr; } //Console.WriteLine(ret.ToString(16)); diff --git a/StgSharp.Common/Geometries/Point.cs b/StgSharp.Common/Geometries/Point.cs index 9731a2cc..08af0df4 100644 --- a/StgSharp.Common/Geometries/Point.cs +++ b/StgSharp.Common/Geometries/Point.cs @@ -65,11 +65,7 @@ namespace StgSharp.Geometries public Vec3 Coord { get => coord; - set - { - coord = value; - coordVec.W = 1; - } + set { coord = value; } } } diff --git a/StgSharp.Common/HighPerformance/M64.cs b/StgSharp.Common/HighPerformance/M64.cs new file mode 100644 index 00000000..1d7a86a1 --- /dev/null +++ b/StgSharp.Common/HighPerformance/M64.cs @@ -0,0 +1,111 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="M64.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Numerics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.HighPerformance +{ + [StructLayout( LayoutKind.Explicit, Pack = 8 )] + public unsafe struct M64 : IRegisterType + { + + [FieldOffset( 0 )] private fixed byte buffer[ 8 ]; + [FieldOffset( 0 )] private ulong value; + + public M64() + { + Unsafe.SkipInit( out this ); + value = 0; + } + + public ref T AsRef() where T: struct,INumber + { + return ref Unsafe.As( ref buffer[ 0 ] ); + } + + public override bool Equals( object obj ) + { + return obj is M64 m64 && this == m64; + } + + public override int GetHashCode() + { + return value.GetHashCode(); + } + + public T Read( int index ) where T: struct, INumber + { + return Unsafe.As( ref buffer[ index * sizeof( T ) ] ); + } + + public void Write( int index, T value ) where T: struct, INumber + { + Unsafe.As( ref buffer[ index * sizeof( T ) ] ) = value; + } + + public static bool operator !=( M64 left, M64 right ) + { + return !( left == right ); + } + + [MethodImpl( MethodImplOptions.AggressiveInlining )] + public static M64 operator <<( M64 m, int shift ) + { + return new M64 + { + value = m.value << shift + }; + } + + public static bool operator ==( M64 left, M64 right ) + { + return left.value == right.value; + } + + [MethodImpl( MethodImplOptions.AggressiveInlining )] + public static M64 operator >>( M64 m, int shift ) + { + return new M64 + { + value = m.value >> shift + }; + } + + } +} diff --git a/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.AssemblyInfo.cs b/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.AssemblyInfo.cs index bf96ef31..f31a02ce 100644 --- a/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.AssemblyInfo.cs +++ b/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+148b0fed4a1abaaeaa3a28e7c7b088590805ebef")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Common")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.sourcelink.json b/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.sourcelink.json index 248b54bf..2440bc0f 100644 --- a/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.sourcelink.json +++ b/StgSharp.Common/obj/x64/Debug/net8.0/StgSharp.Common.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/148b0fed4a1abaaeaa3a28e7c7b088590805ebef/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} \ No newline at end of file diff --git a/StgSharp.Generator/obj/x64/Debug/net8.0/StgSharp.Generator.AssemblyInfo.cs b/StgSharp.Generator/obj/x64/Debug/net8.0/StgSharp.Generator.AssemblyInfo.cs index 7632cfaf..91e78c1b 100644 --- a/StgSharp.Generator/obj/x64/Debug/net8.0/StgSharp.Generator.AssemblyInfo.cs +++ b/StgSharp.Generator/obj/x64/Debug/net8.0/StgSharp.Generator.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+e3741687a706609a1d0055c3fd11f41945838a70")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Generator")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Model/STEP/IStepEntity.cs b/StgSharp.Model/STEP/IStepEntity.cs new file mode 100644 index 00000000..2e43b8f8 --- /dev/null +++ b/StgSharp.Model/STEP/IStepEntity.cs @@ -0,0 +1,36 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="IStepEntity.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.STEP +{ + public interface IStepEntity : IExpMarshalType where TSelf: IStepEntity { } +} \ No newline at end of file diff --git a/StgSharp.Model/STEP/Items/StepAdvancedFace.cs b/StgSharp.Model/STEP/Items/StepAdvancedFace.cs new file mode 100644 index 00000000..fc9bf58f --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepAdvancedFace.cs @@ -0,0 +1,78 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepAdvancedFace.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Linq; + +namespace StgSharp.Modeling.Items +{ + public class StepAdvancedFace : StepFaceSurface + { + + private StepAdvancedFace() : base( string.Empty ) { } + + public StepAdvancedFace( string name ) : base( name ) { } + + public override StepItemType ItemType => StepItemType.AdvancedFace; + + internal static StepAdvancedFace CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepAdvancedFace face = new StepAdvancedFace(); + enumerator.AssertEnumeratorCount( 4 ); + face.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + + object boundsList = enumerator.Values[ 1 ].GetValueList(); + face.Bounds.Clear(); + face.Bounds + .AddRange( + Enumerable.Range( 0, enumerator.Values.Count ) + .Select( _ => ( StepFaceBound )null ) ); + for( int i = 0; i < enumerator.Values.Count; i++ ) + { + int j = i; // capture to avoid rebinding + binder.BindValue( + enumerator.Values[ j ], v => face.Bounds[ j ] = v.AsType() ); + } + binder.BindValue( + enumerator.Values[ 2 ], v => face.FaceGeometry = v.AsType() ); + face.SameSense = ( enumerator.Values[ 3 ] as ExpBoolNode )!.Value; + + return face; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepAxis2Placement.cs b/StgSharp.Model/STEP/Items/StepAxis2Placement.cs new file mode 100644 index 00000000..4a0bf139 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepAxis2Placement.cs @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepAxis2Placement.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepAxis2Placement : StepPlacement + { + + private StepCartesianPoint _location; + private StepDirection _refDirection; + + protected StepAxis2Placement( string name ) : base( name ) { } + + public StepCartesianPoint Location + { + get { return _location; } + set + { + ArgumentNullException.ThrowIfNull( value ); + + _location = value; + } + } + + public StepDirection RefDirection + { + get { return _refDirection; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _refDirection = value; + } + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepAxis2Placement2D.cs b/StgSharp.Model/STEP/Items/StepAxis2Placement2D.cs new file mode 100644 index 00000000..8c05edbe --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepAxis2Placement2D.cs @@ -0,0 +1,79 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepAxis2Placement2D.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepAxis2Placement2D : StepAxis2Placement + { + + private StepAxis2Placement2D() : base( string.Empty ) { } + + public StepAxis2Placement2D( + string label, + StepCartesianPoint location, + StepDirection direction ) + : base( label ) + { + Location = location; + RefDirection = direction; + } + + public override StepItemType ItemType => StepItemType.AxisPlacement2D; + + internal static StepAxis2Placement2D CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepAxis2Placement2D axis = new StepAxis2Placement2D(); + enumerator.AssertEnumeratorCount( 3 ); + axis.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => axis.Location = v.AsType() ); + binder.BindValue( + enumerator.Values[ 2 ], v => axis.RefDirection = v.AsType() ); + return axis; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Location; + yield return RefDirection; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepAxis2Placement3D.cs b/StgSharp.Model/STEP/Items/StepAxis2Placement3D.cs new file mode 100644 index 00000000..94a38e81 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepAxis2Placement3D.cs @@ -0,0 +1,98 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepAxis2Placement3D.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepAxis2Placement3D : StepAxis2Placement + { + + private StepDirection _axis; + + private StepAxis2Placement3D() : base( string.Empty ) { } + + public StepAxis2Placement3D( + string name, + StepCartesianPoint location, + StepDirection axis, + StepDirection refDirection ) + : base( name ) + { + Location = location; + Axis = axis; + RefDirection = refDirection; + } + + public StepDirection Axis + { + get { return _axis; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _axis = value; + } + } + + public override StepItemType ItemType => StepItemType.AxisPlacement3D; + + internal static StepAxis2Placement3D CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepAxis2Placement3D axis = new StepAxis2Placement3D(); + enumerator.AssertEnumeratorCount( 4 ); + axis.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => axis.Location = v.AsType() ); + binder.BindValue( syntaxList.Values[ 2 ], v => axis.Axis = v.AsType() ); + binder.BindValue( + enumerator.Values[ 3 ], v => axis.RefDirection = v.AsType() ); + return axis; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Location; + yield return Axis; + yield return RefDirection; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepBSplineCurve.cs b/StgSharp.Model/STEP/Items/StepBSplineCurve.cs new file mode 100644 index 00000000..de574446 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepBSplineCurve.cs @@ -0,0 +1,132 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepBSplineCurve.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; + +using System.Collections.Generic; +using System.Linq; + +namespace StgSharp.Modeling.Items +{ + public enum StepBSplineCurveForm + { + + Polyline, + CircularArc, + EllipticalArc, + ParabolicArc, + HyperbolicArc, + Unspecified + + } + +; + + public abstract class StepBSplineCurve : StepBoundedCurve + { + + private const string CIRCULAR_ARC = "CIRCULAR_ARC"; + private const string ELLIPTIC_ARC = "ELLIPTIC_ARC"; + private const string HYPERBOLIC_ARC = "HYPERBOLIC_ARC"; + private const string PARABOLIC_ARC = "PARABOLIC_ARC"; + + private const string POLYLINE_FORM = "POLYLINE_FORM"; + private const string UNSPECIFIED = "UNSPECIFIED"; + + public StepBSplineCurve( string name, IEnumerable controlPoints ) + : base( name ) + { + ControlPointsList.AddRange( controlPoints ); + } + + public StepBSplineCurve( string name, params StepCartesianPoint[] controlPoints ) + : this( name, ( IEnumerable )controlPoints ) { } + + public bool ClosedCurve { get; set; } + + public bool SelfIntersect { get; set; } + + public int Degree { get; set; } + + public List ControlPointsList { get; } = new List(); + + public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified; + + internal override IEnumerable GetReferencedItems() + { + return ControlPointsList; + } + + protected static string GetCurveFormString( StepBSplineCurveForm form ) + { + switch( form ) + { + case StepBSplineCurveForm.Polyline: + return POLYLINE_FORM; + case StepBSplineCurveForm.CircularArc: + return CIRCULAR_ARC; + case StepBSplineCurveForm.EllipticalArc: + return ELLIPTIC_ARC; + case StepBSplineCurveForm.ParabolicArc: + return PARABOLIC_ARC; + case StepBSplineCurveForm.HyperbolicArc: + return HYPERBOLIC_ARC; + case StepBSplineCurveForm.Unspecified: + return UNSPECIFIED; + } + + throw new NotImplementedException(); + } + + protected static StepBSplineCurveForm ParseCurveForm( string enumerationValue ) + { + switch( enumerationValue.ToUpperInvariant() ) + { + case POLYLINE_FORM: + return StepBSplineCurveForm.Polyline; + case CIRCULAR_ARC: + return StepBSplineCurveForm.CircularArc; + case ELLIPTIC_ARC: + return StepBSplineCurveForm.EllipticalArc; + case PARABOLIC_ARC: + return StepBSplineCurveForm.ParabolicArc; + case HYPERBOLIC_ARC: + return StepBSplineCurveForm.HyperbolicArc; + default: + return StepBSplineCurveForm.Unspecified; + } + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepBSplineCurveWithKnots.cs b/StgSharp.Model/STEP/Items/StepBSplineCurveWithKnots.cs new file mode 100644 index 00000000..edfba934 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepBSplineCurveWithKnots.cs @@ -0,0 +1,155 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepBSplineCurveWithKnots.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; + +using System.Collections.Generic; +using System.Linq; + +namespace StgSharp.Modeling.Items +{ + public enum StepKnotType + { + + UniformKnots, + QuasiUniformKnots, + PiecewiseBezierKnots, + Unspecified + + } + +; + + public class StepBSplineCurveWithKnots : StepBSplineCurve + { + + private const string PIECEWISE_BEZIER_KNOTS = "PIECEWISE_BEZIER_KNOTS"; + private const string QUASI_UNIFORM_KNOTS = "QUASI_UNIFORM_KNOTS"; + + private const string UNIFORM_KNOTS = "UNIFORM_KNOTS"; + private const string UNSPECIFIED = "UNSPECIFIED"; + + public StepBSplineCurveWithKnots( + string name, + IEnumerable controlPoints ) + : base( name, controlPoints ) { } + + public StepBSplineCurveWithKnots( string name, params StepCartesianPoint[] controlPoints ) + : base( name, controlPoints ) { } + + public List KnotMultiplicities { get; } = new List(); + + public List Knots { get; } = new List(); + + public override StepItemType ItemType => StepItemType.BSplineCurveWithKnots; + + public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified; + + internal static StepBSplineCurveWithKnots CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + enumerator.AssertEnumeratorCount( 9 ); + object controlPointsList = enumerator.Values[ 2 ].GetValueList(); + + StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots( + string.Empty, new StepCartesianPoint[controlPointsList.Values.Count] ); + spline.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + spline.Degree = ( enumerator.Values[ 1 ] as ExpIntNode )!.Value; + + for( int i = 0; i < controlPointsList.Values.Count; i++ ) + { + int j = i; // capture to avoid rebinding + binder.BindValue( + controlPointsList.Values[ j ], + v => spline.ControlPointsList[ j ] = v.AsType() ); + } + + spline.CurveForm = ParseCurveForm( enumerator.Values[ 3 ].GetEnumerationValue() ); + spline.ClosedCurve = ( enumerator.Values[ 4 ] as ExpBoolNode )!.Value; + spline.SelfIntersect = ( enumerator.Values[ 5 ]as ExpBoolNode )!.Value; + + object knotMultiplicitiesList = enumerator.Values[ 6 ].GetValueList(); + spline.KnotMultiplicities.Clear(); + for( int i = 0; i < knotMultiplicitiesList.Values.Count; i++ ) { + spline.KnotMultiplicities + .Add( knotMultiplicitiesList.Values[ i ].GetIntegerValue() ); + } + + object knotslist = enumerator.Values[ 7 ].GetValueList(); + spline.Knots.Clear(); + for( int i = 0; i < knotslist.Values.Count; i++ ) { + spline.Knots.Add( knotslist.Values[ i ].GetRealVavlue() ); + } + + spline.KnotSpec = ParseKnotSpec( enumerator.Values[ 8 ].GetEnumerationValue() ); + + return spline; + } + + private static string GetKnotSpec( StepKnotType spec ) + { + switch( spec ) + { + case StepKnotType.UniformKnots: + return UNIFORM_KNOTS; + case StepKnotType.QuasiUniformKnots: + return QUASI_UNIFORM_KNOTS; + case StepKnotType.PiecewiseBezierKnots: + return PIECEWISE_BEZIER_KNOTS; + case StepKnotType.Unspecified: + return UNSPECIFIED; + } + + throw new NotImplementedException(); + } + + private static StepKnotType ParseKnotSpec( string enumerationValue ) + { + switch( enumerationValue.ToUpperInvariant() ) + { + case UNIFORM_KNOTS: + return StepKnotType.UniformKnots; + case QUASI_UNIFORM_KNOTS: + return StepKnotType.QuasiUniformKnots; + case PIECEWISE_BEZIER_KNOTS: + return StepKnotType.PiecewiseBezierKnots; + default: + return StepKnotType.Unspecified; + } + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepBoundedCurve.cs b/StgSharp.Model/STEP/Items/StepBoundedCurve.cs new file mode 100644 index 00000000..04b489c7 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepBoundedCurve.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepBoundedCurve.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepBoundedCurve : StepCurve + { + + protected StepBoundedCurve( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepCartesianPoint.cs b/StgSharp.Model/STEP/Items/StepCartesianPoint.cs new file mode 100644 index 00000000..492d2a62 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepCartesianPoint.cs @@ -0,0 +1,56 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepCartesianPoint.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public class StepCartesianPoint : StepTriple + { + + private StepCartesianPoint() { } + + public StepCartesianPoint( string label, float x, float y, float z ) + : base( label, x, y, z ) { } + + public override StepItemType ItemType => StepItemType.CartesianPoint; + + protected override int MinimumValueCount => 1; + + internal static StepCartesianPoint CreateFromSyntaxList( ExpNode syntaxList ) + { + return ( StepCartesianPoint )AssignTo( new StepCartesianPoint(), syntaxList ); + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepCircle.cs b/StgSharp.Model/STEP/Items/StepCircle.cs new file mode 100644 index 00000000..96fffd29 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepCircle.cs @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepCircle.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepCircle : StepConic + { + + private StepAxis2Placement _position; + + private StepCircle() : base( string.Empty ) { } + + public StepCircle( string label, StepAxis2Placement position, float radius ) + : base( label ) + { + Position = position; + Radius = radius; + } + + public float Radius { get; set; } + + public StepAxis2Placement Position + { + get { return _position; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _position = value; + } + } + + public override StepItemType ItemType => StepItemType.Circle; + + internal static StepCircle CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepCircle circle = new StepCircle(); + enumerator.AssertEnumeratorCount( 3 ); + circle.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => circle.Position = v.AsType() ); + circle.Radius = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value; + return circle; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Position; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepConic.cs b/StgSharp.Model/STEP/Items/StepConic.cs new file mode 100644 index 00000000..cf8d5bbe --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepConic.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepConic.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepConic : StepCurve + { + + protected StepConic( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepCurve.cs b/StgSharp.Model/STEP/Items/StepCurve.cs new file mode 100644 index 00000000..792a8c95 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepCurve.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepCurve.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepCurve : StepGeometricRepresentationItem + { + + protected StepCurve( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepCylindricalSurface.cs b/StgSharp.Model/STEP/Items/StepCylindricalSurface.cs new file mode 100644 index 00000000..18a80077 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepCylindricalSurface.cs @@ -0,0 +1,70 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepCylindricalSurface.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepCylindricalSurface : StepElementarySurface + { + + private StepCylindricalSurface() : base() { } + + public StepCylindricalSurface( string name, StepAxis2Placement3D position, float radius ) + : base( name, position ) + { + Radius = radius; + } + + public float Radius { get; set; } + + public override StepItemType ItemType => StepItemType.CylindricalSurface; + + internal static StepRepresentationItem CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + enumerator.AssertEnumeratorCount( 3 ); + StepCylindricalSurface surface = new StepCylindricalSurface(); + surface.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => surface.Position = v.AsType() ); + surface.Radius = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value; + return surface; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepDirection.cs b/StgSharp.Model/STEP/Items/StepDirection.cs new file mode 100644 index 00000000..d646ffa9 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepDirection.cs @@ -0,0 +1,55 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepDirection.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public class StepDirection : StepTriple + { + + private StepDirection() { } + + public StepDirection( string name, float x, float y, float z ) : base( name, x, y, z ) { } + + public override StepItemType ItemType => StepItemType.Direction; + + protected override int MinimumValueCount => 2; + + internal static StepDirection CreateFromSyntaxList( ExpNode syntaxList ) + { + return ( StepDirection )AssignTo( new StepDirection(), syntaxList ); + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepEdge.cs b/StgSharp.Model/STEP/Items/StepEdge.cs new file mode 100644 index 00000000..e5e01516 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepEdge.cs @@ -0,0 +1,68 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepEdge.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepEdge : StepTopologicalRepresentationItem + { + + protected StepEdge() : base( string.Empty ) { } + + protected StepEdge( string name, StepVertex edgeStart, StepVertex edgeEnd ) + : base( name ) + { + EdgeStart = edgeStart; + EdgeEnd = edgeEnd; + } + + public StepVertex EdgeStart { get; set; } + + public StepVertex EdgeEnd { get; set; } + + internal override IEnumerable GetReferencedItems() + { + if( EdgeStart != null ) { + yield return EdgeStart; + } + + if( EdgeEnd != null ) { + yield return EdgeEnd; + } + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepEdgeCurve.cs b/StgSharp.Model/STEP/Items/StepEdgeCurve.cs new file mode 100644 index 00000000..30088664 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepEdgeCurve.cs @@ -0,0 +1,102 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepEdgeCurve.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepEdgeCurve : StepEdge + { + + private StepCurve _edgeGeometry; + + private StepEdgeCurve() : base() { } + + public StepEdgeCurve( + string name, + StepVertex edgeStart, + StepVertex edgeEnd, + StepCurve edgeGeometry, + bool isSameSense ) + : base( name, edgeStart, edgeEnd ) + { + EdgeGeometry = edgeGeometry; + IsSameSense = isSameSense; + } + + public bool IsSameSense { get; set; } + + public StepCurve EdgeGeometry + { + get { return _edgeGeometry; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _edgeGeometry = value; + } + } + + public override StepItemType ItemType => StepItemType.EdgeCurve; + + internal static StepEdgeCurve CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepEdgeCurve edgeCurve = new StepEdgeCurve(); + enumerator.AssertEnumeratorCount( 5 ); + edgeCurve.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => edgeCurve.EdgeStart = v.AsType() ); + binder.BindValue( + enumerator.Values[ 2 ], v => edgeCurve.EdgeEnd = v.AsType() ); + binder.BindValue( + enumerator.Values[ 3 ], v => edgeCurve.EdgeGeometry = v.AsType() ); + edgeCurve.IsSameSense = ( enumerator.Values[ 4 ]as ExpBoolNode )!.Value; + return edgeCurve; + } + + internal override IEnumerable GetReferencedItems() + { + foreach( StepRepresentationItem item in base.GetReferencedItems() ) { + yield return item; + } + + yield return EdgeGeometry; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepEdgeLoop.cs b/StgSharp.Model/STEP/Items/StepEdgeLoop.cs new file mode 100644 index 00000000..60e10d19 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepEdgeLoop.cs @@ -0,0 +1,81 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepEdgeLoop.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System.Collections.Generic; +using System.Linq; + +namespace StgSharp.Modeling.Items +{ + public class StepEdgeLoop : StepLoop + { + + public StepEdgeLoop( string name, IEnumerable edgeList ) + : base( name ) + { + EdgeList = new List( edgeList ); + } + + public StepEdgeLoop( string name, params StepOrientedEdge[] edgeList ) + : this( name, ( IEnumerable )edgeList ) { } + + public List EdgeList { get; private set; } + + public override StepItemType ItemType => StepItemType.EdgeLoop; + + internal static StepEdgeLoop CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + enumerator.AssertEnumeratorCount( 2 ); + object edgeSyntaxList = enumerator.Values[ 1 ].GetValueList(); + StepEdgeLoop edgeLoop = new StepEdgeLoop( + string.Empty, new StepOrientedEdge[edgeSyntaxList.Values.Count] ); + edgeLoop.Name = enumerator.Values[ 0 ].GetStringValue(); + for( int i = 0; i < edgeSyntaxList.Values.Count; i++ ) + { + int j = i; // capture to avoid rebinding + binder.BindValue( + edgeSyntaxList.Values[ j ], + v => edgeLoop.EdgeList[ j ] = v.AsType() ); + } + + return edgeLoop; + } + + internal override IEnumerable GetReferencedItems() + { + return EdgeList; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepElementarySurface.cs b/StgSharp.Model/STEP/Items/StepElementarySurface.cs new file mode 100644 index 00000000..20ee49c2 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepElementarySurface.cs @@ -0,0 +1,72 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepElementarySurface.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepElementarySurface : StepSurface + { + + private StepAxis2Placement3D _position; + + protected StepElementarySurface() : base( string.Empty ) { } + + public StepElementarySurface( string name, StepAxis2Placement3D position ) + : base( name ) + { + Position = position; + } + + public StepAxis2Placement3D Position + { + get { return _position; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _position = value; + } + } + + internal override IEnumerable GetReferencedItems() + { + yield return Position; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepEllipse.cs b/StgSharp.Model/STEP/Items/StepEllipse.cs new file mode 100644 index 00000000..cb60931e --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepEllipse.cs @@ -0,0 +1,97 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepEllipse.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepEllipse : StepConic + { + + private StepAxis2Placement _position; + + private StepEllipse() : base( string.Empty ) { } + + public StepEllipse( + string name, + StepAxis2Placement position, + double semiAxis1, + double semiAxis2 ) + : base( name ) + { + Position = position; + SemiAxis1 = semiAxis1; + SemiAxis2 = semiAxis2; + } + + public double SemiAxis1 { get; set; } + + public double SemiAxis2 { get; set; } + + public StepAxis2Placement Position + { + get { return _position; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _position = value; + } + } + + public override StepItemType ItemType => StepItemType.Ellipse; + + internal static StepEllipse CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepEllipse ellipse = new StepEllipse(); + enumerator.AssertEnumeratorCount( 4 ); + ellipse.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => ellipse.Position = v.AsType() ); + ellipse.SemiAxis1 = ( enumerator.Values[ 2 ] as ExpRealNumberNode )!.Value; + ellipse.SemiAxis2 = ( enumerator.Values[ 3 ] as ExpRealNumberNode )!.Value; + return ellipse; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Position; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepFace.cs b/StgSharp.Model/STEP/Items/StepFace.cs new file mode 100644 index 00000000..029edd50 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepFace.cs @@ -0,0 +1,48 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepFace.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System.Collections.Generic; +using System.Linq; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepFace : StepTopologicalRepresentationItem + { + + public StepFace( string name ) : base( name ) { } + + public List Bounds { get; } = new List(); + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepFaceBound.cs b/StgSharp.Model/STEP/Items/StepFaceBound.cs new file mode 100644 index 00000000..71deebcb --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepFaceBound.cs @@ -0,0 +1,75 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepFaceBound.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepFaceBound : StepTopologicalRepresentationItem + { + + protected StepFaceBound() : base( string.Empty ) { } + + public StepFaceBound( string name, StepLoop bound, bool orientation ) + : base( name ) + { + Bound = bound; + Orientation = orientation; + } + + public bool Orientation { get; set; } + + public override StepItemType ItemType => StepItemType.FaceBound; + + public StepLoop Bound { get; set; } + + internal static StepFaceBound CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + enumerator.AssertEnumeratorCount( 3 ); + StepFaceBound faceBound = new StepFaceBound(); + faceBound.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( enumerator.Values[ 1 ], v => faceBound.Bound = v.AsType() ); + faceBound.Orientation = ( enumerator.Values[ 2 ]as ExpBoolNode )!.Value; + return faceBound; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Bound; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepFaceOuterBound.cs b/StgSharp.Model/STEP/Items/StepFaceOuterBound.cs new file mode 100644 index 00000000..2595531c --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepFaceOuterBound.cs @@ -0,0 +1,63 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepFaceOuterBound.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public class StepFaceOuterBound : StepFaceBound + { + + private StepFaceOuterBound() : base() { } + + public StepFaceOuterBound( string name, StepLoop bound, bool orientation ) + : base( name, bound, orientation ) { } + + public override StepItemType ItemType => StepItemType.FaceOuterBound; + + internal static new StepFaceOuterBound CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + enumerator.AssertEnumeratorCount( 3 ); + StepFaceOuterBound faceOuterBound = new StepFaceOuterBound(); + faceOuterBound.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => faceOuterBound.Bound = v.AsType() ); + faceOuterBound.Orientation = ( enumerator.Values[ 2 ]as ExpBoolNode )!.Value; + return faceOuterBound; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepFaceSurface.cs b/StgSharp.Model/STEP/Items/StepFaceSurface.cs new file mode 100644 index 00000000..3dd0d6b3 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepFaceSurface.cs @@ -0,0 +1,50 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepFaceSurface.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepFaceSurface : StepFace + { + + public StepFaceSurface( string name ) : base( name ) { } + + public bool SameSense { get; set; } + + public StepSurface FaceGeometry { get; set; } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepGeometricRepresentationItem.cs b/StgSharp.Model/STEP/Items/StepGeometricRepresentationItem.cs new file mode 100644 index 00000000..0e848cda --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepGeometricRepresentationItem.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepGeometricRepresentationItem.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepGeometricRepresentationItem : StepRepresentationItem + { + + protected StepGeometricRepresentationItem( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepItemType.cs b/StgSharp.Model/STEP/Items/StepItemType.cs new file mode 100644 index 00000000..9a2b3876 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepItemType.cs @@ -0,0 +1,131 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepItemType.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; + +namespace StgSharp.Modeling.Items +{ + public enum StepItemType + { + + AdvancedFace, + AxisPlacement2D, + AxisPlacement3D, + BSplineCurveWithKnots, + CartesianPoint, + Circle, + CylindricalSurface, + Direction, + EdgeCurve, + EdgeLoop, + Ellipse, + FaceBound, + FaceOuterBound, + Line, + OrientedEdge, + Plane, + Vector, + VertexPoint + + } + + internal static class StepItemTypeExtensions + { + + public const string AdvancedFaceText = "ADVANCED_FACE"; + public const string Axis2Placement2DText = "AXIS2_PLACEMENT_2D"; + public const string Axis2Placement3DText = "AXIS2_PLACEMENT_3D"; + public const string BSplineCurveWithKnotsText = "B_SPLINE_CURVE_WITH_KNOTS"; + public const string CartesianPointText = "CARTESIAN_POINT"; + public const string CircleText = "CIRCLE"; + public const string CylindricalSurfaceText = "CYLINDRICAL_SURFACE"; + public const string DirectionText = "DIRECTION"; + public const string EdgeCurveText = "EDGE_CURVE"; + public const string EdgeLoopText = "EDGE_LOOP"; + public const string EllipseText = "ELLIPSE"; + public const string FaceBoundText = "FACE_BOUND"; + public const string FaceOuterBoundText = "FACE_OUTER_BOUND"; + public const string LineText = "LINE"; + public const string OrientedEdgeText = "ORIENTED_EDGE"; + public const string PlaneText = "PLANE"; + public const string VectorText = "VECTOR"; + public const string VertexPointText = "VERTEX_POINT"; + + public static string GetItemTypeString( this StepItemType type ) + { + switch( type ) + { + case StepItemType.AdvancedFace: + return AdvancedFaceText; + case StepItemType.AxisPlacement2D: + return Axis2Placement2DText; + case StepItemType.AxisPlacement3D: + return Axis2Placement3DText; + case StepItemType.BSplineCurveWithKnots: + return BSplineCurveWithKnotsText; + case StepItemType.CartesianPoint: + return CartesianPointText; + case StepItemType.Circle: + return CircleText; + case StepItemType.CylindricalSurface: + return CylindricalSurfaceText; + case StepItemType.Direction: + return DirectionText; + case StepItemType.EdgeCurve: + return EdgeCurveText; + case StepItemType.EdgeLoop: + return EdgeLoopText; + case StepItemType.Ellipse: + return EllipseText; + case StepItemType.FaceBound: + return FaceBoundText; + case StepItemType.FaceOuterBound: + return FaceOuterBoundText; + case StepItemType.Line: + return LineText; + case StepItemType.OrientedEdge: + return OrientedEdgeText; + case StepItemType.Plane: + return PlaneText; + case StepItemType.Vector: + return VectorText; + case StepItemType.VertexPoint: + return VertexPointText; + default: + throw new InvalidOperationException( $"Unexpected item type {type}" ); + } + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepLine.cs b/StgSharp.Model/STEP/Items/StepLine.cs new file mode 100644 index 00000000..c30bdb41 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepLine.cs @@ -0,0 +1,124 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepLine.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Math; +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepLine : StepCurve + { + + private StepCartesianPoint _point; + private StepVector _vector; + + private StepLine() : base( string.Empty ) { } + + public StepLine( string label, StepCartesianPoint point, StepVector vector ) + : base( label ) + { + Point = point; + Vector = vector; + } + + public StepCartesianPoint Point + { + get { return _point; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _point = value; + } + } + + public override StepItemType ItemType => StepItemType.Line; + + public StepVector Vector + { + get { return _vector; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _vector = value; + } + } + + public static StepLine FromPoints( + float x1, + float y1, + float z1, + float x2, + float y2, + float z2 ) + { + StepCartesianPoint start = new StepCartesianPoint( string.Empty, x1, y1, z1 ); + float dx = x2 - x1; + float dy = y2 - y1; + float dz = z2 - z1; + float length = Scaler.Sqrt( dx * dx + dy * dy + dz * dz ); + float dxn = dx / length; + float dyn = dy / length; + float dzn = dz / length; + StepVector vector = new StepVector( + string.Empty, new StepDirection( string.Empty, dxn, dyn, dzn ), length ); + return new StepLine( string.Empty, start, vector ); + } + + internal static StepLine CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepLine line = new StepLine(); + enumerator.AssertEnumeratorCount( 3 ); + line.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => line.Point = v.AsType() ); + binder.BindValue( enumerator.Values[ 2 ], v => line.Vector = v.AsType() ); + return line; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Point; + yield return Vector; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepLoop.cs b/StgSharp.Model/STEP/Items/StepLoop.cs new file mode 100644 index 00000000..1823e9c1 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepLoop.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepLoop.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepLoop : StepTopologicalRepresentationItem + { + + public StepLoop( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepOrientedEdge.cs b/StgSharp.Model/STEP/Items/StepOrientedEdge.cs new file mode 100644 index 00000000..6ceb017c --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepOrientedEdge.cs @@ -0,0 +1,104 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepOrientedEdge.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepOrientedEdge : StepEdge + { + + private StepEdge _edgeElement; + + private StepOrientedEdge() { } + + public StepOrientedEdge( + string name, + StepVertex edgeStart, + StepVertex edgeEnd, + StepEdge edgeElement, + bool orientation ) + : base( name, edgeStart, edgeEnd ) + { + EdgeElement = edgeElement; + Orientation = orientation; + } + + public bool Orientation { get; set; } + + public StepEdge EdgeElement + { + get { return _edgeElement; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _edgeElement = value; + } + } + + public override StepItemType ItemType => StepItemType.OrientedEdge; + + internal static StepOrientedEdge CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepOrientedEdge orientedEdge = new StepOrientedEdge(); + enumerator.AssertEnumeratorCount( 5 ); + orientedEdge.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => orientedEdge.EdgeStart = v.AsType() ); + binder.BindValue( + enumerator.Values[ 2 ], v => orientedEdge.EdgeEnd = v.AsType() ); + binder.BindValue( + enumerator.Values[ 3 ], v => orientedEdge.EdgeElement = v.AsType() ); + orientedEdge.Orientation = ( enumerator.Values[ 4 ]as ExpBoolNode )!.Value; + return orientedEdge; + } + + internal override IEnumerable GetReferencedItems() + { + foreach( StepRepresentationItem item in base.GetReferencedItems() ) { + yield return item; + } + + yield return EdgeElement; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepPlacement.cs b/StgSharp.Model/STEP/Items/StepPlacement.cs new file mode 100644 index 00000000..1fc765d4 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepPlacement.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepPlacement.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepPlacement : StepGeometricRepresentationItem + { + + protected StepPlacement( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepPlane.cs b/StgSharp.Model/STEP/Items/StepPlane.cs new file mode 100644 index 00000000..1c5bddd9 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepPlane.cs @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepPlane.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- + +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public class StepPlane : StepElementarySurface + { + + private StepPlane() : base() { } + + public StepPlane( string name, StepAxis2Placement3D position ) : base( name, position ) { } + + public override StepItemType ItemType => StepItemType.Plane; + + internal static StepPlane CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepPlane plane = new StepPlane(); + enumerator.AssertEnumeratorCount( 2 ); + plane.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => plane.Position = v.AsType() ); + return plane; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepPoint.cs b/StgSharp.Model/STEP/Items/StepPoint.cs new file mode 100644 index 00000000..1a139eb4 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepPoint.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepPoint.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepPoint : StepGeometricRepresentationItem + { + + protected StepPoint( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepRepresentationItem.cs b/StgSharp.Model/STEP/Items/StepRepresentationItem.cs new file mode 100644 index 00000000..0c27adc4 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepRepresentationItem.cs @@ -0,0 +1,58 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepRepresentationItem.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; + +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public abstract partial class StepRepresentationItem + { + + protected StepRepresentationItem( string name ) + { + Name = name; + } + + public abstract StepItemType ItemType { get; } + + public string Name { get; set; } + + internal virtual IEnumerable GetReferencedItems() + { + yield break; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepRepresentationItem_FromTypedParameter.cs b/StgSharp.Model/STEP/Items/StepRepresentationItem_FromTypedParameter.cs new file mode 100644 index 00000000..dcaf97f7 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepRepresentationItem_FromTypedParameter.cs @@ -0,0 +1,127 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepRepresentationItem_FromTypedParameter.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System.Collections.Generic; +using System.Diagnostics; + +namespace StgSharp.Modeling.Items +{ + public abstract partial class StepRepresentationItem + { + + internal static HashSet UnsupportedItemTypes { get; } = new HashSet(); + + internal static StepRepresentationItem FromTypedParameter( + StepBinder binder, + ExpNode itemSyntax ) + { + StepRepresentationItem item = null!; + if( itemSyntax is ExpElementInitializingNode initNode ) + { + string name = initNode.EqualityTypeConvert.Name; + switch( name ) + { + case StepItemTypeExtensions.AdvancedFaceText: + item = StepAdvancedFace.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.Axis2Placement2DText: + item = StepAxis2Placement2D.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.Axis2Placement3DText: + item = StepAxis2Placement3D.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.BSplineCurveWithKnotsText: + item = StepBSplineCurveWithKnots.CreateFromSyntaxList( + binder, initNode.Right ); + break; + case StepItemTypeExtensions.CartesianPointText: + item = StepCartesianPoint.CreateFromSyntaxList( initNode.Right ); + break; + case StepItemTypeExtensions.CircleText: + item = StepCircle.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.CylindricalSurfaceText: + item = StepCylindricalSurface.CreateFromSyntaxList( binder, + initNode.Right ); + break; + case StepItemTypeExtensions.DirectionText: + item = StepDirection.CreateFromSyntaxList( initNode.Right ); + break; + case StepItemTypeExtensions.EdgeCurveText: + item = StepEdgeCurve.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.EdgeLoopText: + item = StepEdgeLoop.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.EllipseText: + item = StepEllipse.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.FaceBoundText: + item = StepFaceBound.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.FaceOuterBoundText: + item = StepFaceOuterBound.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.LineText: + item = StepLine.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.OrientedEdgeText: + item = StepOrientedEdge.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.PlaneText: + item = StepPlane.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.VectorText: + item = StepVector.CreateFromSyntaxList( binder, initNode.Right ); + break; + case StepItemTypeExtensions.VertexPointText: + item = StepVertexPoint.CreateFromSyntaxList( binder, initNode.Right ); + break; + default: + if( UnsupportedItemTypes.Add( name ) ) { + Debug.WriteLine( + $"Unsupported item {name} at {initNode.Line}, {initNode.Column}" ); + } + break; + } + } else + { + // TODO: + } + + return item; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepSurface.cs b/StgSharp.Model/STEP/Items/StepSurface.cs new file mode 100644 index 00000000..c56b3977 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepSurface.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepSurface.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepSurface : StepGeometricRepresentationItem + { + + public StepSurface( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepTopologicalRepresentationItem.cs b/StgSharp.Model/STEP/Items/StepTopologicalRepresentationItem.cs new file mode 100644 index 00000000..84981222 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepTopologicalRepresentationItem.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepTopologicalRepresentationItem.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepTopologicalRepresentationItem : StepRepresentationItem + { + + protected StepTopologicalRepresentationItem( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepTriple.cs b/StgSharp.Model/STEP/Items/StepTriple.cs new file mode 100644 index 00000000..50935c30 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepTriple.cs @@ -0,0 +1,128 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepTriple.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Math; + +using StgSharp.Script; +using StgSharp.Script.Express; + +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepTriple : StepPoint + { + + private Vec3 _coord; + + protected StepTriple() : this( string.Empty, 0.0f, 0.0f, 0.0f ) { } + + protected StepTriple( string name, float x, float y, float z ) + : base( name ) + { + X = x; + Y = y; + Z = z; + } + + public float X + { + get => _coord.X; + set => _coord.X = value; + } + + public float Y + { + get => _coord.Y; + set => _coord.Y = value; + } + + public float Z + { + get => _coord.Z; + set => _coord.Z = value; + } + + protected abstract int MinimumValueCount { get; } + + public bool Equals( StepTriple other ) + { + if( ( object )other == null ) { + return false; + } + + return ItemType == other.ItemType && X == other.X && Y == other.Y && Z == other.Z && Name == + other.Name; + } + + public override bool Equals( object obj ) + { + return ( obj is StepTriple triple ) && Equals( triple ); + } + + public override int GetHashCode() + { + return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); + } + + internal static StepTriple AssignTo( StepTriple triple, ExpNode values ) + { + ExpNodeNextEnumerator enumerator = values.GetEnumerator(); + enumerator.AssertEnumeratorCount( 2 ); + triple.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + object pointValues = enumerator.Values[ 1 ].GetValueList(); + pointValues.AssertEnumeratorCount( triple.MinimumValueCount, 3 ); + triple.X = pointValues.GetRealValueOrDefault( 0 ); + triple.Y = pointValues.GetRealValueOrDefault( 1 ); + triple.Z = pointValues.GetRealValueOrDefault( 2 ); + return triple; + } + + public static bool operator !=( StepTriple left, StepTriple right ) + { + return !( left == right ); + } + + public static bool operator ==( StepTriple left, StepTriple right ) + { + if( ReferenceEquals( left, right ) ) { + return true; + } + + if( ( object )left == null || ( object )right == null ) { + return false; + } + + return left.Equals( right ); + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepVector.cs b/StgSharp.Model/STEP/Items/StepVector.cs new file mode 100644 index 00000000..08769c67 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepVector.cs @@ -0,0 +1,89 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepVector.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepVector : StepGeometricRepresentationItem + { + + private StepDirection _direction; + + private StepVector() : base( string.Empty ) { } + + public StepVector( string name, StepDirection direction, double length ) + : base( name ) + { + Direction = direction; + Length = length; + } + + public double Length { get; set; } + + public StepDirection Direction + { + get { return _direction; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _direction = value; + } + } + + public override StepItemType ItemType => StepItemType.Vector; + + internal static StepVector CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepVector vector = new StepVector(); + enumerator.AssertEnumeratorCount( 3 ); + vector.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => vector.Direction = v.AsType() ); + vector.Length = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value; + return vector; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Direction; + } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepVertex.cs b/StgSharp.Model/STEP/Items/StepVertex.cs new file mode 100644 index 00000000..3d92505b --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepVertex.cs @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepVertex.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +namespace StgSharp.Modeling.Items +{ + public abstract class StepVertex : StepTopologicalRepresentationItem + { + + protected StepVertex( string name ) : base( name ) { } + + } +} + diff --git a/StgSharp.Model/STEP/Items/StepVertexPoint.cs b/StgSharp.Model/STEP/Items/StepVertexPoint.cs new file mode 100644 index 00000000..fa357880 --- /dev/null +++ b/StgSharp.Model/STEP/Items/StepVertexPoint.cs @@ -0,0 +1,87 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="StepVertexPoint.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the ¡°Software¡±), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED ¡°AS IS¡±, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using StgSharp.Script; +using StgSharp.Script.Express; + +using System; +using System.Collections.Generic; + +namespace StgSharp.Modeling.Items +{ + public class StepVertexPoint : StepVertex + { + + private StepCartesianPoint _location; + + private StepVertexPoint() : base( string.Empty ) { } + + public StepVertexPoint( string name, StepCartesianPoint location ) + : base( name ) + { + Location = location; + } + + public StepCartesianPoint Location + { + get { return _location; } + set + { + if( value == null ) { + throw new ArgumentNullException(); + } + + _location = value; + } + } + + public override StepItemType ItemType => StepItemType.VertexPoint; + + internal static StepVertexPoint CreateFromSyntaxList( + StepBinder binder, + ExpNode syntaxList ) + { + ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList ); + StepVertexPoint vertex = new StepVertexPoint(); + enumerator.AssertEnumeratorCount( 2 ); + vertex.Name = enumerator.Values[ 0 ].CodeConvertTemplate; + binder.BindValue( + enumerator.Values[ 1 ], v => vertex.Location = v.AsType() ); + return vertex; + } + + internal override IEnumerable GetReferencedItems() + { + yield return Location; + } + + } +} + diff --git a/StgSharp.Model/STEP/Reader/StepDataReader.cs b/StgSharp.Model/STEP/Reader/StepDataReader.cs index 7ed3ad6e..f004eb74 100644 --- a/StgSharp.Model/STEP/Reader/StepDataReader.cs +++ b/StgSharp.Model/STEP/Reader/StepDataReader.cs @@ -43,9 +43,8 @@ namespace StgSharp.Modeling.STEP { public partial class StepReader { - private Regex expressionSpilitter = new Regex( - @"^#(?[0-9]+)\s*?=\s*?(?\S.*?)\s*;$", - RegexOptions.Compiled ); + + private Regex expressionSpilitter = GetExpressionSplitter(); private ThreadLocal> _codeLineQueue = new ThreadLocal>(); @@ -57,35 +56,35 @@ namespace StgSharp.Modeling.STEP public void ReadDataSection() { - if (_codeLineQueue.Value == null) - { + if( _codeLineQueue.Value == null ) { _codeLineQueue.Value = new ConcurrentQueue(); } - using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream( - 0, _size, MemoryMappedFileAccess.Read)) + using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream( + 0, _size, MemoryMappedFileAccess.Read ) ) { - using (StreamReader sr = new StreamReader(ms)) + using( StreamReader sr = new StreamReader( ms ) ) { long pos = _headStart; string line; - while (string.IsNullOrEmpty(line = sr.ReadLine())) + while( string.IsNullOrEmpty( line = sr.ReadLine()! ) ) { - switch (line) + Match match = expressionSpilitter.Match( line ); + if( match.Success ) { - default: - break; - } - Match match = expressionSpilitter.Match(line); - if (match.Success) - { - int id = int.Parse(match.Groups["id"].Value); - string expression = match.Groups["expression"].Value; - StepCodeLine stepExpression = new StepCodeLine(id, expression); - _codeLineQueue.Value.Enqueue(stepExpression); + int id = int.Parse( match.Groups[ "id" ].Value ); + string expression = match.Groups[ "expression" ].Value; + StepCodeLine stepExpression = new StepCodeLine( id, expression ); + _codeLineQueue.Value.Enqueue( stepExpression ); } } } } } + + [GeneratedRegex( + @"^#(?[0-9]+)\s*?=\s*?(?\S.*?)\s*;$", + RegexOptions.Compiled | RegexOptions.Singleline )] + private static partial Regex GetExpressionSplitter(); + } } diff --git a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs index 418eb6fd..b616e550 100644 --- a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs +++ b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d270b6b1f8220e14d01610bd55f11c0b4908af39")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Model")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json index fb815ce1..2440bc0f 100644 --- a/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json +++ b/StgSharp.Model/obj/x64/Debug/net8.0/StgSharp.Model.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/d270b6b1f8220e14d01610bd55f11c0b4908af39/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} \ No newline at end of file diff --git a/StgSharp.Script/Common/CompileStack.cs b/StgSharp.Script/Common/CompileStack.cs index 4b29cf16..2df13343 100644 --- a/StgSharp.Script/Common/CompileStack.cs +++ b/StgSharp.Script/Common/CompileStack.cs @@ -42,6 +42,8 @@ namespace StgSharp.Script where TType: ITypeSource { + private Token? _lastToken; + private TNode[] _nodeArray = new TNode[4]; private Token[] _operatorArray = new Token[4]; private Token[] _tokenArray = new Token[4]; @@ -51,6 +53,7 @@ namespace StgSharp.Script private Stack _isNode = new Stack(); private Stack> _statementCache = new Stack>(); + private TNode _lastNode; public CompileStack() { @@ -58,6 +61,8 @@ namespace StgSharp.Script _statementCache.Push( new Stack() ); } + public bool IsLastAddedOperator { get; private set; } + public CompileDepthMark CurrentDepthMark { get => _depthStack.Peek(); @@ -180,6 +185,7 @@ namespace StgSharp.Script _nodeArray[ _nodeCount ] = node; _nodeCount++; _isNode.Push( true ); + IsLastAddedOperator = false; } public void PushOperand( Token token ) @@ -190,6 +196,7 @@ namespace StgSharp.Script _tokenArray[ _tokenCount ] = token; _tokenCount++; _isNode.Push( false ); + IsLastAddedOperator = false; } public void PushOperator( Token token ) @@ -199,6 +206,7 @@ namespace StgSharp.Script } _operatorArray[ _operatorCount ] = token; _operatorCount++; + IsLastAddedOperator = true; } public T StateOfCurrentDepth() where T: class, ICompileDepthState diff --git a/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs b/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs new file mode 100644 index 00000000..d391bb72 --- /dev/null +++ b/StgSharp.Script/Express/ExpAstNode/ExpElementInitializingNode.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="ExpElementInitializingNode.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.Script.Express +{ + public class ExpElementInitializingNode : ExpNode + { + + private ExpMetaRefNode _type; + private ExpNode _init; + + public ExpElementInitializingNode( + Token source, + ExpMetaRefNode type, + ExpNode initParameter ) + : base( source ) + { + _type = type; + _init = initParameter; + } + + public override ExpNode Left => _type; + + public override ExpNode Right => _init; + + public override IExpElementSource EqualityTypeConvert => _type.SourceRef; + + } +} diff --git a/StgSharp.Script/Express/ExpElmentSource.cs b/StgSharp.Script/Express/ExpElmentSource.cs index 4e1add85..8b517fa0 100644 --- a/StgSharp.Script/Express/ExpElmentSource.cs +++ b/StgSharp.Script/Express/ExpElmentSource.cs @@ -45,6 +45,8 @@ namespace StgSharp.Script.Express string Name { get; } + public void AddMember( string name, ExpNode memberNode ); + public void Analyse(); public bool TryGetMember( string name, out ExpNode memberNode ); diff --git a/StgSharp.Script/Express/ExpNodeNextEnumerator.cs b/StgSharp.Script/Express/ExpNodeNextEnumerator.cs index 59af23cb..63dc3bc7 100644 --- a/StgSharp.Script/Express/ExpNodeNextEnumerator.cs +++ b/StgSharp.Script/Express/ExpNodeNextEnumerator.cs @@ -28,6 +28,8 @@ // //----------------------------------------------------------------------- //----------------------------------------------------------------------- +using Microsoft.CodeAnalysis.CSharp.Syntax; + using System; using System.Collections; using System.Collections.Generic; @@ -40,13 +42,40 @@ namespace StgSharp.Script.Express public class ExpNodeNextEnumerator : IEnumerator { - private ExpNode _begin; private ExpNode _current; + private List _begin = new List(); + public ExpNodeNextEnumerator( ExpNode token ) { - _begin = token; + _begin[ 0 ] = token; _current = token; + ExpNode t = token; + while( !ReferenceEquals( t.Next, token ) && t.Next != null ) + { + t = t.Next; + _begin.Add( t ); + } + } + + public ExpNode this[ int index ] + { + get + { + ArgumentOutOfRangeException.ThrowIfNegative( index ); + ArgumentOutOfRangeException.ThrowIfGreaterThan( index, _begin.Count ); + return _begin[ index ]; + } + } + + public List Values => _begin; + + public void AssertEnumeratorCount( int count ) + { + if( _begin.Count != count ) { + throw new InvalidOperationException( + $"Enumerator count mismatch. Expected {count}, but got {_begin.Count}." ); + } } void IDisposable.Dispose() @@ -66,13 +95,12 @@ namespace StgSharp.Script.Express void IEnumerator.Reset() { - _current = _begin; + _current = _begin[ 0 ]; } - object IEnumerator.Current => throw new NotImplementedException(); + object IEnumerator.Current => _current; - ExpNode IEnumerator.Current => throw new NotImplementedException( - ); + ExpNode IEnumerator.Current => _current; } } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs index d58e4b77..76a6e256 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.Common.cs @@ -113,7 +113,6 @@ namespace StgSharp.Script.Express } //Many thing miss here - _cache.PushOperand( ExpElementMemberNameNode.Create( t ) ); return true; @@ -258,6 +257,17 @@ namespace StgSharp.Script.Express { _cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) ); return true; + } else if( _cache.IsLastAddedOperator ) + { + if( _cache.PeekOperand( out _, + out ExpNode? typenode ) && typenode is ExpMetaRefNode typeRef ) + { + _cache.PopOperand( out _, out _ ); + _local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) ); + } else + { + return false; + } } return false; } diff --git a/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs b/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs index 954e9813..29d9b7a3 100644 --- a/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs +++ b/StgSharp.Script/Express/ExpSyntaxAnalyzer.cs @@ -53,7 +53,6 @@ namespace StgSharp.Script.Express private CompileStack _cache; private ExpNode _lastStatement; - private ExpSchema _context; private IExpElementSource _local; @@ -107,8 +106,9 @@ namespace StgSharp.Script.Express case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary: TryAppendSymbol( expToken ); break; - case TokenFlag.Member: - TryAppendMember( expToken ); + case TokenFlag.Number or TokenFlag.String: + ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); + _cache.PushOperand( node ); break; case TokenFlag.Separator_Left: TryAppendPrefixSeparator( expToken ); @@ -125,9 +125,8 @@ namespace StgSharp.Script.Express case TokenFlag.Index_Right: TryAppendIndexRight( expToken ); break; - case TokenFlag.Number or TokenFlag.String: - ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken ); - _cache.PushOperand( node ); + case TokenFlag.Member: + TryAppendMember( expToken ); break; default: break; diff --git a/StgSharp.Script/Express/IExpMarshalType.cs b/StgSharp.Script/Express/IExpMarshalType.cs new file mode 100644 index 00000000..8acb4506 --- /dev/null +++ b/StgSharp.Script/Express/IExpMarshalType.cs @@ -0,0 +1,45 @@ +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +// file="IExpMarshalType.cs" +// Project: StgSharp +// AuthorGroup: Nitload Space +// Copyright (c) Nitload Space. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the “Software”), to deal in the Software without restriction, +// including without limitation the rights to use, copy, modify, merge, +// publish, distribute, sublicense, and/or sell copies of the Software, +// and to permit persons to whom the Software is furnished to do so, +// subject to the following conditions: +// +// The above copyright notice and +// this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED “AS IS”, +// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH +// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +//----------------------------------------------------------------------- +//----------------------------------------------------------------------- +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace StgSharp.Script.Express +{ + public interface IExpMarshalType + { + + static abstract TSelf Create( string name, ExpNode node ); + + } +} diff --git a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs index 744f594d..dc76c632 100644 --- a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs +++ b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+a4b2e9a8056c03f25a0aa3136f09d28ba86763fe")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharp.Script")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json index d16a784c..2440bc0f 100644 --- a/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json +++ b/StgSharp.Script/obj/x64/Debug/net8.0/StgSharp.Script.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/7b7b5ee475ba81a574fedf4772a213a798ba4c27/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} \ No newline at end of file diff --git a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs index 5eded2dc..69538707 100644 --- a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs +++ b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.AssemblyInfo.cs @@ -14,7 +14,7 @@ using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] -[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d270b6b1f8220e14d01610bd55f11c0b4908af39")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+2692495dc8460e1f60a2d073f162c5f526e1ba1b")] [assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] diff --git a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json index fb815ce1..2440bc0f 100644 --- a/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json +++ b/StgSharpDebug/obj/x64/Debug/net8.0/StgSharpDebug.sourcelink.json @@ -1 +1 @@ -{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/d270b6b1f8220e14d01610bd55f11c0b4908af39/*"}} \ No newline at end of file +{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\内核源代码\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/2692495dc8460e1f60a2d073f162c5f526e1ba1b/*"}} \ No newline at end of file