@itwin/core-geometry 5.0.0-dev.20 → 5.0.0-dev.23

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.
Files changed (69) hide show
  1. package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
  2. package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
  3. package/lib/cjs/curve/Arc3d.d.ts +10 -1
  4. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  5. package/lib/cjs/curve/Arc3d.js +13 -1
  6. package/lib/cjs/curve/Arc3d.js.map +1 -1
  7. package/lib/cjs/curve/CurveFactory.d.ts +10 -4
  8. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  9. package/lib/cjs/curve/CurveFactory.js +50 -59
  10. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  11. package/lib/cjs/curve/StrokeOptions.d.ts +3 -3
  12. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  13. package/lib/cjs/curve/StrokeOptions.js +1 -1
  14. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  15. package/lib/cjs/geometry3d/PolylineOps.d.ts +2 -1
  16. package/lib/cjs/geometry3d/PolylineOps.d.ts.map +1 -1
  17. package/lib/cjs/geometry3d/PolylineOps.js +2 -1
  18. package/lib/cjs/geometry3d/PolylineOps.js.map +1 -1
  19. package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts +27 -20
  20. package/lib/cjs/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
  21. package/lib/cjs/polyface/IndexedEdgeMatcher.js +56 -30
  22. package/lib/cjs/polyface/IndexedEdgeMatcher.js.map +1 -1
  23. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
  24. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  25. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +2 -1
  26. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  27. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +4 -4
  28. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  29. package/lib/cjs/polyface/PolyfaceBuilder.js +18 -50
  30. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  31. package/lib/cjs/solid/SweepContour.d.ts +24 -15
  32. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  33. package/lib/cjs/solid/SweepContour.js +24 -15
  34. package/lib/cjs/solid/SweepContour.js.map +1 -1
  35. package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
  36. package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
  37. package/lib/esm/curve/Arc3d.d.ts +10 -1
  38. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  39. package/lib/esm/curve/Arc3d.js +13 -1
  40. package/lib/esm/curve/Arc3d.js.map +1 -1
  41. package/lib/esm/curve/CurveFactory.d.ts +10 -4
  42. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  43. package/lib/esm/curve/CurveFactory.js +50 -59
  44. package/lib/esm/curve/CurveFactory.js.map +1 -1
  45. package/lib/esm/curve/StrokeOptions.d.ts +3 -3
  46. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  47. package/lib/esm/curve/StrokeOptions.js +1 -1
  48. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  49. package/lib/esm/geometry3d/PolylineOps.d.ts +2 -1
  50. package/lib/esm/geometry3d/PolylineOps.d.ts.map +1 -1
  51. package/lib/esm/geometry3d/PolylineOps.js +2 -1
  52. package/lib/esm/geometry3d/PolylineOps.js.map +1 -1
  53. package/lib/esm/polyface/IndexedEdgeMatcher.d.ts +27 -20
  54. package/lib/esm/polyface/IndexedEdgeMatcher.d.ts.map +1 -1
  55. package/lib/esm/polyface/IndexedEdgeMatcher.js +56 -30
  56. package/lib/esm/polyface/IndexedEdgeMatcher.js.map +1 -1
  57. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -1
  58. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  59. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +2 -1
  60. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  61. package/lib/esm/polyface/PolyfaceBuilder.d.ts +4 -4
  62. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  63. package/lib/esm/polyface/PolyfaceBuilder.js +19 -51
  64. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  65. package/lib/esm/solid/SweepContour.d.ts +24 -15
  66. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  67. package/lib/esm/solid/SweepContour.js +24 -15
  68. package/lib/esm/solid/SweepContour.js.map +1 -1
  69. package/package.json +3 -3
@@ -283,6 +283,44 @@ class CurveFactory {
283
283
  }
284
284
  return undefined;
285
285
  }
286
+ /** Get start point and tangent for variant curve data. */
287
+ static startPointAndTangent(curve) {
288
+ if (curve instanceof CurvePrimitive_1.CurvePrimitive)
289
+ return curve.fractionToPointAndDerivative(0.0);
290
+ if (curve.length < 2)
291
+ return undefined;
292
+ if (Array.isArray(curve))
293
+ curve = new Point3dArrayCarrier_1.Point3dArrayCarrier(curve);
294
+ const ray = Ray3d_1.Ray3d.createZero();
295
+ curve.getPoint3dAtUncheckedPointIndex(0, ray.origin);
296
+ curve.vectorIndexIndex(0, 1, ray.direction);
297
+ return ray;
298
+ }
299
+ ;
300
+ /** Create an [[Arc3d]] from `sectionData` that has its center at the start point of the centerline. */
301
+ static createArcFromSectionData(centerline, sectionData) {
302
+ const ray = CurveFactory.startPointAndTangent(centerline);
303
+ if (!ray)
304
+ return undefined;
305
+ let arc;
306
+ if (sectionData instanceof Arc3d_1.Arc3d) {
307
+ arc = sectionData.clone();
308
+ arc.center = ray.origin;
309
+ }
310
+ else {
311
+ const vector0 = Point3dVector3d_1.Vector3d.create();
312
+ const vector90 = Point3dVector3d_1.Vector3d.create();
313
+ const length0 = (typeof sectionData === "number") ? sectionData : sectionData.x;
314
+ const length90 = (typeof sectionData === "number") ? sectionData : sectionData.y;
315
+ const baseFrame = Matrix3d_1.Matrix3d.createRigidHeadsUp(ray.direction, Geometry_1.AxisOrder.ZXY);
316
+ baseFrame.columnX(vector0).scaleInPlace(length0);
317
+ baseFrame.columnY(vector90).scaleInPlace(length90);
318
+ arc = Arc3d_1.Arc3d.create(ray.origin, vector0, vector90);
319
+ }
320
+ if (arc.binormalVector().dotProduct(ray.direction) < 0.0)
321
+ arc.reverseInPlace();
322
+ return arc;
323
+ }
286
324
  /**
287
325
  * Create section arcs for mitered pipe.
288
326
  * * At the end of each pipe segment, the pipe is mitered by the plane that bisects the angle between successive
@@ -295,63 +333,22 @@ class CurveFactory {
295
333
  * lengths, or an Arc3d:
296
334
  * * For semi-axis length input, x and y correspond to ellipse local axes perpendicular to each other and to the
297
335
  * start tangent.
298
- * * For Arc3d input, the center is translated to the centerline start point, but otherwise the arc is used as-is
299
- * for the first section. For best results, the arc should be perpendicular to the centerline start tangent.
336
+ * * For Arc3d input, the center is translated to the centerline start point. For best results, ensure this arc
337
+ * is perpendicular to the centerline start tangent.
338
+ * * This function internally calls [[createMiteredSweepSections]] with default options.
300
339
  * @param centerline centerline of pipe. For best results, ensure no successive duplicate points with e.g.,
301
340
  * [[GrowableXYZArray.createCompressed]].
302
341
  * @param sectionData circle radius, ellipse semi-axis lengths, or full Arc3d (if not full, function makes it full).
342
+ * @returns array of sections or empty array if section creation failed.
303
343
  */
304
344
  static createMiteredPipeSections(centerline, sectionData) {
305
- const arcs = [];
306
- if (centerline.length < 2)
345
+ const arc = CurveFactory.createArcFromSectionData(centerline, sectionData);
346
+ if (!arc)
307
347
  return [];
308
- const vector0 = Point3dVector3d_1.Vector3d.create();
309
- const vector90 = Point3dVector3d_1.Vector3d.create();
310
- const vectorBC = Point3dVector3d_1.Vector3d.create();
311
- const sweep = AngleSweep_1.AngleSweep.create360();
312
- centerline.vectorIndexIndex(0, 1, vectorBC); // initially, the start tangent
313
- if (sectionData instanceof Arc3d_1.Arc3d) {
314
- vector0.setFrom(sectionData.vector0);
315
- vector90.setFrom(sectionData.vector90);
316
- sweep.setFrom(sectionData.sweep); // allow e.g., half-pipe
317
- const sectionFacesForward = sectionData.matrixRef.columnDotXYZ(Geometry_1.AxisIndex.Z, vectorBC.x, vectorBC.y, vectorBC.z) > 0;
318
- if (sectionFacesForward !== sectionData.sweep.isCCW)
319
- sweep.reverseInPlace();
320
- }
321
- else if (typeof sectionData === "number" || Point3dVector3d_1.Point3d.isXAndY(sectionData)) {
322
- const length0 = (typeof sectionData === "number") ? sectionData : sectionData.x;
323
- const length90 = (typeof sectionData === "number") ? sectionData : sectionData.y;
324
- const baseFrame = Matrix3d_1.Matrix3d.createRigidHeadsUp(vectorBC, Geometry_1.AxisOrder.ZXY);
325
- baseFrame.columnX(vector0).scaleInPlace(length0);
326
- baseFrame.columnY(vector90).scaleInPlace(length90);
327
- }
328
- else {
329
- return [];
330
- }
331
- // ASSUME: initial section normal points toward sweep direction for subsequent facet creation
332
- const initialSection = Arc3d_1.Arc3d.create(undefined, vector0, vector90, sweep);
333
- centerline.getPoint3dAtUncheckedPointIndex(0, initialSection.centerRef);
334
- arcs.push(initialSection);
335
- const vectorAB = Point3dVector3d_1.Vector3d.create();
336
- const bisector = Point3dVector3d_1.Vector3d.create();
337
- const center = Point3dVector3d_1.Point3d.create();
338
- for (let i = 1; i < centerline.length; i++) {
339
- vectorAB.setFromVector3d(vectorBC);
340
- centerline.getPoint3dAtUncheckedPointIndex(i, center);
341
- if (i + 1 < centerline.length)
342
- centerline.vectorIndexIndex(i, i + 1, vectorBC);
343
- else
344
- vectorBC.setFromVector3d(vectorAB);
345
- if (vectorAB.normalizeInPlace() && vectorBC.normalizeInPlace()) {
346
- vectorAB.interpolate(0.5, vectorBC, bisector);
347
- // At pipe end, the ellipse center comes directly from centerline[i], and vector0/vector90 are
348
- // obtained by sweeping the corresponding vectors of the pipe start ellipse to the bisector plane.
349
- moveVectorToPlane(vector0, vectorAB, bisector, vector0);
350
- moveVectorToPlane(vector90, vectorAB, bisector, vector90);
351
- arcs.push(Arc3d_1.Arc3d.create(center, vector0, vector90, sweep));
352
- }
353
- }
354
- return arcs;
348
+ const miteredSweeps = CurveFactory.createMiteredSweepSections(centerline, arc);
349
+ if (miteredSweeps)
350
+ return miteredSweeps.sections;
351
+ return [];
355
352
  }
356
353
  /** For a smooth curve, stroke and return unnormalized start/end tangents. */
