old data
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user