This commit is contained in:
Nitload
2025-08-25 09:50:30 +08:00
parent bd0e31e922
commit 1359ff4ecc
1630 changed files with 738486 additions and 2399 deletions
+21 -20
View File
@@ -28,46 +28,47 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Linq;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom<StepAdvancedFace>
public class StepAdvancedFace : StepFaceSurface
{
public StepAdvancedFace( StepModel model ) : base( model ) { }
private StepAdvancedFace() : base( string.Empty ) { }
public StepAdvancedFace( string name ) : base( name ) { }
public override StepItemType ItemType => StepItemType.AdvancedFace;
public void FromInstance( StepAdvancedFace entity )
internal static StepAdvancedFace CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static StepAdvancedFace FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepAdvancedFace face = new StepAdvancedFace( binder );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAdvancedFace face = new StepAdvancedFace();
enumerator.AssertEnumeratorCount( 4 );
face.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
face.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
ExpNodePresidentEnumerator boundsList = enumerator[ 1 ].TupleToPresidentEnumerator();
object boundsList = enumerator.Values[ 1 ].GetValueList();
face.Bounds.Clear();
face.Bounds
.AddRange(
Enumerable.Range( 0, enumerator.Count ).Select( _ => ( StepFaceBound )null ) );
for( int i = 0; i < boundsList.Count; i++ )
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
face.Bounds[ j ] = binder[ boundsList[ j ] ] as StepFaceBound;
binder.BindValue(
enumerator.Values[ j ], v => face.Bounds[ j ] = v.AsType<StepFaceBound>() );
}
face.FaceGeometry = binder[ enumerator[ 2 ] ] as StepSurface;
face.SameSense = ( enumerator[ 3 ] as ExpBoolNode )!.Value;
binder.BindValue(
enumerator.Values[ 2 ], v => face.FaceGeometry = v.AsType<StepSurface>() );
face.SameSense = ( enumerator.Values[ 3 ] as ExpBoolNode )!.Value;
return face;
}
+20 -10
View File
@@ -28,35 +28,45 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepAxis2Placement : StepPlacement
public abstract class StepAxis2Placement : StepPlacement
{
private StepCartesianPoint _location;
private StepDirection _refDirection;
protected StepAxis2Placement( StepModel model ) : base( model ) { }
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
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_refDirection = value;
}
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepAxis2Placement";
}
}
}
@@ -28,25 +28,24 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement2D>
public class StepAxis2Placement2D : StepAxis2Placement
{
private StepAxis2Placement2D( StepModel model ) : base( model ) { }
private StepAxis2Placement2D() : base( string.Empty ) { }
public StepAxis2Placement2D(
StepModel model,
string label,
StepCartesianPoint location,
StepDirection direction )
: base( model )
: base( label )
{
Location = location;
RefDirection = direction;
@@ -54,24 +53,25 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.AxisPlacement2D;
public void FromInstance( StepAxis2Placement2D entity )
internal static StepAxis2Placement2D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
Location = entity.Location;
RefDirection = entity.RefDirection;
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 static StepAxis2Placement2D FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepAxis2Placement2D axis = new StepAxis2Placement2D( binder );
enumerator.AssertEnumeratorCount( 3 );
axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint;
axis.RefDirection = binder[ enumerator[ 2 ] ] as StepDirection;
return axis;
yield return Location;
yield return RefDirection;
}
}
@@ -28,28 +28,27 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepAxis2Placement3D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement3D>
public class StepAxis2Placement3D : StepAxis2Placement
{
private StepDirection _axis;
private StepAxis2Placement3D( StepModel model ) : base( model ) { }
private StepAxis2Placement3D() : base( string.Empty ) { }
public StepAxis2Placement3D(
StepModel model,
string name,
StepCartesianPoint location,
StepDirection axis,
StepDirection refDirection )
: base( model )
: base( name )
{
Location = location;
Axis = axis;
@@ -61,35 +60,37 @@ namespace StgSharp.Model.Step
get { return _axis; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_axis = value;
}
}
public override StepItemType ItemType => StepItemType.AxisPlacement3D;
public override bool IsConvertableTo( string entityTypeName )
internal static StepAxis2Placement3D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
throw new NotImplementedException();
}
internal static StepAxis2Placement3D FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepAxis2Placement3D axis = new StepAxis2Placement3D( binder );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAxis2Placement3D axis = new StepAxis2Placement3D();
enumerator.AssertEnumeratorCount( 4 );
axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint;
axis.Axis = binder[ enumerator[ 2 ] ] as StepDirection;
axis.RefDirection = binder[ enumerator[ 3 ] ] as StepDirection;
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;
}
void IExpConvertableFrom<StepAxis2Placement3D>.FromInstance( StepAxis2Placement3D entity )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
throw new NotImplementedException();
yield return Location;
yield return Axis;
yield return RefDirection;
}
}
+48 -57
View File
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -37,7 +36,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public enum StepBSplineCurveForm
{
@@ -51,89 +50,81 @@ namespace StgSharp.Model.Step
}
public static class StepExpEnumValue
;
public abstract class StepBSplineCurve : StepBoundedCurve
{
internal const string CIRCULAR_ARC = "CIRCULAR_ARC";
internal const string ELLIPTIC_ARC = "ELLIPTIC_ARC";
internal const string HYPERBOLIC_ARC = "HYPERBOLIC_ARC";
internal const string PARABOLIC_ARC = "PARABOLIC_ARC";
internal const string POLYLINE_FORM = "POLYLINE_FORM";
internal const string UNSPECIFIED = "UNSPECIFIED";
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";
internal static HashSet<string> AllPossibleValue { get; } = [
CIRCULAR_ARC,
ELLIPTIC_ARC,
HYPERBOLIC_ARC,
PARABOLIC_ARC,
POLYLINE_FORM,
UNSPECIFIED,
];
private const string POLYLINE_FORM = "POLYLINE_FORM";
private const string UNSPECIFIED = "UNSPECIFIED";
}
public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom<StepBSplineCurve>
{
public StepBSplineCurve( StepModel model, params StepCartesianPoint[] controlPoints )
: this( model, ( IEnumerable<StepCartesianPoint> )controlPoints ) { }
public StepBSplineCurve( StepModel model, IEnumerable<StepCartesianPoint> controlPoints )
: base( model )
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; private set; }
= new List<StepCartesianPoint>();
public List<StepCartesianPoint> ControlPointsList { get; } = new List<StepCartesianPoint>();
public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified;
public void FromInstance( StepBSplineCurve entity )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
base.FromInstance( entity );
this.Degree = entity.Degree;
this.ClosedCurve = entity.ClosedCurve;
this.ControlPointsList = entity.ControlPointsList;
this.SelfIntersect = entity.SelfIntersect;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepBSplineCurve";
return ControlPointsList;
}
protected static string GetCurveFormString( StepBSplineCurveForm form )
{
return form switch
switch( form )
{
StepBSplineCurveForm.Polyline => StepExpEnumValue.POLYLINE_FORM,
StepBSplineCurveForm.CircularArc => StepExpEnumValue.CIRCULAR_ARC,
StepBSplineCurveForm.EllipticalArc => StepExpEnumValue.ELLIPTIC_ARC,
StepBSplineCurveForm.ParabolicArc => StepExpEnumValue.PARABOLIC_ARC,
StepBSplineCurveForm.HyperbolicArc => StepExpEnumValue.HYPERBOLIC_ARC,
StepBSplineCurveForm.Unspecified => StepExpEnumValue.UNSPECIFIED,
_ => throw new NotImplementedException(),
};
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 )
{
return enumerationValue.ToUpperInvariant() switch
switch( enumerationValue.ToUpperInvariant() )
{
StepExpEnumValue.POLYLINE_FORM => StepBSplineCurveForm.Polyline,
StepExpEnumValue.CIRCULAR_ARC => StepBSplineCurveForm.CircularArc,
StepExpEnumValue.ELLIPTIC_ARC => StepBSplineCurveForm.EllipticalArc,
StepExpEnumValue.PARABOLIC_ARC => StepBSplineCurveForm.ParabolicArc,
StepExpEnumValue.HYPERBOLIC_ARC => StepBSplineCurveForm.HyperbolicArc,
_ => StepBSplineCurveForm.Unspecified,
};
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;
}
}
}
@@ -28,7 +28,6 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -37,7 +36,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public enum StepKnotType
{
@@ -51,7 +50,7 @@ namespace StgSharp.Model.Step
;
public class StepBSplineCurveWithKnots : StepBSplineCurve, IExpConvertableFrom<StepBSplineCurveWithKnots>
public class StepBSplineCurveWithKnots : StepBSplineCurve
{
private const string PIECEWISE_BEZIER_KNOTS = "PIECEWISE_BEZIER_KNOTS";
@@ -61,14 +60,12 @@ namespace StgSharp.Model.Step
private const string UNSPECIFIED = "UNSPECIFIED";
public StepBSplineCurveWithKnots(
StepModel model,
string name,
IEnumerable<StepCartesianPoint> controlPoints )
: base( model, controlPoints ) { }
: base( name, controlPoints ) { }
public StepBSplineCurveWithKnots(
StepModel model,
params StepCartesianPoint[] controlPoints )
: base( model, controlPoints ) { }
public StepBSplineCurveWithKnots( string name, params StepCartesianPoint[] controlPoints )
: base( name, controlPoints ) { }
public List<int> KnotMultiplicities { get; } = new List<int>();
@@ -78,79 +75,79 @@ namespace StgSharp.Model.Step
public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified;
public void FromInstance( StepBSplineCurveWithKnots entity )
internal static StepBSplineCurveWithKnots CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
KnotSpec = entity.KnotSpec;
KnotMultiplicities.Clear();
KnotMultiplicities.AddRange( entity.KnotMultiplicities );
Knots.Clear();
Knots.AddRange( entity.Knots );
}
internal static StepBSplineCurveWithKnots FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = syntaxList .ToPresidentEnumerator();
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 9 );
ExpNodePresidentEnumerator controlPointsList = enumerator[ 2 ].TupleToPresidentEnumerator(
);
object controlPointsList = enumerator.Values[ 2 ].GetValueList();
StepBSplineCurveWithKnots spline = new StepBSplineCurveWithKnots(
binder, new StepCartesianPoint[controlPointsList.Count] );
spline.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
spline.Degree = ( enumerator[ 1 ] as ExpIntNode )!.Value;
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.Count; i++ )
for( int i = 0; i < controlPointsList.Values.Count; i++ )
{
int j = i; // capture to avoid rebinding
spline.ControlPointsList[ j ] = binder[ controlPointsList[ j ] ]as StepCartesianPoint;
binder.BindValue(
controlPointsList.Values[ j ],
v => spline.ControlPointsList[ j ] = v.AsType<StepCartesianPoint>() );
}
spline.CurveForm = ParseCurveForm( enumerator[ 3 ].CodeConvertTemplate );
spline.ClosedCurve = ( enumerator[ 4 ] as ExpBoolNode )!.Value;
spline.SelfIntersect = ( enumerator[ 5 ]as ExpBoolNode )!.Value;
spline.CurveForm = ParseCurveForm( enumerator.Values[ 3 ].GetEnumerationValue() );
spline.ClosedCurve = ( enumerator.Values[ 4 ] as ExpBoolNode )!.Value;
spline.SelfIntersect = ( enumerator.Values[ 5 ]as ExpBoolNode )!.Value;
ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[ 6 ].TupleToPresidentEnumerator(
);
object knotMultiplicitiesList = enumerator.Values[ 6 ].GetValueList();
spline.KnotMultiplicities.Clear();
for( int i = 0; i < knotMultiplicitiesList.Count; i++ ) {
spline.KnotMultiplicities.Add( ( knotMultiplicitiesList[ i ]as ExpIntNode )!.Value );
for( int i = 0; i < knotMultiplicitiesList.Values.Count; i++ ) {
spline.KnotMultiplicities
.Add( knotMultiplicitiesList.Values[ i ].GetIntegerValue() );
}
ExpNodePresidentEnumerator knotsList = enumerator[ 7 ].TupleToPresidentEnumerator();
object knotslist = enumerator.Values[ 7 ].GetValueList();
spline.Knots.Clear();
for( int i = 0; i < knotsList.Count; i++ ) {
spline.Knots.Add( ( knotsList[ i ]as ExpRealNumberNode )!.Value );
for( int i = 0; i < knotslist.Values.Count; i++ ) {
spline.Knots.Add( knotslist.Values[ i ].GetRealVavlue() );
}
spline.KnotSpec = ParseKnotSpec( enumerator[ 8 ].CodeConvertTemplate );
spline.KnotSpec = ParseKnotSpec( enumerator.Values[ 8 ].GetEnumerationValue() );
return spline;
}
private static string GetKnotSpec( StepKnotType spec )
{
return spec switch
switch( spec )
{
StepKnotType.UniformKnots => UNIFORM_KNOTS,
StepKnotType.QuasiUniformKnots => QUASI_UNIFORM_KNOTS,
StepKnotType.PiecewiseBezierKnots => PIECEWISE_BEZIER_KNOTS,
StepKnotType.Unspecified => UNSPECIFIED,
_ => throw new NotImplementedException(),
};
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 )
{
return enumerationValue.ToUpperInvariant() switch
switch( enumerationValue.ToUpperInvariant() )
{
UNIFORM_KNOTS => StepKnotType.UniformKnots,
QUASI_UNIFORM_KNOTS => StepKnotType.QuasiUniformKnots,
PIECEWISE_BEZIER_KNOTS => StepKnotType.PiecewiseBezierKnots,
_ => StepKnotType.Unspecified,
};
case UNIFORM_KNOTS:
return StepKnotType.UniformKnots;
case QUASI_UNIFORM_KNOTS:
return StepKnotType.QuasiUniformKnots;
case PIECEWISE_BEZIER_KNOTS:
return StepKnotType.PiecewiseBezierKnots;
default:
return StepKnotType.Unspecified;
}
}
}
+3 -19
View File
@@ -28,31 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepBoundedCurve : StepCurve, IExpConvertableFrom<StepBoundedCurve>
public abstract class StepBoundedCurve : StepCurve
{
public StepBoundedCurve( StepModel model ) : base( model ) { }
public void FromInstance( StepBoundedCurve entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepBoundedCurve";
}
internal static StepBoundedCurve FromSyntax( StepModel binder, ExpSyntaxNode syntax )
{
return new StepBoundedCurve( binder );
}
protected StepBoundedCurve( string name ) : base( name ) { }
}
}
@@ -28,32 +28,27 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepCartesianPoint : StepTriple, IExpConvertableFrom<StepCartesianPoint>
public class StepCartesianPoint : StepTriple
{
private StepCartesianPoint( StepModel model ) : base( model ) { }
private StepCartesianPoint() { }
public StepCartesianPoint( StepModel model, float x, float y, float z )
: base( model, x, y, z ) { }
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;
public void FromInstance( StepCartesianPoint entity )
internal static StepCartesianPoint CreateFromSyntaxList( ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static StepCartesianPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
return AssignTo( new StepCartesianPoint( binder ), syntaxList );
return ( StepCartesianPoint )AssignTo( new StepCartesianPoint(), syntaxList );
}
}
+16 -17
View File
@@ -28,24 +28,23 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepCircle : StepConic, IExpConvertableFrom<StepCircle>
public class StepCircle : StepConic
{
private StepAxis2Placement _position;
public StepCircle( StepModel model ) : base( model ) { }
private StepCircle() : base( string.Empty ) { }
public StepCircle( StepModel model, StepAxis2Placement position, float radius )
: base( model )
public StepCircle( string label, StepAxis2Placement position, float radius )
: base( label )
{
Position = position;
Radius = radius;
@@ -68,21 +67,21 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Circle;
public void FromInstance( StepCircle entity )
internal static StepCircle CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
this._position = entity.Position;
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 static StepCircle FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepCircle circle = new StepCircle( binder );
enumerator.AssertEnumeratorCount( 3 );
circle.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
circle.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement;
circle.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value;
return circle;
yield return Position;
}
}
+3 -16
View File
@@ -28,28 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepConic : StepCurve, IExpConvertableFrom<StepConic>
public abstract class StepConic : StepCurve
{
public StepConic( StepModel model ) : base( model ) { }
public override StepItemType ItemType => StepItemType.Conic;
public override bool IsConvertableTo( string entityTypeName )
{
return base.IsConvertableTo( entityTypeName ) || entityTypeName == "StepConic";
}
void IExpConvertableFrom<StepConic>.FromInstance( StepConic entity )
{
base.FromInstance( entity );
}
protected StepConic( string name ) : base( name ) { }
}
}
+3 -16
View File
@@ -28,28 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom<StepCurve>
public abstract class StepCurve : StepGeometricRepresentationItem
{
public StepCurve( StepModel model ) : base( model ) { }
public override StepItemType ItemType => StepItemType.Curve;
public void FromInstance( StepCurve entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepCurve";
}
protected StepCurve( string name ) : base( name ) { }
}
}
@@ -28,25 +28,21 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom<StepCylindricalSurface>
public class StepCylindricalSurface : StepElementarySurface
{
public StepCylindricalSurface( StepModel model ) : base( model ) { }
private StepCylindricalSurface() : base() { }
public StepCylindricalSurface(
StepModel model,
StepAxis2Placement3D position,
float radius )
: base( model, position )
public StepCylindricalSurface( string name, StepAxis2Placement3D position, float radius )
: base( name, position )
{
Radius = radius;
}
@@ -55,22 +51,17 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.CylindricalSurface;
public void FromInstance( StepCylindricalSurface entity )
internal static StepRepresentationItem CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
Radius = entity.Radius;
}
internal static StepRepresentationItem FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepCylindricalSurface surface = new StepCylindricalSurface( binder );
surface.Name = ( enumerator[ 0 ] as ExpStringNode )!.Value;
surface.Position = binder[ enumerator[ 1 ] ]as StepAxis2Placement3D;
surface.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value;
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;
}
+7 -13
View File
@@ -28,32 +28,26 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepDirection : StepTriple, IExpConvertableFrom<StepDirection>
public class StepDirection : StepTriple
{
private StepDirection( StepModel model ) : base( model ) { }
private StepDirection() { }
public StepDirection( StepModel model, float x, float y, float z )
: base( model, x, y, z ) { }
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;
public void FromInstance( StepDirection entity )
internal static StepDirection CreateFromSyntaxList( ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static StepDirection FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
return AssignTo( new StepDirection( binder ), syntaxList );
return ( StepDirection )AssignTo( new StepDirection(), syntaxList );
}
}
+13 -15
View File
@@ -28,22 +28,21 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom<StepEdge>
public abstract class StepEdge : StepTopologicalRepresentationItem
{
protected StepEdge( StepModel model ) : base( model ) { }
protected StepEdge() : base( string.Empty ) { }
protected StepEdge( StepModel model, StepVertex edgeStart, StepVertex edgeEnd )
: base( model )
protected StepEdge( string name, StepVertex edgeStart, StepVertex edgeEnd )
: base( name )
{
EdgeStart = edgeStart;
EdgeEnd = edgeEnd;
@@ -53,16 +52,15 @@ namespace StgSharp.Model.Step
public StepVertex EdgeEnd { get; set; }
public void FromInstance( StepEdge entity )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
base.FromInstance( entity );
EdgeStart = entity.EdgeStart;
EdgeEnd = entity.EdgeEnd;
}
if( EdgeStart != null ) {
yield return EdgeStart;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepEdge";
if( EdgeEnd != null ) {
yield return EdgeEnd;
}
}
}
+28 -20
View File
@@ -28,29 +28,28 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepEdgeCurve : StepEdge, IExpConvertableFrom<StepEdgeCurve>
public class StepEdgeCurve : StepEdge
{
private StepCurve _edgeGeometry;
private StepEdgeCurve( StepModel model ) : base( model ) { }
private StepEdgeCurve() : base() { }
public StepEdgeCurve(
StepModel model,
string name,
StepVertex edgeStart,
StepVertex edgeEnd,
StepCurve edgeGeometry,
bool isSameSense )
: base( model, edgeStart, edgeEnd )
: base( name, edgeStart, edgeEnd )
{
EdgeGeometry = edgeGeometry;
IsSameSense = isSameSense;
@@ -63,30 +62,39 @@ namespace StgSharp.Model.Step
get { return _edgeGeometry; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_edgeGeometry = value;
}
}
public override StepItemType ItemType => StepItemType.EdgeCurve;
public void FromInstance( StepEdgeCurve entity )
internal static StepEdgeCurve CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
EdgeGeometry = entity.EdgeGeometry;
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 static StepEdgeCurve FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepEdgeCurve edgeCurve = new StepEdgeCurve( binder );
enumerator.AssertEnumeratorCount( 5 );
edgeCurve.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
edgeCurve.EdgeStart = binder[ enumerator[ 1 ] ] as StepVertex;
edgeCurve.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex;
edgeCurve.EdgeGeometry = binder[ enumerator[ 3 ] ] as StepCurve;
edgeCurve.IsSameSense = ( enumerator[ 4 ]as ExpBoolNode )!.Value;
return edgeCurve;
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeGeometry;
}
}
+21 -20
View File
@@ -28,53 +28,54 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepEdgeLoop : StepLoop, IExpConvertableFrom<StepEdgeCurve>
public class StepEdgeLoop : StepLoop
{
public StepEdgeLoop( StepModel model, params StepOrientedEdge[] edgeList )
: this( model, ( IEnumerable<StepOrientedEdge> )edgeList ) { }
public StepEdgeLoop( StepModel model, IEnumerable<StepOrientedEdge> edgeList )
: base( model )
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;
public void FromInstance( StepEdgeCurve entity )
internal static StepEdgeLoop CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static StepEdgeLoop FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 2 );
ExpNodePresidentEnumerator edgeSyntaxList = enumerator[ 1 ].TupleToPresidentEnumerator();
object edgeSyntaxList = enumerator.Values[ 1 ].GetValueList();
StepEdgeLoop edgeLoop = new StepEdgeLoop(
binder, new StepOrientedEdge[edgeSyntaxList.Count] );
edgeLoop.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
for( int i = 0; i < edgeSyntaxList.Count; i++ )
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
edgeLoop.EdgeList[ j ] = binder[ edgeSyntaxList[ j ] ] as StepOrientedEdge;
binder.BindValue(
edgeSyntaxList.Values[ j ],
v => edgeLoop.EdgeList[ j ] = v.AsType<StepOrientedEdge>() );
}
return edgeLoop;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
return EdgeList;
}
}
}
@@ -28,24 +28,23 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepElementarySurface : StepSurface, IExpConvertableFrom<StepElementarySurface>
public abstract class StepElementarySurface : StepSurface
{
private StepAxis2Placement3D _position;
public StepElementarySurface( StepModel model ) : base( model ) { }
protected StepElementarySurface() : base( string.Empty ) { }
public StepElementarySurface( StepModel model, StepAxis2Placement3D position )
: base( model )
public StepElementarySurface( string name, StepAxis2Placement3D position )
: base( name )
{
Position = position;
}
@@ -55,15 +54,17 @@ namespace StgSharp.Model.Step
get { return _position; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_position = value;
}
}
public void FromInstance( StepElementarySurface entity )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
base.FromInstance( entity );
_position = entity.Position;
yield return Position;
}
}
+23 -24
View File
@@ -28,45 +28,45 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepEllipse : StepConic, IExpConvertableFrom<StepEllipse>
public class StepEllipse : StepConic
{
private StepAxis2Placement _position;
private StepEllipse( StepModel model ) : base( model ) { }
private StepEllipse() : base( string.Empty ) { }
public StepEllipse(
StepModel model,
string name,
StepAxis2Placement position,
float semiAxis1,
float semiAxis2 )
: base( model )
double semiAxis1,
double semiAxis2 )
: base( name )
{
Position = position;
SemiAxis1 = semiAxis1;
SemiAxis2 = semiAxis2;
}
public float SemiAxis1 { get; set; }
public double SemiAxis1 { get; set; }
public float SemiAxis2 { get; set; }
public double SemiAxis2 { get; set; }
public StepAxis2Placement Position
{
get { return _position; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_position = value;
}
@@ -74,23 +74,22 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Ellipse;
public void FromInstance( StepEllipse entity )
internal static StepEllipse CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
SemiAxis1 = entity.SemiAxis1;
SemiAxis2 = entity.SemiAxis2;
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 static StepEllipse FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepEllipse ellipse = new StepEllipse( binder );
enumerator.AssertEnumeratorCount( 4 );
ellipse.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
ellipse.Position = binder[ ( enumerator[ 1 ] as StepEntityInstanceNode )!.Id ]as StepAxis2Placement2D;
ellipse.SemiAxis1 = ( enumerator[ 2 ] as ExpRealNumberNode )!.Value;
ellipse.SemiAxis2 = ( enumerator[ 3 ] as ExpRealNumberNode )!.Value;
return ellipse;
yield return Position;
}
}
+4 -18
View File
@@ -28,34 +28,20 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFace>
public abstract class StepFace : StepTopologicalRepresentationItem
{
public StepFace( StepModel model ) : base( model ) { }
public StepFace( string name ) : base( name ) { }
public List<StepFaceBound> Bounds { get; private set; } = new List<StepFaceBound>();
public override StepItemType ItemType => StepItemType.Face;
public void FromInstance( StepFace entity )
{
base.FromInstance( entity );
Bounds = entity.Bounds;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepFace";
}
public List<StepFaceBound> Bounds { get; } = new List<StepFaceBound>();
}
}
+16 -19
View File
@@ -28,22 +28,21 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFaceBound>
public class StepFaceBound : StepTopologicalRepresentationItem
{
public StepFaceBound( StepModel model ) : base( model ) { }
protected StepFaceBound() : base( string.Empty ) { }
public StepFaceBound( StepModel model, StepLoop bound, bool orientation )
: base( model )
public StepFaceBound( string name, StepLoop bound, bool orientation )
: base( name )
{
Bound = bound;
Orientation = orientation;
@@ -55,22 +54,20 @@ namespace StgSharp.Model.Step
public StepLoop Bound { get; set; }
public void FromInstance( StepFaceBound entity )
internal static StepFaceBound CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
Bound = entity.Bound;
Orientation = entity.Orientation;
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 static StepFaceBound FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepFaceBound faceBound = new StepFaceBound( binder );
faceBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
faceBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop;
faceBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value;
return faceBound;
yield return Bound;
}
}
+15 -19
View File
@@ -28,37 +28,33 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom<StepFaceOuterBound>
public class StepFaceOuterBound : StepFaceBound
{
private StepFaceOuterBound( StepModel model ) : base( model ) { }
private StepFaceOuterBound() : base() { }
public StepFaceOuterBound( StepModel model, StepLoop bound, bool orientation )
: base( model, bound, orientation ) { }
public StepFaceOuterBound( string name, StepLoop bound, bool orientation )
: base( name, bound, orientation ) { }
public override StepItemType ItemType => StepItemType.FaceOuterBound;
public void FromInstance( StepFaceOuterBound entity )
internal static new StepFaceOuterBound CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static new StepFaceOuterBound FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepFaceOuterBound faceOuterBound = new StepFaceOuterBound( binder );
faceOuterBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
faceOuterBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop;
faceOuterBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value;
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;
}
+4 -12
View File
@@ -28,31 +28,23 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepFaceSurface : StepFace, IExpConvertableFrom<StepFaceSurface>
public abstract class StepFaceSurface : StepFace
{
public StepFaceSurface( StepModel model ) : base( model ) { }
public StepFaceSurface( string name ) : base( name ) { }
public bool SameSense { get; set; }
public StepSurface FaceGeometry { get; set; }
public void FromInstance( StepFaceSurface entity )
{
base.FromInstance( entity );
SameSense = entity.SameSense;
FaceGeometry = entity.FaceGeometry;
}
}
}
@@ -28,27 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepGeometricRepresentationItem>
public abstract class StepGeometricRepresentationItem : StepRepresentationItem
{
public StepGeometricRepresentationItem( StepModel model ) : base( model ) { }
public void FromInstance( StepGeometricRepresentationItem entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) ||
entityName is "StepGeometricRepresentationItem";
}
protected StepGeometricRepresentationItem( string name ) : base( name ) { }
}
}
+131
View File
@@ -0,0 +1,131 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepItemType.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Modeling.Items
{
public enum StepItemType
{
AdvancedFace,
AxisPlacement2D,
AxisPlacement3D,
BSplineCurveWithKnots,
CartesianPoint,
Circle,
CylindricalSurface,
Direction,
EdgeCurve,
EdgeLoop,
Ellipse,
FaceBound,
FaceOuterBound,
Line,
OrientedEdge,
Plane,
Vector,
VertexPoint
}
internal static class StepItemTypeExtensions
{
public const string AdvancedFaceText = "ADVANCED_FACE";
public const string Axis2Placement2DText = "AXIS2_PLACEMENT_2D";
public const string Axis2Placement3DText = "AXIS2_PLACEMENT_3D";
public const string BSplineCurveWithKnotsText = "B_SPLINE_CURVE_WITH_KNOTS";
public const string CartesianPointText = "CARTESIAN_POINT";
public const string CircleText = "CIRCLE";
public const string CylindricalSurfaceText = "CYLINDRICAL_SURFACE";
public const string DirectionText = "DIRECTION";
public const string EdgeCurveText = "EDGE_CURVE";
public const string EdgeLoopText = "EDGE_LOOP";
public const string EllipseText = "ELLIPSE";
public const string FaceBoundText = "FACE_BOUND";
public const string FaceOuterBoundText = "FACE_OUTER_BOUND";
public const string LineText = "LINE";
public const string OrientedEdgeText = "ORIENTED_EDGE";
public const string PlaneText = "PLANE";
public const string VectorText = "VECTOR";
public const string VertexPointText = "VERTEX_POINT";
public static string GetItemTypeString( this StepItemType type )
{
switch( type )
{
case StepItemType.AdvancedFace:
return AdvancedFaceText;
case StepItemType.AxisPlacement2D:
return Axis2Placement2DText;
case StepItemType.AxisPlacement3D:
return Axis2Placement3DText;
case StepItemType.BSplineCurveWithKnots:
return BSplineCurveWithKnotsText;
case StepItemType.CartesianPoint:
return CartesianPointText;
case StepItemType.Circle:
return CircleText;
case StepItemType.CylindricalSurface:
return CylindricalSurfaceText;
case StepItemType.Direction:
return DirectionText;
case StepItemType.EdgeCurve:
return EdgeCurveText;
case StepItemType.EdgeLoop:
return EdgeLoopText;
case StepItemType.Ellipse:
return EllipseText;
case StepItemType.FaceBound:
return FaceBoundText;
case StepItemType.FaceOuterBound:
return FaceOuterBoundText;
case StepItemType.Line:
return LineText;
case StepItemType.OrientedEdge:
return OrientedEdgeText;
case StepItemType.Plane:
return PlaneText;
case StepItemType.Vector:
return VectorText;
case StepItemType.VertexPoint:
return VertexPointText;
default:
throw new InvalidOperationException( $"Unexpected item type {type}" );
}
}
}
}
+58 -54
View File
@@ -1,53 +1,52 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepLine.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//-----------------------------------------------------------------------
// 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:
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Model.Step;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepLine : StepCurve, IExpConvertableFrom<StepLine>
public class StepLine : StepCurve
{
private StepCartesianPoint _point;
private StepVector _vector;
private StepLine(StepModel model) : base(model) { }
private StepLine() : base( string.Empty ) { }
public StepLine(StepModel model, StepCartesianPoint point, StepVector vector)
: base(model)
public StepLine( string label, StepCartesianPoint point, StepVector vector )
: base( label )
{
Point = point;
Vector = vector;
@@ -58,7 +57,10 @@ namespace StgSharp.Model.Step
get { return _point; }
set
{
ArgumentNullException.ThrowIfNull(value);
if( value == null ) {
throw new ArgumentNullException();
}
_point = value;
}
}
@@ -70,51 +72,53 @@ namespace StgSharp.Model.Step
get { return _vector; }
set
{
ArgumentNullException.ThrowIfNull(value);
if( value == null ) {
throw new ArgumentNullException();
}
_vector = value;
}
}
public void FromInstance(StepLine entity)
{
base.FromInstance(entity);
Point = entity.Point;
Vector = entity.Vector;
}
public static StepLine FromPoints(
StepModel model,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
float z2 )
{
StepCartesianPoint start = new StepCartesianPoint(model, x1, y1, z1);
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 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(
model, new StepDirection(model, dxn, dyn, dzn), length);
return new StepLine(model, start, vector);
string.Empty, new StepDirection( string.Empty, dxn, dyn, dzn ), length );
return new StepLine( string.Empty, start, vector );
}
internal static StepLine FromSyntax(StepModel binder, ExpSyntaxNode syntaxList)
internal static StepLine CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepLine line = new StepLine(binder);
enumerator.AssertEnumeratorCount(3);
line.Name = (enumerator[0]as ExpStringNode)!.Value;
line.Point = binder[enumerator[1]] as StepCartesianPoint;
line.Vector = binder[enumerator[2]] as StepVector;
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;
}
}
}
+3 -9
View File
@@ -28,21 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom<StepLoop>
public abstract class StepLoop : StepTopologicalRepresentationItem
{
protected StepLoop( StepModel model ) : base( model ) { }
public void FromInstance( StepLoop entity )
{
base.FromInstance( entity );
}
public StepLoop( string name ) : base( name ) { }
}
}
+26 -22
View File
@@ -28,31 +28,28 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using Microsoft.Win32.SafeHandles;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepOrientedEdge : StepEdge, IExpConvertableFrom<StepOrientedEdge>
public class StepOrientedEdge : StepEdge
{
private StepEdge _edgeElement;
private StepOrientedEdge( StepModel model ) : base( model ) { }
private StepOrientedEdge() { }
public StepOrientedEdge(
StepModel model,
string name,
StepVertex edgeStart,
StepVertex edgeEnd,
StepEdge edgeElement,
bool orientation )
: base( model, edgeStart, edgeEnd )
: base( name, edgeStart, edgeEnd )
{
EdgeElement = edgeElement;
Orientation = orientation;
@@ -75,24 +72,31 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.OrientedEdge;
public void FromInstance( StepOrientedEdge entity )
internal static StepOrientedEdge CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
EdgeElement = entity.EdgeElement;
Orientation = entity.Orientation;
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 static StepOrientedEdge FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepOrientedEdge orientedEdge = new StepOrientedEdge( binder );
enumerator.AssertEnumeratorCount( 5 );
orientedEdge.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
orientedEdge.EdgeStart = binder[ enumerator[ 1 ] ]as StepVertex;
orientedEdge.EdgeEnd = binder[ enumerator[ 2 ] ] as StepVertex;
orientedEdge.EdgeElement = binder[ enumerator[ 3 ] ] as StepEdge;
orientedEdge.Orientation = ( enumerator[ 4 ]as ExpBoolNode )!.Value;
return orientedEdge;
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeElement;
}
}
+3 -35
View File
@@ -28,47 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepPlacement : StepGeometricRepresentationItem, IExpConvertableFrom<StepPlacement>
public abstract class StepPlacement : StepGeometricRepresentationItem
{
private StepCartesianPoint _location;
public StepPlacement( StepModel model ) : base( model ) { }
public StepPlacement( StepModel model, StepCartesianPoint location )
: base( model )
{
_location = location;
}
public StepCartesianPoint Location
{
get { return _location; }
set
{
ArgumentNullException.ThrowIfNull( value );
_location = value;
}
}
public void FromInstance( StepPlacement entity )
{
base.FromInstance( entity );
this.Location = entity.Location;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepPlacement";
}
protected StepPlacement( string name ) : base( name ) { }
}
}
+11 -17
View File
@@ -28,35 +28,29 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepPlane : StepElementarySurface, IExpConvertableFrom<StepPlane>
public class StepPlane : StepElementarySurface
{
public StepPlane( StepModel model ) : base( model ) { }
private StepPlane() : base() { }
public StepPlane( StepModel model, StepAxis2Placement3D position )
: base( model, position ) { }
public StepPlane( string name, StepAxis2Placement3D position ) : base( name, position ) { }
public override StepItemType ItemType => StepItemType.Plane;
public void FromInstance( StepPlane entity )
internal static StepPlane CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
}
internal static StepPlane FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepPlane plane = new StepPlane( binder );
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepPlane plane = new StepPlane();
enumerator.AssertEnumeratorCount( 2 );
plane.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
plane.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement3D;
plane.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => plane.Position = v.AsType<StepAxis2Placement3D>() );
return plane;
}
+3 -18
View File
@@ -28,30 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom<StepPoint>
public abstract class StepPoint : StepGeometricRepresentationItem
{
public StepPoint( StepModel model ) : base( model ) { }
public override StepItemType ItemType => StepItemType.Point;
public void FromInstance( StepPoint entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepPoint";
}
protected StepPoint( string name ) : base( name ) { }
}
}
@@ -28,35 +28,29 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom<StepRepresentationItem>
public abstract partial class StepRepresentationItem
{
protected StepRepresentationItem( StepModel model )
protected StepRepresentationItem( string name )
{
Context = model;
Name = name;
}
public override StepItemType ItemType => StepItemType.PresentationItem;
public abstract StepItemType ItemType { get; }
public void FromInstance( StepRepresentationItem entity )
{
base.FromInstance( entity );
}
public string Name { get; set; }
public virtual bool IsConvertableTo( string entityName )
internal virtual IEnumerable<StepRepresentationItem> GetReferencedItems()
{
return entityName == "StepRepresentationItem";
yield break;
}
}
@@ -0,0 +1,127 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="StepRepresentationItem_FromTypedParameter.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Diagnostics;
namespace StgSharp.Modeling.Items
{
public abstract partial class StepRepresentationItem
{
internal static HashSet<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;
}
}
}
+3 -14
View File
@@ -28,26 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepSurface>
public abstract class StepSurface : StepGeometricRepresentationItem
{
protected StepSurface( StepModel model ) : base( model ) { }
public void FromInstance( StepSurface entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepSurface";
}
public StepSurface( string name ) : base( name ) { }
}
}
@@ -28,29 +28,15 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepTopologicalRepresentationItem>
public abstract class StepTopologicalRepresentationItem : StepRepresentationItem
{
protected StepTopologicalRepresentationItem( StepModel model ) : base( model ) { }
public void FromInstance( StepTopologicalRepresentationItem entity )
{
base.FromInstance( entity );
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) ||
entityName == "StepTopologicalRepresentationItem";
}
protected StepTopologicalRepresentationItem( string name ) : base( name ) { }
}
}
+52 -65
View File
@@ -1,52 +1,51 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepTriple.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//-----------------------------------------------------------------------
// 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:
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public abstract class StepTriple : StepPoint, IExpConvertableFrom<StepTriple>
public abstract class StepTriple : StepPoint
{
private Vec3 _coord;
protected StepTriple(StepModel model) : this(model, 0.0f, 0.0f, 0.0f) { }
protected StepTriple() : this( string.Empty, 0.0f, 0.0f, 0.0f ) { }
protected StepTriple(StepModel model, float x, float y, float z)
: base(model)
protected StepTriple( string name, float x, float y, float z )
: base( name )
{
X = x;
Y = y;
@@ -73,28 +72,19 @@ namespace StgSharp.Model.Step
protected abstract int MinimumValueCount { get; }
public bool Equals(StepTriple other)
public bool Equals( StepTriple other )
{
if (other is null) {
if( ( object )other == null ) {
return false;
}
return ItemType == other.ItemType &&
X == other.X &&
Y == other.Y &&
Z == other.Z &&
Name == other.Name;
return ItemType == other.ItemType && X == other.X && Y == other.Y && Z == other.Z && Name ==
other.Name;
}
public override bool Equals(object obj)
public override bool Equals( object obj )
{
return (obj is StepTriple triple) && Equals(triple);
}
public void FromInstance(StepTriple entity)
{
base.FromInstance(entity);
_coord = entity._coord;
return ( obj is StepTriple triple ) && Equals( triple );
}
public override int GetHashCode()
@@ -102,38 +92,35 @@ namespace StgSharp.Model.Step
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
public override bool IsConvertableTo(string entityName)
internal static StepTriple AssignTo( StepTriple triple, ExpNode values )
{
return base.IsConvertableTo(entityName) || entityName == "StepTriple";
}
internal static T AssignTo<T>(T triple, ExpSyntaxNode values) where T: StepTriple
{
ExpNodePresidentEnumerator enumerator = values.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(2);
triple.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator pointValues = enumerator[1].TupleToPresidentEnumerator();
pointValues.AssertEnumeratorCount(triple.MinimumValueCount, 3);
triple._coord = StepDataParser.ToVector3D(pointValues[0]);
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)
public static bool operator !=( StepTriple left, StepTriple right )
{
return !(left == right);
return !( left == right );
}
public static bool operator ==(StepTriple left, StepTriple right)
public static bool operator ==( StepTriple left, StepTriple right )
{
if (ReferenceEquals(left, right)) {
if( ReferenceEquals( left, right ) ) {
return true;
}
if (left is null || right is null) {
if( ( object )left == null || ( object )right == null ) {
return false;
}
return left.Equals(right);
return left.Equals( right );
}
}
+19 -18
View File
@@ -28,24 +28,23 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepVector : StepGeometricRepresentationItem, IExpConvertableFrom<StepVector>
public class StepVector : StepGeometricRepresentationItem
{
private StepDirection _direction;
private StepVector( StepModel model ) : base( model ) { }
private StepVector() : base( string.Empty ) { }
public StepVector( StepModel model, StepDirection direction, double length )
: base( model )
public StepVector( string name, StepDirection direction, double length )
: base( name )
{
Direction = direction;
Length = length;
@@ -58,7 +57,9 @@ namespace StgSharp.Model.Step
get { return _direction; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_direction = value;
}
@@ -66,21 +67,21 @@ namespace StgSharp.Model.Step
public override StepItemType ItemType => StepItemType.Vector;
public void FromInstance( StepVector entity )
internal static StepVector CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
{
base.FromInstance( entity );
_direction = entity.Direction;
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 static StepVector FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepVector vector = new StepVector( binder );
enumerator.AssertEnumeratorCount( 3 );
vector.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
vector.Direction = binder[ enumerator[ 1 ] ] as StepDirection;
vector.Length = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value;
return vector;
yield return Direction;
}
}
+28 -38
View File
@@ -1,52 +1,42 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepVertex.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//-----------------------------------------------------------------------
// 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:
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Model.Step;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepVertex : StepTopologicalRepresentationItem, IExpConvertableFrom<StepVertex>
public abstract class StepVertex : StepTopologicalRepresentationItem
{
public StepVertex(StepModel model) : base(model) { }
public Vec3 Vertex { get; set; }
public void FromInstance(StepVertex entity)
{
base.FromInstance(entity);
Vertex = entity.Vertex;
}
protected StepVertex( string name ) : base( name ) { }
}
}
+21 -17
View File
@@ -28,24 +28,23 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public class StepVertexPoint : StepVertex, IExpConvertableFrom<StepVertexPoint>
public class StepVertexPoint : StepVertex
{
private StepCartesianPoint _location;
public StepVertexPoint( StepModel model ) : base( model ) { }
private StepVertexPoint() : base( string.Empty ) { }
public StepVertexPoint( StepModel model, StepCartesianPoint location )
: base( model )
public StepVertexPoint( string name, StepCartesianPoint location )
: base( name )
{
Location = location;
}
@@ -55,27 +54,32 @@ namespace StgSharp.Model.Step
get { return _location; }
set
{
ArgumentNullException.ThrowIfNull( value );
if( value == null ) {
throw new ArgumentNullException();
}
_location = value;
}
}
public override StepItemType ItemType => StepItemType.VertexPoint;
public void FromInstance( StepVertexPoint entity )
internal static StepVertexPoint CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
{
base.FromInstance( entity );
this.Location = entity.Location;
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 static StepVertexPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepVertexPoint vertex = new StepVertexPoint( binder );
enumerator.AssertEnumeratorCount( 2 );
vertex.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
vertex.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint;
return vertex;
yield return Location;
}
}