357
354
  static strokeSmoothCurve(curve, options) {
@@ -453,6 +450,8 @@ class CurveFactory {
453
450
  * @return array of sections, formed from projecting `initialSection` successively onto the bisector planes.
454
451
  */
455
452
  static createMiteredSweepSections(centerline, initialSection, options) {
453
+ if (!options)
454
+ options = {};
456
455
  const rail = this.strokeSmoothCurve(centerline, options.strokeOptions);
457
456
  if (!rail)
458
457
  return undefined;
@@ -653,12 +652,4 @@ class CurveFactory {
653
652
  }
654
653
  }
655
654
  exports.CurveFactory = CurveFactory;
656
- /** Starting at vectorR, move parallel to vectorV until perpendicular to planeNormal. */
657
- function moveVectorToPlane(vectorR, vectorV, planeNormal, result) {
658
- // find s such that (vectorR + s * vectorV) DOT planeNormal = 0.
659
- const dotRN = vectorR.dotProduct(planeNormal);
660
- const dotVN = vectorV.dotProduct(planeNormal);
661
- const s = Geometry_1.Geometry.safeDivideFraction(dotRN, dotVN, 0.0);
662
- return vectorR.plusScaled(vectorV, -s, result);
663
- }
664
655
  //# sourceMappingURL=CurveFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CurveFactory.js","sourceRoot":"","sources":["../../../src/curve/CurveFactory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAqF;AACrF,+CAA4C;AAC5C,yDAAsD;AAGtD,qDAAkD;AAElD,mEAAyD;AACzD,2EAAwE;AACxE,mEAAkE;AAClE,2DAAwD;AACxD,+CAA4C;AAC5C,uDAAoD;AACpD,uDAAoD;AAEpD,yDAAsD;AAEtD,iEAA8D;AAC9D,wC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QAAQ,EAAE,QAAQ,EAC5B,CAAC,SAAS,EAAE,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAC/B,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,OAAO,aAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjG,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA/qBD,oCA+qBC;AACD,wFAAwF;AACxF,SAAS,iBAAiB,CAAC,OAAiB,EAAE,OAAiB,EAAE,WAAqB,EAAE,MAAiB;IACvG,gEAAgE;IAChE,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC9C,MAAM,CAAC,GAAG,mBAAQ,CAAC,kBAAkB,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACjD,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { AxisIndex, AxisOrder, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { AngleSweep } from \"../geometry3d/AngleSweep\";\r\nimport { Ellipsoid, GeodesicPathPoint } from \"../geometry3d/Ellipsoid\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineOps } from \"../geometry3d/PolylineOps\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Segment1d } from \"../geometry3d/Segment1d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { SmallSystem } from \"../numerics/SmallSystem\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { Cone } from \"../solid/Cone\";\r\nimport { RuledSweep } from \"../solid/RuledSweep\";\r\nimport { TorusPipe } from \"../solid/TorusPipe\";\r\nimport { Arc3d, ArcBlendData } from \"./Arc3d\";\r\nimport { CurveChain } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveTypes\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { Path } from \"./Path\";\r\nimport { RegionOps } from \"./RegionOps\";\r\nimport { IntegratedSpiral3d } from \"./spiral/IntegratedSpiral3d\";\r\nimport { IntegratedSpiralTypeName } from \"./spiral/TransitionSpiral3d\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n// cspell:word CCWXY\r\n\r\n/**\r\n * Interface to carry parallel arrays of planes and sections, and optional geometry assembled from them,\r\n * as returned by [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport interface SectionSequenceWithPlanes {\r\n /** The plane of each section. */\r\n planes: Plane3dByOriginAndUnitNormal[];\r\n /** Section curve projected onto the corresponding plane. */\r\n sections: AnyCurve[];\r\n /**\r\n * Optional `RuledSweep` generated from the sections.\r\n * * The `RuledSweep` and sections array refer to the same section objects.\r\n */\r\n ruledSweep?: RuledSweep;\r\n /** Optional mesh generated from the `RuledSweep` generated from the sections. */\r\n mesh?: IndexedPolyface;\r\n}\r\n\r\n/**\r\n * Enumeration of geometric output for [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport enum MiteredSweepOutputSelect {\r\n /** Output only the parallel arrays of planes and sections. */\r\n Sections = 0,\r\n /** Output planes and sections, as well as the assembled ruled sweep. */\r\n AlsoRuledSweep = 1,\r\n /** Output planes and sections, as well as the assembled ruled sweep and its stroked mesh. */\r\n AlsoMesh = 2,\r\n}\r\n\r\n/**\r\n * Interface bundling options for [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport interface MiteredSweepOptions {\r\n /** Whether first and last planes are averaged and equated when the centerline is physically closed. Default value is `false`. */\r\n wrapIfPhysicallyClosed?: boolean;\r\n /** Whether to output sections only, or sections plus optional geometry constructed from them. Default value is `MiteredSweepOutputSelect.Sections`. */\r\n outputSelect?: MiteredSweepOutputSelect;\r\n /** How to stroke smooth input curves and the ruled sweep (if outputting a mesh). If undefined, default stroke options are used. */\r\n strokeOptions?: StrokeOptions;\r\n /** Whether to cap the ruled sweep if outputting a ruled sweep or mesh. Default value is `false`. */\r\n capped?: boolean;\r\n /** The first section's normal is aligned to this vector, typically the start tangent of the smooth curve stroked for the centerline. */\r\n startTangent?: Vector3d;\r\n /** The last section's normal is aligned to this vector, typically the end tangent of the smooth curve stroked for the centerline. */\r\n endTangent?: Vector3d;\r\n}\r\n\r\n/**\r\n * Curve strokes plus start/end tangents.\r\n * @internal\r\n*/\r\ninterface SmoothCurveData {\r\n /** Samples along a curve. */\r\n strokes: IndexedXYZCollection;\r\n /** Start tangent (unnormalized). May be undefined if the curve is linear. */\r\n startTangent?: Vector3d;\r\n /** End tangent (unnormalized). May be undefined if the curve is linear. */\r\n endTangent?: Vector3d;\r\n};\r\n\r\n/**\r\n * The `CurveFactory` class contains methods for specialized curve constructions.\r\n * @public\r\n */\r\nexport class CurveFactory {\r\n /** (Cautiously) construct and save a line segment between fractional positions. */\r\n private static addPartialSegment(\r\n path: Path, allowBackup: boolean,\r\n pointA: Point3d | undefined, pointB: Point3d | undefined,\r\n fraction0: number, fraction1: number,\r\n ) {\r\n if (allowBackup || (fraction1 > fraction0)) {\r\n if (pointA !== undefined && pointB !== undefined && !Geometry.isAlmostEqualNumber(fraction0, fraction1))\r\n path.tryAddChild(LineSegment3d.create(pointA.interpolate(fraction0, pointB), pointA.interpolate(fraction1, pointB)));\r\n }\r\n }\r\n /**\r\n * Create a circular arc defined by start point, tangent at start point, and end point.\r\n * * The circular arc is swept from start to end toward direction of the `tangentAtStart`.\r\n * * If tangent is parallel to line segment from start to end, return `undefined`.\r\n */\r\n public static createArcPointTangentPoint(start: Point3d, tangentAtStart: Vector3d, end: Point3d): Arc3d | undefined {\r\n const ret = Arc3d.createCircularStartTangentEnd(start, tangentAtStart, end);\r\n if (ret instanceof Arc3d)\r\n return ret;\r\n else\r\n return undefined;\r\n }\r\n /**\r\n * Construct a sequence of alternating lines and arcs with the arcs creating tangent transition between consecutive edges.\r\n * * If the radius parameter is a number, that radius is used throughout.\r\n * * If the radius parameter is an array of numbers, `radius[i]` is applied at `point[i]`.\r\n * * Note that since no fillet is constructed at the initial or final point, those entries in `radius[]` are never referenced.\r\n * * A zero radius for any point indicates to leave the as a simple corner.\r\n * @param points point source\r\n * @param radius fillet radius or array of radii indexed to correspond to the points.\r\n * @param allowBackupAlongEdge true to allow edges to be created going \"backwards\" along edges if needed to create the blend.\r\n */\r\n public static createFilletsInLineString(\r\n points: LineString3d | IndexedXYZCollection | Point3d[],\r\n radius: number | number[],\r\n allowBackupAlongEdge: boolean = true,\r\n ): Path | undefined {\r\n if (Array.isArray(points))\r\n return this.createFilletsInLineString(new Point3dArrayCarrier(points), radius, allowBackupAlongEdge);\r\n if (points instanceof LineString3d)\r\n return this.createFilletsInLineString(points.packedPoints, radius, allowBackupAlongEdge);\r\n const n = points.length;\r\n if (n <= 1)\r\n return undefined;\r\n const pointA = points.getPoint3dAtCheckedPointIndex(0)!;\r\n const pointB = points.getPoint3dAtCheckedPointIndex(1)!;\r\n // remark: n=2 and n=3 cases should fall out from loop logic\r\n const blendArray: ArcBlendData[] = [];\r\n // build one-sided blends at each end . .\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointA.clone() });\r\n for (let i = 1; i + 1 < n; i++) {\r\n const pointC = points.getPoint3dAtCheckedPointIndex(i + 1)!;\r\n let thisRadius = 0;\r\n if (Array.isArray(radius)) {\r\n if (i < radius.length)\r\n thisRadius = radius[i];\r\n } else if (Number.isFinite(radius))\r\n thisRadius = radius;\r\n if (thisRadius !== 0.0)\r\n blendArray.push(Arc3d.createFilletArc(pointA, pointB, pointC, thisRadius));\r\n else\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointB.clone() });\r\n pointA.setFromPoint3d(pointB);\r\n pointB.setFromPoint3d(pointC);\r\n }\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointB.clone() });\r\n if (!allowBackupAlongEdge) {\r\n // suppress arcs that have overlap with both neighbors or flood either neighbor ..\r\n for (let i = 1; i + 1 < n; i++) {\r\n const b = blendArray[i];\r\n if (b.fraction10 > 1.0\r\n || b.fraction12 > 1.0\r\n || 1.0 - b.fraction10 < blendArray[i - 1].fraction12\r\n || b.fraction12 > 1.0 - blendArray[i + 1].fraction10) {\r\n b.fraction10 = 0.0;\r\n b.fraction12 = 0.0;\r\n blendArray[i].arc = undefined;\r\n }\r\n }\r\n /* The \"1-b\" logic above prevents this loop from ever doing anything.\r\n // on edge with conflict, suppress the arc with larger fraction\r\n for (let i = 1; i < n; i++) {\r\n const b0 = blendArray[i - 1];\r\n const b1 = blendArray[i];\r\n if (b0.fraction12 > 1 - b1.fraction10) {\r\n const b = b0.fraction12 > b1.fraction12 ? b1 : b0;\r\n b.fraction10 = 0.0;\r\n b.fraction12 = 0.0;\r\n blendArray[i].arc = undefined;\r\n }\r\n } */\r\n }\r\n const path = Path.create();\r\n this.addPartialSegment(\r\n path, allowBackupAlongEdge,\r\n blendArray[0].point, blendArray[1].point,\r\n blendArray[0].fraction12, 1.0 - blendArray[1].fraction10,\r\n );\r\n // add each path and successor edge ...\r\n for (let i = 1; i + 1 < points.length; i++) {\r\n const b0 = blendArray[i];\r\n const b1 = blendArray[i + 1];\r\n path.tryAddChild(b0.arc);\r\n this.addPartialSegment(path, allowBackupAlongEdge, b0.point, b1.point, b0.fraction12, 1.0 - b1.fraction10);\r\n }\r\n return path;\r\n }\r\n /**\r\n * Create a `Loop` with given xy corners and fixed z.\r\n * * The corners always proceed counter clockwise from lower left.\r\n * * If the radius is too large for the outer rectangle size, it is reduced to half of the the smaller x or y size.\r\n */\r\n public static createRectangleXY(\r\n x0: number, y0: number, x1: number, y1: number, z: number = 0, filletRadius?: number,\r\n ): Loop {\r\n let radius = Geometry.correctSmallMetricDistance(filletRadius);\r\n const xMin = Math.min(x0, x1);\r\n const xMax = Math.max(x0, x1);\r\n const yMin = Math.min(y0, y1);\r\n const yMax = Math.max(y0, y1);\r\n radius = Math.min(Math.abs(radius), 0.5 * (xMax - xMin), 0.5 * (yMax - yMin));\r\n if (radius === 0.0)\r\n return Loop.createPolygon([\r\n Point3d.create(xMin, yMin, z),\r\n Point3d.create(xMax, yMin, z),\r\n Point3d.create(xMax, yMax, z),\r\n Point3d.create(xMin, yMax, z),\r\n Point3d.create(xMin, yMin, z),\r\n ]);\r\n else {\r\n const vectorU = Vector3d.create(radius, 0, 0);\r\n const vectorV = Vector3d.create(0, radius, 0);\r\n const x0A = xMin + radius;\r\n const y0A = yMin + radius;\r\n const x1A = xMax - radius;\r\n const y1A = yMax - radius;\r\n const centers = [\r\n Point3d.create(x1A, y1A, z),\r\n Point3d.create(x0A, y1A, z),\r\n Point3d.create(x0A, y0A, z),\r\n Point3d.create(x1A, y0A, z),\r\n ];\r\n const loop = Loop.create();\r\n for (let i = 0; i < 4; i++) {\r\n const center = centers[i];\r\n const nextCenter = centers[(i + 1) % 4];\r\n const edgeVector = Vector3d.createStartEnd(center, nextCenter);\r\n const arc = Arc3d.create(center, vectorU, vectorV, AngleSweep.createStartEndDegrees(0, 90));\r\n loop.tryAddChild(arc);\r\n const arcEnd = arc.endPoint();\r\n if (!edgeVector.isAlmostZero)\r\n loop.tryAddChild(LineSegment3d.create(arcEnd, arcEnd.plus(edgeVector)));\r\n vectorU.rotate90CCWXY(vectorU);\r\n vectorV.rotate90CCWXY(vectorV);\r\n }\r\n return loop;\r\n }\r\n }\r\n /**\r\n * If `arcB` is a continuation of `arcA`, extend `arcA` (in place) to include the range of `arcB`\r\n * * This only succeeds if the two arcs are part of identical complete arcs and end of `arcA` matches the beginning of `arcB`.\r\n * @param arcA first arc, modified in place.\r\n * @param arcB second arc, unmodified.\r\n * @param allowReversed whether to consolidate even when second arc is reversed.\r\n * @returns whether `arcA` was modified.\r\n */\r\n public static appendToArcInPlace(arcA: Arc3d, arcB: Arc3d, allowReverse: boolean = false): boolean {\r\n if (arcA.center.isAlmostEqual(arcB.center)) {\r\n const sweepSign = Geometry.split3WaySign(arcA.sweep.sweepRadians * arcB.sweep.sweepRadians, -1, 0, 1);\r\n // evaluate derivatives wrt radians (not fraction!), but adjust direction for sweep signs\r\n const endA = arcA.angleToPointAndDerivative(arcA.sweep.fractionToAngle(1.0));\r\n if (arcA.sweep.sweepRadians < 0)\r\n endA.direction.scaleInPlace(-1.0);\r\n const startB = arcB.angleToPointAndDerivative(arcB.sweep.fractionToAngle(0.0));\r\n if (arcB.sweep.sweepRadians < 0)\r\n startB.direction.scaleInPlace(-1.0);\r\n if (endA.isAlmostEqual(startB)) {\r\n arcA.sweep.setStartEndRadians(\r\n arcA.sweep.startRadians, arcA.sweep.startRadians + arcA.sweep.sweepRadians + sweepSign * arcB.sweep.sweepRadians,\r\n );\r\n return true;\r\n }\r\n // Also ok if negated tangent\r\n if (allowReverse) {\r\n startB.direction.scaleInPlace(-1.0);\r\n if (endA.isAlmostEqual(startB)) {\r\n arcA.sweep.setStartEndRadians(\r\n arcA.sweep.startRadians, arcA.sweep.startRadians + arcA.sweep.sweepRadians - sweepSign * arcB.sweep.sweepRadians,\r\n );\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return a `Path` containing arcs are on the surface of an ellipsoid and pass through a sequence of points.\r\n * * Each arc passes through the two given endpoints and in the plane containing the true surface normal at\r\n * given `fractionForIntermediateNormal`\r\n * @param ellipsoid\r\n * @param pathPoints\r\n * @param fractionForIntermediateNormal fractional position for surface normal used to create the section plane.\r\n */\r\n public static assembleArcChainOnEllipsoid(\r\n ellipsoid: Ellipsoid, pathPoints: GeodesicPathPoint[], fractionForIntermediateNormal: number = 0.5,\r\n ): Path {\r\n const arcPath = Path.create();\r\n for (let i = 0; i + 1 < pathPoints.length; i++) {\r\n const arc = ellipsoid.sectionArcWithIntermediateNormal(\r\n pathPoints[i].toAngles(),\r\n fractionForIntermediateNormal,\r\n pathPoints[i + 1].toAngles());\r\n arcPath.tryAddChild(arc);\r\n }\r\n return arcPath;\r\n }\r\n private static appendGeometryQueryArray(candidate: GeometryQuery | GeometryQuery[] | undefined, result: GeometryQuery[]) {\r\n if (candidate instanceof GeometryQuery)\r\n result.push(candidate);\r\n else if (Array.isArray(candidate)) {\r\n for (const p of candidate)\r\n this.appendGeometryQueryArray(p, result);\r\n }\r\n }\r\n /**\r\n * Create solid primitives for pipe segments (e.g. Cone or TorusPipe) around line and arc primitives.\r\n * @param centerline centerline geometry.\r\n * @param pipeRadius radius of pipe.\r\n */\r\n public static createPipeSegments(\r\n centerline: CurvePrimitive | CurveChain, pipeRadius: number,\r\n ): GeometryQuery | GeometryQuery[] | undefined {\r\n if (centerline instanceof LineSegment3d) {\r\n return Cone.createAxisPoints(centerline.startPoint(), centerline.endPoint(), pipeRadius, pipeRadius, false);\r\n } else if (centerline instanceof Arc3d) {\r\n return TorusPipe.createAlongArc(centerline, pipeRadius, false);\r\n } else if (centerline instanceof CurvePrimitive) {\r\n const builder = PolyfaceBuilder.create();\r\n builder.addMiteredPipes(centerline, pipeRadius);\r\n return builder.claimPolyface();\r\n } else if (centerline instanceof CurveChain) {\r\n const result: GeometryQuery[] = [];\r\n for (const p of centerline.children) {\r\n const pipe = this.createPipeSegments(p, pipeRadius);\r\n this.appendGeometryQueryArray(pipe, result);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Create section arcs for mitered pipe.\r\n * * At the end of each pipe segment, the pipe is mitered by the plane that bisects the angle between successive\r\n * centerline segments.\r\n * * The section arcs are constructed so that lines between corresponding fractional positions on the arcs are\r\n * axial lines on the pipes.\r\n * * This means that the initial arc's vector0 and vector90 lengths and angular separation are _not_ preserved in\r\n * the section arcs.\r\n * * Circular or elliptical pipe cross sections can be specified by supplying either a radius, a pair of semi-axis\r\n * lengths, or an Arc3d:\r\n * * For semi-axis length input, x and y correspond to ellipse local axes perpendicular to each other and to the\r\n * start tangent.\r\n * * For Arc3d input, the center is translated to the centerline start point, but otherwise the arc is used as-is\r\n * for the first section. For best results, the arc should be perpendicular to the centerline start tangent.\r\n * @param centerline centerline of pipe. For best results, ensure no successive duplicate points with e.g.,\r\n * [[GrowableXYZArray.createCompressed]].\r\n * @param sectionData circle radius, ellipse semi-axis lengths, or full Arc3d (if not full, function makes it full).\r\n */\r\n public static createMiteredPipeSections(centerline: IndexedXYZCollection, sectionData: number | XAndY | Arc3d): Arc3d[] {\r\n const arcs: Arc3d[] = [];\r\n if (centerline.length < 2)\r\n return [];\r\n const vector0 = Vector3d.create();\r\n const vector90 = Vector3d.create();\r\n const vectorBC = Vector3d.create();\r\n const sweep = AngleSweep.create360();\r\n centerline.vectorIndexIndex(0, 1, vectorBC)!; // initially, the start tangent\r\n if (sectionData instanceof Arc3d) {\r\n vector0.setFrom(sectionData.vector0);\r\n vector90.setFrom(sectionData.vector90);\r\n sweep.setFrom(sectionData.sweep); // allow e.g., half-pipe\r\n const sectionFacesForward = sectionData.matrixRef.columnDotXYZ(AxisIndex.Z, vectorBC.x, vectorBC.y, vectorBC.z) > 0;\r\n if (sectionFacesForward !== sectionData.sweep.isCCW)\r\n sweep.reverseInPlace();\r\n } else if (typeof sectionData === \"number\" || Point3d.isXAndY(sectionData)) {\r\n const length0 = (typeof sectionData === \"number\") ? sectionData : sectionData.x;\r\n const length90 = (typeof sectionData === \"number\") ? sectionData : sectionData.y;\r\n const baseFrame = Matrix3d.createRigidHeadsUp(vectorBC, AxisOrder.ZXY);\r\n baseFrame.columnX(vector0).scaleInPlace(length0);\r\n baseFrame.columnY(vector90).scaleInPlace(length90);\r\n } else {\r\n return [];\r\n }\r\n // ASSUME: initial section normal points toward sweep direction for subsequent facet creation\r\n const initialSection = Arc3d.create(undefined, vector0, vector90, sweep);\r\n centerline.getPoint3dAtUncheckedPointIndex(0, initialSection.centerRef);\r\n arcs.push(initialSection);\r\n const vectorAB = Vector3d.create();\r\n const bisector = Vector3d.create();\r\n const center = Point3d.create();\r\n for (let i = 1; i < centerline.length; i++) {\r\n vectorAB.setFromVector3d(vectorBC);\r\n centerline.getPoint3dAtUncheckedPointIndex(i, center);\r\n if (i + 1 < centerline.length)\r\n centerline.vectorIndexIndex(i, i + 1, vectorBC)!;\r\n else\r\n vectorBC.setFromVector3d(vectorAB);\r\n if (vectorAB.normalizeInPlace() && vectorBC.normalizeInPlace()) {\r\n vectorAB.interpolate(0.5, vectorBC, bisector);\r\n // At pipe end, the ellipse center comes directly from centerline[i], and vector0/vector90 are\r\n // obtained by sweeping the corresponding vectors of the pipe start ellipse to the bisector plane.\r\n moveVectorToPlane(vector0, vectorAB, bisector, vector0);\r\n moveVectorToPlane(vector90, vectorAB, bisector, vector90);\r\n arcs.push(Arc3d.create(center, vector0, vector90, sweep));\r\n }\r\n }\r\n return arcs;\r\n }\r\n\r\n /** For a smooth curve, stroke and return unnormalized start/end tangents. */\r\n private static strokeSmoothCurve(\r\n curve: IndexedXYZCollection | Point3d[] | CurvePrimitive | CurveChain,\r\n options?: StrokeOptions,\r\n ): SmoothCurveData | undefined {\r\n let startTangent, endTangent: Vector3d | undefined;\r\n if (curve instanceof CurvePrimitive) {\r\n startTangent = curve.fractionToPointAndDerivative(0.0).direction;\r\n endTangent = curve.fractionToPointAndDerivative(1.0).direction;\r\n const strokes = LineString3d.create();\r\n curve.emitStrokes(strokes, options);\r\n curve = strokes.packedPoints;\r\n } else if (curve instanceof CurveChain) {\r\n startTangent = curve.startPointAndDerivative()?.direction;\r\n endTangent = curve.endPointAndDerivative()?.direction;\r\n const strokes = curve.getPackedStrokes(options);\r\n if (!strokes)\r\n return undefined;\r\n curve = strokes;\r\n } else if (Array.isArray(curve))\r\n curve = new Point3dArrayCarrier(curve);\r\n return { strokes: curve, startTangent, endTangent };\r\n }\r\n\r\n /**\r\n * Align two bisector plane normals to given smooth rail tangents or optional overrides.\r\n * * Optionally average the normals for physically closed rail.\r\n */\r\n private static alignFirstAndLastBisectorPlanes(\r\n firstPlane: Plane3dByOriginAndUnitNormal,\r\n lastPlane: Plane3dByOriginAndUnitNormal,\r\n smoothRailData?: SmoothCurveData,\r\n options?: MiteredSweepOptions,\r\n ) {\r\n const normal0 = options?.startTangent ?? (smoothRailData?.startTangent ?? firstPlane.getNormalRef());\r\n const normal1 = options?.endTangent ?? (smoothRailData?.endTangent ?? lastPlane.getNormalRef());\r\n if (options?.wrapIfPhysicallyClosed && firstPlane.getOriginRef().isAlmostEqual(lastPlane.getOriginRef())) {\r\n const avgNormal = normal0.plus(normal1);\r\n if (avgNormal.tryNormalizeInPlace()) { // ignore cusp at seam\r\n firstPlane.getNormalRef().setFrom(avgNormal);\r\n lastPlane.getNormalRef().setFrom(avgNormal);\r\n return;\r\n }\r\n }\r\n if (normal0.tryNormalizeInPlace())\r\n firstPlane.getNormalRef().setFrom(normal0);\r\n if (normal1.tryNormalizeInPlace())\r\n lastPlane.getNormalRef().setFrom(normal1);\r\n }\r\n\r\n /** Reverse a closed curve or region if necessary so that its orientation is CCW with respect to the plane normal. */\r\n private static alignClosedCurveToPlane(curve: AnyCurve, planeNormal: Vector3d) {\r\n let closedCurve: AnyRegion | undefined;\r\n if (curve instanceof CurvePrimitive) {\r\n if (curve.startPoint().isAlmostEqual(curve.endPoint()))\r\n closedCurve = Loop.create(curve);\r\n } else if (curve.isAnyRegion())\r\n closedCurve = curve;\r\n if (closedCurve) {\r\n // The alignment condition is equivalent to positive projected curve area computed wrt to the plane normal.\r\n const toLocal = Matrix3d.createRigidHeadsUp(planeNormal).transpose();\r\n const projection = closedCurve.cloneTransformed(Transform.createOriginAndMatrix(undefined, toLocal));\r\n if (projection) { // now we can ignore z-coords\r\n const areaXY = RegionOps.computeXYArea(projection as AnyRegion);\r\n if (areaXY && areaXY < 0)\r\n curve.reverseInPlace();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Projection to target plane, constructing sweep direction from two given planes.\r\n * * If successful, push the target plane and swept section to the output arrays and return the swept section.\r\n * * If unsuccessful, leave the output arrays alone and return the input section.\r\n */\r\n private static doSweepToPlane(\r\n output: SectionSequenceWithPlanes,\r\n edgePlane0: Plane3dByOriginAndUnitNormal,\r\n edgePlane1: Plane3dByOriginAndUnitNormal,\r\n targetPlane: Plane3dByOriginAndUnitNormal,\r\n section: AnyCurve,\r\n ): AnyCurve {\r\n const sweepVector = Vector3d.createStartEnd(edgePlane0.getOriginRef(), edgePlane1.getOriginRef());\r\n const transform = Transform.createFlattenAlongVectorToPlane(\r\n sweepVector, targetPlane.getOriginRef(), targetPlane.getNormalRef(),\r\n );\r\n if (transform === undefined)\r\n return section;\r\n const transformedSection = section.cloneTransformed(transform);\r\n if (transformedSection === undefined)\r\n return section;\r\n output.planes.push(targetPlane);\r\n output.sections.push(transformedSection);\r\n return transformedSection;\r\n }\r\n\r\n /**\r\n * Sweep the `initialSection` along each segment of the (stroked) `centerline` until it hits the bisector plane at\r\n * the next vertex.\r\n * * For best results, the caller should place `initialSection` in a plane perpendicular to the `centerline`\r\n * start tangent.\r\n * * This plane is commonly (but not necessarily) through the centerline start point itself.\r\n * * To compute the sections, `initialSection` is projected in the direction of the centerline start tangent onto\r\n * the first bisector plane at the centerline start. The result of this projection will be likewise projected onto\r\n * the second plane, and so on in sequence.\r\n * * By default, the first/last bisector plane normals are set to the centerline start/end tangents. The caller can\r\n * override these with tangents supplied in `options`. If the centerline is physically closed and\r\n * `options.wrapIfPhysicallyClosed` is true, the first and last plane normals are averaged and equated.\r\n * * The centerline path does NOT have to be planar, however non-planarity will result in twisting of the sections\r\n * in the bisector planes.\r\n * @param centerline sweep path. Will be stroked if smooth.\r\n * @param initialSection profile curve to be swept. As noted above, this should be on a plane perpendicular to the\r\n * centerline start tangent.\r\n * @param options options for computation and output.\r\n * @return array of sections, formed from projecting `initialSection` successively onto the bisector planes.\r\n */\r\n public static createMiteredSweepSections(\r\n centerline: IndexedXYZCollection | Point3d[] | CurvePrimitive | CurveChain,\r\n initialSection: AnyCurve,\r\n options: MiteredSweepOptions,\r\n ): SectionSequenceWithPlanes | undefined {\r\n const rail = this.strokeSmoothCurve(centerline, options.strokeOptions);\r\n if (!rail)\r\n return undefined;\r\n const planes = PolylineOps.createBisectorPlanesForDistinctPoints(rail.strokes);\r\n if (!planes || planes.length < 2)\r\n return undefined;\r\n this.alignFirstAndLastBisectorPlanes(planes[0], planes[planes.length - 1], rail, options);\r\n\r\n // RuledSweep facet construction assumes the contours are oriented CCW with respect to the sweep direction so that\r\n // facet normals point outward. We only have to align the first contour; the rest will inherit its orientation.\r\n this.alignClosedCurveToPlane(initialSection, planes[0].getNormalRef());\r\n\r\n const sectionData: SectionSequenceWithPlanes = { sections: [], planes: [] };\r\n let currentSection = this.doSweepToPlane(sectionData, planes[0], planes[1], planes[0], initialSection);\r\n for (let i = 1; i < planes.length; i++)\r\n currentSection = this.doSweepToPlane(sectionData, planes[i - 1], planes[i], planes[i], currentSection);\r\n\r\n if (options.outputSelect) {\r\n const ruledSweep = RuledSweep.create(sectionData.sections, options.capped ?? false);\r\n if (ruledSweep) {\r\n sectionData.ruledSweep = ruledSweep;\r\n if (MiteredSweepOutputSelect.AlsoMesh === options.outputSelect) {\r\n const builder = PolyfaceBuilder.create(options.strokeOptions);\r\n builder.addRuledSweep(ruledSweep);\r\n sectionData.mesh = builder.claimPolyface();\r\n }\r\n }\r\n }\r\n return sectionData;\r\n }\r\n /**\r\n * Create a circular arc from start point, tangent at start, radius, optional plane normal, arc sweep.\r\n * * The vector from start point to center is in the direction of upVector crossed with tangentA.\r\n * @param start start point.\r\n * @param tangentAtStart vector in tangent direction at the start.\r\n * @param radius signed radius.\r\n * @param upVector optional out-of-plane vector. Defaults to positive Z.\r\n * @param sweep angular range. If single `Angle` is given, start angle is at 0 degrees (the start point).\r\n */\r\n public static createArcPointTangentRadius(\r\n start: Point3d, tangentAtStart: Vector3d, radius: number, upVector?: Vector3d, sweep?: Angle | AngleSweep,\r\n ): Arc3d | undefined {\r\n return Arc3d.createCircularStartTangentRadius(start, tangentAtStart, radius, upVector, sweep);\r\n }\r\n /**\r\n * Compute 2 spirals (all in XY) for a symmetric line-to-line transition.\r\n * * First spiral begins at given start point.\r\n * * first tangent aims at shoulder.\r\n * * outbound spiral joins line from shoulder to target.\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param startPoint inbound start point.\r\n * @param shoulder point target point for (both) spiral-to-line tangencies.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralSpiralLine(\r\n spiralType: IntegratedSpiralTypeName,\r\n startPoint: Point3d,\r\n shoulderPoint: Point3d,\r\n targetPoint: Point3d,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(startPoint, shoulderPoint);\r\n const vectorBC0 = Vector3d.createStartEnd(shoulderPoint, targetPoint);\r\n const referenceLength = vectorAB.magnitude();\r\n const radiansAB = Math.atan2(vectorAB.y, vectorAB.x);\r\n const lineTurnRadians = vectorAB.angleToXY(vectorBC0);\r\n const spiralTurnRadians = 0.5 * lineTurnRadians.radians;\r\n const radiansBC = radiansAB + lineTurnRadians.radians;\r\n const axesA = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansAB));\r\n const frameA = Transform.createRefs(startPoint.clone(), axesA);\r\n // We know how much it has to turn, and but not the length or end radius.\r\n // make a spiral of referenceLength and scale it back to the junction line\r\n const spiralARefLength = IntegratedSpiral3d.createFrom4OutOf5(spiralType, 0.0, undefined,\r\n Angle.createRadians(0), Angle.createRadians(spiralTurnRadians), referenceLength, undefined, frameA);\r\n if (spiralARefLength) {\r\n const midPlanePerpendicularRadians = radiansAB + spiralTurnRadians;\r\n const midPlanePerpendicularVector = Vector3d.createPolar(1.0, Angle.createRadians(midPlanePerpendicularRadians));\r\n const altitudeB = midPlanePerpendicularVector.dotProductStartEnd(startPoint, shoulderPoint);\r\n const altitudeSpiralEnd = midPlanePerpendicularVector.dotProductStartEnd(startPoint, spiralARefLength.endPoint());\r\n const scaleFactor = altitudeB / altitudeSpiralEnd;\r\n const spiralA = IntegratedSpiral3d.createFrom4OutOf5(spiralType, 0.0, undefined,\r\n Angle.createRadians(0), Angle.createRadians(spiralTurnRadians), referenceLength * scaleFactor, undefined, frameA)!;\r\n const distanceAB = vectorAB.magnitude();\r\n const vectorBC = Vector3d.createStartEnd(shoulderPoint, targetPoint);\r\n vectorBC.scaleToLength(distanceAB, vectorBC);\r\n const pointC = shoulderPoint.plus(vectorBC);\r\n const axesC = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansBC + Math.PI));\r\n const frameC = Transform.createRefs(pointC, axesC);\r\n const spiralC = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, -spiralA.radius01.x1, Angle.zero(), undefined, spiralA.curveLength(), Segment1d.create(1, 0), frameC)!;\r\n return [spiralA, spiralC];\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Compute 2 spirals (all in XY) for a symmetric line-to-line transition.\r\n * * Spiral length is given.\r\n * * tangency points float on both lines.\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param pointA inbound start point.\r\n * @param shoulder point target point for (both) spiral-to-line tangencies.\r\n * @param spiralLength for each part of the spiral pair.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralSpiralLineWithSpiralLength(\r\n spiralType: IntegratedSpiralTypeName,\r\n pointA: Point3d,\r\n pointB: Point3d,\r\n pointC: Point3d,\r\n spiralLength: number,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(pointA, pointB);\r\n const vectorBC = Vector3d.createStartEnd(pointB, pointC);\r\n const radiansAB = Math.atan2(vectorAB.y, vectorAB.x);\r\n const lineTurnAngle = vectorAB.angleToXY(vectorBC);\r\n const spiralTurnRadians = 0.5 * lineTurnAngle.radians;\r\n const bisectorRadians = 0.5 * (Math.PI - lineTurnAngle.radians);\r\n const radiansCB = Math.atan2(-vectorBC.y, -vectorBC.x);\r\n const spiralAB0 = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(spiralTurnRadians),\r\n spiralLength, undefined, Transform.createIdentity(),\r\n );\r\n if (spiralAB0) {\r\n const localEndPoint = spiralAB0.fractionToPoint(1);\r\n const distanceAB = pointA.distance(pointB);\r\n const distanceCB = pointC.distance(pointB);\r\n // The spiral eventually has to end on the bisector, at localEndPoint.y height from the inbound line\r\n // distance from shoulder to projection of that point to point E on the inbound line is\r\n const distanceBE = localEndPoint.y / Math.tan(bisectorRadians);\r\n const xFractionAB = Geometry.conditionalDivideFraction(distanceAB - distanceBE - localEndPoint.x, distanceAB);\r\n const xFractionCB = Geometry.conditionalDivideFraction(distanceCB - distanceBE - localEndPoint.x, distanceCB);\r\n if (xFractionAB !== undefined && xFractionCB !== undefined) {\r\n const axesA = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansAB));\r\n const frameAOrigin = pointA.interpolate(xFractionAB, pointB);\r\n const frameA = Transform.createRefs(frameAOrigin, axesA);\r\n const spiralAB = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(spiralTurnRadians),\r\n spiralLength, undefined, frameA,\r\n )!;\r\n const axesB = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansCB));\r\n const frameBOrigin = pointC.interpolate(xFractionCB, pointB);\r\n const frameB = Transform.createRefs(frameBOrigin, axesB);\r\n const spiralBC = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(-spiralTurnRadians),\r\n spiralLength, undefined, frameB,\r\n )!;\r\n return [spiralAB, spiralBC];\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Compute 2 spirals and an arc (all in XY) for a symmetric line-to-line transition.\r\n * Spiral lengths and arc radius are given (e.g., from design speed standards).\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param pointA inbound start point.\r\n * @param pointB shoulder (target) point for (both) spiral-to-line tangencies.\r\n * @param lengthA inbound spiral length.\r\n * @param lengthB outbound spiral length.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralArcSpiralLine(\r\n spiralType: IntegratedSpiralTypeName,\r\n pointA: Point3d,\r\n pointB: Point3d,\r\n pointC: Point3d,\r\n lengthA: number,\r\n lengthB: number,\r\n arcRadius: number,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(pointA, pointB); vectorAB.z = 0;\r\n const vectorCB = Vector3d.createStartEnd(pointC, pointB); vectorCB.z = 0;\r\n const unitAB = vectorAB.normalize();\r\n const unitCB = vectorCB.normalize();\r\n if (unitAB === undefined || unitCB === undefined)\r\n return undefined;\r\n const unitPerpAB = unitAB.unitPerpendicularXY();\r\n const unitPerpCB = unitCB.unitPerpendicularXY();\r\n const thetaABC = vectorAB.angleToXY(vectorCB);\r\n const sideA = Geometry.split3WaySign(thetaABC.radians, 1, -1, -1);\r\n const sideB = - sideA;\r\n const radiusA = sideA * Math.abs(arcRadius);\r\n const radiusB = sideB * Math.abs(arcRadius);\r\n const spiralA = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, radiusA, Angle.zero(), undefined, lengthA, undefined, Transform.createIdentity())!;\r\n const spiralB = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, radiusB, Angle.zero(), undefined, lengthB, undefined, Transform.createIdentity())!;\r\n const spiralEndA = spiralA.fractionToPointAndUnitTangent(1.0);\r\n const spiralEndB = spiralB.fractionToPointAndUnitTangent(1.0);\r\n // From the end of spiral, step away to arc center (and this is in local coordinates of each spiral)\r\n const sA = spiralEndA.origin.x - radiusA * spiralEndA.direction.y;\r\n const tA = spiralEndA.origin.y + radiusA * spiralEndA.direction.x;\r\n const sB = spiralEndB.origin.x - radiusB * spiralEndB.direction.y;\r\n const tB = spiralEndB.origin.y + radiusB * spiralEndB.direction.x;\r\n // Those local coordinates are rotated to unitAB and unitBC ...\r\n const vectorA = Vector3d.createAdd2Scaled(unitAB, sA, unitPerpAB, tA);\r\n const vectorB = Vector3d.createAdd2Scaled(unitCB, sB, unitPerpCB, tB);\r\n const uv = Vector2d.create();\r\n if (SmallSystem.linearSystem2d(\r\n unitAB.x, -unitCB.x,\r\n unitAB.y, -unitCB.y,\r\n vectorB.x - vectorA.x, vectorB.y - vectorA.y, uv)) {\r\n const tangencyAB = pointB.plusScaled(unitAB, uv.x);\r\n const tangencyCB = pointB.plusScaled(unitCB, uv.y);\r\n const frameA = Transform.createOriginAndMatrixColumns(tangencyAB, unitAB, unitPerpAB, Vector3d.unitZ());\r\n const frameB = Transform.createOriginAndMatrixColumns(tangencyCB, unitCB, unitPerpCB, Vector3d.unitZ());\r\n spiralA.tryTransformInPlace(frameA);\r\n spiralB.tryTransformInPlace(frameB);\r\n const rayA1 = spiralA.fractionToPointAndUnitTangent(1.0);\r\n const rayB0 = spiralB.fractionToPointAndUnitTangent(1.0);\r\n rayB0.direction.scaleInPlace(-1.0);\r\n const sweep = rayA1.direction.angleToXY(rayB0.direction);\r\n if (radiusA < 0)\r\n sweep.setRadians(- sweep.radians);\r\n const arc = CurveFactory.createArcPointTangentRadius(rayA1.origin, rayA1.direction, radiusA, undefined, sweep)!;\r\n return [spiralA, arc, spiralB];\r\n }\r\n return undefined;\r\n }\r\n /** Return the intersection point of 3 planes. */\r\n public static planePlaneIntersectionRay(\r\n planeA: PlaneAltitudeEvaluator, planeB: PlaneAltitudeEvaluator): Ray3d | undefined {\r\n const altitudeA = planeA.altitudeXYZ(0, 0, 0);\r\n const altitudeB = planeB.altitudeXYZ(0, 0, 0);\r\n const normalAx = planeA.normalX();\r\n const normalAy = planeA.normalY();\r\n const normalAz = planeA.normalZ();\r\n const normalBx = planeB.normalX();\r\n const normalBy = planeB.normalY();\r\n const normalBz = planeB.normalZ();\r\n const normalCx = Geometry.crossProductXYXY(normalAy, normalAz, normalBy, normalBz);\r\n const normalCy = Geometry.crossProductXYXY(normalAz, normalAx, normalBz, normalBx);\r\n const normalCz = Geometry.crossProductXYXY(normalAx, normalAy, normalBx, normalBy);\r\n const rayOrigin = SmallSystem.linearSystem3d(\r\n normalAx, normalAy, normalAz,\r\n normalBx, normalBy, normalBz,\r\n normalCx, normalCy, normalCz,\r\n -altitudeA, -altitudeB, 0.0);\r\n if (rayOrigin !== undefined) {\r\n return Ray3d.createXYZUVW(rayOrigin.x, rayOrigin.y, rayOrigin.z, normalCx, normalCy, normalCz);\r\n }\r\n return undefined;\r\n }\r\n}\r\n/** Starting at vectorR, move parallel to vectorV until perpendicular to planeNormal. */\r\nfunction moveVectorToPlane(vectorR: Vector3d, vectorV: Vector3d, planeNormal: Vector3d, result?: Vector3d): Vector3d {\r\n // find s such that (vectorR + s * vectorV) DOT planeNormal = 0.\r\n const dotRN = vectorR.dotProduct(planeNormal);\r\n const dotVN = vectorV.dotProduct(planeNormal);\r\n const s = Geometry.safeDivideFraction(dotRN, dotVN, 0.0);\r\n return vectorR.plusScaled(vectorV, -s, result);\r\n}\r\n"]}
1
+ {"version":3,"file":"CurveFactory.js","sourceRoot":"","sources":["../../../src/curve/CurveFactory.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAqF;AACrF,+CAA4C;AAC5C,yDAAsD;AAGtD,qDAAkD;AAElD,mEAAyD;AACzD,2EAAwE;AACxE,mEAAkE;AAClE,2DAAwD;AACxD,+CAA4C;AAC5C,uDAAoD;AACpD,uDAAoD;AAEpD,yDAAsD;AAEtD,iEAA8D;AAC9D,wCAAqC;AACrC,oDAAiD;AACjD,kDAA+C;AAC/C,mCAA8C;AAC9C,uDAA+C;AAC/C,qDAAkD;AAElD,mDAAgD;AAChD,mDAAgD;AAChD,iDAA8C;AAC9C,iCAA8B;AAC9B,iCAA8B;AAC9B,2CAAwC;AACxC,oEAAiE;AAyBjE;;;GAGG;AACH,IAAY,wBAOX;AAPD,WAAY,wBAAwB;IAClC,8DAA8D;IAC9D,+EAAY,CAAA;IACZ,wEAAwE;IACxE,2FAAkB,CAAA;IAClB,6FAA6F;IAC7F,+EAAY,CAAA;AACd,CAAC,EAPW,wBAAwB,wCAAxB,wBAAwB,QAOnC;AAgCA,CAAC;AAEF;;;GAGG;AACH,MAAa,YAAY;IACvB,mFAAmF;IAC3E,MAAM,CAAC,iBAAiB,CAC9B,IAAU,EAAE,WAAoB,EAChC,MAA2B,EAAE,MAA2B,EACxD,SAAiB,EAAE,SAAiB;QAEpC,IAAI,WAAW,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,EAAE,CAAC;YAC3C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,mBAAQ,CAAC,mBAA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EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACjG,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAhrBD,oCAgrBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { AxisIndex, AxisOrder, Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { AngleSweep } from \"../geometry3d/AngleSweep\";\r\nimport { Ellipsoid, GeodesicPathPoint } from \"../geometry3d/Ellipsoid\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Matrix3d } from \"../geometry3d/Matrix3d\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Vector2d } from \"../geometry3d/Point2dVector2d\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineOps } from \"../geometry3d/PolylineOps\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Segment1d } from \"../geometry3d/Segment1d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { SmallSystem } from \"../numerics/SmallSystem\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { Cone } from \"../solid/Cone\";\r\nimport { RuledSweep } from \"../solid/RuledSweep\";\r\nimport { TorusPipe } from \"../solid/TorusPipe\";\r\nimport { Arc3d, ArcBlendData } from \"./Arc3d\";\r\nimport { CurveChain } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveTypes\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop } from \"./Loop\";\r\nimport { Path } from \"./Path\";\r\nimport { RegionOps } from \"./RegionOps\";\r\nimport { IntegratedSpiral3d } from \"./spiral/IntegratedSpiral3d\";\r\nimport { IntegratedSpiralTypeName } from \"./spiral/TransitionSpiral3d\";\r\nimport { StrokeOptions } from \"./StrokeOptions\";\r\n\r\n// cspell:word CCWXY\r\n\r\n/**\r\n * Interface to carry parallel arrays of planes and sections, and optional geometry assembled from them,\r\n * as returned by [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport interface SectionSequenceWithPlanes {\r\n /** The plane of each section. */\r\n planes: Plane3dByOriginAndUnitNormal[];\r\n /** Section curve projected onto the corresponding plane. */\r\n sections: AnyCurve[];\r\n /**\r\n * Optional `RuledSweep` generated from the sections.\r\n * * The `RuledSweep` and sections array refer to the same section objects.\r\n */\r\n ruledSweep?: RuledSweep;\r\n /** Optional mesh generated from the `RuledSweep` generated from the sections. */\r\n mesh?: IndexedPolyface;\r\n}\r\n\r\n/**\r\n * Enumeration of geometric output for [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport enum MiteredSweepOutputSelect {\r\n /** Output only the parallel arrays of planes and sections. */\r\n Sections = 0,\r\n /** Output planes and sections, as well as the assembled ruled sweep. */\r\n AlsoRuledSweep = 1,\r\n /** Output planes and sections, as well as the assembled ruled sweep and its stroked mesh. */\r\n AlsoMesh = 2,\r\n}\r\n\r\n/**\r\n * Interface bundling options for [CurveFactory.createMiteredSweepSections].\r\n * @public\r\n */\r\nexport interface MiteredSweepOptions {\r\n /** Whether first and last planes are averaged and equated when the centerline is physically closed. Default value is `false`. */\r\n wrapIfPhysicallyClosed?: boolean;\r\n /** Whether to output sections only, or sections plus optional geometry constructed from them. Default value is `MiteredSweepOutputSelect.Sections`. */\r\n outputSelect?: MiteredSweepOutputSelect;\r\n /** How to stroke smooth input curves. If undefined, default stroke options are used. */\r\n strokeOptions?: StrokeOptions;\r\n /** Whether to cap the ruled sweep if outputting a ruled sweep or mesh. Default value is `false`. */\r\n capped?: boolean;\r\n /** The first section's normal is aligned to this vector, typically the start tangent of the smooth curve stroked for the centerline. */\r\n startTangent?: Vector3d;\r\n /** The last section's normal is aligned to this vector, typically the end tangent of the smooth curve stroked for the centerline. */\r\n endTangent?: Vector3d;\r\n}\r\n\r\n/**\r\n * Curve strokes plus start/end tangents.\r\n * @internal\r\n*/\r\ninterface SmoothCurveData {\r\n /** Samples along a curve. */\r\n strokes: IndexedXYZCollection;\r\n /** Start tangent (unnormalized). May be undefined if the curve is linear. */\r\n startTangent?: Vector3d;\r\n /** End tangent (unnormalized). May be undefined if the curve is linear. */\r\n endTangent?: Vector3d;\r\n};\r\n\r\n/**\r\n * The `CurveFactory` class contains methods for specialized curve constructions.\r\n * @public\r\n */\r\nexport class CurveFactory {\r\n /** (Cautiously) construct and save a line segment between fractional positions. */\r\n private static addPartialSegment(\r\n path: Path, allowBackup: boolean,\r\n pointA: Point3d | undefined, pointB: Point3d | undefined,\r\n fraction0: number, fraction1: number,\r\n ) {\r\n if (allowBackup || (fraction1 > fraction0)) {\r\n if (pointA !== undefined && pointB !== undefined && !Geometry.isAlmostEqualNumber(fraction0, fraction1))\r\n path.tryAddChild(LineSegment3d.create(pointA.interpolate(fraction0, pointB), pointA.interpolate(fraction1, pointB)));\r\n }\r\n }\r\n /**\r\n * Create a circular arc defined by start point, tangent at start point, and end point.\r\n * * The circular arc is swept from start to end toward direction of the `tangentAtStart`.\r\n * * If tangent is parallel to line segment from start to end, return `undefined`.\r\n */\r\n public static createArcPointTangentPoint(start: Point3d, tangentAtStart: Vector3d, end: Point3d): Arc3d | undefined {\r\n const ret = Arc3d.createCircularStartTangentEnd(start, tangentAtStart, end);\r\n if (ret instanceof Arc3d)\r\n return ret;\r\n else\r\n return undefined;\r\n }\r\n /**\r\n * Construct a sequence of alternating lines and arcs with the arcs creating tangent transition between consecutive edges.\r\n * * If the radius parameter is a number, that radius is used throughout.\r\n * * If the radius parameter is an array of numbers, `radius[i]` is applied at `point[i]`.\r\n * * Note that since no fillet is constructed at the initial or final point, those entries in `radius[]` are never referenced.\r\n * * A zero radius for any point indicates to leave the as a simple corner.\r\n * @param points point source\r\n * @param radius fillet radius or array of radii indexed to correspond to the points.\r\n * @param allowBackupAlongEdge true to allow edges to be created going \"backwards\" along edges if needed to create the blend.\r\n */\r\n public static createFilletsInLineString(\r\n points: LineString3d | IndexedXYZCollection | Point3d[],\r\n radius: number | number[],\r\n allowBackupAlongEdge: boolean = true,\r\n ): Path | undefined {\r\n if (Array.isArray(points))\r\n return this.createFilletsInLineString(new Point3dArrayCarrier(points), radius, allowBackupAlongEdge);\r\n if (points instanceof LineString3d)\r\n return this.createFilletsInLineString(points.packedPoints, radius, allowBackupAlongEdge);\r\n const n = points.length;\r\n if (n <= 1)\r\n return undefined;\r\n const pointA = points.getPoint3dAtCheckedPointIndex(0)!;\r\n const pointB = points.getPoint3dAtCheckedPointIndex(1)!;\r\n // remark: n=2 and n=3 cases should fall out from loop logic\r\n const blendArray: ArcBlendData[] = [];\r\n // build one-sided blends at each end . .\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointA.clone() });\r\n for (let i = 1; i + 1 < n; i++) {\r\n const pointC = points.getPoint3dAtCheckedPointIndex(i + 1)!;\r\n let thisRadius = 0;\r\n if (Array.isArray(radius)) {\r\n if (i < radius.length)\r\n thisRadius = radius[i];\r\n } else if (Number.isFinite(radius))\r\n thisRadius = radius;\r\n if (thisRadius !== 0.0)\r\n blendArray.push(Arc3d.createFilletArc(pointA, pointB, pointC, thisRadius));\r\n else\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointB.clone() });\r\n pointA.setFromPoint3d(pointB);\r\n pointB.setFromPoint3d(pointC);\r\n }\r\n blendArray.push({ fraction10: 0.0, fraction12: 0.0, point: pointB.clone() });\r\n if (!allowBackupAlongEdge) {\r\n // suppress arcs that have overlap with both neighbors or flood either neighbor ..\r\n for (let i = 1; i + 1 < n; i++) {\r\n const b = blendArray[i];\r\n if (b.fraction10 > 1.0\r\n || b.fraction12 > 1.0\r\n || 1.0 - b.fraction10 < blendArray[i - 1].fraction12\r\n || b.fraction12 > 1.0 - blendArray[i + 1].fraction10) {\r\n b.fraction10 = 0.0;\r\n b.fraction12 = 0.0;\r\n blendArray[i].arc = undefined;\r\n }\r\n }\r\n /* The \"1-b\" logic above prevents this loop from ever doing anything.\r\n // on edge with conflict, suppress the arc with larger fraction\r\n for (let i = 1; i < n; i++) {\r\n const b0 = blendArray[i - 1];\r\n const b1 = blendArray[i];\r\n if (b0.fraction12 > 1 - b1.fraction10) {\r\n const b = b0.fraction12 > b1.fraction12 ? b1 : b0;\r\n b.fraction10 = 0.0;\r\n b.fraction12 = 0.0;\r\n blendArray[i].arc = undefined;\r\n }\r\n } */\r\n }\r\n const path = Path.create();\r\n this.addPartialSegment(\r\n path, allowBackupAlongEdge,\r\n blendArray[0].point, blendArray[1].point,\r\n blendArray[0].fraction12, 1.0 - blendArray[1].fraction10,\r\n );\r\n // add each path and successor edge ...\r\n for (let i = 1; i + 1 < points.length; i++) {\r\n const b0 = blendArray[i];\r\n const b1 = blendArray[i + 1];\r\n path.tryAddChild(b0.arc);\r\n this.addPartialSegment(path, allowBackupAlongEdge, b0.point, b1.point, b0.fraction12, 1.0 - b1.fraction10);\r\n }\r\n return path;\r\n }\r\n /**\r\n * Create a `Loop` with given xy corners and fixed z.\r\n * * The corners always proceed counter clockwise from lower left.\r\n * * If the radius is too large for the outer rectangle size, it is reduced to half of the the smaller x or y size.\r\n */\r\n public static createRectangleXY(\r\n x0: number, y0: number, x1: number, y1: number, z: number = 0, filletRadius?: number,\r\n ): Loop {\r\n let radius = Geometry.correctSmallMetricDistance(filletRadius);\r\n const xMin = Math.min(x0, x1);\r\n const xMax = Math.max(x0, x1);\r\n const yMin = Math.min(y0, y1);\r\n const yMax = Math.max(y0, y1);\r\n radius = Math.min(Math.abs(radius), 0.5 * (xMax - xMin), 0.5 * (yMax - yMin));\r\n if (radius === 0.0)\r\n return Loop.createPolygon([\r\n Point3d.create(xMin, yMin, z),\r\n Point3d.create(xMax, yMin, z),\r\n Point3d.create(xMax, yMax, z),\r\n Point3d.create(xMin, yMax, z),\r\n Point3d.create(xMin, yMin, z),\r\n ]);\r\n else {\r\n const vectorU = Vector3d.create(radius, 0, 0);\r\n const vectorV = Vector3d.create(0, radius, 0);\r\n const x0A = xMin + radius;\r\n const y0A = yMin + radius;\r\n const x1A = xMax - radius;\r\n const y1A = yMax - radius;\r\n const centers = [\r\n Point3d.create(x1A, y1A, z),\r\n Point3d.create(x0A, y1A, z),\r\n Point3d.create(x0A, y0A, z),\r\n Point3d.create(x1A, y0A, z),\r\n ];\r\n const loop = Loop.create();\r\n for (let i = 0; i < 4; i++) {\r\n const center = centers[i];\r\n const nextCenter = centers[(i + 1) % 4];\r\n const edgeVector = Vector3d.createStartEnd(center, nextCenter);\r\n const arc = Arc3d.create(center, vectorU, vectorV, AngleSweep.createStartEndDegrees(0, 90));\r\n loop.tryAddChild(arc);\r\n const arcEnd = arc.endPoint();\r\n if (!edgeVector.isAlmostZero)\r\n loop.tryAddChild(LineSegment3d.create(arcEnd, arcEnd.plus(edgeVector)));\r\n vectorU.rotate90CCWXY(vectorU);\r\n vectorV.rotate90CCWXY(vectorV);\r\n }\r\n return loop;\r\n }\r\n }\r\n /**\r\n * If `arcB` is a continuation of `arcA`, extend `arcA` (in place) to include the range of `arcB`\r\n * * This only succeeds if the two arcs are part of identical complete arcs and end of `arcA` matches the beginning of `arcB`.\r\n * @param arcA first arc, modified in place.\r\n * @param arcB second arc, unmodified.\r\n * @param allowReversed whether to consolidate even when second arc is reversed.\r\n * @returns whether `arcA` was modified.\r\n */\r\n public static appendToArcInPlace(arcA: Arc3d, arcB: Arc3d, allowReverse: boolean = false): boolean {\r\n if (arcA.center.isAlmostEqual(arcB.center)) {\r\n const sweepSign = Geometry.split3WaySign(arcA.sweep.sweepRadians * arcB.sweep.sweepRadians, -1, 0, 1);\r\n // evaluate derivatives wrt radians (not fraction!), but adjust direction for sweep signs\r\n const endA = arcA.angleToPointAndDerivative(arcA.sweep.fractionToAngle(1.0));\r\n if (arcA.sweep.sweepRadians < 0)\r\n endA.direction.scaleInPlace(-1.0);\r\n const startB = arcB.angleToPointAndDerivative(arcB.sweep.fractionToAngle(0.0));\r\n if (arcB.sweep.sweepRadians < 0)\r\n startB.direction.scaleInPlace(-1.0);\r\n if (endA.isAlmostEqual(startB)) {\r\n arcA.sweep.setStartEndRadians(\r\n arcA.sweep.startRadians, arcA.sweep.startRadians + arcA.sweep.sweepRadians + sweepSign * arcB.sweep.sweepRadians,\r\n );\r\n return true;\r\n }\r\n // Also ok if negated tangent\r\n if (allowReverse) {\r\n startB.direction.scaleInPlace(-1.0);\r\n if (endA.isAlmostEqual(startB)) {\r\n arcA.sweep.setStartEndRadians(\r\n arcA.sweep.startRadians, arcA.sweep.startRadians + arcA.sweep.sweepRadians - sweepSign * arcB.sweep.sweepRadians,\r\n );\r\n return true;\r\n }\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return a `Path` containing arcs are on the surface of an ellipsoid and pass through a sequence of points.\r\n * * Each arc passes through the two given endpoints and in the plane containing the true surface normal at\r\n * given `fractionForIntermediateNormal`\r\n * @param ellipsoid\r\n * @param pathPoints\r\n * @param fractionForIntermediateNormal fractional position for surface normal used to create the section plane.\r\n */\r\n public static assembleArcChainOnEllipsoid(\r\n ellipsoid: Ellipsoid, pathPoints: GeodesicPathPoint[], fractionForIntermediateNormal: number = 0.5,\r\n ): Path {\r\n const arcPath = Path.create();\r\n for (let i = 0; i + 1 < pathPoints.length; i++) {\r\n const arc = ellipsoid.sectionArcWithIntermediateNormal(\r\n pathPoints[i].toAngles(),\r\n fractionForIntermediateNormal,\r\n pathPoints[i + 1].toAngles());\r\n arcPath.tryAddChild(arc);\r\n }\r\n return arcPath;\r\n }\r\n private static appendGeometryQueryArray(candidate: GeometryQuery | GeometryQuery[] | undefined, result: GeometryQuery[]) {\r\n if (candidate instanceof GeometryQuery)\r\n result.push(candidate);\r\n else if (Array.isArray(candidate)) {\r\n for (const p of candidate)\r\n this.appendGeometryQueryArray(p, result);\r\n }\r\n }\r\n /**\r\n * Create solid primitives for pipe segments (e.g. Cone or TorusPipe) around line and arc primitives.\r\n * @param centerline centerline geometry.\r\n * @param pipeRadius radius of pipe.\r\n */\r\n public static createPipeSegments(\r\n centerline: CurvePrimitive | CurveChain, pipeRadius: number,\r\n ): GeometryQuery | GeometryQuery[] | undefined {\r\n if (centerline instanceof LineSegment3d) {\r\n return Cone.createAxisPoints(centerline.startPoint(), centerline.endPoint(), pipeRadius, pipeRadius, false);\r\n } else if (centerline instanceof Arc3d) {\r\n return TorusPipe.createAlongArc(centerline, pipeRadius, false);\r\n } else if (centerline instanceof CurvePrimitive) {\r\n const builder = PolyfaceBuilder.create();\r\n builder.addMiteredPipes(centerline, pipeRadius);\r\n return builder.claimPolyface();\r\n } else if (centerline instanceof CurveChain) {\r\n const result: GeometryQuery[] = [];\r\n for (const p of centerline.children) {\r\n const pipe = this.createPipeSegments(p, pipeRadius);\r\n this.appendGeometryQueryArray(pipe, result);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Get start point and tangent for variant curve data. */\r\n private static startPointAndTangent(curve: IndexedXYZCollection | Point3d[] | CurvePrimitive): Ray3d | undefined {\r\n if (curve instanceof CurvePrimitive)\r\n return curve.fractionToPointAndDerivative(0.0);\r\n if (curve.length < 2)\r\n return undefined;\r\n if (Array.isArray(curve))\r\n curve = new Point3dArrayCarrier(curve);\r\n const ray = Ray3d.createZero();\r\n curve.getPoint3dAtUncheckedPointIndex(0, ray.origin);\r\n curve.vectorIndexIndex(0, 1, ray.direction);\r\n return ray;\r\n };\r\n /** Create an [[Arc3d]] from `sectionData` that has its center at the start point of the centerline. */\r\n public static createArcFromSectionData(\r\n centerline: IndexedXYZCollection | Point3d[] | CurvePrimitive, sectionData: number | XAndY | Arc3d,\r\n ): Arc3d | undefined {\r\n const ray = CurveFactory.startPointAndTangent(centerline);\r\n if (!ray)\r\n return undefined;\r\n let arc: Arc3d;\r\n if (sectionData instanceof Arc3d) {\r\n arc = sectionData.clone();\r\n arc.center = ray.origin;\r\n } else {\r\n const vector0 = Vector3d.create();\r\n const vector90 = Vector3d.create();\r\n const length0 = (typeof sectionData === \"number\") ? sectionData : sectionData.x;\r\n const length90 = (typeof sectionData === \"number\") ? sectionData : sectionData.y;\r\n const baseFrame = Matrix3d.createRigidHeadsUp(ray.direction, AxisOrder.ZXY);\r\n baseFrame.columnX(vector0).scaleInPlace(length0);\r\n baseFrame.columnY(vector90).scaleInPlace(length90);\r\n arc = Arc3d.create(ray.origin, vector0, vector90);\r\n }\r\n if (arc.binormalVector().dotProduct(ray.direction) < 0.0)\r\n arc.reverseInPlace();\r\n return arc;\r\n }\r\n /**\r\n * Create section arcs for mitered pipe.\r\n * * At the end of each pipe segment, the pipe is mitered by the plane that bisects the angle between successive\r\n * centerline segments.\r\n * * The section arcs are constructed so that lines between corresponding fractional positions on the arcs are\r\n * axial lines on the pipes.\r\n * * This means that the initial arc's vector0 and vector90 lengths and angular separation are _not_ preserved in\r\n * the section arcs.\r\n * * Circular or elliptical pipe cross sections can be specified by supplying either a radius, a pair of semi-axis\r\n * lengths, or an Arc3d:\r\n * * For semi-axis length input, x and y correspond to ellipse local axes perpendicular to each other and to the\r\n * start tangent.\r\n * * For Arc3d input, the center is translated to the centerline start point. For best results, ensure this arc\r\n * is perpendicular to the centerline start tangent.\r\n * * This function internally calls [[createMiteredSweepSections]] with default options.\r\n * @param centerline centerline of pipe. For best results, ensure no successive duplicate points with e.g.,\r\n * [[GrowableXYZArray.createCompressed]].\r\n * @param sectionData circle radius, ellipse semi-axis lengths, or full Arc3d (if not full, function makes it full).\r\n * @returns array of sections or empty array if section creation failed.\r\n */\r\n public static createMiteredPipeSections(centerline: IndexedXYZCollection, sectionData: number | XAndY | Arc3d): Arc3d[] {\r\n const arc = CurveFactory.createArcFromSectionData(centerline, sectionData);\r\n if (!arc)\r\n return [];\r\n const miteredSweeps = CurveFactory.createMiteredSweepSections(centerline, arc);\r\n if (miteredSweeps)\r\n return miteredSweeps.sections as Arc3d[];\r\n return [];\r\n }\r\n\r\n /** For a smooth curve, stroke and return unnormalized start/end tangents. */\r\n private static strokeSmoothCurve(\r\n curve: IndexedXYZCollection | Point3d[] | CurvePrimitive | CurveChain,\r\n options?: StrokeOptions,\r\n ): SmoothCurveData | undefined {\r\n let startTangent, endTangent: Vector3d | undefined;\r\n if (curve instanceof CurvePrimitive) {\r\n startTangent = curve.fractionToPointAndDerivative(0.0).direction;\r\n endTangent = curve.fractionToPointAndDerivative(1.0).direction;\r\n const strokes = LineString3d.create();\r\n curve.emitStrokes(strokes, options);\r\n curve = strokes.packedPoints;\r\n } else if (curve instanceof CurveChain) {\r\n startTangent = curve.startPointAndDerivative()?.direction;\r\n endTangent = curve.endPointAndDerivative()?.direction;\r\n const strokes = curve.getPackedStrokes(options);\r\n if (!strokes)\r\n return undefined;\r\n curve = strokes;\r\n } else if (Array.isArray(curve))\r\n curve = new Point3dArrayCarrier(curve);\r\n return { strokes: curve, startTangent, endTangent };\r\n }\r\n\r\n /**\r\n * Align two bisector plane normals to given smooth rail tangents or optional overrides.\r\n * * Optionally average the normals for physically closed rail.\r\n */\r\n private static alignFirstAndLastBisectorPlanes(\r\n firstPlane: Plane3dByOriginAndUnitNormal,\r\n lastPlane: Plane3dByOriginAndUnitNormal,\r\n smoothRailData?: SmoothCurveData,\r\n options?: MiteredSweepOptions,\r\n ) {\r\n const normal0 = options?.startTangent ?? (smoothRailData?.startTangent ?? firstPlane.getNormalRef());\r\n const normal1 = options?.endTangent ?? (smoothRailData?.endTangent ?? lastPlane.getNormalRef());\r\n if (options?.wrapIfPhysicallyClosed && firstPlane.getOriginRef().isAlmostEqual(lastPlane.getOriginRef())) {\r\n const avgNormal = normal0.plus(normal1);\r\n if (avgNormal.tryNormalizeInPlace()) { // ignore cusp at seam\r\n firstPlane.getNormalRef().setFrom(avgNormal);\r\n lastPlane.getNormalRef().setFrom(avgNormal);\r\n return;\r\n }\r\n }\r\n if (normal0.tryNormalizeInPlace())\r\n firstPlane.getNormalRef().setFrom(normal0);\r\n if (normal1.tryNormalizeInPlace())\r\n lastPlane.getNormalRef().setFrom(normal1);\r\n }\r\n\r\n /** Reverse a closed curve or region if necessary so that its orientation is CCW with respect to the plane normal. */\r\n private static alignClosedCurveToPlane(curve: AnyCurve, planeNormal: Vector3d) {\r\n let closedCurve: AnyRegion | undefined;\r\n if (curve instanceof CurvePrimitive) {\r\n if (curve.startPoint().isAlmostEqual(curve.endPoint()))\r\n closedCurve = Loop.create(curve);\r\n } else if (curve.isAnyRegion())\r\n closedCurve = curve;\r\n if (closedCurve) {\r\n // The alignment condition is equivalent to positive projected curve area computed wrt to the plane normal.\r\n const toLocal = Matrix3d.createRigidHeadsUp(planeNormal).transpose();\r\n const projection = closedCurve.cloneTransformed(Transform.createOriginAndMatrix(undefined, toLocal));\r\n if (projection) { // now we can ignore z-coords\r\n const areaXY = RegionOps.computeXYArea(projection as AnyRegion);\r\n if (areaXY && areaXY < 0)\r\n curve.reverseInPlace();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Projection to target plane, constructing sweep direction from two given planes.\r\n * * If successful, push the target plane and swept section to the output arrays and return the swept section.\r\n * * If unsuccessful, leave the output arrays alone and return the input section.\r\n */\r\n private static doSweepToPlane(\r\n output: SectionSequenceWithPlanes,\r\n edgePlane0: Plane3dByOriginAndUnitNormal,\r\n edgePlane1: Plane3dByOriginAndUnitNormal,\r\n targetPlane: Plane3dByOriginAndUnitNormal,\r\n section: AnyCurve,\r\n ): AnyCurve {\r\n const sweepVector = Vector3d.createStartEnd(edgePlane0.getOriginRef(), edgePlane1.getOriginRef());\r\n const transform = Transform.createFlattenAlongVectorToPlane(\r\n sweepVector, targetPlane.getOriginRef(), targetPlane.getNormalRef(),\r\n );\r\n if (transform === undefined)\r\n return section;\r\n const transformedSection = section.cloneTransformed(transform);\r\n if (transformedSection === undefined)\r\n return section;\r\n output.planes.push(targetPlane);\r\n output.sections.push(transformedSection);\r\n return transformedSection;\r\n }\r\n\r\n /**\r\n * Sweep the `initialSection` along each segment of the (stroked) `centerline` until it hits the bisector plane at\r\n * the next vertex.\r\n * * For best results, the caller should place `initialSection` in a plane perpendicular to the `centerline`\r\n * start tangent.\r\n * * This plane is commonly (but not necessarily) through the centerline start point itself.\r\n * * To compute the sections, `initialSection` is projected in the direction of the centerline start tangent onto\r\n * the first bisector plane at the centerline start. The result of this projection will be likewise projected onto\r\n * the second plane, and so on in sequence.\r\n * * By default, the first/last bisector plane normals are set to the centerline start/end tangents. The caller can\r\n * override these with tangents supplied in `options`. If the centerline is physically closed and\r\n * `options.wrapIfPhysicallyClosed` is true, the first and last plane normals are averaged and equated.\r\n * * The centerline path does NOT have to be planar, however non-planarity will result in twisting of the sections\r\n * in the bisector planes.\r\n * @param centerline sweep path. Will be stroked if smooth.\r\n * @param initialSection profile curve to be swept. As noted above, this should be on a plane perpendicular to the\r\n * centerline start tangent.\r\n * @param options options for computation and output.\r\n * @return array of sections, formed from projecting `initialSection` successively onto the bisector planes.\r\n */\r\n public static createMiteredSweepSections(\r\n centerline: IndexedXYZCollection | Point3d[] | CurvePrimitive | CurveChain,\r\n initialSection: AnyCurve,\r\n options?: MiteredSweepOptions,\r\n ): SectionSequenceWithPlanes | undefined {\r\n if (!options)\r\n options = {};\r\n const rail = this.strokeSmoothCurve(centerline, options.strokeOptions);\r\n if (!rail)\r\n return undefined;\r\n const planes = PolylineOps.createBisectorPlanesForDistinctPoints(rail.strokes);\r\n if (!planes || planes.length < 2)\r\n return undefined;\r\n this.alignFirstAndLastBisectorPlanes(planes[0], planes[planes.length - 1], rail, options);\r\n\r\n // RuledSweep facet construction assumes the contours are oriented CCW with respect to the sweep direction so that\r\n // facet normals point outward. We only have to align the first contour; the rest will inherit its orientation.\r\n this.alignClosedCurveToPlane(initialSection, planes[0].getNormalRef());\r\n\r\n const sectionData: SectionSequenceWithPlanes = { sections: [], planes: [] };\r\n let currentSection = this.doSweepToPlane(sectionData, planes[0], planes[1], planes[0], initialSection);\r\n for (let i = 1; i < planes.length; i++)\r\n currentSection = this.doSweepToPlane(sectionData, planes[i - 1], planes[i], planes[i], currentSection);\r\n\r\n if (options.outputSelect) {\r\n const ruledSweep = RuledSweep.create(sectionData.sections, options.capped ?? false);\r\n if (ruledSweep) {\r\n sectionData.ruledSweep = ruledSweep;\r\n if (MiteredSweepOutputSelect.AlsoMesh === options.outputSelect) {\r\n const builder = PolyfaceBuilder.create(options.strokeOptions);\r\n builder.addRuledSweep(ruledSweep);\r\n sectionData.mesh = builder.claimPolyface();\r\n }\r\n }\r\n }\r\n return sectionData;\r\n }\r\n /**\r\n * Create a circular arc from start point, tangent at start, radius, optional plane normal, arc sweep.\r\n * * The vector from start point to center is in the direction of upVector crossed with tangentA.\r\n * @param start start point.\r\n * @param tangentAtStart vector in tangent direction at the start.\r\n * @param radius signed radius.\r\n * @param upVector optional out-of-plane vector. Defaults to positive Z.\r\n * @param sweep angular range. If single `Angle` is given, start angle is at 0 degrees (the start point).\r\n */\r\n public static createArcPointTangentRadius(\r\n start: Point3d, tangentAtStart: Vector3d, radius: number, upVector?: Vector3d, sweep?: Angle | AngleSweep,\r\n ): Arc3d | undefined {\r\n return Arc3d.createCircularStartTangentRadius(start, tangentAtStart, radius, upVector, sweep);\r\n }\r\n /**\r\n * Compute 2 spirals (all in XY) for a symmetric line-to-line transition.\r\n * * First spiral begins at given start point.\r\n * * first tangent aims at shoulder.\r\n * * outbound spiral joins line from shoulder to target.\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param startPoint inbound start point.\r\n * @param shoulder point target point for (both) spiral-to-line tangencies.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralSpiralLine(\r\n spiralType: IntegratedSpiralTypeName,\r\n startPoint: Point3d,\r\n shoulderPoint: Point3d,\r\n targetPoint: Point3d,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(startPoint, shoulderPoint);\r\n const vectorBC0 = Vector3d.createStartEnd(shoulderPoint, targetPoint);\r\n const referenceLength = vectorAB.magnitude();\r\n const radiansAB = Math.atan2(vectorAB.y, vectorAB.x);\r\n const lineTurnRadians = vectorAB.angleToXY(vectorBC0);\r\n const spiralTurnRadians = 0.5 * lineTurnRadians.radians;\r\n const radiansBC = radiansAB + lineTurnRadians.radians;\r\n const axesA = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansAB));\r\n const frameA = Transform.createRefs(startPoint.clone(), axesA);\r\n // We know how much it has to turn, and but not the length or end radius.\r\n // make a spiral of referenceLength and scale it back to the junction line\r\n const spiralARefLength = IntegratedSpiral3d.createFrom4OutOf5(spiralType, 0.0, undefined,\r\n Angle.createRadians(0), Angle.createRadians(spiralTurnRadians), referenceLength, undefined, frameA);\r\n if (spiralARefLength) {\r\n const midPlanePerpendicularRadians = radiansAB + spiralTurnRadians;\r\n const midPlanePerpendicularVector = Vector3d.createPolar(1.0, Angle.createRadians(midPlanePerpendicularRadians));\r\n const altitudeB = midPlanePerpendicularVector.dotProductStartEnd(startPoint, shoulderPoint);\r\n const altitudeSpiralEnd = midPlanePerpendicularVector.dotProductStartEnd(startPoint, spiralARefLength.endPoint());\r\n const scaleFactor = altitudeB / altitudeSpiralEnd;\r\n const spiralA = IntegratedSpiral3d.createFrom4OutOf5(spiralType, 0.0, undefined,\r\n Angle.createRadians(0), Angle.createRadians(spiralTurnRadians), referenceLength * scaleFactor, undefined, frameA)!;\r\n const distanceAB = vectorAB.magnitude();\r\n const vectorBC = Vector3d.createStartEnd(shoulderPoint, targetPoint);\r\n vectorBC.scaleToLength(distanceAB, vectorBC);\r\n const pointC = shoulderPoint.plus(vectorBC);\r\n const axesC = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansBC + Math.PI));\r\n const frameC = Transform.createRefs(pointC, axesC);\r\n const spiralC = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, -spiralA.radius01.x1, Angle.zero(), undefined, spiralA.curveLength(), Segment1d.create(1, 0), frameC)!;\r\n return [spiralA, spiralC];\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Compute 2 spirals (all in XY) for a symmetric line-to-line transition.\r\n * * Spiral length is given.\r\n * * tangency points float on both lines.\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param pointA inbound start point.\r\n * @param shoulder point target point for (both) spiral-to-line tangencies.\r\n * @param spiralLength for each part of the spiral pair.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralSpiralLineWithSpiralLength(\r\n spiralType: IntegratedSpiralTypeName,\r\n pointA: Point3d,\r\n pointB: Point3d,\r\n pointC: Point3d,\r\n spiralLength: number,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(pointA, pointB);\r\n const vectorBC = Vector3d.createStartEnd(pointB, pointC);\r\n const radiansAB = Math.atan2(vectorAB.y, vectorAB.x);\r\n const lineTurnAngle = vectorAB.angleToXY(vectorBC);\r\n const spiralTurnRadians = 0.5 * lineTurnAngle.radians;\r\n const bisectorRadians = 0.5 * (Math.PI - lineTurnAngle.radians);\r\n const radiansCB = Math.atan2(-vectorBC.y, -vectorBC.x);\r\n const spiralAB0 = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(spiralTurnRadians),\r\n spiralLength, undefined, Transform.createIdentity(),\r\n );\r\n if (spiralAB0) {\r\n const localEndPoint = spiralAB0.fractionToPoint(1);\r\n const distanceAB = pointA.distance(pointB);\r\n const distanceCB = pointC.distance(pointB);\r\n // The spiral eventually has to end on the bisector, at localEndPoint.y height from the inbound line\r\n // distance from shoulder to projection of that point to point E on the inbound line is\r\n const distanceBE = localEndPoint.y / Math.tan(bisectorRadians);\r\n const xFractionAB = Geometry.conditionalDivideFraction(distanceAB - distanceBE - localEndPoint.x, distanceAB);\r\n const xFractionCB = Geometry.conditionalDivideFraction(distanceCB - distanceBE - localEndPoint.x, distanceCB);\r\n if (xFractionAB !== undefined && xFractionCB !== undefined) {\r\n const axesA = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansAB));\r\n const frameAOrigin = pointA.interpolate(xFractionAB, pointB);\r\n const frameA = Transform.createRefs(frameAOrigin, axesA);\r\n const spiralAB = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(spiralTurnRadians),\r\n spiralLength, undefined, frameA,\r\n )!;\r\n const axesB = Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, Angle.createRadians(radiansCB));\r\n const frameBOrigin = pointC.interpolate(xFractionCB, pointB);\r\n const frameB = Transform.createRefs(frameBOrigin, axesB);\r\n const spiralBC = IntegratedSpiral3d.createFrom4OutOf5(\r\n spiralType, 0, undefined,\r\n Angle.zero(), Angle.createRadians(-spiralTurnRadians),\r\n spiralLength, undefined, frameB,\r\n )!;\r\n return [spiralAB, spiralBC];\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Compute 2 spirals and an arc (all in XY) for a symmetric line-to-line transition.\r\n * Spiral lengths and arc radius are given (e.g., from design speed standards).\r\n * @param spiralType name of spiral type. THIS MUST BE AN \"Integrated\" SPIRAL TYPE.\r\n * @param pointA inbound start point.\r\n * @param pointB shoulder (target) point for (both) spiral-to-line tangencies.\r\n * @param lengthA inbound spiral length.\r\n * @param lengthB outbound spiral length.\r\n * @return array with the computed spirals, or undefined if failure.\r\n */\r\n public static createLineSpiralArcSpiralLine(\r\n spiralType: IntegratedSpiralTypeName,\r\n pointA: Point3d,\r\n pointB: Point3d,\r\n pointC: Point3d,\r\n lengthA: number,\r\n lengthB: number,\r\n arcRadius: number,\r\n ): GeometryQuery[] | undefined {\r\n const vectorAB = Vector3d.createStartEnd(pointA, pointB); vectorAB.z = 0;\r\n const vectorCB = Vector3d.createStartEnd(pointC, pointB); vectorCB.z = 0;\r\n const unitAB = vectorAB.normalize();\r\n const unitCB = vectorCB.normalize();\r\n if (unitAB === undefined || unitCB === undefined)\r\n return undefined;\r\n const unitPerpAB = unitAB.unitPerpendicularXY();\r\n const unitPerpCB = unitCB.unitPerpendicularXY();\r\n const thetaABC = vectorAB.angleToXY(vectorCB);\r\n const sideA = Geometry.split3WaySign(thetaABC.radians, 1, -1, -1);\r\n const sideB = - sideA;\r\n const radiusA = sideA * Math.abs(arcRadius);\r\n const radiusB = sideB * Math.abs(arcRadius);\r\n const spiralA = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, radiusA, Angle.zero(), undefined, lengthA, undefined, Transform.createIdentity())!;\r\n const spiralB = IntegratedSpiral3d.createFrom4OutOf5(spiralType,\r\n 0, radiusB, Angle.zero(), undefined, lengthB, undefined, Transform.createIdentity())!;\r\n const spiralEndA = spiralA.fractionToPointAndUnitTangent(1.0);\r\n const spiralEndB = spiralB.fractionToPointAndUnitTangent(1.0);\r\n // From the end of spiral, step away to arc center (and this is in local coordinates of each spiral)\r\n const sA = spiralEndA.origin.x - radiusA * spiralEndA.direction.y;\r\n const tA = spiralEndA.origin.y + radiusA * spiralEndA.direction.x;\r\n const sB = spiralEndB.origin.x - radiusB * spiralEndB.direction.y;\r\n const tB = spiralEndB.origin.y + radiusB * spiralEndB.direction.x;\r\n // Those local coordinates are rotated to unitAB and unitBC ...\r\n const vectorA = Vector3d.createAdd2Scaled(unitAB, sA, unitPerpAB, tA);\r\n const vectorB = Vector3d.createAdd2Scaled(unitCB, sB, unitPerpCB, tB);\r\n const uv = Vector2d.create();\r\n if (SmallSystem.linearSystem2d(\r\n unitAB.x, -unitCB.x,\r\n unitAB.y, -unitCB.y,\r\n vectorB.x - vectorA.x, vectorB.y - vectorA.y, uv)) {\r\n const tangencyAB = pointB.plusScaled(unitAB, uv.x);\r\n const tangencyCB = pointB.plusScaled(unitCB, uv.y);\r\n const frameA = Transform.createOriginAndMatrixColumns(tangencyAB, unitAB, unitPerpAB, Vector3d.unitZ());\r\n const frameB = Transform.createOriginAndMatrixColumns(tangencyCB, unitCB, unitPerpCB, Vector3d.unitZ());\r\n spiralA.tryTransformInPlace(frameA);\r\n spiralB.tryTransformInPlace(frameB);\r\n const rayA1 = spiralA.fractionToPointAndUnitTangent(1.0);\r\n const rayB0 = spiralB.fractionToPointAndUnitTangent(1.0);\r\n rayB0.direction.scaleInPlace(-1.0);\r\n const sweep = rayA1.direction.angleToXY(rayB0.direction);\r\n if (radiusA < 0)\r\n sweep.setRadians(- sweep.radians);\r\n const arc = CurveFactory.createArcPointTangentRadius(rayA1.origin, rayA1.direction, radiusA, undefined, sweep)!;\r\n return [spiralA, arc, spiralB];\r\n }\r\n return undefined;\r\n }\r\n /** Return the intersection point of 3 planes. */\r\n public static planePlaneIntersectionRay(\r\n planeA: PlaneAltitudeEvaluator, planeB: PlaneAltitudeEvaluator): Ray3d | undefined {\r\n const altitudeA = planeA.altitudeXYZ(0, 0, 0);\r\n const altitudeB = planeB.altitudeXYZ(0, 0, 0);\r\n const normalAx = planeA.normalX();\r\n const normalAy = planeA.normalY();\r\n const normalAz = planeA.normalZ();\r\n const normalBx = planeB.normalX();\r\n const normalBy = planeB.normalY();\r\n const normalBz = planeB.normalZ();\r\n const normalCx = Geometry.crossProductXYXY(normalAy, normalAz, normalBy, normalBz);\r\n const normalCy = Geometry.crossProductXYXY(normalAz, normalAx, normalBz, normalBx);\r\n const normalCz = Geometry.crossProductXYXY(normalAx, normalAy, normalBx, normalBy);\r\n const rayOrigin = SmallSystem.linearSystem3d(\r\n normalAx, normalAy, normalAz,\r\n normalBx, normalBy, normalBz,\r\n normalCx, normalCy, normalCz,\r\n -altitudeA, -altitudeB, 0.0);\r\n if (rayOrigin !== undefined) {\r\n return Ray3d.createXYZUVW(rayOrigin.x, rayOrigin.y, rayOrigin.z, normalCx, normalCy, normalCz);\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
@@ -21,7 +21,7 @@ import { Angle } from "../geometry3d/Angle";
21
21
  * @public
22
22
  */
23
23
  export declare class StrokeOptions {
24
- /** Distance from stroke to actual geometry */
24
+ /** Distance from stroke to actual geometry. */
25
25
  chordTol?: number;
26
26
  /** Turning angle between strokes. Larger value leads to fewer strokes. */
27
27
  angleTol?: Angle;
@@ -32,9 +32,9 @@ export declare class StrokeOptions {
32
32
  * @deprecated in 4.x - never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].
33
33
  */
34
34
  needConvexFacets?: boolean;
35
- /** Minimum strokes on a primitive */
35
+ /** Minimum strokes on a primitive. */
36
36
  minStrokesPerPrimitive?: number;
37
- /** Whether or not to triangulate each added facet */
37
+ /** Whether or not to triangulate each added facet. */
38
38
  shouldTriangulate: boolean;
39
39
  private _needNormals?;
40
40
  private _needTwoSided?;
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeOptions.d.ts","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,aAAa;IACxB,8CAA8C;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC;IACzB,0EAA0E;IACnE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACxB,yCAAyC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACI,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAClC,qCAAqC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACvC,qDAAqD;IAC9C,iBAAiB,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,MAAoB,GAAG,MAAM;IAQvF,4HAA4H;IACrH,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAQpF;;;OAGG;IACI,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM;IAQtG,iGAAiG;IAC1F,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAM5D;;;;OAIG;WACW,eAAe,IAAI,aAAa;IAK9C;;;;OAIG;WACW,eAAe,IAAI,aAAa;CAK/C"}
@@ -33,7 +33,7 @@ const Angle_1 = require("../geometry3d/Angle");
33
33
  */
34
34
  class StrokeOptions {
35
35
  constructor() {
36
- /** Whether or not to triangulate each added facet */
36
+ /** Whether or not to triangulate each added facet. */
37
37
  this.shouldTriangulate = false;
38
38
  /** Default number of strokes for a circle. */
39
39
  this.defaultCircleStrokes = 16;
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IAA1B;QAcE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QA2B1C,8CAA8C;QACvC,yBAAoB,GAAG,EAAE,CAAC;IAuJnC,CAAC;IA/KC,oCAAoC;IACpC,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;IACD,IAAW,UAAU,CAAC,KAAc;QAClC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IACD,oCAAoC;IACpC,IAAW,WAAW;QACpB,OAAO,I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SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAlMD,sCAkMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/**\r\n * Tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n * * It is rare for all three to be active at once.\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * For curves, 15 degrees is typical\r\n * * For facets, 22.5 degrees is typical.\r\n * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n /** Distance from stroke to actual geometry */\r\n public chordTol?: number;\r\n /** Turning angle between strokes. Larger value leads to fewer strokes. */\r\n public angleTol?: Angle;\r\n /** Maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /**\r\n * Caller expects convex facets.\r\n * @deprecated in 4.x - never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].\r\n */\r\n public needConvexFacets?: boolean;\r\n /** Minimum strokes on a primitive */\r\n public minStrokesPerPrimitive?: number;\r\n /** Whether or not to triangulate each added facet */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean {\r\n return this._needParams !== undefined ? this._needParams : false;\r\n }\r\n public set needParams(value: boolean) {\r\n this._needParams = value;\r\n }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean {\r\n return this._needNormals !== undefined ? this._needNormals : false;\r\n }\r\n public set needNormals(value: boolean) {\r\n this._needNormals = value;\r\n }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean {\r\n return this._needTwoSided !== undefined ? this._needTwoSided : false;\r\n }\r\n public set needTwoSided(value: boolean) {\r\n this._needTwoSided = value;\r\n }\r\n /** Optional color request flag */\r\n public needColors?: boolean;\r\n /** Default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** Ask if angleTol is specified */\r\n public get hasAngleTol(): boolean {\r\n return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0;\r\n }\r\n /** Ask if chordTol is specified */\r\n public get hasChordTol(): boolean {\r\n return this.chordTol !== undefined && this.chordTol > 0.0;\r\n }\r\n /** Ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean {\r\n return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0;\r\n }\r\n private _maximizeConvexFacets?: boolean;\r\n /**\r\n * Whether to post-process a planar triangulation by removing edges to maximize the size of convex facets.\r\n * * Setting this to true also sets [[shouldTriangulate]] to true.\r\n */\r\n public get maximizeConvexFacets(): boolean {\r\n return this._maximizeConvexFacets ?? false;\r\n }\r\n public set maximizeConvexFacets(value: boolean) {\r\n this._maximizeConvexFacets = value;\r\n if (value)\r\n this.shouldTriangulate = value;\r\n }\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n options._maximizeConvexFacets = this._maximizeConvexFacets;\r\n return options;\r\n }\r\n /** Return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of the existing count or count needed for angle condition for given\r\n * sweepRadians.\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance\r\n * from the options.\r\n */\r\n public static applyAngleTol(\r\n options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number,\r\n ): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(\r\n options: StrokeOptions | undefined, minCount: number, edgeLength: number,\r\n ): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,\r\n * chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n /** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given\r\n * arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n /** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve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AY,EAAE,QAAQ,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD;;;OAGG;IACI,+BAA+B,CAAC,QAAgB,EAAE,MAAc,EAAE,YAAoB;QAC3F,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE,CAAC;YACzC,MAAM,MAAM,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,iGAAiG;IAC1F,2BAA2B,CAAC,QAAgB;QACjD,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAlMD,sCAkMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/**\r\n * Tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n * * It is rare for all three to be active at once.\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * For curves, 15 degrees is typical\r\n * * For facets, 22.5 degrees is typical.\r\n * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n /** Distance from stroke to actual geometry. */\r\n public chordTol?: number;\r\n /** Turning angle between strokes. Larger value leads to fewer strokes. */\r\n public angleTol?: Angle;\r\n /** Maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /**\r\n * Caller expects convex facets.\r\n * @deprecated in 4.x - never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].\r\n */\r\n public needConvexFacets?: boolean;\r\n /** Minimum strokes on a primitive. */\r\n public minStrokesPerPrimitive?: number;\r\n /** Whether or not to triangulate each added facet. */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean {\r\n return this._needParams !== undefined ? this._needParams : false;\r\n }\r\n public set needParams(value: boolean) {\r\n this._needParams = value;\r\n }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean {\r\n return this._needNormals !== undefined ? this._needNormals : false;\r\n }\r\n public set needNormals(value: boolean) {\r\n this._needNormals = value;\r\n }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean {\r\n return this._needTwoSided !== undefined ? this._needTwoSided : false;\r\n }\r\n public set needTwoSided(value: boolean) {\r\n this._needTwoSided = value;\r\n }\r\n /** Optional color request flag */\r\n public needColors?: boolean;\r\n /** Default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** Ask if angleTol is specified */\r\n public get hasAngleTol(): boolean {\r\n return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0;\r\n }\r\n /** Ask if chordTol is specified */\r\n public get hasChordTol(): boolean {\r\n return this.chordTol !== undefined && this.chordTol > 0.0;\r\n }\r\n /** Ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean {\r\n return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0;\r\n }\r\n private _maximizeConvexFacets?: boolean;\r\n /**\r\n * Whether to post-process a planar triangulation by removing edges to maximize the size of convex facets.\r\n * * Setting this to true also sets [[shouldTriangulate]] to true.\r\n */\r\n public get maximizeConvexFacets(): boolean {\r\n return this._maximizeConvexFacets ?? false;\r\n }\r\n public set maximizeConvexFacets(value: boolean) {\r\n this._maximizeConvexFacets = value;\r\n if (value)\r\n this.shouldTriangulate = value;\r\n }\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n options._maximizeConvexFacets = this._maximizeConvexFacets;\r\n return options;\r\n }\r\n /** Return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of the existing count or count needed for angle condition for given\r\n * sweepRadians.\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance\r\n * from the options.\r\n */\r\n public static applyAngleTol(\r\n options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number,\r\n ): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(\r\n options: StrokeOptions | undefined, minCount: number, edgeLength: number,\r\n ): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,\r\n * chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n /** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given\r\n * arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n /** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /**\r\n * Create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\n }\r\n}\r\n"]}
@@ -76,7 +76,8 @@ export declare class PolylineOps {
76
76
  * @param data points.
77
77
  */
78
78
  static removeClosurePoint(data: Point3d[] | Point3d[][]): void;
79
- /** Create an array of planes.
79
+ /**
80
+ * Create an array of planes.
80
81
  * * First plane has origin at first centerline point, with unit normal directed at the next point.
81
82
  * * Intermediate planes have origin at intermediate points, with unit normals computed from the average of unit vectors
82
83
  * along the incoming and outgoing segments.
@@ -1 +1 @@
1
- {"version":3,"file":"PolylineOps.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/PolylineOps.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAuC,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAC5G,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAKvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAE9E,OAAO,EAAE,OAAO,EAAY,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGlC;;;GAGG;AACH,qBAAa,WAAW;IACtB;;;OAGG;W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