Required keyword on various types (#76)
* Made bounding boxes nullable * Required keyword for Polyline * Curve * others * Interval * Breps! * more changes * removed resolved todo comment * Fixed comment * resolved alan's comments * surfaces
This commit is contained in:
@@ -45,7 +45,7 @@ public sealed class ElementShape : Base
|
||||
public double arcAngle { get; set; }
|
||||
public bool? bodyFlag { get; set; }
|
||||
public double length { get; set; }
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
@@ -66,6 +66,6 @@ public sealed class ElementShape : Base
|
||||
|
||||
public List<PolylineSegment> polylineSegments { get; set; } = new();
|
||||
public double length { get; set; }
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,10 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
this.startAngle = startAngle;
|
||||
this.endAngle = endAngle;
|
||||
this.angleRadians = angleRadians;
|
||||
domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0);
|
||||
domain =
|
||||
angleRadians > 0
|
||||
? new Interval { start = 0, end = angleRadians }
|
||||
: new Interval { start = angleRadians, end = 0 };
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
@@ -64,7 +67,14 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
string? applicationId = null
|
||||
)
|
||||
: this(
|
||||
new Plane(startPoint, new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0), units),
|
||||
new Plane
|
||||
{
|
||||
origin = startPoint,
|
||||
normal = new Vector(0, 0, 1),
|
||||
xdir = new Vector(1, 0, 0),
|
||||
ydir = new Vector(0, 1, 0),
|
||||
units = units
|
||||
},
|
||||
startPoint,
|
||||
endPoint,
|
||||
angleRadians,
|
||||
@@ -106,7 +116,10 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
this.startPoint = startPoint;
|
||||
this.endPoint = endPoint;
|
||||
this.angleRadians = angleRadians;
|
||||
domain = angleRadians > 0 ? new Interval(0, angleRadians) : new Interval(angleRadians, 0);
|
||||
domain =
|
||||
angleRadians > 0
|
||||
? new Interval { start = 0, end = angleRadians }
|
||||
: new Interval { start = angleRadians, end = 0 };
|
||||
this.applicationId = applicationId;
|
||||
|
||||
// find chord and chord angle which may differ from the arc angle
|
||||
@@ -204,7 +217,7 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
public string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Interval domain { get; set; } = new(0, 0);
|
||||
public Interval domain { get; set; } = new() { start = 0, end = 0 };
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double length { get; set; }
|
||||
@@ -213,7 +226,7 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Arc transformed)
|
||||
@@ -279,7 +292,7 @@ public class Arc : Base, IHasBoundingBox, ICurve, IHasArea, ITransformable<Arc>
|
||||
startAngle = list[3],
|
||||
endAngle = list[4],
|
||||
angleRadians = list[5],
|
||||
domain = new Interval(list[6], list[7]),
|
||||
domain = new Interval { start = list[6], end = list[7] },
|
||||
units = Units.GetUnitFromEncoding(list[list.Count - 1]),
|
||||
plane = Plane.FromList(list.GetRange(8, 13))
|
||||
};
|
||||
|
||||
@@ -10,54 +10,25 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Box")]
|
||||
public class Box : Base, IHasVolume, IHasArea, IHasBoundingBox
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Box() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Box"/> instance with a <see cref="Plane"/> and coordinate intervals for all 3 axis {x , y , z}
|
||||
/// </summary>
|
||||
/// <param name="basePlane">The plane the box will be oriented by.</param>
|
||||
/// <param name="xSize">The range of coordinates (min, max) for the X axis</param>
|
||||
/// <param name="ySize">The range of coordinates (min, max) for the Y axis</param>
|
||||
/// <param name="zSize">The range of coordinates (min, max) for the Z axis</param>
|
||||
/// <param name="units">The units the coordinates are in.</param>
|
||||
/// <param name="applicationId">The unique application ID of the object.</param>
|
||||
public Box(
|
||||
Plane basePlane,
|
||||
Interval xSize,
|
||||
Interval ySize,
|
||||
Interval zSize,
|
||||
string units = Units.Meters,
|
||||
string? applicationId = null
|
||||
)
|
||||
{
|
||||
this.basePlane = basePlane;
|
||||
this.xSize = xSize;
|
||||
this.ySize = ySize;
|
||||
this.zSize = zSize;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the plane that defines the orientation of the <see cref="Box"/>
|
||||
/// </summary>
|
||||
public Plane basePlane { get; set; }
|
||||
public required Plane basePlane { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Interval"/> that defines the min and max coordinate in the X direction
|
||||
/// </summary>
|
||||
public Interval xSize { get; set; }
|
||||
public required Interval xSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Interval"/> that defines the min and max coordinate in the Y direction
|
||||
/// </summary>
|
||||
public Interval ySize { get; set; }
|
||||
public required Interval ySize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="Interval"/> that defines the min and max coordinate in the Y direction
|
||||
/// </summary>
|
||||
public Interval zSize { get; set; }
|
||||
public required Interval zSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The units this object's coordinates are in.
|
||||
@@ -65,13 +36,13 @@ public class Box : Base, IHasVolume, IHasArea, IHasBoundingBox
|
||||
/// <remarks>
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </remarks>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; }
|
||||
public Box? bbox { get; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double volume { get; set; }
|
||||
|
||||
@@ -14,52 +14,19 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Brep")]
|
||||
public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<Brep>, IDisplayValue<List<Mesh>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of <see cref="Brep"/> class.
|
||||
/// </summary>
|
||||
public Brep()
|
||||
{
|
||||
Surfaces = new List<Surface>();
|
||||
Curve2D = new List<ICurve>();
|
||||
Curve3D = new List<ICurve>();
|
||||
|
||||
Vertices = new List<Point>();
|
||||
Edges = new List<BrepEdge>();
|
||||
Loops = new List<BrepLoop>();
|
||||
Trims = new List<BrepTrim>();
|
||||
Faces = new List<BrepFace>();
|
||||
|
||||
IsClosed = false;
|
||||
Orientation = BrepOrientation.None;
|
||||
}
|
||||
|
||||
public Brep(string provenance, Mesh displayValue, string units = Units.Meters, string? applicationId = null)
|
||||
: this(provenance, new List<Mesh> { displayValue }, units, applicationId) { }
|
||||
|
||||
public Brep(string provenance, List<Mesh> displayValues, string units = Units.Meters, string? applicationId = null)
|
||||
: this()
|
||||
{
|
||||
this.provenance = provenance;
|
||||
displayValue = displayValues;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public string provenance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unit's this object's coordinates are in.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </remarks>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of surfaces in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<Surface> Surfaces { get; set; }
|
||||
public required List<Surface> Surfaces { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s surfaces.
|
||||
@@ -70,14 +37,10 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
get
|
||||
{
|
||||
var list = new List<double>();
|
||||
if (Surfaces != null)
|
||||
foreach (var srf in Surfaces)
|
||||
{
|
||||
foreach (var srf in Surfaces)
|
||||
{
|
||||
list.AddRange(srf.ToList());
|
||||
}
|
||||
list.AddRange(srf.ToList());
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
set
|
||||
@@ -106,7 +69,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of 3-dimensional curves in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<ICurve> Curve3D { get; set; }
|
||||
public required List<ICurve> Curve3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s 3D curves.
|
||||
@@ -131,7 +94,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of 2-dimensional UV curves in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<ICurve> Curve2D { get; set; }
|
||||
public required List<ICurve> Curve2D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s 2D curves.
|
||||
@@ -156,7 +119,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of vertices in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<Point> Vertices { get; set; }
|
||||
public required List<Point> Vertices { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s vertices.
|
||||
@@ -169,7 +132,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<double>();
|
||||
var list = new List<double>((Vertices.Count * 3) + 1);
|
||||
list.Add(Units.GetEncodingFromUnit(units));
|
||||
foreach (var vertex in Vertices)
|
||||
{
|
||||
@@ -183,6 +146,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
if (value != null)
|
||||
{
|
||||
var units = value.Count % 3 == 0 ? Units.None : Units.GetUnitFromEncoding(value[0]);
|
||||
Vertices = new(value.Count / 3);
|
||||
for (int i = value.Count % 3 == 0 ? 0 : 1; i < value.Count; i += 3)
|
||||
{
|
||||
Vertices.Add(new Point(value[i], value[i + 1], value[i + 2], units));
|
||||
@@ -195,7 +159,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of edges in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<BrepEdge> Edges { get; set; }
|
||||
public required List<BrepEdge> Edges { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s edges.
|
||||
@@ -215,8 +179,8 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
ints.Add(e.StartIndex);
|
||||
ints.Add(e.EndIndex);
|
||||
ints.Add(Convert.ToInt32(e.ProxyCurveIsReversed));
|
||||
ints.Add(e.Domain.start ?? 0);
|
||||
ints.Add(e.Domain.end ?? 1);
|
||||
ints.Add(e.Domain.start);
|
||||
ints.Add(e.Domain.end);
|
||||
ints.AddRange(e.TrimIndices.Select(Convert.ToDouble).Cast<double?>());
|
||||
return ints.Prepend(ints.Count);
|
||||
})
|
||||
@@ -242,11 +206,23 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
var domainStart = loopValues[4];
|
||||
var domainEnd = loopValues[5];
|
||||
Interval domain =
|
||||
domainStart.HasValue && domainEnd.HasValue ? new(domainStart.Value, domainEnd.Value) : new(0, 1);
|
||||
domainStart.HasValue && domainEnd.HasValue
|
||||
? new() { start = domainStart.Value, end = domainEnd.Value }
|
||||
: Interval.UnitInterval;
|
||||
|
||||
var trimIndices = loopValues.GetRange(6, loopValues.Count - 6).Select(d => Convert.ToInt32(d)).ToArray();
|
||||
|
||||
var edge = new BrepEdge(this, curve3dIndex, trimIndices, startIndex, endIndex, proxyReversed, domain);
|
||||
var edge = new BrepEdge
|
||||
{
|
||||
Brep = this,
|
||||
Curve3dIndex = curve3dIndex,
|
||||
TrimIndices = trimIndices,
|
||||
StartIndex = startIndex,
|
||||
EndIndex = endIndex,
|
||||
ProxyCurveIsReversed = proxyReversed,
|
||||
Domain = domain
|
||||
};
|
||||
|
||||
Edges.Add(edge);
|
||||
i += n + 1;
|
||||
}
|
||||
@@ -257,7 +233,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of closed UV loops in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<BrepLoop> Loops { get; set; }
|
||||
public required List<BrepLoop> Loops { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s loops.
|
||||
@@ -296,7 +272,13 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
var faceIndex = loopValues[0];
|
||||
var type = (BrepLoopType)loopValues[1];
|
||||
var trimIndices = loopValues.GetRange(2, loopValues.Count - 2);
|
||||
var loop = new BrepLoop(this, faceIndex, trimIndices, type);
|
||||
var loop = new BrepLoop
|
||||
{
|
||||
Brep = this,
|
||||
FaceIndex = faceIndex,
|
||||
TrimIndices = trimIndices,
|
||||
Type = type
|
||||
};
|
||||
Loops.Add(loop);
|
||||
i += n + 1;
|
||||
}
|
||||
@@ -307,7 +289,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// Gets or sets the list of UV trim segments for each surface in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<BrepTrim> Trims { get; set; }
|
||||
public required List<BrepTrim> Trims { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s trims.
|
||||
@@ -320,7 +302,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
{
|
||||
get
|
||||
{
|
||||
List<int> list = new();
|
||||
List<int> list = new(Trims.Count * TRIMS_ENCODING_LENGTH);
|
||||
foreach (var trim in Trims)
|
||||
{
|
||||
list.Add(trim.EdgeIndex);
|
||||
@@ -343,11 +325,12 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
return;
|
||||
}
|
||||
|
||||
var list = new List<BrepTrim>();
|
||||
for (int i = 0; i < value.Count; i += 9)
|
||||
var list = new List<BrepTrim>(value.Count / TRIMS_ENCODING_LENGTH);
|
||||
for (int i = 0; i < value.Count; i += TRIMS_ENCODING_LENGTH)
|
||||
{
|
||||
var trim = new BrepTrim
|
||||
{
|
||||
Brep = this,
|
||||
EdgeIndex = value[i],
|
||||
StartIndex = value[i + 1],
|
||||
EndIndex = value[i + 2],
|
||||
@@ -356,7 +339,8 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
CurveIndex = value[i + 5],
|
||||
IsoStatus = value[i + 6],
|
||||
TrimType = (BrepTrimType)value[i + 7],
|
||||
IsReversed = value[i + 8] == 1
|
||||
IsReversed = value[i + 8] == 1,
|
||||
Domain = Interval.UnitInterval, //TODO: This is a problem, see CXPLA-28
|
||||
};
|
||||
list.Add(trim);
|
||||
}
|
||||
@@ -365,11 +349,13 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
}
|
||||
}
|
||||
|
||||
private const int TRIMS_ENCODING_LENGTH = 9;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of faces in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public List<BrepFace> Faces { get; set; }
|
||||
public required List<BrepFace> Faces { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the flat list of numbers representing the <see cref="Brep"/>'s faces.
|
||||
@@ -394,11 +380,11 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
.ToList();
|
||||
set
|
||||
{
|
||||
Faces = new List<BrepFace>();
|
||||
if (value == null || value.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Faces = new List<BrepFace>();
|
||||
|
||||
var i = 0;
|
||||
while (i < value.Count)
|
||||
@@ -410,7 +396,14 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
var outerLoopIndex = faceValues[1];
|
||||
var orientationIsReversed = faceValues[2] == 1;
|
||||
var loopIndices = faceValues.GetRange(3, faceValues.Count - 3);
|
||||
var face = new BrepFace(this, surfIndex, loopIndices, outerLoopIndex, orientationIsReversed);
|
||||
var face = new BrepFace
|
||||
{
|
||||
Brep = this,
|
||||
SurfaceIndex = surfIndex,
|
||||
LoopIndices = loopIndices,
|
||||
OuterLoopIndex = outerLoopIndex,
|
||||
OrientationReversed = orientationIsReversed
|
||||
};
|
||||
Faces.Add(face);
|
||||
i += n + 1;
|
||||
}
|
||||
@@ -420,22 +413,22 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
/// <summary>
|
||||
/// Gets or sets if this <see cref="Brep"/> instance is closed or not.
|
||||
/// </summary>
|
||||
public bool IsClosed { get; set; }
|
||||
public required bool IsClosed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of surfaces in this <see cref="Brep"/> instance.
|
||||
/// </summary>
|
||||
public BrepOrientation Orientation { get; set; }
|
||||
public required BrepOrientation Orientation { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DetachProperty]
|
||||
public List<Mesh> displayValue { get; set; }
|
||||
public required List<Mesh> displayValue { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double volume { get; set; }
|
||||
@@ -476,7 +469,7 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
}
|
||||
|
||||
// transform vertices
|
||||
var transformedVertices = new List<Point>();
|
||||
var transformedVertices = new List<Point>(Vertices.Count);
|
||||
foreach (var vertex in Vertices)
|
||||
{
|
||||
vertex.TransformTo(transform, out Point transformedVertex);
|
||||
@@ -485,7 +478,6 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
|
||||
transformed = new Brep
|
||||
{
|
||||
provenance = provenance,
|
||||
units = units,
|
||||
displayValue = displayValues,
|
||||
Surfaces = surfaces,
|
||||
@@ -504,45 +496,63 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
foreach (var e in Edges)
|
||||
{
|
||||
transformed.Edges.Add(
|
||||
new BrepEdge(
|
||||
transformed,
|
||||
e.Curve3dIndex,
|
||||
e.TrimIndices,
|
||||
e.StartIndex,
|
||||
e.EndIndex,
|
||||
e.ProxyCurveIsReversed,
|
||||
e.Domain
|
||||
)
|
||||
new BrepEdge
|
||||
{
|
||||
Brep = transformed,
|
||||
Curve3dIndex = e.Curve3dIndex,
|
||||
TrimIndices = e.TrimIndices,
|
||||
StartIndex = e.StartIndex,
|
||||
EndIndex = e.EndIndex,
|
||||
ProxyCurveIsReversed = e.ProxyCurveIsReversed,
|
||||
Domain = e.Domain
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var l in Loops)
|
||||
{
|
||||
transformed.Loops.Add(new BrepLoop(transformed, l.FaceIndex, l.TrimIndices, l.Type));
|
||||
transformed.Loops.Add(
|
||||
new BrepLoop
|
||||
{
|
||||
Brep = transformed,
|
||||
FaceIndex = l.FaceIndex,
|
||||
TrimIndices = l.TrimIndices,
|
||||
Type = l.Type
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var t in Trims)
|
||||
{
|
||||
transformed.Trims.Add(
|
||||
new BrepTrim(
|
||||
transformed,
|
||||
t.EdgeIndex,
|
||||
t.FaceIndex,
|
||||
t.LoopIndex,
|
||||
t.CurveIndex,
|
||||
t.IsoStatus,
|
||||
t.TrimType,
|
||||
t.IsReversed,
|
||||
t.StartIndex,
|
||||
t.EndIndex
|
||||
)
|
||||
new BrepTrim
|
||||
{
|
||||
Brep = transformed,
|
||||
EdgeIndex = t.EdgeIndex,
|
||||
FaceIndex = t.FaceIndex,
|
||||
LoopIndex = t.LoopIndex,
|
||||
CurveIndex = t.CurveIndex,
|
||||
IsoStatus = t.IsoStatus,
|
||||
TrimType = t.TrimType,
|
||||
IsReversed = t.IsReversed,
|
||||
StartIndex = t.StartIndex,
|
||||
EndIndex = t.EndIndex,
|
||||
Domain = null!,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
foreach (var f in Faces)
|
||||
{
|
||||
transformed.Faces.Add(
|
||||
new BrepFace(transformed, f.SurfaceIndex, f.LoopIndices, f.OuterLoopIndex, f.OrientationReversed)
|
||||
new BrepFace
|
||||
{
|
||||
Brep = transformed,
|
||||
SurfaceIndex = f.SurfaceIndex,
|
||||
LoopIndices = f.LoopIndices,
|
||||
OuterLoopIndex = f.OuterLoopIndex,
|
||||
OrientationReversed = f.OrientationReversed
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -565,21 +575,22 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
for (var i = 0; i < Edges.Count; i++)
|
||||
{
|
||||
var e = Edges[i];
|
||||
lock (e)
|
||||
var existing = e;
|
||||
lock (existing)
|
||||
{
|
||||
if (e.Brep != null)
|
||||
{
|
||||
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
e = new BrepEdge(
|
||||
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
this,
|
||||
e.Curve3dIndex,
|
||||
e.TrimIndices,
|
||||
e.StartIndex,
|
||||
e.EndIndex,
|
||||
e.ProxyCurveIsReversed,
|
||||
e.Domain
|
||||
);
|
||||
e = new BrepEdge
|
||||
{
|
||||
Brep = this,
|
||||
Curve3dIndex = e.Curve3dIndex,
|
||||
TrimIndices = e.TrimIndices,
|
||||
StartIndex = e.StartIndex,
|
||||
EndIndex = e.EndIndex,
|
||||
ProxyCurveIsReversed = e.ProxyCurveIsReversed,
|
||||
Domain = e.Domain,
|
||||
};
|
||||
|
||||
Edges[i] = e;
|
||||
}
|
||||
else
|
||||
@@ -592,13 +603,19 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
for (var i = 0; i < Loops.Count; i++)
|
||||
{
|
||||
var l = Loops[i];
|
||||
lock (l)
|
||||
var existingLoop = l;
|
||||
lock (existingLoop)
|
||||
{
|
||||
if (l.Brep != null)
|
||||
{
|
||||
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
l = new BrepLoop(this, l.FaceIndex, l.TrimIndices, l.Type);
|
||||
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
l = new BrepLoop
|
||||
{
|
||||
Brep = this,
|
||||
FaceIndex = l.FaceIndex,
|
||||
TrimIndices = l.TrimIndices,
|
||||
Type = l.Type,
|
||||
};
|
||||
|
||||
Loops[i] = l;
|
||||
}
|
||||
else
|
||||
@@ -611,24 +628,25 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
for (var i = 0; i < Trims.Count; i++)
|
||||
{
|
||||
var t = Trims[i];
|
||||
lock (t)
|
||||
var existingTrim = t;
|
||||
lock (existingTrim)
|
||||
{
|
||||
if (t.Brep != null)
|
||||
{
|
||||
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
t = new BrepTrim(
|
||||
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
this,
|
||||
t.EdgeIndex,
|
||||
t.FaceIndex,
|
||||
t.LoopIndex,
|
||||
t.CurveIndex,
|
||||
t.IsoStatus,
|
||||
t.TrimType,
|
||||
t.IsReversed,
|
||||
t.StartIndex,
|
||||
t.EndIndex
|
||||
);
|
||||
t = new BrepTrim
|
||||
{
|
||||
Brep = this,
|
||||
EdgeIndex = t.EdgeIndex,
|
||||
LoopIndex = t.LoopIndex,
|
||||
CurveIndex = t.CurveIndex,
|
||||
IsoStatus = t.IsoStatus,
|
||||
TrimType = t.TrimType,
|
||||
IsReversed = t.IsReversed,
|
||||
StartIndex = t.StartIndex,
|
||||
EndIndex = t.EndIndex,
|
||||
FaceIndex = t.FaceIndex,
|
||||
Domain = Interval.UnitInterval, //TODO: This is a problem, see CXPLA-28
|
||||
};
|
||||
Trims[i] = t;
|
||||
}
|
||||
else
|
||||
@@ -641,13 +659,19 @@ public class Brep : Base, IHasArea, IHasVolume, IHasBoundingBox, ITransformable<
|
||||
for (var i = 0; i < Faces.Count; i++)
|
||||
{
|
||||
var f = Faces[i];
|
||||
lock (f)
|
||||
var existingFace = f;
|
||||
lock (existingFace)
|
||||
{
|
||||
if (f.Brep != null)
|
||||
{
|
||||
#pragma warning disable CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
f = new BrepFace(this, f.SurfaceIndex, f.LoopIndices, f.OuterLoopIndex, f.OrientationReversed);
|
||||
#pragma warning restore CS0728 // Possibly incorrect assignment to local which is the argument to a using or lock statement
|
||||
f = new BrepFace
|
||||
{
|
||||
Brep = this,
|
||||
SurfaceIndex = f.SurfaceIndex,
|
||||
LoopIndices = f.LoopIndices,
|
||||
OuterLoopIndex = f.OuterLoopIndex,
|
||||
OrientationReversed = f.OrientationReversed
|
||||
};
|
||||
Faces[i] = f;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -10,38 +10,17 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.BrepEdge")]
|
||||
public class BrepEdge : Base
|
||||
{
|
||||
public BrepEdge() { }
|
||||
|
||||
public BrepEdge(
|
||||
Brep brep,
|
||||
int curve3dIndex,
|
||||
int[] trimIndices,
|
||||
int startIndex,
|
||||
int endIndex,
|
||||
bool proxyCurvedIsReversed,
|
||||
Interval? domain
|
||||
)
|
||||
{
|
||||
Brep = brep;
|
||||
Curve3dIndex = curve3dIndex;
|
||||
TrimIndices = trimIndices;
|
||||
StartIndex = startIndex;
|
||||
EndIndex = endIndex;
|
||||
ProxyCurveIsReversed = proxyCurvedIsReversed;
|
||||
Domain = domain ?? new(0, 1);
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Brep Brep { get; set; }
|
||||
public required Brep Brep { get; set; }
|
||||
|
||||
public int Curve3dIndex { get; set; }
|
||||
public int[] TrimIndices { get; set; }
|
||||
public int StartIndex { get; set; }
|
||||
public int EndIndex { get; set; }
|
||||
public required int Curve3dIndex { get; set; }
|
||||
public required int[] TrimIndices { get; set; }
|
||||
public required int StartIndex { get; set; }
|
||||
public required int EndIndex { get; set; }
|
||||
|
||||
public bool ProxyCurveIsReversed { get; set; }
|
||||
public required bool ProxyCurveIsReversed { get; set; }
|
||||
|
||||
public Interval Domain { get; set; } = new(0, 1);
|
||||
public required Interval Domain { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Point StartVertex => Brep.Vertices[StartIndex];
|
||||
|
||||
@@ -9,24 +9,13 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.BrepFace")]
|
||||
public class BrepFace : Base
|
||||
{
|
||||
public BrepFace() { }
|
||||
|
||||
public BrepFace(Brep brep, int surfaceIndex, List<int> loopIndices, int outerLoopIndex, bool orientationReversed)
|
||||
{
|
||||
Brep = brep;
|
||||
SurfaceIndex = surfaceIndex;
|
||||
LoopIndices = loopIndices;
|
||||
OuterLoopIndex = outerLoopIndex;
|
||||
OrientationReversed = orientationReversed;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Brep Brep { get; set; }
|
||||
public required Brep Brep { get; set; }
|
||||
|
||||
public int SurfaceIndex { get; set; }
|
||||
public List<int> LoopIndices { get; set; }
|
||||
public int OuterLoopIndex { get; set; }
|
||||
public bool OrientationReversed { get; set; }
|
||||
public required int SurfaceIndex { get; set; }
|
||||
public required List<int> LoopIndices { get; set; }
|
||||
public required int OuterLoopIndex { get; set; }
|
||||
public required bool OrientationReversed { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public BrepLoop OuterLoop => Brep.Loops[OuterLoopIndex];
|
||||
|
||||
@@ -9,22 +9,12 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.BrepLoop")]
|
||||
public class BrepLoop : Base
|
||||
{
|
||||
public BrepLoop() { }
|
||||
|
||||
public BrepLoop(Brep brep, int faceIndex, List<int> trimIndices, BrepLoopType type)
|
||||
{
|
||||
Brep = brep;
|
||||
FaceIndex = faceIndex;
|
||||
TrimIndices = trimIndices;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Brep Brep { get; set; }
|
||||
public required Brep Brep { get; set; }
|
||||
|
||||
public int FaceIndex { get; set; }
|
||||
public List<int> TrimIndices { get; set; }
|
||||
public BrepLoopType Type { get; set; }
|
||||
public required int FaceIndex { get; set; }
|
||||
public required List<int> TrimIndices { get; set; }
|
||||
public required BrepLoopType Type { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public BrepFace Face => Brep.Faces[FaceIndex];
|
||||
|
||||
@@ -10,47 +10,19 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.BrepTrim")]
|
||||
public class BrepTrim : Base
|
||||
{
|
||||
public BrepTrim() { }
|
||||
|
||||
public BrepTrim(
|
||||
Brep brep,
|
||||
int edgeIndex,
|
||||
int faceIndex,
|
||||
int loopIndex,
|
||||
int curveIndex,
|
||||
int isoStatus,
|
||||
BrepTrimType trimType,
|
||||
bool reversed,
|
||||
int startIndex,
|
||||
int endIndex
|
||||
)
|
||||
{
|
||||
Brep = brep;
|
||||
EdgeIndex = edgeIndex;
|
||||
FaceIndex = faceIndex;
|
||||
LoopIndex = loopIndex;
|
||||
CurveIndex = curveIndex;
|
||||
IsoStatus = isoStatus;
|
||||
TrimType = trimType;
|
||||
IsReversed = reversed;
|
||||
StartIndex = startIndex;
|
||||
EndIndex = endIndex;
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public Brep Brep { get; set; }
|
||||
public required Brep Brep { get; set; }
|
||||
public required int EdgeIndex { get; set; }
|
||||
public required int StartIndex { get; set; }
|
||||
public required int EndIndex { get; set; }
|
||||
public required int FaceIndex { get; set; }
|
||||
public required int LoopIndex { get; set; }
|
||||
public required int CurveIndex { get; set; }
|
||||
public required int IsoStatus { get; set; }
|
||||
public required BrepTrimType TrimType { get; set; }
|
||||
public required bool IsReversed { get; set; }
|
||||
|
||||
public int EdgeIndex { get; set; }
|
||||
public int StartIndex { get; set; }
|
||||
public int EndIndex { get; set; }
|
||||
public int FaceIndex { get; set; }
|
||||
public int LoopIndex { get; set; }
|
||||
public int CurveIndex { get; set; }
|
||||
public int IsoStatus { get; set; }
|
||||
public BrepTrimType TrimType { get; set; }
|
||||
public bool IsReversed { get; set; }
|
||||
|
||||
public Interval Domain { get; set; } = new(0, 1);
|
||||
public required Interval Domain { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public BrepFace Face => Brep.Faces[FaceIndex];
|
||||
|
||||
@@ -7,46 +7,30 @@ namespace Speckle.Objects.Geometry;
|
||||
/// <summary>
|
||||
/// Represents a circular curve based on a base <see cref="Plane"/> and a <see cref="double"/> as radius.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// These circles are expected to be full (untrimmed) circles.
|
||||
/// For trimmed circles, convert them as <see cref="Arc"/>s instead
|
||||
/// </remarks>
|
||||
[SpeckleType("Objects.Geometry.Circle")]
|
||||
public class Circle : Base, ICurve, IHasArea, IHasBoundingBox
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an empty <see cref="Circle"/> instance.
|
||||
/// </summary>
|
||||
public Circle() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Circle"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="plane">The plane where the circle lies</param>
|
||||
/// <param name="radius">The radius of the circle</param>
|
||||
/// <param name="units">The units the circle is modeled in</param>
|
||||
/// <param name="applicationId">The unique ID of this circle in a specific application</param>
|
||||
public Circle(Plane plane, double radius, string units = Units.Meters, string? applicationId = null)
|
||||
{
|
||||
this.plane = plane;
|
||||
this.radius = radius;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radius of the circle
|
||||
/// </summary>
|
||||
public double? radius { get; set; }
|
||||
public required double radius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Plane"/> the circle lies in.
|
||||
/// </summary>
|
||||
public Plane plane { get; set; }
|
||||
public required Plane plane { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The units this object was modeled in.
|
||||
/// </summary>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double length { get; set; }
|
||||
@@ -57,7 +41,7 @@ public class Circle : Base, ICurve, IHasArea, IHasBoundingBox
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the coordinates of this <see cref="Circle"/> as a list of numbers
|
||||
@@ -67,9 +51,9 @@ public class Circle : Base, ICurve, IHasArea, IHasBoundingBox
|
||||
{
|
||||
var list = new List<double>();
|
||||
|
||||
list.Add(radius ?? 0);
|
||||
list.Add(domain?.start ?? 0);
|
||||
list.Add(domain?.end ?? 1);
|
||||
list.Add(radius);
|
||||
list.Add(domain.start);
|
||||
list.Add(domain.end);
|
||||
list.AddRange(plane.ToList());
|
||||
|
||||
list.Add(Units.GetEncodingFromUnit(units));
|
||||
@@ -88,7 +72,7 @@ public class Circle : Base, ICurve, IHasArea, IHasBoundingBox
|
||||
var circle = new Circle
|
||||
{
|
||||
radius = list[2],
|
||||
domain = new Interval(list[3], list[4]),
|
||||
domain = new Interval { start = list[3], end = list[4] },
|
||||
plane = Plane.FromList(list.GetRange(5, 13)),
|
||||
units = Units.GetUnitFromEncoding(list[list.Count - 1])
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ using Speckle.Objects.Other;
|
||||
using Speckle.Objects.Primitive;
|
||||
using Speckle.Sdk;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Logging;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Objects.Geometry;
|
||||
@@ -10,70 +9,52 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Curve")]
|
||||
public class Curve : Base, ICurve, IHasBoundingBox, IHasArea, ITransformable<Curve>, IDisplayValue<Polyline>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an empty <see cref="Curve"/> instance.
|
||||
/// </summary>
|
||||
public Curve() { }
|
||||
public required int degree { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Curve"/> instance based on displayValue a polyline.
|
||||
/// </summary>
|
||||
/// <param name="poly">The polyline that will be this curve's <see cref="displayValue"/></param>
|
||||
/// <param name="units">The units this curve is be modelled in</param>
|
||||
/// <param name="applicationId">The unique ID of this curve in a specific application</param>
|
||||
public Curve(Polyline poly, string units = Units.Meters, string? applicationId = null)
|
||||
{
|
||||
displayValue = poly;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
public int degree { get; set; }
|
||||
|
||||
public bool periodic { get; set; }
|
||||
public required bool periodic { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// "True" if weights differ, "False" if weights are the same.
|
||||
/// </summary>
|
||||
public bool rational { get; set; }
|
||||
public required bool rational { get; set; }
|
||||
|
||||
[DetachProperty, Chunkable(31250)]
|
||||
public List<double> points { get; set; }
|
||||
public required List<double> points { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the weights for this <see cref="Curve"/>. Use a default value of 1 for unweighted points.
|
||||
/// </summary>
|
||||
[DetachProperty, Chunkable(31250)]
|
||||
public List<double> weights { get; set; }
|
||||
public required List<double> weights { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the knots for this <see cref="Curve"/>. Count should be equal to <see cref="points"/> count + <see cref="degree"/> + 1.
|
||||
/// </summary>
|
||||
[DetachProperty, Chunkable(31250)]
|
||||
public List<double> knots { get; set; }
|
||||
public required List<double> knots { get; set; }
|
||||
|
||||
public bool closed { get; set; }
|
||||
public required bool closed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The units this object was specified in.
|
||||
/// </summary>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Interval domain { get; set; } = new Interval(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double length { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
[DetachProperty]
|
||||
public Polyline displayValue { get; set; }
|
||||
public required Polyline displayValue { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Curve transformed)
|
||||
@@ -99,7 +80,7 @@ public class Curve : Base, ICurve, IHasBoundingBox, IHasArea, ITransformable<Cur
|
||||
closed = closed,
|
||||
units = units,
|
||||
applicationId = applicationId,
|
||||
domain = domain != null ? new Interval { start = domain.start, end = domain.end } : new Interval(0, 1)
|
||||
domain = domain != null ? new Interval { start = domain.start, end = domain.end } : Interval.UnitInterval
|
||||
};
|
||||
|
||||
return result;
|
||||
@@ -175,35 +156,34 @@ public class Curve : Base, ICurve, IHasBoundingBox, IHasArea, ITransformable<Cur
|
||||
/// </remarks>
|
||||
public static Curve FromList(List<double> list)
|
||||
{
|
||||
if (list[0] != list.Count - 1)
|
||||
if ((int)list[0] != list.Count - 1)
|
||||
{
|
||||
throw new Exception($"Incorrect length. Expected {list[0]}, got {list.Count}.");
|
||||
throw new ArgumentException($"Incorrect length. Expected {list[0]}, got {list.Count}", nameof(list));
|
||||
}
|
||||
|
||||
if (list[1] != CurveTypeEncoding.Curve)
|
||||
{
|
||||
throw new Exception($"Wrong curve type. Expected {CurveTypeEncoding.Curve}, got {list[1]}.");
|
||||
throw new ArgumentException($"Wrong curve type. Expected {CurveTypeEncoding.Curve}, got {list[1]}", nameof(list));
|
||||
}
|
||||
|
||||
string units = Units.GetUnitFromEncoding(list[list.Count - 1]);
|
||||
var curve = new Curve
|
||||
{
|
||||
degree = (int)list[2],
|
||||
periodic = list[3] == 1,
|
||||
rational = list[4] == 1,
|
||||
closed = list[5] == 1,
|
||||
domain = new Interval(list[6], list[7]),
|
||||
displayValue = new Polyline() { units = units } // this is unique to breps, so we do not create curves with null displayValues
|
||||
};
|
||||
|
||||
var pointsCount = (int)list[8];
|
||||
var weightsCount = (int)list[9];
|
||||
var knotsCount = (int)list[10];
|
||||
|
||||
curve.points = list.GetRange(11, pointsCount);
|
||||
curve.weights = list.GetRange(11 + pointsCount, weightsCount);
|
||||
curve.knots = list.GetRange(11 + pointsCount + weightsCount, knotsCount);
|
||||
curve.units = units;
|
||||
string units = Units.GetUnitFromEncoding(list[^1]);
|
||||
var curve = new Curve
|
||||
{
|
||||
degree = (int)list[2],
|
||||
periodic = (int)list[3] == 1,
|
||||
rational = (int)list[4] == 1,
|
||||
closed = (int)list[5] == 1,
|
||||
domain = new Interval { start = list[6], end = list[7] },
|
||||
displayValue = new Polyline { value = new(), units = units }, // this is unique to breps, so we do not create curves with null displayValues
|
||||
points = list.GetRange(11, pointsCount),
|
||||
weights = list.GetRange(11 + pointsCount, weightsCount),
|
||||
knots = list.GetRange(11 + pointsCount + weightsCount, knotsCount),
|
||||
units = units,
|
||||
};
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
@@ -7,65 +7,20 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Ellipse")]
|
||||
public class Ellipse : Base, ICurve, IHasArea
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ellipse"/> class.
|
||||
/// This constructor is only intended for serialization/deserialization purposes.
|
||||
/// Use other constructors to manually create ellipses.
|
||||
/// </summary>
|
||||
public Ellipse() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ellipse"/> class.
|
||||
/// </summary>
|
||||
/// <param name="plane">The plane to draw the ellipse in.</param>
|
||||
/// <param name="radius1">First radius of the ellipse.</param>
|
||||
/// <param name="radius2">Second radius of the ellipse.</param>
|
||||
/// <param name="applicationId">Application ID, defaults to null.</param>
|
||||
public Ellipse(Plane plane, double radius1, double radius2, string units = Units.Meters, string? applicationId = null)
|
||||
: this(plane, radius1, radius2, new Interval(0, 1), null, units) { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ellipse"/> class.
|
||||
/// </summary>
|
||||
/// <param name="plane">The plane to draw the ellipse in.</param>
|
||||
/// <param name="radius1">First radius of the ellipse.</param>
|
||||
/// <param name="radius2">Second radius of the ellipse.</param>
|
||||
/// <param name="domain">The curve's internal parametrization domain.</param>
|
||||
/// <param name="trimDomain">The domain to trim the curve with. Will be null if the ellipse is not trimmed.</param>
|
||||
/// <param name="applicationId">Application ID, defaults to null.</param>
|
||||
public Ellipse(
|
||||
Plane plane,
|
||||
double radius1,
|
||||
double radius2,
|
||||
Interval domain,
|
||||
Interval? trimDomain,
|
||||
string units = Units.Meters,
|
||||
string? applicationId = null
|
||||
)
|
||||
{
|
||||
this.plane = plane;
|
||||
firstRadius = radius1;
|
||||
secondRadius = radius2;
|
||||
this.domain = domain;
|
||||
this.trimDomain = trimDomain;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the first radius of the <see cref="Ellipse"/>. This is usually the major radius.
|
||||
/// </summary>
|
||||
public double? firstRadius { get; set; }
|
||||
public required double firstRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the second radius of the <see cref="Ellipse"/>. This is usually the minor radius.
|
||||
/// </summary>
|
||||
public double? secondRadius { get; set; }
|
||||
public required double secondRadius { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the plane to draw this ellipse in.
|
||||
/// </summary>
|
||||
public Plane plane { get; set; }
|
||||
public required Plane plane { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or set the domain interval to trim this <see cref="Ellipse"/> with.
|
||||
@@ -73,14 +28,14 @@ public class Ellipse : Base, ICurve, IHasArea
|
||||
public Interval? trimDomain { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the domain interval for this <see cref="Ellipse"/>.
|
||||
/// </summary>
|
||||
public Interval domain { get; set; } = new(0, 0);
|
||||
public required Interval domain { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public double length { get; set; }
|
||||
@@ -93,10 +48,10 @@ public class Ellipse : Base, ICurve, IHasArea
|
||||
public List<double> ToList()
|
||||
{
|
||||
var list = new List<double>();
|
||||
list.Add(firstRadius ?? 0);
|
||||
list.Add(secondRadius ?? 0);
|
||||
list.Add(domain?.start ?? 0);
|
||||
list.Add(domain?.end ?? 0);
|
||||
list.Add(firstRadius);
|
||||
list.Add(secondRadius);
|
||||
list.Add(domain.start);
|
||||
list.Add(domain.end);
|
||||
|
||||
list.AddRange(plane.ToList());
|
||||
|
||||
@@ -112,7 +67,7 @@ public class Ellipse : Base, ICurve, IHasArea
|
||||
{
|
||||
firstRadius = list[2],
|
||||
secondRadius = list[3],
|
||||
domain = new Interval(list[4], list[5]),
|
||||
domain = new Interval { start = list[4], end = list[5] },
|
||||
plane = Plane.FromList(list.GetRange(6, 13)),
|
||||
units = Units.GetUnitFromEncoding(list[list.Count - 1])
|
||||
};
|
||||
|
||||
@@ -35,6 +35,6 @@ public class Extrusion : Base, IHasVolume, IHasArea, IHasBoundingBox
|
||||
|
||||
public double area { get; set; }
|
||||
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
public double volume { get; set; }
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ public class Line : Base, ICurve, IHasBoundingBox, ITransformable<Line>
|
||||
public Point start { get; set; }
|
||||
public Point end { get; set; }
|
||||
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
public double length { get; set; }
|
||||
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
public bool TransformTo(Transform transform, out Line transformed)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ public class Line : Base, ICurve, IHasBoundingBox, ITransformable<Line>
|
||||
end = transformedEnd,
|
||||
applicationId = applicationId,
|
||||
units = units,
|
||||
domain = domain is null ? new(0, 1) : new() { start = domain.start, end = domain.end }
|
||||
domain = domain is null ? Interval.UnitInterval : new() { start = domain.start, end = domain.end }
|
||||
};
|
||||
return true;
|
||||
}
|
||||
@@ -126,7 +126,10 @@ public class Line : Base, ICurve, IHasBoundingBox, ITransformable<Line>
|
||||
var units = Units.GetUnitFromEncoding(list[list.Count - 1]);
|
||||
var startPt = new Point(list[2], list[3], list[4], units);
|
||||
var endPt = new Point(list[5], list[6], list[7], units);
|
||||
var line = new Line(startPt, endPt, units) { domain = new Interval(list[8], list[9]) };
|
||||
var line = new Line(startPt, endPt, units)
|
||||
{
|
||||
domain = new Interval { start = list[8], end = list[9] }
|
||||
};
|
||||
return line;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Mesh : Base, IHasBoundingBox, IHasVolume, IHasArea, ITransformable<
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double volume { get; set; }
|
||||
|
||||
@@ -10,62 +10,31 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Plane")]
|
||||
public class Plane : Base, ITransformable<Plane>
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an empty <see cref="Plane"/>
|
||||
/// </summary>
|
||||
public Plane() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Plane"/> given it's individual values.
|
||||
/// </summary>
|
||||
/// <param name="origin">The point to be used as origin</param>
|
||||
/// <param name="normal">The vector to be used as Z axis</param>
|
||||
/// <param name="xDir">The vector to be used as the X axis</param>
|
||||
/// <param name="yDir">The vector to be used as the Y axis</param>
|
||||
/// <param name="units">The units the coordinates are in.</param>
|
||||
/// <param name="applicationId">The unique ID of this polyline in a specific application</param>
|
||||
public Plane(
|
||||
Point origin,
|
||||
Vector normal,
|
||||
Vector xDir,
|
||||
Vector yDir,
|
||||
string units = Units.Meters,
|
||||
string? applicationId = null
|
||||
)
|
||||
{
|
||||
this.origin = origin;
|
||||
this.normal = normal;
|
||||
xdir = xDir;
|
||||
ydir = yDir;
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Plane"/>s origin point.
|
||||
/// </summary>
|
||||
public Point origin { get; set; }
|
||||
public required Point origin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Plane"/>s Z axis.
|
||||
/// </summary>
|
||||
public Vector normal { get; set; }
|
||||
public required Vector normal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Plane"/>s X axis.
|
||||
/// </summary>
|
||||
public Vector xdir { get; set; }
|
||||
public required Vector xdir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Plane"/>s Y axis.
|
||||
/// </summary>
|
||||
public Vector ydir { get; set; }
|
||||
public required Vector ydir { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unit's this <see cref="Plane"/> is in.
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </summary>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Plane transformed)
|
||||
@@ -120,13 +89,15 @@ public class Plane : Base, ITransformable<Plane>
|
||||
/// <returns>A new <see cref="Plane"/> with the provided values.</returns>
|
||||
public static Plane FromList(List<double> list)
|
||||
{
|
||||
var plane = new Plane();
|
||||
|
||||
var units = Units.GetUnitFromEncoding(list[list.Count - 1]);
|
||||
plane.origin = new Point(list[0], list[1], list[2], units);
|
||||
plane.normal = new Vector(list[3], list[4], list[5], units);
|
||||
plane.xdir = new Vector(list[6], list[7], list[8], units);
|
||||
plane.ydir = new Vector(list[9], list[10], list[11], units);
|
||||
var plane = new Plane
|
||||
{
|
||||
origin = new Point(list[0], list[1], list[2], units),
|
||||
normal = new Vector(list[3], list[4], list[5], units),
|
||||
xdir = new Vector(list[6], list[7], list[8], units),
|
||||
ydir = new Vector(list[9], list[10], list[11], units),
|
||||
units = units,
|
||||
};
|
||||
|
||||
return plane;
|
||||
}
|
||||
|
||||
@@ -75,10 +75,7 @@ public class Point : Base, ITransformable<Point>
|
||||
/// The units this <see cref="Point"/> is in.
|
||||
/// This should be one of the units specified in <see cref="Units"/>
|
||||
/// </summary>
|
||||
public string units { get; set; } = Units.None;
|
||||
|
||||
[JsonIgnore, Obsolete("Bounding box no longer applicable to point as of 2.18", true)]
|
||||
public Box? bbox { get; set; }
|
||||
public string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Point transformed)
|
||||
@@ -219,11 +216,6 @@ public class Point : Base, ITransformable<Point>
|
||||
return Math.Sqrt(Math.Pow(x - point.x, 2) + Math.Pow(y - point.y, 2) + Math.Pow(z - point.z, 2));
|
||||
}
|
||||
|
||||
public static Point Add(Point left, Point right)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(this, obj))
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Pointcloud : Base, IHasBoundingBox, ITransformable<Pointcloud>
|
||||
public string units { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Pointcloud transformed)
|
||||
|
||||
@@ -11,26 +11,10 @@ namespace Speckle.Objects.Geometry;
|
||||
[SpeckleType("Objects.Geometry.Polycurve")]
|
||||
public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs a new empty <see cref="Polycurve"/> instance.
|
||||
/// </summary>
|
||||
public Polycurve() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new empty <see cref="Polycurve"/> with defined units and unique application ID.
|
||||
/// </summary>
|
||||
/// <param name="units">The units the Polycurve was modelled in.</param>
|
||||
/// <param name="applicationId">The unique ID of this polyline in a specific application</param>
|
||||
public Polycurve(string units = Units.Meters, string? applicationId = null)
|
||||
{
|
||||
this.applicationId = applicationId;
|
||||
this.units = units;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the list of segments that comprise this <see cref="Polycurve"/>
|
||||
/// </summary>
|
||||
public List<ICurve> segments { get; set; } = new();
|
||||
public required List<ICurve> segments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a Boolean value indicating if the <see cref="Polycurve"/> is closed
|
||||
@@ -42,12 +26,12 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
/// The unit's this <see cref="Polycurve"/> is in.
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </summary>
|
||||
public string units { get; set; }
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The internal domain of this curve.
|
||||
/// </summary>
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double length { get; set; }
|
||||
@@ -56,7 +40,7 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out ITransformable polycurve)
|
||||
@@ -98,6 +82,7 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
Polycurve polycurve =
|
||||
new()
|
||||
{
|
||||
segments = new(),
|
||||
units = polyline.units,
|
||||
area = polyline.area,
|
||||
domain = polyline.domain,
|
||||
@@ -114,7 +99,7 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
}
|
||||
if (polyline.closed)
|
||||
{
|
||||
var line = new Line(points[points.Count - 1], points[0], polyline.units);
|
||||
var line = new Line(points[^1], points[0], polyline.units);
|
||||
polycurve.segments.Add(line);
|
||||
}
|
||||
|
||||
@@ -129,8 +114,8 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
{
|
||||
var list = new List<double>();
|
||||
list.Add(closed ? 1 : 0);
|
||||
list.Add(domain?.start ?? 0);
|
||||
list.Add(domain?.end ?? 1);
|
||||
list.Add(domain.start);
|
||||
list.Add(domain.end);
|
||||
|
||||
var crvs = CurveArrayEncodingExtensions.ToArray(segments);
|
||||
list.Add(crvs.Count);
|
||||
@@ -150,16 +135,15 @@ public class Polycurve : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
/// <returns>A new <see cref="Polycurve"/> with the provided values.</returns>
|
||||
public static Polycurve FromList(List<double> list)
|
||||
{
|
||||
var polycurve = new Polycurve { closed = list[2] == 1, domain = new Interval(list[3], list[4]) };
|
||||
|
||||
var temp = list.GetRange(6, (int)list[5]);
|
||||
polycurve.segments = CurveArrayEncodingExtensions.FromArray(temp);
|
||||
polycurve.units = Units.GetUnitFromEncoding(list[list.Count - 1]);
|
||||
var polycurve = new Polycurve
|
||||
{
|
||||
segments = CurveArrayEncodingExtensions.FromArray(temp),
|
||||
closed = (int)list[2] == 1,
|
||||
domain = new Interval { start = list[3], end = list[4] },
|
||||
units = Units.GetUnitFromEncoding(list[^1]),
|
||||
};
|
||||
|
||||
return polycurve;
|
||||
}
|
||||
|
||||
public Polycurve ToPolycurve()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using Speckle.Newtonsoft.Json;
|
||||
using Speckle.Objects.Other;
|
||||
using Speckle.Objects.Primitive;
|
||||
using Speckle.Sdk;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Logging;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
namespace Speckle.Objects.Geometry;
|
||||
@@ -12,170 +10,29 @@ namespace Speckle.Objects.Geometry;
|
||||
/// A polyline curve, defined by a set of vertices.
|
||||
/// </summary>
|
||||
[SpeckleType("Objects.Geometry.Polyline")]
|
||||
public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, ITransformable
|
||||
public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, ITransformable
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructs an empty <see cref="Polyline"/>
|
||||
/// </summary>
|
||||
public Polyline() { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Polyline"/> instance from a flat list of coordinates.
|
||||
/// </summary>
|
||||
/// <param name="coordinatesArray">The array of 3-dimensional coordinates [x1,y1,z1,x2,y2,...</param>
|
||||
/// <param name="units">The units the coordinates are in.</param>
|
||||
/// <param name="applicationId">The unique ID of this polyline in a specific application</param>
|
||||
[Obsolete("Use list constructor instead", true)]
|
||||
public Polyline(IEnumerable<double> coordinatesArray, string units = Units.Meters, string? applicationId = null)
|
||||
: this(coordinatesArray.ToList(), units, applicationId) { }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new <see cref="Polyline"/> instance from a flat list of coordinates.
|
||||
/// </summary>
|
||||
/// <param name="coordinates">The list of 3-dimensional coordinates [x1,y1,z1,x2,y2,...</param>
|
||||
/// <param name="units">The units the coordinates are in.</param>
|
||||
/// <param name="applicationId">The unique ID of this polyline in a specific application</param>
|
||||
public Polyline(List<double> coordinates, string units = Units.Meters, string? applicationId = null)
|
||||
{
|
||||
value = coordinates;
|
||||
this.units = units;
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the raw coordinates that define this polyline. Use GetPoints instead to access this data as <see cref="Point"/> instances instead.
|
||||
/// </summary>
|
||||
[DetachProperty, Chunkable(31250)]
|
||||
public List<double> value { get; set; } = new();
|
||||
public required List<double> value { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// <remarks>
|
||||
/// If true, do not add the last point to the value list. Polyline first and last points should be unique.
|
||||
/// </summary>
|
||||
/// </remarks>
|
||||
public bool closed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The unit's this <see cref="Polyline"/> is in.
|
||||
/// This should be one of <see cref="Units"/>
|
||||
/// </summary>
|
||||
public string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of points representing the vertices of this polyline.
|
||||
/// </summary>
|
||||
[JsonIgnore, Obsolete("Use " + nameof(GetPoints) + " Instead", true)]
|
||||
public List<Point> points => GetPoints();
|
||||
|
||||
/// <inheritdoc/>
|
||||
public object ToType(Type conversionType, IFormatProvider provider)
|
||||
{
|
||||
if (conversionType == typeof(Polycurve))
|
||||
{
|
||||
return (Polycurve)this;
|
||||
}
|
||||
|
||||
throw new InvalidCastException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public TypeCode GetTypeCode()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool ToBoolean(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public byte ToByte(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public char ToChar(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public DateTime ToDateTime(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public decimal ToDecimal(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double ToDouble(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public short ToInt16(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public int ToInt32(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public long ToInt64(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public sbyte ToSByte(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public float ToSingle(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string ToString(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ushort ToUInt16(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public uint ToUInt32(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public ulong ToUInt64(IFormatProvider provider)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public required string units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The internal domain of this curve.
|
||||
/// </summary>
|
||||
public Interval domain { get; set; } = new(0, 1);
|
||||
public Interval domain { get; set; } = Interval.UnitInterval;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public double length { get; set; }
|
||||
@@ -184,7 +41,7 @@ public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, I
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out ITransformable transformed)
|
||||
@@ -253,13 +110,15 @@ public class Polyline : Base, ICurve, IHasArea, IHasBoundingBox, IConvertible, I
|
||||
/// </summary>
|
||||
/// <param name="list">The list of values representing this polyline</param>
|
||||
/// <returns>A new <see cref="Polyline"/> with the provided values.</returns>
|
||||
|
||||
public static Polyline FromList(List<double> list)
|
||||
{
|
||||
var polyline = new Polyline { closed = list[2] == 1, domain = new Interval(list[3], list[4]) };
|
||||
var pointCount = (int)list[5];
|
||||
polyline.value = list.GetRange(6, pointCount);
|
||||
polyline.units = Units.GetUnitFromEncoding(list[list.Count - 1]);
|
||||
return polyline;
|
||||
int pointCount = (int)list[5];
|
||||
return new()
|
||||
{
|
||||
closed = (int)list[2] == 1,
|
||||
domain = new Interval { start = list[3], end = list[4] },
|
||||
value = list.GetRange(6, pointCount),
|
||||
units = Units.GetUnitFromEncoding(list[^1])
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,5 +37,5 @@ public class Spiral : Base, ICurve, IHasBoundingBox, IDisplayValue<Polyline>
|
||||
[DetachProperty]
|
||||
public Polyline displayValue { get; set; }
|
||||
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public class Surface : Base, IHasBoundingBox, IHasArea, ITransformable<Surface>
|
||||
public double area { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Surface transformed)
|
||||
@@ -203,10 +203,10 @@ public class Surface : Base, IHasBoundingBox, IHasArea, ITransformable<Surface>
|
||||
list.Add(rational ? 1 : 0);
|
||||
list.Add(closedU ? 1 : 0);
|
||||
list.Add(closedV ? 1 : 0);
|
||||
list.Add(domainU.start ?? 0); // 7
|
||||
list.Add(domainU.end ?? 1);
|
||||
list.Add(domainV.start ?? 0);
|
||||
list.Add(domainV.end ?? 1); // [0] 10
|
||||
list.Add(domainU.start); // 7
|
||||
list.Add(domainU.end);
|
||||
list.Add(domainV.start);
|
||||
list.Add(domainV.end); // [0] 10
|
||||
|
||||
list.Add(pointData.Count); // 11
|
||||
list.Add(knotsU.Count); // 12
|
||||
|
||||
@@ -104,7 +104,7 @@ public class Vector : Base, IHasBoundingBox, ITransformable<Vector>
|
||||
public double Length => Math.Sqrt(DotProduct(this, this));
|
||||
|
||||
/// <inheritdoc/>
|
||||
public Box bbox { get; set; }
|
||||
public Box? bbox { get; set; }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool TransformTo(Transform transform, out Vector transformed)
|
||||
|
||||
@@ -16,7 +16,7 @@ public interface IHasBoundingBox
|
||||
/// <summary>
|
||||
/// The bounding box containing the object.
|
||||
/// </summary>
|
||||
Box bbox { get; }
|
||||
Box? bbox { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -149,13 +149,14 @@ public class BlockInstance : Instance<BlockDefinition>
|
||||
public Plane GetInsertionPlane()
|
||||
{
|
||||
// TODO: UPDATE!
|
||||
var plane = new Plane(
|
||||
typedDefinition.basePoint ?? new Point(0, 0, 0, units),
|
||||
new Vector(0, 0, 1, units),
|
||||
new Vector(1, 0, 0, units),
|
||||
new Vector(0, 1, 0, units),
|
||||
units
|
||||
);
|
||||
var plane = new Plane()
|
||||
{
|
||||
origin = typedDefinition.basePoint ?? new Point(0, 0, 0, units),
|
||||
normal = new Vector(0, 0, 1, units),
|
||||
xdir = new Vector(1, 0, 0, units),
|
||||
ydir = new Vector(0, 1, 0, units),
|
||||
units = units
|
||||
};
|
||||
plane.TransformTo(transform, out Plane tPlane);
|
||||
return tPlane;
|
||||
}
|
||||
|
||||
@@ -56,13 +56,14 @@ public class RevitInstance : Instance<RevitSymbolElementType>
|
||||
public Plane GetInsertionPlane()
|
||||
{
|
||||
// TODO: Check for Revit in GH/DYN
|
||||
var plane = new Plane(
|
||||
new Point(0, 0, 0, units),
|
||||
new Vector(0, 0, 1, units),
|
||||
new Vector(1, 0, 0, units),
|
||||
new Vector(0, 1, 0, units),
|
||||
units
|
||||
);
|
||||
var plane = new Plane()
|
||||
{
|
||||
origin = new Point(0, 0, 0, units),
|
||||
normal = new Vector(0, 0, 1, units),
|
||||
xdir = new Vector(1, 0, 0, units),
|
||||
ydir = new Vector(0, 1, 0, units),
|
||||
units = units,
|
||||
};
|
||||
plane.TransformTo(transform, out Plane tPlane);
|
||||
return tPlane;
|
||||
}
|
||||
|
||||
@@ -6,22 +6,16 @@ namespace Speckle.Objects.Primitive;
|
||||
[SpeckleType("Objects.Primitive.Interval")]
|
||||
public class Interval : Base
|
||||
{
|
||||
public Interval() { }
|
||||
|
||||
public Interval(double start, double end)
|
||||
{
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public double? start { get; set; }
|
||||
public double? end { get; set; }
|
||||
public required double start { get; set; }
|
||||
public required double end { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public double Length => Math.Abs((end ?? 0) - (start ?? 0));
|
||||
public double Length => Math.Abs((end) - (start));
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString() + $"[{start}, {end}]";
|
||||
}
|
||||
|
||||
public static Interval UnitInterval => new() { start = 0, end = 1 };
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public class Interval2d : Base
|
||||
|
||||
public Interval2d(double start_u, double end_u, double start_v, double end_v)
|
||||
{
|
||||
u = new Interval(start_u, end_u);
|
||||
v = new Interval(start_v, end_v);
|
||||
u = new Interval { start = start_u, end = end_u };
|
||||
v = new Interval { start = start_v, end = end_v };
|
||||
}
|
||||
|
||||
public Interval u { get; set; }
|
||||
|
||||
@@ -3,6 +3,7 @@ using Speckle.Objects.Structural.CSI.Properties;
|
||||
using Speckle.Objects.Structural.Geometry;
|
||||
using Speckle.Objects.Structural.Properties;
|
||||
using Speckle.Objects.Structural.Results;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Host;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
@@ -40,7 +41,14 @@ public class CSINode : Node
|
||||
?? new Axis(
|
||||
"Global",
|
||||
AxisType.Cartesian,
|
||||
new Plane(new Point(0, 0), new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0))
|
||||
new Plane
|
||||
{
|
||||
origin = new Point(0, 0),
|
||||
normal = new Vector(0, 0, 1),
|
||||
xdir = new Vector(1, 0, 0),
|
||||
ydir = new Vector(0, 1, 0),
|
||||
units = Units.Meters, //Not sure if defaulting to meters is correct, but it was what we were doing previously inside Plane's ctor
|
||||
}
|
||||
);
|
||||
CSISpringProperty = springProperty;
|
||||
this.massProperty = massProperty;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Speckle.Objects.Geometry;
|
||||
using Speckle.Objects.Structural.Geometry;
|
||||
using Speckle.Objects.Structural.Properties;
|
||||
using Speckle.Sdk.Common;
|
||||
using Speckle.Sdk.Host;
|
||||
using Speckle.Sdk.Models;
|
||||
|
||||
@@ -42,7 +43,14 @@ public class GSANode : Node
|
||||
? new Axis(
|
||||
"Global",
|
||||
AxisType.Cartesian,
|
||||
new Plane(new Point(0, 0), new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0))
|
||||
new Plane()
|
||||
{
|
||||
origin = new Point(0, 0),
|
||||
normal = new Vector(0, 0, 1),
|
||||
xdir = new Vector(1, 0, 0),
|
||||
ydir = new Vector(0, 1, 0),
|
||||
units = Units.Meters //Not sure if defaulting to meters is correct, but it was what we were doing previously inside Plane's ctor
|
||||
}
|
||||
)
|
||||
: constraintAxis;
|
||||
this.springProperty = springProperty;
|
||||
|
||||
@@ -43,7 +43,14 @@ public class Node : Base
|
||||
?? new Axis(
|
||||
"Global",
|
||||
AxisType.Cartesian,
|
||||
new Plane(new Point(0, 0), new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0))
|
||||
new Plane
|
||||
{
|
||||
origin = new Point(0, 0),
|
||||
normal = new Vector(0, 0, 1),
|
||||
xdir = new Vector(1, 0, 0),
|
||||
ydir = new Vector(0, 1, 0),
|
||||
units = Units.Meters, //Not sure if defaulting to meters is correct, but it was what we were doing previously inside Plane's ctor
|
||||
}
|
||||
);
|
||||
this.springProperty = springProperty;
|
||||
this.massProperty = massProperty;
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using Speckle.Objects.Geometry;
|
||||
using Speckle.Sdk.Common;
|
||||
|
||||
namespace Objects.Tests.Unit.Geometry;
|
||||
|
||||
[TestFixture, TestOf(typeof(Arc))]
|
||||
public class ArcTests
|
||||
{
|
||||
private Plane TestPlane => new(new Point(0, 0), new Vector(0, 0, 1), new Vector(1, 0, 0), new Vector(0, 1, 0));
|
||||
private Plane TestPlane =>
|
||||
new()
|
||||
{
|
||||
origin = new Point(0, 0),
|
||||
normal = new Vector(0, 0, 1),
|
||||
xdir = new Vector(1, 0, 0),
|
||||
ydir = new Vector(0, 1, 0),
|
||||
units = Units.Meters,
|
||||
};
|
||||
|
||||
[Test]
|
||||
public void CanCreateArc_HalfCircle()
|
||||
|
||||
@@ -56,6 +56,24 @@ public class SerializerNonBreakingChanges : PrimitiveTestFixture
|
||||
Assert.That(res.value, Is.EqualTo(testCase));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NullToInt()
|
||||
{
|
||||
var from = new ObjectValueMock { value = null };
|
||||
|
||||
var res = from.SerializeAsTAndDeserialize<IntValueMock>();
|
||||
Assert.That(res.value, Is.EqualTo(default(int)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NullToDouble()
|
||||
{
|
||||
var from = new ObjectValueMock { value = null };
|
||||
|
||||
var res = from.SerializeAsTAndDeserialize<DoubleValueMock>();
|
||||
Assert.That(res.value, Is.EqualTo(default(double)));
|
||||
}
|
||||
|
||||
[
|
||||
Test,
|
||||
TestCaseSource(nameof(Int8TestCases)),
|
||||
@@ -277,6 +295,12 @@ public class EnumValueMock : SerializerMock
|
||||
public MyEnum value { get; set; }
|
||||
}
|
||||
|
||||
[SpeckleType("Speckle.Core.Tests.Unit.Serialisation.ObjectValueMock")]
|
||||
public class ObjectValueMock : SerializerMock
|
||||
{
|
||||
public object? value { get; set; }
|
||||
}
|
||||
|
||||
public enum MyEnum
|
||||
{
|
||||
Zero,
|
||||
|
||||
Reference in New Issue
Block a user