@itwin/core-geometry 4.5.0-dev.3 → 4.5.0-dev.32

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 (107) hide show
  1. package/CHANGELOG.md +47 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/Geometry.d.ts +15 -0
  4. package/lib/cjs/Geometry.d.ts.map +1 -1
  5. package/lib/cjs/Geometry.js +27 -0
  6. package/lib/cjs/Geometry.js.map +1 -1
  7. package/lib/cjs/curve/CoordinateXYZ.d.ts +10 -13
  8. package/lib/cjs/curve/CoordinateXYZ.d.ts.map +1 -1
  9. package/lib/cjs/curve/CoordinateXYZ.js +16 -15
  10. package/lib/cjs/curve/CoordinateXYZ.js.map +1 -1
  11. package/lib/cjs/curve/GeometryQuery.d.ts +17 -17
  12. package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
  13. package/lib/cjs/curve/GeometryQuery.js +16 -15
  14. package/lib/cjs/curve/GeometryQuery.js.map +1 -1
  15. package/lib/cjs/curve/PointString3d.d.ts +17 -13
  16. package/lib/cjs/curve/PointString3d.d.ts.map +1 -1
  17. package/lib/cjs/curve/PointString3d.js +35 -20
  18. package/lib/cjs/curve/PointString3d.js.map +1 -1
  19. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +1 -1
  20. package/lib/cjs/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  21. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js +1 -1
  22. package/lib/cjs/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  23. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  24. package/lib/cjs/geometry3d/FrameBuilder.js +3 -0
  25. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  26. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +8 -2
  27. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  28. package/lib/cjs/geometry3d/GrowableXYZArray.js +11 -2
  29. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  30. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +42 -50
  31. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  32. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +81 -105
  33. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  34. package/lib/cjs/polyface/Polyface.d.ts +166 -120
  35. package/lib/cjs/polyface/Polyface.d.ts.map +1 -1
  36. package/lib/cjs/polyface/Polyface.js +251 -162
  37. package/lib/cjs/polyface/Polyface.js.map +1 -1
  38. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -10
  39. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  40. package/lib/cjs/polyface/PolyfaceBuilder.js +27 -21
  41. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  42. package/lib/cjs/polyface/PolyfaceData.d.ts +142 -86
  43. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  44. package/lib/cjs/polyface/PolyfaceData.js +305 -164
  45. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  46. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  47. package/lib/cjs/topology/Graph.d.ts +2 -8
  48. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  49. package/lib/cjs/topology/Graph.js +0 -3
  50. package/lib/cjs/topology/Graph.js.map +1 -1
  51. package/lib/cjs/topology/Triangulation.d.ts +18 -7
  52. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  53. package/lib/cjs/topology/Triangulation.js +50 -9
  54. package/lib/cjs/topology/Triangulation.js.map +1 -1
  55. package/lib/esm/Geometry.d.ts +15 -0
  56. package/lib/esm/Geometry.d.ts.map +1 -1
  57. package/lib/esm/Geometry.js +27 -0
  58. package/lib/esm/Geometry.js.map +1 -1
  59. package/lib/esm/curve/CoordinateXYZ.d.ts +10 -13
  60. package/lib/esm/curve/CoordinateXYZ.d.ts.map +1 -1
  61. package/lib/esm/curve/CoordinateXYZ.js +16 -15
  62. package/lib/esm/curve/CoordinateXYZ.js.map +1 -1
  63. package/lib/esm/curve/GeometryQuery.d.ts +17 -17
  64. package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
  65. package/lib/esm/curve/GeometryQuery.js +16 -15
  66. package/lib/esm/curve/GeometryQuery.js.map +1 -1
  67. package/lib/esm/curve/PointString3d.d.ts +17 -13
  68. package/lib/esm/curve/PointString3d.d.ts.map +1 -1
  69. package/lib/esm/curve/PointString3d.js +35 -20
  70. package/lib/esm/curve/PointString3d.js.map +1 -1
  71. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js +1 -1
  72. package/lib/esm/curve/spiral/MXCubicAlongArcSpiralEvaluator.js.map +1 -1
  73. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js +1 -1
  74. package/lib/esm/curve/spiral/PolishCubicSpiralEvaluator.js.map +1 -1
  75. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  76. package/lib/esm/geometry3d/FrameBuilder.js +3 -0
  77. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  78. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +8 -2
  79. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  80. package/lib/esm/geometry3d/GrowableXYZArray.js +11 -2
  81. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  82. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +42 -50
  83. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  84. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +80 -103
  85. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  86. package/lib/esm/polyface/Polyface.d.ts +166 -120
  87. package/lib/esm/polyface/Polyface.d.ts.map +1 -1
  88. package/lib/esm/polyface/Polyface.js +251 -162
  89. package/lib/esm/polyface/Polyface.js.map +1 -1
  90. package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -10
  91. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  92. package/lib/esm/polyface/PolyfaceBuilder.js +27 -21
  93. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  94. package/lib/esm/polyface/PolyfaceData.d.ts +142 -86
  95. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  96. package/lib/esm/polyface/PolyfaceData.js +305 -164
  97. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  98. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  99. package/lib/esm/topology/Graph.d.ts +2 -8
  100. package/lib/esm/topology/Graph.d.ts.map +1 -1
  101. package/lib/esm/topology/Graph.js +0 -3
  102. package/lib/esm/topology/Graph.js.map +1 -1
  103. package/lib/esm/topology/Triangulation.d.ts +18 -7
  104. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  105. package/lib/esm/topology/Triangulation.js +50 -9
  106. package/lib/esm/topology/Triangulation.js.map +1 -1
  107. package/package.json +4 -3
@@ -16,7 +16,7 @@ import { PointString3d } from "./PointString3d";
16
16
  * ```ts
17
17
  * function processGeometryQuery(q: GeometryQuery): void {
18
18
  * if ("solid" === q.geometryCategory)
19
- * alert("Solid type = " + q.solidPrimitiveType; // compiler knows q is an instance of SolidPrimitive
19
+ * alert("Solid type = " + q.solidPrimitiveType); // compiler knows q is an instance of SolidPrimitive
20
20
  * // ...etc...
21
21
  * ```
22
22
  *
@@ -27,7 +27,7 @@ import { PointString3d } from "./PointString3d";
27
27
  * - "solid" => [[SolidPrimitive]]
28
28
  * - "point" => [[CoordinateXYZ]]
29
29
  * - "pointCollection" => [[PointString3d]]
30
- * - "bsurf" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])
30
+ * - "bsurf" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])
31
31
  *
32
32
  * @see [[AnyGeometryQuery]]
33
33
  * @public
@@ -40,17 +40,17 @@ export type GeometryQueryCategory = "polyface" | "curvePrimitive" | "curveCollec
40
40
  */
41
41
  export type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd;
42
42
  /**
43
- * Queries to be supported by Curve, Surface, and Solid objects
43
+ * Queries to be supported by Curve, Surface, and Solid objects.
44
44
  * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,
45
- * and bspline surfaces
45
+ * and bspline surfaces.
46
46
  * @public
47
47
  */
