This commit is contained in:
Nitload
2025-08-25 09:50:30 +08:00
parent bd0e31e922
commit 1359ff4ecc
1630 changed files with 738486 additions and 2399 deletions
+52 -65
View File
@@ -1,52 +1,51 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="StepTriple.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//-----------------------------------------------------------------------
// file="StepTriple.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the ¡°Software¡±), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// THE SOFTWARE IS PROVIDED ¡°AS IS¡±,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
using StgSharp.Mathematics;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using StgSharp.Model.Step;
using StgSharp.Script;
using StgSharp.Script.Express;
using System.Collections.Generic;
namespace StgSharp.Model.Step
namespace StgSharp.Modeling.Items
{
public abstract class StepTriple : StepPoint, IExpConvertableFrom<StepTriple>
public abstract class StepTriple : StepPoint
{
private Vec3 _coord;
protected StepTriple(StepModel model) : this(model, 0.0f, 0.0f, 0.0f) { }
protected StepTriple() : this( string.Empty, 0.0f, 0.0f, 0.0f ) { }
protected StepTriple(StepModel model, float x, float y, float z)
: base(model)
protected StepTriple( string name, float x, float y, float z )
: base( name )
{
X = x;
Y = y;
@@ -73,28 +72,19 @@ namespace StgSharp.Model.Step
protected abstract int MinimumValueCount { get; }
public bool Equals(StepTriple other)
public bool Equals( StepTriple other )
{
if (other is null) {
if( ( object )other == null ) {
return false;
}
return ItemType == other.ItemType &&
X == other.X &&
Y == other.Y &&
Z == other.Z &&
Name == other.Name;
return ItemType == other.ItemType && X == other.X && Y == other.Y && Z == other.Z && Name ==
other.Name;
}
public override bool Equals(object obj)
public override bool Equals( object obj )
{
return (obj is StepTriple triple) && Equals(triple);
}
public void FromInstance(StepTriple entity)
{
base.FromInstance(entity);
_coord = entity._coord;
return ( obj is StepTriple triple ) && Equals( triple );
}
public override int GetHashCode()
@@ -102,38 +92,35 @@ namespace StgSharp.Model.Step
return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode();
}
public override bool IsConvertableTo(string entityName)
internal static StepTriple AssignTo( StepTriple triple, ExpNode values )
{
return base.IsConvertableTo(entityName) || entityName == "StepTriple";
}
internal static T AssignTo<T>(T triple, ExpSyntaxNode values) where T: StepTriple
{
ExpNodePresidentEnumerator enumerator = values.ToPresidentEnumerator();
enumerator.AssertEnumeratorCount(2);
triple.Name = (enumerator[0]as ExpStringNode)!.Value;
ExpNodePresidentEnumerator pointValues = enumerator[1].TupleToPresidentEnumerator();
pointValues.AssertEnumeratorCount(triple.MinimumValueCount, 3);
triple._coord = StepDataParser.ToVector3D(pointValues[0]);
ExpNodeNextEnumerator enumerator = values.GetEnumerator();
enumerator.AssertEnumeratorCount( 2 );
triple.Name = enumerator.Values[ 0 ].CodeConvertTemplate;
object pointValues = enumerator.Values[ 1 ].GetValueList();
pointValues.AssertEnumeratorCount( triple.MinimumValueCount, 3 );
triple.X = pointValues.GetRealValueOrDefault( 0 );
triple.Y = pointValues.GetRealValueOrDefault( 1 );
triple.Z = pointValues.GetRealValueOrDefault( 2 );
return triple;
}
public static bool operator !=(StepTriple left, StepTriple right)
public static bool operator !=( StepTriple left, StepTriple right )
{
return !(left == right);
return !( left == right );
}
public static bool operator ==(StepTriple left, StepTriple right)
public static bool operator ==( StepTriple left, StepTriple right )
{
if (ReferenceEquals(left, right)) {
if( ReferenceEquals( left, right ) ) {
return true;
}
if (left is null || right is null) {
if( ( object )left == null || ( object )right == null ) {
return false;
}
return left.Equals(right);
return left.Equals( right );
}
}