Merge from branch giga

This commit is contained in:
Nitload
2025-08-31 10:42:51 +08:00
parent 1fc687f7d0
commit 1a0ccdd8cb
1619 changed files with 2812 additions and 733136 deletions
+21 -22
View File
@@ -28,47 +28,46 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Linq;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepAdvancedFace : StepFaceSurface
public class StepAdvancedFace : StepFaceSurface, IExpConvertableFrom<StepAdvancedFace>
{
private StepAdvancedFace() : base( string.Empty ) { }
public StepAdvancedFace( string name ) : base( name ) { }
public StepAdvancedFace( StepModel model ) : base( model ) { }
public override StepItemType ItemType => StepItemType.AdvancedFace;
internal static StepAdvancedFace CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepAdvancedFace entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAdvancedFace face = new StepAdvancedFace();
enumerator.AssertEnumeratorCount( 4 );
face.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
base.FromInstance( entity );
}
object boundsList = enumerator.Values[ 1 ].GetValueList();
internal static StepAdvancedFace FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepAdvancedFace face = new StepAdvancedFace( binder );
enumerator.AssertEnumeratorCount( 4 );
face.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
ExpNodePresidentEnumerator boundsList = enumerator[ 1 ].TupleToPresidentEnumerator();
face.Bounds.Clear();
face.Bounds
.AddRange(
Enumerable.Range( 0, enumerator.Values.Count )
.Select( _ => ( StepFaceBound )null ) );
for( int i = 0; i < enumerator.Values.Count; i++ )
Enumerable.Range( 0, enumerator.Count ).Select( _ => ( StepFaceBound )null ) );
for( int i = 0; i < boundsList.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
enumerator.Values[ j ], v => face.Bounds[ j ] = v.AsType<StepFaceBound>() );
face.Bounds[ j ] = binder[ boundsList[ j ] ] as StepFaceBound;
}
binder.BindValue(
enumerator.Values[ 2 ], v => face.FaceGeometry = v.AsType<StepSurface>() );
face.SameSense = ( enumerator.Values[ 3 ] as ExpBoolNode )!.Value;
face.FaceGeometry = binder[ enumerator[ 2 ] ] as StepSurface;
face.SameSense = ( enumerator[ 3 ] as ExpBoolNode )!.Value;
return face;
}
+10 -20
View File
@@ -28,45 +28,35 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepAxis2Placement : StepPlacement
public 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;
}
}
protected StepAxis2Placement( StepModel model ) : base( model ) { }
public StepDirection RefDirection
{
get { return _refDirection; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_refDirection = value;
}
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepAxis2Placement";
}
}
}
@@ -28,24 +28,25 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepAxis2Placement2D : StepAxis2Placement
public class StepAxis2Placement2D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement2D>
{
private StepAxis2Placement2D() : base( string.Empty ) { }
private StepAxis2Placement2D( StepModel model ) : base( model ) { }
public StepAxis2Placement2D(
string label,
StepModel model,
StepCartesianPoint location,
StepDirection direction )
: base( label )
: base( model )
{
Location = location;
RefDirection = direction;
@@ -53,25 +54,24 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.AxisPlacement2D;
internal static StepAxis2Placement2D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepAxis2Placement2D entity )
{
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;
base.FromInstance( entity );
Location = entity.Location;
RefDirection = entity.RefDirection;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepAxis2Placement2D FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
yield return Location;
yield return RefDirection;
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;
}
}
@@ -28,27 +28,28 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepAxis2Placement3D : StepAxis2Placement
public class StepAxis2Placement3D : StepAxis2Placement, IExpConvertableFrom<StepAxis2Placement3D>
{
private StepDirection _axis;
private StepAxis2Placement3D() : base( string.Empty ) { }
private StepAxis2Placement3D( StepModel model ) : base( model ) { }
public StepAxis2Placement3D(
string name,
StepModel model,
StepCartesianPoint location,
StepDirection axis,
StepDirection refDirection )
: base( name )
: base( model )
{
Location = location;
Axis = axis;
@@ -60,37 +61,35 @@ namespace StgSharp.Modeling.Items
get { return _axis; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_axis = value;
}
}
public override StepItemType ItemType => StepItemType.AxisPlacement3D;
internal static StepAxis2Placement3D CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public override bool IsConvertableTo( string entityTypeName )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepAxis2Placement3D axis = new StepAxis2Placement3D();
throw new NotImplementedException();
}
internal static StepAxis2Placement3D FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepAxis2Placement3D axis = new StepAxis2Placement3D( binder );
enumerator.AssertEnumeratorCount( 4 );
axis.Name = enumerator.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>() );
axis.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
axis.Location = binder[ enumerator[ 1 ] ] as StepCartesianPoint;
axis.Axis = binder[ enumerator[ 2 ] ] as StepDirection;
axis.RefDirection = binder[ enumerator[ 3 ] ] as StepDirection;
return axis;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
void IExpConvertableFrom<StepAxis2Placement3D>.FromInstance( StepAxis2Placement3D entity )
{
yield return Location;
yield return Axis;
yield return RefDirection;
throw new NotImplementedException();
}
}
+57 -48
View File
@@ -28,6 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -36,7 +37,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public enum StepBSplineCurveForm
{
@@ -50,81 +51,89 @@ namespace StgSharp.Modeling.Items
}
;
public abstract class StepBSplineCurve : StepBoundedCurve
public static class StepExpEnumValue
{
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 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 POLYLINE_FORM = "POLYLINE_FORM";
private const string UNSPECIFIED = "UNSPECIFIED";
internal static HashSet<string> AllPossibleValue { get; } = [
CIRCULAR_ARC,
ELLIPTIC_ARC,
HYPERBOLIC_ARC,
PARABOLIC_ARC,
POLYLINE_FORM,
UNSPECIFIED,
];
public StepBSplineCurve( string name, IEnumerable<StepCartesianPoint> controlPoints )
: base( name )
}
public class StepBSplineCurve : StepBoundedCurve, IExpConvertableFrom<StepBSplineCurve>
{
public StepBSplineCurve( StepModel model, params StepCartesianPoint[] controlPoints )
: this( model, ( IEnumerable<StepCartesianPoint> )controlPoints ) { }
public StepBSplineCurve( StepModel model, IEnumerable<StepCartesianPoint> controlPoints )
: base( model )
{
ControlPointsList.AddRange( controlPoints );
}
public 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 List<StepCartesianPoint> ControlPointsList { get; private set; }
= new List<StepCartesianPoint>();
public StepBSplineCurveForm CurveForm { get; set; } = StepBSplineCurveForm.Unspecified;
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
public void FromInstance( StepBSplineCurve entity )
{
return ControlPointsList;
base.FromInstance( entity );
this.Degree = entity.Degree;
this.ClosedCurve = entity.ClosedCurve;
this.ControlPointsList = entity.ControlPointsList;
this.SelfIntersect = entity.SelfIntersect;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepBSplineCurve";
}
protected static string GetCurveFormString( StepBSplineCurveForm form )
{
switch( form )
return form switch
{
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();
StepBSplineCurveForm.Polyline => StepExpEnumValue.POLYLINE_FORM,
StepBSplineCurveForm.CircularArc => StepExpEnumValue.CIRCULAR_ARC,
StepBSplineCurveForm.EllipticalArc => StepExpEnumValue.ELLIPTIC_ARC,
StepBSplineCurveForm.ParabolicArc => StepExpEnumValue.PARABOLIC_ARC,
StepBSplineCurveForm.HyperbolicArc => StepExpEnumValue.HYPERBOLIC_ARC,
StepBSplineCurveForm.Unspecified => StepExpEnumValue.UNSPECIFIED,
_ => throw new NotImplementedException(),
};
}
protected static StepBSplineCurveForm ParseCurveForm( string enumerationValue )
{
switch( enumerationValue.ToUpperInvariant() )
return enumerationValue.ToUpperInvariant() switch
{
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;
}
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,
};
}
}
@@ -28,6 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
@@ -36,7 +37,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public enum StepKnotType
{
@@ -50,7 +51,7 @@ namespace StgSharp.Modeling.Items
;
public class StepBSplineCurveWithKnots : StepBSplineCurve
public class StepBSplineCurveWithKnots : StepBSplineCurve, IExpConvertableFrom<StepBSplineCurveWithKnots>
{
private const string PIECEWISE_BEZIER_KNOTS = "PIECEWISE_BEZIER_KNOTS";
@@ -60,12 +61,14 @@ namespace StgSharp.Modeling.Items
private const string UNSPECIFIED = "UNSPECIFIED";
public StepBSplineCurveWithKnots(
string name,
StepModel model,
IEnumerable<StepCartesianPoint> controlPoints )
: base( name, controlPoints ) { }
: base( model, controlPoints ) { }
public StepBSplineCurveWithKnots( string name, params StepCartesianPoint[] controlPoints )
: base( name, controlPoints ) { }
public StepBSplineCurveWithKnots(
StepModel model,
params StepCartesianPoint[] controlPoints )
: base( model, controlPoints ) { }
public List<int> KnotMultiplicities { get; } = new List<int>();
@@ -75,79 +78,79 @@ namespace StgSharp.Modeling.Items
public StepKnotType KnotSpec { get; set; } = StepKnotType.Unspecified;
internal static StepBSplineCurveWithKnots CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepBSplineCurveWithKnots entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( 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();
enumerator.AssertEnumeratorCount( 9 );
object controlPointsList = enumerator.Values[ 2 ].GetValueList();
ExpNodePresidentEnumerator controlPointsList = enumerator[ 2 ].TupleToPresidentEnumerator(
);
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;
binder, new StepCartesianPoint[controlPointsList.Count] );
spline.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
spline.Degree = ( enumerator[ 1 ] as ExpIntNode )!.Value;
for( int i = 0; i < controlPointsList.Values.Count; i++ )
for( int i = 0; i < controlPointsList.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
controlPointsList.Values[ j ],
v => spline.ControlPointsList[ j ] = v.AsType<StepCartesianPoint>() );
spline.ControlPointsList[ j ] = binder[ controlPointsList[ j ] ]as StepCartesianPoint;
}
spline.CurveForm = ParseCurveForm( enumerator.Values[ 3 ].GetEnumerationValue() );
spline.ClosedCurve = ( enumerator.Values[ 4 ] as ExpBoolNode )!.Value;
spline.SelfIntersect = ( enumerator.Values[ 5 ]as ExpBoolNode )!.Value;
spline.CurveForm = ParseCurveForm( enumerator[ 3 ].CodeConvertTemplate );
spline.ClosedCurve = ( enumerator[ 4 ] as ExpBoolNode )!.Value;
spline.SelfIntersect = ( enumerator[ 5 ]as ExpBoolNode )!.Value;
object knotMultiplicitiesList = enumerator.Values[ 6 ].GetValueList();
ExpNodePresidentEnumerator knotMultiplicitiesList = enumerator[ 6 ].TupleToPresidentEnumerator(
);
spline.KnotMultiplicities.Clear();
for( int i = 0; i < knotMultiplicitiesList.Values.Count; i++ ) {
spline.KnotMultiplicities
.Add( knotMultiplicitiesList.Values[ i ].GetIntegerValue() );
for( int i = 0; i < knotMultiplicitiesList.Count; i++ ) {
spline.KnotMultiplicities.Add( ( knotMultiplicitiesList[ i ]as ExpIntNode )!.Value );
}
object knotslist = enumerator.Values[ 7 ].GetValueList();
ExpNodePresidentEnumerator knotsList = enumerator[ 7 ].TupleToPresidentEnumerator();
spline.Knots.Clear();
for( int i = 0; i < knotslist.Values.Count; i++ ) {
spline.Knots.Add( knotslist.Values[ i ].GetRealVavlue() );
for( int i = 0; i < knotsList.Count; i++ ) {
spline.Knots.Add( ( knotsList[ i ]as ExpRealNumberNode )!.Value );
}
spline.KnotSpec = ParseKnotSpec( enumerator.Values[ 8 ].GetEnumerationValue() );
spline.KnotSpec = ParseKnotSpec( enumerator[ 8 ].CodeConvertTemplate );
return spline;
}
private static string GetKnotSpec( StepKnotType spec )
{
switch( spec )
return spec switch
{
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();
StepKnotType.UniformKnots => UNIFORM_KNOTS,
StepKnotType.QuasiUniformKnots => QUASI_UNIFORM_KNOTS,
StepKnotType.PiecewiseBezierKnots => PIECEWISE_BEZIER_KNOTS,
StepKnotType.Unspecified => UNSPECIFIED,
_ => throw new NotImplementedException(),
};
}
private static StepKnotType ParseKnotSpec( string enumerationValue )
{
switch( enumerationValue.ToUpperInvariant() )
return enumerationValue.ToUpperInvariant() switch
{
case UNIFORM_KNOTS:
return StepKnotType.UniformKnots;
case QUASI_UNIFORM_KNOTS:
return StepKnotType.QuasiUniformKnots;
case PIECEWISE_BEZIER_KNOTS:
return StepKnotType.PiecewiseBezierKnots;
default:
return StepKnotType.Unspecified;
}
UNIFORM_KNOTS => StepKnotType.UniformKnots,
QUASI_UNIFORM_KNOTS => StepKnotType.QuasiUniformKnots,
PIECEWISE_BEZIER_KNOTS => StepKnotType.PiecewiseBezierKnots,
_ => StepKnotType.Unspecified,
};
}
}
+19 -3
View File
@@ -28,15 +28,31 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepBoundedCurve : StepCurve
public class StepBoundedCurve : StepCurve, IExpConvertableFrom<StepBoundedCurve>
{
protected StepBoundedCurve( string name ) : base( name ) { }
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 );
}
}
}
@@ -28,27 +28,32 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepCartesianPoint : StepTriple
public class StepCartesianPoint : StepTriple, IExpConvertableFrom<StepCartesianPoint>
{
private StepCartesianPoint() { }
private StepCartesianPoint( StepModel model ) : base( model ) { }
public StepCartesianPoint( string label, float x, float y, float z )
: base( label, x, y, z ) { }
public StepCartesianPoint( StepModel model, float x, float y, float z )
: base( model, x, y, z ) { }
public override StepItemType ItemType => StepItemType.CartesianPoint;
protected override int MinimumValueCount => 1;
internal static StepCartesianPoint CreateFromSyntaxList( ExpNode syntaxList )
public void FromInstance( StepCartesianPoint entity )
{
return ( StepCartesianPoint )AssignTo( new StepCartesianPoint(), syntaxList );
base.FromInstance( entity );
}
internal static StepCartesianPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
return AssignTo( new StepCartesianPoint( binder ), syntaxList );
}
}
+17 -16
View File
@@ -28,23 +28,24 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepCircle : StepConic
public class StepCircle : StepConic, IExpConvertableFrom<StepCircle>
{
private StepAxis2Placement _position;
private StepCircle() : base( string.Empty ) { }
public StepCircle( StepModel model ) : base( model ) { }
public StepCircle( string label, StepAxis2Placement position, float radius )
: base( label )
public StepCircle( StepModel model, StepAxis2Placement position, float radius )
: base( model )
{
Position = position;
Radius = radius;
@@ -67,21 +68,21 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.Circle;
internal static StepCircle CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepCircle entity )
{
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;
base.FromInstance( entity );
this._position = entity.Position;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepCircle FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
yield return Position;
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;
}
}
+16 -3
View File
@@ -28,15 +28,28 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepConic : StepCurve
public class StepConic : StepCurve, IExpConvertableFrom<StepConic>
{
protected StepConic( string name ) : base( name ) { }
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 );
}
}
}
+16 -3
View File
@@ -28,15 +28,28 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepCurve : StepGeometricRepresentationItem
public class StepCurve : StepGeometricRepresentationItem, IExpConvertableFrom<StepCurve>
{
protected StepCurve( string name ) : base( name ) { }
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";
}
}
}
@@ -28,21 +28,25 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepCylindricalSurface : StepElementarySurface
public class StepCylindricalSurface : StepElementarySurface, IExpConvertableFrom<StepCylindricalSurface>
{
private StepCylindricalSurface() : base() { }
public StepCylindricalSurface( StepModel model ) : base( model ) { }
public StepCylindricalSurface( string name, StepAxis2Placement3D position, float radius )
: base( name, position )
public StepCylindricalSurface(
StepModel model,
StepAxis2Placement3D position,
float radius )
: base( model, position )
{
Radius = radius;
}
@@ -51,17 +55,22 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.CylindricalSurface;
internal static StepRepresentationItem CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepCylindricalSurface entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
base.FromInstance( entity );
Radius = entity.Radius;
}
internal static StepRepresentationItem FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 3 );
StepCylindricalSurface surface = new StepCylindricalSurface();
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;
StepCylindricalSurface surface = new StepCylindricalSurface( binder );
surface.Name = ( enumerator[ 0 ] as ExpStringNode )!.Value;
surface.Position = binder[ enumerator[ 1 ] ]as StepAxis2Placement3D;
surface.Radius = ( enumerator[ 2 ]as ExpRealNumberNode )!.Value;
return surface;
}
+13 -7
View File
@@ -28,26 +28,32 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepDirection : StepTriple
public class StepDirection : StepTriple, IExpConvertableFrom<StepDirection>
{
private StepDirection() { }
private StepDirection( StepModel model ) : base( model ) { }
public StepDirection( string name, float x, float y, float z ) : base( name, x, y, z ) { }
public StepDirection( StepModel model, float x, float y, float z )
: base( model, x, y, z ) { }
public override StepItemType ItemType => StepItemType.Direction;
protected override int MinimumValueCount => 2;
internal static StepDirection CreateFromSyntaxList( ExpNode syntaxList )
public void FromInstance( StepDirection entity )
{
return ( StepDirection )AssignTo( new StepDirection(), syntaxList );
base.FromInstance( entity );
}
internal static StepDirection FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
return AssignTo( new StepDirection( binder ), syntaxList );
}
}
+15 -13
View File
@@ -28,21 +28,22 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepEdge : StepTopologicalRepresentationItem
public class StepEdge : StepTopologicalRepresentationItem, IExpConvertableFrom<StepEdge>
{
protected StepEdge() : base( string.Empty ) { }
protected StepEdge( StepModel model ) : base( model ) { }
protected StepEdge( string name, StepVertex edgeStart, StepVertex edgeEnd )
: base( name )
protected StepEdge( StepModel model, StepVertex edgeStart, StepVertex edgeEnd )
: base( model )
{
EdgeStart = edgeStart;
EdgeEnd = edgeEnd;
@@ -52,15 +53,16 @@ namespace StgSharp.Modeling.Items
public StepVertex EdgeEnd { get; set; }
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
public void FromInstance( StepEdge entity )
{
if( EdgeStart != null ) {
yield return EdgeStart;
}
base.FromInstance( entity );
EdgeStart = entity.EdgeStart;
EdgeEnd = entity.EdgeEnd;
}
if( EdgeEnd != null ) {
yield return EdgeEnd;
}
public override bool IsConvertableTo( string entityName )
{
return base.IsConvertableTo( entityName ) || entityName == "StepEdge";
}
}
+20 -28
View File
@@ -28,28 +28,29 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepEdgeCurve : StepEdge
public class StepEdgeCurve : StepEdge, IExpConvertableFrom<StepEdgeCurve>
{
private StepCurve _edgeGeometry;
private StepEdgeCurve() : base() { }
private StepEdgeCurve( StepModel model ) : base( model ) { }
public StepEdgeCurve(
string name,
StepModel model,
StepVertex edgeStart,
StepVertex edgeEnd,
StepCurve edgeGeometry,
bool isSameSense )
: base( name, edgeStart, edgeEnd )
: base( model, edgeStart, edgeEnd )
{
EdgeGeometry = edgeGeometry;
IsSameSense = isSameSense;
@@ -62,39 +63,30 @@ namespace StgSharp.Modeling.Items
get { return _edgeGeometry; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_edgeGeometry = value;
}
}
public override StepItemType ItemType => StepItemType.EdgeCurve;
internal static StepEdgeCurve CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepEdgeCurve entity )
{
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;
base.FromInstance( entity );
EdgeGeometry = entity.EdgeGeometry;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepEdgeCurve FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeGeometry;
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;
}
}
+20 -21
View File
@@ -28,54 +28,53 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepEdgeLoop : StepLoop
public class StepEdgeLoop : StepLoop, IExpConvertableFrom<StepEdgeCurve>
{
public StepEdgeLoop( string name, IEnumerable<StepOrientedEdge> edgeList )
: base( name )
public StepEdgeLoop( StepModel model, params StepOrientedEdge[] edgeList )
: this( model, ( IEnumerable<StepOrientedEdge> )edgeList ) { }
public StepEdgeLoop( StepModel model, IEnumerable<StepOrientedEdge> edgeList )
: base( model )
{
EdgeList = new List<StepOrientedEdge>( edgeList );
}
public 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 )
public void FromInstance( StepEdgeCurve entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
base.FromInstance( entity );
}
internal static StepEdgeLoop FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
enumerator.AssertEnumeratorCount( 2 );
object edgeSyntaxList = enumerator.Values[ 1 ].GetValueList();
ExpNodePresidentEnumerator edgeSyntaxList = enumerator[ 1 ].TupleToPresidentEnumerator();
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++ )
binder, new StepOrientedEdge[edgeSyntaxList.Count] );
edgeLoop.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
for( int i = 0; i < edgeSyntaxList.Count; i++ )
{
int j = i; // capture to avoid rebinding
binder.BindValue(
edgeSyntaxList.Values[ j ],
v => edgeLoop.EdgeList[ j ] = v.AsType<StepOrientedEdge>() );
edgeLoop.EdgeList[ j ] = binder[ edgeSyntaxList[ j ] ] as StepOrientedEdge;
}
return edgeLoop;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
return EdgeList;
}
}
}
@@ -28,23 +28,24 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepElementarySurface : StepSurface
public class StepElementarySurface : StepSurface, IExpConvertableFrom<StepElementarySurface>
{
private StepAxis2Placement3D _position;
protected StepElementarySurface() : base( string.Empty ) { }
public StepElementarySurface( StepModel model ) : base( model ) { }
public StepElementarySurface( string name, StepAxis2Placement3D position )
: base( name )
public StepElementarySurface( StepModel model, StepAxis2Placement3D position )
: base( model )
{
Position = position;
}
@@ -54,17 +55,15 @@ namespace StgSharp.Modeling.Items
get { return _position; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_position = value;
}
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
public void FromInstance( StepElementarySurface entity )
{
yield return Position;
base.FromInstance( entity );
_position = entity.Position;
}
}
+24 -23
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.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepEllipse : StepConic
public class StepEllipse : StepConic, IExpConvertableFrom<StepEllipse>
{
private StepAxis2Placement _position;
private StepEllipse() : base( string.Empty ) { }
private StepEllipse( StepModel model ) : base( model ) { }
public StepEllipse(
StepModel model,
string name,
StepAxis2Placement position,
double semiAxis1,
double semiAxis2 )
: base( name )
float semiAxis1,
float semiAxis2 )
: base( model )
{
Position = position;
SemiAxis1 = semiAxis1;
SemiAxis2 = semiAxis2;
}
public double SemiAxis1 { get; set; }
public float SemiAxis1 { get; set; }
public double SemiAxis2 { get; set; }
public float SemiAxis2 { get; set; }
public StepAxis2Placement Position
{
get { return _position; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_position = value;
}
@@ -74,22 +74,23 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.Ellipse;
internal static StepEllipse CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepEllipse entity )
{
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;
base.FromInstance( entity );
SemiAxis1 = entity.SemiAxis1;
SemiAxis2 = entity.SemiAxis2;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepEllipse FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
yield return Position;
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;
}
}
+18 -4
View File
@@ -28,20 +28,34 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
using System.Linq;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepFace : StepTopologicalRepresentationItem
public class StepFace : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFace>
{
public StepFace( string name ) : base( name ) { }
public StepFace( StepModel model ) : base( model ) { }
public List<StepFaceBound> Bounds { get; } = new List<StepFaceBound>();
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";
}
}
}
+19 -16
View File
@@ -28,21 +28,22 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepFaceBound : StepTopologicalRepresentationItem
public class StepFaceBound : StepTopologicalRepresentationItem, IExpConvertableFrom<StepFaceBound>
{
protected StepFaceBound() : base( string.Empty ) { }
public StepFaceBound( StepModel model ) : base( model ) { }
public StepFaceBound( string name, StepLoop bound, bool orientation )
: base( name )
public StepFaceBound( StepModel model, StepLoop bound, bool orientation )
: base( model )
{
Bound = bound;
Orientation = orientation;
@@ -54,20 +55,22 @@ namespace StgSharp.Modeling.Items
public StepLoop Bound { get; set; }
internal static StepFaceBound CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepFaceBound entity )
{
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;
base.FromInstance( entity );
Bound = entity.Bound;
Orientation = entity.Orientation;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepFaceBound FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
yield return Bound;
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;
}
}
+19 -15
View File
@@ -28,33 +28,37 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepFaceOuterBound : StepFaceBound
public class StepFaceOuterBound : StepFaceBound, IExpConvertableFrom<StepFaceOuterBound>
{
private StepFaceOuterBound() : base() { }
private StepFaceOuterBound( StepModel model ) : base( model ) { }
public StepFaceOuterBound( string name, StepLoop bound, bool orientation )
: base( name, bound, orientation ) { }
public StepFaceOuterBound( StepModel model, StepLoop bound, bool orientation )
: base( model, bound, orientation ) { }
public override StepItemType ItemType => StepItemType.FaceOuterBound;
internal static new StepFaceOuterBound CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepFaceOuterBound entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
base.FromInstance( entity );
}
internal static new StepFaceOuterBound FromSyntax(
StepModel binder,
ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( 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;
StepFaceOuterBound faceOuterBound = new StepFaceOuterBound( binder );
faceOuterBound.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
faceOuterBound.Bound = binder[ enumerator[ 1 ] ] as StepLoop;
faceOuterBound.Orientation = ( enumerator[ 2 ]as ExpBoolNode )!.Value;
return faceOuterBound;
}
+12 -4
View File
@@ -28,23 +28,31 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepFaceSurface : StepFace
public class StepFaceSurface : StepFace, IExpConvertableFrom<StepFaceSurface>
{
public StepFaceSurface( string name ) : base( name ) { }
public StepFaceSurface( StepModel model ) : base( model ) { }
public bool SameSense { get; set; }
public StepSurface FaceGeometry { get; set; }
public void FromInstance( StepFaceSurface entity )
{
base.FromInstance( entity );
SameSense = entity.SameSense;
FaceGeometry = entity.FaceGeometry;
}
}
}
@@ -28,15 +28,27 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepGeometricRepresentationItem : StepRepresentationItem
public class StepGeometricRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepGeometricRepresentationItem>
{
protected StepGeometricRepresentationItem( string name ) : base( name ) { }
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";
}
}
}
-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}" );
}
}
}
}
+54 -58
View File
@@ -1,52 +1,53 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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.Math;
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepLine : StepCurve
public class StepLine : StepCurve, IExpConvertableFrom<StepLine>
{
private StepCartesianPoint _point;
private StepVector _vector;
private StepLine() : base( string.Empty ) { }
private StepLine(StepModel model) : base(model) { }
public StepLine( string label, StepCartesianPoint point, StepVector vector )
: base( label )
public StepLine(StepModel model, StepCartesianPoint point, StepVector vector)
: base(model)
{
Point = point;
Vector = vector;
@@ -57,10 +58,7 @@ namespace StgSharp.Modeling.Items
get { return _point; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull(value);
_point = value;
}
}
@@ -72,53 +70,51 @@ namespace StgSharp.Modeling.Items
get { return _vector; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull(value);
_vector = value;
}
}
public void FromInstance(StepLine entity)
{
base.FromInstance(entity);
Point = entity.Point;
Vector = entity.Vector;
}
public static StepLine FromPoints(
StepModel model,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2 )
float z2)
{
StepCartesianPoint start = new StepCartesianPoint( string.Empty, x1, y1, z1 );
StepCartesianPoint start = new StepCartesianPoint(model, 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(
string.Empty, new StepDirection( string.Empty, dxn, dyn, dzn ), length );
return new StepLine( string.Empty, start, vector );
model, new StepDirection(model, dxn, dyn, dzn), length);
return new StepLine(model, start, vector);
}
internal static StepLine CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
internal static StepLine FromSyntax(StepModel binder, ExpSyntaxNode 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>() );
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator(syntaxList);
StepLine line = new StepLine(binder);
enumerator.AssertEnumeratorCount(3);
line.Name = (enumerator[0]as ExpStringNode)!.Value;
line.Point = binder[enumerator[1]] as StepCartesianPoint;
line.Vector = binder[enumerator[2]] as StepVector;
return line;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
{
yield return Point;
yield return Vector;
}
}
}
+9 -3
View File
@@ -28,15 +28,21 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepLoop : StepTopologicalRepresentationItem
public abstract class StepLoop : StepTopologicalRepresentationItem, IExpConvertableFrom<StepLoop>
{
public StepLoop( string name ) : base( name ) { }
protected StepLoop( StepModel model ) : base( model ) { }
public void FromInstance( StepLoop entity )
{
base.FromInstance( entity );
}
}
}
+22 -26
View File
@@ -28,28 +28,31 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using Microsoft.Win32.SafeHandles;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepOrientedEdge : StepEdge
public class StepOrientedEdge : StepEdge, IExpConvertableFrom<StepOrientedEdge>
{
private StepEdge _edgeElement;
private StepOrientedEdge() { }
private StepOrientedEdge( StepModel model ) : base( model ) { }
public StepOrientedEdge(
string name,
StepModel model,
StepVertex edgeStart,
StepVertex edgeEnd,
StepEdge edgeElement,
bool orientation )
: base( name, edgeStart, edgeEnd )
: base( model, edgeStart, edgeEnd )
{
EdgeElement = edgeElement;
Orientation = orientation;
@@ -72,31 +75,24 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.OrientedEdge;
internal static StepOrientedEdge CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepOrientedEdge entity )
{
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;
base.FromInstance( entity );
EdgeElement = entity.EdgeElement;
Orientation = entity.Orientation;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepOrientedEdge FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
foreach( StepRepresentationItem item in base.GetReferencedItems() ) {
yield return item;
}
yield return EdgeElement;
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;
}
}
+35 -3
View File
@@ -28,15 +28,47 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
using System;
namespace StgSharp.Model.Step
{
public abstract class StepPlacement : StepGeometricRepresentationItem
public class StepPlacement : StepGeometricRepresentationItem, IExpConvertableFrom<StepPlacement>
{
protected StepPlacement( string name ) : base( name ) { }
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";
}
}
}
+17 -11
View File
@@ -28,29 +28,35 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Geometries;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepPlane : StepElementarySurface
public class StepPlane : StepElementarySurface, IExpConvertableFrom<StepPlane>
{
private StepPlane() : base() { }
public StepPlane( StepModel model ) : base( model ) { }
public StepPlane( string name, StepAxis2Placement3D position ) : base( name, position ) { }
public StepPlane( StepModel model, StepAxis2Placement3D position )
: base( model, position ) { }
public override StepItemType ItemType => StepItemType.Plane;
internal static StepPlane CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepPlane entity )
{
ExpNodeNextEnumerator enumerator = new ExpNodeNextEnumerator( syntaxList );
StepPlane plane = new StepPlane();
base.FromInstance( entity );
}
internal static StepPlane FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
ExpNodePresidentEnumerator enumerator = new ExpNodePresidentEnumerator( syntaxList );
StepPlane plane = new StepPlane( binder );
enumerator.AssertEnumeratorCount( 2 );
plane.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
binder.BindValue(
enumerator.Values[ 1 ], v => plane.Position = v.AsType<StepAxis2Placement3D>() );
plane.Name = ( enumerator[ 0 ]as ExpStringNode )!.Value;
plane.Position = binder[ enumerator[ 1 ] ] as StepAxis2Placement3D;
return plane;
}
+18 -3
View File
@@ -28,15 +28,30 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
using System;
namespace StgSharp.Model.Step
{
public abstract class StepPoint : StepGeometricRepresentationItem
public class StepPoint : StepGeometricRepresentationItem, IExpConvertableFrom<StepPoint>
{
protected StepPoint( string name ) : base( name ) { }
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";
}
}
}
@@ -28,29 +28,35 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Script;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract partial class StepRepresentationItem
public class StepRepresentationItem : StepEntityBase, IExpConvertableFrom<StepRepresentationItem>
{
protected StepRepresentationItem( string name )
protected StepRepresentationItem( StepModel model )
{
Name = name;
Context = model;
}
public abstract StepItemType ItemType { get; }
public override StepItemType ItemType => StepItemType.PresentationItem;
public string Name { get; set; }
internal virtual IEnumerable<StepRepresentationItem> GetReferencedItems()
public void FromInstance( StepRepresentationItem entity )
{
yield break;
base.FromInstance( entity );
}
public virtual bool IsConvertableTo( string entityName )
{
return entityName == "StepRepresentationItem";
}
}
@@ -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;
}
}
}
+14 -3
View File
@@ -28,15 +28,26 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepSurface : StepGeometricRepresentationItem
public class StepSurface : StepGeometricRepresentationItem, IExpConvertableFrom<StepSurface>
{
public StepSurface( string name ) : base( name ) { }
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";
}
}
}
@@ -28,15 +28,29 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
namespace StgSharp.Modeling.Items
using System;
namespace StgSharp.Model.Step
{
public abstract class StepTopologicalRepresentationItem : StepRepresentationItem
public class StepTopologicalRepresentationItem : StepRepresentationItem, IExpConvertableFrom<StepTopologicalRepresentationItem>
{
protected StepTopologicalRepresentationItem( string name ) : base( name ) { }
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";
}
}
}
+65 -52
View File
@@ -1,51 +1,52 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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.Math;
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepTriple : StepPoint
public abstract class StepTriple : StepPoint, IExpConvertableFrom<StepTriple>
{
private Vec3 _coord;
protected StepTriple() : this( string.Empty, 0.0f, 0.0f, 0.0f ) { }
protected StepTriple(StepModel model) : this(model, 0.0f, 0.0f, 0.0f) { }
protected StepTriple( string name, float x, float y, float z )
: base( name )
protected StepTriple(StepModel model, float x, float y, float z)
: base(model)
{
X = x;
Y = y;
@@ -72,19 +73,28 @@ namespace StgSharp.Modeling.Items
protected abstract int MinimumValueCount { get; }
public bool Equals( StepTriple other )
public bool Equals(StepTriple other)
{
if( ( object )other == null ) {
if (other is 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 );
return (obj is StepTriple triple) && Equals(triple);
}
public void FromInstance(StepTriple entity)
{
base.FromInstance(entity);
_coord = entity._coord;
}
public override int GetHashCode()
@@ -92,35 +102,38 @@ namespace StgSharp.Modeling.Items
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
internal static StepTriple AssignTo( StepTriple triple, ExpNode values )
public override bool IsConvertableTo(string entityName)
{
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 base.IsConvertableTo(entityName) || entityName == "StepTriple";
}
internal static T AssignTo<T>(T triple, ExpSyntaxNode values) where T: StepTriple
{
ExpNodePresidentEnumerator enumerator = values.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(2);
triple.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator pointValues = enumerator[1].TupleToPresidentEnumerator();
pointValues.AssertEnumeratorCount(triple.MinimumValueCount, 3);
triple._coord = StepDataParser.ToVector3D(pointValues[0]);
return triple;
}
public static bool operator !=( StepTriple left, StepTriple right )
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( ( object )left == null || ( object )right == null ) {
if (left is null || right is null) {
return false;
}
return left.Equals( right );
return left.Equals(right);
}
}
+18 -19
View File
@@ -28,23 +28,24 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepVector : StepGeometricRepresentationItem
public class StepVector : StepGeometricRepresentationItem, IExpConvertableFrom<StepVector>
{
private StepDirection _direction;
private StepVector() : base( string.Empty ) { }
private StepVector( StepModel model ) : base( model ) { }
public StepVector( string name, StepDirection direction, double length )
: base( name )
public StepVector( StepModel model, StepDirection direction, double length )
: base( model )
{
Direction = direction;
Length = length;
@@ -57,9 +58,7 @@ namespace StgSharp.Modeling.Items
get { return _direction; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_direction = value;
}
@@ -67,21 +66,21 @@ namespace StgSharp.Modeling.Items
public override StepItemType ItemType => StepItemType.Vector;
internal static StepVector CreateFromSyntaxList( StepBinder binder, ExpNode syntaxList )
public void FromInstance( StepVector entity )
{
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;
base.FromInstance( entity );
_direction = entity.Direction;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepVector FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
yield return Direction;
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;
}
}
+38 -28
View File
@@ -1,42 +1,52 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// 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.Modeling.Items
namespace StgSharp.Model.Step
{
public abstract class StepVertex : StepTopologicalRepresentationItem
public class StepVertex : StepTopologicalRepresentationItem, IExpConvertableFrom<StepVertex>
{
protected StepVertex( string name ) : base( name ) { }
public StepVertex(StepModel model) : base(model) { }
public Vec3 Vertex { get; set; }
public void FromInstance(StepVertex entity)
{
base.FromInstance(entity);
Vertex = entity.Vertex;
}
}
}
+17 -21
View File
@@ -28,23 +28,24 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System;
using System.Collections.Generic;
namespace StgSharp.Modeling.Items
namespace StgSharp.Model.Step
{
public class StepVertexPoint : StepVertex
public class StepVertexPoint : StepVertex, IExpConvertableFrom<StepVertexPoint>
{
private StepCartesianPoint _location;
private StepVertexPoint() : base( string.Empty ) { }
public StepVertexPoint( StepModel model ) : base( model ) { }
public StepVertexPoint( string name, StepCartesianPoint location )
: base( name )
public StepVertexPoint( StepModel model, StepCartesianPoint location )
: base( model )
{
Location = location;
}
@@ -54,32 +55,27 @@ namespace StgSharp.Modeling.Items
get { return _location; }
set
{
if( value == null ) {
throw new ArgumentNullException();
}
ArgumentNullException.ThrowIfNull( value );
_location = value;
}
}
public override StepItemType ItemType => StepItemType.VertexPoint;
internal static StepVertexPoint CreateFromSyntaxList(
StepBinder binder,
ExpNode syntaxList )
public void FromInstance( StepVertexPoint entity )
{
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;
base.FromInstance( entity );
this.Location = entity.Location;
}
internal override IEnumerable<StepRepresentationItem> GetReferencedItems()
internal static StepVertexPoint FromSyntax( StepModel binder, ExpSyntaxNode syntaxList )
{
yield return Location;
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;
}
}