48
48
  export declare abstract class GeometryQuery {
49
49
  /** Type discriminator. */
50
50
  abstract readonly geometryCategory: GeometryQueryCategory;
51
- /** Return the range of the entire GeometryQuery tree */
51
+ /** Return the range of the entire GeometryQuery tree. */
52
52
  range(transform?: Transform, result?: Range3d): Range3d;
53
- /** Extend rangeToExtend by the range of this geometry multiplied by the transform */
53
+ /** Extend `rangeToExtend` by the range of this geometry multiplied by the `transform`. */
54
54
  abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void;
55
55
  /**
56
56
  * Attempt to transform in place.
@@ -58,7 +58,7 @@ export declare abstract class GeometryQuery {
58
58
  * * Some geometry types may fail if scaling is non-uniform.
59
59
  */
60
60
  abstract tryTransformInPlace(transform: Transform): boolean;
61
- /** Try to move the geometry by dx,dy,dz */
61
+ /** Try to move the geometry by dx,dy,dz. */
62
62
  tryTranslateInPlace(dx: number, dy?: number, dz?: number): boolean;
63
63
  /** Return a transformed clone. */
64
64
  abstract cloneTransformed(transform: Transform): GeometryQuery | undefined;
@@ -69,28 +69,28 @@ export declare abstract class GeometryQuery {
69
69
  * * leaf classes do not need to implement.
70
70
  */
71
71
  get children(): GeometryQuery[] | undefined;
72
- /** Test if (other instanceof this.Type). REQUIRED IN ALL CONCRETE CLASSES */
72
+ /** Test `if (other instanceof this.Type)`. REQUIRED IN ALL CONCRETE CLASSES. */
73
73
  abstract isSameGeometryClass(other: GeometryQuery): boolean;
74
74
  /**
75
75
  * Test for exact structure and nearly identical geometry.
76
- * * Leaf classes must implement !!!
77
- * * base class implementation recurses through children.
78
- * * base implementation is complete for classes with children and no properties.
79
- * * classes with both children and properties must implement for properties, call super for children.
76
+ * * Leaf classes must implement.
77
+ * * Base class implementation recurses through children.
78
+ * * Base implementation is complete for classes with children and no properties.
79
+ * * Classes with both children and properties must implement for properties, call super for children.
80
80
  */
81
81
  isAlmostEqual(other: GeometryQuery): boolean;
82
82
  /**
83
83
  * Apply instance method [[isAlmostEqual]] if both are defined.
84
- * * both undefined returns true
85
- * * single defined returns false
84
+ * * Both undefined returns true.
85
+ * * Single defined returns false.
86
86
  */
87
87
  static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean;
88
88
  /**
89
- * * "double dispatch" call pattern.
90
- * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d` etc as
89
+ * Double Dispatch call pattern.
90
+ * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d`, etc as
91
91
  * relevant to its use case.
92
92
  * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call
93
- * such as `handler.handleLineSegment3d ()`
93
+ * such as `handler.handleLineSegment3d())`
94
94
  * * This allows each type-specific method to be called without a switch or `instanceof` test.
95
95
  * @param handler handler to be called by the particular geometry class
96
96
  */
@@ -1 +1 @@
1
- {"version":3,"file":"GeometryQuery.d.ts","sourceRoot":"","sources":["../../../src/curve/GeometryQuery.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAA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;GAKG;AACH,8BAAsB,aAAa;IACjC,0BAA0B;IAC1B,kBAAyB,gBAAgB,EAAE,qBAAqB,CAAC;IACjE,yDAAyD;IAClD,KAAK,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,OAAO;IAO9D,0FAA0F;aAC1E,WAAW,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;IAChF;;;;OAIG;aACa,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAClE,4CAA4C;IACrC,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,GAAE,MAAY,EAAE,EAAE,GAAE,MAAY,GAAG,OAAO;IAGnF,kCAAkC;aAClB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,GAAG,SAAS;IACjF,qBAAqB;aACL,KAAK,IAAI,aAAa,GAAG,SAAS;IAClD;;;OAGG;IACH,IAAW,QAAQ,IAAI,aAAa,EAAE,GAAG,SAAS,CAEjD;IACD,gFAAgF;aAChE,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAClE;;;;;;OAMG;IACI,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAoBnD;;;;OAIG;WACW,cAAc,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,EAAE,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO;IAOjG;;;;;;;;OAQG;aACa,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG;CACzE"}
@@ -1,13 +1,13 @@
1
1
  import { Range3d } from "../geometry3d/Range";
2
2
  import { Transform } from "../geometry3d/Transform";
3
3
  /**
4
- * Queries to be supported by Curve, Surface, and Solid objects
4
+ * Queries to be supported by Curve, Surface, and Solid objects.
5
5
  * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,
6
- * and bspline surfaces
6
+ * and bspline surfaces.
7
7
  * @public
8
8
  */
9
9
  export class GeometryQuery {
10
- /** Return the range of the entire GeometryQuery tree */
10
+ /** Return the range of the entire GeometryQuery tree. */
11
11
  range(transform, result) {
12
12
  if (result)
13
13
  result.setNull();
@@ -15,7 +15,7 @@ export class GeometryQuery {
15
15
  this.extendRange(range, transform);
16
16
  return range;
17
17
  }
18
- /** Try to move the geometry by dx,dy,dz */
18
+ /** Try to move the geometry by dx,dy,dz. */
19
19
  tryTranslateInPlace(dx, dy = 0.0, dz = 0.0) {
20
20
  return this.tryTransformInPlace(Transform.createTranslationXYZ(dx, dy, dz));
21
21
  }
@@ -23,13 +23,15 @@ export class GeometryQuery {
23
23
  * Return GeometryQuery children for recursive queries.
24
24
  * * leaf classes do not need to implement.
25
25
  */
26
- get children() { return undefined; }
26
+ get children() {
27
+ return undefined;
28
+ }
27
29
  /**
28
30
  * Test for exact structure and nearly identical geometry.
29
- * * Leaf classes must implement !!!
30
- * * base class implementation recurses through children.
31
- * * base implementation is complete for classes with children and no properties.
32
- * * classes with both children and properties must implement for properties, call super for children.
31
+ * * Leaf classes must implement.
32
+ * * Base class implementation recurses through children.
33
+ * * Base implementation is complete for classes with children and no properties.
34
+ * * Classes with both children and properties must implement for properties, call super for children.
33
35
  */
34
36
  isAlmostEqual(other) {
35
37
  if (this.isSameGeometryClass(other)) {
@@ -44,20 +46,19 @@ export class GeometryQuery {
44
46
  }
45
47
  return true;
46
48
  }
47
- else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children. So these null pointer cases are never reached.
48
- return false; // plainly different .
49
+ else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children so these null pointer cases are never reached.
50
+ return false; // plainly different
49
51
  }
50
52
  else {
51
- // both children null. call it equal? This class should probably have implemented.
52
- return true;
53
+ return true; // both children null; call it equal
53
54
  }
54
55
  }
55
56
  return false;
56
57
  }
57
58
  /**
58
59
  * Apply instance method [[isAlmostEqual]] if both are defined.
59
- * * both undefined returns true
60
- * * single defined returns false
60
+ * * Both undefined returns true.
61
+ * * Single defined returns false.
61
62
  */
62
63
  static areAlmostEqual(a, b) {
63
64
  if (a instanceof GeometryQuery && b instanceof GeometryQuery)
@@ -1 +1 @@
1
- {"version":3,"file":"GeometryQuery.js","sourceRoot":"","sources":["../../../src/curve/GeometryQuery.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAsCpD;;;;;GAKG;AACH,MAAM,OAAgB,aAAa;IAGjC,wDAAwD;IACjD,KAAK,CAAC,SAAqB,EAAE,MAAgB;QAClD,IAAI,MAAM;YAAE,MAAM,CAAC,OAAO,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IASD,2CAA2C;IACpC,mBAAmB,CAAC,EAAU,EAAE,KAAa,GAAG,EAAE,KAAa,GAAG;QACvE,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAKD;;;OAGG;IACH,IAAW,QAAQ,KAAkC,OAAO,SAAS,CAAC,CAAC,CAAC;IAGxE;;;;;;OAMG;IACI,aAAa,CAAC,KAAoB;QACvC,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;YAChC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;YACjC,IAAI,SAAS,IAAI,SAAS,EAAE;gBAC1B,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;oBACvC,OAAO,KAAK,CAAC;gBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACzC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;wBAAE,OAAO,KAAK,CAAC;iBAC7D;gBACD,OAAO,IAAI,CAAC;aACb;iBAAM,IAAI,SAAS,IAAI,SAAS,EAAE,EAAG,yGAAyG;gBAC7I,OAAO,KAAK,CAAC,CAAG,sBAAsB;aACvC;iBAAM;gBACL,oFAAoF;gBACpF,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,CAA4B,EAAE,CAA4B;QACrF,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,YAAY,aAAa;YAC1D,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;CAWF","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/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { BSpline2dNd } from \"../bspline/BSplineSurface\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { SolidPrimitive } from \"../solid/SolidPrimitive\";\r\nimport { CoordinateXYZ } from \"./CoordinateXYZ\";\r\nimport { CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { PointString3d } from \"./PointString3d\";\r\n\r\n/**\r\n * Describes the category of a [[GeometryQuery]], enabling type-switching like:\r\n * ```ts\r\n * function processGeometryQuery(q: GeometryQuery): void {\r\n * if (\"solid\" === q.geometryCategory)\r\n * alert(\"Solid type = \" + q.solidPrimitiveType; // compiler knows q is an instance of SolidPrimitive\r\n * // ...etc...\r\n * ```\r\n *\r\n * Each string maps to a particular subclass of [[GeometryQuery]]:\r\n * - \"polyface\" => [[Polyface]]\r\n * - \"curvePrimitive\" => [[CurvePrimitive]]\r\n * - \"curveCollection\" => [[CurveCollection]]\r\n * - \"solid\" => [[SolidPrimitive]]\r\n * - \"point\" => [[CoordinateXYZ]]\r\n * - \"pointCollection\" => [[PointString3d]]\r\n * - \"bsurf\" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])\r\n *\r\n * @see [[AnyGeometryQuery]]\r\n * @public\r\n */\r\nexport type GeometryQueryCategory = \"polyface\" | \"curvePrimitive\" | \"curveCollection\" | \"solid\" | \"point\" | \"pointCollection\" | \"bsurf\";\r\n\r\n/**\r\n * Union type for subclasses of [[GeometryQuery]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[GeometryQuery.geometryCategory]].\r\n * @public\r\n */\r\nexport type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd;\r\n\r\n/**\r\n * Queries to be supported by Curve, Surface, and Solid objects\r\n * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,\r\n * and bspline surfaces\r\n * @public\r\n */\r\nexport abstract class GeometryQuery {\r\n /** Type discriminator. */\r\n public abstract readonly geometryCategory: GeometryQueryCategory;\r\n /** Return the range of the entire GeometryQuery tree */\r\n public range(transform?: Transform, result?: Range3d): Range3d {\r\n if (result) result.setNull();\r\n const range = result ? result : Range3d.createNull();\r\n this.extendRange(range, transform);\r\n return range;\r\n }\r\n /** Extend rangeToExtend by the range of this geometry multiplied by the transform */\r\n public abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void;\r\n /**\r\n * Attempt to transform in place.\r\n * * LineSegment3d, Arc3d, LineString3d, BsplineCurve3d always succeed.\r\n * * Some geometry types may fail if scaling is non-uniform.\r\n */\r\n public abstract tryTransformInPlace(transform: Transform): boolean;\r\n /** Try to move the geometry by dx,dy,dz */\r\n public tryTranslateInPlace(dx: number, dy: number = 0.0, dz: number = 0.0): boolean {\r\n return this.tryTransformInPlace(Transform.createTranslationXYZ(dx, dy, dz));\r\n }\r\n /** Return a transformed clone. */\r\n public abstract cloneTransformed(transform: Transform): GeometryQuery | undefined;\r\n /** Return a clone */\r\n public abstract clone(): GeometryQuery | undefined;\r\n /**\r\n * Return GeometryQuery children for recursive queries.\r\n * * leaf classes do not need to implement.\r\n */\r\n public get children(): GeometryQuery[] | undefined { return undefined; }\r\n /** Test if (other instanceof this.Type). REQUIRED IN ALL CONCRETE CLASSES */\r\n public abstract isSameGeometryClass(other: GeometryQuery): boolean;\r\n /**\r\n * Test for exact structure and nearly identical geometry.\r\n * * Leaf classes must implement !!!\r\n * * base class implementation recurses through children.\r\n * * base implementation is complete for classes with children and no properties.\r\n * * classes with both children and properties must implement for properties, call super for children.\r\n */\r\n public isAlmostEqual(other: GeometryQuery): boolean {\r\n if (this.isSameGeometryClass(other)) {\r\n const childrenA = this.children;\r\n const childrenB = other.children;\r\n if (childrenA && childrenB) {\r\n if (childrenA.length !== childrenB.length)\r\n return false;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n if (!childrenA[i].isAlmostEqual(childrenB[i])) return false;\r\n }\r\n return true;\r\n } else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children. So these null pointer cases are never reached.\r\n return false; // plainly different .\r\n } else {\r\n // both children null. call it equal? This class should probably have implemented.\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Apply instance method [[isAlmostEqual]] if both are defined.\r\n * * both undefined returns true\r\n * * single defined returns false\r\n */\r\n public static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean {\r\n if (a instanceof GeometryQuery && b instanceof GeometryQuery)\r\n return a.isAlmostEqual(b);\r\n if ((a === undefined) && (b === undefined))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * * \"double dispatch\" call pattern.\r\n * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d` etc as\r\n * relevant to its use case.\r\n * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call\r\n * such as `handler.handleLineSegment3d ()`\r\n * * This allows each type-specific method to be called without a switch or `instanceof` test.\r\n * @param handler handler to be called by the particular geometry class\r\n */\r\n public abstract dispatchToGeometryHandler(handler: GeometryHandler): any;\r\n}\r\n"]}
1
+ {"version":3,"file":"GeometryQuery.js","sourceRoot":"","sources":["../../../src/curve/GeometryQuery.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAsCpD;;;;;GAKG;AACH,MAAM,OAAgB,aAAa;IAGjC,yDAAyD;IAClD,KAAK,CAAC,SAAqB,EAAE,MAAgB;QAClD,IAAI,MAAM;YACR,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;QACrD,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;IACf,CAAC;IASD,4CAA4C;IACrC,mBAAmB,CAAC,EAAU,EAAE,KAAa,GAAG,EAAE,KAAa,GAAG;QACvE,OAAO,IAAI,CAAC,mBAAmB,CAAC,SAAS,CAAC,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;IAKD;;;OAGG;IACH,IAAW,QAAQ;QACjB,OAAO,SAAS,CAAC;IACnB,CAAC;IAGD;;;;;;OAMG;IACI,aAAa,CAAC,KAAoB;QACvC,IAAI,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE;YACnC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC;YAChC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC;YACjC,IAAI,SAAS,IAAI,SAAS,EAAE;gBAC1B,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM;oBACvC,OAAO,KAAK,CAAC;gBACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;oBACzC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;wBAC3C,OAAO,KAAK,CAAC;iBAChB;gBACD,OAAO,IAAI,CAAC;aACb;iBAAM,IAAI,SAAS,IAAI,SAAS,EAAE,EAAE,uGAAuG;gBAC1I,OAAO,KAAK,CAAC,CAAC,oBAAoB;aACnC;iBAAM;gBACL,OAAO,IAAI,CAAC,CAAC,oCAAoC;aAClD;SACF;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;OAIG;IACI,MAAM,CAAC,cAAc,CAAC,CAA4B,EAAE,CAA4B;QACrF,IAAI,CAAC,YAAY,aAAa,IAAI,CAAC,YAAY,aAAa;YAC1D,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,SAAS,CAAC;YACxC,OAAO,IAAI,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;CAWF","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/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { BSpline2dNd } from \"../bspline/BSplineSurface\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { SolidPrimitive } from \"../solid/SolidPrimitive\";\r\nimport { CoordinateXYZ } from \"./CoordinateXYZ\";\r\nimport { CurveCollection } from \"./CurveCollection\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { PointString3d } from \"./PointString3d\";\r\n\r\n/**\r\n * Describes the category of a [[GeometryQuery]], enabling type-switching like:\r\n * ```ts\r\n * function processGeometryQuery(q: GeometryQuery): void {\r\n * if (\"solid\" === q.geometryCategory)\r\n * alert(\"Solid type = \" + q.solidPrimitiveType); // compiler knows q is an instance of SolidPrimitive\r\n * // ...etc...\r\n * ```\r\n *\r\n * Each string maps to a particular subclass of [[GeometryQuery]]:\r\n * - \"polyface\" => [[Polyface]]\r\n * - \"curvePrimitive\" => [[CurvePrimitive]]\r\n * - \"curveCollection\" => [[CurveCollection]]\r\n * - \"solid\" => [[SolidPrimitive]]\r\n * - \"point\" => [[CoordinateXYZ]]\r\n * - \"pointCollection\" => [[PointString3d]]\r\n * - \"bsurf\" => [[BSpline2dNd]] (which is an intermediate class shared by [[BSplineSurface3d]] and [[BSplineSurface3dH]])\r\n *\r\n * @see [[AnyGeometryQuery]]\r\n * @public\r\n */\r\nexport type GeometryQueryCategory = \"polyface\" | \"curvePrimitive\" | \"curveCollection\" | \"solid\" | \"point\" | \"pointCollection\" | \"bsurf\";\r\n\r\n/**\r\n * Union type for subclasses of [[GeometryQuery]]. Specific subclasses can be discriminated at compile- or run-time\r\n * using [[GeometryQuery.geometryCategory]].\r\n * @public\r\n */\r\nexport type AnyGeometryQuery = Polyface | CurvePrimitive | CurveCollection | SolidPrimitive | CoordinateXYZ | PointString3d | BSpline2dNd;\r\n\r\n/**\r\n * Queries to be supported by Curve, Surface, and Solid objects.\r\n * * `GeometryQuery` is an abstract base class with (abstract) methods for querying curve, solid primitive, mesh,\r\n * and bspline surfaces.\r\n * @public\r\n */\r\nexport abstract class GeometryQuery {\r\n /** Type discriminator. */\r\n public abstract readonly geometryCategory: GeometryQueryCategory;\r\n /** Return the range of the entire GeometryQuery tree. */\r\n public range(transform?: Transform, result?: Range3d): Range3d {\r\n if (result)\r\n result.setNull();\r\n const range = result ? result : Range3d.createNull();\r\n this.extendRange(range, transform);\r\n return range;\r\n }\r\n /** Extend `rangeToExtend` by the range of this geometry multiplied by the `transform`. */\r\n public abstract extendRange(rangeToExtend: Range3d, transform?: Transform): void;\r\n /**\r\n * Attempt to transform in place.\r\n * * LineSegment3d, Arc3d, LineString3d, BsplineCurve3d always succeed.\r\n * * Some geometry types may fail if scaling is non-uniform.\r\n */\r\n public abstract tryTransformInPlace(transform: Transform): boolean;\r\n /** Try to move the geometry by dx,dy,dz. */\r\n public tryTranslateInPlace(dx: number, dy: number = 0.0, dz: number = 0.0): boolean {\r\n return this.tryTransformInPlace(Transform.createTranslationXYZ(dx, dy, dz));\r\n }\r\n /** Return a transformed clone. */\r\n public abstract cloneTransformed(transform: Transform): GeometryQuery | undefined;\r\n /** Return a clone */\r\n public abstract clone(): GeometryQuery | undefined;\r\n /**\r\n * Return GeometryQuery children for recursive queries.\r\n * * leaf classes do not need to implement.\r\n */\r\n public get children(): GeometryQuery[] | undefined {\r\n return undefined;\r\n }\r\n /** Test `if (other instanceof this.Type)`. REQUIRED IN ALL CONCRETE CLASSES. */\r\n public abstract isSameGeometryClass(other: GeometryQuery): boolean;\r\n /**\r\n * Test for exact structure and nearly identical geometry.\r\n * * Leaf classes must implement.\r\n * * Base class implementation recurses through children.\r\n * * Base implementation is complete for classes with children and no properties.\r\n * * Classes with both children and properties must implement for properties, call super for children.\r\n */\r\n public isAlmostEqual(other: GeometryQuery): boolean {\r\n if (this.isSameGeometryClass(other)) {\r\n const childrenA = this.children;\r\n const childrenB = other.children;\r\n if (childrenA && childrenB) {\r\n if (childrenA.length !== childrenB.length)\r\n return false;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n if (!childrenA[i].isAlmostEqual(childrenB[i]))\r\n return false;\r\n }\r\n return true;\r\n } else if (childrenA || childrenB) { // CurveCollections start with empty arrays for children so these null pointer cases are never reached.\r\n return false; // plainly different\r\n } else {\r\n return true; // both children null; call it equal\r\n }\r\n }\r\n return false;\r\n }\r\n /**\r\n * Apply instance method [[isAlmostEqual]] if both are defined.\r\n * * Both undefined returns true.\r\n * * Single defined returns false.\r\n */\r\n public static areAlmostEqual(a: GeometryQuery | undefined, b: GeometryQuery | undefined): boolean {\r\n if (a instanceof GeometryQuery && b instanceof GeometryQuery)\r\n return a.isAlmostEqual(b);\r\n if ((a === undefined) && (b === undefined))\r\n return true;\r\n return false;\r\n }\r\n /**\r\n * Double Dispatch call pattern.\r\n * * User code implements a `GeometryHandler` with specialized methods to handle `LineSegment3d`, `Arc3d`, etc as\r\n * relevant to its use case.\r\n * * Each such `GeometryQuery` class implements this method as a one-line method containing the appropriate call\r\n * such as `handler.handleLineSegment3d())`\r\n * * This allows each type-specific method to be called without a switch or `instanceof` test.\r\n * @param handler handler to be called by the particular geometry class\r\n */\r\n public abstract dispatchToGeometryHandler(handler: GeometryHandler): any;\r\n}\r\n"]}
@@ -21,36 +21,40 @@ export declare class PointString3d extends GeometryQuery implements BeJSONFuncti
21
21
  /** Test if `other` is a PointString3d */
22
22
  isSameGeometryClass(other: GeometryQuery): boolean;
23
23
  private _points;
24
- /** return a clone of the points array. */
24
+ /** Return a clone of the points array. */
25
25
  get points(): Point3d[];
26
26
  private constructor();
27
27
  /** Clone and apply a transform. */
28
28
  cloneTransformed(transform: Transform): PointString3d;
29
+ /**
30
+ * Turn any array (possibly nested) into a "flat" array of objects that are not arrays. This allows processing
31
+ * the objects without recursion into nested arrays.
32
+ */
29
33
  private static flattenArray;
30
34
  /** Create a PointString3d from points. */
31
35
  static create(...points: any[]): PointString3d;
32
- /** Add multiple points to the PointString3d */
36
+ /** Add multiple points to the PointString3d. */
33
37
  addPoints(...points: any[]): void;
34
- /** Add a single point to the PointString3d */
38
+ /** Add a single point to the PointString3d. */
35
39
  addPoint(point: Point3d): void;
36
- /** Remove the last point added to the PointString3d */
40
+ /** Remove the last point added to the PointString3d. */
37
41
  popPoint(): void;
38
- /** Replace this PointString3d's point array by a clone of the array in `other` */
42
+ /** Replace this PointString3d's point array by a clone of the array in `other`. */
39
43
  setFrom(other: PointString3d): void;
40
- /** Create from an array of Point3d */
44
+ /** Create from an array of Point3d. */
41
45
  static createPoints(points: Point3d[]): PointString3d;
42
- /** Create a PointString3d from xyz coordinates packed in a Float64Array */
46
+ /** Create a PointString3d from xyz coordinates packed in a Float64Array. */
43
47
  static createFloat64Array(xyzData: Float64Array): PointString3d;
44
48
  /** Return a deep clone. */
45
49
  clone(): PointString3d;
46
- /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,2,2]]` */
50
+ /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,5,6]]`. */
47
51
  setFromJSON(json?: any): void;
48
52
  /**
49
53
  * Convert an PointString3d to a JSON object.
50
- * @return {*} [[x,y,z],...[x,y,z]]
54
+ * @return {*} e.g., `[[1,2,3], [4,5,6]]`.
51
55
  */
52
56
  toJSON(): XYZProps[];
53
- /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,2,2]]` */
57
+ /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,5,6]]`. */
54
58
  static fromJSON(json?: any): PointString3d;
55
59
  /** Access a single point by index. */
56
60
  pointAt(i: number, result?: Point3d): Point3d | undefined;
@@ -58,7 +62,7 @@ export declare class PointString3d extends GeometryQuery implements BeJSONFuncti
58
62
  numPoints(): number;
59
63
  /** Reverse the point order */
60
64
  reverseInPlace(): void;
61
- /** Return the number of points. */
65
+ /** Apply transform on points in place. */
62
66
  tryTransformInPlace(transform: Transform): boolean;
63
67
  /** Return the index and coordinates of the closest point to spacePoint. */
64
68
  closestPoint(spacePoint: Point3d): {
@@ -67,13 +71,13 @@ export declare class PointString3d extends GeometryQuery implements BeJSONFuncti
67
71
  };
68
72
  /** Return true if all points are in the given plane. */
69
73
  isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean;
70
- /** Extend a range to include the points in this PointString3d. */
74
+ /** Extend a range to include the points in this PointString3d (optionally transformed). */
71
75
  extendRange(rangeToExtend: Range3d, transform?: Transform): void;
72
76
  /** Return true if corresponding points are almost equal. */
73
77
  isAlmostEqual(other: GeometryQuery): boolean;
74
78
  /** Reduce to empty set of points. */
75
79
  clear(): void;
76
- /** Second step of double dispatch: call `handler.handlePointString(this)` */
80
+ /** Second step of double dispatch: call `handler.handlePointString(this)` */
77
81
  dispatchToGeometryHandler(handler: GeometryHandler): any;
78
82
  }
