MulAvailable

This commit is contained in:
Nitload
2025-12-16 23:13:17 +08:00
parent 28ea5d1d1e
commit 3486375470
2637 changed files with 23787 additions and 838773 deletions
@@ -1,281 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Common.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 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.Modeling.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private static Regex _entityTypeCheckPattern = GetEntityTypeCheckPattern();
[GeneratedRegex( @"^[A-Z_]+$", 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 );
_cache.StatementsInDepth.Push( statement );
if( t.Value == ";" ) {
StepEntityInitStatements.Enqueue( 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 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 ) ) {
_cache.PushOperator( t );
}
return false;
}
private bool TryParseInstance( Token t )
{
if( t.Value[ 0 ] == '#' )
{
_cache.PushOperand( StepEntityInstanceNode.Register( t ) );
return true;
}
return false;
}
private bool TryParseKeyword( Token t )
{
switch( t.Value )
{
case ExpKeyword.Return:
_cache.PushOperator( t );
return true;
case ExpKeyword.Skip:
_cache.PushOperand( ExpProcedureControlNode.Skip( t ) );
return true;
default:
return false;
}
}
}
}
@@ -1,68 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private static string ParseStepEnumLiteral( string source )
{
int length = source.Length;
ReadOnlySpan<char> span = source.AsSpan();
if( length > 2 && span[ 0 ] == '.' && span[ length - 1 ] == '.' ) {
return span.Slice( 1, length - 2 ).ToString();
}
throw new ExpInvalidSyntaxException( $"\"{source}\" is not a valid enum syntax" );
}
private void TryAppendEnum( Token e )
{
ExpSyntaxNode node = e.Value switch
{
".T." => new ExpBoolNode( e, true, true ),
".F." => new ExpBoolNode( e, false, true ),
".U." => new ExpLogicValueNode( e, ExpLogic.Unknown, true ),
_ => ExpEnumLiteralNode.Create( e, ParseStepEnumLiteral ),
};
_cache.PushOperand( node );
}
}
}
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess.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.Modeling.Step
{
internal partial class StepExpSyntaxAnalyzer
{
public void ThrowCompileException( int errorCode )
{
switch( errorCode )
{
case 0 or 1:
return;
case TokenTypeNotMatch:
throw new Exception();
default:
break;
}
}
}
}
@@ -1,148 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step.SyntaxNode;
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.Modeling.Step
{
internal partial class StepExpSyntaxAnalyzer
{
public int CompareOperatorPrecedence( Token left, Token right )
{
ExpressCompile.TryGetOperatorPrecedence( left.Value, out int leftPrecedence );
ExpressCompile.TryGetOperatorPrecedence( right.Value, out int rightPrecedence );
return leftPrecedence - rightPrecedence;
}
public bool TryGenerateUnaryNode( Token t, out ExpSyntaxNode node )
{
ExpSyntaxNode operand = GetNextOperandCache();
switch( t.Value )
{
case ExpKeyword.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus( t, operand );
return true;
case ExpKeyword.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus( t, operand );
return true;
case ExpKeyword.Not:
node = ExpUnaryOperatorNode.UnaryNot( t, operand );
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
/// <summary>
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS.
/// </summary>
private ExpSyntaxNode ConvertAndPushOneOperator( Token op )
{
switch( op.Flag )
{
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( op, out ExpSyntaxNode? node );
_cache.PushOperand( node );
return node;
case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode( op, out node );
_cache.PushOperand( node );
return node;
case TokenFlag.Member:
_cache.PopOperand( out _, out ExpSyntaxNode? p );
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller( op.Value );
node = ExpFunctionCallingNode.CallFunction( op, caller, p );
_cache.PushOperand( 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 ExpKeyword.Add:
node = ExpBinaryOperatorNode.Add( t, left, right );
return true;
case ExpKeyword.Sub:
node = ExpBinaryOperatorNode.Sub( t, left, right );
return true;
case ExpKeyword.Mul:
node = ExpBinaryOperatorNode.Mul( t, left, right );
return true;
case ExpKeyword.Div:
node = ExpBinaryOperatorNode.Div( t, left, right );
return true;
case ExpKeyword.Equal:
node = ExpBinaryOperatorNode.EqualTo( t, left, right );
return true;
case ExpKeyword.NotEqual:
node = ExpBinaryOperatorNode.NotEqualTo( t, left, right );
return true;
case ExpKeyword.GreaterThan:
node = ExpBinaryOperatorNode.GreaterThan( t, left, right );
return true;
case ExpKeyword.LessThan:
node = ExpBinaryOperatorNode.LessThan( t, left, right );
return true;
case ExpKeyword.Assignment:
node = ExpBinaryOperatorNode.Assign( t, left, right );
return true;
case ExpKeyword.InstanceEqual:
node = ExpBinaryOperatorNode.CompareInstanceEqual( t, left, right );
return true;
case ExpKeyword.InstanceNotEqual:
node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right );
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
}
}
@@ -1,85 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.PrefixReverseAnalysing.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Modeling.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
{
ExpInvalidSyntaxException.ThrowNoOperator( rightSeparator );
}
} else
{
while( _cache.TryPopOperator( out op ) ) {
ConvertAndPushOneOperator( op );
}
_cache.PopOperand( out _, out root );
_cache.StatementsInDepth.Push( root );
}
root = _cache.PackAllStatements();
_cache.DecreaseDepth();
if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) )
{
_cache.PopOperator();
_cache.PushOperand( root );
} else
{
throw new ExpCompileException(
rightSeparator, "Ending of block does not match its begging" );
}
}
}
}
@@ -1,149 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.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 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.Modeling.Step
{
internal partial class StepExpSyntaxAnalyzer : ISyntaxAnalyzer
{
private const int EndLine = 1;
private const int TokenGenerated = 0;
private const int TokenTypeNotMatch = -1;
private CompileStack<ExpSyntaxNode, IExpElementSource> _cache;
private ExpSchema _context;
private ExpSyntaxNode _lastStatement;
private IExpElementSource _local;
public StepExpSyntaxAnalyzer()
{
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
}
public StepExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local )
{
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
ArgumentNullException.ThrowIfNull( context );
if( context is not ExpSchema_Builtin )
{
_context = context;
} else
{
throw new InvalidCastException( "Not a valid Schema type" );
}
_local = local;
}
public ConcurrentQueue<ExpSyntaxNode> StepEntityInitStatements { get; } = new ConcurrentQueue<ExpSyntaxNode>(
);
/// <summary>
/// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators.
/// </summary>
public void AppendToken( Token expToken )
{
switch( expToken.Flag )
{
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol( expToken );
break;
case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken );
_cache.PushOperand( node );
break;
case TokenFlag.Separator_Left:
TryAppendPrefixSeparator( expToken );
break;
case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd( expToken );
break;
case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator( expToken );
break;
case TokenFlag.Index_Left:
TryAppendIndexLeft( expToken );
break;
case TokenFlag.Index_Right:
TryAppendIndexRight( expToken );
break;
case TokenFlag.Member:
TryAppendMember( expToken );
break;
default:
break;
}
}
public ExpSyntaxNode GetNextOperandCache()
{
if( _cache.PopOperand( out Token t, out ExpSyntaxNode? n ) )
{
return n;
} else
{
// process some rare case here
}
throw new NotImplementedException();
}
public enum ExpCompileStateCode
{
Common,
ForLoop,
RepeatLoop,
UntilLoop,
IfBranch,
CaseBranch,
CollectionIndex,
}
}
}
@@ -1,104 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataSectionsTranmitter.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepDataSectionTransmitter : IScriptSourceProvider
{
private const string EndDataText = "ENDSEC;";
private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0;
public bool IsEmpty => _isEmpty;
public bool IsWriting { get; private set; } = true;
public int Location => _line;
public void EndWriting()
{
_cache.Enqueue( EndDataText );
IsWriting = false;
}
public string ReadLine()
{
_cache.TryDequeue( out string? line );
while( !IsEmpty )
{
if( _cache.TryDequeue( out line ) )
{
if( line == EndDataText )
{
_isEmpty = true;
return string.Empty;
}
_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 == EndDataText ) {
EndWriting();
}
_cache.Enqueue( line );
}
IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count )
{
throw new NotSupportedException();
}
}
}
@@ -1,117 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataTokenReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.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.Modeling.Step
{
public class StepDataTokenReader : IScriptTokenReader
{
private ExpTokenReader _reader;
private HashSet<string> token1Hash = [
"T","F","UNSPECIFIED"
];
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader( StepDataSectionTransmitter transmitter )
{
_reader = new ExpTokenReader( transmitter );
_reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter;
}
public bool IsEmpty
{
get => _reader.IsEmpty && _transmitter.IsWriting;
}
public Token ReadToken()
{
return _reader.ReadToken();
}
public bool TryReadToken( out Token t )
{
return _reader.TryReadToken( out t );
}
private class TokenPreReader : ExpTokenReaderPreProcessor
{
private static Regex NextEnumPattern = GetNextEnumPattern();
public override bool Process( string codeLine, int line, ref int current, out Token t )
{
ReadOnlySpan<char> chars = codeLine.AsSpan( current );
char c = chars[ 0 ];
if( c != '.' )
{
t = Token.Empty;
return false;
}
Match match = NextEnumPattern.Match( codeLine, current );
if( match.Success )
{
int begin = match.Groups[ "begin" ].Index;
int end = match.Groups[ "end" ].Length;
int rest = match.Groups[ "rets" ].Length;
current = rest;
t = new Token( match.Groups[ "begin" ].Value, line, begin, TokenFlag.Enum );
return true;
} else
{
t = Token.Empty;
return false;
}
}
[GeneratedRegex(
@"(?<begin>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)",
RegexOptions.Singleline )]
private static extern Regex GetNextEnumPattern();
}
}
}
@@ -1,61 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDependencyDetector.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepDependencyDetector
{
public StepDependencyDetector() { }
public List<int> Dependencies { get; private set; } = new();
public void AddDependency( StepEntityInstanceNode node )
{
Dependencies.Add( node.Id );
}
public IEnumerable<int> ExportAllDependencies()
{
List<int> ret = Dependencies;
Dependencies = new List<int>();
return ret;
}
}
}
@@ -1,54 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityDefineSequence.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public record class StepEntityDefineSequence
{
public StepEntityDefineSequence( ExpSyntaxNode node, IEnumerable<int> dep )
{
Expression = node;
Dependencies = dep;
}
public ExpSyntaxNode Expression { get; init; }
public IEnumerable<int> Dependencies { get; init; }
}
}
-101
View File
@@ -1,101 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpressStepUntil.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
using StgSharp.Modeling.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace StgSharp.Modeling.Step
{
public class ExpressStepUntil : ExpSchema
{
private FrozenDictionary<string, ExpTypeSource> entitiesDefine;
public ExpressStepUntil()
{
Span<KeyValuePair<string, ExpTypeSource>> source = [
new KeyValuePair<string, ExpTypeSource>( StepItemTypeExtensions.AdvancedFaceText,
),
];
Dictionary<string, ExpTypeSource> tIndex = new Dictionary<string, ExpTypeSource>();
}
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 )
{
throw new NotImplementedException();
}
public override bool TryGetFunction( string name, out ExpFunctionSource f )
{
throw new NotImplementedException();
}
public override bool TryGetProcedure( string name, out ExpProcedureSource p )
{
throw new NotImplementedException();
}
public override bool TryGetRule( string name, out ExpRuleSource r )
{
throw new NotImplementedException();
}
public override bool TryGetSchemaInclude( string name, out ExpSchema include )
{
throw new NotImplementedException();
}
public override bool TryGetType( string name, out ExpTypeSource t )
{
throw new NotImplementedException();
}
}
}
-142
View File
@@ -1,142 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpressStepUtil.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace StgSharp.Modeling.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 VectorText = "VECTOR";
public const string VertexPointText = "VERTEX_POINT";
private static
HashSet<string> names = [
AdvancedFaceText,
Axis2Placement2DText,
Axis2Placement3DText,
BSplineCurveWithKnotsText,
CartesianPointText,
CircleText,
CylindricalSurfaceText,
DirectionText,
EdgeCurveText,
EdgeLoopText,
EllipseText,
FaceBoundText,
FaceOuterBoundText,
LineText,
OrientedEdgeText,
PlaneText,
VectorText,
VertexPointText,
];
private FrozenDictionary<string, ExpTypeSource> entitiesDefine;
public ExpressStepUtil()
{
Dictionary<string, ExpTypeSource> tIndex = new Dictionary<string, ExpTypeSource>();
}
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 )
{
e = null!;
return false;
}
public override bool TryGetFunction( string name, out ExpFunctionSource f )
{
throw new NotImplementedException();
}
public override bool TryGetProcedure( string name, out ExpProcedureSource p )
{
p = null!;
return false;
}
public override bool TryGetRule( string name, out ExpRuleSource r )
{
r = null!;
return false;
}
public override bool TryGetSchemaInclude( string name, out ExpSchema include )
{
include = null!;
return false;
}
public override bool TryGetType( string name, out ExpTypeSource t )
{
t = null!;
return false;
}
}
}
@@ -1,71 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IStepObject.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Math;
using StgSharp.PipeLine;
using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Modeling.STEP
{
public abstract class IStepObject : StepExpressionBase, IGeometry
{
public abstract Point this[ int index ]
{
get;
set;
}
public abstract Vec4[] VertexStream
{
get;
}
public abstract CoordinationBase Coordination
{
get;
}
public abstract int VertexCount
{
get;
}
public abstract ReadOnlySpan<int> VertexIndices
{
get;
}
}
}
@@ -1,135 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpression.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
namespace StgSharp.Modeling.STEP
{
public abstract class StepExpressionBase
{
public abstract List<StepExpressionBase> ParameterList { get; set; }
public int ID { get; internal set; }
}
public abstract class StepExpressionParameter : StepExpressionBase
{
public abstract object Value { get; set; }
}
public class StepObjectConstructor
{
private static Regex regex = new Regex(
@"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)",
RegexOptions.Compiled );
private readonly int _id;
private readonly List<string> _paramList;
private string _caller;
public StepObjectConstructor( int id, string caller, string parameters )
{
_caller = caller;
_paramList = new List<string>();
SplitParameter( parameters );
}
public string this[ int paramIndex ]
{
get => _paramList[ paramIndex ];
}
public ReadOnlyCollection<string> ParamList
{
get => _paramList.AsReadOnly();
}
public static string TempCallerName
{
get => "TEMPCALLER";
}
public string Caller
{
get => _caller;
internal set => _caller = value;
}
public static StepObjectConstructor CreateTempExpression( int id )
{
return new StepObjectConstructor( 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 );
}
}
public record class StepCodeLine
{
public StepCodeLine( int id, string codeLine )
{
ID = id;
CodeLine = codeLine;
}
public int ID
{
get;
set;
}
public string CodeLine
{
get;
set;
}
}
}
@@ -1,227 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="STEPHeader.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.Text;
namespace StgSharp.Modeling.STEP
{
/// <summary>
/// C# implementation of HEADER part in STEP file.
/// </summary>
public struct StepInfo
{
private STEPFileDescriptor _header;
private STEPFileName _name;
private STEPSchema _schema;
public (int mainLevel, int? subLevel) Level
{
get => _header.Level;
internal set => _header.Level = value;
}
public DateTime TimeStamp
{
get => _name.TimeStamp;
internal set => _name.TimeStamp = value;
}
public STEPFileDescriptor Descriptor
{
get => _header;
internal set => _header = value;
}
public STEPFileName FileName
{
get => _name;
internal set => _name = value;
}
public STEPSchema Schema
{
get => _schema;
internal set => _schema = value;
}
public string Description
{
get => _header.Description;
internal set => _header.Description = value;
}
public string Name
{
get => _name.Name;
internal set => _name.Name = value;
}
public string Author
{
get => _name.Author;
internal set => _name.Author = value;
}
public string Organization
{
get => _name.Organization;
internal set => _name.Organization = value;
}
public string OriginatingSystem
{
get => _name.OriginatingSystem;
internal set => _name.OriginatingSystem = value;
}
public string Authorization
{
get => _name.Authorization;
internal set => _name.Authorization = value;
}
public string PreprocessorVersion
{
get => _name.PreprocessorVersion;
internal set => _name.PreprocessorVersion = value;
}
public string Version
{
get => _name.Version;
internal set => _name.Version = value;
}
public string SchemaString
{
get => _schema.Data;
internal set => _schema.Data = value;
}
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public struct 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 struct STEPSchema
{
private List<string> _schema;
public string Data
{
get;
internal set;
}
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public struct STEPFileDescriptor
{
public (int mainLevel,int? subLevel) Level
{
get;
internal set;
}
public string Description
{
get;
internal set;
}
}
}
@@ -1,64 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepModel.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.PipeLine;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Modeling.STEP
{
public class StepModel
{
private BlueprintScheduler _builder;
private Dictionary<int, IStepObject> _node
= new Dictionary<int, IStepObject>();
private StepInfo _header;
internal StepModel(
StepInfo header,
Dictionary<int, IStepObject> nodeSource )
{
_header = header;
_node = nodeSource;
_builder = new BlueprintScheduler();
}
public void BuildGeometry() { }
public void OrganizeNode()
{
foreach( KeyValuePair<int, IStepObject> node in _node ) { }
}
}
}
-36
View File
@@ -1,36 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="IStepEntity.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
namespace StgSharp.Modeling.STEP
{
public interface IStepEntity<TSelf> : IExpMarshalType<TSelf> where TSelf: IStepEntity<TSelf> { }
}
@@ -1,78 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepAdvancedFace.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Linq;
namespace StgSharp.Modeling.Items
{
public class StepAdvancedFace : StepFaceSurface
{
private StepAdvancedFace() : base( string.Empty ) { }
public StepAdvancedFace( string name ) : base( name ) { }
public override StepItemType ItemType => StepItemType.AdvancedFace;
internal static StepAdvancedFace CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAdvancedFace face = new StepAdvancedFace();
enumerator.AssertEnumeratorCount( 4 );
face.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
object boundsList = enumerator.Values[ 1 ].GetValueList();
face.Bounds.Clear();
face.Bounds
.AddRange(
Enumerable.Range( 0, enumerator.Values.Count )
.Select( _ => ( StepFaceBound )null ) );
for( int i = 0; i < enumerator.Values.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
enumerator.Values[ j ], v => face.Bounds[ j ] = v.AsType<StepFaceBound>() );
}
binder.BindValue(
enumerator.Values[ 2 ], v => face.FaceGeometry = v.AsType<StepSurface>() );
face.SameSense = ( enumerator.Values[ 3 ] as ExpBoolNode )!.Value;
return face;
}
}
}
@@ -1,72 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepAxis2Placement.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Modeling.Items
{
public abstract class StepAxis2Placement : StepPlacement
{
private StepCartesianPoint _location;
private StepDirection _refDirection;
protected StepAxis2Placement( string name ) : base( name ) { }
public StepCartesianPoint Location
{
get { return _location; }
set
{
ArgumentNullException.ThrowIfNull( value );
_location = value;
}
}
public StepDirection RefDirection
{
get { return _refDirection; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_refDirection = value;
}
}
}
}
@@ -1,79 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepAxis2Placement2D.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepAxis2Placement2D : StepAxis2Placement
{
private StepAxis2Placement2D() : base( string.Empty ) { }
public StepAxis2Placement2D(
string label,
StepCartesianPoint location,
StepDirection direction )
: base( label )
{
Location = location;
RefDirection = direction;
}
public override StepItemType ItemType => StepItemType.AxisPlacement2D;
internal static StepAxis2Placement2D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAxis2Placement2D axis = new StepAxis2Placement2D();
enumerator.AssertEnumeratorCount( 3 );
axis.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => axis.Location = v.AsType<StepCartesianPoint>() );
binder.BindValue(
enumerator.Values[ 2 ], v => axis.RefDirection = v.AsType<StepDirection>() );
return axis;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Location;
yield return RefDirection;
}
}
}
@@ -1,98 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepAxis2Placement3D.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepAxis2Placement3D : StepAxis2Placement
{
private StepDirection _axis;
private StepAxis2Placement3D() : base( string.Empty ) { }
public StepAxis2Placement3D(
string name,
StepCartesianPoint location,
StepDirection axis,
StepDirection refDirection )
: base( name )
{
Location = location;
Axis = axis;
RefDirection = refDirection;
}
public StepDirection Axis
{
get { return _axis; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_axis = value;
}
}
public override StepItemType ItemType => StepItemType.AxisPlacement3D;
internal static StepAxis2Placement3D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAxis2Placement3D axis = new StepAxis2Placement3D();
enumerator.AssertEnumeratorCount( 4 );
axis.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => axis.Location = v.AsType<StepCartesianPoint>() );
binder.BindValue( syntaxList.Values[ 2 ], v => axis.Axis = v.AsType<StepDirection>() );
binder.BindValue(
enumerator.Values[ 3 ], v => axis.RefDirection = v.AsType<StepDirection>() );
return axis;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Location;
yield return Axis;
yield return RefDirection;
}
}
}
@@ -1,132 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepBSplineCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
{
public enum StepBSplineCurveForm
{
Polyline,
CircularArc,
EllipticalArc,
ParabolicArc,
HyperbolicArc,
Unspecified
}
;
public abstract class StepBSplineCurve : StepBoundedCurve
{
private const string CIRCULAR_ARC = "CIRCULAR_ARC";
private const string ELLIPTIC_ARC = "ELLIPTIC_ARC";
private const string HYPERBOLIC_ARC = "HYPERBOLIC_ARC";
private const string PARABOLIC_ARC = "PARABOLIC_ARC";
private const string POLYLINE_FORM = "POLYLINE_FORM";
private const string UNSPECIFIED = "UNSPECIFIED";
public StepBSplineCurve( string name, IEnumerable<StepCartesianPoint> controlPoints )
: base( name )
{
ControlPointsList.AddRange( controlPoints );
}
public StepBSplineCurve( string name, params StepCartesianPoint[] controlPoints )
: this( name, ( IEnumerable<StepCartesianPoint> )controlPoints ) { }
public bool ClosedCurve { get; set; }
public bool SelfIntersect { get; set; }
public int Degree { get; set; }
public List<StepCartesianPoint> ControlPointsList { get; } = new List<StepCartesianPoint>();
public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified;
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
return ControlPointsList;
}
protected static string GetCurveFormString( StepBSplineCurveForm form )
{
switch( form )
{
case StepBSplineCurveForm.Polyline:
return POLYLINE_FORM;
case StepBSplineCurveForm.CircularArc:
return CIRCULAR_ARC;
case StepBSplineCurveForm.EllipticalArc:
return ELLIPTIC_ARC;
case StepBSplineCurveForm.ParabolicArc:
return PARABOLIC_ARC;
case StepBSplineCurveForm.HyperbolicArc:
return HYPERBOLIC_ARC;
case StepBSplineCurveForm.Unspecified:
return UNSPECIFIED;
}
throw new NotImplementedException();
}
protected static StepBSplineCurveForm ParseCurveForm( string enumerationValue )
{
switch( enumerationValue.ToUpperInvariant() )
{
case POLYLINE_FORM:
return StepBSplineCurveForm.Polyline;
case CIRCULAR_ARC:
return StepBSplineCurveForm.CircularArc;
case ELLIPTIC_ARC:
return StepBSplineCurveForm.EllipticalArc;
case PARABOLIC_ARC:
return StepBSplineCurveForm.ParabolicArc;
case HYPERBOLIC_ARC:
return StepBSplineCurveForm.HyperbolicArc;
default:
return StepBSplineCurveForm.Unspecified;
}
}
}
}
@@ -1,155 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepBSplineCurveWithKnots.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
{
public enum StepKnotType
{
UniformKnots,
QuasiUniformKnots,
PiecewiseBezierKnots,
Unspecified
}
;
public class StepBSplineCurveWithKnots : StepBSplineCurve
{
private const string PIECEWISE_BEZIER_KNOTS = "PIECEWISE_BEZIER_KNOTS";
private const string QUASI_UNIFORM_KNOTS = "QUASI_UNIFORM_KNOTS";
private const string UNIFORM_KNOTS = "UNIFORM_KNOTS";
private const string UNSPECIFIED = "UNSPECIFIED";
public StepBSplineCurveWithKnots(
string name,
IEnumerable<StepCartesianPoint> controlPoints )
: base( name, controlPoints ) { }
public StepBSplineCurveWithKnots( string name, params StepCartesianPoint[] controlPoints )
: base( name, controlPoints ) { }
public List<int> KnotMultiplicities { get; } = new List<int>();
public List<double> Knots { get; } = new List<double>();
public override StepItemType ItemType => StepItemType.BSplineCurveWithKnots;
public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified;
internal static StepBSplineCurveWithKnots CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 9 );
object controlPointsList = enumerator.Values[ 2 ].GetValueList();
StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots(
string.Empty, new StepCartesianPoint[controlPointsList.Values.Count] );
spline.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
spline.Degree = ( enumerator.Values[ 1 ] as ExpIntNode )!.Value;
for( int i = 0; i < controlPointsList.Values.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
controlPointsList.Values[ j ],
v => spline.ControlPointsList[ j ] = v.AsType<StepCartesianPoint>() );
}
spline.CurveForm = ParseCurveForm( enumerator.Values[ 3 ].GetEnumerationValue() );
spline.ClosedCurve = ( enumerator.Values[ 4 ] as ExpBoolNode )!.Value;
spline.SelfIntersect = ( enumerator.Values[ 5 ]as ExpBoolNode )!.Value;
object knotMultiplicitiesList = enumerator.Values[ 6 ].GetValueList();
spline.KnotMultiplicities.Clear();
for( int i = 0; i < knotMultiplicitiesList.Values.Count; i++ ) {
spline.KnotMultiplicities
.Add( knotMultiplicitiesList.Values[ i ].GetIntegerValue() );
}
object knotslist = enumerator.Values[ 7 ].GetValueList();
spline.Knots.Clear();
for( int i = 0; i < knotslist.Values.Count; i++ ) {
spline.Knots.Add( knotslist.Values[ i ].GetRealVavlue() );
}
spline.KnotSpec = ParseKnotSpec( enumerator.Values[ 8 ].GetEnumerationValue() );
return spline;
}
private static string GetKnotSpec( StepKnotType spec )
{
switch( spec )
{
case StepKnotType.UniformKnots:
return UNIFORM_KNOTS;
case StepKnotType.QuasiUniformKnots:
return QUASI_UNIFORM_KNOTS;
case StepKnotType.PiecewiseBezierKnots:
return PIECEWISE_BEZIER_KNOTS;
case StepKnotType.Unspecified:
return UNSPECIFIED;
}
throw new NotImplementedException();
}
private static StepKnotType ParseKnotSpec( string enumerationValue )
{
switch( enumerationValue.ToUpperInvariant() )
{
case UNIFORM_KNOTS:
return StepKnotType.UniformKnots;
case QUASI_UNIFORM_KNOTS:
return StepKnotType.QuasiUniformKnots;
case PIECEWISE_BEZIER_KNOTS:
return StepKnotType.PiecewiseBezierKnots;
default:
return StepKnotType.Unspecified;
}
}
}
}
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepBoundedCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepBoundedCurve : StepCurve
{
protected StepBoundedCurve( string name ) : base( name ) { }
}
}
@@ -1,54 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepBoundedSurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepBoundedSurface : StepSurface, IExpConvertableFrom<StepBoundedSurface>
{
public StepBoundedSurface( StepModel model ) : base( model ) { }
public override StepItemType ItemType => StepItemType.BoundedSurface;
public void FromInstance( StepBoundedSurface entity )
{
base.FromInstance( entity );
}
}
}
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepBoundedSurfaceCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepBoundedSurfaceCurve : StepBoundedCurve, IExpConvertableFrom<StepBoundedSurfaceCurve, StepSurfaceCurve>
{
public StepBoundedSurfaceCurve( StepModel model ) : base( model ) { }
public StepCurve Parent { get; set; } = null!;
public void FromInstance( StepSurfaceCurve entity )
{
base.FromInstance( entity );
}
public void FromInstance( StepBoundedSurfaceCurve entity )
{
base.FromInstance( entity );
}
}
}
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepCartesianPoint.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public class StepCartesianPoint : StepTriple
{
private StepCartesianPoint() { }
public StepCartesianPoint( string label, float x, float y, float z )
: base( label, x, y, z ) { }
public override StepItemType ItemType => StepItemType.CartesianPoint;
protected override int MinimumValueCount => 1;
internal static StepCartesianPoint CreateFromSyntaxList( ExpNode syntaxList )
{
return ( StepCartesianPoint )AssignTo( new StepCartesianPoint(), syntaxList );
}
}
}
-89
View File
@@ -1,89 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepCircle.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepCircle : StepConic
{
private StepAxis2Placement _position;
private StepCircle() : base( string.Empty ) { }
public StepCircle( string label, StepAxis2Placement position, float radius )
: base( label )
{
Position = position;
Radius = radius;
}
public float Radius { get; set; }
public StepAxis2Placement Position
{
get { return _position; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_position = value;
}
}
public override StepItemType ItemType => StepItemType.Circle;
internal static StepCircle CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepCircle circle = new StepCircle();
enumerator.AssertEnumeratorCount( 3 );
circle.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => circle.Position = v.AsType<StepAxis2Placement>() );
circle.Radius = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value;
return circle;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Position;
}
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepConic.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepConic : StepCurve
{
protected StepConic( string name ) : base( name ) { }
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepCurve : StepGeometricRepresentationItem
{
protected StepCurve( string name ) : base( name ) { }
}
}
@@ -1,70 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepCylindricalSurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepCylindricalSurface : StepElementarySurface
{
private StepCylindricalSurface() : base() { }
public StepCylindricalSurface( string name, StepAxis2Placement3D position, float radius )
: base( name, position )
{
Radius = radius;
}
public float Radius { get; set; }
public override StepItemType ItemType => StepItemType.CylindricalSurface;
internal static StepRepresentationItem CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepCylindricalSurface surface = new StepCylindricalSurface();
surface.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => surface.Position = v.AsType<StepAxis2Placement3D>() );
surface.Radius = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value;
return surface;
}
}
}
@@ -1,55 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDirection.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public class StepDirection : StepTriple
{
private StepDirection() { }
public StepDirection( string name, float x, float y, float z ) : base( name, x, y, z ) { }
public override StepItemType ItemType => StepItemType.Direction;
protected override int MinimumValueCount => 2;
internal static StepDirection CreateFromSyntaxList( ExpNode syntaxList )
{
return ( StepDirection )AssignTo( new StepDirection(), syntaxList );
}
}
}
-68
View File
@@ -1,68 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEdge.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public abstract class StepEdge : StepTopologicalRepresentationItem
{
protected StepEdge() : base( string.Empty ) { }
protected StepEdge( string name, StepVertex edgeStart, StepVertex edgeEnd )
: base( name )
{
EdgeStart = edgeStart;
EdgeEnd = edgeEnd;
}
public StepVertex EdgeStart { get; set; }
public StepVertex EdgeEnd { get; set; }
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
if( EdgeStart != null ) {
yield return EdgeStart;
}
if( EdgeEnd != null ) {
yield return EdgeEnd;
}
}
}
}
-102
View File
@@ -1,102 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEdgeCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepEdgeCurve : StepEdge
{
private StepCurve _edgeGeometry;
private StepEdgeCurve() : base() { }
public StepEdgeCurve(
string name,
StepVertex edgeStart,
StepVertex edgeEnd,
StepCurve edgeGeometry,
bool isSameSense )
: base( name, edgeStart, edgeEnd )
{
EdgeGeometry = edgeGeometry;
IsSameSense = isSameSense;
}
public bool IsSameSense { get; set; }
public StepCurve EdgeGeometry
{
get { return _edgeGeometry; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_edgeGeometry = value;
}
}
public override StepItemType ItemType => StepItemType.EdgeCurve;
internal static StepEdgeCurve CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepEdgeCurve edgeCurve = new StepEdgeCurve();
enumerator.AssertEnumeratorCount( 5 );
edgeCurve.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => edgeCurve.EdgeStart = v.AsType<StepVertex>() );
binder.BindValue(
enumerator.Values[ 2 ], v => edgeCurve.EdgeEnd = v.AsType<StepVertex>() );
binder.BindValue(
enumerator.Values[ 3 ], v => edgeCurve.EdgeGeometry = v.AsType<StepCurve>() );
edgeCurve.IsSameSense = ( enumerator.Values[ 4 ]as ExpBoolNode )!.Value;
return edgeCurve;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeGeometry;
}
}
}
-81
View File
@@ -1,81 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEdgeLoop.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
{
public class StepEdgeLoop : StepLoop
{
public StepEdgeLoop( string name, IEnumerable<StepOrientedEdge> edgeList )
: base( name )
{
EdgeList = new List<StepOrientedEdge>( edgeList );
}
public StepEdgeLoop( string name, params StepOrientedEdge[] edgeList )
: this( name, ( IEnumerable<StepOrientedEdge> )edgeList ) { }
public List<StepOrientedEdge> EdgeList { get; private set; }
public override StepItemType ItemType => StepItemType.EdgeLoop;
internal static StepEdgeLoop CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 2 );
object edgeSyntaxList = enumerator.Values[ 1 ].GetValueList();
StepEdgeLoop edgeLoop = new StepEdgeLoop(
string.Empty, new StepOrientedEdge[edgeSyntaxList.Values.Count] );
edgeLoop.Name = enumerator.Values[ 0 ].GetStringValue();
for( int i = 0; i < edgeSyntaxList.Values.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
edgeSyntaxList.Values[ j ],
v => edgeLoop.EdgeList[ j ] = v.AsType<StepOrientedEdge>() );
}
return edgeLoop;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
return EdgeList;
}
}
}
@@ -1,72 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepElementarySurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public abstract class StepElementarySurface : StepSurface
{
private StepAxis2Placement3D _position;
protected StepElementarySurface() : base( string.Empty ) { }
public StepElementarySurface( string name, StepAxis2Placement3D position )
: base( name )
{
Position = position;
}
public StepAxis2Placement3D Position
{
get { return _position; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_position = value;
}
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Position;
}
}
}
-97
View File
@@ -1,97 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEllipse.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepEllipse : StepConic
{
private StepAxis2Placement _position;
private StepEllipse() : base( string.Empty ) { }
public StepEllipse(
string name,
StepAxis2Placement position,
double semiAxis1,
double semiAxis2 )
: base( name )
{
Position = position;
SemiAxis1 = semiAxis1;
SemiAxis2 = semiAxis2;
}
public double SemiAxis1 { get; set; }
public double SemiAxis2 { get; set; }
public StepAxis2Placement Position
{
get { return _position; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_position = value;
}
}
public override StepItemType ItemType => StepItemType.Ellipse;
internal static StepEllipse CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepEllipse ellipse = new StepEllipse();
enumerator.AssertEnumeratorCount( 4 );
ellipse.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => ellipse.Position = v.AsType<StepAxis2Placement>() );
ellipse.SemiAxis1 = ( enumerator.Values[ 2 ] as ExpRealNumberNode )!.Value;
ellipse.SemiAxis2 = ( enumerator.Values[ 3 ] as ExpRealNumberNode )!.Value;
return ellipse;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Position;
}
}
}
-48
View File
@@ -1,48 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepFace.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
{
public abstract class StepFace : StepTopologicalRepresentationItem
{
public StepFace( string name ) : base( name ) { }
public List<StepFaceBound> Bounds { get; } = new List<StepFaceBound>();
}
}
@@ -1,75 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepFaceBound.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepFaceBound : StepTopologicalRepresentationItem
{
protected StepFaceBound() : base( string.Empty ) { }
public StepFaceBound( string name, StepLoop bound, bool orientation )
: base( name )
{
Bound = bound;
Orientation = orientation;
}
public bool Orientation { get; set; }
public override StepItemType ItemType => StepItemType.FaceBound;
public StepLoop Bound { get; set; }
internal static StepFaceBound CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepFaceBound faceBound = new StepFaceBound();
faceBound.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue( enumerator.Values[ 1 ], v => faceBound.Bound = v.AsType<StepLoop>() );
faceBound.Orientation = ( enumerator.Values[ 2 ]as ExpBoolNode )!.Value;
return faceBound;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Bound;
}
}
}
@@ -1,63 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepFaceOuterBound.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public class StepFaceOuterBound : StepFaceBound
{
private StepFaceOuterBound() : base() { }
public StepFaceOuterBound( string name, StepLoop bound, bool orientation )
: base( name, bound, orientation ) { }
public override StepItemType ItemType => StepItemType.FaceOuterBound;
internal static new StepFaceOuterBound CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepFaceOuterBound faceOuterBound = new StepFaceOuterBound();
faceOuterBound.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => faceOuterBound.Bound = v.AsType<StepLoop>() );
faceOuterBound.Orientation = ( enumerator.Values[ 2 ]as ExpBoolNode )!.Value;
return faceOuterBound;
}
}
}
@@ -1,50 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepFaceSurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public abstract class StepFaceSurface : StepFace
{
public StepFaceSurface( string name ) : base( name ) { }
public bool SameSense { get; set; }
public StepSurface FaceGeometry { get; set; }
}
}
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepGeometricRepresentationItem.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepGeometricRepresentationItem : StepRepresentationItem
{
protected StepGeometricRepresentationItem( string name ) : base( name ) { }
}
}
-131
View File
@@ -1,131 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepItemType.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Modeling.Items
{
public enum StepItemType
{
AdvancedFace,
AxisPlacement2D,
AxisPlacement3D,
BSplineCurveWithKnots,
CartesianPoint,
Circle,
CylindricalSurface,
Direction,
EdgeCurve,
EdgeLoop,
Ellipse,
FaceBound,
FaceOuterBound,
Line,
OrientedEdge,
Plane,
Vector,
VertexPoint
}
internal static class StepItemTypeExtensions
{
public const string AdvancedFaceText = "ADVANCED_FACE";
public const string Axis2Placement2DText = "AXIS2_PLACEMENT_2D";
public const string Axis2Placement3DText = "AXIS2_PLACEMENT_3D";
public const string BSplineCurveWithKnotsText = "B_SPLINE_CURVE_WITH_KNOTS";
public const string CartesianPointText = "CARTESIAN_POINT";
public const string CircleText = "CIRCLE";
public const string CylindricalSurfaceText = "CYLINDRICAL_SURFACE";
public const string DirectionText = "DIRECTION";
public const string EdgeCurveText = "EDGE_CURVE";
public const string EdgeLoopText = "EDGE_LOOP";
public const string EllipseText = "ELLIPSE";
public const string FaceBoundText = "FACE_BOUND";
public const string FaceOuterBoundText = "FACE_OUTER_BOUND";
public const string LineText = "LINE";
public const string OrientedEdgeText = "ORIENTED_EDGE";
public const string PlaneText = "PLANE";
public const string VectorText = "VECTOR";
public const string VertexPointText = "VERTEX_POINT";
public static string GetItemTypeString( this StepItemType type )
{
switch( type )
{
case StepItemType.AdvancedFace:
return AdvancedFaceText;
case StepItemType.AxisPlacement2D:
return Axis2Placement2DText;
case StepItemType.AxisPlacement3D:
return Axis2Placement3DText;
case StepItemType.BSplineCurveWithKnots:
return BSplineCurveWithKnotsText;
case StepItemType.CartesianPoint:
return CartesianPointText;
case StepItemType.Circle:
return CircleText;
case StepItemType.CylindricalSurface:
return CylindricalSurfaceText;
case StepItemType.Direction:
return DirectionText;
case StepItemType.EdgeCurve:
return EdgeCurveText;
case StepItemType.EdgeLoop:
return EdgeLoopText;
case StepItemType.Ellipse:
return EllipseText;
case StepItemType.FaceBound:
return FaceBoundText;
case StepItemType.FaceOuterBound:
return FaceOuterBoundText;
case StepItemType.Line:
return LineText;
case StepItemType.OrientedEdge:
return OrientedEdgeText;
case StepItemType.Plane:
return PlaneText;
case StepItemType.Vector:
return VectorText;
case StepItemType.VertexPoint:
return VertexPointText;
default:
throw new InvalidOperationException( $"Unexpected item type {type}" );
}
}
}
}
-124
View File
@@ -1,124 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepLine.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepLine : StepCurve
{
private StepCartesianPoint _point;
private StepVector _vector;
private StepLine() : base( string.Empty ) { }
public StepLine( string label, StepCartesianPoint point, StepVector vector )
: base( label )
{
Point = point;
Vector = vector;
}
public StepCartesianPoint Point
{
get { return _point; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_point = value;
}
}
public override StepItemType ItemType => StepItemType.Line;
public StepVector Vector
{
get { return _vector; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_vector = value;
}
}
public static StepLine FromPoints(
float x1,
float y1,
float z1,
float x2,
float y2,
float z2 )
{
StepCartesianPoint start = new StepCartesianPoint( string.Empty, x1, y1, z1 );
float dx = x2 - x1;
float dy = y2 - y1;
float dz = z2 - z1;
float length = Scaler.Sqrt( dx * dx + dy * dy + dz * dz );
float dxn = dx / length;
float dyn = dy / length;
float dzn = dz / length;
StepVector vector = new StepVector(
string.Empty, new StepDirection( string.Empty, dxn, dyn, dzn ), length );
return new StepLine( string.Empty, start, vector );
}
internal static StepLine CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepLine line = new StepLine();
enumerator.AssertEnumeratorCount( 3 );
line.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => line.Point = v.AsType<StepCartesianPoint>() );
binder.BindValue( enumerator.Values[ 2 ], v => line.Vector = v.AsType<StepVector>() );
return line;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Point;
yield return Vector;
}
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepLoop.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepLoop : StepTopologicalRepresentationItem
{
public StepLoop( string name ) : base( name ) { }
}
}
@@ -1,104 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepOrientedEdge.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepOrientedEdge : StepEdge
{
private StepEdge _edgeElement;
private StepOrientedEdge() { }
public StepOrientedEdge(
string name,
StepVertex edgeStart,
StepVertex edgeEnd,
StepEdge edgeElement,
bool orientation )
: base( name, edgeStart, edgeEnd )
{
EdgeElement = edgeElement;
Orientation = orientation;
}
public bool Orientation { get; set; }
public StepEdge EdgeElement
{
get { return _edgeElement; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_edgeElement = value;
}
}
public override StepItemType ItemType => StepItemType.OrientedEdge;
internal static StepOrientedEdge CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepOrientedEdge orientedEdge = new StepOrientedEdge();
enumerator.AssertEnumeratorCount( 5 );
orientedEdge.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => orientedEdge.EdgeStart = v.AsType<StepVertex>() );
binder.BindValue(
enumerator.Values[ 2 ], v => orientedEdge.EdgeEnd = v.AsType<StepVertex>() );
binder.BindValue(
enumerator.Values[ 3 ], v => orientedEdge.EdgeElement = v.AsType<StepEdge>() );
orientedEdge.Orientation = ( enumerator.Values[ 4 ]as ExpBoolNode )!.Value;
return orientedEdge;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeElement;
}
}
}
@@ -1,52 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepPcurveOrSurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step.Items
{
public class StepPCurveOrSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepPCurveOrSurface>
{
public StepPCurveOrSurface( StepModel model ) : base( model ) { }
public void FromInstance( StepPCurveOrSurface entity )
{
base.FromInstance( entity );
}
}
}
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepPlacement.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepPlacement : StepGeometricRepresentationItem
{
protected StepPlacement( string name ) : base( name ) { }
}
}
-59
View File
@@ -1,59 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepPlane.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public class StepPlane : StepElementarySurface
{
private StepPlane() : base() { }
public StepPlane( string name, StepAxis2Placement3D position ) : base( name, position ) { }
public override StepItemType ItemType => StepItemType.Plane;
internal static StepPlane CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepPlane plane = new StepPlane();
enumerator.AssertEnumeratorCount( 2 );
plane.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => plane.Position = v.AsType<StepAxis2Placement3D>() );
return plane;
}
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepPoint.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepPoint : StepGeometricRepresentationItem
{
protected StepPoint( string name ) : base( name ) { }
}
}
@@ -1,58 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepRepresentationItem.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public abstract partial class StepRepresentationItem
{
protected StepRepresentationItem( string name )
{
Name = name;
}
public abstract StepItemType ItemType { get; }
public string Name { get; set; }
internal virtual IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield break;
}
}
}
@@ -1,127 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepRepresentationItem_FromTypedParameter.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Diagnostics;
namespace StgSharp.Modeling.Items
{
public abstract partial class StepRepresentationItem
{
internal static HashSet<string> UnsupportedItemTypes { get; } = new HashSet<string>();
internal static StepRepresentationItem FromTypedParameter(
StepBinder binder,
ExpNode itemSyntax )
{
StepRepresentationItem item = null!;
if( itemSyntax is ExpElementInitializingNode initNode )
{
string name = initNode.EqualityTypeConvert.Name;
switch( name )
{
case StepItemTypeExtensions.AdvancedFaceText:
item = StepAdvancedFace.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.Axis2Placement2DText:
item = StepAxis2Placement2D.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.Axis2Placement3DText:
item = StepAxis2Placement3D.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.BSplineCurveWithKnotsText:
item = StepBSplineCurveWithKnots.CreateFromSyntaxList(
binder, initNode.Right );
break;
case StepItemTypeExtensions.CartesianPointText:
item = StepCartesianPoint.CreateFromSyntaxList( initNode.Right );
break;
case StepItemTypeExtensions.CircleText:
item = StepCircle.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.CylindricalSurfaceText:
item = StepCylindricalSurface.CreateFromSyntaxList( binder,
initNode.Right );
break;
case StepItemTypeExtensions.DirectionText:
item = StepDirection.CreateFromSyntaxList( initNode.Right );
break;
case StepItemTypeExtensions.EdgeCurveText:
item = StepEdgeCurve.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.EdgeLoopText:
item = StepEdgeLoop.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.EllipseText:
item = StepEllipse.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.FaceBoundText:
item = StepFaceBound.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.FaceOuterBoundText:
item = StepFaceOuterBound.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.LineText:
item = StepLine.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.OrientedEdgeText:
item = StepOrientedEdge.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.PlaneText:
item = StepPlane.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.VectorText:
item = StepVector.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.VertexPointText:
item = StepVertexPoint.CreateFromSyntaxList( binder, initNode.Right );
break;
default:
if( UnsupportedItemTypes.Add( name ) ) {
Debug.WriteLine(
$"Unsupported item {name} at {initNode.Line}, {initNode.Column}" );
}
break;
}
} else
{
// TODO:
}
return item;
}
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepSurface.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepSurface : StepGeometricRepresentationItem
{
public StepSurface( string name ) : base( name ) { }
}
}
@@ -1,54 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepSurfaceCurve.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepSurfaceCurve : StepCurve, IExpConvertableFrom<StepSurfaceCurve>
{
public StepSurfaceCurve( StepModel model ) : base( model ) { }
public StepCurve Curve3D { get; set; }
public void FromInstance( StepSurfaceCurve entity )
{
throw new NotImplementedException();
}
}
}
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepTopologicalRepresentationItem.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepTopologicalRepresentationItem : StepRepresentationItem
{
protected StepTopologicalRepresentationItem( string name ) : base( name ) { }
}
}
-128
View File
@@ -1,128 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepTriple.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public abstract class StepTriple : StepPoint
{
private Vec3 _coord;
protected StepTriple() : this( string.Empty, 0.0f, 0.0f, 0.0f ) { }
protected StepTriple( string name, float x, float y, float z )
: base( name )
{
X = x;
Y = y;
Z = z;
}
public float X
{
get => _coord.X;
set => _coord.X = value;
}
public float Y
{
get => _coord.Y;
set => _coord.Y = value;
}
public float Z
{
get => _coord.Z;
set => _coord.Z = value;
}
protected abstract int MinimumValueCount { get; }
public bool Equals( StepTriple other )
{
if( ( object )other == null ) {
return false;
}
return ItemType == other.ItemType && X == other.X && Y == other.Y && Z == other.Z && Name ==
other.Name;
}
public override bool Equals( object obj )
{
return ( obj is StepTriple triple ) && Equals( triple );
}
public override int GetHashCode()
{
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
internal static StepTriple AssignTo( StepTriple triple, ExpNode values )
{
ExpNodeNextEnumerator enumerator = values.GetEnumerator();
enumerator.AssertEnumeratorCount( 2 );
triple.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
object pointValues = enumerator.Values[ 1 ].GetValueList();
pointValues.AssertEnumeratorCount( triple.MinimumValueCount, 3 );
triple.X = pointValues.GetRealValueOrDefault( 0 );
triple.Y = pointValues.GetRealValueOrDefault( 1 );
triple.Z = pointValues.GetRealValueOrDefault( 2 );
return triple;
}
public static bool operator !=( StepTriple left, StepTriple right )
{
return !( left == right );
}
public static bool operator ==( StepTriple left, StepTriple right )
{
if( ReferenceEquals( left, right ) ) {
return true;
}
if( ( object )left == null || ( object )right == null ) {
return false;
}
return left.Equals( right );
}
}
}
-89
View File
@@ -1,89 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepVector.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepVector : StepGeometricRepresentationItem
{
private StepDirection _direction;
private StepVector() : base( string.Empty ) { }
public StepVector( string name, StepDirection direction, double length )
: base( name )
{
Direction = direction;
Length = length;
}
public double Length { get; set; }
public StepDirection Direction
{
get { return _direction; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_direction = value;
}
}
public override StepItemType ItemType => StepItemType.Vector;
internal static StepVector CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepVector vector = new StepVector();
enumerator.AssertEnumeratorCount( 3 );
vector.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => vector.Direction = v.AsType<StepDirection>() );
vector.Length = ( enumerator.Values[ 2 ]as ExpRealNumberNode )!.Value;
return vector;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Direction;
}
}
}
-43
View File
@@ -1,43 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepVertex.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
{
public abstract class StepVertex : StepTopologicalRepresentationItem
{
protected StepVertex( string name ) : base( name ) { }
}
}
@@ -1,87 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepVertexPoint.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
{
public class StepVertexPoint : StepVertex
{
private StepCartesianPoint _location;
private StepVertexPoint() : base( string.Empty ) { }
public StepVertexPoint( string name, StepCartesianPoint location )
: base( name )
{
Location = location;
}
public StepCartesianPoint Location
{
get { return _location; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
_location = value;
}
}
public override StepItemType ItemType => StepItemType.VertexPoint;
internal static StepVertexPoint CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepVertexPoint vertex = new StepVertexPoint();
enumerator.AssertEnumeratorCount( 2 );
vertex.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => vertex.Location = v.AsType<StepCartesianPoint>() );
return vertex;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Location;
}
}
}
@@ -1,290 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpSyntaxAnalyzer.Common.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 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.Threading.Tasks;
using System.Xml.Schema;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Modeling.Step
{
public partial class StepExpSyntaxAnalyzer
{
private bool IsSeparatorMatch( Token leftSperator, Token rightSeparator )
{
return leftSperator.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 ExpNode? 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 ExpNode? expNode );
if( !_cache.PopOperand( out Token colleToken, out ExpNode? 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 );
ExpNode node = ConvertAndPushOneOperator( op );
}
switch( _cache.OperandAheadOfDepth )
{
case 0:
if( t.Value == ";" ) {
return true;
}
_cache.StatementsInDepth.Push( ExpNode.Empty );
goto case 1;
case 1:
_cache.PopOperand( out _, out ExpNode? statement );
_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();
ExpNode node = ConvertAndPushOneOperator( tmp );
goto processPrecedence;
}
}
_cache.PushOperator( t );
return true;
}
private bool TryParseConstant( Token t )
{
switch( t.Value )
{
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( ExpKeyword.BuiltinFunctions.Contains( t.Value ) )
{
_cache.PushOperator( t );
return true;
} else if( _context.TryGetFunction( t.Value, out ExpFunctionSource? f ) )
{
_cache.PushOperand( t );
return true;
}
return false;
}
private bool TryParseInstance( Token t )
{
if( _local.TryGetMember( t.Value,
out ExpNode? node ) && node is ExpElementInstance instance )
{
_cache.PushOperand( ExpInstanceReferenceNode.MakeReferenceFrom( t, instance ) );
return true;
} else if( _cache.IsLastAddedOperator )
{
if( _cache.PeekOperand( out _,
out ExpNode? typenode ) && typenode is ExpMetaRefNode typeRef )
{
_cache.PopOperand( out _, out _ );
_local.AddMember( t.Value, typeRef.SourceRef.CreateInstanceNode( t ) );
} else
{
return false;
}
}
return false;
}
private bool TryParseKeyword( Token t )
{
switch( t.Value )
{
case ExpKeyword.Return:
_cache.PushOperator( t );
return true;
case ExpKeyword.Skip:
_cache.PushOperand( ExpProcedureControlNode.Skip( t ) );
return true;
default:
return false;
}
}
}
}
@@ -1,56 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess.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.Modeling.Step
{
public partial class StepExpSyntaxAnalyzer
{
public void ThrowCompileException( int errorCode )
{
switch( errorCode )
{
case 0 or 1:
return;
case TokenTypeNotMatch:
throw new Exception();
default:
break;
}
}
}
}
@@ -1,184 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Modeling.Step
{
public 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 ExpNode node )
{
ExpNode 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 = ExpNode.Empty;
return false;
}
}
/// <summary>
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS.
/// </summary>
private ExpNode ConvertAndPushOneOperator( Token op )
{
switch( op.Flag )
{
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode( op, out ExpNode? node );
_cache.PushOperand( node );
return node;
case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode( op, out node );
_cache.PushOperand( node );
return node;
case TokenFlag.Member:
if( _context.TryGetFunction( op.Value, out ExpFunctionSource? f ) )
{
if( !_cache.PopOperand( out Token t, out ExpNode? p ) )
{
node = ExpFunctionCallingNode.CallFunction( op, f, p );
return node;
} else
{
throw new ExpCompileException(
t,
"An ExpNode for function calling is needed, but a token was popped" );
}
} else if( _context.TryGetProcedure( op.Value, out ExpProcedureSource? p ) )
{
if( !_cache.PopOperand( out Token t, out ExpNode? param ) )
{
node = ExpProcedureCallingNode.CallProcedure( op, p, param );
return node;
} else
{
throw new ExpCompileException(
t,
"An ExpNode for function calling is needed, but a token was popped" );
}
} else if( ExpSchema.BuiltinSchema.TryGetFunction( op.Value, out f ) )
{
if( !_cache.PopOperand( out Token t, out ExpNode? param ) )
{
node = ExpFunctionCallingNode.CallFunction( op, f, param );
return node;
} else
{
throw new ExpCompileException(
t,
"An ExpNode for function calling is needed, but a token was popped" );
}
} else
{
throw new NotImplementedException();
//uncertain case here
}
default:
throw new NotImplementedException();
}
}
private bool TryGenerateBinaryNode( Token t, out ExpNode node )
{
ExpNode right = GetNextOperandCache();
ExpNode left = GetNextOperandCache();
switch( t.Value )
{
case ExpKeyword.Add:
node = ExpBinaryOperatorNode.Add( t, left, right );
return true;
case ExpKeyword.Sub:
node = ExpBinaryOperatorNode.Sub( t, left, right );
return true;
case ExpKeyword.Mul:
node = ExpBinaryOperatorNode.Mul( t, left, right );
return true;
case ExpKeyword.Div:
node = ExpBinaryOperatorNode.Div( t, left, right );
return true;
case ExpKeyword.Equal:
node = ExpBinaryOperatorNode.EqualTo( t, left, right );
return true;
case ExpKeyword.NotEqual:
node = ExpBinaryOperatorNode.NotEqualTo( t, left, right );
return true;
case ExpKeyword.GreaterThan:
node = ExpBinaryOperatorNode.GreaterThan( t, left, right );
return true;
case ExpKeyword.LessThan:
node = ExpBinaryOperatorNode.LessThan( t, left, right );
return true;
case ExpKeyword.Assignment:
node = ExpBinaryOperatorNode.Assign( t, left, right );
return true;
case ExpKeyword.InstanceEqual:
node = ExpBinaryOperatorNode.CompareInstanceEqual( t, left, right );
return true;
case ExpKeyword.InstanceNotEqual:
node = ExpBinaryOperatorNode.CompareInstanceNotEqual( t, left, right );
return true;
default:
node = ExpNode.Empty;
return false;
}
}
}
}
@@ -1,85 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpSyntaxAnalyzer.PrefixReverseAnalysing.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Modeling.Step
{
public partial class StepExpSyntaxAnalyzer
{
private void ClosePrefixReverse( Token rightSeparator )
{
Token op;
ExpNode root;
if( _cache.OperatorAheadOfDepth == 0 )
{
if( _cache.OperandAheadOfDepth == 1 )
{
_cache.PopOperand( out _, out ExpNode? statement );
_cache.StatementsInDepth.Push( statement );
} else
{
ExpInvalidSyntaxException.ThrowNoOperator( rightSeparator );
}
} else
{
while( _cache.TryPopOperator( out op ) ) {
ConvertAndPushOneOperator( op );
}
_cache.PopOperand( out _, out root );
_cache.StatementsInDepth.Push( root );
}
root = _cache.PackAllStatements();
_cache.DecreaseDepth();
if( IsSeparatorMatch( _cache.PeekOperator(), rightSeparator ) )
{
_cache.PopOperator();
_cache.PushOperand( root );
} else
{
throw new ExpCompileException(
rightSeparator, "Ending of block does not match its begging" );
}
}
}
}
@@ -1,145 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpSyntaxAnalyzer.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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
using StgSharp.Script.Express;
using StgSharp.Threading;
using System;
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.Modeling.Step
{
public partial class StepExpSyntaxAnalyzer : ISyntaxAnalyzer
{
private const int EndLine = 1;
private const int TokenGenerated = 0;
private const int TokenTypeNotMatch = -1;
private CompileStack<ExpNode, IExpElementSource> _cache;
private ExpNode _lastStatement;
private ExpSchema _context;
private IExpElementSource _local;
public StepExpSyntaxAnalyzer()
{
_cache = new CompileStack<ExpNode, IExpElementSource>();
}
public StepExpSyntaxAnalyzer( ExpSchema context, IExpElementSource local )
{
_cache = new CompileStack<ExpNode, IExpElementSource>();
ArgumentNullException.ThrowIfNull( context );
if( context is not ExpSchema_Builtin )
{
_context = context;
} else
{
throw new InvalidCastException( "Not a valid Schema type" );
}
_local = local;
}
/// <summary>
/// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators.
/// </summary>
public void AppendToken( Token expToken )
{
switch( expToken.Flag )
{
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol( expToken );
break;
case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral( expToken );
_cache.PushOperand( node );
break;
case TokenFlag.Separator_Left:
TryAppendPrefixSeparator( expToken );
break;
case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd( expToken );
break;
case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator( expToken );
break;
case TokenFlag.Index_Left:
TryAppendIndexLeft( expToken );
break;
case TokenFlag.Index_Right:
TryAppendIndexRight( expToken );
break;
case TokenFlag.Member:
TryAppendMember( expToken );
break;
default:
break;
}
}
public ExpNode GetNextOperandCache()
{
if( _cache.PopOperand( out Token t, out ExpNode? n ) )
{
return n;
} else
{
// process some rare case here
}
throw new NotImplementedException();
}
public enum ExpCompileStateCode
{
Common,
ForLoop,
RepeatLoop,
UntilLoop,
IfBranch,
CaseBranch,
CollectionIndex,
}
}
}
@@ -1,90 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataReader.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.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.Modeling.STEP
{
public partial class StepReader
{
private Regex expressionSpilitter = GetExpressionSplitter();
private ThreadLocal<ConcurrentQueue<StepCodeLine>> _codeLineQueue
= new ThreadLocal<ConcurrentQueue<StepCodeLine>>();
public ConcurrentQueue<StepCodeLine> DataSectionPool
{
get => _codeLineQueue.Value;
}
public void ReadDataSection()
{
if( _codeLineQueue.Value == null ) {
_codeLineQueue.Value = new ConcurrentQueue<StepCodeLine>();
}
using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read ) )
{
using( StreamReader sr = new StreamReader( ms ) )
{
long pos = _headStart;
string line;
while( string.IsNullOrEmpty( line = sr.ReadLine()! ) )
{
Match match = expressionSpilitter.Match( line );
if( match.Success )
{
int id = int.Parse( match.Groups[ "id" ].Value );
string expression = match.Groups[ "expression" ].Value;
StepCodeLine stepExpression = new StepCodeLine( id, expression );
_codeLineQueue.Value.Enqueue( stepExpression );
}
}
}
}
}
[GeneratedRegex(
@"^#(?<id>[0-9]+)\s*?=\s*?(?<expression>\S.*?)\s*;$",
RegexOptions.Compiled | RegexOptions.Singleline )]
private static partial Regex GetExpressionSplitter();
}
}
@@ -1,143 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataSectionTokenReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.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.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepDataSectionTokenReader : IScriptTokenReader
{
private ExpSourceReader _reader;
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataSectionTokenReader( StepDataSectionTransmitter transmitter )
{
_reader = new ExpSourceReader( transmitter );
_transmitter = transmitter;
}
public Token ReadToken()
{
if( _cache.Count == 0 )
{
if( _reader.TryReadToken( out Token token0 ) && ( token0.Value != "." ) ) {
return token0;
}
if( _reader.TryReadToken( out Token token1 ) && ( token1.Value != "T" || token1.Value !=
"F" ) )
{
_cache.Enqueue( token1 );
return token0;
}
if( _reader.TryReadToken( out Token token2 ) && ( token2.Value != "." ) )
{
_cache.Enqueue( token1 );
_cache.Enqueue( token2 );
return token0;
}
switch( token1.Value )
{
case "T":
return new Token( ".T.", token0.Line, token1.Column, TokenFlag.Member );
case "F":
return new Token( ".F.", token0.Line, token1.Column, TokenFlag.Member );
default:
break;
}
}
return _cache.Dequeue();
}
public bool TryReadToken( out Token t )
{
if( _cache.Count == 0 )
{
if( _reader.TryReadToken( out Token token0 ) )
{
if( token0.Value != "." )
{
t = token0;
return true;
}
} else
{
t = Token.Empty;
return false;
}
if( _reader.TryReadToken( out Token token1 ) )
{
if( token1.Value != "T" || token1.Value != "F" )
{
_cache.Enqueue( token1 );
t = token0;
return true;
}
} else
{
t = Token.Empty;
return false;
}
if( _reader.TryReadToken( out Token token2 ) )
{
if( token2.Value != "." )
{
_cache.Enqueue( token1 );
_cache.Enqueue( token2 );
t = token0;
return true;
}
} else
{
t = Token.Empty;
return false;
}
t = token1.Value switch
{
"T" => new Token( ".T.", token0.Line, token1.Column, TokenFlag.Member ),
"F" => new Token( ".F.", token0.Line, token1.Column, TokenFlag.Member ),
_ => Token.Empty
};
}
return _reader.TryReadToken( out t );
}
}
}
@@ -1,95 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataSectionsTranmitter.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepDataSectionTransmitter : IScriptSourceProvider
{
private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0;
public bool IsEmpty => _isEmpty;
public int Location => _line;
public void EndWriting()
{
_cache.Enqueue( "END_DATA" );
}
public string ReadLine()
{
_cache.TryDequeue( out string? line );
while( !IsEmpty )
{
if( _cache.TryDequeue( out line ) )
{
if( line == "END_DATA" )
{
_isEmpty = true;
return string.Empty;
}
_line++;
return line;
}
}
return string.Empty;
}
public string ReadLine( out int position )
{
string ret = ReadLine();
position = _line;
return ret;
}
public void WriteLine( string line )
{
_cache.Enqueue( line );
}
IScriptSourceProvider IScriptSourceProvider.Slice( int location, int count )
{
throw new NotSupportedException();
}
}
}
@@ -1,112 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataTokenReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.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.Modeling.Step
{
public class StepDataTokenReader : IScriptTokenReader
{
private ExpTokenReader _reader;
private HashSet<string> token1Hash = [
"T","F","UNSPECIFIED"
];
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader( StepDataSectionTransmitter transmitter )
{
_reader = new ExpTokenReader( transmitter );
_reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter;
}
public Token ReadToken()
{
return _reader.ReadToken();
}
public bool TryReadToken( out Token t )
{
return _reader.TryReadToken( out t );
}
private class TokenPreReader : ExpTokenReaderPreProcessor
{
private static Regex NextEnumPattern = GetNextEnumPattern();
public override bool Process( string codeLine, int line, ref int current, out Token t )
{
ReadOnlySpan<char> chars = codeLine.AsSpan( current );
char c = chars[ 0 ];
if( c != '.' )
{
t = Token.Empty;
return false;
}
Match match = NextEnumPattern.Match( codeLine, current );
if( match.Success )
{
int begin = match.Groups[ "begin" ].Index;
int end = match.Groups[ "end" ].Length;
int rest = match.Groups[ "rets" ].Length;
current = rest;
t = new Token( match.Groups[ "begin" ].Value, line, begin, TokenFlag.Enum );
return true;
} else
{
t = Token.Empty;
return false;
}
}
[GeneratedRegex(
@"(?<begin>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)",
RegexOptions.Singleline )]
private static extern Regex GetNextEnumPattern();
}
}
}
@@ -1,57 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpressParser.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
using StgSharp.Script;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepExpressSyntaxParser : ISyntaxAnalyzer
{
private StepExpSyntaxAnalyzer _analyzer;
public StepExpressSyntaxParser()
{
_analyzer = new StepExpSyntaxAnalyzer();
}
public void AppendToken( Token t )
{
}
}
}
@@ -1,112 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepHeadReader.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.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Modeling.STEP
{
public partial class StepReader
{
/**/
private static Regex expressionSplitter = new Regex(
@"^(?<CALLER>[A-Z_]+)\s?\((?<PARAM>.+)\)\;",
RegexOptions.Compiled );
public StepInfo GetInfo()
{
StepInfo info = new StepInfo();
List<StepObjectConstructor> constructorList = new List<StepObjectConstructor>();
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 StepObjectConstructor(
0, match[ "CALLER" ].ToString(),
match[ "PARAM" ].ToString() ) );
}
foreach( StepObjectConstructor 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;
}
/**/
}
}
-158
View File
@@ -1,158 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace StgSharp.Modeling.STEP
{
public partial class StepReader : IDisposable
{
private const string fileLabel = "ISO-10303-21;";
private bool disposedValue;
private FileStream _fileStream;
private long _headStart = -1, _headEnd = -1, _dataStart = -1, _size;
private MemoryMappedFile _memoryFile;
private StepReader() { }
private StepReader( FileStream stream, long size )
{
_fileStream = stream;
_size = size;
_memoryFile = MemoryMappedFile.CreateFromFile(
stream, mapName: null, size, MemoryMappedFileAccess.Read,
HandleInheritability.None, leaveOpen: true );
}
// ~StepReader()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose( disposing: true );
GC.SuppressFinalize( this );
}
public static bool FromFile( string path, out StepReader reader )
{
FileInfo info = new FileInfo( path );
if( !info.Exists ) {
reader = null!;
return false;
}
FileStream stream = new FileStream(
path, FileMode.Open, FileAccess.Read, FileShare.Read,
bufferSize: 4096, useAsync: true );
byte[] fileHead = new byte[40];
stream.Read( fileHead, 0, fileLabel.Length );
if( !Encoding.UTF8.GetString( fileHead ).Contains( fileLabel ) ) {
throw new InvalidDataException(
"The given file is not a STEP file" );
}
reader = new StepReader( stream, info.Length );
reader.LocateSection();
return reader != null;
}
private void LocateSection()
{
long startPos = 0;
byte[] buffer = new byte[1024];
Span<byte> bufferSpan = buffer,
headerSec = Encoding.UTF8.GetBytes( "HEADER;" ),
endsecSec = Encoding.UTF8.GetBytes( "ENDSEC;" ),
dataSec = Encoding.UTF8.GetBytes( "DATA;" );
_fileStream.Position = 0;
for( ; startPos < _size; startPos += 1000 ) {
_fileStream.Read( buffer );
if( _headStart == -1 ) {
long pos = bufferSpan.IndexOf( headerSec );
if( pos >= 0 ) {
_headStart = startPos + pos;
}
}
if( _headEnd == -1 ) {
long pos = bufferSpan.IndexOf( endsecSec );
if( pos >= 0 ) {
_headEnd = startPos + pos;
}
}
if( _dataStart == -1 ) {
long pos = bufferSpan.IndexOf( dataSec );
if( pos >= 0 ) {
_dataStart = startPos + pos;
}
} else {
break;
}
_fileStream.Seek( 1000, SeekOrigin.Current );
}
}
private string ReadToken( StreamReader reader, ref long posCache )
{
StringBuilder token = new StringBuilder( 100 );
while( token.Length == 0 || token[ token.Length - 1 ] != ';' ) {
string subString = reader.ReadLine();
if( subString == null ) {
break;
}
token.Append( subString.TrimStart() );
}
posCache += token.Length;
return token.ToString();
}
private protected virtual void Dispose( bool disposing )
{
if( !disposedValue ) {
if( disposing ) {
_fileStream.Dispose();
_memoryFile.Dispose();
}
disposedValue = true;
}
}
}
}
-94
View File
@@ -1,94 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataParser.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace StgSharp.Modeling.STEP
{
public static class StepDataParser
{
private static Regex _stringParser = new Regex(
@"(\(\s?'|')\s*(?<value>.+)\s*('\s*\)|')", RegexOptions.Compiled );
private static Regex _vectorParser = new Regex(
@"^\(\s+(?<x>-?[0-9]+\.[0-9]+),\s+(?<y>-?[0-9]+\.[0-9]+),\s+(?<z>-?[0-9]+\.[0-9]+)\s+\)$",
RegexOptions.Compiled );
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( string source )
{
Match match = _vectorParser.Match( source );
if( match.Success ) {
return new Vec3(
float.Parse( match.Groups[ "x" ].Value ),
float.Parse( match.Groups[ "y" ].Value ),
float.Parse( match.Groups[ "z" ].Value ) );
}
return Vec3.Zero;
}
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);
}
}
}
-65
View File
@@ -1,65 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityBase.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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Math;
using StgSharp.Modeling.Step;
using StgSharp.PipeLine;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace StgSharp.Modeling.Step
{
public abstract class StepEntityBase : IExpMarshalType<StepUninitializedEntity>
{
protected StepEntityBase( string name )
{
Name = name;
}
public int Id { get; protected set; }
public abstract StepItemType ItemType { get; }
public string Name { get; protected set; }
public static StepUninitializedEntity Create( string name, ExpSyntaxNode node )
{
return new StepUninitializedEntity( name, 0 );
}
}
}
-61
View File
@@ -1,61 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityLabel.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.PipeLine;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public record class StepEntityLabel : PipelineNodeLabel
{
public StepEntityLabel( int id )
{
Id = id;
}
public int Id { get; init; }
public override int ComputeHashCode()
{
return Id;
}
public override string ToString()
{
return $"StepEntityLabel: {Id}";
}
}
}
@@ -1,40 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityUnsupportedException.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.Model.Step
{
internal class StepEntityUnsupportedException : Exception { }
}
-227
View File
@@ -1,227 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="STEPHeader.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.Text;
namespace StgSharp.Modeling.Step
{
/// <summary>
/// C# implementation of HEADER part in STEP file.
/// </summary>
public struct StepInfo
{
private STEPFileDescriptor _header;
private STEPFileName _name;
private STEPSchema _schema;
public (int mainLevel, int? subLevel) Level
{
get => _header.Level;
internal set => _header.Level = value;
}
public DateTime TimeStamp
{
get => _name.TimeStamp;
internal set => _name.TimeStamp = value;
}
public STEPFileDescriptor Descriptor
{
get => _header;
internal set => _header = value;
}
public STEPFileName FileName
{
get => _name;
internal set => _name = value;
}
public STEPSchema Schema
{
get => _schema;
internal set => _schema = value;
}
public string Description
{
get => _header.Description;
internal set => _header.Description = value;
}
public string Name
{
get => _name.Name;
internal set => _name.Name = value;
}
public string Author
{
get => _name.Author;
internal set => _name.Author = value;
}
public string Organization
{
get => _name.Organization;
internal set => _name.Organization = value;
}
public string OriginatingSystem
{
get => _name.OriginatingSystem;
internal set => _name.OriginatingSystem = value;
}
public string Authorization
{
get => _name.Authorization;
internal set => _name.Authorization = value;
}
public string PreprocessorVersion
{
get => _name.PreprocessorVersion;
internal set => _name.PreprocessorVersion = value;
}
public string Version
{
get => _name.Version;
internal set => _name.Version = value;
}
public string SchemaString
{
get => _schema.Data;
internal set => _schema.Data = value;
}
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public struct 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 struct STEPSchema
{
private List<string> _schema;
public string Data
{
get;
internal set;
}
}
/// <summary>
/// C# implementation of FILE_NAME part in header of STEP file.
/// </summary>
public struct STEPFileDescriptor
{
public (int mainLevel,int? subLevel) Level
{
get;
internal set;
}
public string Description
{
get;
internal set;
}
}
}
@@ -1,101 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepHeaderLineConstructor.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.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepHeaderLineConstructor
{
private static Regex regex = new Regex(
@"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)",
RegexOptions.Compiled );
private readonly int _id;
private readonly List<string> _paramList;
private string _caller;
public StepHeaderLineConstructor( int id, string caller, string parameters )
{
_caller = caller;
_paramList = new List<string>();
SplitParameter( parameters );
}
public string this[ int paramIndex ]
{
get => _paramList[ paramIndex ];
}
public ReadOnlyCollection<string> ParamList
{
get => _paramList.AsReadOnly();
}
public static string TempCallerName
{
get => "TEMPCALLER";
}
public string Caller
{
get => _caller;
internal set => _caller = value;
}
public static StepHeaderLineConstructor CreateTempExpression( int id )
{
return new StepHeaderLineConstructor( id, "TEMPCALLER", string.Empty );
}
private void SplitParameter( string parameters )
{
if( string.IsNullOrEmpty( parameters ) || string.IsNullOrWhiteSpace( parameters ) ) {
return;
}
Match match = regex.Match( parameters );
while( match.Success )
{
_paramList.Add( match.Groups[ "param1" ].Value );
parameters = match.Groups[ "other" ].Value;
match = regex.Match( parameters );
}
_paramList.Add( parameters );
}
}
}
-63
View File
@@ -1,63 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepItemType.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
using StgSharp.Script;
using System;
namespace StgSharp.Modeling.Step
{
public enum StepItemType
{
Unknown,
AdvancedFace,
AxisPlacement2D,
AxisPlacement3D,
BSplineCurveWithKnots,
CartesianPoint,
Circle,
CylindricalSurface,
Direction,
EdgeCurve,
EdgeLoop,
Ellipse,
FaceBound,
FaceOuterBound,
Line,
OrientedEdge,
Plane,
Vector,
VertexPoint
}
}
-80
View File
@@ -1,80 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepModel.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.PipeLine;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Modeling.Step
{
public class StepModel
{
private BlueprintScheduler _builder;
private Dictionary<int, StepUncertainEntity> _nodes
= new Dictionary<int, StepUncertainEntity>();
private StepInfo _header;
internal StepModel( StepInfo header )
{
_header = header;
_builder = new BlueprintScheduler();
}
public StepUncertainEntity this[ int id ]
{
get
{
if( _nodes.TryGetValue( id, out StepUncertainEntity? node ) ) {
return node;
}
node = StepUncertainEntity.Create( id );
return node;
}
}
public void AddUncertainEntity( int id, StepUncertainEntity entity )
{
if( _nodes.ContainsKey( id ) ) {
throw new InvalidOperationException(
"Attempt to add entity with same id more than once" );
}
_nodes.Add( id, entity );
}
public void OrganizeNode()
{
foreach( KeyValuePair<int, StepUncertainEntity> node in _nodes ) { }
}
}
}
@@ -1,101 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepObjectConstructor.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.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public class StepObjectConstructor
{
private static Regex regex = new Regex(
@"(?<param1>.+?(\)|'\s?\)|'))\s?(?<sepcomma>,)\s?(?<other>(.|\(|\(\s?').+)",
RegexOptions.Compiled );
private readonly int _id;
private readonly List<string> _paramList;
private string _caller;
public StepObjectConstructor( int id, string caller, string parameters )
{
_caller = caller;
_paramList = new List<string>();
SplitParameter( parameters );
}
public string this[ int paramIndex ]
{
get => _paramList[ paramIndex ];
}
public ReadOnlyCollection<string> ParamList
{
get => _paramList.AsReadOnly();
}
public static string TempCallerName
{
get => "TEMPCALLER";
}
public string Caller
{
get => _caller;
internal set => _caller = value;
}
public static StepObjectConstructor CreateTempExpression( int id )
{
return new StepObjectConstructor( 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 );
}
}
}
@@ -1,75 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepDataReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
using StgSharp.Modeling.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.Modeling.Step
{
public partial class StepReader
{
public StepDataSectionTransmitter DataTransmitter { get; } = new StepDataSectionTransmitter(
);
public async void ReadDataSection()
{
using( MemoryMappedViewStream ms = _memoryFile.CreateViewStream(
0, _size, MemoryMappedFileAccess.Read ) )
{
StreamReader sr = new StreamReader( ms );
long pos = _headStart;
string line;
while( string.IsNullOrEmpty( line = sr.ReadLine()! ) ) {
DataTransmitter.WriteLine( line );
}
sr.Dispose();
}
}
[GeneratedRegex(
@"^#(?<id>[0-9]+)\s*?=\s*?(?<expression>\S.*?)\s*;$",
RegexOptions.Compiled | RegexOptions.Singleline )]
private static partial Regex GetExpressionSplitter();
}
}
@@ -1,111 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepHeadReader.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.IO;
using System.IO.MemoryMappedFiles;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public partial class StepReader
{
private static Regex expressionSplitter = new Regex(
@"^(?<CALLER>[A-Z_]+)\s?\((?<PARAM>.+)\)\;", RegexOptions.Compiled );
/**/
private StepInfo _info;
public StepInfo GetInfo()
{
if( _info is not null ) {
return _info;
}
StepInfo info = new StepInfo();
List<StepObjectConstructor> constructorList = new List<StepObjectConstructor>();
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 StepObjectConstructor(
0, match[ "CALLER" ].ToString(), match[ "PARAM" ].ToString() ) );
}
foreach( StepObjectConstructor 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;
}
/**/
}
}
-106
View File
@@ -1,106 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepReader.ToModel.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Modeling.Step
{
public partial class StepReader
{
private volatile int _version = 0;
private StepDataTokenReader tokenReader;
private StepExpSyntaxAnalyzer analyzer;
private StepModel Model { get; set; }
private Task<StepModel> ReadToModelTask { get; set; }
public StepModel ReadToModel()
{
if( Model is not null ) {
return Model;
}
if( _version != 0 ) {
throw new InvalidOperationException(
"A ReadToModel method has been called and is running now, use Async version instead" );
}
Interlocked.Increment( ref _version );
GetInfo();
tokenReader = new StepDataTokenReader( DataTransmitter );
analyzer = new StepExpSyntaxAnalyzer();
Task secTask = Task.Run( ReadDataSection );
Task anTask = Task.Run( ReadStepToken );
ConcurrentQueue<ExpSyntaxNode> initStatements = analyzer.StepEntityInitStatements;
Model = new StepModel( _info );
while( initStatements.TryDequeue( out ExpSyntaxNode? statement ) || !anTask.IsCompleted )
{
if( statement is null )
{
Thread.Sleep( 0 );
continue;
}
StepUninitializedEntity entity = StepUninitializedEntity.FromSyntax(
Model, statement );
Model.AddUncertainEntity( entity.Id, entity );
}
Task.WaitAll( secTask, anTask );
return Model;
}
public async Task<StepModel> ReadToModelAsync()
{
if( ReadToModelTask is null ) {
ReadToModelTask = Task.Run( ReadToModel );
}
return await ReadToModelTask;
}
private void ReadStepToken()
{
while( !tokenReader.IsEmpty )
{
Token t = tokenReader.ReadToken();
analyzer.AppendToken( t );
}
}
}
}
-172
View File
@@ -1,172 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepReader.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp;
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.Modeling.Step
{
public partial class StepReader : IDisposable
{
private const string fileLabel = "ISO-10303-21;";
private bool disposedValue;
private FileStream _fileStream;
private long _headStart = -1, _headEnd = -1, _dataStart = -1, _size;
private MemoryMappedFile _memoryFile;
private StepReader() { }
private StepReader( FileStream stream, long size )
{
_fileStream = stream;
_size = size;
_memoryFile = MemoryMappedFile.CreateFromFile(
stream, mapName: null, size, MemoryMappedFileAccess.Read, HandleInheritability.None,
leaveOpen: true );
}
// ~StepReader()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose( disposing: true );
GC.SuppressFinalize( this );
}
public static bool FromFile( string path, out StepReader reader )
{
FileInfo info = new FileInfo( path );
if( !info.Exists )
{
reader = null!;
return false;
}
FileStream stream = new FileStream(
path, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096,
useAsync: true );
byte[] fileHead = new byte[40];
stream.Read( fileHead, 0, fileLabel.Length );
if( !Encoding.UTF8.GetString( fileHead ).Contains( fileLabel ) ) {
throw new InvalidDataException( "The given file is not a STEP file" );
}
reader = new StepReader( stream, info.Length );
reader.LocateSection();
return reader != null;
}
private void LocateSection()
{
long startPos = 0;
byte[] buffer = new byte[1024];
Span<byte> bufferSpan = buffer,
headerSec = Encoding.UTF8.GetBytes( "HEADER;" ),
endsecSec = Encoding.UTF8.GetBytes( "ENDSEC;" ),
dataSec = Encoding.UTF8.GetBytes( "DATA;" );
_fileStream.Position = 0;
for( ; startPos < _size; startPos += 1000 )
{
_fileStream.Read( buffer );
if( _headStart == -1 )
{
long pos = bufferSpan.IndexOf( headerSec );
if( pos >= 0 ) {
_headStart = startPos + pos;
}
}
if( _headEnd == -1 )
{
long pos = bufferSpan.IndexOf( endsecSec );
if( pos >= 0 ) {
_headEnd = startPos + pos;
}
}
if( _dataStart == -1 )
{
long pos = bufferSpan.IndexOf( dataSec );
if( pos >= 0 ) {
_dataStart = startPos + pos;
}
} else
{
break;
}
_fileStream.Seek( 1000, SeekOrigin.Current );
}
}
private string ReadToken( StreamReader reader, ref long posCache )
{
StringBuilder token = new StringBuilder( 100 );
while( token.Length == 0 || token[ token.Length - 1 ] != ';' )
{
string subString = reader.ReadLine()!;
if( subString == null )
{
break;
}
token.Append( subString.TrimStart() );
}
posCache += token.Length;
return token.ToString();
}
private protected virtual void Dispose( bool disposing )
{
if( !disposedValue )
{
if( disposing )
{
_fileStream.Dispose();
_memoryFile.Dispose();
}
disposedValue = true;
}
}
}
}
-197
View File
@@ -1,197 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepUncertainElement.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp;
using StgSharp.PipeLine;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace StgSharp.Modeling.Step
{
public class StepUninitializedEntity : StepEntityBase, IConvertableToPipelineNode
{
private ExpSyntaxNode data;
private int _id;
private StepModel _model;
private string _name;
public StepUninitializedEntity( string name, int id )
: base( name )
{
_name = name;
_id = id;
}
public int Id
{
get => _id;
}
public override StepItemType ItemType => StepItemType.Unknown;
public string Name
{
get => _name;
}
internal static HashSet<string> UnsupportedItemTypes { get; } = new HashSet<string>();
public static StepUninitializedEntity Create( int id )
{
return new StepUninitializedEntity( string.Empty, id );
}
public static StepUninitializedEntity Create( string name, ExpSyntaxNode node )
{
return new StepUninitializedEntity( name, 0 );
}
public void Init( StepModel model, ExpSyntaxNode param )
{
if( param is ExpFunctionCallingNode caller )
{
string entityName = caller.FunctionCaller.Name;
ExpSyntaxNode p = caller.Right;
ExpNodeNextEnumerator e = p.ToEnumerator();
} else
{
throw new ExpInvalidSyntaxException(
"Assigned syntax node is not a function caller." );
}
}
public void InitGeometry()
{
throw new NotImplementedException();
}
internal static StepEntityBase FromTypedParameter(
StepModel binder,
ExpSyntaxNode itemSyntax )
{
StepEntityBase item = null!;
if( itemSyntax is ExpElementInitializingNode initNode )
{
string name = initNode.EqualityTypeConvert.Name;
switch( name )
{
case StepItemTypeExtensions.AdvancedFaceText:
item = StepAdvancedFace.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.Axis2Placement2DText:
item = StepAxis2Placement2D.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.Axis2Placement3DText:
item = StepAxis2Placement3D.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.BSplineCurveWithKnotsText:
item = StepBSplineCurveWithKnots.CreateFromSyntaxList(
binder, initNode.Right );
break;
case StepItemTypeExtensions.CartesianPointText:
item = StepCartesianPoint.CreateFromSyntaxList( initNode.Right );
break;
case StepItemTypeExtensions.CircleText:
item = StepCircle.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.CylindricalSurfaceText:
item = StepCylindricalSurface.CreateFromSyntaxList( binder,
initNode.Right );
break;
case StepItemTypeExtensions.DirectionText:
item = StepDirection.CreateFromSyntaxList( initNode.Right );
break;
case StepItemTypeExtensions.EdgeCurveText:
item = StepEdgeCurve.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.EdgeLoopText:
item = StepEdgeLoop.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.EllipseText:
item = StepEllipse.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.FaceBoundText:
item = StepFaceBound.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.FaceOuterBoundText:
item = StepFaceOuterBound.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.LineText:
item = StepLine.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.OrientedEdgeText:
item = StepOrientedEdge.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.PlaneText:
item = StepPlane.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.VectorText:
item = StepVector.CreateFromSyntaxList( binder, initNode.Right );
break;
case StepItemTypeExtensions.VertexPointText:
item = StepVertexPoint.CreateFromSyntaxList( binder, initNode.Right );
break;
default:
if( UnsupportedItemTypes.Add( name ) ) {
Debug.WriteLine(
$"Unsupported item {name} at {initNode.Line}, {initNode.Column}" );
}
break;
}
} else
{
// TODO:
}
return item;
}
void IConvertableToPipelineNode.NodeMain(
in Dictionary<string, PipelineNodeImport> input,
in Dictionary<string, PipelineNodeExport> output )
{
InitGeometry();
PipelineNodeExport.SkipAll( output );
}
IEnumerable<string> IConvertableToPipelineNode.InputInterfacesName => ["in"];
PipelineNodeOperation IConvertableToPipelineNode.Operation => ( this as IConvertableToPipelineNode ).NodeMain;
IEnumerable<string> IConvertableToPipelineNode.OutputInterfacesName => ["out"];
}
}
@@ -1,83 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepUncertainElement.Parse.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
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()
};
}
}
}
@@ -1,57 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepUnsupportedEntity.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepUnsupportedEntity : StepEntityBase
{
private ExpSyntaxNode _initSequence;
public StepUnsupportedEntity( StepModel model, int id, string name, ExpSyntaxNode sequence )
{
Id = id;
Name = name;
_initSequence = sequence;
Context = model;
}
public override StepItemType ItemType => StepItemType.Unknown;
}
}
@@ -1,67 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepComplexEntityNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script.Express;
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;
public StepComplexEntityNode( ExpSyntaxNode node )
: base( node.Source )
{
_begin = node;
}
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => _begin;
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
public StepComplexEntityNode FromTuple( ExpSyntaxNode node )
{
if( node is not ExpTupleNode tuple ) {
throw new ExpInvalidSyntaxException( "Node to convert is not a complex" );
}
return new StepComplexEntityNode( tuple.Right );
}
}
}
@@ -1,68 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityInitCaller.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 Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Modeling.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.Threading.Tasks;
namespace StgSharp.Model.Step.SyntaxNode
{
public class StepEntityInitCaller : ExpFunctionSource
{
private static Dictionary<string, StepEntityInitCaller> _callers = new();
private StepEntityInitCaller( string name )
: base( name, null )
{
ReturningType = StepEntityType.Source;
}
public static StepEntityInitCaller CreateCaller( string name )
{
if( _callers.TryGetValue( name, out StepEntityInitCaller? caller ) ) {
return caller;
}
caller = new StepEntityInitCaller( name );
_callers.Add( name, caller );
return caller;
}
}
}
@@ -1,64 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepEntityInstanceNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Modeling.Step;
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.Modeling.Step
{
public class StepEntityInstanceNode : ExpSyntaxNode
{
private int id;
private StepModel _model;
public StepEntityInstanceNode( Token source, StepModel model ) : base( source ) { }
public override ExpSyntaxNode Left => Empty;
public override ExpSyntaxNode Right => Empty;
public override IExpElementSource EqualityTypeConvert => throw new NotImplementedException();
private void GetInstance()
{
_model
}
}
}
@@ -1,60 +0,0 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepExpEnumValueNode.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Modeling.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; }
}
}
@@ -0,0 +1,303 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// 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;
}
}
}
}
@@ -0,0 +1,65 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.Enum"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
private static string ParseStepEnumLiteral(string source)
{
int length = source.Length;
ReadOnlySpan<char> span = source.AsSpan();
if (length > 2 && span[0] == '.' && span[length - 1] == '.') {
return span.Slice(1, length - 2).ToString();
}
throw new ExpInvalidSyntaxException($"\"{source}\" is not a valid enum syntax");
}
private void TryAppendEnum(Token e)
{
ExpSyntaxNode node = e.Value switch
{
".T." => new ExpBoolNode(e, true, true),
".F." => new ExpBoolNode(e, false, true),
".U." => new ExpLogicValueNode(e, ExpLogic.Unknown, true),
_ => ExpEnumLiteralNode.Create(e, ParseStepEnumLiteral),
};
_cache.PushOperand(node);
}
}
}
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.ErrorProcess"
// 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 partial class StepExpSyntaxAnalyzer
{
public void ThrowCompileException(int errorCode)
{
switch (errorCode)
{
case 0 or 1:
return;
case TokenTypeNotMatch:
throw new Exception();
default:
break;
}
}
}
}
@@ -0,0 +1,128 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer.OperatorParser"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer
{
public int CompareOperatorPrecedence(Token left, Token right)
{
ExpressCompile.TryGetOperatorPrecedence(left.Value, out int leftPrecedence);
ExpressCompile.TryGetOperatorPrecedence(right.Value, out int rightPrecedence);
return leftPrecedence - rightPrecedence;
}
public bool TryGenerateUnaryNode(Token t, out ExpSyntaxNode node)
{
ExpSyntaxNode operand = GetNextOperandCache();
switch (t.Value)
{
case ExpKeyword.UnaryPlus:
node = ExpUnaryOperatorNode.UnaryPlus(t, operand);
return true;
case ExpKeyword.UnaryMinus:
node = ExpUnaryOperatorNode.UnaryMinus(t, operand);
return true;
case ExpKeyword.Not:
node = ExpUnaryOperatorNode.UnaryNot(t, operand);
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
/// <summary>
/// WARNING: This method cannot process INDEXOF, FUNCTION CALLING, LOOP and any ENDING
/// SYMBOLS.
/// </summary>
private ExpSyntaxNode ConvertAndPushOneOperator(Token op)
{
switch (op.Flag)
{
case TokenFlag.Symbol_Unary:
TryGenerateUnaryNode(op, out ExpSyntaxNode? node);
_cache.PushOperand(node);
return node;
case TokenFlag.Symbol_Binary:
TryGenerateBinaryNode(op, out node);
_cache.PushOperand(node);
return node;
case TokenFlag.Member:
_cache.PopOperand(out _, out ExpSyntaxNode? p);
StepEntityInitCaller caller = StepEntityInitCaller.CreateCaller(op.Value);
node = ExpFunctionCallingNode.CallFunction(op, caller, p);
_cache.StatementsInDepth.Push(node);
return node;
default:
throw new NotImplementedException();
}
}
private bool TryGenerateBinaryNode(Token t, out ExpSyntaxNode node)
{
/*
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left = GetNextOperandCache();
/**/
switch (t.Value)
{
case "=":
ExpSyntaxNode right = GetNextOperandCache();
ExpSyntaxNode left;
if (right is ExpTupleNode tuple)
{
right = StepComplexEntityNode.FromTuple(tuple);
left = GetNextOperandCache();
} else
{
left = right;
right = _cache.StatementsInDepth.Pop();
}
node = ExpBinaryOperatorNode.Assign(t, left, right);
return true;
default:
node = ExpSyntaxNode.Empty;
return false;
}
}
}
}
@@ -0,0 +1,87 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// 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");
}
}
}
}
@@ -0,0 +1,135 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="ExpSyntaxAnalyzer"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Script;
using StgSharp.Script.Express;
using StgSharp.Threading;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ExpKeyword = StgSharp.Script.Express.ExpressCompile.Keyword;
namespace StgSharp.Model.Step
{
internal partial class StepExpSyntaxAnalyzer : ISyntaxAnalyzer
{
private const int EndLine = 1;
private const int TokenGenerated = 0;
private const int TokenTypeNotMatch = -1;
private CompileStack<ExpSyntaxNode, IExpElementSource> _cache;
private ExpSchema _context;
private ExpSyntaxNode _lastStatement;
private IExpElementSource _local;
public StepExpSyntaxAnalyzer()
{
_cache = new CompileStack<ExpSyntaxNode, IExpElementSource>();
_context = new ExpressStepUtil();
}
public ConcurrentQueue<StepEntityDefineSequence> StepEntityInitStatements { get; } = new();
/// <summary>
/// Append a token to top of cache. This method will automatically convert token to node
/// if meets separators or operators.
/// </summary>
public void AppendToken(Token expToken)
{
switch (expToken.Flag)
{
case TokenFlag.Symbol_Unary or TokenFlag.Symbol_Binary:
TryAppendSymbol(expToken);
break;
case TokenFlag.Number or TokenFlag.String:
ExpElementInstance node = ExpElementInstance.CreateLiteral(expToken);
_cache.PushOperand(node);
break;
case TokenFlag.Separator_Left:
TryAppendPrefixSeparator(expToken);
break;
case TokenFlag.Separator_Right:
TryAppendPrefixSeparatorEnd(expToken);
break;
case TokenFlag.Separator_Middle:
TryAppendMiddleSeparator(expToken);
break;
case TokenFlag.Index_Left:
TryAppendIndexLeft(expToken);
break;
case TokenFlag.Index_Right:
TryAppendIndexRight(expToken);
break;
case TokenFlag.Member:
TryAppendMember(expToken);
break;
case TokenFlag.Enum:
TryAppendEnum(expToken);
break;
default:
break;
}
}
public ExpSyntaxNode GetNextOperandCache()
{
if (_cache.PopOperand(out Token t, out ExpSyntaxNode? n))
{
return n;
} else
{
// process some rare case here
}
throw new NotImplementedException();
}
public enum ExpCompileStateCode
{
Common,
ForLoop,
RepeatLoop,
UntilLoop,
IfBranch,
CaseBranch,
CollectionIndex,
}
}
}
@@ -0,0 +1,108 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDataSectionsTranmitter"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Script;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public class StepDataSectionTransmitter : IScriptSourceProvider
{
private const string EndDataText = "ENDSEC;";
// private bool _isEmpty;
private ConcurrentQueue<string> _cache = new ConcurrentQueue<string>();
private int _line = 0;
public StepDataSectionTransmitter() { }
public StepDataSectionTransmitter(int begins)
{
Begin = begins;
_line = Begin;
}
public bool IsEmpty => _cache.IsEmpty && !IsWriting;
public bool IsWriting { get; private set; } = true;
public int Begin { get; internal set; }
public int Location => _line;
public void EndWriting()
{
IsWriting = false;
}
public string ReadLine()
{
if (_cache.TryDequeue(out string? line))
{
_line++;
return line;
}
return string.Empty;
}
public string ReadLine(out int position)
{
string ret = ReadLine();
position = _line;
return ret;
}
public void WriteLine(string line)
{
if (line == "DATA;") {
return;
}
if (line == EndDataText)
{
EndWriting();
return;
}
if (IsWriting) {
_cache.Enqueue(line);
}
}
IScriptSourceProvider IScriptSourceProvider.Slice(int location, int count)
{
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,165 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDataTokenReader"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
public partial class StepDataTokenReader : IScriptTokenReader
{
private ExpTokenReader _reader;
private HashSet<string> tokenHash = [ "T", "F", "UNSPECIFIED" ];
private Queue<Token> _cache = new Queue<Token>();
private StepDataSectionTransmitter _transmitter;
public StepDataTokenReader(StepDataSectionTransmitter transmitter)
{
_reader = new ExpTokenReader(transmitter);
_reader.TokenReaderPreProcessor = new TokenPreReader();
_transmitter = transmitter;
}
public bool IsEmpty
{
get
{
if (_reader.IsEmpty) {
return !_transmitter.IsWriting;
}
return false;
}
}
public Token ReadToken()
{
return _reader.ReadToken();
}
public bool TryReadToken(out Token t)
{
return _reader.TryReadToken(out t);
}
private partial class TokenPreReader : ExpTokenReaderPreProcessor
{
private static Regex
_nextHashtagSymbolPattern = GetEntityTagSymbolPattern(),
_nextEnumPattern = GetNextEnumPattern(),
_stringPattern = GetStringPattern();
public override bool Process(string codeLine, int line, ref int current, out Token t)
{
ReadOnlySpan<char> chars = codeLine.AsSpan(current);
char c = chars[0];
Match match;
switch (c)
{
case '#':
match = _nextHashtagSymbolPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new(
ExpressCompile.PoolString(chars[0..(end - begin)]), line,
begin, TokenFlag.Member);
return true;
}
break;
case '.':
match = _nextEnumPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
t = new Token(
match.Groups["token"].Value, line, begin, TokenFlag.Enum);
return true;
}
break;
case '$':
t = new Token("$", line, current, TokenFlag.Member);
current++;
return true;
case '*':
t = new Token("*", line, current, TokenFlag.Member);
current++;
return true;
case '\'':
match = _stringPattern.Match(codeLine, current);
if (match.Success)
{
int begin = match.Groups["token"].Index;
int end = match.Groups["end"].Index;
int rest = match.Groups["rest"].Index;
current = rest;
string value = chars.Slice(1, (end - begin - 1)).ToString();
if (string.IsNullOrWhiteSpace(value)) {
value = string.Empty;
}
t = new Token(value, line, begin, TokenFlag.String);
return true;
}
break;
default:
break;
}
t = Token.Empty;
return false;
}
[GeneratedRegex(@"(?<token>#[0-9A-Za-z]+)(?<end>\s*?)(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetEntityTagSymbolPattern();
[GeneratedRegex(@"(?<token>\.[A-Za-z_]+\.)(?<end>\s*)(?<rest>\S*)", RegexOptions.Singleline)]
private static partial Regex GetNextEnumPattern();
[GeneratedRegex(@"(?<token>')(?>\\\\|''|(?!')[^'])*(?<end>')\s*?(?<rest>\S|$)", RegexOptions.Singleline)]
private static partial Regex GetStringPattern();
}
}
}
@@ -0,0 +1,58 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepDependencyDetector"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Model.Step;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Model.Step
{
internal class StepDependencyDetector
{
public StepDependencyDetector() { }
public List<int> Dependencies { get; private set; } = new();
public void AddDependency(StepEntityInstanceNode node)
{
Dependencies.Add(node.Id);
}
public IEnumerable<int> ExportAllDependencies()
{
List<int> ret = Dependencies;
Dependencies = new List<int>();
return ret;
}
}
}

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