From dfa6f4ba92eab1cd18a4bbe837b7ea0ce432e5dc Mon Sep 17 00:00:00 2001 From: Youmu Liu <105042599+Nitload-NSI@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:12:58 +0800 Subject: [PATCH] Better L4 and array storage design --- StgSharp.Common/Environment/Platform.cs | 96 +++--- .../HighPerformance/Memory/L4_design.md | 18 ++ .../State/ISimpleStateMachine.cs | 35 +- .../State/SimpleStateMachineNode.cs | 43 +-- StgSharp.Common/State/StateContext.cs | 40 +++ .../Geometries/PlainGeometry/Triangle.cs | 33 +- .../Internal/IntrinsicContext.cs | 137 +++++--- .../MatrixParallelTask.cs | 116 +++---- .../Numeric/Graphics/Matrix44.cs | 114 +++++-- StgSharp.Mathematics/Numeric/Graphics/Vec4.cs | 79 +++-- .../Numeric/MatrixCompute.Factorize.cs | 22 +- .../Numeric/MatrixCompute.Float.cs | 72 +++-- .../Numeric/MatrixCompute.double.cs | 72 +++-- .../Numeric/Runtime/MatrixParallel.Publish.cs | 16 +- .../Numeric/Runtime/MatrixParallel.cs | 46 +-- .../Numeric/Runtime/MatrixParallelQueue.cs | 1 + .../Runtime/MatrixParallelThread.Fma.cs | 21 +- .../Runtime/MatrixParallelThread.Model.cs | 16 +- .../Numeric/Runtime/MatrixParallelThread.cs | 4 +- .../Numeric/Runtime/MatrixParallelWrap.cs | 57 ++-- .../Numeric/Runtime/MatrixTaskFactory.cs | 17 +- .../Step/Analyser/ExpSyntaxAnalyzer.Common.cs | 303 ------------------ .../Step/Analyser/ExpSyntaxAnalyzer.Enum.cs | 65 ---- .../ExpSyntaxAnalyzer.OperatorParser.cs | 128 -------- ...xpSyntaxAnalyzer.PrefixReverseAnalysing.cs | 87 ----- .../Step/Analyser/ExpSyntaxAnalyzer.cs | 135 -------- .../Analyser/StepDataSectionsTranmitter.cs | 108 ------- .../Step/Analyser/StepDataTokenReader.cs | 165 ---------- .../Step/Analyser/StepDependencyDetector.cs | 58 ---- StgSharp.Model/Step/ExpressStepUtil.cs | 129 -------- StgSharp.Model/Step/Items/StepAdvancedFace.cs | 74 ----- .../Step/Items/StepAxis2Placement.cs | 59 ---- .../Step/Items/StepAxis2Placement2D.cs | 71 ---- .../Step/Items/StepAxis2Placement3D.cs | 92 ------ StgSharp.Model/Step/Items/StepBSplineCurve.cs | 131 -------- .../Step/Items/StepBSplineCurveWithKnots.cs | 149 --------- .../Step/Items/StepBSplineSurface.cs | 182 ----------- StgSharp.Model/Step/Items/StepBoundedCurve.cs | 56 ---- .../Step/Items/StepBoundedSurface.cs | 51 --- .../Step/Items/StepBoundedSurfaceCurve.cs | 56 ---- .../Step/Items/StepCartesianPoint.cs | 57 ---- StgSharp.Model/Step/Items/StepCircle.cs | 87 ----- StgSharp.Model/Step/Items/StepConic.cs | 53 --- StgSharp.Model/Step/Items/StepCurve.cs | 53 --- .../Step/Items/StepCylindricalSurface.cs | 71 ---- StgSharp.Model/Step/Items/StepDirection.cs | 57 ---- StgSharp.Model/Step/Items/StepEdge.cs | 67 ---- StgSharp.Model/Step/Items/StepEdgeCurve.cs | 91 ------ StgSharp.Model/Step/Items/StepEdgeLoop.cs | 77 ----- .../Step/Items/StepElementarySurface.cs | 68 ---- StgSharp.Model/Step/Items/StepEllipse.cs | 90 ------ StgSharp.Model/Step/Items/StepFace.cs | 59 ---- StgSharp.Model/Step/Items/StepFaceBound.cs | 75 ----- .../Step/Items/StepFaceOuterBound.cs | 62 ---- StgSharp.Model/Step/Items/StepFaceSurface.cs | 55 ---- .../Items/StepGeometricRepresentationItem.cs | 51 --- StgSharp.Model/Step/Items/StepLine.cs | 110 ------- StgSharp.Model/Step/Items/StepLoop.cs | 46 --- StgSharp.Model/Step/Items/StepOrientedEdge.cs | 97 ------ .../Step/Items/StepPcurveOrSurface.cs | 49 --- StgSharp.Model/Step/Items/StepPlacement.cs | 72 ----- StgSharp.Model/Step/Items/StepPlane.cs | 61 ---- StgSharp.Model/Step/Items/StepPoint.cs | 55 ---- .../Step/Items/StepRepresentationItem.cs | 61 ---- StgSharp.Model/Step/Items/StepSurface.cs | 51 --- StgSharp.Model/Step/Items/StepSurfaceCurve.cs | 51 --- .../StepTopologicalRepresentationItem.cs | 53 --- StgSharp.Model/Step/Items/StepTriple.cs | 134 -------- StgSharp.Model/Step/Items/StepVector.cs | 85 ----- StgSharp.Model/Step/Items/StepVertex.cs | 51 --- StgSharp.Model/Step/Items/StepVertexPoint.cs | 80 ----- StgSharp.Model/Step/StepDataParser.cs | 189 ----------- StgSharp.Model/Step/StepEntityBase.cs | 130 -------- StgSharp.Model/Step/StepEntityLabel.cs | 59 ---- .../Step/StepEntityUnsupportedException.cs | 37 --- StgSharp.Model/Step/StepHeader.cs | 176 ---------- .../Step/StepHeaderLineConstructor.cs | 98 ------ StgSharp.Model/Step/StepItemType.cs | 67 ---- StgSharp.Model/Step/StepModel.cs | 192 ----------- .../Step/StepReader.DataSectionReader.cs | 73 ----- StgSharp.Model/Step/StepReader.HeadReader.cs | 110 ------- StgSharp.Model/Step/StepReader.ToModel.cs | 130 -------- StgSharp.Model/Step/StepReader.cs | 168 ---------- .../Step/StepUncertainEntity.Parse.cs | 78 ----- StgSharp.Model/Step/StepUncertainEntity.cs | 235 -------------- StgSharp.Model/Step/StepUnsupportedEntity.cs | 54 ---- .../Step/SyntaxNode/StepComplexEntityNode.cs | 64 ---- .../Step/SyntaxNode/StepEntityInitCaller.cs | 64 ---- .../Step/SyntaxNode/StepEntityInstanceNode.cs | 102 ------ .../Step/SyntaxNode/StepExpEnumValueNode.cs | 57 ---- StgSharp.Native/StgSharp.Native.vcxproj | 1 - .../StgSharp.Native.vcxproj.filters | 3 - .../sn-head/sn_intrinsic.context.x86.h | 53 ++- StgSharp.Native/sn-head/sn_intrinsic.h | 32 +- StgSharp.Native/sn-head/sn_intrinsic.std.h | 12 +- StgSharp.Native/sn-src/load_intrinsic.x86.c | 99 +++--- StgSharp.Native/sn-src/m.bufop.x86.c | 18 +- StgSharp.Native/sn-src/m.fma.x86.c | 32 +- StgSharp.Native/sn-src/m.fma_tile.x86.c | 16 +- StgSharp.Native/sn-src/str_string.c | 54 ---- .../Abstraction/ITokenReader.cs | 2 + .../RegularMachine/Node.Branch.cs | 1 - .../RegularMachine/StateMachine.cs | 1 - 103 files changed, 853 insertions(+), 6837 deletions(-) rename StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs => StgSharp.Common/State/ISimpleStateMachine.cs (65%) rename StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs => StgSharp.Common/State/SimpleStateMachineNode.cs (58%) create mode 100644 StgSharp.Common/State/StateContext.cs rename StgSharp.Mathematics/{Numeric/Runtime => Internal}/MatrixParallelTask.cs (86%) delete mode 100644 StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs delete mode 100644 StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs delete mode 100644 StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs delete mode 100644 StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs delete mode 100644 StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs delete mode 100644 StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs delete mode 100644 StgSharp.Model/Step/Analyser/StepDataTokenReader.cs delete mode 100644 StgSharp.Model/Step/Analyser/StepDependencyDetector.cs delete mode 100644 StgSharp.Model/Step/ExpressStepUtil.cs delete mode 100644 StgSharp.Model/Step/Items/StepAdvancedFace.cs delete mode 100644 StgSharp.Model/Step/Items/StepAxis2Placement.cs delete mode 100644 StgSharp.Model/Step/Items/StepAxis2Placement2D.cs delete mode 100644 StgSharp.Model/Step/Items/StepAxis2Placement3D.cs delete mode 100644 StgSharp.Model/Step/Items/StepBSplineCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs delete mode 100644 StgSharp.Model/Step/Items/StepBSplineSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepBoundedCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepBoundedSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepCartesianPoint.cs delete mode 100644 StgSharp.Model/Step/Items/StepCircle.cs delete mode 100644 StgSharp.Model/Step/Items/StepConic.cs delete mode 100644 StgSharp.Model/Step/Items/StepCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepCylindricalSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepDirection.cs delete mode 100644 StgSharp.Model/Step/Items/StepEdge.cs delete mode 100644 StgSharp.Model/Step/Items/StepEdgeCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepEdgeLoop.cs delete mode 100644 StgSharp.Model/Step/Items/StepElementarySurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepEllipse.cs delete mode 100644 StgSharp.Model/Step/Items/StepFace.cs delete mode 100644 StgSharp.Model/Step/Items/StepFaceBound.cs delete mode 100644 StgSharp.Model/Step/Items/StepFaceOuterBound.cs delete mode 100644 StgSharp.Model/Step/Items/StepFaceSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs delete mode 100644 StgSharp.Model/Step/Items/StepLine.cs delete mode 100644 StgSharp.Model/Step/Items/StepLoop.cs delete mode 100644 StgSharp.Model/Step/Items/StepOrientedEdge.cs delete mode 100644 StgSharp.Model/Step/Items/StepPcurveOrSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepPlacement.cs delete mode 100644 StgSharp.Model/Step/Items/StepPlane.cs delete mode 100644 StgSharp.Model/Step/Items/StepPoint.cs delete mode 100644 StgSharp.Model/Step/Items/StepRepresentationItem.cs delete mode 100644 StgSharp.Model/Step/Items/StepSurface.cs delete mode 100644 StgSharp.Model/Step/Items/StepSurfaceCurve.cs delete mode 100644 StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs delete mode 100644 StgSharp.Model/Step/Items/StepTriple.cs delete mode 100644 StgSharp.Model/Step/Items/StepVector.cs delete mode 100644 StgSharp.Model/Step/Items/StepVertex.cs delete mode 100644 StgSharp.Model/Step/Items/StepVertexPoint.cs delete mode 100644 StgSharp.Model/Step/StepDataParser.cs delete mode 100644 StgSharp.Model/Step/StepEntityBase.cs delete mode 100644 StgSharp.Model/Step/StepEntityLabel.cs delete mode 100644 StgSharp.Model/Step/StepEntityUnsupportedException.cs delete mode 100644 StgSharp.Model/Step/StepHeader.cs delete mode 100644 StgSharp.Model/Step/StepHeaderLineConstructor.cs delete mode 100644 StgSharp.Model/Step/StepItemType.cs delete mode 100644 StgSharp.Model/Step/StepModel.cs delete mode 100644 StgSharp.Model/Step/StepReader.DataSectionReader.cs delete mode 100644 StgSharp.Model/Step/StepReader.HeadReader.cs delete mode 100644 StgSharp.Model/Step/StepReader.ToModel.cs delete mode 100644 StgSharp.Model/Step/StepReader.cs delete mode 100644 StgSharp.Model/Step/StepUncertainEntity.Parse.cs delete mode 100644 StgSharp.Model/Step/StepUncertainEntity.cs delete mode 100644 StgSharp.Model/Step/StepUnsupportedEntity.cs delete mode 100644 StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs delete mode 100644 StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs delete mode 100644 StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs delete mode 100644 StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs delete mode 100644 StgSharp.Native/sn-src/str_string.c diff --git a/StgSharp.Common/Environment/Platform.cs b/StgSharp.Common/Environment/Platform.cs index a50392d3..9675be26 100644 --- a/StgSharp.Common/Environment/Platform.cs +++ b/StgSharp.Common/Environment/Platform.cs @@ -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. /// [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(IntPtr funcPtr) + internal static TDele ConvertAPI( + 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(); + } + } } diff --git a/StgSharp.Common/HighPerformance/Memory/L4_design.md b/StgSharp.Common/HighPerformance/Memory/L4_design.md index 5ff4ca1f..103c87e4 100644 --- a/StgSharp.Common/HighPerformance/Memory/L4_design.md +++ b/StgSharp.Common/HighPerformance/Memory/L4_design.md @@ -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. 操作流程 diff --git a/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs b/StgSharp.Common/State/ISimpleStateMachine.cs similarity index 65% rename from StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs rename to StgSharp.Common/State/ISimpleStateMachine.cs index a323ed45..07c11f52 100644 --- a/StgSharp.Model/Step/Analyser/StepEntityDefineSequence.cs +++ b/StgSharp.Common/State/ISimpleStateMachine.cs @@ -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 + where TStateNode : SimpleStateMachineNode + where TStateLabel : unmanaged, IEquatable + where TStateContext : StateContext { - public StepEntityDefineSequence(ExpSyntaxNode node, IEnumerable dep) - { - Expression = node; - Dependencies = dep; - } + TStateNode this[ + TStateLabel label + ] { get; } - public ExpSyntaxNode Expression { get; init; } + ref readonly TStateNode GetCurrentStateNode(); - public IEnumerable Dependencies { get; init; } + void Reset(); + + bool TryMoveNext( + TStateContext ctx + ); } } diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs b/StgSharp.Common/State/SimpleStateMachineNode.cs similarity index 58% rename from StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs rename to StgSharp.Common/State/SimpleStateMachineNode.cs index 0b197fa3..5f58ff8e 100644 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.ErrorProcess.cs +++ b/StgSharp.Common/State/SimpleStateMachineNode.cs @@ -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 + where TSelf : SimpleStateMachineNode + where TLabel : unmanaged, IEquatable + 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 _jumpTable = []; + + public ReadOnlySpan AvailableNodes => CollectionsMarshal.AsSpan(_jumpTable); + + public abstract bool IsValidateFrom( + TSelf former, + TStateContext context + ); + + public abstract bool TryTransaction( + ReadOnlySpan nodeSpan, + TStateContext context, + out TLabel label + ); } } diff --git a/StgSharp.Common/State/StateContext.cs b/StgSharp.Common/State/StateContext.cs new file mode 100644 index 00000000..27d4138e --- /dev/null +++ b/StgSharp.Common/State/StateContext.cs @@ -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 { } +} diff --git a/StgSharp.Mathematics/Geometries/PlainGeometry/Triangle.cs b/StgSharp.Mathematics/Geometries/PlainGeometry/Triangle.cs index c26e5778..7e0c4b04 100644 --- a/StgSharp.Mathematics/Geometries/PlainGeometry/Triangle.cs +++ b/StgSharp.Mathematics/Geometries/PlainGeometry/Triangle.cs @@ -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); diff --git a/StgSharp.Mathematics/Internal/IntrinsicContext.cs b/StgSharp.Mathematics/Internal/IntrinsicContext.cs index 300289a6..c49c68a4 100644 --- a/StgSharp.Mathematics/Internal/IntrinsicContext.cs +++ b/StgSharp.Mathematics/Internal/IntrinsicContext.cs @@ -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] factorial_simd; // factorial_simd public delegate* unmanaged[Cdecl] index_pair; // index_pair public delegate* unmanaged[Cdecl] 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])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])ptr)(left, + right, + ans, + scalar); + } + + } + + [InlineArray(MatrixElementType.IntrinsicCount)] + internal unsafe struct MatrixSingleKernelIntrinsicArray + { + + private MatrixSingleKernelIntrinsic e0; + + } + + #endregion + } \ No newline at end of file diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelTask.cs b/StgSharp.Mathematics/Internal/MatrixParallelTask.cs similarity index 86% rename from StgSharp.Mathematics/Numeric/Runtime/MatrixParallelTask.cs rename to StgSharp.Mathematics/Internal/MatrixParallelTask.cs index 4a32b2bb..735c6102 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelTask.cs +++ b/StgSharp.Mathematics/Internal/MatrixParallelTask.cs @@ -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)); + } + + } } \ No newline at end of file diff --git a/StgSharp.Mathematics/Numeric/Graphics/Matrix44.cs b/StgSharp.Mathematics/Numeric/Graphics/Matrix44.cs index b79df51d..7ea83e07 100644 --- a/StgSharp.Mathematics/Numeric/Graphics/Matrix44.cs +++ b/StgSharp.Mathematics/Numeric/Graphics/Matrix44.cs @@ -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 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 AsSpan() { return MemoryMarshal.CreateReadOnlySpan(ref Unsafe.As(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* 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); } diff --git a/StgSharp.Mathematics/Numeric/Graphics/Vec4.cs b/StgSharp.Mathematics/Numeric/Graphics/Vec4.cs index 39a26515..aca4cb12 100644 --- a/StgSharp.Mathematics/Numeric/Graphics/Vec4.cs +++ b/StgSharp.Mathematics/Numeric/Graphics/Vec4.cs @@ -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(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 span) + public static Vec4 FromSpan( + ReadOnlySpan 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.Equals(Vec4 other) + bool IEquatable.Equals( + Vec4 other + ) { return vec == other.vec; } diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.Factorize.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.Factorize.cs index f374e9cd..b5d28d39 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.Factorize.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.Factorize.cs @@ -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 matrix, Span pivot, Matrix lower, - Matrix upper) + Matrix 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++) { diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.Float.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.Float.cs index aa7ad0bf..1aff6019 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.Float.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.Float.cs @@ -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 left, Matrix right, Matrix ans) + public static unsafe void Add( + Matrix left, + Matrix right, + Matrix ans + ) { int f32 = (int)MatrixElementType.F32; if (left.ColumnLength != right.ColumnLength || @@ -57,7 +62,8 @@ namespace StgSharp.Mathematics.Numeric MatrixKernel* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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 ans, float value) + public static unsafe void Fill( + Matrix 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(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 left, Matrix right, Matrix ans) + public static unsafe void Mul( + Matrix left, + Matrix right, + Matrix ans + ) { int f32 = (int)MatrixElementType.F32; @@ -155,9 +169,10 @@ namespace StgSharp.Mathematics.Numeric enumeration->Member(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 left, float right, Matrix ans) + public static unsafe void Mul( + Matrix left, + float right, + Matrix 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* leftPtr = left.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* 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 left, Matrix right, Matrix ans) + public static unsafe void Sub( + Matrix left, + Matrix right, + Matrix ans + ) { int f32 = (int)MatrixElementType.F32; if (left.ColumnLength != right.ColumnLength || @@ -251,7 +277,8 @@ namespace StgSharp.Mathematics.Numeric MatrixKernel* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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); diff --git a/StgSharp.Mathematics/Numeric/MatrixCompute.double.cs b/StgSharp.Mathematics/Numeric/MatrixCompute.double.cs index ed3df8c1..e2aea435 100644 --- a/StgSharp.Mathematics/Numeric/MatrixCompute.double.cs +++ b/StgSharp.Mathematics/Numeric/MatrixCompute.double.cs @@ -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 left, Matrix right, Matrix ans) + public static unsafe void Add( + Matrix left, + Matrix right, + Matrix ans + ) { int f64 = (int)MatrixElementType.F64; if (left.ColumnLength != right.ColumnLength || @@ -53,7 +58,8 @@ namespace StgSharp.Mathematics.Numeric MatrixKernel* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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 ans, double value) + public static unsafe void Fill( + Matrix 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(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 left, Matrix right, Matrix ans) + public static unsafe void Mul( + Matrix left, + Matrix right, + Matrix ans + ) { int f64 = (int)MatrixElementType.F64; @@ -145,9 +159,10 @@ namespace StgSharp.Mathematics.Numeric enumeration->Member(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 left, double right, Matrix ans) + public static unsafe void Mul( + Matrix left, + double right, + Matrix 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* leftPtr = left.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* 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 left, Matrix right, Matrix ans) + public static unsafe void Sub( + Matrix left, + Matrix right, + Matrix ans + ) { int f64 = (int)MatrixElementType.F64; if (left.ColumnLength != right.ColumnLength || @@ -240,7 +266,8 @@ namespace StgSharp.Mathematics.Numeric MatrixKernel* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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* leftPtr = left.Buffer; MatrixKernel* rightPtr = right.Buffer; MatrixKernel* 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); diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs index 383274ad..d3104b5a 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.Publish.cs @@ -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; diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.cs index 36844278..3af5785b 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallel.cs @@ -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 _threads; - - private static ConcurrentDictionary contextMap; - + private static bool _meaningful; + + private static CapacityFixedStack _threads; + + private static ConcurrentDictionary contextMap; + private static SlabAllocator 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 + ); } -} +} diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs index fd00529a..c4510594 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelQueue.cs @@ -26,6 +26,7 @@ // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- using Microsoft.VisualBasic.FileIO; +using StgSharp.Mathematics.Internal; using System; using System.Collections.Concurrent; using System.Collections.Generic; diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Fma.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Fma.cs index 8d3a24ed..e72329d1 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Fma.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Fma.cs @@ -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(0) = i; enumeration->Member(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(0) = i; enumeration->Member(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); } } diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Model.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Model.cs index e6a1592f..92272fa2 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Model.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.Model.cs @@ -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])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) { diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.cs index 79f16439..b5e90a92 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelThread.cs @@ -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 { diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs index 989e845e..322251eb 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixParallelWrap.cs @@ -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) diff --git a/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs b/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs index dda54a69..55c51ef2 100644 --- a/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs +++ b/StgSharp.Mathematics/Numeric/Runtime/MatrixTaskFactory.cs @@ -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); diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs deleted file mode 100644 index b47239f8..00000000 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Common.cs +++ /dev/null @@ -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; - } - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs deleted file mode 100644 index 9a41ebd9..00000000 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.Enum.cs +++ /dev/null @@ -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 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); - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs deleted file mode 100644 index e87cde73..00000000 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.OperatorParser.cs +++ /dev/null @@ -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; - } - } - - /// - /// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING - /// SYMBOLS. - /// - 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; - } - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs deleted file mode 100644 index c7876f50..00000000 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs +++ /dev/null @@ -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"); - } - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs b/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs deleted file mode 100644 index 45237d00..00000000 --- a/StgSharp.Model/Step/Analyser/ExpSyntaxAnalyzer.cs +++ /dev/null @@ -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 _cache; - private ExpSchema _context; - private ExpSyntaxNode _lastStatement; - private IExpElementSource _local; - - public StepExpSyntaxAnalyzer() - { - _cache = new CompileStack(); - _context = new ExpressStepUtil(); - } - - public ConcurrentQueue StepEntityInitStatements { get; } = new(); - - /// - /// Append a token to top of cache. This method will automatically convert token to node - /// if meets separators or operators. - /// - 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, - - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs b/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs deleted file mode 100644 index 1a80ba49..00000000 --- a/StgSharp.Model/Step/Analyser/StepDataSectionsTranmitter.cs +++ /dev/null @@ -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 _cache = new ConcurrentQueue(); - 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(); - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs b/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs deleted file mode 100644 index 07faa82e..00000000 --- a/StgSharp.Model/Step/Analyser/StepDataTokenReader.cs +++ /dev/null @@ -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 tokenHash = [ "T", "F", "UNSPECIFIED" ]; - private Queue _cache = new Queue(); - 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 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(@"(?#[0-9A-Za-z]+)(?\s*?)(?\S|$)", RegexOptions.Singleline)] - private static partial Regex GetEntityTagSymbolPattern(); - - [GeneratedRegex(@"(?\.[A-Za-z_]+\.)(?\s*)(?\S*)", RegexOptions.Singleline)] - private static partial Regex GetNextEnumPattern(); - - [GeneratedRegex(@"(?')(?>\\\\|''|(?!')[^'])*(?')\s*?(?\S|$)", RegexOptions.Singleline)] - private static partial Regex GetStringPattern(); - - } - - } -} diff --git a/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs b/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs deleted file mode 100644 index 818cbe4d..00000000 --- a/StgSharp.Model/Step/Analyser/StepDependencyDetector.cs +++ /dev/null @@ -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 Dependencies { get; private set; } = new(); - - public void AddDependency(StepEntityInstanceNode node) - { - Dependencies.Add(node.Id); - } - - public IEnumerable ExportAllDependencies() - { - List ret = Dependencies; - Dependencies = new List(); - return ret; - } - - } -} diff --git a/StgSharp.Model/Step/ExpressStepUtil.cs b/StgSharp.Model/Step/ExpressStepUtil.cs deleted file mode 100644 index c721c879..00000000 --- a/StgSharp.Model/Step/ExpressStepUtil.cs +++ /dev/null @@ -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 names = [ AdvancedFaceText, Axis2Placement2DText, Axis2Placement3DText, BSplineCurveWithKnotsText, CartesianPointText, CircleText, CylindricalSurfaceText, DirectionText, EdgeCurveText, EdgeLoopText, EllipseText, FaceBoundText, FaceOuterBoundText, LineText, OrientedEdgeText, PlaneText, RepresentationItemText, VectorText, VertexPointText, ]; - - private FrozenDictionary entitiesDefine; - private StringPool _entityNamePool = new StringPool(); - - public ExpressStepUtil() - { - IEnumerable> defineSource = []; - entitiesDefine = new Dictionary(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; - } - - } -} \ No newline at end of file diff --git a/StgSharp.Model/Step/Items/StepAdvancedFace.cs b/StgSharp.Model/Step/Items/StepAdvancedFace.cs deleted file mode 100644 index 6f7d492f..00000000 --- a/StgSharp.Model/Step/Items/StepAdvancedFace.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement.cs b/StgSharp.Model/Step/Items/StepAxis2Placement.cs deleted file mode 100644 index 6bc8eba7..00000000 --- a/StgSharp.Model/Step/Items/StepAxis2Placement.cs +++ /dev/null @@ -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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs b/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs deleted file mode 100644 index 32f49df1..00000000 --- a/StgSharp.Model/Step/Items/StepAxis2Placement2D.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs b/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs deleted file mode 100644 index a3dce3d4..00000000 --- a/StgSharp.Model/Step/Items/StepAxis2Placement3D.cs +++ /dev/null @@ -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 - { - - 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.FromInstance(StepAxis2Placement3D entity) - { - throw new NotImplementedException(); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepBSplineCurve.cs b/StgSharp.Model/Step/Items/StepBSplineCurve.cs deleted file mode 100644 index a7fba8b9..00000000 --- a/StgSharp.Model/Step/Items/StepBSplineCurve.cs +++ /dev/null @@ -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 AllPossibleValue { get; } = [ CIRCULAR_ARC, ELLIPTIC_ARC, HYPERBOLIC_ARC, PARABOLIC_ARC, POLYLINE_FORM, UNSPECIFIED, ]; - - } - - public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom - { - - public StepBSplineCurve(StepModel model, params StepCartesianPoint[] controlPoints) - : this(model, (IEnumerable)controlPoints) { } - - public StepBSplineCurve(StepModel model, IEnumerable controlPoints) - : base(model) - { - ControlPointsList.AddRange(controlPoints); - } - - public bool ClosedCurve { get; set; } - - public bool SelfIntersect { get; set; } - - public int Degree { get; set; } - - public List ControlPointsList { get; private set; } - = new List(); - - 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, - }; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs b/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs deleted file mode 100644 index c46a546d..00000000 --- a/StgSharp.Model/Step/Items/StepBSplineCurveWithKnots.cs +++ /dev/null @@ -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 - { - - 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 controlPoints) - : base(model, controlPoints) { } - - public StepBSplineCurveWithKnots(StepModel model, params StepCartesianPoint[] controlPoints) - : base(model, controlPoints) { } - - public List KnotMultiplicities { get; } = new List(); - - public List Knots { get; } = new List(); - - public override StepItemType ItemType => StepItemType.BSplineCurveWithKnots; - - public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified; - - 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, - }; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepBSplineSurface.cs b/StgSharp.Model/Step/Items/StepBSplineSurface.cs deleted file mode 100644 index 8a143a2e..00000000 --- a/StgSharp.Model/Step/Items/StepBSplineSurface.cs +++ /dev/null @@ -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 - { - - 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> ControlPointsList { get; set; } - = new List>(); - - 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 pList = new List(points.Count); - CollectionsMarshal.SetCount(pList, points.Count); - Span ls = CollectionsMarshal.AsSpan(pList); - Span 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 list in entity.ControlPointsList) { - ControlPointsList.Add(new List(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 - }; - } - - } -} \ No newline at end of file diff --git a/StgSharp.Model/Step/Items/StepBoundedCurve.cs b/StgSharp.Model/Step/Items/StepBoundedCurve.cs deleted file mode 100644 index e36a3f1b..00000000 --- a/StgSharp.Model/Step/Items/StepBoundedCurve.cs +++ /dev/null @@ -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 - { - - 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); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepBoundedSurface.cs b/StgSharp.Model/Step/Items/StepBoundedSurface.cs deleted file mode 100644 index 042024f1..00000000 --- a/StgSharp.Model/Step/Items/StepBoundedSurface.cs +++ /dev/null @@ -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 - { - - public StepBoundedSurface(StepModel model) : base(model) { } - - public override StepItemType ItemType => StepItemType.BoundedSurface; - - public void FromInstance(StepBoundedSurface entity) - { - base.FromInstance(entity); - } - - } -} diff --git a/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs b/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs deleted file mode 100644 index 3c5c2747..00000000 --- a/StgSharp.Model/Step/Items/StepBoundedSurfaceCurve.cs +++ /dev/null @@ -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 - { - - 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); - } - - } -} diff --git a/StgSharp.Model/Step/Items/StepCartesianPoint.cs b/StgSharp.Model/Step/Items/StepCartesianPoint.cs deleted file mode 100644 index f25fc8c7..00000000 --- a/StgSharp.Model/Step/Items/StepCartesianPoint.cs +++ /dev/null @@ -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 - { - - 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); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepCircle.cs b/StgSharp.Model/Step/Items/StepCircle.cs deleted file mode 100644 index 8c9f43b6..00000000 --- a/StgSharp.Model/Step/Items/StepCircle.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepConic.cs b/StgSharp.Model/Step/Items/StepConic.cs deleted file mode 100644 index 304a32bd..00000000 --- a/StgSharp.Model/Step/Items/StepConic.cs +++ /dev/null @@ -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 - { - - 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.FromInstance(StepConic entity) - { - base.FromInstance(entity); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepCurve.cs b/StgSharp.Model/Step/Items/StepCurve.cs deleted file mode 100644 index 8c7ba5a6..00000000 --- a/StgSharp.Model/Step/Items/StepCurve.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepCylindricalSurface.cs b/StgSharp.Model/Step/Items/StepCylindricalSurface.cs deleted file mode 100644 index 436d7936..00000000 --- a/StgSharp.Model/Step/Items/StepCylindricalSurface.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepDirection.cs b/StgSharp.Model/Step/Items/StepDirection.cs deleted file mode 100644 index 474aac92..00000000 --- a/StgSharp.Model/Step/Items/StepDirection.cs +++ /dev/null @@ -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 - { - - 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); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepEdge.cs b/StgSharp.Model/Step/Items/StepEdge.cs deleted file mode 100644 index 23b586e0..00000000 --- a/StgSharp.Model/Step/Items/StepEdge.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepEdgeCurve.cs b/StgSharp.Model/Step/Items/StepEdgeCurve.cs deleted file mode 100644 index dc7d44ec..00000000 --- a/StgSharp.Model/Step/Items/StepEdgeCurve.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepEdgeLoop.cs b/StgSharp.Model/Step/Items/StepEdgeLoop.cs deleted file mode 100644 index f6eece2d..00000000 --- a/StgSharp.Model/Step/Items/StepEdgeLoop.cs +++ /dev/null @@ -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 - { - - public StepEdgeLoop(StepModel model, params StepOrientedEdge[] edgeList) - : this(model, (IEnumerable)edgeList) { } - - public StepEdgeLoop(StepModel model, IEnumerable edgeList) - : base(model) - { - EdgeList = new List(edgeList); - } - - public List 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepElementarySurface.cs b/StgSharp.Model/Step/Items/StepElementarySurface.cs deleted file mode 100644 index 1ab71d39..00000000 --- a/StgSharp.Model/Step/Items/StepElementarySurface.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepEllipse.cs b/StgSharp.Model/Step/Items/StepEllipse.cs deleted file mode 100644 index dc8083f0..00000000 --- a/StgSharp.Model/Step/Items/StepEllipse.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepFace.cs b/StgSharp.Model/Step/Items/StepFace.cs deleted file mode 100644 index 7b97de2b..00000000 --- a/StgSharp.Model/Step/Items/StepFace.cs +++ /dev/null @@ -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 - { - - public StepFace(StepModel model) : base(model) { } - - public List Bounds { get; private set; } = new List(); - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepFaceBound.cs b/StgSharp.Model/Step/Items/StepFaceBound.cs deleted file mode 100644 index 8a6c3ad3..00000000 --- a/StgSharp.Model/Step/Items/StepFaceBound.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepFaceOuterBound.cs b/StgSharp.Model/Step/Items/StepFaceOuterBound.cs deleted file mode 100644 index a289928e..00000000 --- a/StgSharp.Model/Step/Items/StepFaceOuterBound.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepFaceSurface.cs b/StgSharp.Model/Step/Items/StepFaceSurface.cs deleted file mode 100644 index 715968b1..00000000 --- a/StgSharp.Model/Step/Items/StepFaceSurface.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs b/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs deleted file mode 100644 index 06da119f..00000000 --- a/StgSharp.Model/Step/Items/StepGeometricRepresentationItem.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepLine.cs b/StgSharp.Model/Step/Items/StepLine.cs deleted file mode 100644 index 725f8ec0..00000000 --- a/StgSharp.Model/Step/Items/StepLine.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepLoop.cs b/StgSharp.Model/Step/Items/StepLoop.cs deleted file mode 100644 index 7af4b13b..00000000 --- a/StgSharp.Model/Step/Items/StepLoop.cs +++ /dev/null @@ -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 - { - - protected StepLoop(StepModel model) : base(model) { } - - public void FromInstance(StepLoop entity) - { - base.FromInstance(entity); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepOrientedEdge.cs b/StgSharp.Model/Step/Items/StepOrientedEdge.cs deleted file mode 100644 index c26e2a57..00000000 --- a/StgSharp.Model/Step/Items/StepOrientedEdge.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs b/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs deleted file mode 100644 index 839ef85d..00000000 --- a/StgSharp.Model/Step/Items/StepPcurveOrSurface.cs +++ /dev/null @@ -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 - { - - public StepPCurveOrSurface(StepModel model) : base(model) { } - - public void FromInstance(StepPCurveOrSurface entity) - { - base.FromInstance(entity); - } - - } -} diff --git a/StgSharp.Model/Step/Items/StepPlacement.cs b/StgSharp.Model/Step/Items/StepPlacement.cs deleted file mode 100644 index c3960b6a..00000000 --- a/StgSharp.Model/Step/Items/StepPlacement.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepPlane.cs b/StgSharp.Model/Step/Items/StepPlane.cs deleted file mode 100644 index 3011b9d0..00000000 --- a/StgSharp.Model/Step/Items/StepPlane.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepPoint.cs b/StgSharp.Model/Step/Items/StepPoint.cs deleted file mode 100644 index aaa17e2c..00000000 --- a/StgSharp.Model/Step/Items/StepPoint.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepRepresentationItem.cs b/StgSharp.Model/Step/Items/StepRepresentationItem.cs deleted file mode 100644 index e930d97f..00000000 --- a/StgSharp.Model/Step/Items/StepRepresentationItem.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepSurface.cs b/StgSharp.Model/Step/Items/StepSurface.cs deleted file mode 100644 index 216cbb90..00000000 --- a/StgSharp.Model/Step/Items/StepSurface.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepSurfaceCurve.cs b/StgSharp.Model/Step/Items/StepSurfaceCurve.cs deleted file mode 100644 index e22ea960..00000000 --- a/StgSharp.Model/Step/Items/StepSurfaceCurve.cs +++ /dev/null @@ -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 - { - - public StepSurfaceCurve(StepModel model) : base(model) { } - - public StepCurve Curve3D { get; set; } - - public void FromInstance(StepSurfaceCurve entity) - { - throw new NotImplementedException(); - } - - } -} diff --git a/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs b/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs deleted file mode 100644 index 8b3d5e0b..00000000 --- a/StgSharp.Model/Step/Items/StepTopologicalRepresentationItem.cs +++ /dev/null @@ -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 - { - - 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"; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepTriple.cs b/StgSharp.Model/Step/Items/StepTriple.cs deleted file mode 100644 index fa6438c0..00000000 --- a/StgSharp.Model/Step/Items/StepTriple.cs +++ /dev/null @@ -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 - { - - 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 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); - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepVector.cs b/StgSharp.Model/Step/Items/StepVector.cs deleted file mode 100644 index 1f65a809..00000000 --- a/StgSharp.Model/Step/Items/StepVector.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepVertex.cs b/StgSharp.Model/Step/Items/StepVertex.cs deleted file mode 100644 index 2fd94216..00000000 --- a/StgSharp.Model/Step/Items/StepVertex.cs +++ /dev/null @@ -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 - { - - public StepVertex(StepModel model) : base(model) { } - - public Vec3 Vertex { get; set; } - - public void FromInstance(StepVertex entity) - { - base.FromInstance(entity); - Vertex = entity.Vertex; - } - - } -} - diff --git a/StgSharp.Model/Step/Items/StepVertexPoint.cs b/StgSharp.Model/Step/Items/StepVertexPoint.cs deleted file mode 100644 index 3a244a9c..00000000 --- a/StgSharp.Model/Step/Items/StepVertexPoint.cs +++ /dev/null @@ -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 - { - - 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; - } - - } -} - diff --git a/StgSharp.Model/Step/StepDataParser.cs b/StgSharp.Model/Step/StepDataParser.cs deleted file mode 100644 index db040c30..00000000 --- a/StgSharp.Model/Step/StepDataParser.cs +++ /dev/null @@ -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*(?.+)\s*('\s*\)|')", RegexOptions.Singleline)] - private static partial Regex GetStringParser(); - - [GeneratedRegex( - @"^\(\s+(?-?[0-9]+\.[0-9]+),\s+(?-?[0-9]+\.[0-9]+),\s+(?-?[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(); - } - } - - } -} diff --git a/StgSharp.Model/Step/StepEntityBase.cs b/StgSharp.Model/Step/StepEntityBase.cs deleted file mode 100644 index e31f2e1b..00000000 --- a/StgSharp.Model/Step/StepEntityBase.cs +++ /dev/null @@ -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 - { - - public IEnumerable 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 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; - } - - } -} diff --git a/StgSharp.Model/Step/StepEntityLabel.cs b/StgSharp.Model/Step/StepEntityLabel.cs deleted file mode 100644 index 40ee0058..00000000 --- a/StgSharp.Model/Step/StepEntityLabel.cs +++ /dev/null @@ -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}"; - } - - } -} diff --git a/StgSharp.Model/Step/StepEntityUnsupportedException.cs b/StgSharp.Model/Step/StepEntityUnsupportedException.cs deleted file mode 100644 index 7d6a6b29..00000000 --- a/StgSharp.Model/Step/StepEntityUnsupportedException.cs +++ /dev/null @@ -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 { } -} diff --git a/StgSharp.Model/Step/StepHeader.cs b/StgSharp.Model/Step/StepHeader.cs deleted file mode 100644 index c34f0322..00000000 --- a/StgSharp.Model/Step/StepHeader.cs +++ /dev/null @@ -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 -{ - /// - /// C# implementation of HEADER part in STEP file. - /// - 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; - } - - } - - /// - /// C# implementation of FILE_NAME part in header of STEP file. - /// - 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 _schema = new(); - - public string Data { get; internal set; } - - } - - /// - /// C# implementation of FILE_NAME part in header of STEP file. - /// - public record class STEPFileDescriptor - { - - public (int mainLevel,int? subLevel) Level { get; internal set; } - - public string Description { get; internal set; } - - } -} diff --git a/StgSharp.Model/Step/StepHeaderLineConstructor.cs b/StgSharp.Model/Step/StepHeaderLineConstructor.cs deleted file mode 100644 index b2abcd67..00000000 --- a/StgSharp.Model/Step/StepHeaderLineConstructor.cs +++ /dev/null @@ -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( - @"(?.+?(\)|'\s?\)|'))\s?(?,)\s?(?(.|\(|\(\s?').+)", - RegexOptions.Compiled); - - private readonly int _id; - private readonly List _paramList; - private string _caller; - - public StepHeaderLineConstructor(int id, string caller, string parameters) - { - _caller = caller; - _paramList = new List(); - SplitParameter(parameters); - } - - public string this[int paramIndex] - { - get => _paramList[paramIndex]; - } - - public ReadOnlyCollection 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); - } - - } -} diff --git a/StgSharp.Model/Step/StepItemType.cs b/StgSharp.Model/Step/StepItemType.cs deleted file mode 100644 index da776ec4..00000000 --- a/StgSharp.Model/Step/StepItemType.cs +++ /dev/null @@ -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 - - } -} - diff --git a/StgSharp.Model/Step/StepModel.cs b/StgSharp.Model/Step/StepModel.cs deleted file mode 100644 index 11c17617..00000000 --- a/StgSharp.Model/Step/StepModel.cs +++ /dev/null @@ -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 _nodes - = new Dictionary(); - - 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 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 nodes = PipelineMarshal.GetNodeSortedEnumeration( - _initScheduler); - int count = 0; - List 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(); - } - - } -} diff --git a/StgSharp.Model/Step/StepReader.DataSectionReader.cs b/StgSharp.Model/Step/StepReader.DataSectionReader.cs deleted file mode 100644 index 4957f597..00000000 --- a/StgSharp.Model/Step/StepReader.DataSectionReader.cs +++ /dev/null @@ -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( - @"^#(?[0-9]+)\s*?=\s*?(?\S.*?)\s*;$", - RegexOptions.Compiled | RegexOptions.Singleline)] - private static partial Regex GetExpressionSplitter(); - - } -} diff --git a/StgSharp.Model/Step/StepReader.HeadReader.cs b/StgSharp.Model/Step/StepReader.HeadReader.cs deleted file mode 100644 index 79f17f46..00000000 --- a/StgSharp.Model/Step/StepReader.HeadReader.cs +++ /dev/null @@ -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 constructorList = new List(); - 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(@"^(?[A-Z_]+)\s?\((?.+)\)\;", RegexOptions.Compiled)] - private static partial Regex GetStepHeadExpressionParser(); - /**/ - - } -} \ No newline at end of file diff --git a/StgSharp.Model/Step/StepReader.ToModel.cs b/StgSharp.Model/Step/StepReader.ToModel.cs deleted file mode 100644 index 62c7095f..00000000 --- a/StgSharp.Model/Step/StepReader.ToModel.cs +++ /dev/null @@ -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 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 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 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 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); - } - } - - } -} diff --git a/StgSharp.Model/Step/StepReader.cs b/StgSharp.Model/Step/StepReader.cs deleted file mode 100644 index 81ed4a69..00000000 --- a/StgSharp.Model/Step/StepReader.cs +++ /dev/null @@ -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 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; - } - } - - } -} diff --git a/StgSharp.Model/Step/StepUncertainEntity.Parse.cs b/StgSharp.Model/Step/StepUncertainEntity.Parse.cs deleted file mode 100644 index 25fc925a..00000000 --- a/StgSharp.Model/Step/StepUncertainEntity.Parse.cs +++ /dev/null @@ -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() - }; - } - - } -} diff --git a/StgSharp.Model/Step/StepUncertainEntity.cs b/StgSharp.Model/Step/StepUncertainEntity.cs deleted file mode 100644 index 199917e8..00000000 --- a/StgSharp.Model/Step/StepUncertainEntity.cs +++ /dev/null @@ -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 dependency) - { - Context = model; - Id = id; - _data = initialization; - if (dependency == null) - { - Dependencies = []; - } else - { - Dependencies = dependency; - } - } - - public override StepItemType ItemType => StepItemType.Unknown; - - internal static HashSet UnsupportedItemTypes { get; } = new HashSet(); - - 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 input, - in Dictionary 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 IConvertableToPipelineNode.InputPortName => [ InName ]; - - PipelineNodeOperation IConvertableToPipelineNode.Operation => (this as IConvertableToPipelineNode).NodeMain; - - IEnumerable IConvertableToPipelineNode.OutputPortName => [ OutName ]; - - } -} \ No newline at end of file diff --git a/StgSharp.Model/Step/StepUnsupportedEntity.cs b/StgSharp.Model/Step/StepUnsupportedEntity.cs deleted file mode 100644 index 84fefe06..00000000 --- a/StgSharp.Model/Step/StepUnsupportedEntity.cs +++ /dev/null @@ -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; - - } -} diff --git a/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs b/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs deleted file mode 100644 index e71fe179..00000000 --- a/StgSharp.Model/Step/SyntaxNode/StepComplexEntityNode.cs +++ /dev/null @@ -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); - } - - } -} diff --git a/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs b/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs deleted file mode 100644 index 96a39d8a..00000000 --- a/StgSharp.Model/Step/SyntaxNode/StepEntityInitCaller.cs +++ /dev/null @@ -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 _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; - } - - } -} diff --git a/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs b/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs deleted file mode 100644 index 43c4fdcb..00000000 --- a/StgSharp.Model/Step/SyntaxNode/StepEntityInstanceNode.cs +++ /dev/null @@ -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"); - - } -} diff --git a/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs b/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs deleted file mode 100644 index 32e0cbe3..00000000 --- a/StgSharp.Model/Step/SyntaxNode/StepExpEnumValueNode.cs +++ /dev/null @@ -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; } - - } -} diff --git a/StgSharp.Native/StgSharp.Native.vcxproj b/StgSharp.Native/StgSharp.Native.vcxproj index 136aba8a..be1f116a 100644 --- a/StgSharp.Native/StgSharp.Native.vcxproj +++ b/StgSharp.Native/StgSharp.Native.vcxproj @@ -185,7 +185,6 @@ - diff --git a/StgSharp.Native/StgSharp.Native.vcxproj.filters b/StgSharp.Native/StgSharp.Native.vcxproj.filters index 5325cbd2..8c79c37c 100644 --- a/StgSharp.Native/StgSharp.Native.vcxproj.filters +++ b/StgSharp.Native/StgSharp.Native.vcxproj.filters @@ -27,9 +27,6 @@ 源文件 - - 源文件 - 源文件 diff --git a/StgSharp.Native/sn-head/sn_intrinsic.context.x86.h b/StgSharp.Native/sn-head/sn_intrinsic.context.x86.h index 0b97e260..59671ec7 100644 --- a/StgSharp.Native/sn-head/sn_intrinsic.context.x86.h +++ b/StgSharp.Native/sn-head/sn_intrinsic.context.x86.h @@ -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 diff --git a/StgSharp.Native/sn-head/sn_intrinsic.h b/StgSharp.Native/sn-head/sn_intrinsic.h index b51a9c04..1b7536dd 100644 --- a/StgSharp.Native/sn-head/sn_intrinsic.h +++ b/StgSharp.Native/sn-head/sn_intrinsic.h @@ -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; diff --git a/StgSharp.Native/sn-head/sn_intrinsic.std.h b/StgSharp.Native/sn-head/sn_intrinsic.std.h index bee3f3f8..0f981626 100644 --- a/StgSharp.Native/sn-head/sn_intrinsic.std.h +++ b/StgSharp.Native/sn-head/sn_intrinsic.std.h @@ -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 diff --git a/StgSharp.Native/sn-src/load_intrinsic.x86.c b/StgSharp.Native/sn-src/load_intrinsic.x86.c index 6ea2fdb3..4a220d7e 100644 --- a/StgSharp.Native/sn-src/load_intrinsic.x86.c +++ b/StgSharp.Native/sn-src/load_intrinsic.x86.c @@ -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; } diff --git a/StgSharp.Native/sn-src/m.bufop.x86.c b/StgSharp.Native/sn-src/m.bufop.x86.c index 686ad429..95958fe0 100644 --- a/StgSharp.Native/sn-src/m.bufop.x86.c +++ b/StgSharp.Native/sn-src/m.bufop.x86.c @@ -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]); diff --git a/StgSharp.Native/sn-src/m.fma.x86.c b/StgSharp.Native/sn-src/m.fma.x86.c index 66dd136a..a357ef71 100644 --- a/StgSharp.Native/sn-src/m.fma.x86.c +++ b/StgSharp.Native/sn-src/m.fma.x86.c @@ -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 } }; diff --git a/StgSharp.Native/sn-src/m.fma_tile.x86.c b/StgSharp.Native/sn-src/m.fma_tile.x86.c index ba4f1ae1..41b418b4 100644 --- a/StgSharp.Native/sn-src/m.fma_tile.x86.c +++ b/StgSharp.Native/sn-src/m.fma_tile.x86.c @@ -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 } }; diff --git a/StgSharp.Native/sn-src/str_string.c b/StgSharp.Native/sn-src/str_string.c deleted file mode 100644 index abcc3f0b..00000000 --- a/StgSharp.Native/sn-src/str_string.c +++ /dev/null @@ -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 diff --git a/StgSharp.RegularAnalysis/Abstraction/ITokenReader.cs b/StgSharp.RegularAnalysis/Abstraction/ITokenReader.cs index 6076bb5e..a603d34e 100644 --- a/StgSharp.RegularAnalysis/Abstraction/ITokenReader.cs +++ b/StgSharp.RegularAnalysis/Abstraction/ITokenReader.cs @@ -25,6 +25,8 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- +using System; + namespace StgSharp.RegularAnalysis.Abstraction { public static class TokenReader diff --git a/StgSharp.RegularAnalysis/RegularMachine/Node.Branch.cs b/StgSharp.RegularAnalysis/RegularMachine/Node.Branch.cs index b55f15f5..ccf8e87d 100644 --- a/StgSharp.RegularAnalysis/RegularMachine/Node.Branch.cs +++ b/StgSharp.RegularAnalysis/RegularMachine/Node.Branch.cs @@ -25,7 +25,6 @@ // // ----------------------------------------------------------------------- // ----------------------------------------------------------------------- -using StgSharp.MVVM; using System; using System.Collections.Generic; using System.Diagnostics.Contracts; diff --git a/StgSharp.RegularAnalysis/RegularMachine/StateMachine.cs b/StgSharp.RegularAnalysis/RegularMachine/StateMachine.cs index dff68cae..774b5e1f 100644 --- a/StgSharp.RegularAnalysis/RegularMachine/StateMachine.cs +++ b/StgSharp.RegularAnalysis/RegularMachine/StateMachine.cs @@ -27,7 +27,6 @@ // ----------------------------------------------------------------------- using StgSharp.Internal; using StgSharp.State; - using System; using System.Collections.Generic; using System.Linq;