Better L4 and array storage design

This commit is contained in:
Youmu Liu
2026-03-04 18:12:58 +08:00
parent 7e970352ab
commit dfa6f4ba92
103 changed files with 853 additions and 6837 deletions
+60 -36
View File
@@ -1,30 +1,27 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="Platform.cs"
// file="Platform"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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.
// 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.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@@ -64,31 +61,41 @@ namespace StgSharp
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogError(Exception ex)
public static void LogError(
Exception ex
)
{
DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogInfo(string log)
public static void LogInfo(
string log
)
{
DefaultLog.InternalWriteLog(log, LogType.Info);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(string log)
public static void LogWarning(
string log
)
{
DefaultLog.InternalWriteLog(log, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void LogWarning(Exception notVerySeriesException)
public static void LogWarning(
Exception notVerySeriesException
)
{
DefaultLog.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Mark(bool needConsole)
public static void Mark(
bool needConsole
)
{
markCount++;
if (needConsole) {
@@ -96,7 +103,9 @@ namespace StgSharp
}
}
public static void Terminate(int exitCode)
public static void Terminate(
int exitCode
)
{
MainTimeProvider.StopProvidingTime();
@@ -110,7 +119,8 @@ namespace StgSharp
bool isConsole,
[CallerFilePath] string filePath = "",
[CallerMemberName] string callerName = "",
[CallerLineNumber] int lineNumber = 0)
[CallerLineNumber] int lineNumber = 0
)
{
Type t = target.GetType();
string log = $"Tracked object: {nameof(target)}\t\tType:{t.Name}\n";
@@ -141,12 +151,17 @@ namespace StgSharp
/// The severity of current message.
/// </param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void WriteLog(string message, LogType logType)
public static void WriteLog(
string message,
LogType logType
)
{
DefaultLog.InternalWriteLog(message, logType);
}
internal static TDele ConvertAPI<TDele>(IntPtr funcPtr)
internal static TDele ConvertAPI<TDele>(
IntPtr funcPtr
)
{
if (funcPtr == IntPtr.Zero) {
throw new InvalidCastException(
@@ -162,7 +177,10 @@ namespace StgSharp
}
}
internal static Delegate ConvertAPI(IntPtr funcPtr, Type T)
internal static Delegate ConvertAPI(
IntPtr funcPtr,
Type T
)
{
if (funcPtr == IntPtr.Zero) {
throw new InvalidCastException(
@@ -199,14 +217,20 @@ namespace StgSharp
internal class Initializer : IStaticModule
{
public string ModuleName => "StgSharp";
public string ModuleName => "StgSharpCore";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void InitializeModule()
public void InitializeModule(
IModuleInitializeProfile profile
)
{
World.InternalInitialize();
}
public void UninitializeModule()
{
throw new NotImplementedException();
}
}
}
@@ -151,6 +151,24 @@ L4 缓存器是一个纯软件实现的**线程本地数据缓存层**,
- 所在热度级别
- 单链表的 next 指针
### 3.5 并发模型
L4 采用「**部分并发**」设计:
| 操作 | 执行者 | 并发性 |
|---|---|---|
| Lookup(Swiss Table 读) | 各工作线程 | ✅ 完全并行 |
| Load(Slab分配+插入) | L4 服务线程 | 串行(单消费者) |
| Evict(逐出+可选写回) | L4 服务线程 | 串行 |
| Flush(dirty批量写回) | MatrixParallelWrap | 计算任务结束后单次执行 |
**Swiss Table 并发读安全保证**:服务线程插入时遵守严格写顺序:
先写 key/value,`sfence`,再写控制字节,确保工作线程
读到控制字节时 key/value 已完整可见。
**热度更新简化**:热度仅在 Load 时由服务线程设置,
Lookup 命中时不修改热度,确保 Lookup 路径零写操作。
---
## 4. 操作流程
@@ -1,9 +1,9 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityDefineSequence"
// file="ISimpleStateMachine"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -25,29 +25,32 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
namespace StgSharp.State
{
public record class StepEntityDefineSequence
public interface ISimpleStateMachine<TStateNode, TStateLabel, TStateContext>
where TStateNode : SimpleStateMachineNode<TStateNode, TStateLabel, TStateContext>
where TStateLabel : unmanaged, IEquatable<TStateLabel>
where TStateContext : StateContext
{
public StepEntityDefineSequence(ExpSyntaxNode node, IEnumerable<int> dep)
{
Expression = node;
Dependencies = dep;
}
TStateNode this[
TStateLabel label
] { get; }
public ExpSyntaxNode Expression { get; init; }
ref readonly TStateNode GetCurrentStateNode();
public IEnumerable<int> Dependencies { get; init; }
void Reset();
bool TryMoveNext(
TStateContext ctx
);
}
}
@@ -1,9 +1,9 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess"
// file="SimpleStateMachineNode"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -28,26 +28,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
namespace StgSharp.State
{
internal partial class StepExpSyntaxAnalyzer
public abstract class SimpleStateMachineNode<TSelf, TLabel, TStateContext>
where TSelf : SimpleStateMachineNode<TSelf, TLabel, TStateContext>
where TLabel : unmanaged, IEquatable<TLabel>
where TStateContext : StateContext
{
public void ThrowCompileException(int errorCode)
{
switch (errorCode)
{
case 0 or 1:
return;
case TokenTypeNotMatch:
throw new Exception();
default:
break;
}
}
private readonly List<int> _jumpTable = [];
public ReadOnlySpan<int> AvailableNodes => CollectionsMarshal.AsSpan(_jumpTable);
public abstract bool IsValidateFrom(
TSelf former,
TStateContext context
);
public abstract bool TryTransaction(
ReadOnlySpan<TSelf> nodeSpan,
TStateContext context,
out TLabel label
);
}
}
+40
View File
@@ -0,0 +1,40 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StateContext.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.State
{
public abstract class StateContext { }
}
@@ -25,7 +25,6 @@
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphics;
@@ -49,7 +48,11 @@ namespace StgSharp.Geometries
vertexMat = new Vec4[3];
}
public Triangle(Point vertex01, Point vertex02, Point vertex03)
public Triangle(
Point vertex01,
Point vertex02,
Point vertex03
)
: base(PlainCoordinate.StandardPlainCoordination)
{
this[0] = vertex01;
@@ -57,7 +60,12 @@ namespace StgSharp.Geometries
this[2] = vertex03;
}
public Triangle(PlainCoordinate coordination, Point vertex01, Point vertex02, Point vertex03)
public Triangle(
PlainCoordinate coordination,
Point vertex01,
Point vertex02,
Point vertex03
)
: base(coordination)
{
this[0] = vertex01;
@@ -65,7 +73,14 @@ namespace StgSharp.Geometries
this[2] = vertex03;
}
public Triangle(float v0x, float v0y, float v1x, float v1y, float v2x, float v2y)
public Triangle(
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y
)
: base(PlainCoordinate.StandardPlainCoordination)
{
this[0] = new Point(v0x, v0y, 0);
@@ -73,7 +88,15 @@ namespace StgSharp.Geometries
this[2] = new Point(v2x, v2y, 0);
}
public Triangle(PlainCoordinate coordination, float v0x, float v0y, float v1x, float v1y, float v2x, float v2y)
public Triangle(
PlainCoordinate coordination,
float v0x,
float v0y,
float v1x,
float v1y,
float v2x,
float v2y
)
: base(coordination)
{
this[0] = new Point(v0x, v0y, 0);
@@ -31,33 +31,16 @@ using System.Runtime.InteropServices;
namespace StgSharp.Mathematics.Internal
{
[InlineArray(10)]
internal unsafe struct MatrixIntrinsic
{
private nint handle; //f32_panel_mul
public readonly nint this[
MatrixIntrinsicHandle handle
]
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => this[(int)handle];
}
}
internal enum MatrixIntrinsicHandle : int
{
BufferAdd = 0,
BufferFill = 1,
BufferScalarMul = 2,
BufferSub = 3,
BufferTranspose = 4,
Add = 0,
Fill = 1,
ScalarMul = 2,
Sub = 3,
Transpose = 4,
ClearPanel = 5,
KerFma = 6,
TileFma = 7,
Fma = 6,
Pivot = 8,
}
@@ -66,18 +49,18 @@ namespace StgSharp.Mathematics.Internal
public struct MatrixElementType
{
public const int IntrinsicCount = 0xa;
public const int IntrinsicCount = 0x0a;
public static readonly MatrixElementType F32 = new(0x00010004);
public static readonly MatrixElementType F64 = new(0x00020008);
public static readonly MatrixElementType I08 = new(0x00030001);
public static readonly MatrixElementType I16 = new(0x00040002);
public static readonly MatrixElementType I32 = new(0x00050004);
public static readonly MatrixElementType I64 = new(0x00060008);
public static readonly MatrixElementType U08 = new(0x00070001);
public static readonly MatrixElementType U16 = new(0x00080002);
public static readonly MatrixElementType U32 = new(0x00090004);
public static readonly MatrixElementType U64 = new(0x000a0008);
public static readonly MatrixElementType F32 = new(0x00000004);
public static readonly MatrixElementType F64 = new(0x00010008);
public static readonly MatrixElementType I08 = new(0x00020001);
public static readonly MatrixElementType I16 = new(0x00030002);
public static readonly MatrixElementType I32 = new(0x00040004);
public static readonly MatrixElementType I64 = new(0x00050008);
public static readonly MatrixElementType U08 = new(0x00060001);
public static readonly MatrixElementType U16 = new(0x00070002);
public static readonly MatrixElementType U32 = new(0x00080004);
public static readonly MatrixElementType U64 = new(0x00090008);
[FieldOffset(0)] internal readonly int Mask;
[FieldOffset(2)] public readonly ushort IntrinsicNode;
@@ -96,14 +79,6 @@ namespace StgSharp.Mathematics.Internal
}
[InlineArray(MatrixElementType.IntrinsicCount)]
internal unsafe struct MatrixIntrinsicArray
{
private MatrixIntrinsic e0;
}
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct IntrinsicContext
{
@@ -112,7 +87,8 @@ namespace StgSharp.Mathematics.Internal
public delegate* unmanaged[Cdecl]<int, ulong> factorial_simd; // factorial_simd
public delegate* unmanaged[Cdecl]<char*, int, int, int> index_pair; // index_pair
public delegate* unmanaged[Cdecl]<Vector4*, Vector4*, void> vec_f32_normalize_3; // f32_normalize_3
public MatrixIntrinsicArray mat; // mat[4] in native order
public MatrixMultiKernelIntrinsicArray mat_mk; // mat[4] in native order
public MatrixSingleKernelIntrinsicArray mat_sk; // mat[4] in native order
public IntrinsicContext()
{
@@ -120,4 +96,79 @@ namespace StgSharp.Mathematics.Internal
}
}
#region mk
[InlineArray(10)]
internal unsafe struct MatrixMultiKernelIntrinsic
{
private nint handle; //f32_panel_mul
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void Call(
MatrixIntrinsicHandle index,
MatrixParallelTask* task
)
{
nint ptr = this[(int)index];
((delegate* unmanaged[Cdecl]<MatrixParallelTask*, void>)ptr)(task);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly nint Get(
MatrixIntrinsicHandle index
)
{
return this[(int)index];
}
}
[InlineArray(MatrixElementType.IntrinsicCount)]
internal unsafe struct MatrixMultiKernelIntrinsicArray
{
private MatrixMultiKernelIntrinsic e0;
}
#endregion
#region sk
[InlineArray(10)]
internal unsafe struct MatrixSingleKernelIntrinsic
{
private nint handle; //f32_panel_mul
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void Call(
MatrixIntrinsicHandle index,
MatrixKernel* left,
MatrixKernel* right,
MatrixKernel* ans,
ulong scalar
)
{
nint ptr = this[(int)index];
((delegate* unmanaged[Cdecl]<MatrixKernel*, MatrixKernel*, MatrixKernel*, ulong, void>)ptr)(left,
right,
ans,
scalar);
}
}
[InlineArray(MatrixElementType.IntrinsicCount)]
internal unsafe struct MatrixSingleKernelIntrinsicArray
{
private MatrixSingleKernelIntrinsic e0;
}
#endregion
}
@@ -1,60 +1,62 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelTask"
// 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.Mathematics;
using StgSharp.Mathematics.Intrinsic;
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StgSharp.Mathematics.Numeric
{
[StructLayout(LayoutKind.Explicit)]
internal unsafe struct MatrixParallelTask
{
[FieldOffset(0)]public MatrixKernel* Mat1; // 8
[FieldOffset(8)] public MatrixKernel* Mat2; // 8
[FieldOffset(16)] public MatrixKernel* Mat3; // 16
[FieldOffset(32)] public int Common_i;
[FieldOffset(36)] public int Common_j;
[FieldOffset(40)] public int Common_k;
[FieldOffset(44)] public int i;
[FieldOffset(48)] public int j;
[FieldOffset(52)] public int k;
[FieldOffset(56)] public MatrixElementType ElementType; // 56
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelTask"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StgSharp.Mathematics.Internal
{
[StructLayout(LayoutKind.Explicit)]
internal unsafe struct MatrixParallelTask
{
[FieldOffset(0)]public MatrixKernel* Mat1; // 8
[FieldOffset(8)] public MatrixKernel* Mat2; // 8
[FieldOffset(16)] public MatrixKernel* Mat3; // 16
[FieldOffset(32)] public int Common_i;
[FieldOffset(36)] public int Common_j;
[FieldOffset(40)] public int Common_k;
[FieldOffset(44)] public int i;
[FieldOffset(48)] public int j;
[FieldOffset(52)] public int k;
[FieldOffset(56)] public MatrixElementType ElementType; // 56
[FieldOffset(24)] public nint Span; // 24
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy(MatrixParallelTask* source, MatrixParallelTask* target)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTask), sizeof(MatrixParallelTask));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Copy(
MatrixParallelTask* source,
MatrixParallelTask* target
)
{
Buffer.MemoryCopy(source, target, sizeof(MatrixParallelTask),
sizeof(MatrixParallelTask));
}
}
}
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="Matrix44"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -26,7 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Mathematics.Intrinsic;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Numeric;
using System;
using System.Collections;
@@ -34,6 +34,7 @@ using System.Collections.Generic;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics.X86;
namespace StgSharp.Mathematics.Graphics
{
@@ -46,13 +47,20 @@ namespace StgSharp.Mathematics.Graphics
[FieldOffset(0)] internal ColumnSet4 mat;
[FieldOffset(0)] internal MatrixKernel<float> kernel;
internal Matrix44(ColumnSet4 mat)
internal Matrix44(
ColumnSet4 mat
)
{
Unsafe.SkipInit(out this);
this.mat = mat;
}
internal Matrix44(Vector4 vec0, Vector4 vec1, Vector4 vec2, Vector4 vec3)
internal Matrix44(
Vector4 vec0,
Vector4 vec1,
Vector4 vec2,
Vector4 vec3
)
{
Unsafe.SkipInit(out this);
mat.colum0 = vec0;
@@ -82,7 +90,8 @@ namespace StgSharp.Mathematics.Graphics
float a30,
float a31,
float a32,
float a33)
float a33
)
{
Unsafe.SkipInit(out this);
mat.colum0 = new Vector4(a00, a10, a20, a30);
@@ -91,7 +100,10 @@ namespace StgSharp.Mathematics.Graphics
mat.colum3 = new Vector4(a03, a13, a23, a33);
}
public unsafe float this[int rowNum, int columNum]
public unsafe float this[
int rowNum,
int columNum
]
{
get
{
@@ -133,84 +145,124 @@ namespace StgSharp.Mathematics.Graphics
public static Matrix44 Unit => new Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
public static Matrix44 WNegativeUnit => new Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1);
public static Matrix44 WNegativeUnit => new Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, -1);
public static Matrix44 XNegativeUnit => new Matrix44(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
public static Matrix44 XNegativeUnit => new Matrix44(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1);
public static Matrix44 YNegativeUnit => new Matrix44(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
public static Matrix44 YNegativeUnit => new Matrix44(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0,
0, 0, 1);
public static Matrix44 ZNegativeUnit => new Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1);
public static Matrix44 ZNegativeUnit => new Matrix44(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1, 0, 0,
0, 0, 1);
public ReadOnlySpan<float> AsSpan()
{
return MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As<ColumnSet4, float>(ref mat), 16);
}
public override bool Equals(object? obj)
public override bool Equals(
object? obj
)
{
return obj is Matrix44 x && Equals(x);
}
public bool Equals(Matrix44 other)
public bool Equals(
Matrix44 other
)
{
return mat.Equals(other.mat);
}
public override int GetHashCode()
{
return HashCode.Combine(mat.colum0.GetHashCode(), mat.colum1.GetHashCode(), mat.colum2.GetHashCode(),
mat.colum3.GetHashCode());
return HashCode.Combine(mat.colum0.GetHashCode(), mat.colum1.GetHashCode(),
mat.colum2.GetHashCode(), mat.colum3.GetHashCode());
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void InternalTranspose(ref Matrix44 transpose)
internal unsafe void InternalTranspose(
ref Matrix44 transpose
)
{
const int f32 = 0;
fixed (MatrixKernel<float>* source = &this.kernel, target = &transpose.kernel) {
MathematicsModule.GlobalContext.mat[f32].buffer_transpose(source, target);
MathematicsModule.GlobalContext.mat_sk[f32].Call(MatrixIntrinsicHandle.Transpose,
null, (MatrixKernel*)source,
(MatrixKernel*)target, 0);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe Matrix44 operator -(Matrix44 left, Matrix44 right)
public static unsafe Matrix44 operator -(
Matrix44 left,
Matrix44 right
)
{
Matrix44 ret = new();
const int f32 = 0;
MathematicsModule.GlobalContext.mat[f32].buffer_sub(&left, &right, &ret, 1);
int f32 = MatrixElementType.F32.IntrinsicNode;
MathematicsModule.GlobalContext.mat_sk[f32].Call(MatrixIntrinsicHandle.Sub,
(MatrixKernel*)&left,
(MatrixKernel*)&right,
(MatrixKernel*)&ret, 1);
return ret;
}
public static bool operator !=(Matrix44 left, Matrix44 right)
public static bool operator !=(
Matrix44 left,
Matrix44 right
)
{
return !(left == right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe Matrix44 operator *(Matrix44 mat, float value)
public static unsafe Matrix44 operator *(
Matrix44 mat,
float value
)
{
return new Matrix44(mat.mat.colum0 * value, mat.mat.colum1 * value, mat.mat.colum2 * value,
mat.mat.colum3 * value);
int f32 = MatrixElementType.F32.IntrinsicNode;
return new Matrix44(mat.mat.colum0 * value, mat.mat.colum1 * value,
mat.mat.colum2 * value, mat.mat.colum3 * value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Matrix44 operator *(Matrix44 left, Matrix44 right)
public static Matrix44 operator *(
Matrix44 left,
Matrix44 right
)
{
Matrix44 ret = new();
int f32 = (int)MatrixElementType.F32;
MathematicsModule.GlobalContext.mat[f32].kernel_fma(&left, &right, &ret);
int f32 = MatrixElementType.F32.IntrinsicNode;
MathematicsModule.GlobalContext.mat_sk[f32].Call(MatrixIntrinsicHandle.Fma,
(MatrixKernel*)&left,
(MatrixKernel*)&right,
(MatrixKernel*)&ret, 0);
return ret;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe Matrix44 operator +(Matrix44 left, Matrix44 right)
public static unsafe Matrix44 operator +(
Matrix44 left,
Matrix44 right
)
{
Matrix44 ret = new();
const int f32 = 0;
MathematicsModule.GlobalContext.mat[f32].buffer_add(&left, &right, &ret, 1);
int f32 = MatrixElementType.F32.IntrinsicNode;
MathematicsModule.GlobalContext.mat_sk[f32].Call(MatrixIntrinsicHandle.Add,
(MatrixKernel*)&left,
(MatrixKernel*)&right,
(MatrixKernel*)&ret, 1);
return ret;
}
public static bool operator ==(Matrix44 left, Matrix44 right)
public static bool operator ==(
Matrix44 left,
Matrix44 right
)
{
return left.Equals(right);
}
+60 -19
View File
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="Vec4"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -26,7 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Mathematics.Intrinsic;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Numeric;
using System;
using System.Data.Common;
@@ -52,7 +52,9 @@ namespace StgSharp.Mathematics.Graphics
[FieldOffset(4)] public float Y;
[FieldOffset(8)] public float Z;
internal Vec4(Vector4 v)
internal Vec4(
Vector4 v
)
{
Unsafe.SkipInit(out X);
Unsafe.SkipInit(out Y);
@@ -63,7 +65,9 @@ namespace StgSharp.Mathematics.Graphics
vec = v;
}
internal Vec4(M128 v)
internal Vec4(
M128 v
)
{
Unsafe.SkipInit(out X);
Unsafe.SkipInit(out Y);
@@ -74,7 +78,10 @@ namespace StgSharp.Mathematics.Graphics
reg = v;
}
public Vec4(Vec3 v3, float w)
public Vec4(
Vec3 v3,
float w
)
{
Unsafe.SkipInit(out X);
Unsafe.SkipInit(out Y);
@@ -84,7 +91,12 @@ namespace StgSharp.Mathematics.Graphics
W = w;
}
public Vec4(float x, float y, float z, float w)
public Vec4(
float x,
float y,
float z,
float w
)
{
vec = new Vector4(x, y, z, w);
}
@@ -123,7 +135,10 @@ namespace StgSharp.Mathematics.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec4 Add(Vec4 left, Vec4 right)
public static Vec4 Add(
Vec4 left,
Vec4 right
)
{
return left + right;
}
@@ -133,12 +148,16 @@ namespace StgSharp.Mathematics.Graphics
return MemoryMarshal.CreateReadOnlySpan(ref reg.Member<float>(0), 4);
}
public override bool Equals(object obj)
public override bool Equals(
object obj
)
{
return obj is Vec4 v && v == this;
}
public static Vec4 FromSpan(ReadOnlySpan<float> span)
public static Vec4 FromSpan(
ReadOnlySpan<float> span
)
{
if (span.Length < 4) {
throw new ArgumentException("Span length must be at least 4.", nameof(span));
@@ -161,7 +180,10 @@ namespace StgSharp.Mathematics.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec4 Subtract(Vec4 left, Vec4 right)
public static Vec4 Subtract(
Vec4 left,
Vec4 right
)
{
return left - right;
}
@@ -172,36 +194,55 @@ namespace StgSharp.Mathematics.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec4 operator -(Vec4 left, Vec4 right)
public static Vec4 operator -(
Vec4 left,
Vec4 right
)
{
return new Vec4(left.vec - right.vec);
}
public static bool operator !=(Vec4 left, Vec4 right)
public static bool operator !=(
Vec4 left,
Vec4 right
)
{
return !(left == right);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec4 operator *(Matrix44 mat, Vec4 vec)
public static Vec4 operator *(
Matrix44 mat,
Vec4 vec
)
{
Matrix44 transpose = mat.Transpose;
return new Vec4(Vector4.Dot(transpose.mat.colum0, vec.vec), Vector4.Dot(transpose.mat.colum1, vec.vec),
Vector4.Dot(transpose.mat.colum2, vec.vec), Vector4.Dot(transpose.mat.colum3, vec.vec));
return new Vec4(Vector4.Dot(transpose.mat.colum0, vec.vec),
Vector4.Dot(transpose.mat.colum1, vec.vec),
Vector4.Dot(transpose.mat.colum2, vec.vec),
Vector4.Dot(transpose.mat.colum3, vec.vec));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vec4 operator +(Vec4 left, Vec4 right)
public static Vec4 operator +(
Vec4 left,
Vec4 right
)
{
return new Vec4(left.vec + right.vec);
}
public static bool operator ==(Vec4 left, Vec4 right)
public static bool operator ==(
Vec4 left,
Vec4 right
)
{
return left.vec == right.vec;
}
bool IEquatable<Vec4>.Equals(Vec4 other)
bool IEquatable<Vec4>.Equals(
Vec4 other
)
{
return vec == other.vec;
}
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixCompute.Factorize"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -41,7 +41,8 @@ namespace StgSharp.Mathematics.Numeric
Matrix<float> matrix,
Span<int> pivot,
Matrix<float> lower,
Matrix<float> upper)
Matrix<float> upper
)
{
if (matrix.ColumnLength != matrix.RowLength) {
throw new InvalidOperationException("Matrix must be square.");
@@ -53,10 +54,14 @@ namespace StgSharp.Mathematics.Numeric
if (pivot.Length < n) {
throw new ArgumentException("Pivot span length is insufficient.", nameof(pivot));
}
if (lower.RowLength != n || lower.ColumnLength != n || lower.Layout != MatrixLayout.UpperTriangle) {
if (lower.RowLength != n ||
lower.ColumnLength != n ||
lower.Layout != MatrixLayout.UpperTriangle) {
throw new ArgumentException("Lower matrix must be lower-triangular with same dimensions as input.", nameof(lower));
}
if (upper.RowLength != n || upper.ColumnLength != n || upper.Layout != MatrixLayout.UpperTriangle) {
if (upper.RowLength != n ||
upper.ColumnLength != n ||
upper.Layout != MatrixLayout.UpperTriangle) {
throw new ArgumentException("Upper matrix must be upper-triangular with same dimensions as input.", nameof(upper));
}
@@ -73,9 +78,10 @@ namespace StgSharp.Mathematics.Numeric
for (int kBlock = 0; kBlock < n; kBlock += 4)
{
MathematicsModule.GlobalContext
.mat[(int)MatrixElementType.F32].pivot(matrix.Buffer, (ulong)(kBlock >> 2),
(ulong)(matrix.KernelRowLength - (kBlock >> 2)),
(ulong)pivots);
.mat_sk[(int)MatrixElementType.F32].pivot(matrix.Buffer,
(ulong)(kBlock >> 2),
(ulong)(matrix.KernelRowLength - (kBlock >> 2)),
(ulong)pivots);
int colsInBlock = Math.Min(4, n - kBlock);
for (int offset = 0; offset < colsInBlock; offset++)
{
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixCompute.Float"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -28,6 +28,7 @@
using StgSharp.Collections;
using StgSharp.Internal;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
@@ -42,7 +43,11 @@ namespace StgSharp.Mathematics.Numeric
public static partial class MatrixCompute
{
public static unsafe void Add(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
public static unsafe void Add(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != right.ColumnLength ||
@@ -57,7 +62,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* rightPtr = right.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_add(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_add(leftPtr, rightPtr, ansPtr,
count);
return;
} else if (count <= 1024)
@@ -67,7 +73,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* rightPtr = right.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_add(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_add(leftPtr, rightPtr, ansPtr,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -80,7 +87,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = ans.KernelColumnLength;
package->SecCount = ans.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f32].buffer_add;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f32].buffer_add;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -88,7 +95,10 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Fill(Matrix<float> ans, float value)
public static unsafe void Fill(
Matrix<float> ans,
float value
)
{
int f32 = (int)MatrixElementType.F32;
long count = (long)ans.KernelColumnLength * ans.KernelRowLength;
@@ -96,12 +106,12 @@ namespace StgSharp.Mathematics.Numeric
scalar->Data<float>(0) = value;
if (count <= 256)
{
MathematicsModule.GlobalContext.mat[f32].buffer_fill(ans.Buffer, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_fill(ans.Buffer, scalar, count);
return;
} else if (count <= 1024)
{
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
MathematicsModule.GlobalContext.mat[f32].buffer_fill(ans.Buffer, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_fill(ans.Buffer, scalar, count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
}
@@ -111,7 +121,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = ans.KernelColumnLength;
package->SecCount = ans.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.ANS_SCALAR_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f32].buffer_fill;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f32].buffer_fill;
package->Scalar = scalar;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -119,7 +129,11 @@ namespace StgSharp.Mathematics.Numeric
taskGroup.Dispose();
}
public static unsafe void Mul(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
public static unsafe void Mul(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
{
int f32 = (int)MatrixElementType.F32;
@@ -155,9 +169,10 @@ namespace StgSharp.Mathematics.Numeric
enumeration->Member<int>(1) = j;
MathematicsModule.GlobalContext
.mat[f32].kernel_tile_fma((MatrixKernel*)left.Buffer,
.mat_sk[f32].kernel_tile_fma((MatrixKernel*)left.Buffer,
(MatrixKernel*)right.Buffer,
(MatrixKernel*)ans.Buffer, enumeration);
(MatrixKernel*)ans.Buffer,
enumeration);
}
}
@@ -184,13 +199,18 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Mul(Matrix<float> left, float right, Matrix<float> ans)
public static unsafe void Mul(
Matrix<float> left,
float right,
Matrix<float> ans
)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != ans.ColumnLength || left.RowLength != ans.RowLength) {
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
}
if (left.Layout != MatrixLayout.DenseRectangle || ans.Layout != MatrixLayout.DenseRectangle) {
if (left.Layout != MatrixLayout.DenseRectangle ||
ans.Layout != MatrixLayout.DenseRectangle) {
throw new NotSupportedException("Only dense rectangle matrices are supported.");
}
long count = (long)left.KernelColumnLength * left.KernelRowLength;
@@ -200,7 +220,8 @@ namespace StgSharp.Mathematics.Numeric
{
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_scalar_mul(leftPtr, ansPtr, scalar,
count);
return;
} else if (count <= 1024)
@@ -209,7 +230,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_scalar_mul(leftPtr, ansPtr, scalar,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -222,7 +244,7 @@ namespace StgSharp.Mathematics.Numeric
package->SecCount = left.KernelRowLength;
package->Scalar = scalar;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f32].buffer_scalar_mul;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f32].buffer_scalar_mul;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -231,7 +253,11 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Sub(Matrix<float> left, Matrix<float> right, Matrix<float> ans)
public static unsafe void Sub(
Matrix<float> left,
Matrix<float> right,
Matrix<float> ans
)
{
int f32 = (int)MatrixElementType.F32;
if (left.ColumnLength != right.ColumnLength ||
@@ -251,7 +277,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* rightPtr = right.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_sub(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_sub(leftPtr, rightPtr, ansPtr,
count);
return;
} else if (count <= 1024)
@@ -261,7 +288,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<float>* leftPtr = left.Buffer;
MatrixKernel<float>* rightPtr = right.Buffer;
MatrixKernel<float>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f32].buffer_sub(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f32].buffer_sub(leftPtr, rightPtr, ansPtr,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -274,7 +302,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = left.KernelColumnLength;
package->SecCount = left.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f32].buffer_sub;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f32].buffer_sub;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixCompute.double"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -27,6 +27,7 @@
// -----------------------------------------------------------------------
using StgSharp.Internal;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -38,7 +39,11 @@ namespace StgSharp.Mathematics.Numeric
public partial class MatrixCompute
{
public static unsafe void Add(Matrix<double> left, Matrix<double> right, Matrix<double> ans)
public static unsafe void Add(
Matrix<double> left,
Matrix<double> right,
Matrix<double> ans
)
{
int f64 = (int)MatrixElementType.F64;
if (left.ColumnLength != right.ColumnLength ||
@@ -53,7 +58,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* rightPtr = right.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_add(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_add(leftPtr, rightPtr, ansPtr,
count);
return;
} else if (count <= 1024)
@@ -63,7 +69,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* rightPtr = right.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_add(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_add(leftPtr, rightPtr, ansPtr,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -76,7 +83,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = ans.KernelColumnLength;
package->SecCount = ans.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f64].buffer_add;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f64].buffer_add;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -84,7 +91,10 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Fill(Matrix<double> ans, double value)
public static unsafe void Fill(
Matrix<double> ans,
double value
)
{
int f64 = (int)MatrixElementType.F64;
long count = (long)ans.KernelColumnLength * ans.KernelRowLength;
@@ -92,12 +102,12 @@ namespace StgSharp.Mathematics.Numeric
scalar->Data<double>(0) = value;
if (count <= 256)
{
MathematicsModule.GlobalContext.mat[f64].buffer_fill(ans.Buffer, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_fill(ans.Buffer, scalar, count);
return;
} else if (count <= 1024)
{
MatrixParallelThread[] pool = MatrixParallel.LeadParallel(1);
MathematicsModule.GlobalContext.mat[f64].buffer_fill(ans.Buffer, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_fill(ans.Buffer, scalar, count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
}
@@ -107,7 +117,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = ans.KernelColumnLength;
package->SecCount = ans.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.ANS_SCALAR_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f64].buffer_fill;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f64].buffer_fill;
package->Scalar = scalar;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -115,7 +125,11 @@ namespace StgSharp.Mathematics.Numeric
taskGroup.Dispose();
}
public static unsafe void Mul(Matrix<double> left, Matrix<double> right, Matrix<double> ans)
public static unsafe void Mul(
Matrix<double> left,
Matrix<double> right,
Matrix<double> ans
)
{
int f64 = (int)MatrixElementType.F64;
@@ -145,9 +159,10 @@ namespace StgSharp.Mathematics.Numeric
enumeration->Member<int>(1) = j;
MathematicsModule.GlobalContext
.mat[f64].kernel_tile_fma((MatrixKernel*)left.Buffer,
.mat_sk[f64].kernel_tile_fma((MatrixKernel*)left.Buffer,
(MatrixKernel*)right.Buffer,
(MatrixKernel*)ans.Buffer, enumeration);
(MatrixKernel*)ans.Buffer,
enumeration);
}
}
if (count > 256) {
@@ -173,13 +188,18 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Mul(Matrix<double> left, double right, Matrix<double> ans)
public static unsafe void Mul(
Matrix<double> left,
double right,
Matrix<double> ans
)
{
int f64 = (int)MatrixElementType.F64;
if (left.ColumnLength != ans.ColumnLength || left.RowLength != ans.RowLength) {
throw new IndexOutOfRangeException("Matrix dimensions must agree.");
}
if (left.Layout != MatrixLayout.DenseRectangle || ans.Layout != MatrixLayout.DenseRectangle) {
if (left.Layout != MatrixLayout.DenseRectangle ||
ans.Layout != MatrixLayout.DenseRectangle) {
throw new NotSupportedException("Only dense rectangle matrices are supported.");
}
long count = (long)left.KernelColumnLength * left.KernelRowLength;
@@ -189,7 +209,8 @@ namespace StgSharp.Mathematics.Numeric
{
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_scalar_mul(leftPtr, ansPtr, scalar,
count);
return;
} else if (count <= 1024)
@@ -198,7 +219,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_scalar_mul(leftPtr, ansPtr, scalar, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_scalar_mul(leftPtr, ansPtr, scalar,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -211,7 +233,7 @@ namespace StgSharp.Mathematics.Numeric
package->SecCount = left.KernelRowLength;
package->Scalar = scalar;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.RIGHT_ANS_SCALAR_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f64].buffer_scalar_mul;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f64].buffer_scalar_mul;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -220,7 +242,11 @@ namespace StgSharp.Mathematics.Numeric
return;
}
public static unsafe void Sub(Matrix<double> left, Matrix<double> right, Matrix<double> ans)
public static unsafe void Sub(
Matrix<double> left,
Matrix<double> right,
Matrix<double> ans
)
{
int f64 = (int)MatrixElementType.F64;
if (left.ColumnLength != right.ColumnLength ||
@@ -240,7 +266,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* rightPtr = right.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_sub(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_sub(leftPtr, rightPtr, ansPtr,
count);
return;
} else if (count <= 1024)
@@ -250,7 +277,8 @@ namespace StgSharp.Mathematics.Numeric
MatrixKernel<double>* leftPtr = left.Buffer;
MatrixKernel<double>* rightPtr = right.Buffer;
MatrixKernel<double>* ansPtr = ans.Buffer;
MathematicsModule.GlobalContext.mat[f64].buffer_sub(leftPtr, rightPtr, ansPtr, count);
MathematicsModule.GlobalContext.mat_sk[f64].buffer_sub(leftPtr, rightPtr, ansPtr,
count);
MatrixParallel.ReturnParallelResources(ref pool);
return;
@@ -263,7 +291,7 @@ namespace StgSharp.Mathematics.Numeric
package->PrimCount = left.KernelColumnLength;
package->SecCount = left.KernelRowLength;
package->ComputeMode = new MatrixOpMode(MatrixIndexStyle.BUFFER_INDEX, MatrixOperationParam.LEFT_RIGHT_ANS_PARAM);
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat[f64].buffer_sub;
package->ComputeHandle = (IntPtr)MathematicsModule.GlobalContext.mat_sk[f64].buffer_sub;
MatrixParallelWrap taskGroup = MatrixParallel.ScheduleTask(package);
taskGroup.LaunchParallel(SleepMode.DeepSleep);
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixParallel.Publish"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -26,8 +26,8 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Mathematics;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -46,7 +46,9 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal static unsafe MatrixParallelWrap ScheduleTask(MatrixParallelTask* package)
internal static unsafe MatrixParallelWrap ScheduleTask(
MatrixParallelTask* package
)
{
switch (package->ComputeMode.OperationStyle)
{
@@ -57,7 +59,9 @@ namespace StgSharp.Mathematics.Numeric
}
}
private static unsafe MatrixParallelWrap ScheduleBufferTask(MatrixParallelTask* package)
private static unsafe MatrixParallelWrap ScheduleBufferTask(
MatrixParallelTask* package
)
{
int primCount = package->PrimCount;
int secCount = package->SecCount;
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixParallel"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -27,7 +27,8 @@
// -----------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Internal;
using StgSharp.Mathematics.Intrinsic;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Memory;
using System;
using System.Collections.Concurrent;
@@ -36,6 +37,7 @@ using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
@@ -43,12 +45,12 @@ namespace StgSharp.Mathematics.Numeric
public static partial class MatrixParallel
{
private static bool _meaningful;
private static CapacityFixedStack<MatrixParallelThread> _threads;
private static ConcurrentDictionary<SIMDID, nint> contextMap;
private static bool _meaningful;
private static CapacityFixedStack<MatrixParallelThread> _threads;
private static ConcurrentDictionary<SIMDID, nint> contextMap;
private static SlabAllocator<IntrinsicContext> contextAllocator;
public static bool IsParallelSupported { get; } = Environment.ProcessorCount > 6;
@@ -57,7 +59,9 @@ namespace StgSharp.Mathematics.Numeric
private static bool IsInitialized { get; set; } = false;
internal static unsafe IntrinsicContext* GetContext(SIMDID simd)
internal static unsafe IntrinsicContext* GetContext(
SIMDID simd
)
{
if (!IsParallelSupported) {
return null;
@@ -67,8 +71,8 @@ namespace StgSharp.Mathematics.Numeric
return (IntrinsicContext*)handle;
} else
{
IntrinsicContext* context = (IntrinsicContext*)contextAllocator.Allocate();
IntrinsicContext* context = (IntrinsicContext*)contextAllocator.Allocate();
return context;
}
}
@@ -93,9 +97,9 @@ namespace StgSharp.Mathematics.Numeric
MatrixParallelThread thread = new MatrixParallelThread(i);
_threads.Push(thread);
SpinWait.SpinUntil(() => thread.State == MatrixThreadState.Ready);
}
// TODO 构建全局的保底上下文
}
// TODO 构建全局的保底上下文
foreach (MatrixParallelThread thread in _threads) { }
if (contextMap.Keys.Count == 1)
{
@@ -114,11 +118,17 @@ namespace StgSharp.Mathematics.Numeric
[LibraryImport(Native.LibName, EntryPoint = "sn_compare_simd")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial ulong CompareSIMDID(IntrinsicContext* context, ulong id);
private static unsafe partial ulong CompareSIMDID(
IntrinsicContext* context,
ulong id
);
[LibraryImport(Native.LibName, EntryPoint = "load_intrinsic_function")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
private static unsafe partial void LoadIntrinsicFunction(IntrinsicContext* context, ulong id);
private static unsafe partial void LoadIntrinsicFunction(
IntrinsicContext* context,
ulong id
);
}
}
}
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.VisualBasic.FileIO;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixParallelThread.Fma"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -27,6 +27,7 @@
// -----------------------------------------------------------------------
using StgSharp.Internal;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -39,7 +40,9 @@ namespace StgSharp.Mathematics.Numeric
public partial class MatrixParallelThread
{
internal static unsafe void ComputeFmaPanelF32(MatrixParallelTask* p)
internal static unsafe void ComputeFmaPanelF32(
MatrixParallelTask* p
)
{
int f32 = MatrixElementType.F32.IntrinsicNode;
MatrixKernel* leftBuffer = (MatrixKernel*)p->Left;
@@ -62,12 +65,14 @@ namespace StgSharp.Mathematics.Numeric
int j = (int)(c % ansHeight);
enumeration->Member<int>(0) = i;
enumeration->Member<int>(1) = j;
MathematicsModule.GlobalContext.mat[f32].kernel_tile_fma(leftBuffer, rightBuffer, ansBuffer,
enumeration);
MathematicsModule.GlobalContext.mat_sk[f32].kernel_tile_fma(leftBuffer, rightBuffer,
ansBuffer, enumeration);
}
}
internal static unsafe void ComputeFmaPanelF64(MatrixParallelTask* p)
internal static unsafe void ComputeFmaPanelF64(
MatrixParallelTask* p
)
{
int f64 = MatrixElementType.F64.IntrinsicNode;
@@ -92,8 +97,8 @@ namespace StgSharp.Mathematics.Numeric
int j = (int)(c % ansHeight);
enumeration->Member<int>(0) = i;
enumeration->Member<int>(1) = j;
MathematicsModule.GlobalContext.mat[f64].kernel_tile_fma(leftBuffer, rightBuffer, ansBuffer,
enumeration);
MathematicsModule.GlobalContext.mat_sk[f64].kernel_tile_fma(leftBuffer, rightBuffer,
ansBuffer, enumeration);
}
}
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixParallelThread.Model"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using System;
using System.Runtime.CompilerServices;
@@ -36,7 +37,9 @@ namespace StgSharp.Mathematics.Numeric
private const int KernelStealCount = 64;
internal unsafe void BufferCompute(MatrixParallelTask* p)
internal unsafe void BufferCompute(
MatrixParallelTask* p
)
{
// while () { }
int size = p->ElementSize * 16;
@@ -47,11 +50,14 @@ namespace StgSharp.Mathematics.Numeric
((delegate* unmanaged[Cdecl]<void*, void*, void*, void*, long, void>)computeHandle)((void*)(p->Left + offset),
(void*)(p->Right + offset),
(void*)(p->Answer + offset),
scalar, count);
scalar,
count);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
internal unsafe void SpecialBufferCompute(MatrixParallelTask* p)
internal unsafe void SpecialBufferCompute(
MatrixParallelTask* p
)
{
switch ((MatrixElementType)p->ElementSize)
{
@@ -26,9 +26,11 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Internal;
using StgSharp.Mathematics.Intrinsic;
using StgSharp.Mathematics.Internal;
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
namespace StgSharp.Mathematics.Numeric
{
@@ -1,30 +1,27 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallelWrap.cs"
// file="MatrixParallelWrap"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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.
// 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.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
@@ -36,6 +33,7 @@ using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Mathematics.Numeric
@@ -56,7 +54,9 @@ namespace StgSharp.Mathematics.Numeric
private bool _disposed = false;
private int _count;
internal MatrixParallelWrap(MatrixParallelThread[] threadArray)
internal MatrixParallelWrap(
MatrixParallelThread[] threadArray
)
{
_threads = threadArray;
IsMultithread = threadArray.Length > 1;
@@ -69,9 +69,8 @@ namespace StgSharp.Mathematics.Numeric
{
get
{
if (_disposed) {
throw new ObjectDisposedException(typeof(MatrixParallelWrap).Name);
}
ObjectDisposedException.ThrowIf(_disposed, nameof(MatrixParallelWrap));
return _threads;
}
}
@@ -90,7 +89,9 @@ namespace StgSharp.Mathematics.Numeric
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void LaunchParallel(SleepMode afterWork)
public void LaunchParallel(
SleepMode afterWork
)
{
AfterWork = (ThreadPriority)afterWork;
foreach (MatrixParallelThread thread in _threads)
@@ -2,8 +2,8 @@
// -----------------------------------------------------------------------
// file="MatrixTaskFactory"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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
@@ -26,6 +26,7 @@
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Mathematics.Internal;
using StgSharp.Mathematics.Memory;
using System;
using System.Collections.Generic;
@@ -74,7 +75,9 @@ namespace StgSharp.Mathematics.Numeric
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe MatrixParallelTask* FromExistPackage(MatrixParallelTask* exist)
public static unsafe MatrixParallelTask* FromExistPackage(
MatrixParallelTask* exist
)
{
MatrixParallelTask* ptr = (MatrixParallelTask*)_wrapAllocator.Allocate();
MatrixParallelTask.Copy(exist, ptr);
@@ -83,13 +86,17 @@ namespace StgSharp.Mathematics.Numeric
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Release(ScalarPacket* source)
public static void Release(
ScalarPacket* source
)
{
_scalarAllocator.Free((nuint)source);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Release(MatrixParallelTask* source)
public static void Release(
MatrixParallelTask* source
)
{
if (source->Scalar != null) {
_scalarAllocator.Free((nuint)source->Scalar);
@@ -1,303 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Common"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml.Schema;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private static Regex _entityTypeCheckPattern = GetEntityTypeCheckPattern();
private StepDependencyDetector _dependencyDetector = new StepDependencyDetector();
[GeneratedRegex(@"^[A-Z0-9_]+$", RegexOptions.Singleline)]
private static partial Regex GetEntityTypeCheckPattern();
private bool IsSeparatorMatch(Token leftSeparator, Token rightSeparator)
{
return leftSeparator.Value switch
{
ExpKeyword.LeftBrace => rightSeparator.Value == ExpKeyword.RightBrace,
ExpKeyword.LeftParen => rightSeparator.Value == ExpKeyword.RightParen,
ExpKeyword.Comma => rightSeparator.Value == ExpKeyword.Comma,
ExpKeyword.Semicolon => rightSeparator.Value == ExpKeyword.Semicolon,
_ => false
};
}
private bool TryAppendIndexLeft(Token t)
{
if (t.Flag != TokenFlag.Index_Left) {
return false;
}
if (_cache.TryPeekOperand(out bool isNode, out _, out ExpSyntaxNode? node))
{
if (node.EqualityTypeConvert is not ExpCollectionBase) {
ExpInvalidSyntaxException.ThrowNonCollectionIndex(t);
}
}
_cache.PushOperator(t);
_cache.IncreaseDepth((int)ExpCompileStateCode.CollectionIndex);
return true;
}
private bool TryAppendIndexRight(Token t)
{
if (t.Flag != TokenFlag.Index_Right) {
return false;
}
// reverse building
ClosePrefixReverse(t);
// make index node
_cache.PopOperand(out _, out ExpSyntaxNode? expNode);
if (!_cache.PopOperand(out Token colleToken, out ExpSyntaxNode? colleNode)) { }
_cache.PushOperand(
ExpCollectionIndexNode.Create(
t, (colleNode as ExpCollectionInstanceBase)!, expNode));
return true;
}
private bool TryAppendMember(Token t)
{
if (t.Flag != TokenFlag.Member) {
return false;
}
if (TryParseConstant(t)) {
return true;
}
if (TryParseFunction(t)) {
return true;
}
if (TryParseInstance(t)) {
return true;
}
if (TryParseKeyword(t)) {
return true;
}
if (TryParseElementName(t)) {
return true;
}
// Many thing miss here
_cache.PushOperand(ExpElementMemberNameNode.Create(t));
return true;
}
private bool TryAppendMiddleSeparator(Token t)
{
if (t.Flag != TokenFlag.Separator_Middle) {
return false;
}
while (_cache.OperatorAheadOfDepth > 0)
{
_cache.TryPopOperator(out Token op);
ExpSyntaxNode node = ConvertAndPushOneOperator(op);
}
switch (_cache.OperandAheadOfDepth)
{
case 0:
if (t.Value == ";") {
return true;
}
_cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
goto case 1;
case 1:
_cache.PopOperand(out _, out ExpSyntaxNode? statement);
if (t.Value == ";")
{
StepEntityDefineSequence sequence = new StepEntityDefineSequence(
statement, _dependencyDetector.ExportAllDependencies());
StepEntityInitStatements.Enqueue(sequence);
} else
{
_cache.StatementsInDepth.Push(statement);
}
return true;
default:
ExpInvalidSyntaxException.ThrowNoOperator(t);
break;
}
return true;
}
private bool TryAppendNumAndStrLiteral(Token t)
{
if ((t.Flag & (TokenFlag.String | TokenFlag.Number)) == 0) {
return false;
}
_cache.PushOperand(ExpElementInstance.CreateLiteral(t));
return true;
}
private bool TryAppendPrefixSeparator(Token t)
{
if (t.Flag != TokenFlag.Separator_Left) {
return false;
}
_cache.PushOperator(t);
_cache.IncreaseDepth((int)ExpCompileStateCode.Common);
return true;
}
private bool TryAppendPrefixSeparatorEnd(Token t)
{
if (t.Flag != TokenFlag.Separator_Right) {
return false;
}
ClosePrefixReverse(t);
return true;
}
private bool TryAppendSymbol(Token t)
{
if ((t.Flag & (TokenFlag.Symbol_Unary | TokenFlag.Symbol_Binary)) == 0) {
return false;
}
int cmp = -1;
processPrecedence:
if (_cache.TryPeekOperator(out Token tmp))
{
cmp = CompareOperatorPrecedence(t, tmp);
if (cmp >= 0)
{
_cache.PopOperator();
ExpSyntaxNode node = ConvertAndPushOneOperator(tmp);
goto processPrecedence;
}
}
_cache.PushOperator(t);
return true;
}
private bool TryParseConstant(Token t)
{
switch (t.Value)
{
case "$":
_cache.PushOperand(StepEntityInstanceNode.RegisterNull(t));
return true;
case "*":
_cache.PushOperand(StepEntityInstanceNode.RegisterRuntimeInference(t));
return true;
case ExpKeyword.E:
_cache.PushOperand(new ExpRealNumberNode(t, MathF.E, true));
return true;
case ExpKeyword.Pi:
_cache.PushOperand(new ExpRealNumberNode(t, MathF.PI, true));
return true;
default:
if (ExpElementInstance.TryCreateLiteral(t, out ExpElementInstance? node))
{
_cache.PushOperand(node);
return true;
}
return false;
}
}
private bool TryParseElementName(Token t)
{
if (_context.TryGetType(t.Value, out ExpTypeSource? type))
{
_cache.PushOperand(ExpMetaRefNode.RefType(t, type));
return true;
}
if (_context.TryGetEntity(t.Value, out ExpEntitySource? entity))
{
_cache.PushOperand(ExpMetaRefNode.RefEntity(t, entity));
return true;
}
return false;
}
private bool TryParseFunction(Token t)
{
if (_entityTypeCheckPattern.IsMatch(t.Value))
{
if (_cache.PeekOperator().Flag == TokenFlag.Member)
{
Token op = _cache.PopOperator();
ConvertAndPushOneOperator(op);
}
_cache.PushOperator(t);
return true;
}
return false;
}
private bool TryParseInstance(Token t)
{
if (t.Value[0] == '#')
{
StepEntityInstanceNode node = StepEntityInstanceNode.Register(t);
if (t.Column != 0) {
_dependencyDetector.AddDependency(node);
}
_cache.PushOperand(node);
return true;
}
return false;
}
private bool TryParseKeyword(Token t)
{
switch (t.Value)
{
case ExpKeyword.Return:
_cache.PushOperator(t);
return true;
case ExpKeyword.Skip:
_cache.PushOperand(ExpProcedureControlNode.Skip(t));
return true;
default:
return false;
}
}
}
}
@@ -1,65 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum"
// 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;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private static string ParseStepEnumLiteral(string source)
{
int length = source.Length;
ReadOnlySpan<char> span = source.AsSpan();
if (length > 2 && span[0] == '.' && span[length - 1] == '.') {
return span.Slice(1, length - 2).ToString();
}
throw new ExpInvalidSyntaxException($"\"{source}\" is not a valid enum syntax");
}
private void TryAppendEnum(Token e)
{
ExpSyntaxNode node = e.Value switch
{
".T." => new ExpBoolNode(e, true, true),
".F." => new ExpBoolNode(e, false, true),
".U." => new ExpLogicValueNode(e, ExpLogic.Unknown, true),
_ => ExpEnumLiteralNode.Create(e, ParseStepEnumLiteral),
};
_cache.PushOperand(node);
}
}
}
@@ -1,128 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser"
// 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;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
public int CompareOperatorPrecedence(Token left, Token right)
{
ExpressCompile.TryGetOperatorPrecedence(left.Value, out int leftPrecedence);
ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence);
return leftPrecedence - rightPrecedence;
}
public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node)
{
ExpSyntaxNode operand = GetNextOperandCache();
switch (t.Value)
{
case ExpKeyword.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus(t, operand);
return true;
case ExpKeyword.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus(t, operand);
return true;
case ExpKeyword.Not:
node = ExpUnaryOperatorNode.UnaryNot(t, operand);
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
/// <summary>
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS.
/// </summary>
private ExpSyntaxNode ConvertAndPushOneOperator(Token op)
{
switch (op.Flag)
{
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode(op, out ExpSyntaxNode? node);
_cache.PushOperand(node);
return node;
case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode(op, out node);
_cache.PushOperand(node);
return node;
case TokenFlag.Member:
_cache.PopOperand(out _, out ExpSyntaxNode? p);
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller(op.Value);
node = ExpFunctionCallingNode.CallFunction(op, caller, p);
_cache.StatementsInDepth.Push(node);
return node;
default:
throw new NotImplementedException();
}
}
private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node)
{
/*
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left = GetNextOperandCache();
/**/
switch (t.Value)
{
case "=":
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left;
if (right is ExpTupleNode tuple)
{
right = StepComplexEntityNode.FromTuple(tuple);
left = GetNextOperandCache();
} else
{
left = right;
right = _cache.StatementsInDepth.Pop();
}
node = ExpBinaryOperatorNode.Assign(t, left, right);
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
}
}
@@ -1,87 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing"
// 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.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private void ClosePrefixReverse(Token rightSeparator)
{
Token op;
ExpSyntaxNode root;
if (_cache.OperatorAheadOfDepth == 0)
{
if (_cache.OperandAheadOfDepth == 1)
{
_cache.PopOperand(out _, out ExpSyntaxNode? statement);
_cache.StatementsInDepth.Push(statement);
} else
{
_cache.StatementsInDepth.Push(ExpSyntaxNode.Empty);
}
} else
{
while (_cache.TryPopOperator(out op))
{
ExpSyntaxNode node = ConvertAndPushOneOperator(op);
}
if (_cache.OperandAheadOfDepth == 1)
{
_cache.PopOperand(out _, out root);
_cache.StatementsInDepth.Push(root);
}
}
root = _cache.PackAllStatements();
_cache.DecreaseDepth();
if (IsSeparatorMatch(_cache.PeekOperator(), rightSeparator))
{
_cache.PopOperator();
root = ExpTupleNode.Pack(root);
_cache.PushOperand(root);
} else
{
throw new ExpCompileException(
rightSeparator, "Ending of block does not match its begging");
}
}
}
}
@@ -1,135 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
using StgSharp.Script.Express;
using StgSharp.Threading;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer : ISyntaxAnalyzer
{
private const int EndLine = 1;
private const int TokenGenerated = 0;
private const int TokenTypeNotMatch = -1;
private CompileStack<ExpSyntaxNode, IExpElementSource> _cache;
private ExpSchema _context;
private ExpSyntaxNode _lastStatement;
private IExpElementSource _local;
public StepExpSyntaxAnalyzer()
{
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
_context = new ExpressStepUtil();
}
public ConcurrentQueue<StepEntityDefineSequence> StepEntityInitStatements { get; } = new();
/// <summary>
/// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators.
/// </summary>
public void AppendToken(Token expToken)
{
switch (expToken.Flag)
{
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol(expToken);
break;
case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken);
_cache.PushOperand(node);
break;
case TokenFlag.Separator_Left:
TryAppendPrefixSeparator(expToken);
break;
case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd(expToken);
break;
case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator(expToken);
break;
case TokenFlag.Index_Left:
TryAppendIndexLeft(expToken);
break;
case TokenFlag.Index_Right:
TryAppendIndexRight(expToken);
break;
case TokenFlag.Member:
TryAppendMember(expToken);
break;
case TokenFlag.Enum:
TryAppendEnum(expToken);
break;
default:
break;
}
}
public ExpSyntaxNode GetNextOperandCache()
{
if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n))
{
return n;
} else
{
// process some rare case here
}
throw new NotImplementedException();
}
public enum ExpCompileStateCode
{
Common,
ForLoop,
RepeatLoop,
UntilLoop,
IfBranch,
CaseBranch,
CollectionIndex,
}
}
}
@@ -1,108 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDataSectionsTranmitter"
// 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 System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepDataSectionTransmitter : IScriptSourceProvider
{
private const string EndDataText = "ENDSEC;";
// private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0;
public StepDataSectionTransmitter() { }
public StepDataSectionTransmitter(int begins)
{
Begin = begins;
_line = Begin;
}
public bool IsEmpty => _cache.IsEmpty && !IsWriting;
public bool IsWriting { get; private set; } = true;
public int Begin { get; internal set; }
public int Location => _line;
public void EndWriting()
{
IsWriting = false;
}
public string ReadLine()
{
if (_cache.TryDequeue(out string? line))
{
_line++;
return line;
}
return string.Empty;
}
public string ReadLine(out int position)
{
string ret = ReadLine();
position = _line;
return ret;
}
public void WriteLine(string line)
{
if (line == "DATA;") {
return;
}
if (line == EndDataText)
{
EndWriting();
return;
}
if (IsWriting) {
_cache.Enqueue(line);
}
}
IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count)
{
throw new NotSupportedException();
}
}
}
@@ -1,165 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDataTokenReader"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepDataTokenReader : IScriptTokenReader
{
private ExpTokenReader _reader;
private HashSet<string> tokenHash = [ "T", "F", "UNSPECIFIED" ];
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader(StepDataSectionTransmitter transmitter)
{
_reader = new ExpTokenReader(transmitter);
_reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter;
}
public bool IsEmpty
{
get
{
if (_reader.IsEmpty) {
return !_transmitter.IsWriting;
}
return false;
}
}
public Token ReadToken()
{
return _reader.ReadToken();
}
public bool TryReadToken(out Token t)
{
return _reader.TryReadToken(out t);
}
private partial class TokenPreReader : ExpTokenReaderPreProcessor
{
private static Regex
_nextHashtagSymbolPattern = GetEntityTagSymbolPattern(),
_nextEnumPattern = GetNextEnumPattern(),
_stringPattern = GetStringPattern();
public override bool Process(string codeLine, int line, ref int current, out Token t)
{
ReadOnlySpan<char> chars = codeLine.AsSpan(current);
char c = chars[0];
Match match;
switch (c)
{
case '#':
match = _nextHashtagSymbolPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new(
ExpressCompile.PoolString(chars[0..(end - begin)]), line,
begin, TokenFlag.Member);
return true;
}
break;
case '.':
match = _nextEnumPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new Token(
match.Groups["token"].Value, line, begin, TokenFlag.Enum);
return true;
}
break;
case '$':
t = new Token("$", line, current, TokenFlag.Member);
current++;
return true;
case '*':
t = new Token("*", line, current, TokenFlag.Member);
current++;
return true;
case '\'':
match = _stringPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
string value = chars.Slice(1, (end - begin - 1)).ToString();
if (string.IsNullOrWhiteSpace(value)) {
value = string.Empty;
}
t = new Token(value, line, begin, TokenFlag.String);
return true;
}
break;
default:
break;
}
t = Token.Empty;
return false;
}
[GeneratedRegex(@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetEntityTagSymbolPattern();
[GeneratedRegex(@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)", RegexOptions.Singleline)]
private static partial Regex GetNextEnumPattern();
[GeneratedRegex(@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetStringPattern();
}
}
}
@@ -1,58 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDependencyDetector"
// 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.Model.Step;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepDependencyDetector
{
public StepDependencyDetector() { }
public List<int> Dependencies { get; private set; } = new();
public void AddDependency(StepEntityInstanceNode node)
{
Dependencies.Add(node.Id);
}
public IEnumerable<int> ExportAllDependencies()
{
List<int> ret = Dependencies;
Dependencies = new List<int>();
return ret;
}
}
}
-129
View File
@@ -1,129 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpressStepUtil"
// 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 CommunityToolkit.HighPerformance.Buffers;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace StgSharp.Model.Step
{
public class ExpressStepUtil : ExpSchema
{
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 RepresentationItemText = "REPRESENTATION_ITEM";
public const string VectorText = "VECTOR";
public const string VertexPointText = "VERTEX_POINT";
private static
HashSet<string> names = [ AdvancedFaceText, Axis2Placement2DText, Axis2Placement3DText, BSplineCurveWithKnotsText, CartesianPointText, CircleText, CylindricalSurfaceText, DirectionText, EdgeCurveText, EdgeLoopText, EllipseText, FaceBoundText, FaceOuterBoundText, LineText, OrientedEdgeText, PlaneText, RepresentationItemText, VectorText, VertexPointText, ];
private FrozenDictionary<string, ExpEntitySource> entitiesDefine;
private StringPool _entityNamePool = new StringPool();
public ExpressStepUtil()
{
IEnumerable<KeyValuePair<string, ExpEntitySource>> defineSource = [];
entitiesDefine = new Dictionary<string, ExpEntitySource>(defineSource)
.ToFrozenDictionary();
foreach (string item in names) {
_entityNamePool.Add(item);
}
}
internal StepModel Current { get; set; }
public override void LoadFromSource(ExpSchemaSource source)
{
return;
}
public override bool TryGetConst(string name, out ExpElementInstance c)
{
c = null!;
return false;
}
public override bool TryGetEntity(string name, out ExpEntitySource e)
{
return entitiesDefine.TryGetValue(name, out e!);
}
public override bool TryGetFunction(string name, out ExpFunctionSource f)
{
f = null!;
return false;
}
public override bool TryGetProcedure(string name, out ExpProcedureSource p)
{
p = null!;
return false;
}
public override bool TryGetRule(string name, out ExpRuleSource r)
{
r = null!;
return false;
}
public override bool TryGetSchemaInclude(string name, out ExpSchema include)
{
include = null!;
return false;
}
public override bool TryGetType(string name, out ExpTypeSource t)
{
t = null!;
return false;
}
}
}
@@ -1,74 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepAdvancedFace"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Linq;
namespace StgSharp.Model.Step
{
public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom<StepAdvancedFace>
{
public StepAdvancedFace(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.AdvancedFace;
public void FromInstance(StepAdvancedFace entity)
{
base.FromInstance(entity);
}
internal static StepAdvancedFace FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAdvancedFace face = new StepAdvancedFace(binder);
enumerator.AssertEnumeratorCount(4);
face.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator boundsList = enumerator[1].TupleToPresidentEnumerator();
face.Bounds.Clear();
face.Bounds
.AddRange(
Enumerable.Range(0, enumerator.Count).Select(_ => (StepFaceBound)null));
for (int i = 0; i < boundsList.Count; i++)
{
int j = i; // capture to avoid rebinding
face.Bounds[j] = binder[boundsList[j]] as StepFaceBound;
}
face.FaceGeometry = binder[enumerator[2]] as StepSurface;
face.SameSense = (enumerator[3] as ExpBoolNode)!.Value;
return face;
}
}
}
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepAxis2Placement"
// 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.Model.Step;
using StgSharp.Script;
using System;
namespace StgSharp.Model.Step
{
public class StepAxis2Placement : StepPlacement
{
private StepDirection _refDirection;
protected StepAxis2Placement(StepModel model) : base(model) { }
public StepDirection RefDirection
{
get { return _refDirection; }
set
{
ArgumentNullException.ThrowIfNull(value);
_refDirection = value;
}
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepAxis2Placement";
}
}
}
@@ -1,71 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepAxis2Placement2D"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement2D>
{
private StepAxis2Placement2D(StepModel model) : base(model) { }
public StepAxis2Placement2D(StepModel model, StepCartesianPoint location, StepDirection direction)
: base(model)
{
Location = location;
RefDirection = direction;
}
public override StepItemType ItemType => StepItemType.AxisPlacement2D;
public void FromInstance(StepAxis2Placement2D entity)
{
base.FromInstance(entity);
Location = entity.Location;
RefDirection = entity.RefDirection;
}
internal static StepAxis2Placement2D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAxis2Placement2D axis = new StepAxis2Placement2D(binder);
enumerator.AssertEnumeratorCount(3);
axis.Name = (enumerator[0]as ExpStringNode)!.Value;
axis.Location = binder[enumerator[1]] as StepCartesianPoint;
axis.RefDirection = binder[enumerator[2]] as StepDirection;
return axis;
}
}
}
@@ -1,92 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepAxis2Placement3D"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepAxis2Placement3D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement3D>
{
private StepDirection _axis;
private StepAxis2Placement3D(StepModel model) : base(model) { }
public StepAxis2Placement3D(
StepModel model,
StepCartesianPoint location,
StepDirection axis,
StepDirection refDirection)
: base(model)
{
Location = location;
Axis = axis;
RefDirection = refDirection;
}
public StepDirection Axis
{
get { return _axis; }
set
{
ArgumentNullException.ThrowIfNull(value);
_axis = value;
}
}
public override StepItemType ItemType => StepItemType.AxisPlacement3D;
public override bool IsConvertableTo(string entityTypeName)
{
throw new NotImplementedException();
}
internal static StepAxis2Placement3D FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepAxis2Placement3D axis = new StepAxis2Placement3D(binder);
enumerator.AssertEnumeratorCount(4);
axis.Name = (enumerator[0]as ExpStringNode)!.Value;
axis.Location = binder[enumerator[1]] as StepCartesianPoint;
axis.Axis = binder[enumerator[2]] as StepDirection;
axis.RefDirection = binder[enumerator[3]] as StepDirection;
return axis;
}
void IExpConvertableFrom<StepAxis2Placement3D>.FromInstance(StepAxis2Placement3D entity)
{
throw new NotImplementedException();
}
}
}
@@ -1,131 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBSplineCurve"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
{
public enum StepBSplineCurveForm
{
Polyline,
CircularArc,
EllipticalArc,
ParabolicArc,
HyperbolicArc,
Unspecified
}
public static class StepExpEnumValue
{
internal const string CIRCULAR_ARC = "CIRCULAR_ARC";
internal const string ELLIPTIC_ARC = "ELLIPTIC_ARC";
internal const string HYPERBOLIC_ARC = "HYPERBOLIC_ARC";
internal const string PARABOLIC_ARC = "PARABOLIC_ARC";
internal const string POLYLINE_FORM = "POLYLINE_FORM";
internal const string UNSPECIFIED = "UNSPECIFIED";
internal static HashSet<string> AllPossibleValue { get; } = [ CIRCULAR_ARC, ELLIPTIC_ARC, HYPERBOLIC_ARC, PARABOLIC_ARC, POLYLINE_FORM, UNSPECIFIED, ];
}
public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom<StepBSplineCurve>
{
public StepBSplineCurve(StepModel model, params StepCartesianPoint[] controlPoints)
: this(model, (IEnumerable<StepCartesianPoint>)controlPoints) { }
public StepBSplineCurve(StepModel model, IEnumerable<StepCartesianPoint> controlPoints)
: base(model)
{
ControlPointsList.AddRange(controlPoints);
}
public bool ClosedCurve { get; set; }
public bool SelfIntersect { get; set; }
public int Degree { get; set; }
public List<StepCartesianPoint> ControlPointsList { get; private set; }
= new List<StepCartesianPoint>();
public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified;
public void FromInstance(StepBSplineCurve entity)
{
base.FromInstance(entity);
this.Degree = entity.Degree;
this.ClosedCurve = entity.ClosedCurve;
this.ControlPointsList = entity.ControlPointsList;
this.SelfIntersect = entity.SelfIntersect;
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepBSplineCurve";
}
protected static string GetCurveFormString(StepBSplineCurveForm form)
{
return form switch
{
StepBSplineCurveForm.Polyline => StepExpEnumValue.POLYLINE_FORM,
StepBSplineCurveForm.CircularArc => StepExpEnumValue.CIRCULAR_ARC,
StepBSplineCurveForm.EllipticalArc => StepExpEnumValue.ELLIPTIC_ARC,
StepBSplineCurveForm.ParabolicArc => StepExpEnumValue.PARABOLIC_ARC,
StepBSplineCurveForm.HyperbolicArc => StepExpEnumValue.HYPERBOLIC_ARC,
StepBSplineCurveForm.Unspecified => StepExpEnumValue.UNSPECIFIED,
_ => throw new NotImplementedException(),
};
}
protected static StepBSplineCurveForm ParseCurveForm(string enumerationValue)
{
return enumerationValue.ToUpperInvariant() switch
{
StepExpEnumValue.POLYLINE_FORM => StepBSplineCurveForm.Polyline,
StepExpEnumValue.CIRCULAR_ARC => StepBSplineCurveForm.CircularArc,
StepExpEnumValue.ELLIPTIC_ARC => StepBSplineCurveForm.EllipticalArc,
StepExpEnumValue.PARABOLIC_ARC => StepBSplineCurveForm.ParabolicArc,
StepExpEnumValue.HYPERBOLIC_ARC => StepBSplineCurveForm.HyperbolicArc,
_ => StepBSplineCurveForm.Unspecified,
};
}
}
}
@@ -1,149 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBSplineCurveWithKnots"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
{
public enum StepKnotType
{
UniformKnots,
QuasiUniformKnots,
PiecewiseBezierKnots,
Unspecified
}
;
public class StepBSplineCurveWithKnots : StepBSplineCurve, IExpConvertableFrom<StepBSplineCurveWithKnots>
{
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(StepModel model, IEnumerable<StepCartesianPoint> controlPoints)
: base(model, controlPoints) { }
public StepBSplineCurveWithKnots(StepModel model, params StepCartesianPoint[] controlPoints)
: base(model, controlPoints) { }
public List<int> KnotMultiplicities { get; } = new List<int>();
public List<double> Knots { get; } = new List<double>();
public override StepItemType ItemType => StepItemType.BSplineCurveWithKnots;
public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified;
public void FromInstance(StepBSplineCurveWithKnots entity)
{
base.FromInstance(entity);
KnotSpec = entity.KnotSpec;
KnotMultiplicities.Clear();
KnotMultiplicities.AddRange(entity.KnotMultiplicities);
Knots.Clear();
Knots.AddRange(entity.Knots);
}
internal static StepBSplineCurveWithKnots FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = syntaxList .ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(9);
ExpNodePresidentEnumerator controlPointsList = enumerator[2].TupleToPresidentEnumerator(
);
StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots(
binder, new StepCartesianPoint[controlPointsList.Count]);
spline.Name = (enumerator[0]as ExpStringNode)!.Value;
spline.Degree = (enumerator[1] as ExpIntNode)!.Value;
for (int i = 0; i < controlPointsList.Count; i++)
{
int j = i; // capture to avoid rebinding
spline.ControlPointsList[j] = binder[controlPointsList[j]]as StepCartesianPoint;
}
spline.CurveForm = ParseCurveForm(enumerator[3].CodeConvertTemplate);
spline.ClosedCurve = (enumerator[4] as ExpBoolNode)!.Value;
spline.SelfIntersect = (enumerator[5]as ExpBoolNode)!.Value;
ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[6].TupleToPresidentEnumerator(
);
spline.KnotMultiplicities.Clear();
for (int i = 0; i < knotMultiplicitiesList.Count; i++) {
spline.KnotMultiplicities.Add((knotMultiplicitiesList[i]as ExpIntNode)!.Value);
}
ExpNodePresidentEnumerator knotsList = enumerator[7].TupleToPresidentEnumerator();
spline.Knots.Clear();
for (int i = 0; i < knotsList.Count; i++) {
spline.Knots.Add((knotsList[i]as ExpRealNumberNode)!.Value);
}
spline.KnotSpec = ParseKnotSpec(enumerator[8].CodeConvertTemplate);
return spline;
}
private static string GetKnotSpec(StepKnotType spec)
{
return spec switch
{
StepKnotType.UniformKnots => UNIFORM_KNOTS,
StepKnotType.QuasiUniformKnots => QUASI_UNIFORM_KNOTS,
StepKnotType.PiecewiseBezierKnots => PIECEWISE_BEZIER_KNOTS,
StepKnotType.Unspecified => UNSPECIFIED,
_ => throw new NotImplementedException(),
};
}
private static StepKnotType ParseKnotSpec(string enumerationValue)
{
return enumerationValue.ToUpperInvariant() switch
{
UNIFORM_KNOTS => StepKnotType.UniformKnots,
QUASI_UNIFORM_KNOTS => StepKnotType.QuasiUniformKnots,
PIECEWISE_BEZIER_KNOTS => StepKnotType.PiecewiseBezierKnots,
_ => StepKnotType.Unspecified,
};
}
}
}
@@ -1,182 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBSplineSurface"
// 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 CommunityToolkit.HighPerformance;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public enum StepBSplineSurfaceForm
{
PLANE_SURF,
CYLINDRICAL_SURF,
CONICAL_SURF,
SPHERICAL_SURF,
TOROIDAL_SURF,
SURF_OF_REVOLUTION,
RULED_SURF,
GENERALISED_CONE,
QUADRIC_SURF,
SURF_OF_LINEAR_EXTRUSION,
UNSPECIFIED,
}
public class StepBSplineSurface : StepBoundedSurface, IExpConvertableFrom<StepBSplineSurface>
{
public const string CONICAL_SURF_TEXT = "CONICAL_SURF";
public const string CYLINDRICAL_SURF_TEXT = "CYLINDRICAL_SURF";
public const string GENERALISED_CONE_TEXT = "GENERALISED_CONE";
public const string PLANE_SURF_TEXT = "PLANE_SURF";
public const string QUADRIC_SURF_TEXT = "QUADRIC_SURF";
public const string RULED_SURF_TEXT = "RULED_SURF";
public const string SPHERICAL_SURF_TEXT = "SPHERICAL_SURF";
public const string SURF_OF_LINEAR_EXTRUSION_TEXT = "SURF_OF_LINEAR_EXTRUSION";
public const string SURF_OF_REVOLUTION_TEXT = "SURF_OF_REVOLUTION";
public const string TOROIDAL_SURF_TEXT = "TOROIDAL_SURF";
public const string UNSPECIFIED_TEXT = "UNSPECIFIED";
public StepBSplineSurface(StepModel model) : base(model) { }
public bool UClosed { get; set; }
public bool VClosed { get; set; }
public bool SelfIntersections { get; set; }
public int UDegree { get; set; }
public int VDegree { get; set; }
public int UUpper => ControlPointsList.Count - 1;
public int VUpper => ControlPointsList[0].Count - 1;
public List<List<StepCartesianPoint>> ControlPointsList { get; set; }
= new List<List<StepCartesianPoint>>();
public StepBSplineSurfaceForm SurfaceForm { get; set; }
public static StepBSplineSurface CreateFromSyntax(StepModel binder, ExpSyntaxNode syntax)
{
ExpNodePresidentEnumerator enumerator = syntax.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(7);
StepBSplineSurface ret = new StepBSplineSurface(binder);
ret.UDegree = (enumerator[0] as ExpIntNode).Value;
ret.VDegree = (enumerator[1] as ExpIntNode).Value;
ExpNodePresidentEnumerator pointList = enumerator[2].TupleToPresidentEnumerator();
pointList.AssertEnumeratorCount(2, int.MaxValue);
for (int i = 0; i < pointList.Count; i++)
{
ExpNodePresidentEnumerator points = pointList[i].TupleToPresidentEnumerator();
points.AssertEnumeratorCount(2, int.MaxValue);
List<StepCartesianPoint> pList = new List<StepCartesianPoint>(points.Count);
CollectionsMarshal.SetCount(pList, points.Count);
Span<StepCartesianPoint> ls = CollectionsMarshal.AsSpan(pList);
Span<ExpSyntaxNode> aspan = points.AsSpan();
for (int j = 0; j < points.Count; j++)
{
StepCartesianPoint p = binder[aspan[i] as StepEntityInstanceNode] as StepCartesianPoint;
ls[j] = p;
}
ret.ControlPointsList.Add(pList);
}
ret.SurfaceForm = GetSurfaceForm(enumerator[3].CodeConvertTemplate);
ret.UClosed = (enumerator[4] as ExpBoolNode).Value;
ret.VClosed = (enumerator[5] as ExpBoolNode).Value;
ret.SelfIntersections = (enumerator[6] as ExpBoolNode).Value;
return ret;
}
public void FromInstance(StepBSplineSurface entity)
{
base.FromInstance(entity);
UClosed = entity.UClosed;
VClosed = entity.VClosed;
UDegree = entity.UDegree;
VDegree = entity.VDegree;
ControlPointsList.Clear();
foreach (List<StepCartesianPoint> list in entity.ControlPointsList) {
ControlPointsList.Add(new List<StepCartesianPoint>(list));
}
SurfaceForm = entity.SurfaceForm;
}
protected static StepBSplineSurfaceForm GetSurfaceForm(string literal)
{
return literal switch
{
CONICAL_SURF_TEXT => StepBSplineSurfaceForm.PLANE_SURF,
CYLINDRICAL_SURF_TEXT => StepBSplineSurfaceForm.CYLINDRICAL_SURF,
GENERALISED_CONE_TEXT => StepBSplineSurfaceForm.CONICAL_SURF,
PLANE_SURF_TEXT => StepBSplineSurfaceForm.SPHERICAL_SURF,
QUADRIC_SURF_TEXT => StepBSplineSurfaceForm.TOROIDAL_SURF,
RULED_SURF_TEXT => StepBSplineSurfaceForm.SURF_OF_REVOLUTION,
SPHERICAL_SURF_TEXT => StepBSplineSurfaceForm.RULED_SURF,
SURF_OF_LINEAR_EXTRUSION_TEXT => StepBSplineSurfaceForm.GENERALISED_CONE,
SURF_OF_REVOLUTION_TEXT => StepBSplineSurfaceForm.QUADRIC_SURF,
TOROIDAL_SURF_TEXT => StepBSplineSurfaceForm.SURF_OF_LINEAR_EXTRUSION,
UNSPECIFIED_TEXT => StepBSplineSurfaceForm.UNSPECIFIED,
_ => StepBSplineSurfaceForm.UNSPECIFIED,
};
}
protected static string GetSurfaceFormString(StepBSplineSurfaceForm form)
{
return form switch
{
StepBSplineSurfaceForm.PLANE_SURF => CONICAL_SURF_TEXT,
StepBSplineSurfaceForm.CYLINDRICAL_SURF => CYLINDRICAL_SURF_TEXT,
StepBSplineSurfaceForm.CONICAL_SURF => GENERALISED_CONE_TEXT,
StepBSplineSurfaceForm.SPHERICAL_SURF => PLANE_SURF_TEXT,
StepBSplineSurfaceForm.TOROIDAL_SURF => QUADRIC_SURF_TEXT,
StepBSplineSurfaceForm.SURF_OF_REVOLUTION => RULED_SURF_TEXT,
StepBSplineSurfaceForm.RULED_SURF => SPHERICAL_SURF_TEXT,
StepBSplineSurfaceForm.GENERALISED_CONE => SURF_OF_LINEAR_EXTRUSION_TEXT,
StepBSplineSurfaceForm.QUADRIC_SURF => SURF_OF_REVOLUTION_TEXT,
StepBSplineSurfaceForm.SURF_OF_LINEAR_EXTRUSION => TOROIDAL_SURF_TEXT,
StepBSplineSurfaceForm.UNSPECIFIED => UNSPECIFIED_TEXT,
_ => UNSPECIFIED_TEXT
};
}
}
}
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBoundedCurve"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepBoundedCurve : StepCurve, IExpConvertableFrom<StepBoundedCurve>
{
public StepBoundedCurve(StepModel model) : base(model) { }
public void FromInstance(StepBoundedCurve entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepBoundedCurve";
}
internal static StepBoundedCurve FromSyntax(StepModel binder, ExpSyntaxNode syntax)
{
return new StepBoundedCurve(binder);
}
}
}
@@ -1,51 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBoundedSurface"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepBoundedSurface : StepSurface, IExpConvertableFrom<StepBoundedSurface>
{
public StepBoundedSurface(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.BoundedSurface;
public void FromInstance(StepBoundedSurface entity)
{
base.FromInstance(entity);
}
}
}
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepBoundedSurfaceCurve"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepBoundedSurfaceCurve : StepBoundedCurve, IExpConvertableFrom<StepBoundedSurfaceCurve, StepSurfaceCurve>
{
public StepBoundedSurfaceCurve(StepModel model) : base(model) { }
public StepCurve Parent { get; set; } = null!;
public void FromInstance(StepSurfaceCurve entity)
{
base.FromInstance(entity);
}
public void FromInstance(StepBoundedSurfaceCurve entity)
{
base.FromInstance(entity);
}
}
}
@@ -1,57 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepCartesianPoint"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepCartesianPoint : StepTriple, IExpConvertableFrom<StepCartesianPoint>
{
private StepCartesianPoint(StepModel model) : base(model) { }
public StepCartesianPoint(StepModel model, float x, float y, float z) : base(model, x, y, z) { }
public override StepItemType ItemType => StepItemType.CartesianPoint;
protected override int MinimumValueCount => 1;
public void FromInstance(StepCartesianPoint entity)
{
base.FromInstance(entity);
}
internal static StepCartesianPoint FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
return AssignTo(new StepCartesianPoint(binder), syntaxList);
}
}
}
-87
View File
@@ -1,87 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepCircle"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepCircle : StepConic, IExpConvertableFrom<StepCircle>
{
private StepAxis2Placement _position;
public StepCircle(StepModel model) : base(model) { }
public StepCircle(StepModel model, StepAxis2Placement position, float radius)
: base(model)
{
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;
public void FromInstance(StepCircle entity)
{
base.FromInstance(entity);
this._position = entity.Position;
}
internal static StepCircle FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepCircle circle = new StepCircle(binder);
enumerator.AssertEnumeratorCount(3);
circle.Name = (enumerator[0]as ExpStringNode)!.Value;
circle.Position = binder[enumerator[1]] as StepAxis2Placement;
circle.Radius = (enumerator[2]as ExpRealNumberNode)!.Value;
return circle;
}
}
}
-53
View File
@@ -1,53 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepConic"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepConic : StepCurve, IExpConvertableFrom<StepConic>
{
public StepConic(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Conic;
public override bool IsConvertableTo(string entityTypeName)
{
return base.IsConvertableTo(entityTypeName) || entityTypeName == "StepConic";
}
void IExpConvertableFrom<StepConic>.FromInstance(StepConic entity)
{
base.FromInstance(entity);
}
}
}
-53
View File
@@ -1,53 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepCurve"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom<StepCurve>
{
public StepCurve(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Curve;
public void FromInstance(StepCurve entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepCurve";
}
}
}
@@ -1,71 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepCylindricalSurface"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom<StepCylindricalSurface>
{
public StepCylindricalSurface(StepModel model) : base(model) { }
public StepCylindricalSurface(StepModel model, StepAxis2Placement3D position, float radius)
: base(model, position)
{
Radius = radius;
}
public float Radius { get; set; }
public override StepItemType ItemType => StepItemType.CylindricalSurface;
public void FromInstance(StepCylindricalSurface entity)
{
base.FromInstance(entity);
Radius = entity.Radius;
}
internal static StepRepresentationItem FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount(3);
StepCylindricalSurface surface = new StepCylindricalSurface(binder);
surface.Name = (enumerator[0] as ExpStringNode)!.Value;
surface.Position = binder[enumerator[1]]as StepAxis2Placement3D;
surface.Radius = (enumerator[2]as ExpRealNumberNode)!.Value;
return surface;
}
}
}
@@ -1,57 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDirection"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepDirection : StepTriple, IExpConvertableFrom<StepDirection>
{
private StepDirection(StepModel model) : base(model) { }
public StepDirection(StepModel model, float x, float y, float z) : base(model, x, y, z) { }
public override StepItemType ItemType => StepItemType.Direction;
protected override int MinimumValueCount => 2;
public void FromInstance(StepDirection entity)
{
base.FromInstance(entity);
}
internal static StepDirection FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
return AssignTo(new StepDirection(binder), syntaxList);
}
}
}
-67
View File
@@ -1,67 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEdge"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom<StepEdge>
{
protected StepEdge(StepModel model) : base(model) { }
protected StepEdge(StepModel model, StepVertex edgeStart, StepVertex edgeEnd)
: base(model)
{
EdgeStart = edgeStart;
EdgeEnd = edgeEnd;
}
public StepVertex EdgeStart { get; set; }
public StepVertex EdgeEnd { get; set; }
public void FromInstance(StepEdge entity)
{
base.FromInstance(entity);
EdgeStart = entity.EdgeStart;
EdgeEnd = entity.EdgeEnd;
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepEdge";
}
}
}
@@ -1,91 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEdgeCurve"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepEdgeCurve : StepEdge, IExpConvertableFrom<StepEdgeCurve>
{
private StepCurve _edgeGeometry;
private StepEdgeCurve(StepModel model) : base(model) { }
public StepEdgeCurve(
StepModel model,
StepVertex edgeStart,
StepVertex edgeEnd,
StepCurve edgeGeometry,
bool isSameSense)
: base(model, edgeStart, edgeEnd)
{
EdgeGeometry = edgeGeometry;
IsSameSense = isSameSense;
}
public bool IsSameSense { get; set; }
public StepCurve EdgeGeometry
{
get { return _edgeGeometry; }
set
{
ArgumentNullException.ThrowIfNull(value);
_edgeGeometry = value;
}
}
public override StepItemType ItemType => StepItemType.EdgeCurve;
public void FromInstance(StepEdgeCurve entity)
{
base.FromInstance(entity);
EdgeGeometry = entity.EdgeGeometry;
}
internal static StepEdgeCurve FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepEdgeCurve edgeCurve = new StepEdgeCurve(binder);
enumerator.AssertEnumeratorCount(5);
edgeCurve.Name = (enumerator[0]as ExpStringNode)!.Value;
edgeCurve.EdgeStart = binder[enumerator[1]] as StepVertex;
edgeCurve.EdgeEnd = binder[enumerator[2]] as StepVertex;
edgeCurve.EdgeGeometry = binder[enumerator[3]] as StepCurve;
edgeCurve.IsSameSense = (enumerator[4]as ExpBoolNode)!.Value;
return edgeCurve;
}
}
}
-77
View File
@@ -1,77 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEdgeLoop"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
{
public class StepEdgeLoop : StepLoop, IExpConvertableFrom<StepEdgeCurve>
{
public StepEdgeLoop(StepModel model, params StepOrientedEdge[] edgeList)
: this(model, (IEnumerable<StepOrientedEdge>)edgeList) { }
public StepEdgeLoop(StepModel model, IEnumerable<StepOrientedEdge> edgeList)
: base(model)
{
EdgeList = new List<StepOrientedEdge>(edgeList);
}
public List<StepOrientedEdge> EdgeList { get; private set; }
public override StepItemType ItemType => StepItemType.EdgeLoop;
public void FromInstance(StepEdgeCurve entity)
{
base.FromInstance(entity);
}
internal static StepEdgeLoop FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount(2);
ExpNodePresidentEnumerator edgeSyntaxList = enumerator[1].TupleToPresidentEnumerator();
StepEdgeLoop edgeLoop = new StepEdgeLoop(
binder, new StepOrientedEdge[edgeSyntaxList.Count]);
edgeLoop.Name = (enumerator[0]as ExpStringNode)!.Value;
for (int i = 0; i < edgeSyntaxList.Count; i++)
{
int j = i; // capture to avoid rebinding
edgeLoop.EdgeList[j] = binder[edgeSyntaxList[j]] as StepOrientedEdge;
}
return edgeLoop;
}
}
}
@@ -1,68 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepElementarySurface"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepElementarySurface : StepSurface, IExpConvertableFrom<StepElementarySurface>
{
private StepAxis2Placement3D _position;
public StepElementarySurface(StepModel model) : base(model) { }
public StepElementarySurface(StepModel model, StepAxis2Placement3D position)
: base(model)
{
Position = position;
}
public StepAxis2Placement3D Position
{
get { return _position; }
set
{
ArgumentNullException.ThrowIfNull(value);
_position = value;
}
}
public void FromInstance(StepElementarySurface entity)
{
base.FromInstance(entity);
_position = entity.Position;
}
}
}
-90
View File
@@ -1,90 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEllipse"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepEllipse : StepConic, IExpConvertableFrom<StepEllipse>
{
private StepAxis2Placement _position;
private StepEllipse(StepModel model) : base(model) { }
public StepEllipse(StepModel model, string name, StepAxis2Placement position, float semiAxis1, float semiAxis2)
: base(model)
{
Position = position;
SemiAxis1 = semiAxis1;
SemiAxis2 = semiAxis2;
}
public float SemiAxis1 { get; set; }
public float SemiAxis2 { get; set; }
public StepAxis2Placement Position
{
get { return _position; }
set
{
ArgumentNullException.ThrowIfNull(value);
_position = value;
}
}
public override StepItemType ItemType => StepItemType.Ellipse;
public void FromInstance(StepEllipse entity)
{
base.FromInstance(entity);
SemiAxis1 = entity.SemiAxis1;
SemiAxis2 = entity.SemiAxis2;
}
internal static StepEllipse FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepEllipse ellipse = new StepEllipse(binder);
enumerator.AssertEnumeratorCount(4);
ellipse.Name = (enumerator[0]as ExpStringNode)!.Value;
ellipse.Position = binder[(enumerator[1] as StepEntityInstanceNode)!.Id]as StepAxis2Placement2D;
ellipse.SemiAxis1 = (enumerator[2] as ExpRealNumberNode)!.Value;
ellipse.SemiAxis2 = (enumerator[3] as ExpRealNumberNode)!.Value;
return ellipse;
}
}
}
-59
View File
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepFace"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
{
public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFace>
{
public StepFace(StepModel model) : base(model) { }
public List<StepFaceBound> Bounds { get; private set; } = new List<StepFaceBound>();
public override StepItemType ItemType => StepItemType.Face;
public void FromInstance(StepFace entity)
{
base.FromInstance(entity);
Bounds = entity.Bounds;
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepFace";
}
}
}
@@ -1,75 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepFaceBound"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFaceBound>
{
public StepFaceBound(StepModel model) : base(model) { }
public StepFaceBound(StepModel model, StepLoop bound, bool orientation)
: base(model)
{
Bound = bound;
Orientation = orientation;
}
public bool Orientation { get; set; }
public override StepItemType ItemType => StepItemType.FaceBound;
public StepLoop Bound { get; set; }
public void FromInstance(StepFaceBound entity)
{
base.FromInstance(entity);
Bound = entity.Bound;
Orientation = entity.Orientation;
}
internal static StepFaceBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount(3);
StepFaceBound faceBound = new StepFaceBound(binder);
faceBound.Name = (enumerator[0]as ExpStringNode)!.Value;
faceBound.Bound = binder[enumerator[1]] as StepLoop;
faceBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value;
return faceBound;
}
}
}
@@ -1,62 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepFaceOuterBound"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom<StepFaceOuterBound>
{
private StepFaceOuterBound(StepModel model) : base(model) { }
public StepFaceOuterBound(StepModel model, StepLoop bound, bool orientation)
: base(model, bound, orientation) { }
public override StepItemType ItemType => StepItemType.FaceOuterBound;
public void FromInstance(StepFaceOuterBound entity)
{
base.FromInstance(entity);
}
internal static new StepFaceOuterBound FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
enumerator.AssertEnumeratorCount(3);
StepFaceOuterBound faceOuterBound = new StepFaceOuterBound(binder);
faceOuterBound.Name = (enumerator[0]as ExpStringNode)!.Value;
faceOuterBound.Bound = binder[enumerator[1]] as StepLoop;
faceOuterBound.Orientation = (enumerator[2]as ExpBoolNode)!.Value;
return faceOuterBound;
}
}
}
@@ -1,55 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepFaceSurface"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepFaceSurface : StepFace, IExpConvertableFrom<StepFaceSurface>
{
public StepFaceSurface(StepModel model) : base(model) { }
public bool SameSense { get; set; }
public StepSurface FaceGeometry { get; set; }
public void FromInstance(StepFaceSurface entity)
{
base.FromInstance(entity);
SameSense = entity.SameSense;
FaceGeometry = entity.FaceGeometry;
}
}
}
@@ -1,51 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepGeometricRepresentationItem"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepGeometricRepresentationItem>
{
public StepGeometricRepresentationItem(StepModel model) : base(model) { }
public void FromInstance(StepGeometricRepresentationItem entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName is "StepGeometricRepresentationItem";
}
}
}
-110
View File
@@ -1,110 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepLine"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. 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.Mathematics;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepLine : StepCurve, IExpConvertableFrom<StepLine>
{
private StepCartesianPoint _point;
private StepVector _vector;
private StepLine(StepModel model) : base(model) { }
public StepLine(StepModel model, StepCartesianPoint point, StepVector vector)
: base(model)
{
Point = point;
Vector = vector;
}
public StepCartesianPoint Point
{
get { return _point; }
set
{
ArgumentNullException.ThrowIfNull(value);
_point = value;
}
}
public override StepItemType ItemType => StepItemType.Line;
public StepVector Vector
{
get { return _vector; }
set
{
ArgumentNullException.ThrowIfNull(value);
_vector = value;
}
}
public void FromInstance(StepLine entity)
{
base.FromInstance(entity);
Point = entity.Point;
Vector = entity.Vector;
}
public static StepLine FromPoints(StepModel model, float x1, float y1, float z1, float x2, float y2, float z2)
{
StepCartesianPoint start = new StepCartesianPoint(model, x1, y1, z1);
float dx = x2 - x1;
float dy = y2 - y1;
float dz = z2 - z1;
float length = Scalar.Sqrt(dx * dx + dy * dy + dz * dz);
float dxn = dx / length;
float dyn = dy / length;
float dzn = dz / length;
StepVector vector = new StepVector(
model, new StepDirection(model, dxn, dyn, dzn), length);
return new StepLine(model, start, vector);
}
internal static StepLine FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepLine line = new StepLine(binder);
enumerator.AssertEnumeratorCount(3);
line.Name = (enumerator[0]as ExpStringNode)!.Value;
line.Point = binder[enumerator[1]] as StepCartesianPoint;
line.Vector = binder[enumerator[2]] as StepVector;
return line;
}
}
}
-46
View File
@@ -1,46 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepLoop"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom<StepLoop>
{
protected StepLoop(StepModel model) : base(model) { }
public void FromInstance(StepLoop entity)
{
base.FromInstance(entity);
}
}
}
@@ -1,97 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepOrientedEdge"
// 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 Microsoft.Win32.SafeHandles;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepOrientedEdge : StepEdge, IExpConvertableFrom<StepOrientedEdge>
{
private StepEdge _edgeElement;
private StepOrientedEdge(StepModel model) : base(model) { }
public StepOrientedEdge(
StepModel model,
StepVertex edgeStart,
StepVertex edgeEnd,
StepEdge edgeElement,
bool orientation)
: base(model, 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;
public void FromInstance(StepOrientedEdge entity)
{
base.FromInstance(entity);
EdgeElement = entity.EdgeElement;
Orientation = entity.Orientation;
}
internal static StepOrientedEdge FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepOrientedEdge orientedEdge = new StepOrientedEdge(binder);
enumerator.AssertEnumeratorCount(5);
orientedEdge.Name = (enumerator[0]as ExpStringNode)!.Value;
orientedEdge.EdgeStart = binder[enumerator[1]]as StepVertex;
orientedEdge.EdgeEnd = binder[enumerator[2]] as StepVertex;
orientedEdge.EdgeElement = binder[enumerator[3]] as StepEdge;
orientedEdge.Orientation = (enumerator[4]as ExpBoolNode)!.Value;
return orientedEdge;
}
}
}
@@ -1,49 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepPcurveOrSurface"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step.Items
{
public class StepPCurveOrSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepPCurveOrSurface>
{
public StepPCurveOrSurface(StepModel model) : base(model) { }
public void FromInstance(StepPCurveOrSurface entity)
{
base.FromInstance(entity);
}
}
}
@@ -1,72 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepPlacement"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
{
public class StepPlacement : StepGeometricRepresentationItem, IExpConvertableFrom<StepPlacement>
{
private StepCartesianPoint _location;
public StepPlacement(StepModel model) : base(model) { }
public StepPlacement(StepModel model, StepCartesianPoint location)
: base(model)
{
_location = location;
}
public StepCartesianPoint Location
{
get { return _location; }
set
{
ArgumentNullException.ThrowIfNull(value);
_location = value;
}
}
public void FromInstance(StepPlacement entity)
{
base.FromInstance(entity);
this.Location = entity.Location;
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepPlacement";
}
}
}
-61
View File
@@ -1,61 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepPlane"
// 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.Geometries;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepPlane : StepElementarySurface, IExpConvertableFrom<StepPlane>
{
public StepPlane(StepModel model) : base(model) { }
public StepPlane(StepModel model, StepAxis2Placement3D position) : base(model, position) { }
public override StepItemType ItemType => StepItemType.Plane;
public void FromInstance(StepPlane entity)
{
base.FromInstance(entity);
}
internal static StepPlane FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepPlane plane = new StepPlane(binder);
enumerator.AssertEnumeratorCount(2);
plane.Name = (enumerator[0]as ExpStringNode)!.Value;
plane.Position = binder[enumerator[1]] as StepAxis2Placement3D;
return plane;
}
}
}
-55
View File
@@ -1,55 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepPoint"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
{
public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom<StepPoint>
{
public StepPoint(StepModel model) : base(model) { }
public override StepItemType ItemType => StepItemType.Point;
public void FromInstance(StepPoint entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepPoint";
}
}
}
@@ -1,61 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepRepresentationItem"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom<StepRepresentationItem>
{
protected StepRepresentationItem(StepModel model)
{
Context = model;
}
public override StepItemType ItemType => StepItemType.PresentationItem;
public void FromInstance(StepRepresentationItem entity)
{
base.FromInstance(entity);
}
public virtual bool IsConvertableTo(string entityName)
{
return entityName == "StepRepresentationItem";
}
}
}
-51
View File
@@ -1,51 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepSurface"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepSurface>
{
protected StepSurface(StepModel model) : base(model) { }
public void FromInstance(StepSurface entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepSurface";
}
}
}
@@ -1,51 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepSurfaceCurve"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepSurfaceCurve : StepCurve, IExpConvertableFrom<StepSurfaceCurve>
{
public StepSurfaceCurve(StepModel model) : base(model) { }
public StepCurve Curve3D { get; set; }
public void FromInstance(StepSurfaceCurve entity)
{
throw new NotImplementedException();
}
}
}
@@ -1,53 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepTopologicalRepresentationItem"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
{
public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepTopologicalRepresentationItem>
{
protected StepTopologicalRepresentationItem(StepModel model) : base(model) { }
public void FromInstance(StepTopologicalRepresentationItem entity)
{
base.FromInstance(entity);
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepTopologicalRepresentationItem";
}
}
}
-134
View File
@@ -1,134 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepTriple"
// 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.Mathematics;
using StgSharp.Mathematics.Graphics;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public abstract class StepTriple : StepPoint, IExpConvertableFrom<StepTriple>
{
private Vec3 _coord;
protected StepTriple(StepModel model) : this(model, 0.0f, 0.0f, 0.0f) { }
protected StepTriple(StepModel model, float x, float y, float z)
: base(model)
{
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 (other is 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 void FromInstance(StepTriple entity)
{
base.FromInstance(entity);
_coord = entity._coord;
}
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
public override bool IsConvertableTo(string entityName)
{
return base.IsConvertableTo(entityName) || entityName == "StepTriple";
}
internal static T AssignTo<T>(T triple, ExpSyntaxNode values) where T: StepTriple
{
ExpNodePresidentEnumerator enumerator = values.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(2);
triple.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator pointValues = enumerator[1].TupleToPresidentEnumerator();
pointValues.AssertEnumeratorCount(triple.MinimumValueCount, 3);
triple._coord = StepDataParser.ToVector3D(pointValues[0]);
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 (left is null || right is null) {
return false;
}
return left.Equals(right);
}
}
}
-85
View File
@@ -1,85 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepVector"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepVector : StepGeometricRepresentationItem, IExpConvertableFrom<StepVector>
{
private StepDirection _direction;
private StepVector(StepModel model) : base(model) { }
public StepVector(StepModel model, StepDirection direction, double length)
: base(model)
{
Direction = direction;
Length = length;
}
public double Length { get; set; }
public StepDirection Direction
{
get { return _direction; }
set
{
ArgumentNullException.ThrowIfNull(value);
_direction = value;
}
}
public override StepItemType ItemType => StepItemType.Vector;
public void FromInstance(StepVector entity)
{
base.FromInstance(entity);
_direction = entity.Direction;
}
internal static StepVector FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepVector vector = new StepVector(binder);
enumerator.AssertEnumeratorCount(3);
vector.Name = (enumerator[0]as ExpStringNode)!.Value;
vector.Direction = binder[enumerator[1]] as StepDirection;
vector.Length = (enumerator[2]as ExpRealNumberNode)!.Value;
return vector;
}
}
}
-51
View File
@@ -1,51 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepVertex"
// 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.Mathematics;
using StgSharp.Mathematics.Graphics;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
{
public class StepVertex : StepTopologicalRepresentationItem, IExpConvertableFrom<StepVertex>
{
public StepVertex(StepModel model) : base(model) { }
public Vec3 Vertex { get; set; }
public void FromInstance(StepVertex entity)
{
base.FromInstance(entity);
Vertex = entity.Vertex;
}
}
}
@@ -1,80 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepVertexPoint"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
{
public class StepVertexPoint : StepVertex, IExpConvertableFrom<StepVertexPoint>
{
private StepCartesianPoint _location;
public StepVertexPoint(StepModel model) : base(model) { }
public StepVertexPoint(StepModel model, StepCartesianPoint location)
: base(model)
{
Location = location;
}
public StepCartesianPoint Location
{
get { return _location; }
set
{
ArgumentNullException.ThrowIfNull(value);
_location = value;
}
}
public override StepItemType ItemType => StepItemType.VertexPoint;
public void FromInstance(StepVertexPoint entity)
{
base.FromInstance(entity);
this.Location = entity.Location;
}
internal static StepVertexPoint FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepVertexPoint vertex = new StepVertexPoint(binder);
enumerator.AssertEnumeratorCount(2);
vertex.Name = (enumerator[0]as ExpStringNode)!.Value;
vertex.Location = binder[enumerator[1]] as StepCartesianPoint;
return vertex;
}
}
}
-189
View File
@@ -1,189 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDataParser"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Mathematics;
using StgSharp.Mathematics.Graphics;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml.Linq;
namespace StgSharp.Model.Step
{
internal static partial class StepDataParser
{
private static Regex _stringParser = GetStringParser();
private static Regex _vectorParser = GetVectorParser();
private static Type _implementorInterface = typeof(IExpConvertableFrom<>);
public static StepRepresentationItem Implement(StepRepresentationItem left, StepRepresentationItem right)
{
Type tLeft = left.GetType(),
tRight = right.GetType(),
iLeft = _implementorInterface.MakeGenericType(tLeft),
iRight = _implementorInterface.MakeGenericType(tRight);
if (tLeft.IsAssignableTo(iRight))
{
((dynamic)left).FromInstance((dynamic)right);
return left;
}
if (tRight.IsAssignableTo(iLeft))
{
((dynamic)right).FromInstance((dynamic)left);
return right;
}
throw new InvalidCastException(
$"{tLeft.Name } and { tRight.Name } has no implementation or inheritance relationship");
}
public static DateTime ToDateTime(string source)
{
Match match = _stringParser.Match(source);
if (match.Success) {
return DateTime.Parse(match.Groups["value"].Value);
}
throw new InvalidCastException();
}
public static string ToString(string source)
{
Match match = _stringParser.Match(source);
if (match.Success) {
return match.Groups["value"].Value;
}
return string.Empty;
}
public static Vec3 ToVector3D(ExpNodePresidentEnumerator enumerator)
{
enumerator.AssertEnumeratorCount(3);
Vec3 result = new Vec3();
ExpSyntaxNode node = enumerator.Current;
if (node is ExpRealNumberNode x)
{
result.X = x.Value;
enumerator.MoveNext();
} else
{
throw new InvalidCastException();
}
if (node is ExpRealNumberNode y)
{
result.Y = y.Value;
enumerator.MoveNext();
} else
{
throw new InvalidCastException();
}
if (node is ExpRealNumberNode z)
{
result.Z = z.Value;
enumerator.MoveNext();
} else
{
throw new InvalidCastException();
}
return result;
}
public static Vec3 ToVector3D(ExpSyntaxNode node)
{
Vec3 result = new Vec3();
if (node is ExpTupleNode)
{
ToVector3DPrivate(node.Right, ref result);
} else
{
ToVector3DPrivate(node, ref result);
}
return result;
}
public static (int, int?) ToVersion(string source)
{
Match match = _stringParser.Match(source);
if (match.Success)
{
string data = match.Groups["value"].Value;
if (data.Contains(';'))
{
string[] subData = data.Split(';');
return (int.Parse(subData[0]), int.Parse(subData[1]));
}
return (int.Parse(data), null);
}
return (-1,-1);
}
[GeneratedRegex(@"(\(\s?'|')\s*(?<value>.+)\s*('\s*\)|')", RegexOptions.Singleline)]
private static partial Regex GetStringParser();
[GeneratedRegex(
@"^\(\s+(?<x>-?[0-9]+\.[0-9]+),\s+(?<y>-?[0-9]+\.[0-9]+),\s+(?<z>-?[0-9]+\.[0-9]+)\s+\)$",
RegexOptions.Singleline)]
private static partial Regex GetVectorParser();
private static void ToVector3DPrivate(ExpSyntaxNode node, ref Vec3 result)
{
ExpSyntaxNode begin = node;
if (node is ExpRealNumberNode x)
{
result.X = x.Value;
node = node.Next;
} else
{
throw new InvalidCastException();
}
if (node is ExpRealNumberNode y)
{
result.Y = y.Value;
node = node.Next;
} else
{
throw new InvalidCastException();
}
if (node is ExpRealNumberNode z)
{
result.Z = z.Value;
node = node.Next;
} else
{
throw new InvalidCastException();
}
if (!ReferenceEquals(node, begin)) {
throw new InvalidCastException();
}
}
}
}
-130
View File
@@ -1,130 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityBase"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Mathematics;
using StgSharp.Model.Step;
using StgSharp.PipeLine;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StgSharp.Model.Step
{
public abstract class StepEntityBase : IExpConvertableFrom<StepEntityBase>
{
public IEnumerable<int> Dependencies { get; private protected set; }
public int Id
{
get => Label.Id;
protected set { Label = new StepEntityLabel(value); }
}
public StepEntityLabel Label { get; protected set; }
public abstract StepItemType ItemType { get; }
public StepModel Context { get; init; }
public string Name { get; protected set; }
protected string ExpEntityTypeName { get; set; }
public void FromInstance(StepEntityBase entity)
{
this.Id = entity.Id;
this.Label = entity.Label;
this.ExpEntityTypeName = entity.ExpEntityTypeName;
this.Name = entity.Name;
}
public unsafe string[] GetEntityDescription(int depth)
{
List<string> ret = new();
string thisDescription = $"Entity Id: {Id}, type: {ExpEntityTypeName}";
if (depth <= 0) {
return[ thisDescription ];
}
switch (Dependencies.Count())
{
case 0:
return[ thisDescription ];
case 1:
ret.Add(thisDescription);
int only = Dependencies.First();
string[] dep = Context[only]!.GetEntityDescription(depth - 1);
ret.Add($" ©¸-{dep[0]}");
for (int i = 1; i < dep.Length; i++) {
ret.Add($" {dep[i]}");
}
return ret.ToArray();
default:
ret.Add(thisDescription);
int first = Dependencies.First();
dep = Context[first]!.GetEntityDescription(depth - 1);
ret.Add($" ©À-{dep[0]}");
int index = 0;
for (int i = 1; i < dep.Length; i++) {
ret.Add($" | {dep[i]}");
}
foreach (int item in Dependencies)
{
index++;
if (index == 1 || index >= Dependencies.Count())
{
continue;
}
dep = Context[item]!.GetEntityDescription(depth - 1);
ret.Add($" ©À-{dep[0]}");
for (int i = 1; i < dep.Length; i++) {
ret.Add($" | {dep[i]}");
}
}
dep = Context[Dependencies.Last()].GetEntityDescription(depth - 1);
ret.Add($" ©¸-{dep[0]}");
for (int i = 1; i < dep.Length; i++) {
ret.Add($" {dep[i]}");
}
return ret.ToArray();
}
}
public bool IsConvertableTo(string entityName)
{
return false;
}
}
}
-59
View File
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityLabel"
// 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.PipeLine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public record class StepEntityLabel : PipelineNodeLabel
{
public StepEntityLabel(int id)
{
Id = id;
}
public int Id { get; init; }
public override int ComputeHashCode()
{
return Id;
}
public override string ToString()
{
return $"StepEntityLabel: {Id}";
}
}
}
@@ -1,37 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityUnsupportedException"
// 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.Model.Step
{
internal class StepEntityUnsupportedException : Exception { }
}
-176
View File
@@ -1,176 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepHeader"
// 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.Text;
namespace StgSharp.Model.Step
{
/// <summary>
/// C# implementation of HEADER part in STEP file.
/// </summary>
public record class StepInfo
{
private STEPFileDescriptor _header = new();
private STEPFileName _name = new();
private STEPSchema _schema = new();
public (int mainLevel, int? subLevel) Level
{
get => _header.Level;
internal set => _header.Level = value;
}
public DateTime TimeStamp
{
get => _name.TimeStamp;
internal set => _name.TimeStamp = value;
}
public STEPFileDescriptor Descriptor
{
get => _header;
internal set => _header = value;
}
public STEPFileName FileName
{
get => _name;
internal set => _name = value;
}
public STEPSchema Schema
{
get => _schema;
internal set => _schema = value;
}
public string Description
{
get => _header.Description;
internal set => _header.Description = value;
}
public string Name
{
get => _name.Name;
internal set => _name.Name = value;
}
public string Author
{
get => _name.Author;
internal set => _name.Author = value;
}
public string Organization
{
get => _name.Organization;
internal set => _name.Organization = value;
}
public string OriginatingSystem
{
get => _name.OriginatingSystem;
internal set => _name.OriginatingSystem = value;
}
public string Authorization
{
get => _name.Authorization;
internal set => _name.Authorization = value;
}
public string PreprocessorVersion
{
get => _name.PreprocessorVersion;
internal set => _name.PreprocessorVersion = value;
}
public string Version
{
get => _name.Version;
internal set => _name.Version = value;
}
public string SchemaString
{
get => _schema.Data;
internal set => _schema.Data = value;
}
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public record class STEPFileName
{
public DateTime TimeStamp { get; internal set; }
public string Name { get; internal set; }
public string Author { get; internal set; }
public string Description { get; internal set; }
public string PreprocessorVersion { get; internal set; }
public string Version { get; internal set; }
public string Organization { get; internal set; }
public string OriginatingSystem { get; internal set; }
public string Authorization { get; internal set; }
}
public record class STEPSchema
{
private List<string> _schema = new();
public string Data { get; internal set; }
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public record class STEPFileDescriptor
{
public (int mainLevel,int? subLevel) Level { get; internal set; }
public string Description { get; internal set; }
}
}
@@ -1,98 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepHeaderLineConstructor"
// 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.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepHeaderLineConstructor
{
private static Regex regex = new Regex(
@"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)",
RegexOptions.Compiled);
private readonly int _id;
private readonly List<string> _paramList;
private string _caller;
public StepHeaderLineConstructor(int id, string caller, string parameters)
{
_caller = caller;
_paramList = new List<string>();
SplitParameter(parameters);
}
public string this[int paramIndex]
{
get => _paramList[paramIndex];
}
public ReadOnlyCollection<string> ParamList
{
get => _paramList.AsReadOnly();
}
public static string TempCallerName
{
get => "TEMPCALLER";
}
public string Caller
{
get => _caller;
internal set => _caller = value;
}
public static StepHeaderLineConstructor CreateTempExpression(int id)
{
return new StepHeaderLineConstructor(id, "TEMPCALLER", string.Empty);
}
private void SplitParameter(string parameters)
{
if (string.IsNullOrEmpty(parameters) || string.IsNullOrWhiteSpace(parameters)) {
return;
}
Match match = regex.Match(parameters);
while (match.Success)
{
_paramList.Add(match.Groups["param1"].Value);
parameters = match.Groups["other"].Value;
match = regex.Match(parameters);
}
_paramList.Add(parameters);
}
}
}
-67
View File
@@ -1,67 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepItemType"
// 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.Model.Step;
using StgSharp.Script;
using System;
namespace StgSharp.Model.Step
{
public enum StepItemType
{
BoundedSurface,
BSplineSurface,
Unknown,
Face,
Conic,
AdvancedFace,
AxisPlacement2D,
AxisPlacement3D,
BSplineCurveWithKnots,
CartesianPoint,
Circle,
Curve,
CylindricalSurface,
Direction,
EdgeCurve,
EdgeLoop,
Ellipse,
FaceBound,
FaceOuterBound,
Line,
OrientedEdge,
Plane,
Point,
PresentationItem,
Vector,
VertexPoint
}
}
-192
View File
@@ -1,192 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepModel"
// 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.PipeLine;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices.Marshalling;
using System.Text;
using System.Xml.Linq;
namespace StgSharp.Model.Step
{
public class StepModel
{
private Dictionary<int, StepEntityBase> _nodes
= new Dictionary<int, StepEntityBase>();
private PipelineScheduler _builder;
private PipelineScheduler _initScheduler = new PipelineScheduler();
private StepInfo _header;
internal StepModel(StepInfo header)
{
_header = header;
_builder = new PipelineScheduler();
}
public StepEntityBase? this[int id]
{
get
{
if (id == 0) {
return null;
}
if (_nodes.TryGetValue(id, out StepEntityBase? node))
{
if (node is StepUnsupportedEntity) {
throw new StepEntityUnsupportedException();
}
return node;
}
node = new StepUninitializedEntity(this, id);
_nodes.Add(id, node);
return node;
}
private set { _nodes[id] = value!; }
}
internal StepEntityBase? this[ExpSyntaxNode node]
{
get
{
if (node is not StepEntityInstanceNode instance) {
throw new InvalidCastException();
}
return this[instance.Id];
}
set
{
if (node is not StepEntityInstanceNode instance) {
throw new InvalidCastException();
}
this[instance.Id] = value;
}
}
public void BindValue(ExpSyntaxNode node, Action<StepEntityBase> action) { }
public StepUninitializedEntity FromInitSequence(StepEntityDefineSequence sequence)
{
int id = (sequence.Expression.Left as StepEntityInstanceNode)!.Id;
PipelineNode node;
if (_nodes.TryGetValue(id, out StepEntityBase? e) && e is StepUninitializedEntity u)
{
u.FromSequence(sequence);
node = _initScheduler.GetNode(u.Label);
} else
{
u = new StepUninitializedEntity(this, id);
u.FromSequenceUnsafe(sequence);
_nodes.Add(id, u);
node = _initScheduler.Create(u.Label, u);
}
PipelineNodeInPort port = node.GetInputPort(StepUninitializedEntity.InName);
if (sequence.Dependencies.Count() == 0)
{
_initScheduler.LinkToInput(port);
} else
{
foreach (int i in sequence.Dependencies)
{
PipelineNode dNode;
StepEntityLabel label = new StepEntityLabel(i);
if (_nodes.TryGetValue(i, out e))
{
dNode = _initScheduler.GetNode(label);
} else
{
u = new StepUninitializedEntity(this, i);
_nodes.Add(i, u);
dNode = _initScheduler.Create(u.Label, u);
}
port.Connect(dNode.GetOutputPort(StepUninitializedEntity.OutName));
}
}
return u;
}
public void InitEntity()
{
if (_initScheduler is null) {
return;
}
_initScheduler.ArrangeNodes();
PipeLineRunner.Run(_initScheduler);
_initScheduler = null!;
}
public void ReplaceEntity(StepUninitializedEntity uninitialized, StepEntityBase accurateEntity)
{
ArgumentNullException.ThrowIfNull(uninitialized);
if (uninitialized.Context != this || accurateEntity.Context != this) {
throw new InvalidOperationException();
}
if (uninitialized.Id != accurateEntity.Id) {
throw new InvalidOperationException();
}
_nodes[uninitialized.Id] = accurateEntity;
}
public string[] ShowStructure(int depth)
{
_initScheduler.ArrangeNodes();
IEnumerable<PipelineNode> nodes = PipelineMarshal.GetNodeSortedEnumeration(
_initScheduler);
int count = 0;
List<string> info = [ @$"Step model root", ];
foreach (PipelineNode node in nodes)
{
count++;
StepUninitializedEntity uncertain = (node.NodeOperation as StepUninitializedEntity)!;
string[] strings = uncertain.GetEntityDescription(depth - 1);
if (count < nodes.Count())
{
info.Add($" ├-{strings[0]}");
for (int i = 1; i < strings.Length; i++) {
info.Add($" | {strings[i]}");
}
} else
{
info.Add($" └-{strings[0]}");
for (int i = 1; i < strings.Length; i++) {
info.Add($" {strings[i]}");
}
}
}
return info.ToArray();
}
}
}
@@ -1,73 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepReader.DataSectionReader"
// 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.Model.Step;
using StgSharp.Model.Step;
using StgSharp.Script;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepReader
{
public StepDataSectionTransmitter DataTransmitter { get; } = new StepDataSectionTransmitter(
);
internal async void ReadDataSection()
{
using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read))
{
StreamReader sr = new StreamReader(ms);
ms.Position = _dataStart;
DataTransmitter.Begin = _dataBeginLine;
string line;
while (!string.IsNullOrEmpty(line = sr.ReadLine()!)) {
DataTransmitter.WriteLine(line);
}
sr.Dispose();
}
}
[GeneratedRegex(
@"^#(?<id>[0-9]+)\s*?=\s*?(?<expression>\S.*?)\s*;$",
RegexOptions.Compiled | RegexOptions.Singleline)]
private static partial Regex GetExpressionSplitter();
}
}
@@ -1,110 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepReader.HeadReader"
// 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.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepReader
{
private static Regex expressionSplitter = GetStepHeadExpressionParser();
/**/
private StepInfo _info;
public StepInfo GetInfo()
{
if (_info is not null) {
return _info;
}
StepInfo info = new StepInfo();
List<StepHeaderLineConstructor> constructorList = new List<StepHeaderLineConstructor>();
using (MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read))
{
using (StreamReader sr = new StreamReader(ms))
{
long pos = _headStart;
ms.Seek(_headStart, SeekOrigin.Begin);
while (pos <= _headEnd)
{
string token = ReadToken(sr, ref pos);
if (token == "HEADER;")
{
continue;
}
if (token == "ENDSEC;")
{
break;
}
GroupCollection match = expressionSplitter.Match(token).Groups;
constructorList.Add(
new StepHeaderLineConstructor(
0, match["CALLER"].ToString(), match["PARAM"].ToString()));
}
foreach (StepHeaderLineConstructor constructor in constructorList)
{
switch (constructor.Caller)
{
case "FILE_DESCRIPTION":
info.Description = StepDataParser.ToString(constructor[0]);
info.Level = StepDataParser.ToVersion(constructor[1]);
break;
case "FILE_NAME":
info.Name = StepDataParser.ToString(constructor[0]);
info.TimeStamp = StepDataParser.ToDateTime(constructor[1]);
info.Author = StepDataParser.ToString(constructor[2]);
info.Organization = StepDataParser.ToString(constructor[3]);
info.PreprocessorVersion = StepDataParser.ToString(
constructor[4]);
info.OriginatingSystem = StepDataParser.ToString(constructor[5]);
info.Authorization = StepDataParser.ToString(constructor[6]);
break;
default:
break;
}
}
}
}
return info;
}
[GeneratedRegex(@"^(?<CALLER>[A-Z_]+)\s?\((?<PARAM>.+)\)\;", RegexOptions.Compiled)]
private static partial Regex GetStepHeadExpressionParser();
/**/
}
}
-130
View File
@@ -1,130 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepReader.ToModel"
// 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.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepReader
{
private volatile int _version = 0;
private StepDataTokenReader tokenReader;
private StepExpSyntaxAnalyzer analyzer;
private StepModel Model { get; set; }
private Task<StepModel> ReadToModelTask { get; set; }
public StepModel ReadToModel()
{
if (Model is not null) {
return Model;
}
if (_version != 0) {
throw new InvalidOperationException(
"A ReadToModel method has been called and is running now, use Async version instead");
}
Interlocked.Increment(ref _version);
GetInfo();
tokenReader = new StepDataTokenReader(DataTransmitter);
analyzer = new StepExpSyntaxAnalyzer();
ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements;
Task secTask = Task.Run(ReadDataSection);
Task anTask = Task.Run(ReadStepToken);
Model = new StepModel(_info);
while (initStatements.TryDequeue(out StepEntityDefineSequence? statement) || !anTask.IsCompleted)
{
if (statement is null)
{
Thread.Sleep(0);
continue;
}
StepUninitializedEntity entity = Model.FromInitSequence(statement);
}
Task.WaitAll(secTask, anTask);
return Model;
}
public async Task<StepModel> ReadToModelAsync()
{
if (ReadToModelTask is null) {
ReadToModelTask = Task.Run(ReadToModel);
}
return await ReadToModelTask;
}
public StepModel ReadToModelSingleThread()
{
if (Model is not null) {
return Model;
}
if (_version != 0) {
throw new InvalidOperationException(
"A ReadToModel method has been called and is running now, use Async version instead");
}
Interlocked.Increment(ref _version);
GetInfo();
tokenReader = new StepDataTokenReader(DataTransmitter);
analyzer = new StepExpSyntaxAnalyzer();
ConcurrentQueue<StepEntityDefineSequence> initStatements = analyzer.StepEntityInitStatements;
ReadDataSection();
ReadStepToken();
Model = new StepModel(_info);
while (initStatements.TryDequeue(out StepEntityDefineSequence? statement))
{
if (statement is null)
{
Thread.Sleep(0);
continue;
}
StepUninitializedEntity entity = Model.FromInitSequence(statement);
}
return Model;
}
private void ReadStepToken()
{
while (!tokenReader.IsEmpty)
{
Token t = tokenReader.ReadToken();
analyzer.AppendToken(t);
}
}
}
}
-168
View File
@@ -1,168 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepReader"
// 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;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepReader : IDisposable
{
private const string fileLabel = "ISO-10303-21;";
private bool disposedValue;
private FileStream _fileStream;
private int _dataBeginLine;
private long _headStart = -1, _headEnd = -1, _dataStart = -1, _size;
private MemoryMappedFile _memoryFile;
private StepReader() { }
private StepReader(FileStream stream, long size)
{
_fileStream = stream;
_size = size;
_memoryFile = MemoryMappedFile.CreateFromFile(
stream, mapName:null, size, MemoryMappedFileAccess.Read, HandleInheritability.None, leaveOpen:true);
}
// ~StepReader()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose(disposing:true);
GC.SuppressFinalize(this);
}
public static bool FromFile(string path, out StepReader reader)
{
FileInfo info = new FileInfo(path);
if (!info.Exists)
{
reader = null!;
return false;
}
FileStream stream = new FileStream(
path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize:4096, useAsync:true);
byte[] fileHead = new byte[40];
stream.Read(fileHead, 0, fileLabel.Length);
if (!Encoding.UTF8.GetString(fileHead).Contains(fileLabel)) {
throw new InvalidDataException("The given file is not a STEP file");
}
reader = new StepReader(stream, info.Length);
reader.LocateSection();
return reader != null;
}
private void LocateSection()
{
long startPos = 0;
byte[] buffer = new byte[1024];
Span<byte> bufferSpan = buffer,
headerSec = Encoding.UTF8.GetBytes("HEADER;"),
endsecSec = Encoding.UTF8.GetBytes("ENDSEC;"),
dataSec = Encoding.UTF8.GetBytes("DATA;");
_fileStream.Position = 0;
for (; startPos < _size; startPos += 1000)
{
_fileStream.Read(buffer);
if (_headStart == -1)
{
long pos = bufferSpan.IndexOf(headerSec);
if (pos >= 0) {
_headStart = startPos + pos;
}
}
if (_headEnd == -1)
{
long pos = bufferSpan.IndexOf(endsecSec);
if (pos >= 0) {
_headEnd = startPos + pos;
}
}
if (_dataStart == -1)
{
long pos = bufferSpan.IndexOf(dataSec);
if (pos >= 0) {
_dataStart = startPos + pos;
}
} else
{
break;
}
_fileStream.Seek(1000, SeekOrigin.Current);
}
}
private string ReadToken(StreamReader reader, ref long posCache)
{
StringBuilder token = new StringBuilder(100);
while (token.Length == 0 || token[token.Length - 1] != ';')
{
string subString = reader.ReadLine()!;
if (subString == null)
{
break;
}
token.Append(subString.TrimStart());
}
posCache += token.Length;
return token.ToString();
}
private protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
_fileStream.Dispose();
_memoryFile.Dispose();
}
disposedValue = true;
}
}
}
}
@@ -1,78 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepUncertainEntity.Parse"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepUninitializedEntity
{
private static StepRepresentationItem ConvertSimpleEntity(StepModel context, ExpFunctionCallingNode calling)
{
string name = calling.FunctionCaller.Name;
return name switch
{
ExpressStepUtil.AdvancedFaceText => StepAdvancedFace.FromSyntax(
context, calling.Right),
ExpressStepUtil.Axis2Placement2DText => StepAxis2Placement2D.FromSyntax(
context, calling.Right),
ExpressStepUtil.Axis2Placement3DText => StepAxis2Placement3D.FromSyntax(
context, calling.Right),
ExpressStepUtil.BSplineCurveWithKnotsText => StepBSplineCurveWithKnots.FromSyntax(
context, calling.Right),
ExpressStepUtil.CartesianPointText => StepCartesianPoint.FromSyntax(
context, calling.Right),
ExpressStepUtil.CircleText => StepCircle.FromSyntax(context, calling.Right),
ExpressStepUtil.CylindricalSurfaceText => StepCylindricalSurface.FromSyntax(
context, calling.Right),
ExpressStepUtil.DirectionText => StepDirection.FromSyntax(context, calling.Right),
ExpressStepUtil.EdgeCurveText => StepEdgeCurve.FromSyntax(context, calling.Right),
ExpressStepUtil.EdgeLoopText => StepEdgeLoop.FromSyntax(context, calling.Right),
ExpressStepUtil.EllipseText => StepEllipse.FromSyntax(context, calling.Right),
ExpressStepUtil.FaceBoundText => StepFaceBound.FromSyntax(context, calling.Right),
ExpressStepUtil.FaceOuterBoundText => StepFaceOuterBound.FromSyntax(
context, calling.Right),
ExpressStepUtil.LineText => StepLine.FromSyntax(context, calling.Right),
ExpressStepUtil.OrientedEdgeText => StepOrientedEdge.FromSyntax(
context, calling.Right),
ExpressStepUtil.PlaneText => StepPlane.FromSyntax(context, calling.Right),
ExpressStepUtil.VectorText => StepVector.FromSyntax(context, calling.Right),
ExpressStepUtil.VertexPointText => StepVertexPoint.FromSyntax(
context, calling.Right),
_ => throw new StepEntityUnsupportedException()
};
}
}
}
-235
View File
@@ -1,235 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepUncertainEntity"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
using StgSharp;
using StgSharp.Model.Step;
using StgSharp.PipeLine;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Dynamic;
using System.Reflection.Metadata;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Transactions;
using System.Xml.Linq;
namespace StgSharp.Model.Step
{
public partial class StepUninitializedEntity : StepEntityBase, IConvertableToPipelineNode
{
internal const string InName = "in", OutName = "out";
private ExpSyntaxNode _data;
internal StepUninitializedEntity(StepModel model, int id)
{
Context = model;
Id = id;
}
internal StepUninitializedEntity(StepModel model, StepEntityLabel label)
{
Context = model;
Label = label;
}
internal StepUninitializedEntity(
StepModel model,
int id,
ExpSyntaxNode initialization,
IEnumerable<int> dependency)
{
Context = model;
Id = id;
_data = initialization;
if (dependency == null)
{
Dependencies = [];
} else
{
Dependencies = dependency;
}
}
public override StepItemType ItemType => StepItemType.Unknown;
internal static HashSet<string> UnsupportedItemTypes { get; } = new HashSet<string>();
internal StepEntityBase? ConvertToAccurate()
{
/*
StringBuilder builder = new StringBuilder();
if( Dependencies is null || _data is null )
{
builder.Append( "---------------------------" );
builder.Append( "************************" );
Console.WriteLine(
$"Building entity {Id} from thread {Environment.CurrentManagedThreadId} with dependency:{builder.ToString()} " );
} else
{
foreach( int item in Dependencies ) {
builder.Append( $"{item}," );
}
}
return null;
/**/
if (_data is ExpFunctionCallingNode initNode)
{
string name = initNode.FunctionCaller.Name;
StepEntityBase? entity = ConvertSimpleEntity(Context, initNode);
if (entity is null)
{
UnsupportedItemTypes.Add(name);
return null;
}
return entity;
} else if (_data is StepComplexEntityNode complex)
{
/**/
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(complex.Right, true);
StepRepresentationItem entity = null!;
while (enumerator.MoveNext())
{
if (enumerator.Current is not ExpFunctionCallingNode init) {
throw new InvalidCastException();
}
StepRepresentationItem? e = ConvertSimpleEntity(Context, init);
if (e is null)
{
// throw new NotImplementedException( $"Unknown entity type in sequence {Id}" );
return null;
}
if (entity is null)
{
entity = e;
} else
{
entity = StepDataParser.Implement(entity, e);
}
}
return entity;
/**/
return null;
} else
{
throw new ExpInvalidSyntaxException("Name of entity is required.");
}
}
internal void FromSequence(StepEntityDefineSequence sequence)
{
ExpSyntaxNode node = sequence.Expression;
if (node is not ExpBinaryOperatorNode assign) {
throw new ExpInvalidSyntaxException("Not an assign expression ");
}
StepEntityInstanceNode? idNode = assign.Left as StepEntityInstanceNode;
if (idNode!.Id != this.Id) {
throw new InvalidOperationException();
}
FromSequenceUnsafe(sequence);
}
internal void FromSequenceUnsafe(StepEntityDefineSequence sequence)
{
ExpSyntaxNode assign = (sequence.Expression as ExpBinaryOperatorNode)!;
ExpSyntaxNode initNode;
if ((assign.Right is ExpFunctionCallingNode f))
{
initNode = assign.Right;
ExpEntityTypeName = f.FunctionCaller.Name;
} else if ((assign.Right is StepComplexEntityNode c))
{
initNode = assign.Right;
ExpNodeTempEnumerator enumerator = new ExpNodeTempEnumerator(c.Right, false);
StringBuilder sb = new StringBuilder();
sb.Append("Complex entity initialization: ");
int count = 0;
while (enumerator.MoveNext())
{
if (count > 0) {
sb.Append(" <-> ");
}
f = (enumerator.Current as ExpFunctionCallingNode)!;
sb.Append($"{f.FunctionCaller.Name}");
count++;
}
ExpEntityTypeName = sb.ToString();
} else
{
throw new ExpInvalidSyntaxException(
"Entity init or complex entity define is required.");
}
if (_data is not null) {
return;
}
_data = initNode!;
Dependencies = sequence.Dependencies ?? [];
}
void IConvertableToPipelineNode.NodeMain(
in Dictionary<string, PipelineNodeInPort> input,
in Dictionary<string, PipelineNodeOutPort> output)
{
try
{
StepEntityBase? entity = ConvertToAccurate();
if (entity is not null)
{
entity.FromInstance(this);
Context.ReplaceEntity(this, entity);
}
}
catch (StepEntityUnsupportedException) { }
catch (Exception ex)
{
throw new Exception($"Step decoder crashed when building entity {Id}", ex);
}
// Context.ReplaceEntity( this, entity );
PipelineNodeOutPort.SkipAll(output);
}
IEnumerable<string> IConvertableToPipelineNode.InputPortName => [ InName ];
PipelineNodeOperation IConvertableToPipelineNode.Operation => (this as IConvertableToPipelineNode).NodeMain;
IEnumerable<string> IConvertableToPipelineNode.OutputPortName => [ OutName ];
}
}
@@ -1,54 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepUnsupportedEntity"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepUnsupportedEntity : StepEntityBase
{
private ExpSyntaxNode _initSequence;
public StepUnsupportedEntity(StepModel model, int id, string name, ExpSyntaxNode sequence)
{
Id = id;
Name = name;
_initSequence = sequence;
Context = model;
}
public override StepItemType ItemType => StepItemType.Unknown;
}
}
@@ -1,64 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepComplexEntityNode"
// 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;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepComplexEntityNode : ExpSyntaxNode
{
private ExpSyntaxNode _begin;
private StepComplexEntityNode(ExpSyntaxNode node)
: base(node.Source)
{
_begin = node;
}
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => _begin;
public override IExpElementSource EqualityTypeConvert => StepEntityType.Source;
public static StepComplexEntityNode FromTuple(ExpSyntaxNode node)
{
if (node is not ExpTupleNode tuple) {
throw new ExpInvalidSyntaxException("Node to convert is not a complex");
}
return new StepComplexEntityNode(tuple.Right);
}
}
}
@@ -1,64 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityInitCaller"
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepEntityInitCaller : ExpFunctionSource
{
private static Dictionary<string, StepEntityInitCaller> _callers = new();
private StepEntityInitCaller(string name)
: base(name, null)
{
ReturningType = StepEntityType.Source;
}
public static StepEntityInitCaller CreateCaller(string name)
{
if (_callers.TryGetValue(name, out StepEntityInitCaller? caller)) {
return caller;
}
caller = new StepEntityInitCaller(name);
_callers.Add(name, caller);
return caller;
}
}
}
@@ -1,102 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepEntityInstanceNode"
// 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.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepEntityInstanceNode : ExpSyntaxNode
{
private StepEntityInstanceNode(Token source) : base(source) { }
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => StepEntityType.Source;
public int Id { get; init; }
public static StepEntityInstanceNode Register(Token t)
{
if (t.Value[0] != '#') {
throw new ExpInvalidSyntaxException("Entity label in STEP should be # + number");
}
StepEntityInstanceNode node = new StepEntityInstanceNode(t)
{
Id = int.Parse(t.Value.AsSpan(1)),
};
return node;
}
public static StepEntityInstanceNode RegisterNull(Token t)
{
if (t.Value != "$") {
throw new ExpInvalidSyntaxException(
$"Token {t.Value} does not represent a null entity");
}
StepEntityInstanceNode node = new StepEntityInstanceNode(t)
{
Id = 0,
};
return node;
}
public static StepEntityInstanceNode RegisterRuntimeInference(Token t)
{
if (t.Value != "*") {
throw new ExpInvalidSyntaxException(
$"Token {t.Value} does not represent a runtime inferences entity");
}
StepEntityInstanceNode node = new StepEntityInstanceNode(t)
{
Id = -1,
};
return node;
}
}
internal class StepEntityType : ExpTypeSource
{
private StepEntityType(string typeName) : base(typeName) { }
public static StepEntityType Source { get; } = new StepEntityType("ENTITY");
}
}
@@ -1,57 +0,0 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepExpEnumValueNode"
// 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;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepExpEnumValueNode : ExpSyntaxNode
{
public StepExpEnumValueNode(Token source)
: base(source)
{
EnumValue = source.Value;
}
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
public string EnumValue { get; private set; }
}
}
-1
View File
@@ -185,7 +185,6 @@
<ClCompile Include="sn-src\simdid.x86.c" />
<ClCompile Include="sn-src\simdid_compare.x86.c" />
<ClCompile Include="sn-src\sn_native.c" />
<ClCompile Include="sn-src\str_string.c" />
<ClCompile Include="sn-src\t.affinity.c" />
<ClCompile Include="sn-src\vector.c" />
<ClCompile Include="sn-src\vector_dot.c" />
@@ -27,9 +27,6 @@
<ClCompile Include="sn-src\s.hash.x86.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="sn-src\str_string.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="sn-src\vector.c">
<Filter>源文件</Filter>
</ClCompile>
@@ -182,15 +182,52 @@ SN_MK_PROC_DECL_STD(double, avx, , fma);
SN_MK_PROC_DECL_STD(double, avx, _fma, fma);
SN_MK_PROC_DECL_STD(double, 512, , fma);
SN_MK_PROC_DECL_STD(float, sse, , tiled_fma);
SN_MK_PROC_DECL_STD(float, avx, , tiled_fma);
SN_MK_PROC_DECL_STD(float, avx, _fma, tiled_fma);
SN_MK_PROC_DECL_STD(float, 512, , tiled_fma);
SN_SK_PROC_DECL_STD(float, avx, , add);
SN_SK_PROC_DECL_STD(float, 512, , add);
SN_MK_PROC_DECL_STD(double, sse, , tiled_fma);
SN_MK_PROC_DECL_STD(double, avx, , tiled_fma);
SN_MK_PROC_DECL_STD(double, avx, _fma, tiled_fma);
SN_MK_PROC_DECL_STD(double, 512, , tiled_fma);
SN_SK_PROC_DECL_STD(double, sse, , add);
SN_SK_PROC_DECL_STD(double, avx, , add);
SN_SK_PROC_DECL_STD(double, 512, , add);
SN_SK_PROC_DECL_STD(float, sse, , sub);
SN_SK_PROC_DECL_STD(float, avx, , sub);
SN_SK_PROC_DECL_STD(float, 512, , sub);
SN_SK_PROC_DECL_STD(double, sse, , sub);
SN_SK_PROC_DECL_STD(double, avx, , sub);
SN_SK_PROC_DECL_STD(double, 512, , sub);
SN_SK_PROC_DECL_STD(float, sse, , transpose);
SN_SK_PROC_DECL_STD(float, avx, , transpose);
SN_SK_PROC_DECL_STD(float, 512, , transpose);
SN_SK_PROC_DECL_STD(float, sse, , scalar_mul);
SN_SK_PROC_DECL_STD(float, avx, , scalar_mul);
SN_SK_PROC_DECL_STD(float, 512, , scalar_mul);
SN_SK_PROC_DECL_STD(double, sse, , scalar_mul);
SN_SK_PROC_DECL_STD(double, avx, , scalar_mul);
SN_SK_PROC_DECL_STD(double, 512, , scalar_mul);
SN_SK_PROC_DECL_STD(float, sse, , fill);
SN_SK_PROC_DECL_STD(float, avx, , fill);
SN_SK_PROC_DECL_STD(float, 512, , fill);
SN_SK_PROC_DECL_STD(double, sse, , fill);
SN_SK_PROC_DECL_STD(double, avx, , fill);
SN_SK_PROC_DECL_STD(double, 512, , fill);
SN_SK_PROC_DECL_STD(float, sse, , quality);
SN_SK_PROC_DECL_STD(float, sse, , fma);
SN_SK_PROC_DECL_STD(float, avx, , fma);
SN_SK_PROC_DECL_STD(float, avx, _fma, fma);
SN_SK_PROC_DECL_STD(float, 512, , fma);
SN_SK_PROC_DECL_STD(double, sse, , fma);
SN_SK_PROC_DECL_STD(double, avx, , fma);
SN_SK_PROC_DECL_STD(double, avx, _fma, fma);
SN_SK_PROC_DECL_STD(double, 512, , fma);
#pragma endregion
+21 -11
View File
@@ -73,6 +73,8 @@ static_assert(sizeof(MAT_TASK(float)) == 128, "matrix_parallel_task_package size
#endif
typedef void(SN_DECL *UNI_MK_PROC)(matrix_task *task);
typedef void(SN_DECL *UNI_SK_PROC)(mat_kernel const *left, mat_kernel const *right,
mat_kernel *restrict ans, uint64_t scalar);
typedef void(SN_DECL *VECTORNORMALIZEPROC)(__m128 *source, __m128 *target);
typedef void(SN_DECL *DOTPROC)(void *transpose, __m128 *vector, __m128 *ans);
@@ -85,25 +87,33 @@ typedef int(SN_DECL *INDEX_PAIR)(short const *stram, uint32_t target, int length
#pragma endregion
typedef struct mat_intrinsic {
UNI_MK_PROC buffer_add;
UNI_MK_PROC buffer_fill;
UNI_MK_PROC buffer_scalar_mul;
UNI_MK_PROC buffer_sub;
UNI_MK_PROC buffer_transpose;
UNI_MK_PROC ker_fma;
UNI_MK_PROC ker_tile_fma;
typedef struct mat_mk_intrinsic {
UNI_MK_PROC add;
UNI_MK_PROC fill;
UNI_MK_PROC scalar_mul;
UNI_MK_PROC sub;
UNI_MK_PROC transpose;
UNI_MK_PROC fma;
UNI_MK_PROC pivot;
} mat_mk_intrinsic;
} mat_intrinsic;
typedef struct mat_sk_intrinsic {
UNI_SK_PROC add;
UNI_SK_PROC fill;
UNI_SK_PROC scalar_mul;
UNI_SK_PROC sub;
UNI_SK_PROC transpose;
UNI_SK_PROC fma;
UNI_SK_PROC pivot;
} mat_sk_intrinsic;
// Mirrors C# IntrinsicContext field order so managed/unmanaged layouts stay in sync.
typedef struct sn_intrinsic {
HASH city_hash_simplify;
FACTORIALROC factorial_simd;
INDEX_PAIR index_pair;
VECTORNORMALIZEPROC vec_f32_normalize_3;
mat_intrinsic mat[4];
mat_mk_intrinsic mat_mk[0x0a];
mat_sk_intrinsic mat_sk[0x0a];
} sn_intrinsic;
typedef enum elment_mask { F32 = 0, F64 = 1, I32 = 2, I64 = 3 } element_mask;
+9 -3
View File
@@ -10,12 +10,18 @@
#define mat_task_local ((_mat_task_local const *)task)
#define STD_MK_PROC_NAME(T_type, T_arch, T_feature, T_op) \
T_type##_mat_proc_##T_op##_##T_arch##_##T_feature
#define MK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op) \
T_type##_multi_kernel_proc_##T_op##_##T_arch##_##T_feature
#define SN_MK_PROC_DECL(T_type, P_name) INTERNAL void SN_DECL P_name(MAT_TASK(T_type) const *task)
#define SN_MK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL void SN_DECL STD_MK_PROC_NAME(T_type, T_arch, T_feature, \
INTERNAL void SN_DECL MK_PROC_NAME_STD(T_type, T_arch, T_feature, \
T_op)(MAT_TASK(T_type) const *task)
#define SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op) \
T_type##_single_kernel_proc_##T_op##_##T_arch##_##T_feature
#define SN_SK_PROC_DECL_STD(T_type, T_arch, T_feature, T_op) \
INTERNAL void SN_DECL SK_PROC_NAME_STD(T_type, T_arch, T_feature, T_op)( \
MAT_KERNEL(T_type) const *left, MAT_KERNEL(T_type) const *right, \
MAT_KERNEL(T_type) *restrict ans, uint64_t scalar)
#define _SN_STD__PROBE_0 0
#define _SN_STD__PROBE_1 1
+44 -55
View File
@@ -50,25 +50,22 @@ void load_intrinsic_sse(sn_intrinsic *context, SIMDID id)
{
context->city_hash_simplify = city_hash_simplify_sse;
context->factorial_simd = factorial_simd_sse;
context->index_pair = index_pair_sse;
context->mat[F32].buffer_add = STD_MK_PROC_NAME(float, sse, , add);
context->mat[F32].buffer_fill = STD_MK_PROC_NAME(float, sse, , fill);
context->mat[F32].buffer_scalar_mul = STD_MK_PROC_NAME(float, sse, , scalar_mul);
context->mat[F32].buffer_sub = STD_MK_PROC_NAME(float, sse, , sub);
context->mat[F32].buffer_transpose = STD_MK_PROC_NAME(float, sse, , transpose);
context->mat[F32].ker_fma = STD_MK_PROC_NAME(float, sse, , fma);
context->mat[F32].ker_tile_fma = STD_MK_PROC_NAME(float, sse, , tiled_fma);
context->mat[F32].pivot = NULL;
context->mat_mk[F32].add = MK_PROC_NAME_STD(float, sse, , add);
context->mat_mk[F32].fill = MK_PROC_NAME_STD(float, sse, , fill);
context->mat_mk[F32].scalar_mul = MK_PROC_NAME_STD(float, sse, , scalar_mul);
context->mat_mk[F32].sub = MK_PROC_NAME_STD(float, sse, , sub);
context->mat_mk[F32].transpose = MK_PROC_NAME_STD(float, sse, , transpose);
context->mat_mk[F32].fma = MK_PROC_NAME_STD(float, sse, , fma);
context->mat_mk[F32].pivot = NULL;
context->mat[F64].buffer_add = STD_MK_PROC_NAME(double, sse, , add);
context->mat[F64].buffer_fill = STD_MK_PROC_NAME(double, sse, , fill);
context->mat[F64].buffer_scalar_mul = STD_MK_PROC_NAME(double, sse, , scalar_mul);
context->mat[F64].buffer_sub = STD_MK_PROC_NAME(double, sse, , sub);
context->mat[F64].buffer_transpose = NULL;
context->mat[F64].ker_fma = STD_MK_PROC_NAME(double, sse, , fma);
context->mat[F64].ker_tile_fma = STD_MK_PROC_NAME(double, sse, , tiled_fma);
context->mat[F64].pivot = NULL;
context->mat_mk[F64].add = MK_PROC_NAME_STD(double, sse, , add);
context->mat_mk[F64].fill = MK_PROC_NAME_STD(double, sse, , fill);
context->mat_mk[F64].scalar_mul = MK_PROC_NAME_STD(double, sse, , scalar_mul);
context->mat_mk[F64].sub = MK_PROC_NAME_STD(double, sse, , sub);
context->mat_mk[F64].transpose = NULL;
context->mat_mk[F64].fma = MK_PROC_NAME_STD(double, sse, , fma);
context->mat_mk[F64].pivot = NULL;
context->vec_f32_normalize_3 = f32_normalize;
}
@@ -81,29 +78,24 @@ void load_intrinsic_avx(sn_intrinsic *context, SIMDID id)
context->city_hash_simplify = city_hash_simplify_sse;
context->factorial_simd = factorial_simd_sse;
context->index_pair = index_pair_sse;
context->mat[F32].buffer_add = STD_MK_PROC_NAME(float, avx, , add);
context->mat[F32].buffer_fill = STD_MK_PROC_NAME(float, avx, , fill);
context->mat[F32].buffer_scalar_mul = STD_MK_PROC_NAME(float, avx, , scalar_mul);
context->mat[F32].buffer_sub = STD_MK_PROC_NAME(float, avx, , sub);
context->mat[F32].buffer_transpose = STD_MK_PROC_NAME(float, avx, , transpose);
context->mat[F32].ker_fma = is_fma ? STD_MK_PROC_NAME(float, avx, , fma) :
STD_MK_PROC_NAME(float, avx, _fma, fma);
context->mat[F32].ker_tile_fma = is_fma ? STD_MK_PROC_NAME(float, avx, , tiled_fma) :
STD_MK_PROC_NAME(float, avx, _fma, tiled_fma);
context->mat[F32].pivot = NULL;
context->mat_mk[F32].add = MK_PROC_NAME_STD(float, avx, , add);
context->mat_mk[F32].fill = MK_PROC_NAME_STD(float, avx, , fill);
context->mat_mk[F32].scalar_mul = MK_PROC_NAME_STD(float, avx, , scalar_mul);
context->mat_mk[F32].sub = MK_PROC_NAME_STD(float, avx, , sub);
context->mat_mk[F32].transpose = MK_PROC_NAME_STD(float, avx, , transpose);
context->mat_mk[F32].fma = is_fma ? MK_PROC_NAME_STD(float, avx, , fma) :
MK_PROC_NAME_STD(float, avx, _fma, fma);
context->mat_mk[F32].pivot = NULL;
context->mat[F64].buffer_add = STD_MK_PROC_NAME(double, avx, , add);
context->mat[F64].buffer_fill = STD_MK_PROC_NAME(double, avx, , fill);
context->mat[F64].buffer_scalar_mul = STD_MK_PROC_NAME(double, avx, , scalar_mul);
context->mat[F64].buffer_sub = STD_MK_PROC_NAME(double, avx, , sub);
context->mat[F64].buffer_transpose = NULL;
context->mat[F64].ker_fma = is_fma ? STD_MK_PROC_NAME(double, avx, , fma) :
STD_MK_PROC_NAME(double, avx, _fma, fma);
context->mat[F64].ker_tile_fma = is_fma ? STD_MK_PROC_NAME(double, avx, , tiled_fma) :
STD_MK_PROC_NAME(double, avx, _fma, tiled_fma);
context->mat[F64].pivot = NULL;
context->mat_mk[F64].add = MK_PROC_NAME_STD(double, avx, , add);
context->mat_mk[F64].fill = MK_PROC_NAME_STD(double, avx, , fill);
context->mat_mk[F64].scalar_mul = MK_PROC_NAME_STD(double, avx, , scalar_mul);
context->mat_mk[F64].sub = MK_PROC_NAME_STD(double, avx, , sub);
context->mat_mk[F64].transpose = NULL;
context->mat_mk[F64].fma = is_fma ? MK_PROC_NAME_STD(double, avx, , fma) :
MK_PROC_NAME_STD(double, avx, _fma, fma);
context->mat_mk[F64].pivot = NULL;
context->vec_f32_normalize_3 = f32_normalize;
}
@@ -112,25 +104,22 @@ void load_intrinsic_512(sn_intrinsic *context, SIMDID id)
{
context->city_hash_simplify = city_hash_simplify_sse;
context->factorial_simd = factorial_simd_sse;
context->index_pair = index_pair_sse;
context->mat[F32].buffer_add = STD_MK_PROC_NAME(float, 512, , add);
context->mat[F32].buffer_fill = STD_MK_PROC_NAME(float, 512, , fill);
context->mat[F32].buffer_scalar_mul = STD_MK_PROC_NAME(float, 512, , scalar_mul);
context->mat[F32].buffer_sub = STD_MK_PROC_NAME(float, 512, , sub);
context->mat[F32].buffer_transpose = STD_MK_PROC_NAME(float, 512, , transpose);
context->mat[F32].ker_fma = STD_MK_PROC_NAME(float, 512, , fma);
context->mat[F32].ker_tile_fma = STD_MK_PROC_NAME(float, 512, , tiled_fma);
context->mat[F32].pivot = NULL;
context->mat_mk[F32].add = MK_PROC_NAME_STD(float, 512, , add);
context->mat_mk[F32].fill = MK_PROC_NAME_STD(float, 512, , fill);
context->mat_mk[F32].scalar_mul = MK_PROC_NAME_STD(float, 512, , scalar_mul);
context->mat_mk[F32].sub = MK_PROC_NAME_STD(float, 512, , sub);
context->mat_mk[F32].transpose = MK_PROC_NAME_STD(float, 512, , transpose);
context->mat_mk[F32].fma = MK_PROC_NAME_STD(float, 512, , fma);
context->mat_mk[F32].pivot = NULL;
context->mat[F64].buffer_add = STD_MK_PROC_NAME(double, 512, , add);
context->mat[F64].buffer_fill = STD_MK_PROC_NAME(double, 512, , fill);
context->mat[F64].buffer_scalar_mul = STD_MK_PROC_NAME(double, 512, , scalar_mul);
context->mat[F64].buffer_sub = STD_MK_PROC_NAME(double, 512, , sub);
context->mat[F64].buffer_transpose = NULL;
context->mat[F64].ker_fma = STD_MK_PROC_NAME(double, 512, , fma);
context->mat[F64].ker_tile_fma = STD_MK_PROC_NAME(double, 512, , tiled_fma);
context->mat[F64].pivot = NULL;
context->mat_mk[F64].add = MK_PROC_NAME_STD(double, 512, , add);
context->mat_mk[F64].fill = MK_PROC_NAME_STD(double, 512, , fill);
context->mat_mk[F64].scalar_mul = MK_PROC_NAME_STD(double, 512, , scalar_mul);
context->mat_mk[F64].sub = MK_PROC_NAME_STD(double, 512, , sub);
context->mat_mk[F64].transpose = NULL;
context->mat_mk[F64].fma = MK_PROC_NAME_STD(double, 512, , fma);
context->mat_mk[F64].pivot = NULL;
context->vec_f32_normalize_3 = f32_normalize;
}
+9 -9
View File
@@ -39,7 +39,7 @@ SN_MK_PROC_DECL_STD(float, 512, , fill)
SN_MK_PROC_DECL_STD(double, sse, , fill)
{
__mk_param_std(BUFFER, ANS_SCALAR, float);
__mk_param_std(BUFFER, ANS_SCALAR, double);
register __m128d vec = _mm_set1_pd(((double *)(scalar->data))[0]);
for (size_t i = 0; i < count; i++) {
ans[i].f64_x[0] = vec;
@@ -55,7 +55,7 @@ SN_MK_PROC_DECL_STD(double, sse, , fill)
SN_MK_PROC_DECL_STD(double, avx, , fill)
{
__mk_param_std(BUFFER, ANS_SCALAR, float);
__mk_param_std(BUFFER, ANS_SCALAR, double);
register __m256d vec = _mm256_broadcast_sd(((double *)(scalar->data)));
for (size_t i = 0; i < count; i++) {
ans[i].f64_y[0] = vec;
@@ -67,7 +67,7 @@ SN_MK_PROC_DECL_STD(double, avx, , fill)
SN_MK_PROC_DECL_STD(double, 512, , fill)
{
__mk_param_std(BUFFER, ANS_SCALAR, float);
__mk_param_std(BUFFER, ANS_SCALAR, double);
register __m512d vec = _mm512_broadcastsd_pd(_mm_loadu_pd(scalar));
for (size_t i = 0; i < count; i++) {
ans[i].f64_z[0] = vec;
@@ -116,7 +116,7 @@ SN_MK_PROC_DECL_STD(float, 512, , add)
}
SN_MK_PROC_DECL_STD(double, sse, , add)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
register __m128d c0 = _mm_add_pd(_mm_castps_pd(left[i].f32_x[0]),
@@ -149,7 +149,7 @@ SN_MK_PROC_DECL_STD(double, sse, , add)
SN_MK_PROC_DECL_STD(double, avx, , add)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
size_t s = sizeof(MAT_KERNEL(float));
@@ -166,7 +166,7 @@ SN_MK_PROC_DECL_STD(double, avx, , add)
SN_MK_PROC_DECL_STD(double, 512, , add)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
register __m512d c0 = _mm512_add_pd(left[i].f64_z[0], right[i].f64_z[0]);
@@ -217,7 +217,7 @@ SN_MK_PROC_DECL_STD(float, 512, , sub)
SN_MK_PROC_DECL_STD(double, sse, , sub)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
register __m128d c0 = _mm_sub_pd(left[i].f64_x[0], right[i].f64_x[0]);
@@ -242,7 +242,7 @@ SN_MK_PROC_DECL_STD(double, sse, , sub)
SN_MK_PROC_DECL_STD(double, avx, , sub)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
register __m256 c0 = _mm256_sub_ps(left[i].f32_y[0], right[i].f32_y[0]);
@@ -254,7 +254,7 @@ SN_MK_PROC_DECL_STD(double, avx, , sub)
SN_MK_PROC_DECL_STD(double, 512, , sub)
{
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, float);
__mk_param_std(BUFFER, LEFT_RIGHT_ANS, double);
for (size_t i = 0; i < count; i++) {
register __m512 c0 = _mm512_sub_ps(left[i].f32_z[0], right[i].f32_z[0]);
+8 -24
View File
@@ -10,10 +10,8 @@
// float
SN_MK_PROC_DECL_STD(float, sse, , fma)
SN_SK_PROC_DECL_STD(float, sse, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
const __m128 a0 = _mm_load_ps((float *)&left->f32_x[0]);
const __m128 a1 = _mm_load_ps((float *)&left->f32_x[1]);
const __m128 a2 = _mm_load_ps((float *)&left->f32_x[2]);
@@ -60,10 +58,8 @@ SN_MK_PROC_DECL_STD(float, sse, , fma)
_mm_store_ps((float *)&ans->f32_x[3], c3);
}
SN_MK_PROC_DECL_STD(float, avx, , fma)
SN_SK_PROC_DECL_STD(float, avx, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
static const __m256i b01_shift = { .m256i_i32 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m256i b23_shift = { .m256i_i32 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
@@ -108,10 +104,8 @@ SN_MK_PROC_DECL_STD(float, avx, , fma)
ans->f32_y[1] = c23;
}
SN_MK_PROC_DECL_STD(float, avx, _fma, fma)
SN_SK_PROC_DECL_STD(float, avx, _fma, fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
static const __m256i b01_shift = { .m256i_i32 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m256i b23_shift = { .m256i_i32 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
@@ -156,10 +150,8 @@ SN_MK_PROC_DECL_STD(float, avx, _fma, fma)
ans->f32_y[1] = c23;
}
SN_MK_PROC_DECL_STD(float, 512, , fma)
SN_SK_PROC_DECL_STD(float, 512, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
static const __m512i b_shift = { .m512i_i32 = {
// shuff order
0, 1, 2, 3, // col0
@@ -194,10 +186,8 @@ SN_MK_PROC_DECL_STD(float, 512, , fma)
// double
SN_MK_PROC_DECL_STD(double, sse, , fma)
SN_SK_PROC_DECL_STD(double, sse, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
for (int col = 0; col < 4; ++col) {
/* current answer column (two chunks: rows 0-1 and 2-3) */
register __m128d c_lo = _mm_load_pd(ans->f64_x + (col * 2 + 0));
@@ -240,10 +230,8 @@ SN_MK_PROC_DECL_STD(double, sse, , fma)
}
}
SN_MK_PROC_DECL_STD(double, avx, , fma)
SN_SK_PROC_DECL_STD(double, avx, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
const __m256d a0 = _mm256_load_pd((double *)&left->f64_y[0]);
const __m256d a1 = _mm256_load_pd((double *)&left->f64_y[1]);
const __m256d a2 = _mm256_load_pd((double *)&left->f64_y[2]);
@@ -286,10 +274,8 @@ SN_MK_PROC_DECL_STD(double, avx, , fma)
_mm256_store_pd((double *)&ans->f64_y[3], ccol);
}
SN_MK_PROC_DECL_STD(double, avx, _fma, fma)
SN_SK_PROC_DECL_STD(double, avx, _fma, fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
const __m256d a0 = _mm256_load_pd((double *)&left->f64_y[0]);
const __m256d a1 = _mm256_load_pd((double *)&left->f64_y[1]);
const __m256d a2 = _mm256_load_pd((double *)&left->f64_y[2]);
@@ -332,10 +318,8 @@ SN_MK_PROC_DECL_STD(double, avx, _fma, fma)
_mm256_store_pd((double *)&ans->f64_y[3], ccol);
}
SN_MK_PROC_DECL_STD(double, 512, , fma)
SN_SK_PROC_DECL_STD(double, 512, , fma)
{
__mk_param_std(KERNEL, LEFT_RIGHT_ANS, float);
static const __m512i b01_shift = { .m512i_i64 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m512i b23_shift = { .m512i_i64 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
+8 -8
View File
@@ -12,7 +12,7 @@
// float
SN_MK_PROC_DECL_STD(float, sse, , tiled_fma)
SN_MK_PROC_DECL_STD(float, sse, , fma)
{
__mk_param_std(TILE, LEFT_RIGHT_ANS, float);
@@ -69,7 +69,7 @@ SN_MK_PROC_DECL_STD(float, sse, , tiled_fma)
_mm_store_ps((float *)&ans_cur->f32_x[3], c3);
}
SN_MK_PROC_DECL_STD(float, avx, , tiled_fma)
SN_MK_PROC_DECL_STD(float, avx, , fma)
{
static const __m256i b01_shift_source = { .m256i_i32 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m256i b23_shift_source = { .m256i_i32 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
@@ -127,7 +127,7 @@ SN_MK_PROC_DECL_STD(float, avx, , tiled_fma)
_mm256_store_ps((float *)&ans_cur->f32_y[1], c23);
}
SN_MK_PROC_DECL_STD(float, avx, _fma, tiled_fma)
SN_MK_PROC_DECL_STD(float, avx, _fma, fma)
{
static const __m256i b01_shift_source = { .m256i_i32 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m256i b23_shift_source = { .m256i_i32 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
@@ -185,7 +185,7 @@ SN_MK_PROC_DECL_STD(float, avx, _fma, tiled_fma)
_mm256_store_ps((float *)&ans_cur->f32_y[1], c23);
}
SN_MK_PROC_DECL_STD(float, 512, , tiled_fma)
SN_MK_PROC_DECL_STD(float, 512, , fma)
{
static const __m512i b_shift_source = { .m512i_i32 = {
// shuff order
@@ -260,7 +260,7 @@ SN_MK_PROC_DECL_STD(float, 512, , tiled_fma)
c##i##_hi = _mm_add_pd(c##i##_hi, _mm_mul_pd(a_hi, b)); \
} while (0)
SN_MK_PROC_DECL_STD(double, sse, , tiled_fma)
SN_MK_PROC_DECL_STD(double, sse, , fma)
{
__mk_param_std(TILE, LEFT_RIGHT_ANS, double);
@@ -299,7 +299,7 @@ SN_MK_PROC_DECL_STD(double, sse, , tiled_fma)
_mm_store_pd(ans_cur->f64_x + (3 * 2 + 1), c3_hi);
}
SN_MK_PROC_DECL_STD(double, avx, , tiled_fma)
SN_MK_PROC_DECL_STD(double, avx, , fma)
{
__mk_param_std(TILE, LEFT_RIGHT_ANS, double);
@@ -372,7 +372,7 @@ SN_MK_PROC_DECL_STD(double, avx, , tiled_fma)
_mm256_store_pd((double *)&ans_cur->f64_y[3], c3);
}
SN_MK_PROC_DECL_STD(double, avx, _fma, tiled_fma)
SN_MK_PROC_DECL_STD(double, avx, _fma, fma)
{
__mk_param_std(TILE, LEFT_RIGHT_ANS, double);
@@ -429,7 +429,7 @@ SN_MK_PROC_DECL_STD(double, avx, _fma, tiled_fma)
_mm256_store_pd((double *)&ans_cur->f64_y[3], c3);
}
SN_MK_PROC_DECL_STD(double, 512, , tiled_fma)
SN_MK_PROC_DECL_STD(double, 512, , fma)
{
static const __m512i b01_shift_source = { .m512i_i64 = { 0, 1, 2, 3, 5, 6, 7, 4 } };
static const __m512i b23_shift_source = { .m512i_i64 = { 2, 3, 0, 1, 7, 4, 5, 6 } };
-54
View File
@@ -1,54 +0,0 @@
#include "sn_target.h"
#if SN_IS_ARCH(SN_ARCH_X86_64)
#include "sn_intrinsic.h"
INTERNAL int SN_DECL index_pair_sse(short const *str, uint32_t target, int length)
{
int index = 0, result = 0, size = length, end = size - 8;
__m128i s = _mm_set1_epi32(target);
__m128i vec, com;
while (index < end) {
vec = _mm_loadu_epi32(str + index);
com = _mm_cmpeq_epi16(vec, s);
result = _mm_movemask_epi8(com);
if (result) {
for (size_t i = 0; i < 7; i++) {
if (((result & 0xF) == 0xF)) {
return index + i;
}
if (result == 0) {
break;
}
result >>= 2;
}
}
index += 1;
vec = _mm_loadu_epi32(str + index);
com = _mm_cmpeq_epi16(vec, s);
result = _mm_movemask_epi8(com);
if (result) {
for (size_t i = 0; i < 7; i++) {
if (((result & 0xF) == 0xF)) {
return index + i;
}
if (result == 0) {
break;
}
result >>= 2;
}
}
index += 7;
}
for (; (index < size - 1) && (!result); index += 2) {
result = *(int *)(str + index) == target;
}
if (result) {
return index;
}
return -1;
}
#endif

Some files were not shown because too many files have changed in this diff Show More