@itwin/core-geometry 3.2.0-dev.1 → 3.2.0-dev.6

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 (197) hide show
  1. package/lib/cjs/bspline/AkimaCurve3d.d.ts +2 -8
  2. package/lib/cjs/bspline/AkimaCurve3d.d.ts.map +1 -1
  3. package/lib/cjs/bspline/AkimaCurve3d.js +2 -17
  4. package/lib/cjs/bspline/AkimaCurve3d.js.map +1 -1
  5. package/lib/cjs/bspline/BSpline1dNd.d.ts +11 -6
  6. package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
  7. package/lib/cjs/bspline/BSpline1dNd.js +64 -6
  8. package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
  9. package/lib/cjs/bspline/BSplineCurve.d.ts +10 -14
  10. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  11. package/lib/cjs/bspline/BSplineCurve.js +40 -32
  12. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  13. package/lib/cjs/bspline/BSplineCurve3dH.d.ts +0 -2
  14. package/lib/cjs/bspline/BSplineCurve3dH.d.ts.map +1 -1
  15. package/lib/cjs/bspline/BSplineCurve3dH.js +0 -6
  16. package/lib/cjs/bspline/BSplineCurve3dH.js.map +1 -1
  17. package/lib/cjs/bspline/BSplineCurveOps.d.ts.map +1 -1
  18. package/lib/cjs/bspline/BSplineCurveOps.js +4 -6
  19. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  20. package/lib/cjs/bspline/Bezier1dNd.d.ts +8 -11
  21. package/lib/cjs/bspline/Bezier1dNd.d.ts.map +1 -1
  22. package/lib/cjs/bspline/Bezier1dNd.js +13 -14
  23. package/lib/cjs/bspline/Bezier1dNd.js.map +1 -1
  24. package/lib/cjs/bspline/BezierCurve3d.d.ts +0 -6
  25. package/lib/cjs/bspline/BezierCurve3d.d.ts.map +1 -1
  26. package/lib/cjs/bspline/BezierCurve3d.js +0 -14
  27. package/lib/cjs/bspline/BezierCurve3d.js.map +1 -1
  28. package/lib/cjs/bspline/BezierCurve3dH.d.ts +0 -4
  29. package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
  30. package/lib/cjs/bspline/BezierCurve3dH.js +0 -8
  31. package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
  32. package/lib/cjs/bspline/BezierCurveBase.d.ts +9 -0
  33. package/lib/cjs/bspline/BezierCurveBase.d.ts.map +1 -1
  34. package/lib/cjs/bspline/BezierCurveBase.js +15 -0
  35. package/lib/cjs/bspline/BezierCurveBase.js.map +1 -1
  36. package/lib/cjs/bspline/InterpolationCurve3d.d.ts +2 -8
  37. package/lib/cjs/bspline/InterpolationCurve3d.d.ts.map +1 -1
  38. package/lib/cjs/bspline/InterpolationCurve3d.js +2 -17
  39. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  40. package/lib/cjs/bspline/KnotVector.d.ts +24 -9
  41. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  42. package/lib/cjs/bspline/KnotVector.js +86 -26
  43. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  44. package/lib/cjs/curve/Arc3d.d.ts +2 -2
  45. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  46. package/lib/cjs/curve/Arc3d.js +1 -2
  47. package/lib/cjs/curve/Arc3d.js.map +1 -1
  48. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +3 -3
  49. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  50. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +3 -7
  51. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  52. package/lib/cjs/curve/CurveCollection.d.ts +2 -2
  53. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  54. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  55. package/lib/cjs/curve/CurveCurveIntersectXY.js +2 -2
  56. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
  57. package/lib/cjs/curve/CurvePrimitive.d.ts +4 -0
  58. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  59. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  60. package/lib/cjs/curve/LineSegment3d.d.ts +2 -2
  61. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  62. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  63. package/lib/cjs/curve/LineString3d.d.ts +4 -4
  64. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  65. package/lib/cjs/curve/LineString3d.js +52 -22
  66. package/lib/cjs/curve/LineString3d.js.map +1 -1
  67. package/lib/cjs/curve/ProxyCurve.d.ts +6 -2
  68. package/lib/cjs/curve/ProxyCurve.d.ts.map +1 -1
  69. package/lib/cjs/curve/ProxyCurve.js +11 -2
  70. package/lib/cjs/curve/ProxyCurve.js.map +1 -1
  71. package/lib/cjs/curve/Query/CurveSplitContext.d.ts.map +1 -1
  72. package/lib/cjs/curve/Query/CurveSplitContext.js +1 -3
  73. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  74. package/lib/cjs/curve/StrokeOptions.js +2 -1
  75. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  76. package/lib/cjs/curve/internalContexts/CloneCurvesContext.js.map +1 -1
  77. package/lib/cjs/curve/internalContexts/CloneWithExpandedLineStrings.d.ts +2 -2
  78. package/lib/cjs/curve/internalContexts/CloneWithExpandedLineStrings.d.ts.map +1 -1
  79. package/lib/cjs/curve/internalContexts/CloneWithExpandedLineStrings.js.map +1 -1
  80. package/lib/cjs/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  81. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts +0 -4
  82. package/lib/cjs/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  83. package/lib/cjs/curve/spiral/DirectSpiral3d.js +0 -15
  84. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  85. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts +0 -4
  86. package/lib/cjs/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  87. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +0 -15
  88. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  89. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts +8 -0
  90. package/lib/cjs/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  91. package/lib/cjs/curve/spiral/TransitionSpiral3d.js +15 -0
  92. package/lib/cjs/curve/spiral/TransitionSpiral3d.js.map +1 -1
  93. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  94. package/lib/cjs/serialization/IModelJsonSchema.d.ts +4 -0
  95. package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
  96. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  97. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  98. package/lib/cjs/solid/SweepContour.js.map +1 -1
  99. package/lib/esm/bspline/AkimaCurve3d.d.ts +2 -8
  100. package/lib/esm/bspline/AkimaCurve3d.d.ts.map +1 -1
  101. package/lib/esm/bspline/AkimaCurve3d.js +2 -17
  102. package/lib/esm/bspline/AkimaCurve3d.js.map +1 -1
  103. package/lib/esm/bspline/BSpline1dNd.d.ts +11 -6
  104. package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
  105. package/lib/esm/bspline/BSpline1dNd.js +65 -7
  106. package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
  107. package/lib/esm/bspline/BSplineCurve.d.ts +10 -14
  108. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  109. package/lib/esm/bspline/BSplineCurve.js +40 -32
  110. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  111. package/lib/esm/bspline/BSplineCurve3dH.d.ts +0 -2
  112. package/lib/esm/bspline/BSplineCurve3dH.d.ts.map +1 -1
  113. package/lib/esm/bspline/BSplineCurve3dH.js +0 -6
  114. package/lib/esm/bspline/BSplineCurve3dH.js.map +1 -1
  115. package/lib/esm/bspline/BSplineCurveOps.d.ts.map +1 -1
  116. package/lib/esm/bspline/BSplineCurveOps.js +4 -6
  117. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  118. package/lib/esm/bspline/Bezier1dNd.d.ts +8 -11
  119. package/lib/esm/bspline/Bezier1dNd.d.ts.map +1 -1
  120. package/lib/esm/bspline/Bezier1dNd.js +13 -14
  121. package/lib/esm/bspline/Bezier1dNd.js.map +1 -1
  122. package/lib/esm/bspline/BezierCurve3d.d.ts +0 -6
  123. package/lib/esm/bspline/BezierCurve3d.d.ts.map +1 -1
  124. package/lib/esm/bspline/BezierCurve3d.js +0 -14
  125. package/lib/esm/bspline/BezierCurve3d.js.map +1 -1
  126. package/lib/esm/bspline/BezierCurve3dH.d.ts +0 -4
  127. package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
  128. package/lib/esm/bspline/BezierCurve3dH.js +0 -8
  129. package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
  130. package/lib/esm/bspline/BezierCurveBase.d.ts +9 -0
  131. package/lib/esm/bspline/BezierCurveBase.d.ts.map +1 -1
  132. package/lib/esm/bspline/BezierCurveBase.js +15 -0
  133. package/lib/esm/bspline/BezierCurveBase.js.map +1 -1
  134. package/lib/esm/bspline/InterpolationCurve3d.d.ts +2 -8
  135. package/lib/esm/bspline/InterpolationCurve3d.d.ts.map +1 -1
  136. package/lib/esm/bspline/InterpolationCurve3d.js +2 -17
  137. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  138. package/lib/esm/bspline/KnotVector.d.ts +24 -9
  139. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  140. package/lib/esm/bspline/KnotVector.js +86 -26
  141. package/lib/esm/bspline/KnotVector.js.map +1 -1
  142. package/lib/esm/curve/Arc3d.d.ts +2 -2
  143. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  144. package/lib/esm/curve/Arc3d.js +1 -2
  145. package/lib/esm/curve/Arc3d.js.map +1 -1
  146. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +3 -3
  147. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  148. package/lib/esm/curve/CurveChainWithDistanceIndex.js +3 -7
  149. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  150. package/lib/esm/curve/CurveCollection.d.ts +2 -2
  151. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  152. package/lib/esm/curve/CurveCollection.js.map +1 -1
  153. package/lib/esm/curve/CurveCurveIntersectXY.js +2 -2
  154. package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
  155. package/lib/esm/curve/CurvePrimitive.d.ts +4 -0
  156. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  157. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  158. package/lib/esm/curve/LineSegment3d.d.ts +2 -2
  159. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  160. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  161. package/lib/esm/curve/LineString3d.d.ts +4 -4
  162. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  163. package/lib/esm/curve/LineString3d.js +52 -22
  164. package/lib/esm/curve/LineString3d.js.map +1 -1
  165. package/lib/esm/curve/ProxyCurve.d.ts +6 -2
  166. package/lib/esm/curve/ProxyCurve.d.ts.map +1 -1
  167. package/lib/esm/curve/ProxyCurve.js +11 -2
  168. package/lib/esm/curve/ProxyCurve.js.map +1 -1
  169. package/lib/esm/curve/Query/CurveSplitContext.d.ts.map +1 -1
  170. package/lib/esm/curve/Query/CurveSplitContext.js +1 -3
  171. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  172. package/lib/esm/curve/StrokeOptions.js +2 -1
  173. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  174. package/lib/esm/curve/internalContexts/CloneCurvesContext.js.map +1 -1
  175. package/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.d.ts +2 -2
  176. package/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.d.ts.map +1 -1
  177. package/lib/esm/curve/internalContexts/CloneWithExpandedLineStrings.js.map +1 -1
  178. package/lib/esm/curve/internalContexts/PolygonOffsetContext.js.map +1 -1
  179. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts +0 -4
  180. package/lib/esm/curve/spiral/DirectSpiral3d.d.ts.map +1 -1
  181. package/lib/esm/curve/spiral/DirectSpiral3d.js +0 -15
  182. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  183. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts +0 -4
  184. package/lib/esm/curve/spiral/IntegratedSpiral3d.d.ts.map +1 -1
  185. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +0 -15
  186. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  187. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts +8 -0
  188. package/lib/esm/curve/spiral/TransitionSpiral3d.d.ts.map +1 -1
  189. package/lib/esm/curve/spiral/TransitionSpiral3d.js +15 -0
  190. package/lib/esm/curve/spiral/TransitionSpiral3d.js.map +1 -1
  191. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  192. package/lib/esm/serialization/IModelJsonSchema.d.ts +4 -0
  193. package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
  194. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  195. package/lib/esm/solid/RuledSweep.js.map +1 -1
  196. package/lib/esm/solid/SweepContour.js.map +1 -1
  197. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"RuledSweep.js","sourceRoot":"","sources":["../../../src/solid/RuledSweep.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sFAAmF;AACnF,8DAAuE;AACvE,4DAAyD;AAEzD,0CAAuC;AAIvC,qDAAkD;AAClD,iDAA8C;AAQ9C;;;;GAIG;AACH,M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AC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;CAEF;AApLD,gCAoLC","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 Solid\r\n */\r\n\r\nimport { ConstructCurveBetweenCurves } from \"../curve/ConstructCurveBetweenCurves\";\r\nimport { CurveChain, CurveCollection } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { SolidPrimitive } from \"./SolidPrimitive\";\r\nimport { SweepContour } from \"./SweepContour\";\r\n\r\n/**\r\n * * type for a function argument taking 2 curves and returning another curve or failing with undefined.\r\n * * This is used (for instance) by `RuleSweep.mutatePartners`\r\n * @public\r\n */\r\nexport type CurvePrimitiveMutator = (primitiveA: CurvePrimitive, primitiveB: CurvePrimitive) => CurvePrimitive | undefined;\r\n/**\r\n * A ruled sweep (surface) is a collection of 2 or more contours.\r\n * * All contours must have identical number and type of geometry. (paths, loops, parity regions, lines, arcs, other curves)\r\n * @public\r\n */\r\nexport class RuledSweep extends SolidPrimitive {\r\n /** String name for schema properties */\r\n public readonly solidPrimitiveType = \"ruledSweep\";\r\n\r\n private _contours: SweepContour[];\r\n private constructor(contours: SweepContour[], capped: boolean) {\r\n super(capped);\r\n this._contours = contours;\r\n }\r\n /**\r\n * Create a ruled sweep from an array of contours.\r\n * * the contours are CAPTURED (not cloned)\r\n */\r\n public static create(contours: CurveCollection[], capped: boolean): RuledSweep | undefined {\r\n const sweepContours = [];\r\n for (const contour of contours) {\r\n const sweepable = SweepContour.createForLinearSweep(contour);\r\n if (sweepable === undefined) return undefined;\r\n sweepContours.push(sweepable);\r\n }\r\n return new RuledSweep(sweepContours, capped);\r\n }\r\n /** Return a reference to the array of SweepContour. */\r\n public sweepContoursRef(): SweepContour[] { return this._contours; }\r\n /** Return clones of all the sweep contours\r\n * * See also cloneContours, which returns the spatial contours without their local coordinate system definitions)\r\n */\r\n public cloneSweepContours(): SweepContour[] {\r\n const result = [];\r\n for (const sweepable of this._contours) {\r\n result.push(sweepable.clone());\r\n }\r\n return result;\r\n }\r\n /** Return clones of all the contours\r\n * * See also cloneContours, which returns the contours in their local coordinate systems\r\n */\r\n public cloneContours(): CurveCollection[] {\r\n const result = [];\r\n for (const sweepable of this._contours) {\r\n result.push(sweepable.curves.clone() as CurveCollection);\r\n }\r\n return result;\r\n }\r\n /** Return a deep clone */\r\n public clone(): RuledSweep {\r\n return new RuledSweep(this.cloneSweepContours(), this.capped);\r\n }\r\n /** Transform all contours in place. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (transform.matrix.isSingular())\r\n return false;\r\n for (const contour of this._contours) {\r\n contour.tryTransformInPlace(transform);\r\n }\r\n return true;\r\n }\r\n /** Return a cloned transform. */\r\n public cloneTransformed(transform: Transform): RuledSweep {\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Return a coordinate frame (right handed unit vectors)\r\n * * origin on base contour\r\n * * x, y directions from base contour.\r\n * * z direction perpendicular\r\n */\r\n public getConstructiveFrame(): Transform | undefined {\r\n if (this._contours.length === 0) return undefined;\r\n return this._contours[0].localToWorld.cloneRigid();\r\n }\r\n /** Test if `other` is an instance of a `RuledSweep` */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof RuledSweep; }\r\n /** test same contour geometry and capping. */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (other instanceof RuledSweep) {\r\n if (this.capped !== other.capped) return false;\r\n if (this._contours.length !== other._contours.length) return false;\r\n for (let i = 0; i < this._contours.length; i++) {\r\n if (!this._contours[i].isAlmostEqual(other._contours[i]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** dispatch to strongly typed `handler.handleRuledSweep(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleRuledSweep(this);\r\n }\r\n /**\r\n * Return the section curves at a fraction of the sweep\r\n * @param vFraction fractional position along the sweep direction\r\n */\r\n public constantVSection(vFraction: number): CurveCollection | undefined {\r\n const numSection = this._contours.length;\r\n if (numSection < 2)\r\n return undefined;\r\n const q = vFraction * numSection;\r\n let section0 = 0;\r\n if (vFraction >= 1.0)\r\n section0 = numSection - 1;\r\n else\r\n section0 = Math.floor(q);\r\n if (section0 + 1 >= numSection)\r\n section0 = numSection - 2;\r\n const section1 = section0 + 1;\r\n const localFraction = Geometry.clampToStartEnd(q - section0, 0, 1);\r\n return RuledSweep.mutatePartners(this._contours[section0].curves, this._contours[section1].curves,\r\n (primitive0: CurvePrimitive, primitive1: CurvePrimitive): CurvePrimitive | undefined => {\r\n const newPrimitive = ConstructCurveBetweenCurves.interpolateBetween(primitive0, localFraction, primitive1);\r\n if (newPrimitive instanceof CurvePrimitive) return newPrimitive;\r\n return undefined;\r\n });\r\n }\r\n /** Pass each contour to `extendRange` */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n for (const contour of this._contours)\r\n contour.curves.extendRange(rangeToExtend, transform);\r\n }\r\n\r\n /** Construct a CurveCollection with the same structure as collectionA and collectionB, with primitives constructed by the caller-supplied primitiveMutator function.\r\n * @returns Returns undefined if there is any type mismatch between the two collections.\r\n */\r\n public static mutatePartners(collectionA: CurveCollection, collectionB: CurveCollection, primitiveMutator: CurvePrimitiveMutator): CurveCollection | undefined {\r\n if (!collectionA.isSameGeometryClass(collectionB))\r\n return undefined;\r\n if (collectionA instanceof CurveChain && collectionB instanceof CurveChain) {\r\n const chainA = collectionA;\r\n const chainB = collectionB;\r\n const chainC = chainA.cloneEmptyPeer() as CurveChain;\r\n const childrenA = chainA.children;\r\n const childrenB = chainB.children;\r\n if (childrenA.length !== childrenB.length)\r\n return undefined;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n const newChild = primitiveMutator(childrenA[i], childrenB[i]);\r\n if (!newChild)\r\n return undefined;\r\n chainC.children.push(newChild);\r\n }\r\n return chainC;\r\n } else if (collectionA instanceof CurveCollection && collectionB instanceof CurveCollection) {\r\n const collectionC = collectionA.cloneEmptyPeer();\r\n const childrenA = collectionA.children;\r\n const childrenB = collectionB.children;\r\n const childrenC = collectionC.children;\r\n if (childrenA === undefined || childrenB === undefined || childrenC === undefined || childrenA.length !== childrenB.length)\r\n return undefined;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n const childA = childrenA[i];\r\n const childB = childrenB[i];\r\n if (childA instanceof CurvePrimitive && childB instanceof CurvePrimitive) {\r\n const newPrimitive = primitiveMutator(childA, childB);\r\n if (!newPrimitive)\r\n return undefined;\r\n childrenC.push(newPrimitive);\r\n } else if (childA instanceof CurveCollection && childB instanceof CurveCollection) {\r\n const newChild = this.mutatePartners(childA, childB, primitiveMutator);\r\n if (!newChild)\r\n return undefined;\r\n if (newChild instanceof CurveCollection)\r\n childrenC.push(newChild);\r\n }\r\n }\r\n return collectionC;\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return true if this is a closed volume, as observed by\r\n * * cap flag\r\n * identical first and last contours.\r\n */\r\n public get isClosedVolume(): boolean {\r\n const n = this._contours.length;\r\n return n > 1 && (this.capped || this._contours[0].isAlmostEqual(this._contours[n - 1]));\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"RuledSweep.js","sourceRoot":"","sources":["../../../src/solid/RuledSweep.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sFAAmF;AACnF,8DAA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AAI,CAAC,SAAS,CAAC,MAAM,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;CAEF;AApLD,gCAoLC","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 Solid\r\n */\r\n\r\nimport { ConstructCurveBetweenCurves } from \"../curve/ConstructCurveBetweenCurves\";\r\nimport { CurveChain, CurveCollection } from \"../curve/CurveCollection\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { SolidPrimitive } from \"./SolidPrimitive\";\r\nimport { SweepContour } from \"./SweepContour\";\r\n\r\n/**\r\n * * type for a function argument taking 2 curves and returning another curve or failing with undefined.\r\n * * This is used (for instance) by `RuleSweep.mutatePartners`\r\n * @public\r\n */\r\nexport type CurvePrimitiveMutator = (primitiveA: CurvePrimitive, primitiveB: CurvePrimitive) => CurvePrimitive | undefined;\r\n/**\r\n * A ruled sweep (surface) is a collection of 2 or more contours.\r\n * * All contours must have identical number and type of geometry. (paths, loops, parity regions, lines, arcs, other curves)\r\n * @public\r\n */\r\nexport class RuledSweep extends SolidPrimitive {\r\n /** String name for schema properties */\r\n public readonly solidPrimitiveType = \"ruledSweep\";\r\n\r\n private _contours: SweepContour[];\r\n private constructor(contours: SweepContour[], capped: boolean) {\r\n super(capped);\r\n this._contours = contours;\r\n }\r\n /**\r\n * Create a ruled sweep from an array of contours.\r\n * * the contours are CAPTURED (not cloned)\r\n */\r\n public static create(contours: CurveCollection[], capped: boolean): RuledSweep | undefined {\r\n const sweepContours = [];\r\n for (const contour of contours) {\r\n const sweepable = SweepContour.createForLinearSweep(contour);\r\n if (sweepable === undefined) return undefined;\r\n sweepContours.push(sweepable);\r\n }\r\n return new RuledSweep(sweepContours, capped);\r\n }\r\n /** Return a reference to the array of SweepContour. */\r\n public sweepContoursRef(): SweepContour[] { return this._contours; }\r\n /** Return clones of all the sweep contours\r\n * * See also cloneContours, which returns the spatial contours without their local coordinate system definitions)\r\n */\r\n public cloneSweepContours(): SweepContour[] {\r\n const result = [];\r\n for (const sweepable of this._contours) {\r\n result.push(sweepable.clone());\r\n }\r\n return result;\r\n }\r\n /** Return clones of all the contours\r\n * * See also cloneContours, which returns the contours in their local coordinate systems\r\n */\r\n public cloneContours(): CurveCollection[] {\r\n const result = [];\r\n for (const sweepable of this._contours) {\r\n result.push(sweepable.curves.clone());\r\n }\r\n return result;\r\n }\r\n /** Return a deep clone */\r\n public clone(): RuledSweep {\r\n return new RuledSweep(this.cloneSweepContours(), this.capped);\r\n }\r\n /** Transform all contours in place. */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (transform.matrix.isSingular())\r\n return false;\r\n for (const contour of this._contours) {\r\n contour.tryTransformInPlace(transform);\r\n }\r\n return true;\r\n }\r\n /** Return a cloned transform. */\r\n public cloneTransformed(transform: Transform): RuledSweep {\r\n const result = this.clone();\r\n result.tryTransformInPlace(transform);\r\n return result;\r\n }\r\n /** Return a coordinate frame (right handed unit vectors)\r\n * * origin on base contour\r\n * * x, y directions from base contour.\r\n * * z direction perpendicular\r\n */\r\n public getConstructiveFrame(): Transform | undefined {\r\n if (this._contours.length === 0) return undefined;\r\n return this._contours[0].localToWorld.cloneRigid();\r\n }\r\n /** Test if `other` is an instance of a `RuledSweep` */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof RuledSweep; }\r\n /** test same contour geometry and capping. */\r\n public override isAlmostEqual(other: GeometryQuery): boolean {\r\n if (other instanceof RuledSweep) {\r\n if (this.capped !== other.capped) return false;\r\n if (this._contours.length !== other._contours.length) return false;\r\n for (let i = 0; i < this._contours.length; i++) {\r\n if (!this._contours[i].isAlmostEqual(other._contours[i]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n /** dispatch to strongly typed `handler.handleRuledSweep(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleRuledSweep(this);\r\n }\r\n /**\r\n * Return the section curves at a fraction of the sweep\r\n * @param vFraction fractional position along the sweep direction\r\n */\r\n public constantVSection(vFraction: number): CurveCollection | undefined {\r\n const numSection = this._contours.length;\r\n if (numSection < 2)\r\n return undefined;\r\n const q = vFraction * numSection;\r\n let section0 = 0;\r\n if (vFraction >= 1.0)\r\n section0 = numSection - 1;\r\n else\r\n section0 = Math.floor(q);\r\n if (section0 + 1 >= numSection)\r\n section0 = numSection - 2;\r\n const section1 = section0 + 1;\r\n const localFraction = Geometry.clampToStartEnd(q - section0, 0, 1);\r\n return RuledSweep.mutatePartners(this._contours[section0].curves, this._contours[section1].curves,\r\n (primitive0: CurvePrimitive, primitive1: CurvePrimitive): CurvePrimitive | undefined => {\r\n const newPrimitive = ConstructCurveBetweenCurves.interpolateBetween(primitive0, localFraction, primitive1);\r\n if (newPrimitive instanceof CurvePrimitive) return newPrimitive;\r\n return undefined;\r\n });\r\n }\r\n /** Pass each contour to `extendRange` */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n for (const contour of this._contours)\r\n contour.curves.extendRange(rangeToExtend, transform);\r\n }\r\n\r\n /** Construct a CurveCollection with the same structure as collectionA and collectionB, with primitives constructed by the caller-supplied primitiveMutator function.\r\n * @returns Returns undefined if there is any type mismatch between the two collections.\r\n */\r\n public static mutatePartners(collectionA: CurveCollection, collectionB: CurveCollection, primitiveMutator: CurvePrimitiveMutator): CurveCollection | undefined {\r\n if (!collectionA.isSameGeometryClass(collectionB))\r\n return undefined;\r\n if (collectionA instanceof CurveChain && collectionB instanceof CurveChain) {\r\n const chainA = collectionA;\r\n const chainB = collectionB;\r\n const chainC = chainA.cloneEmptyPeer() as CurveChain;\r\n const childrenA = chainA.children;\r\n const childrenB = chainB.children;\r\n if (childrenA.length !== childrenB.length)\r\n return undefined;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n const newChild = primitiveMutator(childrenA[i], childrenB[i]);\r\n if (!newChild)\r\n return undefined;\r\n chainC.children.push(newChild);\r\n }\r\n return chainC;\r\n } else if (collectionA instanceof CurveCollection && collectionB instanceof CurveCollection) {\r\n const collectionC = collectionA.cloneEmptyPeer();\r\n const childrenA = collectionA.children;\r\n const childrenB = collectionB.children;\r\n const childrenC = collectionC.children;\r\n if (childrenA === undefined || childrenB === undefined || childrenC === undefined || childrenA.length !== childrenB.length)\r\n return undefined;\r\n for (let i = 0; i < childrenA.length; i++) {\r\n const childA = childrenA[i];\r\n const childB = childrenB[i];\r\n if (childA instanceof CurvePrimitive && childB instanceof CurvePrimitive) {\r\n const newPrimitive = primitiveMutator(childA, childB);\r\n if (!newPrimitive)\r\n return undefined;\r\n childrenC.push(newPrimitive);\r\n } else if (childA instanceof CurveCollection && childB instanceof CurveCollection) {\r\n const newChild = this.mutatePartners(childA, childB, primitiveMutator);\r\n if (!newChild)\r\n return undefined;\r\n if (newChild instanceof CurveCollection)\r\n childrenC.push(newChild);\r\n }\r\n }\r\n return collectionC;\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return true if this is a closed volume, as observed by\r\n * * cap flag\r\n * identical first and last contours.\r\n */\r\n public get isClosedVolume(): boolean {\r\n const n = this._contours.length;\r\n return n > 1 && (this.capped || this._contours[0].isAlmostEqual(this._contours[n - 1]));\r\n }\r\n\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SweepContour.js","sourceRoot":"","sources":["../../../src/sol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9B;YACD,OAAO,MAAM,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA9OD,oCA8OC","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 Solid\r\n */\r\n\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { AnyCurve } from \"../curve/CurveChain\";\r\nimport { CurveCollection } from \"../curve/CurveCollection\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\n\r\n/**\r\n * Sweepable contour with Transform for local to world interaction.\r\n * * The surface/solid classes `LinearSweep`, `RotationalSweep`, `RuledSweep` use this for their swept contours.\r\n * @public\r\n */\r\nexport class SweepContour {\r\n /** The underlying curve collection, in its world coordinates position. */\r\n public curves: CurveCollection;\r\n /** coordinate frame that in which the curves are all in the xy plane. */\r\n public localToWorld: Transform;\r\n /** Axis used only in rotational case. */\r\n public axis: Ray3d | undefined;\r\n\r\n private constructor(contour: CurveCollection, map: Transform, axis: Ray3d | undefined) {\r\n this.curves = contour;\r\n this.localToWorld = map;\r\n this.axis = axis;\r\n }\r\n /** Create for linear sweep.\r\n * * The optional default normal may be useful for guiding coordinate frame setup.\r\n * * the contour is CAPTURED.\r\n */\r\n public static createForLinearSweep(contour: CurveCollection, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, contour);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, undefined);\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create for linear sweep.\r\n * * The optional default normal may be useful for guiding coordinate frame setup.\r\n * * the points are captured into linestrings and Loops as needed.\r\n */\r\n public static createForPolygon(points: MultiLineStringDataVariant, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, points);\r\n if (localToWorld) {\r\n if (defaultNormal !== undefined) {\r\n if (localToWorld.matrix.dotColumnZ(defaultNormal))\r\n localToWorld.matrix.scaleColumnsInPlace(1.0, -1.0, -1.0);\r\n }\r\n const linestrings = LineString3d.createArrayOfLineString3d(points);\r\n const loops = [];\r\n for (const ls of linestrings) {\r\n ls.addClosurePoint();\r\n loops.push(Loop.create(ls));\r\n }\r\n if (loops.length === 1) {\r\n return new SweepContour(loops[0], localToWorld, undefined);\r\n } else if (loops.length > 1) {\r\n return new SweepContour(ParityRegion.createLoops(loops), localToWorld, undefined);\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create for rotational sweep.\r\n * * The axis ray is retained.\r\n * * the contour is CAPTURED.\r\n */\r\n public static createForRotation(contour: CurveCollection, axis: Ray3d): SweepContour | undefined {\r\n // createRightHandedFrame -- the axis is a last-gasp resolver for in-plane vectors.\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, contour, axis);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, axis.clone());\r\n }\r\n return undefined;\r\n }\r\n /** Return (Reference to) the curves */\r\n public getCurves(): CurveCollection { return this.curves; }\r\n /** Apply `transform` to the curves, axis.\r\n * * The local to world frame is reconstructed for the transformed curves.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (this.curves.tryTransformInPlace(transform)) {\r\n if (this.axis)\r\n this.axis.transformInPlace(transform);\r\n\r\n const localToWorld = this.axis !== undefined\r\n ? FrameBuilder.createRightHandedFrame(undefined, this.curves, this.axis)\r\n : FrameBuilder.createRightHandedFrame(undefined, this.curves);\r\n if (localToWorld) {\r\n this.localToWorld.setFrom(localToWorld);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): SweepContour {\r\n return new SweepContour(this.curves.clone() as CurveCollection, this.localToWorld.clone(), this.axis);\r\n }\r\n /** Return a transformed clone. */\r\n public cloneTransformed(transform: Transform): SweepContour | undefined {\r\n const newContour = this.clone();\r\n if (newContour.tryTransformInPlace(transform))\r\n return newContour;\r\n return undefined;\r\n }\r\n /** Test for near equality of cures and local frame. */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof SweepContour) {\r\n return this.curves.isAlmostEqual(other.curves) && this.localToWorld.isAlmostEqual(other.localToWorld);\r\n }\r\n return false;\r\n }\r\n\r\n private _xyStrokes?: AnyCurve;\r\n private _facets?: IndexedPolyface;\r\n public get xyStrokes(): AnyCurve | undefined { return this._xyStrokes;}\r\n /**\r\n * build the (cached) internal facets.\r\n * @param options options for stroking the curves.\r\n */\r\n public buildFacets(options: StrokeOptions | undefined): void {\r\n if (!this._facets) {\r\n if (this.curves instanceof Loop) {\r\n this._xyStrokes = this.curves.cloneStroked(options);\r\n if (this._xyStrokes instanceof Loop && this._xyStrokes.children.length === 1) {\r\n const children = this._xyStrokes.children;\r\n const linestring = children[0] as LineString3d;\r\n const points = linestring.points;\r\n this.localToWorld.multiplyInversePoint3dArrayInPlace(points);\r\n if (PolygonOps.sumTriangleAreasXY(points) < 0)\r\n points.reverse();\r\n const graph = Triangulator.createTriangulatedGraphFromSingleLoop(points);\r\n if (graph) {\r\n Triangulator.flipTriangles(graph);\r\n const unflippedPoly = PolyfaceBuilder.graphToPolyface(graph, options);\r\n this._facets = unflippedPoly;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n }\r\n } else if (this.curves instanceof ParityRegion) {\r\n this._xyStrokes = this.curves.cloneStroked(options);\r\n if (this._xyStrokes instanceof (ParityRegion)) {\r\n const worldToLocal = this.localToWorld.inverse()!;\r\n this._xyStrokes.tryTransformInPlace(worldToLocal);\r\n const strokes = [];\r\n for (const childLoop of this._xyStrokes.children) {\r\n const loopCurves = childLoop.children;\r\n if (loopCurves.length === 1) {\r\n const c = loopCurves[0];\r\n if (c instanceof LineString3d)\r\n strokes.push(c.packedPoints);\r\n }\r\n }\r\n const numLoops = strokes.length;\r\n /** Try the earcut algorithm first -- lots less machinery, but can't handle any form of overlap */\r\n const graph = Triangulator.createTriangulatedGraphFromLoops(strokes);\r\n if (graph && HalfEdgeGraphSearch.isTriangulatedCCW(graph, true, numLoops - 1)) {\r\n Triangulator.flipTriangles(graph);\r\n const unflippedPoly = PolyfaceBuilder.graphToPolyface(graph, options);\r\n this._facets = unflippedPoly;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n } else {\r\n // earcut failed. Restart with full merge and parity analysis.\r\n const polyface = RegionOps.polygonXYAreaUnionLoopsToPolyface(strokes, [], true);\r\n if (polyface) {\r\n this._facets = polyface as IndexedPolyface;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n }\r\n\r\n }\r\n }\r\n }\r\n }\r\n /** delete existing facets.\r\n * * This protects against PolyfaceBuilder reusing facets constructed with different options settings.\r\n */\r\n public purgeFacets() {\r\n this._facets = undefined;\r\n }\r\n\r\n /** Emit facets to a builder.\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public emitFacets(builder: PolyfaceBuilder, reverse: boolean, transform?: Transform) {\r\n this.buildFacets(builder.options);\r\n if (this._facets)\r\n builder.addIndexedPolyface(this._facets, reverse, transform);\r\n }\r\n\r\n /** Emit facets to a function\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public announceFacets(announce: (facets: IndexedPolyface) => void, options: StrokeOptions | undefined) {\r\n this.buildFacets(options);\r\n if (this._facets)\r\n announce(this._facets);\r\n }\r\n\r\n /**\r\n * Triangulate the region.\r\n * Create a UnionOfConvexClipPlaneSets that clips to the swept region.\r\n * * If sweepVector is not given, the sweep direction is perpendicular to the plane of the contour.\r\n * * If sweepVector is given, it is the sweep direction and does not have to be perpendicular to the contour.\r\n * * cap0 and cap1 indicate construction of clip planes parallel to the contour plane.\r\n * * If cap1 is true, the cap plane is at `anyPointOnPlane + sweepVector`. That is, the sweep vector indicates both direction and distance.\r\n * * caps are NOT created of sweepVector is not given.\r\n */\r\n public sweepToUnionOfConvexClipPlaneSets(sweepVector?: Vector3d, cap0: boolean = false, cap1: boolean = false): UnionOfConvexClipPlaneSets | undefined {\r\n const builder = PolyfaceBuilder.create();\r\n // It's a trip around the barn, but it's easy to make a polyface and scan it . . .\r\n if (!sweepVector)\r\n cap0 = cap1 = false;\r\n this.buildFacets(builder.options);\r\n if (sweepVector === undefined)\r\n sweepVector = this.localToWorld.matrix.columnZ();\r\n const zVector = this.localToWorld.matrix.columnZ();\r\n const facets = this._facets;\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n if (facets) {\r\n const plane0Origin = this.localToWorld.getOrigin();\r\n const plane1Origin = plane0Origin.plus(sweepVector);\r\n const inwardNormal0 = zVector.clone();\r\n const inwardNormal1 = zVector.negate();\r\n\r\n const result = UnionOfConvexClipPlaneSets.createEmpty();\r\n const visitor = facets.createVisitor(1);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n const numEdges = visitor.point.length - 1;\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n for (let i = 0; i < numEdges; i++) {\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i, point0);\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i + 1, point1);\r\n const plane = ClipPlane.createEdgeAndUpVector(point1, point0, sweepVector);\r\n const visible = visitor.edgeVisible[i];\r\n plane?.setFlags(!visible, !visible);\r\n clipper.addPlaneToConvexSet(plane);\r\n }\r\n if (cap0)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal0, plane0Origin));\r\n if (cap1)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal1, plane1Origin));\r\n result.addConvexSet(clipper);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SweepContour.js","sourceRoot":"","sources":["../../../src/solid/SweepContour.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,qDAAkD;AAClD,uEAAoE;AACpE,uFAAoF;AAGpF,wDAAqD;AACrD,wCAAqC;AACrC,wDAAqD;AACrD,kDAA+C;AAE/C,6DAA0D;AAC1D,mEAAkE;AAClE,yDAAsD;AAItD,iEAA8D;AAC9D,yEAAsE;AACtE,6DAAqF;AAErF;;;;GAIG;AACH,MAAa,YAAY;IAQvB,YAAoB,OAAwB,EAAE,GAAc,EAAE,IAAuB;QACnF,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,oBAAoB,CAAC,OAAwB,EAAE,aAAwB;QACnF,MAAM,YAAY,GAAG,2BAAY,CAAC,sBAAsB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACjF,IAAI,YAAY,EAAE;YAClB,OAAO,IAAI,YAAY,CAAC,OAAO,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;SACzD;QACD,OAAO,SAAS,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,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;oBACvC,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;oBACpC,OAAO,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;iBACpC;gBACD,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,qBAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,IAAI,IAAI;oBACN,OAAO,CAAC,mBAAmB,CAAC,qBAAS,CAAC,oBAAoB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;gBAC3F,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;aAC9B;YACD,OAAO,MAAM,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AA9OD,oCA8OC","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 Solid\r\n */\r\n\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { AnyCurve } from \"../curve/CurveChain\";\r\nimport { CurveCollection } from \"../curve/CurveCollection\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { ParityRegion } from \"../curve/ParityRegion\";\r\nimport { RegionOps } from \"../curve/RegionOps\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { IndexedPolyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\n\r\n/**\r\n * Sweepable contour with Transform for local to world interaction.\r\n * * The surface/solid classes `LinearSweep`, `RotationalSweep`, `RuledSweep` use this for their swept contours.\r\n * @public\r\n */\r\nexport class SweepContour {\r\n /** The underlying curve collection, in its world coordinates position. */\r\n public curves: CurveCollection;\r\n /** coordinate frame that in which the curves are all in the xy plane. */\r\n public localToWorld: Transform;\r\n /** Axis used only in rotational case. */\r\n public axis: Ray3d | undefined;\r\n\r\n private constructor(contour: CurveCollection, map: Transform, axis: Ray3d | undefined) {\r\n this.curves = contour;\r\n this.localToWorld = map;\r\n this.axis = axis;\r\n }\r\n /** Create for linear sweep.\r\n * * The optional default normal may be useful for guiding coordinate frame setup.\r\n * * the contour is CAPTURED.\r\n */\r\n public static createForLinearSweep(contour: CurveCollection, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, contour);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, undefined);\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create for linear sweep.\r\n * * The optional default normal may be useful for guiding coordinate frame setup.\r\n * * the points are captured into linestrings and Loops as needed.\r\n */\r\n public static createForPolygon(points: MultiLineStringDataVariant, defaultNormal?: Vector3d): SweepContour | undefined {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(defaultNormal, points);\r\n if (localToWorld) {\r\n if (defaultNormal !== undefined) {\r\n if (localToWorld.matrix.dotColumnZ(defaultNormal))\r\n localToWorld.matrix.scaleColumnsInPlace(1.0, -1.0, -1.0);\r\n }\r\n const linestrings = LineString3d.createArrayOfLineString3d(points);\r\n const loops = [];\r\n for (const ls of linestrings) {\r\n ls.addClosurePoint();\r\n loops.push(Loop.create(ls));\r\n }\r\n if (loops.length === 1) {\r\n return new SweepContour(loops[0], localToWorld, undefined);\r\n } else if (loops.length > 1) {\r\n return new SweepContour(ParityRegion.createLoops(loops), localToWorld, undefined);\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Create for rotational sweep.\r\n * * The axis ray is retained.\r\n * * the contour is CAPTURED.\r\n */\r\n public static createForRotation(contour: CurveCollection, axis: Ray3d): SweepContour | undefined {\r\n // createRightHandedFrame -- the axis is a last-gasp resolver for in-plane vectors.\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, contour, axis);\r\n if (localToWorld) {\r\n return new SweepContour(contour, localToWorld, axis.clone());\r\n }\r\n return undefined;\r\n }\r\n /** Return (Reference to) the curves */\r\n public getCurves(): CurveCollection { return this.curves; }\r\n /** Apply `transform` to the curves, axis.\r\n * * The local to world frame is reconstructed for the transformed curves.\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n if (this.curves.tryTransformInPlace(transform)) {\r\n if (this.axis)\r\n this.axis.transformInPlace(transform);\r\n\r\n const localToWorld = this.axis !== undefined\r\n ? FrameBuilder.createRightHandedFrame(undefined, this.curves, this.axis)\r\n : FrameBuilder.createRightHandedFrame(undefined, this.curves);\r\n if (localToWorld) {\r\n this.localToWorld.setFrom(localToWorld);\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n /** Return a deep clone. */\r\n public clone(): SweepContour {\r\n return new SweepContour(this.curves.clone(), this.localToWorld.clone(), this.axis);\r\n }\r\n /** Return a transformed clone. */\r\n public cloneTransformed(transform: Transform): SweepContour | undefined {\r\n const newContour = this.clone();\r\n if (newContour.tryTransformInPlace(transform))\r\n return newContour;\r\n return undefined;\r\n }\r\n /** Test for near equality of cures and local frame. */\r\n public isAlmostEqual(other: any): boolean {\r\n if (other instanceof SweepContour) {\r\n return this.curves.isAlmostEqual(other.curves) && this.localToWorld.isAlmostEqual(other.localToWorld);\r\n }\r\n return false;\r\n }\r\n\r\n private _xyStrokes?: AnyCurve;\r\n private _facets?: IndexedPolyface;\r\n public get xyStrokes(): AnyCurve | undefined { return this._xyStrokes;}\r\n /**\r\n * build the (cached) internal facets.\r\n * @param options options for stroking the curves.\r\n */\r\n public buildFacets(options: StrokeOptions | undefined): void {\r\n if (!this._facets) {\r\n if (this.curves instanceof Loop) {\r\n this._xyStrokes = this.curves.cloneStroked(options);\r\n if (this._xyStrokes instanceof Loop && this._xyStrokes.children.length === 1) {\r\n const children = this._xyStrokes.children;\r\n const linestring = children[0] as LineString3d;\r\n const points = linestring.points;\r\n this.localToWorld.multiplyInversePoint3dArrayInPlace(points);\r\n if (PolygonOps.sumTriangleAreasXY(points) < 0)\r\n points.reverse();\r\n const graph = Triangulator.createTriangulatedGraphFromSingleLoop(points);\r\n if (graph) {\r\n Triangulator.flipTriangles(graph);\r\n const unflippedPoly = PolyfaceBuilder.graphToPolyface(graph, options);\r\n this._facets = unflippedPoly;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n }\r\n } else if (this.curves instanceof ParityRegion) {\r\n this._xyStrokes = this.curves.cloneStroked(options);\r\n if (this._xyStrokes instanceof (ParityRegion)) {\r\n const worldToLocal = this.localToWorld.inverse()!;\r\n this._xyStrokes.tryTransformInPlace(worldToLocal);\r\n const strokes = [];\r\n for (const childLoop of this._xyStrokes.children) {\r\n const loopCurves = childLoop.children;\r\n if (loopCurves.length === 1) {\r\n const c = loopCurves[0];\r\n if (c instanceof LineString3d)\r\n strokes.push(c.packedPoints);\r\n }\r\n }\r\n const numLoops = strokes.length;\r\n /** Try the earcut algorithm first -- lots less machinery, but can't handle any form of overlap */\r\n const graph = Triangulator.createTriangulatedGraphFromLoops(strokes);\r\n if (graph && HalfEdgeGraphSearch.isTriangulatedCCW(graph, true, numLoops - 1)) {\r\n Triangulator.flipTriangles(graph);\r\n const unflippedPoly = PolyfaceBuilder.graphToPolyface(graph, options);\r\n this._facets = unflippedPoly;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n } else {\r\n // earcut failed. Restart with full merge and parity analysis.\r\n const polyface = RegionOps.polygonXYAreaUnionLoopsToPolyface(strokes, [], true);\r\n if (polyface) {\r\n this._facets = polyface as IndexedPolyface;\r\n this._facets.tryTransformInPlace(this.localToWorld);\r\n }\r\n }\r\n\r\n }\r\n }\r\n }\r\n }\r\n /** delete existing facets.\r\n * * This protects against PolyfaceBuilder reusing facets constructed with different options settings.\r\n */\r\n public purgeFacets() {\r\n this._facets = undefined;\r\n }\r\n\r\n /** Emit facets to a builder.\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public emitFacets(builder: PolyfaceBuilder, reverse: boolean, transform?: Transform) {\r\n this.buildFacets(builder.options);\r\n if (this._facets)\r\n builder.addIndexedPolyface(this._facets, reverse, transform);\r\n }\r\n\r\n /** Emit facets to a function\r\n * This method may cache and reuse facets over multiple calls.\r\n */\r\n public announceFacets(announce: (facets: IndexedPolyface) => void, options: StrokeOptions | undefined) {\r\n this.buildFacets(options);\r\n if (this._facets)\r\n announce(this._facets);\r\n }\r\n\r\n /**\r\n * Triangulate the region.\r\n * Create a UnionOfConvexClipPlaneSets that clips to the swept region.\r\n * * If sweepVector is not given, the sweep direction is perpendicular to the plane of the contour.\r\n * * If sweepVector is given, it is the sweep direction and does not have to be perpendicular to the contour.\r\n * * cap0 and cap1 indicate construction of clip planes parallel to the contour plane.\r\n * * If cap1 is true, the cap plane is at `anyPointOnPlane + sweepVector`. That is, the sweep vector indicates both direction and distance.\r\n * * caps are NOT created of sweepVector is not given.\r\n */\r\n public sweepToUnionOfConvexClipPlaneSets(sweepVector?: Vector3d, cap0: boolean = false, cap1: boolean = false): UnionOfConvexClipPlaneSets | undefined {\r\n const builder = PolyfaceBuilder.create();\r\n // It's a trip around the barn, but it's easy to make a polyface and scan it . . .\r\n if (!sweepVector)\r\n cap0 = cap1 = false;\r\n this.buildFacets(builder.options);\r\n if (sweepVector === undefined)\r\n sweepVector = this.localToWorld.matrix.columnZ();\r\n const zVector = this.localToWorld.matrix.columnZ();\r\n const facets = this._facets;\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n if (facets) {\r\n const plane0Origin = this.localToWorld.getOrigin();\r\n const plane1Origin = plane0Origin.plus(sweepVector);\r\n const inwardNormal0 = zVector.clone();\r\n const inwardNormal1 = zVector.negate();\r\n\r\n const result = UnionOfConvexClipPlaneSets.createEmpty();\r\n const visitor = facets.createVisitor(1);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n const numEdges = visitor.point.length - 1;\r\n const clipper = ConvexClipPlaneSet.createEmpty();\r\n for (let i = 0; i < numEdges; i++) {\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i, point0);\r\n visitor.point.getPoint3dAtUncheckedPointIndex(i + 1, point1);\r\n const plane = ClipPlane.createEdgeAndUpVector(point1, point0, sweepVector);\r\n const visible = visitor.edgeVisible[i];\r\n plane?.setFlags(!visible, !visible);\r\n clipper.addPlaneToConvexSet(plane);\r\n }\r\n if (cap0)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal0, plane0Origin));\r\n if (cap1)\r\n clipper.addPlaneToConvexSet(ClipPlane.createNormalAndPoint(inwardNormal1, plane1Origin));\r\n result.addConvexSet(clipper);\r\n }\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n}\r\n"]}
@@ -82,14 +82,8 @@ export declare class AkimaCurve3d extends ProxyCurve {
82
82
  * Transform this [[AkimaCurve3d]] and its defining data in place
83
83
  */
84
84
  tryTransformInPlace(transform: Transform): boolean;
85
- /**
86
- * Return a transformed clone.
87
- */
88
- cloneTransformed(transform: Transform): GeometryQuery | undefined;
89
- /**
90
- * Return a clone.
91
- */
92
- clone(): GeometryQuery | undefined;
85
+ /** Return a deep clone */
86
+ clone(): AkimaCurve3d;
93
87
  /** Test if `other` is also an [[AkimaCurve3d]] */
94
88
  isSameGeometryClass(other: GeometryQuery): boolean;
95
89
  isAlmostEqual(other: GeometryQuery): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"AkimaCurve3d.d.ts","sourceRoot":"","sources":["../../../src/bspline/AkimaCurve3d.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD;;;;GAIG;AACF,MAAM,WAAW,iBAAiB;IAClC,8CAA8C;IAC9C,SAAS,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED;;;;;GAKG;AACH,qBAAa,mBAAmB;IACvB,SAAS,EAAE,OAAO,EAAE,CAAC;IAC5B;;;;OAIG;gBACgB,SAAS,CAAC,EAAE,OAAO,EAAE;IAIzC;;;;mEAI+D;IACvD,wBAAwB,IAAI,iBAAiB;IAMtD,gEAAgE;IACvD,KAAK,IAAI,mBAAmB;IAKrC,gEAAgE;WAClD,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB;WAKpD,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO;CAQtH;AAED;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,SAAgB,kBAAkB,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAsB;IACtC;;OAEG;IACL,OAAO;IAIW,yBAAyB,CAAC,OAAO,EAAE,eAAe;IAGpE;;;;OAIG;WACa,MAAM,CAAC,OAAO,EAAE,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;mEAI+D;IACvD,wBAAwB,IAAI,iBAAiB;IAMtD,gEAAgE;IACvD,KAAK,IAAI,mBAAmB;IAKrC,gEAAgE;WAClD,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,mBAAmB;WAKpD,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,EAAE,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO;CAQtH;AAED;;;;;;GAMG;AACH,qBAAa,YAAa,SAAQ,UAAU;IAC1C,SAAgB,kBAAkB,wBAAwB;IAC1D,OAAO,CAAC,QAAQ,CAAsB;IACtC;;OAEG;IACL,OAAO;IAIW,yBAAyB,CAAC,OAAO,EAAE,eAAe;IAGpE;;;;OAIG;WACa,MAAM,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,GAAG,YAAY,GAAG,SAAS;WAUlF,aAAa,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,GAAG,SAAS;IAOnF,uEAAuE;IAChE,yBAAyB,IAAI,YAAY;IAIhD;;;OAGG;IACI,MAAM,IAAI,GAAG;IAGpB,2EAA2E;IACpE,UAAU,IAAI,iBAAiB;IAItC;;;OAGG;IACI,cAAc,IAAI,IAAI;IAI7B;;OAEG;IACI,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAQzD,0BAA0B;IACV,KAAK,IAAI,YAAY;IAIrC,kDAAkD;IAC3C,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;IAEzC,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO;CAM7D"}
@@ -127,24 +127,9 @@ export class AkimaCurve3d extends ProxyCurve {
127
127
  }
128
128
  return proxyOk;
129
129
  }
130
- /**
131
- * Return a transformed clone.
132
- */
133
- cloneTransformed(transform) {
134
- const myClone = this.clone();
135
- if (myClone && (myClone === null || myClone === void 0 ? void 0 : myClone.tryTransformInPlace(transform)))
136
- return myClone;
137
- return undefined;
138
- }
139
- /**
140
- * Return a clone.
141
- */
130
+ /** Return a deep clone */
142
131
  clone() {
143
- const proxyClone = this._proxyCurve.clone();
144
- if (proxyClone) {
145
- return new AkimaCurve3d(this._options.clone(), proxyClone);
146
- }
147
- return undefined;
132
+ return new AkimaCurve3d(this._options.clone(), this._proxyCurve.clone());
148
133
  }
149
134
  /** Test if `other` is also an [[AkimaCurve3d]] */
150
135
  isSameGeometryClass(other) { return other instanceof AkimaCurve3d; }
@@ -1 +1 @@
1
- {"version":3,"file":"AkimaCurve3d.js","sourceRoot":"","sources":["../../../src/bspline/AkimaCurve3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBhD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAE9B;;;;OAIG;IACH,YAAmB,SAAqB;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC;IAEF;;;;mEAI+D;IACvD,wBAAwB;QAC7B,MAAM,KAAK,GAAG;YACZ,SAAS,EAAE,YAAY,CAAC,yBAAyB,CAAC,IAAI,CAAC,SAAS,CAAC;SAClE,CAAC;QACF,OAAO,KAAK,CAAC;IACf,CAAC;IACH,gEAAgE;IACvD,KAAK;QACV,MAAM,KAAK,GAAG,IAAI,mBAAmB,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;QACtF,OAAO,KAAK,CAAC;IACf,CAAC;IAEH,gEAAgE;IACzD,MAAM,CAAC,MAAM,CAAC,MAAyB;QAC5C,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,YAAY,CAAC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IAAI,CAAC,QAAQ,CAAC,KAAK,EAAG,EAAE,UAA4B,CAAC,CAAC;SAC/E;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IACH,kDAAkD;IACzC,mBAAmB,CAAC,KAAoB,IAAa,OAAO,KAAK,YAAY,YAAY,CAAC,CAAC,CAAC;IAEnF,aAAa,CAAC,KAAoB;QAChD,IAAI,KAAK,YAAY,YAAY,EAAE;YACjC,OAAO,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC1E;QACD,OAAO,KAAK,CAAC;IACf,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/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { ProxyCurve } from \"../curve/ProxyCurve\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { BSplineCurve3d } from \"./BSplineCurve\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\n\r\n/**\r\n * fitPoints [[AkimaCurve3d]]\r\n * * This is a \"json compatible\" version of the serializer-friendly [[AkimaCurve3dOptions]]\r\n * @public\r\n */\r\n export interface AkimaCurve3dProps {\r\n /** Points that the curve must pass through */\r\n fitPoints: XYZProps[];\r\n}\r\n\r\n/**\r\n * fitPoints and end condition data for [[AkimaCurve3d]]\r\n * * This is a \"typed object\" version of the serializer-friendly [[AkimaCurve3dProps]]\r\n * * Typical use cases rarely require all parameters, so the constructor does not itemize them as parameters.\r\n * @public\r\n */\r\nexport class AkimaCurve3dOptions {\r\n public fitPoints: Point3d[];\r\n /**\r\n *\r\n * @param fitPoints points to CAPTURE\r\n * @param knots array to CAPTURE\r\n */\r\n public constructor(fitPoints?: Point3d[]) {\r\n this.fitPoints = fitPoints ? fitPoints : [];\r\n }\r\n\r\n /** Points that the curve must pass through.\r\n * First and last 2 points are \"beyond the end\" for control of end slope.\r\n fitPoints: Point3d[];\r\n\r\n/** Clone with strongly typed members reduced to simple json. */\r\n public cloneAsAkimaCurve3dProps(): AkimaCurve3dProps {\r\n const props = {\r\n fitPoints: Point3dArray.cloneDeepJSONNumberArrays(this.fitPoints),\r\n };\r\n return props;\r\n }\r\n/** Clone with strongly typed members reduced to simple json. */\r\n public clone(): AkimaCurve3dOptions {\r\n const clone = new AkimaCurve3dOptions(Point3dArray.clonePoint3dArray(this.fitPoints));\r\n return clone;\r\n }\r\n\r\n/** Clone with strongly typed members reduced to simple json. */\r\npublic static create(source: AkimaCurve3dProps): AkimaCurve3dOptions {\r\n const result = new AkimaCurve3dOptions(Point3dArray.clonePoint3dArray(source.fitPoints));\r\n return result;\r\n}\r\n\r\n public static areAlmostEqual(dataA: AkimaCurve3dOptions | undefined, dataB: AkimaCurve3dOptions | undefined): boolean {\r\n if (dataA === undefined && dataB === undefined)\r\n return true;\r\n if (dataA !== undefined && dataB !== undefined) {\r\n return Geometry.almostEqualArrays(dataA.fitPoints, dataB.fitPoints, (a: Point3d, b: Point3d) => a.isAlmostEqual(b));\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Interpolating curve.\r\n * * Derive from [[ProxyCurve]]\r\n * * Use a [[BSplineCurve3d]] as the proxy\r\n * *\r\n * @public\r\n */\r\nexport class AkimaCurve3d extends ProxyCurve {\r\n public readonly curvePrimitiveType = \"interpolationCurve\";\r\n private _options: AkimaCurve3dOptions;\r\n /**\r\n * CAPTURE properties and proxy curve.\r\n */\r\nprivate constructor(properties: AkimaCurve3dOptions, proxyCurve: CurvePrimitive) {\r\n super(proxyCurve);\r\n this._options = properties;\r\n }\r\n public override dispatchToGeometryHandler(handler: GeometryHandler) {\r\n return handler.handleAkimaCurve3d(this);\r\n }\r\n/**\r\n * Create an [[AkimaCurve3d]] based on points, knots, and other properties in the [[AkimaCurve3dProps]] or [[AkimaCurve3dOptions]].\r\n * * This saves a COPY OF the options or props.\r\n * * Use createCapture () if the options or props can be used without copy\r\n */\r\n public static create(options: AkimaCurve3dOptions | AkimaCurve3dProps): AkimaCurve3d | undefined {\r\n let optionsCopy;\r\n if (options instanceof AkimaCurve3dOptions) {\r\n optionsCopy = options.clone();\r\n } else {\r\n optionsCopy = AkimaCurve3dOptions.create(options);\r\n }\r\n return AkimaCurve3d.createCapture(optionsCopy);\r\n }\r\n\r\n public static createCapture(options: AkimaCurve3dOptions): AkimaCurve3d | undefined{\r\n const proxyCurve = BSplineCurve3d.createFromAkimaCurve3dOptions(options);\r\n if (proxyCurve)\r\n return new AkimaCurve3d(options, proxyCurve);\r\n return undefined;\r\n }\r\n\r\n /** Return a (copy of) the defining points, packed as a Float64Array */\r\n public copyFitPointsFloat64Array(): Float64Array {\r\n return Point3dArray.cloneXYZPropsAsFloat64Array(this._options.fitPoints);\r\n }\r\n\r\n /**\r\n * Return json key-value pairs for for this [[AkimaCurve3d]].\r\n * @returns\r\n */\r\n public toJSON(): any {\r\n return this._options.cloneAsAkimaCurve3dProps();\r\n }\r\n /** Clone the [[AkimaCurve3dProps]] object in this [[AkimaCurve3dProps]] */\r\n public cloneProps(): AkimaCurve3dProps {\r\n return this._options.cloneAsAkimaCurve3dProps();\r\n }\r\n\r\n /**\r\n * Reverse the curve direction.\r\n * * This updates both the defining properties and the proxy bspline.\r\n */\r\n public reverseInPlace(): void {\r\n this._proxyCurve.reverseInPlace();\r\n this._options.fitPoints.reverse();\r\n }\r\n /**\r\n * Transform this [[AkimaCurve3d]] and its defining data in place\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n const proxyOk = this._proxyCurve.tryTransformInPlace(transform);\r\n if (proxyOk) {\r\n transform.multiplyPoint3dArray(this._options.fitPoints);\r\n }\r\n return proxyOk;\r\n }\r\n /**\r\n * Return a transformed clone.\r\n */\r\n public cloneTransformed(transform: Transform): GeometryQuery | undefined {\r\n const myClone = this.clone();\r\n if (myClone && myClone?.tryTransformInPlace(transform))\r\n return myClone;\r\n return undefined;\r\n }\r\n /**\r\n * Return a clone.\r\n */\r\n public clone(): GeometryQuery | undefined {\r\n const proxyClone = this._proxyCurve.clone();\r\n if (proxyClone) {\r\n return new AkimaCurve3d(this._options.clone (), proxyClone as CurvePrimitive);\r\n }\r\n return undefined;\r\n }\r\n/** Test if `other` is also an [[AkimaCurve3d]] */\r\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof AkimaCurve3d; }\r\n\r\n public override isAlmostEqual(other: GeometryQuery): boolean{\r\n if (other instanceof AkimaCurve3d) {\r\n return AkimaCurve3dOptions.areAlmostEqual(this._options, other._options);\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"AkimaCurve3d.js","sourceRoot":"","sources":["../../../src/bspline/AkimaCurve3d.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBhD;;;;;GAKG;AACH,MAAM,OAAO,mBAAmB;IAE9B;;;;OAIG;IACH,YAAmB,SAAqB;QACtC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC;IAEF;;;;mEAI+D;IACvD,wBAAwB;QAC7B,MAAM,KAAK,GAAG;YACZ,SA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B;IACV,KAAK;QACnB,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,kDAAkD;IAC3C,mBAAmB,CAAC,KAAoB,IAAa,OAAO,KAAK,YAAY,YAAY,CAAC,CAAC,CAAC;IAEnF,aAAa,CAAC,KAAoB;QAChD,IAAI,KAAK,YAAY,YAAY,EAAE;YACjC,OAAO,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;SAC1E;QACD,OAAO,KAAK,CAAC;IACf,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/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { ProxyCurve } from \"../curve/ProxyCurve\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { BSplineCurve3d } from \"./BSplineCurve\";\r\nimport { GeometryQuery } from \"../curve/GeometryQuery\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { GeometryHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { XYZProps } from \"../geometry3d/XYZProps\";\r\n\r\n/**\r\n * fitPoints [[AkimaCurve3d]]\r\n * * This is a \"json compatible\" version of the serializer-friendly [[AkimaCurve3dOptions]]\r\n * @public\r\n */\r\n export interface AkimaCurve3dProps {\r\n /** Points that the curve must pass through */\r\n fitPoints: XYZProps[];\r\n}\r\n\r\n/**\r\n * fitPoints and end condition data for [[AkimaCurve3d]]\r\n * * This is a \"typed object\" version of the serializer-friendly [[AkimaCurve3dProps]]\r\n * * Typical use cases rarely require all parameters, so the constructor does not itemize them as parameters.\r\n * @public\r\n */\r\nexport class AkimaCurve3dOptions {\r\n public fitPoints: Point3d[];\r\n /**\r\n *\r\n * @param fitPoints points to CAPTURE\r\n * @param knots array to CAPTURE\r\n */\r\n public constructor(fitPoints?: Point3d[]) {\r\n this.fitPoints = fitPoints ? fitPoints : [];\r\n }\r\n\r\n /** Points that the curve must pass through.\r\n * First and last 2 points are \"beyond the end\" for control of end slope.\r\n fitPoints: Point3d[];\r\n\r\n/** Clone with strongly typed members reduced to simple json. */\r\n public cloneAsAkimaCurve3dProps(): AkimaCurve3dProps {\r\n const props = {\r\n fitPoints: Point3dArray.cloneDeepJSONNumberArrays(this.fitPoints),\r\n };\r\n return props;\r\n }\r\n/** Clone with strongly typed members reduced to simple json. */\r\n public clone(): AkimaCurve3dOptions {\r\n const clone = new AkimaCurve3dOptions(Point3dArray.clonePoint3dArray(this.fitPoints));\r\n return clone;\r\n }\r\n\r\n/** Clone with strongly typed members reduced to simple json. */\r\npublic static create(source: AkimaCurve3dProps): AkimaCurve3dOptions {\r\n const result = new AkimaCurve3dOptions(Point3dArray.clonePoint3dArray(source.fitPoints));\r\n return result;\r\n}\r\n\r\n public static areAlmostEqual(dataA: AkimaCurve3dOptions | undefined, dataB: AkimaCurve3dOptions | undefined): boolean {\r\n if (dataA === undefined && dataB === undefined)\r\n return true;\r\n if (dataA !== undefined && dataB !== undefined) {\r\n return Geometry.almostEqualArrays(dataA.fitPoints, dataB.fitPoints, (a: Point3d, b: Point3d) => a.isAlmostEqual(b));\r\n }\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Interpolating curve.\r\n * * Derive from [[ProxyCurve]]\r\n * * Use a [[BSplineCurve3d]] as the proxy\r\n * *\r\n * @public\r\n */\r\nexport class AkimaCurve3d extends ProxyCurve {\r\n public readonly curvePrimitiveType = \"interpolationCurve\";\r\n private _options: AkimaCurve3dOptions;\r\n /**\r\n * CAPTURE properties and proxy curve.\r\n */\r\nprivate constructor(properties: AkimaCurve3dOptions, proxyCurve: CurvePrimitive) {\r\n super(proxyCurve);\r\n this._options = properties;\r\n }\r\n public override dispatchToGeometryHandler(handler: GeometryHandler) {\r\n return handler.handleAkimaCurve3d(this);\r\n }\r\n/**\r\n * Create an [[AkimaCurve3d]] based on points, knots, and other properties in the [[AkimaCurve3dProps]] or [[AkimaCurve3dOptions]].\r\n * * This saves a COPY OF the options or props.\r\n * * Use createCapture () if the options or props can be used without copy\r\n */\r\n public static create(options: AkimaCurve3dOptions | AkimaCurve3dProps): AkimaCurve3d | undefined {\r\n let optionsCopy;\r\n if (options instanceof AkimaCurve3dOptions) {\r\n optionsCopy = options.clone();\r\n } else {\r\n optionsCopy = AkimaCurve3dOptions.create(options);\r\n }\r\n return AkimaCurve3d.createCapture(optionsCopy);\r\n }\r\n\r\n public static createCapture(options: AkimaCurve3dOptions): AkimaCurve3d | undefined{\r\n const proxyCurve = BSplineCurve3d.createFromAkimaCurve3dOptions(options);\r\n if (proxyCurve)\r\n return new AkimaCurve3d(options, proxyCurve);\r\n return undefined;\r\n }\r\n\r\n /** Return a (copy of) the defining points, packed as a Float64Array */\r\n public copyFitPointsFloat64Array(): Float64Array {\r\n return Point3dArray.cloneXYZPropsAsFloat64Array(this._options.fitPoints);\r\n }\r\n\r\n /**\r\n * Return json key-value pairs for for this [[AkimaCurve3d]].\r\n * @returns\r\n */\r\n public toJSON(): any {\r\n return this._options.cloneAsAkimaCurve3dProps();\r\n }\r\n /** Clone the [[AkimaCurve3dProps]] object in this [[AkimaCurve3dProps]] */\r\n public cloneProps(): AkimaCurve3dProps {\r\n return this._options.cloneAsAkimaCurve3dProps();\r\n }\r\n\r\n /**\r\n * Reverse the curve direction.\r\n * * This updates both the defining properties and the proxy bspline.\r\n */\r\n public reverseInPlace(): void {\r\n this._proxyCurve.reverseInPlace();\r\n this._options.fitPoints.reverse();\r\n }\r\n /**\r\n * Transform this [[AkimaCurve3d]] and its defining data in place\r\n */\r\n public tryTransformInPlace(transform: Transform): boolean {\r\n const proxyOk = this._proxyCurve.tryTransformInPlace(transform);\r\n if (proxyOk) {\r\n transform.multiplyPoint3dArray(this._options.fitPoints);\r\n }\r\n return proxyOk;\r\n }\r\n\r\n /** Return a deep clone */\r\n public override clone(): AkimaCurve3d {\r\n return new AkimaCurve3d(this._options.clone(), this._proxyCurve.clone());\r\n }\r\n\r\n /** Test if `other` is also an [[AkimaCurve3d]] */\r\n public isSameGeometryClass(other: GeometryQuery): boolean { return other instanceof AkimaCurve3d; }\r\n\r\n public override isAlmostEqual(other: GeometryQuery): boolean{\r\n if (other instanceof AkimaCurve3d) {\r\n return AkimaCurve3dOptions.areAlmostEqual(this._options, other._options);\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import { BSplineWrapMode, KnotVector } from "./KnotVector";
6
6
  /** Bspline knots and poles for 1d-to-Nd.
7
7
  * * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
8
8
  * * Derived classes (not this class) assign meaning such as x,y,z,w.
9
- * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighed 2D x,y,w
9
+ * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w
10
10
  * @public
11
11
  */
12
12
  export declare class BSpline1dNd {
@@ -25,7 +25,7 @@ export declare class BSpline1dNd {
25
25
  /** (property accessor) Return the number of poles*/
26
26
  get numPoles(): number;
27
27
  /** copy 3 values of pole `i` into a point.
28
- * * The calling clas sis responsible for knowing if this is an appropriate access to the blocked data.
28
+ * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
29
29
  */
30
30
  getPoint3dPole(i: number, result?: Point3d): Point3d | undefined;
31
31
  /** preallocated array (length === `order`) used as temporary in evaluations */
@@ -71,14 +71,14 @@ export declare class BSpline1dNd {
71
71
  * * Evaluate the basis functions and one derivative at spanIndex and fraction.
72
72
  * * Evaluations are stored in the preallocated `this.basisBuffer`
73
73
  * * Immediately do the summations of the basis values times the respective control points
74
- * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer`
74
+ * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
75
75
  * */
76
76
  evaluateBuffersInSpan1(spanIndex: number, spanFraction: number): void;
77
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer` */
77
+ /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
78
78
  sumPoleBufferForSpan(spanIndex: number): void;
79
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer1`, i.e. form first derivatives */
79
+ /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */
80
80
  sumPoleBuffer1ForSpan(spanIndex: number): void;
81
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer2`, i.e. form second derivatives */
81
+ /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */
82
82
  sumPoleBuffer2ForSpan(spanIndex: number): void;
83
83
  /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */
84
84
  evaluateBuffersAtKnot(u: number, numDerivative?: number): void;
@@ -92,5 +92,10 @@ export declare class BSpline1dNd {
92
92
  * @returns true if `degree` leading and trailing polygon blocks match
93
93
  */
94
94
  testCloseablePolygon(mode?: BSplineWrapMode): boolean;
95
+ /** Insert knot and resulting pole into the instance, optionally multiple times.
96
+ * @param knot the knot to be inserted (may already exist in the KnotVector)
97
+ * @param totalMultiplicity the total multiplicity of the knot on return
98
+ */
99
+ addKnot(knot: number, totalMultiplicity: number): boolean;
95
100
  }
96
101
  //# sourceMappingURL=BSpline1dNd.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BSpline1dNd.d.ts","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,C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S9C,4HAA4H;IACrH,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU;IAgBjE;;OAEG;IACI,cAAc,IAAI,IAAI;IAgB7B;;;;OAIG;IACI,oBAAoB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO;IAyB5D;;;OAGG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO;CA2DjE"}
@@ -9,11 +9,11 @@
9
9
  import { Geometry } from "../Geometry";
10
10
  /* eslint-disable @typescript-eslint/naming-convention, no-empty */
11
11
  import { Point3d } from "../geometry3d/Point3dVector3d";
12
- import { BSplineWrapMode } from "./KnotVector";
12
+ import { BSplineWrapMode, KnotVector } from "./KnotVector";
13
13
  /** Bspline knots and poles for 1d-to-Nd.
14
14
  * * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
15
15
  * * Derived classes (not this class) assign meaning such as x,y,z,w.
16
- * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighed 2D x,y,w
16
+ * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w
17
17
  * @public
18
18
  */
19
19
  export class BSpline1dNd {
@@ -44,7 +44,7 @@ export class BSpline1dNd {
44
44
  /** (property accessor) Return the number of poles*/
45
45
  get numPoles() { return this.packedData.length / this.poleLength; }
46
46
  /** copy 3 values of pole `i` into a point.
47
- * * The calling clas sis responsible for knowing if this is an appropriate access to the blocked data.
47
+ * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
48
48
  */
49
49
  getPoint3dPole(i, result) { return Point3d.createFromPacked(this.packedData, i, result); }
50
50
  /**
@@ -87,14 +87,14 @@ export class BSpline1dNd {
87
87
  * * Evaluate the basis functions and one derivative at spanIndex and fraction.
88
88
  * * Evaluations are stored in the preallocated `this.basisBuffer`
89
89
  * * Immediately do the summations of the basis values times the respective control points
90
- * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer`
90
+ * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
91
91
  * */
92
92
  evaluateBuffersInSpan1(spanIndex, spanFraction) {
93
93
  this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
94
94
  this.sumPoleBufferForSpan(spanIndex);
95
95
  this.sumPoleBuffer1ForSpan(spanIndex);
96
96
  }
97
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer` */
97
+ /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
98
98
  sumPoleBufferForSpan(spanIndex) {
99
99
  this.poleBuffer.fill(0);
100
100
  let k = spanIndex * this.poleLength;
@@ -104,7 +104,7 @@ export class BSpline1dNd {
104
104
  }
105
105
  }
106
106
  }
107
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer1`, i.e. form first derivatives */
107
+ /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */
108
108
  sumPoleBuffer1ForSpan(spanIndex) {
109
109
  this.poleBuffer1.fill(0);
110
110
  let k = spanIndex * this.poleLength;
@@ -114,7 +114,7 @@ export class BSpline1dNd {
114
114
  }
115
115
  }
116
116
  }
117
- /** sum poles at span `spanIndex` by the weights in the `poleBuffer2`, i.e. form second derivatives */
117
+ /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */
118
118
  sumPoleBuffer2ForSpan(spanIndex) {
119
119
  this.poleBuffer2.fill(0);
120
120
  let k = spanIndex * this.poleLength;
@@ -187,5 +187,63 @@ export class BSpline1dNd {
187
187
  }
188
188
  return false;
189
189
  }
190
+ /** Insert knot and resulting pole into the instance, optionally multiple times.
191
+ * @param knot the knot to be inserted (may already exist in the KnotVector)
192
+ * @param totalMultiplicity the total multiplicity of the knot on return
193
+ */
194
+ addKnot(knot, totalMultiplicity) {
195
+ if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)
196
+ return false; // invalid input
197
+ let iLeftKnot = this.knots.knotToLeftKnotIndex(knot);
198
+ // snap input if too close to an existing knot
199
+ if (Math.abs(knot - this.knots.knots[iLeftKnot]) < KnotVector.knotTolerance) {
200
+ knot = this.knots.knots[iLeftKnot]; // snap to left knot of bracket
201
+ }
202
+ else if (Math.abs(knot - this.knots.knots[iLeftKnot + 1]) < KnotVector.knotTolerance) {
203
+ iLeftKnot += this.knots.getKnotMultiplicityAtIndex(iLeftKnot + 1);
204
+ if (iLeftKnot > this.knots.rightKnotIndex)
205
+ return true; // nothing to do
206
+ knot = this.knots.knots[iLeftKnot]; // snap to left knot of next bracket
207
+ }
208
+ const numKnotsToAdd = Math.min(totalMultiplicity, this.degree) - this.knots.getKnotMultiplicity(knot);
209
+ if (numKnotsToAdd <= 0)
210
+ return true; // nothing to do
211
+ // working arrays and pole buffer
212
+ let currKnotCount = this.knots.knots.length;
213
+ const newKnots = new Float64Array(currKnotCount + numKnotsToAdd);
214
+ for (let i = 0; i < currKnotCount; ++i)
215
+ newKnots[i] = this.knots.knots[i];
216
+ let currPoleCount = this.numPoles;
217
+ const newPackedData = new Float64Array(this.packedData.length + (numKnotsToAdd * this.poleLength));
218
+ for (let i = 0; i < this.packedData.length; ++i)
219
+ newPackedData[i] = this.packedData[i];
220
+ const dataBuf = new Float64Array(this.degree * this.poleLength); // holds degree poles
221
+ // each iteration adds one knot and one pole to the working arrays (cf. Farin 4e)
222
+ for (let iter = 0; iter < numKnotsToAdd; ++iter) {
223
+ // fill the buffer with new poles obtained from control polygon corner cutting
224
+ let iBuf = 0;
225
+ const iStart = iLeftKnot - this.degree + 2;
226
+ for (let i = iStart; i < iStart + this.degree; ++i) {
227
+ const fraction = (knot - newKnots[i - 1]) / (newKnots[i + this.degree - 1] - newKnots[i - 1]);
228
+ for (let j = i * this.poleLength; j < (i + 1) * this.poleLength; ++j) {
229
+ dataBuf[iBuf++] = Geometry.interpolate(newPackedData[j - this.poleLength], fraction, newPackedData[j]);
230
+ }
231
+ }
232
+ // overwrite degree-1 poles with degree new poles, shifting tail to the right by one
233
+ newPackedData.copyWithin((iStart + this.degree) * this.poleLength, (iStart + this.degree - 1) * this.poleLength, currPoleCount * this.poleLength);
234
+ let iData = iStart * this.poleLength;
235
+ for (const d of dataBuf)
236
+ newPackedData[iData++] = d; // overwrite degree new poles
237
+ // add the knot to newKnots in position, shifting tail to the right by one
238
+ newKnots.copyWithin(iLeftKnot + 2, iLeftKnot + 1, currKnotCount);
239
+ newKnots[iLeftKnot + 1] = knot;
240
+ ++iLeftKnot;
241
+ ++currKnotCount;
242
+ ++currPoleCount;
243
+ }
244
+ this.knots.setKnotsCapture(newKnots);
245
+ this.packedData = newPackedData;
246
+ return true;
247
+ }
190
248
  }
191
249
  //# sourceMappingURL=BSpline1dNd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BSpline1dNd.js","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,2CAA2C;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,mEAAmE;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,eAAe,EAAc,MAAM,cAAc,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,OAAO,WAAW;IAgCtB;;;;;;OAMG;IACH,YAAsB,QAAgB,EAAE,UAAkB,EAAE,KAAa,EAAE,KAAiB;QAC1F,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,IAAI,YAAY,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,GAAG,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG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AAI,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,CAAC;oBAC7D,OAAO,KAAK,CAAC;aAChB;YACD,OAAO,IAAI,CAAC;SACb;QAED,IAAI,IAAI,KAAK,eAAe,CAAC,mBAAmB,EAAE;YAChD,kCAAkC;YAClC,OAAO,IAAI,CAAC;SACb;QAED,OAAO,KAAK,CAAC;IACf,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/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\nimport { Geometry } from \"../Geometry\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/** Bspline knots and poles for 1d-to-Nd.\r\n * * The \"pole\" (aka control point) of this class is a block of `poleLength` numbers.\r\n * * Derived classes (not this class) assign meaning such as x,y,z,w.\r\n * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighed 2D x,y,w\r\n * @public\r\n */\r\nexport class BSpline1dNd {\r\n /** knots of the bspline */\r\n public knots: KnotVector;\r\n /** poles, packed in blocks of `poleLength` doubles. */\r\n public packedData: Float64Array;\r\n /** (property accessor) Return the number of numeric values per pole. */\r\n public poleLength: number;\r\n /** (property accessor) Return the degree of the polynomials. */\r\n public get degree(): number { return this.knots.degree; }\r\n /** (property accessor) Return the number of order (one more than degree) of the polynomials */\r\n public get order(): number { return this.knots.degree + 1; }\r\n /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/\r\n public get numSpan(): number { return this.numPoles - this.knots.degree; }\r\n /** (property accessor) Return the number of poles*/\r\n public get numPoles(): number { return this.packedData.length / this.poleLength; }\r\n /** copy 3 values of pole `i` into a point.\r\n * * The calling clas sis responsible for knowing if this is an appropriate access to the blocked data.\r\n */\r\n public getPoint3dPole(i: number, result?: Point3d): Point3d | undefined { return Point3d.createFromPacked(this.packedData, i, result); }\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer1: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer2: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer1: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer2: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n\r\n /**\r\n * initialize arrays for given spline dimensions.\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n protected constructor(numPoles: number, poleLength: number, order: number, knots: KnotVector) {\r\n this.knots = knots;\r\n this.packedData = new Float64Array(numPoles * poleLength);\r\n this.poleLength = poleLength;\r\n this.basisBuffer = new Float64Array(order);\r\n this.poleBuffer = new Float64Array(poleLength);\r\n this.basisBuffer1 = new Float64Array(order);\r\n this.basisBuffer2 = new Float64Array(order);\r\n this.poleBuffer1 = new Float64Array(poleLength);\r\n this.poleBuffer2 = new Float64Array(poleLength);\r\n }\r\n\r\n /**\r\n * create a 1Bspline1dNd`\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n public static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined {\r\n return new BSpline1dNd(numPoles, poleLength, order, knots);\r\n }\r\n /** Map a span index and local fraction to knot value. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this.knots.spanFractionToKnot(span, localFraction);\r\n }\r\n\r\n /** Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span. */\r\n public evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array) {\r\n if (spanIndex < 0) spanIndex = 0;\r\n if (spanIndex >= this.numSpan) spanIndex = this.numSpan - 1;\r\n const knotIndex0 = spanIndex + this.degree - 1;\r\n const globalKnot = this.knots.baseKnotFractionToKnot(knotIndex0, spanFraction);\r\n return df ?\r\n this.knots.evaluateBasisFunctions1(knotIndex0, globalKnot, f, df, ddf) :\r\n this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);\r\n }\r\n /**\r\n * * Evaluate the basis functions at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer`\r\n * */\r\n public evaluateBuffersInSpan(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n }\r\n /**\r\n * * Evaluate the basis functions and one derivative at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer`\r\n * */\r\n public evaluateBuffersInSpan1(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n this.sumPoleBuffer1ForSpan(spanIndex);\r\n }\r\n /** sum poles at span `spanIndex` by the weights in the `poleBuffer` */\r\n public sumPoleBufferForSpan(spanIndex: number) {\r\n this.poleBuffer.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer) {\r\n for (let j = 0; j < this.poleLength; j++) { this.poleBuffer[j] += f * this.packedData[k++]; }\r\n }\r\n }\r\n /** sum poles at span `spanIndex` by the weights in the `poleBuffer1`, i.e. form first derivatives */\r\n public sumPoleBuffer1ForSpan(spanIndex: number) {\r\n this.poleBuffer1.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer1) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer1[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** sum poles at span `spanIndex` by the weights in the `poleBuffer2`, i.e. form second derivatives */\r\n public sumPoleBuffer2ForSpan(spanIndex: number) {\r\n this.poleBuffer2.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer2) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer2[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */\r\n public evaluateBuffersAtKnot(u: number, numDerivative: number = 0) {\r\n const knotIndex0 = this.knots.knotToLeftKnotIndex(u);\r\n if (numDerivative < 1) {\r\n this.knots.evaluateBasisFunctions(knotIndex0, u, this.basisBuffer);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n } else if (numDerivative === 1) {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n } else {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1, this.basisBuffer2);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);\r\n }\r\n }\r\n /**\r\n * Reverse the (blocked) poles (in `this.packedData` in place.\r\n */\r\n public reverseInPlace(): void {\r\n // reverse poles in blocks ...\r\n const b = this.poleLength;\r\n const data = this.packedData;\r\n for (let i0 = 0, j0 = b * (this.numPoles - 1);\r\n i0 < j0;\r\n i0 += b, j0 -= b) {\r\n let t = 0;\r\n for (let i = 0; i < b; i++) {\r\n t = data[i0 + i];\r\n data[i0 + i] = data[j0 + i];\r\n data[j0 + i] = t;\r\n }\r\n }\r\n this.knots.reflectKnots();\r\n }\r\n /**\r\n * Test if the leading and trailing polygon coordinates are replicated in the manner of a \"closed\" bspline polygon which has been expanded\r\n * to act as a normal bspline.\r\n * @returns true if `degree` leading and trailing polygon blocks match\r\n */\r\n public testCloseablePolygon(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.knots.wrappable;\r\n const degree = this.degree;\r\n const blockSize = this.poleLength;\r\n const indexDelta = (this.numPoles - this.degree) * blockSize;\r\n const data = this.packedData;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n // expect {degree} matched points.\r\n const numValuesToTest = degree * blockSize;\r\n for (let i0 = 0; i0 < numValuesToTest; i0++) {\r\n if (!Geometry.isSameCoordinate(data[i0], data[i0 + indexDelta]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // no pole conditions are applied.\r\n return true;\r\n }\r\n\r\n return false;\r\n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ACpE,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxG;aACF;YAED,oFAAoF;YACpF,aAAa,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAClJ,IAAI,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YACrC,KAAK,MAAM,CAAC,IAAI,OAAO;gBACrB,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,6BAA6B;YAE5D,0EAA0E;YAC1E,QAAQ,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;YACjE,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;YAE/B,EAAE,SAAS,CAAC;YACZ,EAAE,aAAa,CAAC;YAChB,EAAE,aAAa,CAAC;SACjB;QACD,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;QAChC,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/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\nimport { Geometry } from \"../Geometry\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/** Bspline knots and poles for 1d-to-Nd.\r\n * * The \"pole\" (aka control point) of this class is a block of `poleLength` numbers.\r\n * * Derived classes (not this class) assign meaning such as x,y,z,w.\r\n * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w\r\n * @public\r\n */\r\nexport class BSpline1dNd {\r\n /** knots of the bspline */\r\n public knots: KnotVector;\r\n /** poles, packed in blocks of `poleLength` doubles. */\r\n public packedData: Float64Array;\r\n /** (property accessor) Return the number of numeric values per pole. */\r\n public poleLength: number;\r\n /** (property accessor) Return the degree of the polynomials. */\r\n public get degree(): number { return this.knots.degree; }\r\n /** (property accessor) Return the number of order (one more than degree) of the polynomials */\r\n public get order(): number { return this.knots.degree + 1; }\r\n /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/\r\n public get numSpan(): number { return this.numPoles - this.knots.degree; }\r\n /** (property accessor) Return the number of poles*/\r\n public get numPoles(): number { return this.packedData.length / this.poleLength; }\r\n /** copy 3 values of pole `i` into a point.\r\n * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.\r\n */\r\n public getPoint3dPole(i: number, result?: Point3d): Point3d | undefined { return Point3d.createFromPacked(this.packedData, i, result); }\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer1: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer2: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer1: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer2: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n\r\n /**\r\n * initialize arrays for given spline dimensions.\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n protected constructor(numPoles: number, poleLength: number, order: number, knots: KnotVector) {\r\n this.knots = knots;\r\n this.packedData = new Float64Array(numPoles * poleLength);\r\n this.poleLength = poleLength;\r\n this.basisBuffer = new Float64Array(order);\r\n this.poleBuffer = new Float64Array(poleLength);\r\n this.basisBuffer1 = new Float64Array(order);\r\n this.basisBuffer2 = new Float64Array(order);\r\n this.poleBuffer1 = new Float64Array(poleLength);\r\n this.poleBuffer2 = new Float64Array(poleLength);\r\n }\r\n\r\n /**\r\n * create a 1Bspline1dNd`\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n public static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined {\r\n return new BSpline1dNd(numPoles, poleLength, order, knots);\r\n }\r\n /** Map a span index and local fraction to knot value. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this.knots.spanFractionToKnot(span, localFraction);\r\n }\r\n\r\n /** Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span. */\r\n public evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array) {\r\n if (spanIndex < 0) spanIndex = 0;\r\n if (spanIndex >= this.numSpan) spanIndex = this.numSpan - 1;\r\n const knotIndex0 = spanIndex + this.degree - 1;\r\n const globalKnot = this.knots.baseKnotFractionToKnot(knotIndex0, spanFraction);\r\n return df ?\r\n this.knots.evaluateBasisFunctions1(knotIndex0, globalKnot, f, df, ddf) :\r\n this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);\r\n }\r\n /**\r\n * * Evaluate the basis functions at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer`\r\n * */\r\n public evaluateBuffersInSpan(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n }\r\n /**\r\n * * Evaluate the basis functions and one derivative at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`\r\n * */\r\n public evaluateBuffersInSpan1(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n this.sumPoleBuffer1ForSpan(spanIndex);\r\n }\r\n /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */\r\n public sumPoleBufferForSpan(spanIndex: number) {\r\n this.poleBuffer.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer) {\r\n for (let j = 0; j < this.poleLength; j++) { this.poleBuffer[j] += f * this.packedData[k++]; }\r\n }\r\n }\r\n /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */\r\n public sumPoleBuffer1ForSpan(spanIndex: number) {\r\n this.poleBuffer1.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer1) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer1[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */\r\n public sumPoleBuffer2ForSpan(spanIndex: number) {\r\n this.poleBuffer2.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer2) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer2[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */\r\n public evaluateBuffersAtKnot(u: number, numDerivative: number = 0) {\r\n const knotIndex0 = this.knots.knotToLeftKnotIndex(u);\r\n if (numDerivative < 1) {\r\n this.knots.evaluateBasisFunctions(knotIndex0, u, this.basisBuffer);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n } else if (numDerivative === 1) {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n } else {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1, this.basisBuffer2);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);\r\n }\r\n }\r\n /**\r\n * Reverse the (blocked) poles (in `this.packedData` in place.\r\n */\r\n public reverseInPlace(): void {\r\n // reverse poles in blocks ...\r\n const b = this.poleLength;\r\n const data = this.packedData;\r\n for (let i0 = 0, j0 = b * (this.numPoles - 1);\r\n i0 < j0;\r\n i0 += b, j0 -= b) {\r\n let t = 0;\r\n for (let i = 0; i < b; i++) {\r\n t = data[i0 + i];\r\n data[i0 + i] = data[j0 + i];\r\n data[j0 + i] = t;\r\n }\r\n }\r\n this.knots.reflectKnots();\r\n }\r\n /**\r\n * Test if the leading and trailing polygon coordinates are replicated in the manner of a \"closed\" bspline polygon which has been expanded\r\n * to act as a normal bspline.\r\n * @returns true if `degree` leading and trailing polygon blocks match\r\n */\r\n public testCloseablePolygon(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.knots.wrappable;\r\n const degree = this.degree;\r\n const blockSize = this.poleLength;\r\n const indexDelta = (this.numPoles - this.degree) * blockSize;\r\n const data = this.packedData;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n // expect {degree} matched points.\r\n const numValuesToTest = degree * blockSize;\r\n for (let i0 = 0; i0 < numValuesToTest; i0++) {\r\n if (!Geometry.isSameCoordinate(data[i0], data[i0 + indexDelta]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // no pole conditions are applied.\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /** Insert knot and resulting pole into the instance, optionally multiple times.\r\n * @param knot the knot to be inserted (may already exist in the KnotVector)\r\n * @param totalMultiplicity the total multiplicity of the knot on return\r\n */\r\n public addKnot(knot: number, totalMultiplicity: number): boolean {\r\n if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)\r\n return false; // invalid input\r\n let iLeftKnot = this.knots.knotToLeftKnotIndex(knot);\r\n\r\n // snap input if too close to an existing knot\r\n if (Math.abs(knot - this.knots.knots[iLeftKnot]) < KnotVector.knotTolerance) {\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of bracket\r\n } else if (Math.abs(knot - this.knots.knots[iLeftKnot + 1]) < KnotVector.knotTolerance) {\r\n iLeftKnot += this.knots.getKnotMultiplicityAtIndex(iLeftKnot + 1);\r\n if (iLeftKnot > this.knots.rightKnotIndex)\r\n return true; // nothing to do\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of next bracket\r\n }\r\n const numKnotsToAdd = Math.min(totalMultiplicity, this.degree) - this.knots.getKnotMultiplicity(knot);\r\n if (numKnotsToAdd <= 0)\r\n return true; // nothing to do\r\n\r\n // working arrays and pole buffer\r\n let currKnotCount = this.knots.knots.length;\r\n const newKnots = new Float64Array(currKnotCount + numKnotsToAdd);\r\n for (let i = 0; i < currKnotCount; ++i)\r\n newKnots[i] = this.knots.knots[i];\r\n let currPoleCount = this.numPoles;\r\n const newPackedData = new Float64Array(this.packedData.length + (numKnotsToAdd * this.poleLength));\r\n for (let i = 0; i < this.packedData.length; ++i)\r\n newPackedData[i] = this.packedData[i];\r\n const dataBuf = new Float64Array(this.degree * this.poleLength); // holds degree poles\r\n\r\n // each iteration adds one knot and one pole to the working arrays (cf. Farin 4e)\r\n for (let iter = 0; iter < numKnotsToAdd; ++iter) {\r\n // fill the buffer with new poles obtained from control polygon corner cutting\r\n let iBuf = 0;\r\n const iStart = iLeftKnot - this.degree + 2;\r\n for (let i = iStart; i < iStart + this.degree; ++i) {\r\n const fraction = (knot - newKnots[i - 1]) / (newKnots[i + this.degree - 1] - newKnots[i - 1]);\r\n for (let j = i * this.poleLength; j < (i + 1) * this.poleLength; ++j) {\r\n dataBuf[iBuf++] = Geometry.interpolate(newPackedData[j - this.poleLength], fraction, newPackedData[j]);\r\n }\r\n }\r\n\r\n // overwrite degree-1 poles with degree new poles, shifting tail to the right by one\r\n newPackedData.copyWithin((iStart + this.degree) * this.poleLength, (iStart + this.degree - 1) * this.poleLength, currPoleCount * this.poleLength);\r\n let iData = iStart * this.poleLength;\r\n for (const d of dataBuf)\r\n newPackedData[iData++] = d; // overwrite degree new poles\r\n\r\n // add the knot to newKnots in position, shifting tail to the right by one\r\n newKnots.copyWithin(iLeftKnot + 2, iLeftKnot + 1, currKnotCount);\r\n newKnots[iLeftKnot + 1] = knot;\r\n\r\n ++iLeftKnot;\r\n ++currKnotCount;\r\n ++currPoleCount;\r\n }\r\n this.knots.setKnotsCapture(newKnots);\r\n this.packedData = newPackedData;\r\n return true;\r\n }\r\n}\r\n"]}