@itwin/core-geometry 5.0.0-dev.82 → 5.0.0-dev.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/Geometry.d.ts +2 -4
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +2 -4
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -4
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +4 -4
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts +1 -1
- package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +1 -1
- package/lib/cjs/geometry3d/Transform.js +1 -1
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.d.ts +54 -41
- package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/cjs/serialization/IModelJsonSchema.js +83 -69
- package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/cjs/solid/Cone.d.ts +39 -14
- package/lib/cjs/solid/Cone.d.ts.map +1 -1
- package/lib/cjs/solid/Cone.js +50 -18
- package/lib/cjs/solid/Cone.js.map +1 -1
- package/lib/cjs/solid/Sphere.d.ts +34 -17
- package/lib/cjs/solid/Sphere.d.ts.map +1 -1
- package/lib/cjs/solid/Sphere.js +47 -22
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/esm/Geometry.d.ts +2 -4
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +2 -4
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -4
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +4 -4
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts +1 -1
- package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
- package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +1 -1
- package/lib/esm/geometry3d/Transform.js +1 -1
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.d.ts +54 -41
- package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
- package/lib/esm/serialization/IModelJsonSchema.js +83 -69
- package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
- package/lib/esm/solid/Cone.d.ts +39 -14
- package/lib/esm/solid/Cone.d.ts.map +1 -1
- package/lib/esm/solid/Cone.js +51 -19
- package/lib/esm/solid/Cone.js.map +1 -1
- package/lib/esm/solid/Sphere.d.ts +34 -17
- package/lib/esm/solid/Sphere.d.ts.map +1 -1
- package/lib/esm/solid/Sphere.js +48 -23
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/package.json +3 -3
|
@@ -194,10 +194,19 @@ var IModelJson;
|
|
|
194
194
|
return defaultValue;
|
|
195
195
|
}
|
|
196
196
|
static parseAxesFromVectors(json, axisOrder, createDefaultIdentity) {
|
|
197
|
-
if (Array.isArray(json)
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
if (Array.isArray(json)) {
|
|
198
|
+
let matrix;
|
|
199
|
+
if (json.length === 2) { // square and normalize
|
|
200
|
+
const xVector = Point3dVector3d_1.Vector3d.fromJSON(json[0]);
|
|
201
|
+
const yVector = Point3dVector3d_1.Vector3d.fromJSON(json[1]);
|
|
202
|
+
matrix = Matrix3d_1.Matrix3d.createRigidFromColumns(xVector, yVector, axisOrder);
|
|
203
|
+
}
|
|
204
|
+
else if (json.length === 3) { // preserve axes
|
|
205
|
+
const xVector = Point3dVector3d_1.Vector3d.fromJSON(json[0]);
|
|
206
|
+
const yVector = Point3dVector3d_1.Vector3d.fromJSON(json[1]);
|
|
207
|
+
const zVector = Point3dVector3d_1.Vector3d.fromJSON(json[2]);
|
|
208
|
+
matrix = Matrix3d_1.Matrix3d.createColumnsInAxisOrder(axisOrder, xVector, yVector, zVector);
|
|
209
|
+
}
|
|
201
210
|
if (matrix)
|
|
202
211
|
return matrix;
|
|
203
212
|
}
|
|
@@ -207,23 +216,23 @@ var IModelJson;
|
|
|
207
216
|
}
|
|
208
217
|
/**
|
|
209
218
|
* Look for orientation data and convert to Matrix3d.
|
|
210
|
-
* * Search order
|
|
211
|
-
* * *
|
|
212
|
-
* * *
|
|
213
|
-
* * *
|
|
219
|
+
* * Search order and interpretation:
|
|
220
|
+
* * * xyzVectors - general matrix, axes preserved
|
|
221
|
+
* * * yawPitchRollAngles - right-handed rotation via axial rotations
|
|
222
|
+
* * * xyVectors - right-handed rotation, xy-plane specified, axes squared and normalized
|
|
223
|
+
* * * zxVectors - right-handed rotation, zx-plane specified, axes squared and normalized
|
|
214
224
|
* @param json [in] json source data
|
|
215
225
|
* @param createDefaultIdentity [in] If true and no orientation is present, return an identity matrix. If false and no orientation is present, return undefined.
|
|
216
226
|
*/
|
|
217
227
|
static parseOrientation(json, createDefaultIdentity) {
|
|
218
|
-
if (json.
|
|
228
|
+
if (json.xyzVectors)
|
|
229
|
+
return Reader.parseAxesFromVectors(json.xyzVectors, Geometry_1.AxisOrder.XYZ, createDefaultIdentity);
|
|
230
|
+
if (json.yawPitchRollAngles)
|
|
219
231
|
return Reader.parseYawPitchRollAnglesToMatrix3d(json.yawPitchRollAngles);
|
|
220
|
-
|
|
221
|
-
else if (json.xyVectors) {
|
|
232
|
+
if (json.xyVectors)
|
|
222
233
|
return Reader.parseAxesFromVectors(json.xyVectors, Geometry_1.AxisOrder.XYZ, createDefaultIdentity);
|
|
223
|
-
|
|
224
|
-
else if (json.zxVectors) {
|
|
234
|
+
if (json.zxVectors)
|
|
225
235
|
return Reader.parseAxesFromVectors(json.zxVectors, Geometry_1.AxisOrder.ZXY, createDefaultIdentity);
|
|
226
|
-
}
|
|
227
236
|
if (createDefaultIdentity)
|
|
228
237
|
return Matrix3d_1.Matrix3d.createIdentity();
|
|
229
238
|
return undefined;
|
|
@@ -467,11 +476,8 @@ var IModelJson;
|
|
|
467
476
|
const radius = Reader.parseNumberProperty(json, "radius");
|
|
468
477
|
const startRadius = Reader.parseNumberProperty(json, "startRadius", radius);
|
|
469
478
|
const endRadius = Reader.parseNumberProperty(json, "endRadius", startRadius);
|
|
470
|
-
const capped = Reader.parseBooleanProperty(json, "capped"
|
|
471
|
-
if (start
|
|
472
|
-
&& end
|
|
473
|
-
&& startRadius !== undefined
|
|
474
|
-
&& endRadius !== undefined) {
|
|
479
|
+
const capped = Reader.parseBooleanProperty(json, "capped");
|
|
480
|
+
if (start && end && startRadius !== undefined && endRadius !== undefined) {
|
|
475
481
|
if (axes === undefined) {
|
|
476
482
|
const axisVector = Point3dVector3d_1.Vector3d.createStartEnd(start, end);
|
|
477
483
|
const frame = Matrix3d_1.Matrix3d.createRigidHeadsUp(axisVector, Geometry_1.AxisOrder.ZXY);
|
|
@@ -479,9 +485,7 @@ var IModelJson;
|
|
|
479
485
|
const vectorY = frame.columnY();
|
|
480
486
|
return Cone_1.Cone.createBaseAndTarget(start, end, vectorX, vectorY, startRadius, endRadius, capped);
|
|
481
487
|
}
|
|
482
|
-
|
|
483
|
-
return Cone_1.Cone.createBaseAndTarget(start, end, axes.columnX(), axes.columnY(), startRadius, endRadius, capped);
|
|
484
|
-
}
|
|
488
|
+
return Cone_1.Cone.createBaseAndTarget(start, end, axes.columnX(), axes.columnY(), startRadius, endRadius, capped);
|
|
485
489
|
}
|
|
486
490
|
return undefined;
|
|
487
491
|
}
|
|
@@ -567,23 +571,15 @@ var IModelJson;
|
|
|
567
571
|
/** Parse `SphereProps` to `Sphere` instance. */
|
|
568
572
|
static parseSphere(json) {
|
|
569
573
|
const center = Reader.parsePoint3dProperty(json, "center");
|
|
570
|
-
// optional unqualified radius . . .
|
|
571
574
|
const radius = Reader.parseNumberProperty(json, "radius");
|
|
572
|
-
// optional specific X
|
|
573
575
|
const radiusX = Reader.parseNumberProperty(json, "radiusX", radius);
|
|
574
|
-
// missing Y and Z both pick up radiusX (which may have already been defaulted from unqualified radius)
|
|
575
576
|
const radiusY = Reader.parseNumberProperty(json, "radiusY", radiusX);
|
|
576
|
-
const radiusZ = Reader.parseNumberProperty(json, "radiusZ",
|
|
577
|
-
const latitudeStartEnd = Reader.parseAngleSweepProps(json, "latitudeStartEnd");
|
|
578
|
-
const axes = Reader.parseOrientation(json,
|
|
579
|
-
const capped = Reader.parseBooleanProperty(json, "capped"
|
|
580
|
-
if (center
|
|
581
|
-
&& radiusX !== undefined
|
|
582
|
-
&& radiusY !== undefined
|
|
583
|
-
&& radiusZ !== undefined
|
|
584
|
-
&& capped !== undefined) {
|
|
577
|
+
const radiusZ = Reader.parseNumberProperty(json, "radiusZ", radiusY);
|
|
578
|
+
const latitudeStartEnd = Reader.parseAngleSweepProps(json, "latitudeStartEnd");
|
|
579
|
+
const axes = Reader.parseOrientation(json, false);
|
|
580
|
+
const capped = Reader.parseBooleanProperty(json, "capped");
|
|
581
|
+
if (center && radiusX && radiusY && radiusZ)
|
|
585
582
|
return Sphere_1.Sphere.createFromAxesAndScales(center, axes, radiusX, radiusY, radiusZ, latitudeStartEnd, capped);
|
|
586
|
-
}
|
|
587
583
|
return undefined;
|
|
588
584
|
}
|
|
589
585
|
/** Parse RuledSweepProps to RuledSweep instance. */
|
|
@@ -708,11 +704,6 @@ var IModelJson;
|
|
|
708
704
|
}
|
|
709
705
|
}
|
|
710
706
|
IModelJson.Reader = Reader;
|
|
711
|
-
// ISSUE: include 3d in names?
|
|
712
|
-
// ISSUE: would like shorter term than lineSegment
|
|
713
|
-
// ISSUE: is arc clear?
|
|
714
|
-
// ISSUE: label center, vectorX, vector90 on arc?
|
|
715
|
-
// ISSUE: sweep data on arc -- serialize as AngleSweep?
|
|
716
707
|
/**
|
|
717
708
|
* Class to deserialize json objects into GeometryQuery objects
|
|
718
709
|
* @public
|
|
@@ -861,63 +852,86 @@ var IModelJson;
|
|
|
861
852
|
const centerB = data.getCenterB();
|
|
862
853
|
const vectorX = data.getVectorX();
|
|
863
854
|
const vectorY = data.getVectorY();
|
|
855
|
+
const xMag = vectorX.magnitude();
|
|
856
|
+
const yMag = vectorY.magnitude();
|
|
857
|
+
const xySameLength = Geometry_1.Geometry.isSameCoordinate(xMag, yMag);
|
|
864
858
|
const axisVector = Point3dVector3d_1.Vector3d.createStartEnd(centerA, centerB);
|
|
859
|
+
// special case of cylinder
|
|
865
860
|
if (Geometry_1.Geometry.isSameCoordinate(radiusA, radiusB)
|
|
866
861
|
&& vectorX.isPerpendicularTo(axisVector)
|
|
867
862
|
&& vectorY.isPerpendicularTo(axisVector)
|
|
868
|
-
&&
|
|
869
|
-
&& Geometry_1.Geometry.isSameCoordinate(
|
|
863
|
+
&& xySameLength
|
|
864
|
+
&& Geometry_1.Geometry.isSameCoordinate(xMag, 1.0)) {
|
|
870
865
|
return {
|
|
871
866
|
cylinder: {
|
|
872
867
|
capped: data.capped,
|
|
873
|
-
start:
|
|
874
|
-
end:
|
|
868
|
+
start: centerA.toJSON(),
|
|
869
|
+
end: centerB.toJSON(),
|
|
875
870
|
radius: radiusA,
|
|
876
871
|
},
|
|
877
872
|
};
|
|
878
873
|
}
|
|
874
|
+
const coneProps = {
|
|
875
|
+
capped: data.capped,
|
|
876
|
+
start: centerA.toJSON(),
|
|
877
|
+
end: centerB.toJSON(),
|
|
878
|
+
};
|
|
879
|
+
if (Geometry_1.Geometry.isSameCoordinate(radiusA, radiusB)) {
|
|
880
|
+
coneProps.radius = radiusA;
|
|
881
|
+
}
|
|
879
882
|
else {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
start: data.getCenterA().toJSON(),
|
|
883
|
-
end: data.getCenterB().toJSON(),
|
|
884
|
-
startRadius: data.getRadiusA(),
|
|
885
|
-
endRadius: data.getRadiusB(),
|
|
886
|
-
};
|
|
887
|
-
Writer.insertOrientationFromXYVectors(coneProps, vectorX, vectorY, false);
|
|
888
|
-
return { cone: coneProps };
|
|
883
|
+
coneProps.startRadius = radiusA;
|
|
884
|
+
coneProps.endRadius = radiusB;
|
|
889
885
|
}
|
|
886
|
+
// always specify an orthogonal frame for backwards compatibility
|
|
887
|
+
Writer.insertOrientationFromXYVectors(coneProps, vectorX, vectorY, false);
|
|
888
|
+
// specify a general matrix if elliptical sections
|
|
889
|
+
const ellipticalSections = !xySameLength || !vectorX.isPerpendicularTo(vectorY, true);
|
|
890
|
+
if (ellipticalSections)
|
|
891
|
+
coneProps.xyzVectors = [vectorX.toJSON(), vectorY.toJSON(), axisVector.toJSON()];
|
|
892
|
+
return { cone: coneProps };
|
|
890
893
|
}
|
|
891
894
|
/** Convert strongly typed instance to tagged json */
|
|
892
895
|
handleSphere(data) {
|
|
893
896
|
const xData = data.cloneVectorX().normalizeWithLength();
|
|
894
897
|
const yData = data.cloneVectorY().normalizeWithLength();
|
|
895
898
|
const zData = data.cloneVectorZ().normalizeWithLength();
|
|
899
|
+
if (!xData.v || !yData.v || !zData.v)
|
|
900
|
+
return undefined;
|
|
901
|
+
const rigid = Matrix3d_1.Matrix3d.createIdentity();
|
|
902
|
+
const skew = Matrix3d_1.Matrix3d.createIdentity();
|
|
903
|
+
if (!data.cloneLocalToWorld().matrix.factorRigidSkew(rigid, skew))
|
|
904
|
+
return undefined;
|
|
905
|
+
const value = { center: data.cloneCenter().toJSON() };
|
|
906
|
+
// always specify an orthogonal frame if !identity for backwards compatibility
|
|
907
|
+
if (!rigid.isIdentity)
|
|
908
|
+
value.zxVectors = [zData.v.toJSON(), xData.v.toJSON()];
|
|
909
|
+
// specify a general matrix if skew/mirror local frame
|
|
910
|
+
if (!skew.isDiagonal || skew.determinant() < 0.0)
|
|
911
|
+
value.xyzVectors = [xData.v.toJSON(), yData.v.toJSON(), zData.v.toJSON()];
|
|
896
912
|
const latitudeSweep = data.cloneLatitudeSweep();
|
|
913
|
+
const fullSweep = latitudeSweep.isFullLatitudeSweep;
|
|
914
|
+
if (data.capped && !fullSweep)
|
|
915
|
+
value.capped = data.capped;
|
|
916
|
+
if (!fullSweep)
|
|
917
|
+
value.latitudeStartEnd = latitudeSweep.toJSON();
|
|
897
918
|
const rX = xData.mag;
|
|
898
919
|
const rY = yData.mag;
|
|
899
920
|
const rZ = zData.mag;
|
|
900
|
-
if (
|
|
901
|
-
|
|
902
|
-
center: data.cloneCenter().toJSON(),
|
|
903
|
-
};
|
|
904
|
-
if (!(data.getConstructiveFrame()).matrix.isIdentity)
|
|
905
|
-
value.zxVectors = [zData.v.toJSON(), xData.v.toJSON()];
|
|
906
|
-
const fullSweep = latitudeSweep.isFullLatitudeSweep;
|
|
907
|
-
if (data.capped && !fullSweep)
|
|
908
|
-
value.capped = data.capped;
|
|
909
|
-
if (Geometry_1.Geometry.isSameCoordinate(rX, rY) && Geometry_1.Geometry.isSameCoordinate(rX, rZ))
|
|
921
|
+
if (Geometry_1.Geometry.isSameCoordinate(rX, rY)) {
|
|
922
|
+
if (Geometry_1.Geometry.isSameCoordinate(rX, rZ))
|
|
910
923
|
value.radius = rX;
|
|
911
|
-
else {
|
|
924
|
+
else { // radiusY will pick up radiusX
|
|
912
925
|
value.radiusX = rX;
|
|
913
|
-
value.radiusY = rY;
|
|
914
926
|
value.radiusZ = rZ;
|
|
915
927
|
}
|
|
916
|
-
if (!fullSweep)
|
|
917
|
-
value.latitudeStartEnd = latitudeSweep.toJSON();
|
|
918
|
-
return { sphere: value };
|
|
919
928
|
}
|
|
920
|
-
|
|
929
|
+
else {
|
|
930
|
+
value.radiusX = rX;
|
|
931
|
+
value.radiusY = rY;
|
|
932
|
+
value.radiusZ = rZ;
|
|
933
|
+
}
|
|
934
|
+
return { sphere: value };
|
|
921
935
|
}
|
|
922
936
|
/** Convert strongly typed instance to tagged json */
|
|
923
937
|
handleTorusPipe(data) {
|