79
83
  //# sourceMappingURL=PointString3d.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PointString3d.d.ts","sourceRoot":"","sources":["../../../src/curve/PointString3d.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAIhD;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,aAAc,YAAW,eAAe;IACzE,wCAAwC;IACxC,SAAgB,gBAAgB,qBAAqB;IAErD,yCA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AE,aAAa,GAAG,OAAO;IAK5D,qCAAqC;IAC9B,KAAK;IAGZ,6EAA6E;IACtE,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG;CAGhE"}
@@ -18,9 +18,13 @@ import { GeometryQuery } from "./GeometryQuery";
18
18
  */
19
19
  export class PointString3d extends GeometryQuery {
20
20
  /** Test if `other` is a PointString3d */
21
- isSameGeometryClass(other) { return other instanceof PointString3d; }
22
- /** return a clone of the points array. */
23
- get points() { return this._points; }
21
+ isSameGeometryClass(other) {
22
+ return other instanceof PointString3d;
23
+ }
24
+ /** Return a clone of the points array. */
25
+ get points() {
26
+ return this._points;
27
+ }
24
28
  constructor() {
25
29
  super();
26
30
  /** String name for schema properties */
@@ -30,11 +34,18 @@ export class PointString3d extends GeometryQuery {
30
34
  /** Clone and apply a transform. */
31
35
  cloneTransformed(transform) {
32
36
  const c = this.clone();
33
- c.tryTransformInPlace(transform);
37
+ c.tryTransformInPlace(transform); // we know tryTransformInPlace succeeds
34
38
  return c;
35
39
  }
40
+ /**
41
+ * Turn any array (possibly nested) into a "flat" array of objects that are not arrays. This allows processing
42
+ * the objects without recursion into nested arrays.
43
+ */
36
44
  static flattenArray(arr) {
37
- return arr.reduce((flat, toFlatten) => {
45
+ return arr.reduce(
46
+ // a callback function to execute for each element in the array. Its return value becomes
47
+ // the value of the "flat" parameter on the next invocation of the callback function.
48
+ (flat, toFlatten) => {
38
49
  return flat.concat(Array.isArray(toFlatten) ? PointString3d.flattenArray(toFlatten) : toFlatten);
39
50
  }, []);
40
51
  }
@@ -44,7 +55,7 @@ export class PointString3d extends GeometryQuery {
44
55
  result.addPoints(points);
45
56
  return result;
46
57
  }
47
- /** Add multiple points to the PointString3d */
58
+ /** Add multiple points to the PointString3d. */
48
59
  addPoints(...points) {
49
60
  const toAdd = PointString3d.flattenArray(points);
50
61
  for (const p of toAdd) {
@@ -52,25 +63,25 @@ export class PointString3d extends GeometryQuery {
52
63
  this._points.push(p);
53
64
  }
54
65
  }
55
- /** Add a single point to the PointString3d */
66
+ /** Add a single point to the PointString3d. */
56
67
  addPoint(point) {
57
68
  this._points.push(point);
58
69
  }
59
- /** Remove the last point added to the PointString3d */
70
+ /** Remove the last point added to the PointString3d. */
60
71
  popPoint() {
61
72
  this._points.pop();
62
73
  }
63
- /** Replace this PointString3d's point array by a clone of the array in `other` */
74
+ /** Replace this PointString3d's point array by a clone of the array in `other`. */
64
75
  setFrom(other) {
65
76
  this._points = Point3dArray.clonePoint3dArray(other._points);
66
77
  }
67
- /** Create from an array of Point3d */
78
+ /** Create from an array of Point3d. */
68
79
  static createPoints(points) {
69
80
  const ps = new PointString3d();
70
81
  ps._points = Point3dArray.clonePoint3dArray(points);
71
82
  return ps;
72
83
  }
73
- /** Create a PointString3d from xyz coordinates packed in a Float64Array */
84
+ /** Create a PointString3d from xyz coordinates packed in a Float64Array. */
74
85
  static createFloat64Array(xyzData) {
75
86
  const ps = new PointString3d();
76
87
  for (let i = 0; i + 3 <= xyzData.length; i += 3)
@@ -83,7 +94,7 @@ export class PointString3d extends GeometryQuery {
83
94
  retVal.setFrom(this);
84
95
  return retVal;
85
96
  }
86
- /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,2,2]]` */
97
+ /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,5,6]]`. */
87
98
  setFromJSON(json) {
88
99
  this._points.length = 0;
89
100
  if (Array.isArray(json)) {
@@ -94,7 +105,7 @@ export class PointString3d extends GeometryQuery {
94
105
  }
95
106
  /**
96
107
  * Convert an PointString3d to a JSON object.
97
- * @return {*} [[x,y,z],...[x,y,z]]
108
+ * @return {*} e.g., `[[1,2,3], [4,5,6]]`.
98
109
  */
99
110
  toJSON() {
100
111
  const value = [];
@@ -102,7 +113,7 @@ export class PointString3d extends GeometryQuery {
102
113
  value.push(p.toJSON());
103
114
  return value;
104
115
  }
105
- /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,2,2]]` */
116
+ /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,5,6]]`. */
106
117
  static fromJSON(json) {
107
118
  const ps = new PointString3d();
108
119
  ps.setFromJSON(json);
@@ -120,14 +131,16 @@ export class PointString3d extends GeometryQuery {
120
131
  return undefined;
121
132
  }
122
133
  /** Return the number of points. */
123
- numPoints() { return this._points.length; }
134
+ numPoints() {
135
+ return this._points.length;
136
+ }
124
137
  /** Reverse the point order */
125
138
  reverseInPlace() {
126
139
  if (this._points.length >= 2) {
127
140
  let i0 = 0;
128
141
  let i1 = this._points.length - 1;
129
142
  while (i0 < i1) {
130
- const a = this._points[i0];
143
+ const a = this._points[i1];
131
144
  this._points[i1] = this._points[i0];
132
145
  this._points[i0] = a;
133
146
  i0++;
@@ -135,7 +148,7 @@ export class PointString3d extends GeometryQuery {
135
148
  }
136
149
  }
137
150
  }
138
- /** Return the number of points. */
151
+ /** Apply transform on points in place. */
139
152
  tryTransformInPlace(transform) {
140
153
  transform.multiplyPoint3dArrayInPlace(this._points);
141
154
  return true;
@@ -154,7 +167,7 @@ export class PointString3d extends GeometryQuery {
154
167
  isInPlane(plane) {
155
168
  return Point3dArray.isCloseToPlane(this._points, plane, Geometry.smallMetricDistance);
156
169
  }
157
- /** Extend a range to include the points in this PointString3d. */
170
+ /** Extend a range to include the points in this PointString3d (optionally transformed). */
158
171
  extendRange(rangeToExtend, transform) {
159
172
  rangeToExtend.extendArray(this._points, transform);
160
173
  }
@@ -165,8 +178,10 @@ export class PointString3d extends GeometryQuery {
165
178
  return Point3dArray.isAlmostEqual(this._points, other._points);
166
179
  }
167
180
  /** Reduce to empty set of points. */
168
- clear() { this._points.length = 0; }
169
- /** Second step of double dispatch: call `handler.handlePointString(this)` */
181
+ clear() {
182
+ this._points.length = 0;
183
+ }
184
+ /** Second step of double dispatch: call `handler.handlePointString(this)` */
170
185
  dispatchToGeometryHandler(handler) {
171
186
  return handler.handlePointString3d(this);
172
187
  }
@@ -1 +1 @@
1
- {"version":3,"file":"PointString3d.js","sourceRoot":"","sources":["../../../src/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,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;SACzC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,wDAAwD;IACjD,SAAS,CAAC,KAAmC;QAClD,OAAO,YAAY,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACxF,CAAC;IACD,kEAAkE;IAC3D,WAAW,CAAC,aAAsB,EAAE,SAAqB;QAC9D,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,4DAA4D;IAC5C,aAAa,CAAC,KAAoB;QAChD,IAAI,CAAC,CAAC,KAAK,YAAY,aAAa,CAAC;YACnC,OAAO,KAAK,CAAC;QACf,OAAO,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IACD,qCAAqC;IAC9B,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAC3C,8EAA8E;IACvE,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CAEF","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 { BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/**\r\n * A PointString3d is an array of points.\r\n * * PointString3D is first class (displayable, possibly persistent) geometry derived from the GeometryQuery base class.\r\n * * The various points in the PointString3d are NOT connected by line segments for display or other calculations.\r\n * @public\r\n */\r\nexport class PointString3d extends GeometryQuery implements BeJSONFunctions {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"pointCollection\";\r\n\r\n /** Test if `other` is a PointString3d */\r\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof PointString3d; }\r\n private _points: Point3d[];\r\n /** return a clone of the points array. */\r\n public get points(): Point3d[] { return this._points; }\r\n private constructor() {\r\n super();\r\n this._points = [];\r\n }\r\n /** Clone and apply a transform. */\r\n public cloneTransformed(transform: Transform): PointString3d { // we know tryTransformInPlace succeeds.\r\n const c = this.clone();\r\n c.tryTransformInPlace(transform);\r\n return c;\r\n }\r\n private static flattenArray(arr: any): any {\r\n return arr.reduce((flat: any, toFlatten: any) => {\r\n return flat.concat(Array.isArray(toFlatten) ? PointString3d.flattenArray(toFlatten) : toFlatten);\r\n }, []);\r\n }\r\n /** Create a PointString3d from points. */\r\n public static create(...points: any[]): PointString3d {\r\n const result = new PointString3d();\r\n result.addPoints(points);\r\n return result;\r\n }\r\n\r\n /** Add multiple points to the PointString3d */\r\n public addPoints(...points: any[]) {\r\n const toAdd: any[] = PointString3d.flattenArray(points);\r\n for (const p of toAdd) {\r\n if (p instanceof Point3d)\r\n this._points.push(p);\r\n }\r\n }\r\n /** Add a single point to the PointString3d */\r\n public addPoint(point: Point3d) {\r\n this._points.push(point);\r\n }\r\n /** Remove the last point added to the PointString3d */\r\n public popPoint() {\r\n this._points.pop();\r\n }\r\n\r\n /** Replace this PointString3d's point array by a clone of the array in `other` */\r\n public setFrom(other: PointString3d) {\r\n this._points = Point3dArray.clonePoint3dArray(other._points);\r\n }\r\n /** Create from an array of Point3d */\r\n public static createPoints(points: Point3d[]): PointString3d {\r\n const ps = new PointString3d();\r\n ps._points = Point3dArray.clonePoint3dArray(points);\r\n return ps;\r\n }\r\n /** Create a PointString3d from xyz coordinates packed in a Float64Array */\r\n public static createFloat64Array(xyzData: Float64Array): PointString3d {\r\n const ps = new PointString3d();\r\n for (let i = 0; i + 3 <= xyzData.length; i += 3)\r\n ps._points.push(Point3d.create(xyzData[i], xyzData[i + 1], xyzData[i + 2]));\r\n return ps;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): PointString3d {\r\n const retVal = new PointString3d();\r\n retVal.setFrom(this);\r\n return retVal;\r\n }\r\n /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,2,2]]` */\r\n public setFromJSON(json?: any) {\r\n this._points.length = 0;\r\n if (Array.isArray(json)) {\r\n let xyz;\r\n for (xyz of json)\r\n this._points.push(Point3d.fromJSON(xyz));\r\n }\r\n }\r\n /**\r\n * Convert an PointString3d to a JSON object.\r\n * @return {*} [[x,y,z],...[x,y,z]]\r\n */\r\n public toJSON(): XYZProps[] {\r\n const value = [];\r\n for (const p of this._points) value.push(p.toJSON());\r\n return value;\r\n }\r\n /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,2,2]]` */\r\n public static fromJSON(json?: any): PointString3d {\r\n const ps = new PointString3d(); ps.setFromJSON(json); return ps;\r\n }\r\n /** Access a single point by index. */\r\n public pointAt(i: number, result?: Point3d): Point3d | undefined {\r\n if (i >= 0 && i < this._points.length) {\r\n if (result) { result.setFrom(this._points[i]); return result; }\r\n return this._points[i].clone();\r\n }\r\n return undefined;\r\n }\r\n /** Return the number of points. */\r\n public numPoints(): number { return this._points.length; }\r\n\r\n /** Reverse the point order */\r\n public reverseInPlace(): void {\r\n if (this._points.length >= 2) {\r\n let i0 = 0;\r\n let i1 = this._points.length - 1;\r\n while (i0 < i1) {\r\n const a = this._points[i0];\r\n this._points[i1] = this._points[i0];\r\n this._points[i0] = a;\r\n i0++;\r\n i1--;\r\n }\r\n }\r\n }\r\n /** Return the number of points. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n transform.multiplyPoint3dArrayInPlace(this._points);\r\n return true;\r\n }\r\n /** Return the index and coordinates of the closest point to spacePoint. */\r\n public closestPoint(spacePoint: Point3d): { index: number, xyz: Point3d } {\r\n const result = { index: -1, xyz: Point3d.create() };\r\n const index = Point3dArray.closestPointIndex(this._points, spacePoint);\r\n if (index >= 0) {\r\n result.index = index;\r\n result.xyz.setFrom(this._points[index]);\r\n }\r\n return result;\r\n }\r\n /** Return true if all points are in the given plane. */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return Point3dArray.isCloseToPlane(this._points, plane, Geometry.smallMetricDistance);\r\n }\r\n /** Extend a range to include the points in this PointString3d. */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n rangeToExtend.extendArray(this._points, transform);\r\n }\r\n /** Return true if corresponding points are almost equal. */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (!(other instanceof PointString3d))\r\n return false;\r\n return Point3dArray.isAlmostEqual(this._points, other._points);\r\n }\r\n /** Reduce to empty set of points. */\r\n public clear() { this._points.length = 0; }\r\n /** Second step of double dispatch: call `handler.handlePointString(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handlePointString3d(this);\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"PointString3d.js","sourceRoot":"","sources":["../../../src/curve/PointString3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,OAAO,EAAmB,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGxD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM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E,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IACxF,CAAC;IACD,2FAA2F;IACpF,WAAW,CAAC,aAAsB,EAAE,SAAqB;QAC9D,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IACD,4DAA4D;IAC5C,aAAa,CAAC,KAAoB;QAChD,IAAI,CAAC,CAAC,KAAK,YAAY,aAAa,CAAC;YACnC,OAAO,KAAK,CAAC;QACf,OAAO,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACjE,CAAC;IACD,qCAAqC;IAC9B,KAAK;QACV,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,6EAA6E;IACtE,yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;CACF","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 { BeJSONFunctions, Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/**\r\n * A PointString3d is an array of points.\r\n * * PointString3D is first class (displayable, possibly persistent) geometry derived from the GeometryQuery base class.\r\n * * The various points in the PointString3d are NOT connected by line segments for display or other calculations.\r\n * @public\r\n */\r\nexport class PointString3d extends GeometryQuery implements BeJSONFunctions {\r\n /** String name for schema properties */\r\n public readonly geometryCategory = \"pointCollection\";\r\n /** Test if `other` is a PointString3d */\r\n public isSameGeometryClass(other: GeometryQuery): boolean {\r\n return other instanceof PointString3d;\r\n }\r\n private _points: Point3d[];\r\n /** Return a clone of the points array. */\r\n public get points(): Point3d[] {\r\n return this._points;\r\n }\r\n private constructor() {\r\n super();\r\n this._points = [];\r\n }\r\n /** Clone and apply a transform. */\r\n public cloneTransformed(transform: Transform): PointString3d {\r\n const c = this.clone();\r\n c.tryTransformInPlace(transform); // we know tryTransformInPlace succeeds\r\n return c;\r\n }\r\n /**\r\n * Turn any array (possibly nested) into a \"flat\" array of objects that are not arrays. This allows processing\r\n * the objects without recursion into nested arrays.\r\n */\r\n private static flattenArray(arr: any): any {\r\n return arr.reduce(\r\n // a callback function to execute for each element in the array. Its return value becomes\r\n // the value of the \"flat\" parameter on the next invocation of the callback function.\r\n (flat: any, toFlatten: any) => {\r\n return flat.concat(Array.isArray(toFlatten) ? PointString3d.flattenArray(toFlatten) : toFlatten);\r\n },\r\n [], // initial value (empty array)\r\n );\r\n }\r\n /** Create a PointString3d from points. */\r\n public static create(...points: any[]): PointString3d {\r\n const result = new PointString3d();\r\n result.addPoints(points);\r\n return result;\r\n }\r\n /** Add multiple points to the PointString3d. */\r\n public addPoints(...points: any[]) {\r\n const toAdd: any[] = PointString3d.flattenArray(points);\r\n for (const p of toAdd) {\r\n if (p instanceof Point3d)\r\n this._points.push(p);\r\n }\r\n }\r\n /** Add a single point to the PointString3d. */\r\n public addPoint(point: Point3d) {\r\n this._points.push(point);\r\n }\r\n /** Remove the last point added to the PointString3d. */\r\n public popPoint() {\r\n this._points.pop();\r\n }\r\n /** Replace this PointString3d's point array by a clone of the array in `other`. */\r\n public setFrom(other: PointString3d) {\r\n this._points = Point3dArray.clonePoint3dArray(other._points);\r\n }\r\n /** Create from an array of Point3d. */\r\n public static createPoints(points: Point3d[]): PointString3d {\r\n const ps = new PointString3d();\r\n ps._points = Point3dArray.clonePoint3dArray(points);\r\n return ps;\r\n }\r\n /** Create a PointString3d from xyz coordinates packed in a Float64Array. */\r\n public static createFloat64Array(xyzData: Float64Array): PointString3d {\r\n const ps = new PointString3d();\r\n for (let i = 0; i + 3 <= xyzData.length; i += 3)\r\n ps._points.push(Point3d.create(xyzData[i], xyzData[i + 1], xyzData[i + 2]));\r\n return ps;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): PointString3d {\r\n const retVal = new PointString3d();\r\n retVal.setFrom(this);\r\n return retVal;\r\n }\r\n /** Replace this instance's points by those from a json array, e.g. `[[1,2,3], [4,5,6]]`. */\r\n public setFromJSON(json?: any) {\r\n this._points.length = 0;\r\n if (Array.isArray(json)) {\r\n let xyz;\r\n for (xyz of json)\r\n this._points.push(Point3d.fromJSON(xyz));\r\n }\r\n }\r\n /**\r\n * Convert an PointString3d to a JSON object.\r\n * @return {*} e.g., `[[1,2,3], [4,5,6]]`.\r\n */\r\n public toJSON(): XYZProps[] {\r\n const value = [];\r\n for (const p of this._points)\r\n value.push(p.toJSON());\r\n return value;\r\n }\r\n /** Create a PointString3d from a json array, e.g. `[[1,2,3], [4,5,6]]`. */\r\n public static fromJSON(json?: any): PointString3d {\r\n const ps = new PointString3d();\r\n ps.setFromJSON(json);\r\n return ps;\r\n }\r\n /** Access a single point by index. */\r\n public pointAt(i: number, result?: Point3d): Point3d | undefined {\r\n if (i >= 0 && i < this._points.length) {\r\n if (result) {\r\n result.setFrom(this._points[i]);\r\n return result;\r\n }\r\n return this._points[i].clone();\r\n }\r\n return undefined;\r\n }\r\n /** Return the number of points. */\r\n public numPoints(): number {\r\n return this._points.length;\r\n }\r\n /** Reverse the point order */\r\n public reverseInPlace(): void {\r\n if (this._points.length >= 2) {\r\n let i0 = 0;\r\n let i1 = this._points.length - 1;\r\n while (i0 < i1) {\r\n const a = this._points[i1];\r\n this._points[i1] = this._points[i0];\r\n this._points[i0] = a;\r\n i0++;\r\n i1--;\r\n }\r\n }\r\n }\r\n /** Apply transform on points in place. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n transform.multiplyPoint3dArrayInPlace(this._points);\r\n return true;\r\n }\r\n /** Return the index and coordinates of the closest point to spacePoint. */\r\n public closestPoint(spacePoint: Point3d): { index: number, xyz: Point3d } {\r\n const result = { index: -1, xyz: Point3d.create() };\r\n const index = Point3dArray.closestPointIndex(this._points, spacePoint);\r\n if (index >= 0) {\r\n result.index = index;\r\n result.xyz.setFrom(this._points[index]);\r\n }\r\n return result;\r\n }\r\n /** Return true if all points are in the given plane. */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return Point3dArray.isCloseToPlane(this._points, plane, Geometry.smallMetricDistance);\r\n }\r\n /** Extend a range to include the points in this PointString3d (optionally transformed). */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n rangeToExtend.extendArray(this._points, transform);\r\n }\r\n /** Return true if corresponding points are almost equal. */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (!(other instanceof PointString3d))\r\n return false;\r\n return Point3dArray.isAlmostEqual(this._points, other._points);\r\n }\r\n /** Reduce to empty set of points. */\r\n public clear() {\r\n this._points.length = 0;\r\n }\r\n /** Second step of double dispatch: call `handler.handlePointString(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handlePointString3d(this);\r\n }\r\n}\r\n"]}
@@ -47,7 +47,7 @@ export class MXCubicAlongArcEvaluator extends CubicEvaluator {
47
47
  super.scaleInPlace(scaleFactor);
48
48
  }
49
49
  /** return a deep copy of the evaluator */
50
- clone() { return new MXCubicAlongArcEvaluator(this.nominalLength1, this.nominalRadius1, super._axisLength, this.cubicM); }
50
+ clone() { return new MXCubicAlongArcEvaluator(this.nominalLength1, this.nominalRadius1, this.axisLength, this.cubicM); }
51
51
  /** Member by member matchup ... */
52
52
  isAlmostEqual(other) {
53
53
  if (other instanceof MXCubicAlongArcEvaluator) {
@@ -1 +1 @@
1
- {"version":3,"file":"MXCubicAlongArcSpiralEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/MXCubicAlongArcSpiralEvaluator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IAI1D,uEAAuE;IACvE,YAAoB,OAAe,EAAE,OAAe,EAAE,UAAkB,EAAE,MAAc;QACtF,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,kCAAkC;IAC3B,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,OAAe;QAC1D,MAAM,UAAU,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACnG,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,OAAO,GAAG,UAAU,CAAC,CAAC;IAC5C,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,OAAe;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,SAAS;YACjB,OAAO,SAAS,CAAC;QACnB,MAAM,IAAI,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QAC7F,OAAO,IAAI,wBAAwB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACjE,CAAC;IAEe,YAAY,CAAC,WAAmB;QAC9C,IAAI,CAAC,cAAc,IAAI,WAAW,CAAC;QACnC,IAAI,CAAC,cAAc,IAAI,WAAW,CAAC;QACnC,KAAK,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;IACD,0CAA0C;IACnC,KAAK,KAA+B,OAAO,IAAI,wBAAwB,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3J,mCAAmC;IAC5B,aAAa,CAAC,KAAU;QAC7B,IAAI,KAAK,YAAY,wBAAwB,EAAE;YAC7C,OAAO,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC;mBACtE,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;SAC3E;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACD;;;;;OAKG;IACI,MAAM,CAAC,2BAA2B,CAAC,cAAsB,EAAE,cAAsB,EAAE,oBAA4B;QACpH,MAAM,EAAE,GAAG,cAAc,GAAG,cAAc,CAAC;QAC3C,MAAM,EAAE,GAAG,cAAc,GAAG,cAAc,CAAC;QAC3C,MAAM,EAAE,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;QACvD,OAAO,oBAAoB,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;CACF","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\nimport { Geometry } from \"../../Geometry\";\r\nimport { CubicEvaluator } from \"./CubicEvaluator\";\r\n/**\r\n * MX Cubic along arc.\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * Lx`\r\n * * m is (1/6RL)\r\n * * construction length L is nominal along the curve.\r\n * * x length Lx is along the axis, determined by two terms of the clothoid x series.\r\n * *\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n * @internal\r\n */\r\nexport class MXCubicAlongArcEvaluator extends CubicEvaluator {\r\n public nominalLength1: number;\r\n public nominalRadius1: number;\r\n\r\n /** Constructor is private. Caller responsible for cubicM validity. */\r\n private constructor(length1: number, radius1: number, axisLength: number, cubicM: number) {\r\n super(axisLength, cubicM);\r\n this.nominalLength1 = length1;\r\n this.nominalRadius1 = radius1;\r\n }\r\n\r\n /** Compute the cubic constant. */\r\n public static computeCubicM(length1: number, radius1: number): number | undefined {\r\n const axisLength = MXCubicAlongArcEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n return 1.0 / (6.0 * radius1 * axisLength);\r\n }\r\n\r\n public static create(length1: number, radius1: number): MXCubicAlongArcEvaluator | undefined {\r\n const m = this.computeCubicM(length1, radius1);\r\n if (m === undefined)\r\n return undefined;\r\n const xMax = MXCubicAlongArcEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n return new MXCubicAlongArcEvaluator(length1, radius1, xMax, m);\r\n }\r\n\r\n public override scaleInPlace(scaleFactor: number) {\r\n this.nominalLength1 *= scaleFactor;\r\n this.nominalRadius1 *= scaleFactor;\r\n super.scaleInPlace(scaleFactor);\r\n }\r\n /** return a deep copy of the evaluator */\r\n public clone(): MXCubicAlongArcEvaluator { return new MXCubicAlongArcEvaluator(this.nominalLength1, this.nominalRadius1, super._axisLength, this.cubicM); }\r\n /** Member by member matchup ... */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof MXCubicAlongArcEvaluator) {\r\n return Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1)\r\n && Geometry.isSameCoordinate(this.nominalRadius1, other.nominalRadius1);\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return a (fast but mediocre) approximation of spiral x position as function of approximate distance along the curve.\r\n * * This x-to-distance relation is not as precise as the CurvePrimitive method moveSignedDistanceFromFraction.\r\n * * It is supported here for users interested in replicating the Czech distance mapping rather than the more accurate CurvePrimitive measurements.\r\n * @param x distance along the x axis.\r\n */\r\n public static approximateDistanceAlongToX(nominalLength1: number, nominalRadius1: number, nominalDistanceAlong: number): number {\r\n const l2 = nominalLength1 * nominalLength1;\r\n const r2 = nominalRadius1 * nominalRadius1;\r\n const xx = nominalDistanceAlong * nominalDistanceAlong;\r\n return nominalDistanceAlong * (1.0 - xx * xx / (40.0 * r2 * l2));\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"MXCubicAlongArcSpiralEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/MXCubicAlongArcSpiralEvaluator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,wBAAyB,SAAQ,cAAc;IAI1D,uEAAuE;IACvE,YAAoB,OAAe,EAAE,OAAe,EAAE,UAAkB,EAAE,MAAc;QACtF,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,kCAAkC;IAC3B,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,OAAe;QAC1D,MAAM,UAAU,GAAG,wBAAwB,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACnG,OAAO,GAAG,GAAG,CA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G,cAAc,GAAG,cAAc,CAAC;QAC3C,MAAM,EAAE,GAAG,oBAAoB,GAAG,oBAAoB,CAAC;QACvD,OAAO,oBAAoB,GAAG,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;CACF","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\nimport { Geometry } from \"../../Geometry\";\r\nimport { CubicEvaluator } from \"./CubicEvaluator\";\r\n/**\r\n * MX Cubic along arc.\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * Lx`\r\n * * m is (1/6RL)\r\n * * construction length L is nominal along the curve.\r\n * * x length Lx is along the axis, determined by two terms of the clothoid x series.\r\n * *\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n * @internal\r\n */\r\nexport class MXCubicAlongArcEvaluator extends CubicEvaluator {\r\n public nominalLength1: number;\r\n public nominalRadius1: number;\r\n\r\n /** Constructor is private. Caller responsible for cubicM validity. */\r\n private constructor(length1: number, radius1: number, axisLength: number, cubicM: number) {\r\n super(axisLength, cubicM);\r\n this.nominalLength1 = length1;\r\n this.nominalRadius1 = radius1;\r\n }\r\n\r\n /** Compute the cubic constant. */\r\n public static computeCubicM(length1: number, radius1: number): number | undefined {\r\n const axisLength = MXCubicAlongArcEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n return 1.0 / (6.0 * radius1 * axisLength);\r\n }\r\n\r\n public static create(length1: number, radius1: number): MXCubicAlongArcEvaluator | undefined {\r\n const m = this.computeCubicM(length1, radius1);\r\n if (m === undefined)\r\n return undefined;\r\n const xMax = MXCubicAlongArcEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n return new MXCubicAlongArcEvaluator(length1, radius1, xMax, m);\r\n }\r\n\r\n public override scaleInPlace(scaleFactor: number) {\r\n this.nominalLength1 *= scaleFactor;\r\n this.nominalRadius1 *= scaleFactor;\r\n super.scaleInPlace(scaleFactor);\r\n }\r\n /** return a deep copy of the evaluator */\r\n public clone(): MXCubicAlongArcEvaluator { return new MXCubicAlongArcEvaluator(this.nominalLength1, this.nominalRadius1, this.axisLength, this.cubicM); }\r\n /** Member by member matchup ... */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof MXCubicAlongArcEvaluator) {\r\n return Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1)\r\n && Geometry.isSameCoordinate(this.nominalRadius1, other.nominalRadius1);\r\n }\r\n return false;\r\n }\r\n /**\r\n * Return a (fast but mediocre) approximation of spiral x position as function of approximate distance along the curve.\r\n * * This x-to-distance relation is not as precise as the CurvePrimitive method moveSignedDistanceFromFraction.\r\n * * It is supported here for users interested in replicating the Czech distance mapping rather than the more accurate CurvePrimitive measurements.\r\n * @param x distance along the x axis.\r\n */\r\n public static approximateDistanceAlongToX(nominalLength1: number, nominalRadius1: number, nominalDistanceAlong: number): number {\r\n const l2 = nominalLength1 * nominalLength1;\r\n const r2 = nominalRadius1 * nominalRadius1;\r\n const xx = nominalDistanceAlong * nominalDistanceAlong;\r\n return nominalDistanceAlong * (1.0 - xx * xx / (40.0 * r2 * l2));\r\n }\r\n}\r\n"]}
@@ -48,7 +48,7 @@ export class PolishCubicEvaluator extends CubicEvaluator {
48
48
  super.scaleInPlace(scaleFactor);
49
49
  }
50
50
  /** return a deep copy of the evaluator */
51
- clone() { return new PolishCubicEvaluator(this.nominalLength1, this.nominalRadius1, super._axisLength, this.cubicM); }
51
+ clone() { return new PolishCubicEvaluator(this.nominalLength1, this.nominalRadius1, this.axisLength, this.cubicM); }
52
52
  /** Member by member matchup ... */
53
53
  isAlmostEqual(other) {
54
54
  if (other instanceof PolishCubicEvaluator) {
@@ -1 +1 @@
1
- {"version":3,"file":"PolishCubicSpiralEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/PolishCubicSpiralEvaluator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAItD,uEAAuE;IACvE,YAAoB,OAAe,EAAE,OAAe,EAAE,UAAkB,EAAE,MAAc;QACtF,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,OAAe;QAC1D,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,OAAe;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,KAAK,SAAS;YACjB,OAAO,SAAS,CAAC;QACnB,MAAM,IAAI,GAAG,oBAAoB,CAAC,2BAA2B,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACzF,IAAI,IAAI,KAAK,SAAS;YACpB,OAAO,SAAS,CAAC;QACnB,OAAO,IAAI,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEe,YAAY,CAAC,WAAmB;QAC9C,IAAI,CAAC,cAAc,IA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esContent":["/*---------------------------------------------------------------------------------------------\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\nimport { Geometry } from \"../../Geometry\";\r\nimport { SimpleNewton } from \"../../numerics/Newton\";\r\nimport { CubicEvaluator } from \"./CubicEvaluator\";\r\n/**\r\n * Polish Cubic.\r\n * * Construction takes nominal length and end radius.\r\n * curve is is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * m is (1/6RL)\r\n * * Lx = x length is along the axis, determined by inversion of a distance series at nominal length\r\n * *\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n * @internal\r\n */\r\nexport class PolishCubicEvaluator extends CubicEvaluator {\r\n public nominalLength1: number;\r\n public nominalRadius1: number;\r\n\r\n /** Constructor is private. Caller responsible for cubicM validity. */\r\n private constructor(length1: number, radius1: number, axisLength: number, cubicM: number) {\r\n super(axisLength, cubicM);\r\n this.nominalLength1 = length1;\r\n this.nominalRadius1 = radius1;\r\n }\r\n\r\n /** Compute the czech cubic constant. */\r\n public static computeCubicM(length1: number, radius1: number): number {\r\n return 1.0 / (6.0 * length1 * radius1);\r\n }\r\n\r\n public static create(length1: number, radius1: number): PolishCubicEvaluator | undefined {\r\n const m = this.computeCubicM(length1, radius1);\r\n if (m === undefined)\r\n return undefined;\r\n const xMax = PolishCubicEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n if (xMax === undefined)\r\n return undefined;\r\n return new PolishCubicEvaluator(length1, radius1, xMax, m);\r\n }\r\n\r\n public override scaleInPlace(scaleFactor: number) {\r\n this.nominalLength1 *= scaleFactor;\r\n this.nominalRadius1 *= scaleFactor;\r\n super.scaleInPlace(scaleFactor);\r\n }\r\n /** return a deep copy of the evaluator */\r\n public clone(): PolishCubicEvaluator { return new PolishCubicEvaluator(this.nominalLength1, this.nominalRadius1, super._axisLength, this.cubicM); }\r\n /** Member by member matchup ... */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof PolishCubicEvaluator) {\r\n return Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1)\r\n && Geometry.isSameCoordinate(this.nominalRadius1, other.nominalRadius1);\r\n }\r\n return false;\r\n }\r\n\r\n /** Compute the coefficient of x^4 in the x-to-distance series expansion */\r\n public static computeX4SeriesCoefficient(length1: number, radius1: number): number {\r\n return 1.0 / (4.0 * length1 * length1 * radius1 * radius1);\r\n }\r\n /**\r\n * Evaluate a series approximation of distance along the true curve.\r\n * @param x distance along x axis\r\n * @param radius1 nominal end radius\r\n * @param length1 nominal length along curve\r\n * @returns\r\n */\r\n public static xToApproximateDistance(x: number, radius1: number, length1: number): number {\r\n // C31 * ( 1 + 1 / 10 * E31 - 1 / 72 * E31^2 + 1 / 208 * E31^3 - 5 / 2176 * E31^4 )\r\n const a4 = this.computeX4SeriesCoefficient(length1, radius1);\r\n const ax2 = a4 * x * x;\r\n const ax3 = ax2 * x;\r\n const ax4 = ax3 * x;\r\n const s0 = x * (1.0 + ax4 * (0.1 + ax4 * (-1.0 / 72.0 + ax4 * (1.0 / 208.0 - 5.0 * ax4 / 2176.0))));\r\n return s0;\r\n }\r\n\r\n /**\r\n * Evaluate the derivative of the x-to-distance series.\r\n * @param x distance along x axis\r\n * @param radius1 nominal end radius\r\n * @param length1 nominal length along curve\r\n * @returns\r\n */\r\n public static xToApproximateDistanceDerivative(x: number, radius1: number, length1: number): number {\r\n // C31 * ( 1 + 1 / 10 * E31 - 1 / 72 * E31^2 + 1 / 208 * E31^3 - 5 / 2176 * E31^4 )\r\n const a4 = this.computeX4SeriesCoefficient(length1, radius1);\r\n const ax2 = a4 * x * x;\r\n const ax3 = ax2 * x;\r\n const ax4 = ax3 * x;\r\n // derivative notes ..\r\n // take away leading x -- this reduces each power by 1\r\n // multiply each coefficient by its original power:\r\n // 0.1==>0.5\r\n // 1/72==> 9/72 = 1/8\r\n // 1/208==>13/208=1/16\r\n // 1/2176==>17/2176= 1/128\r\n const ds = (1.0 + ax4 * (0.5 + ax4 * (-1.0 / 8.0 + ax4 * (1.0 / 16.0 - 5.0 * ax4 / 128.0))));\r\n return ds;\r\n }\r\n\r\n /** Invert the xToApproximateDistance function. */\r\n public static approximateDistanceAlongToX(s: number, radius1: number, length1: number): number | undefined {\r\n const root = SimpleNewton.runNewton1D(s,\r\n (x: number) => (this.xToApproximateDistance(x, radius1, length1) - s),\r\n (x: number) => this.xToApproximateDistanceDerivative(x, radius1, length1));\r\n return root;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PolishCubicSpiralEvaluator.js","sourceRoot":"","sources":["../../../../src/curve/spiral/PolishCubicSpiralEvaluator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAItD,uEAAuE;IACvE,YAAoB,OAAe,EAAE,OAAe,EAAE,UAAkB,EAAE,MAAc;QACtF,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;IAChC,CAAC;IAED,wCAAwC;IACjC,MAAM,CAAC,aAAa,CAAC,OAAe,EAAE,OAAe;QAC1D,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,OAAe;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;Q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EAAE,OAAe,EAAE,OAAe;QACnF,MAAM,IAAI,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,EACrC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,EACrE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC;IACd,CAAC;CACF","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\nimport { Geometry } from \"../../Geometry\";\r\nimport { SimpleNewton } from \"../../numerics/Newton\";\r\nimport { CubicEvaluator } from \"./CubicEvaluator\";\r\n/**\r\n * Polish Cubic.\r\n * * Construction takes nominal length and end radius.\r\n * curve is is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * m is (1/6RL)\r\n * * Lx = x length is along the axis, determined by inversion of a distance series at nominal length\r\n * *\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n * @internal\r\n */\r\nexport class PolishCubicEvaluator extends CubicEvaluator {\r\n public nominalLength1: number;\r\n public nominalRadius1: number;\r\n\r\n /** Constructor is private. Caller responsible for cubicM validity. */\r\n private constructor(length1: number, radius1: number, axisLength: number, cubicM: number) {\r\n super(axisLength, cubicM);\r\n this.nominalLength1 = length1;\r\n this.nominalRadius1 = radius1;\r\n }\r\n\r\n /** Compute the czech cubic constant. */\r\n public static computeCubicM(length1: number, radius1: number): number {\r\n return 1.0 / (6.0 * length1 * radius1);\r\n }\r\n\r\n public static create(length1: number, radius1: number): PolishCubicEvaluator | undefined {\r\n const m = this.computeCubicM(length1, radius1);\r\n if (m === undefined)\r\n return undefined;\r\n const xMax = PolishCubicEvaluator.approximateDistanceAlongToX(length1, radius1, length1);\r\n if (xMax === undefined)\r\n return undefined;\r\n return new PolishCubicEvaluator(length1, radius1, xMax, m);\r\n }\r\n\r\n public override scaleInPlace(scaleFactor: number) {\r\n this.nominalLength1 *= scaleFactor;\r\n this.nominalRadius1 *= scaleFactor;\r\n super.scaleInPlace(scaleFactor);\r\n }\r\n /** return a deep copy of the evaluator */\r\n public clone(): PolishCubicEvaluator { return new PolishCubicEvaluator(this.nominalLength1, this.nominalRadius1, this.axisLength, this.cubicM); }\r\n /** Member by member matchup ... */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof PolishCubicEvaluator) {\r\n return Geometry.isSameCoordinate(this.nominalLength1, other.nominalLength1)\r\n && Geometry.isSameCoordinate(this.nominalRadius1, other.nominalRadius1);\r\n }\r\n return false;\r\n }\r\n\r\n /** Compute the coefficient of x^4 in the x-to-distance series expansion */\r\n public static computeX4SeriesCoefficient(length1: number, radius1: number): number {\r\n return 1.0 / (4.0 * length1 * length1 * radius1 * radius1);\r\n }\r\n /**\r\n * Evaluate a series approximation of distance along the true curve.\r\n * @param x distance along x axis\r\n * @param radius1 nominal end radius\r\n * @param length1 nominal length along curve\r\n * @returns\r\n */\r\n public static xToApproximateDistance(x: number, radius1: number, length1: number): number {\r\n // C31 * ( 1 + 1 / 10 * E31 - 1 / 72 * E31^2 + 1 / 208 * E31^3 - 5 / 2176 * E31^4 )\r\n const a4 = this.computeX4SeriesCoefficient(length1, radius1);\r\n const ax2 = a4 * x * x;\r\n const ax3 = ax2 * x;\r\n const ax4 = ax3 * x;\r\n const s0 = x * (1.0 + ax4 * (0.1 + ax4 * (-1.0 / 72.0 + ax4 * (1.0 / 208.0 - 5.0 * ax4 / 2176.0))));\r\n return s0;\r\n }\r\n\r\n /**\r\n * Evaluate the derivative of the x-to-distance series.\r\n * @param x distance along x axis\r\n * @param radius1 nominal end radius\r\n * @param length1 nominal length along curve\r\n * @returns\r\n */\r\n public static xToApproximateDistanceDerivative(x: number, radius1: number, length1: number): number {\r\n // C31 * ( 1 + 1 / 10 * E31 - 1 / 72 * E31^2 + 1 / 208 * E31^3 - 5 / 2176 * E31^4 )\r\n const a4 = this.computeX4SeriesCoefficient(length1, radius1);\r\n const ax2 = a4 * x * x;\r\n const ax3 = ax2 * x;\r\n const ax4 = ax3 * x;\r\n // derivative notes ..\r\n // take away leading x -- this reduces each power by 1\r\n // multiply each coefficient by its original power:\r\n // 0.1==>0.5\r\n // 1/72==> 9/72 = 1/8\r\n // 1/208==>13/208=1/16\r\n // 1/2176==>17/2176= 1/128\r\n const ds = (1.0 + ax4 * (0.5 + ax4 * (-1.0 / 8.0 + ax4 * (1.0 / 16.0 - 5.0 * ax4 / 128.0))));\r\n return ds;\r\n }\r\n\r\n /** Invert the xToApproximateDistance function. */\r\n public static approximateDistanceAlongToX(s: number, radius1: number, length1: number): number | undefined {\r\n const root = SimpleNewton.runNewton1D(s,\r\n (x: number) => (this.xToApproximateDistance(x, radius1, length1) - s),\r\n (x: number) => this.xToApproximateDistanceDerivative(x, radius1, length1));\r\n return root;\r\n }\r\n}\r\n"]}