@itwin/core-geometry 4.0.0-dev.4 → 4.0.0-dev.41

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 (344) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/lib/cjs/Geometry.d.ts +56 -16
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +87 -30
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/bspline/BSplineCurveOps.js +4 -5
  7. package/lib/cjs/bspline/BSplineCurveOps.js.map +1 -1
  8. package/lib/cjs/bspline/InterpolationCurve3d.js +7 -10
  9. package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
  10. package/lib/cjs/clipping/ClipPrimitive.js +2 -2
  11. package/lib/cjs/clipping/ClipPrimitive.js.map +1 -1
  12. package/lib/cjs/clipping/ClipUtils.js +4 -4
  13. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  14. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  15. package/lib/cjs/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  16. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  17. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +20 -13
  18. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  19. package/lib/cjs/curve/CurveCollection.js +1 -1
  20. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  21. package/lib/cjs/curve/CurveCurve.d.ts +11 -8
  22. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  23. package/lib/cjs/curve/CurveCurve.js +16 -12
  24. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  25. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts +5 -1
  26. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  27. package/lib/cjs/curve/CurveCurveIntersectXY.js +11 -10
  28. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
  29. package/lib/cjs/curve/Loop.d.ts +2 -2
  30. package/lib/cjs/curve/Loop.d.ts.map +1 -1
  31. package/lib/cjs/curve/Loop.js +6 -0
  32. package/lib/cjs/curve/Loop.js.map +1 -1
  33. package/lib/cjs/curve/RegionOps.d.ts +10 -10
  34. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  35. package/lib/cjs/curve/RegionOps.js +11 -11
  36. package/lib/cjs/curve/RegionOps.js.map +1 -1
  37. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +2 -1
  38. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  39. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +5 -2
  40. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  41. package/lib/cjs/curve/StrokeOptions.js +1 -2
  42. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  43. package/lib/cjs/curve/spiral/DirectSpiral3d.js +1 -2
  44. package/lib/cjs/curve/spiral/DirectSpiral3d.js.map +1 -1
  45. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js +1 -2
  46. package/lib/cjs/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  47. package/lib/cjs/geometry3d/Angle.d.ts +19 -0
  48. package/lib/cjs/geometry3d/Angle.d.ts.map +1 -1
  49. package/lib/cjs/geometry3d/Angle.js +39 -0
  50. package/lib/cjs/geometry3d/Angle.js.map +1 -1
  51. package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -0
  52. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  53. package/lib/cjs/geometry3d/AngleSweep.js +1 -0
  54. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  55. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +195 -8
  56. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  57. package/lib/cjs/geometry3d/BarycentricTriangle.js +459 -11
  58. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  59. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  60. package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  61. package/lib/cjs/geometry3d/CoincidentGeometryOps.js +3 -0
  62. package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
  63. package/lib/cjs/geometry3d/GrowableFloat64Array.js +2 -2
  64. package/lib/cjs/geometry3d/GrowableFloat64Array.js.map +1 -1
  65. package/lib/cjs/geometry3d/GrowableXYArray.d.ts +1 -1
  66. package/lib/cjs/geometry3d/GrowableXYArray.d.ts.map +1 -1
  67. package/lib/cjs/geometry3d/GrowableXYArray.js +2 -2
  68. package/lib/cjs/geometry3d/GrowableXYArray.js.map +1 -1
  69. package/lib/cjs/geometry3d/GrowableXYZArray.js +1 -1
  70. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  71. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts +22 -7
  72. package/lib/cjs/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  73. package/lib/cjs/geometry3d/IndexedXYCollection.js +41 -5
  74. package/lib/cjs/geometry3d/IndexedXYCollection.js.map +1 -1
  75. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +58 -4
  76. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  77. package/lib/cjs/geometry3d/IndexedXYZCollection.js +102 -4
  78. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  79. package/lib/cjs/geometry3d/Matrix3d.d.ts +479 -265
  80. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  81. package/lib/cjs/geometry3d/Matrix3d.js +996 -784
  82. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  83. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts +1 -0
  84. package/lib/cjs/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  85. package/lib/cjs/geometry3d/OrderedRotationAngles.js +1 -0
  86. package/lib/cjs/geometry3d/OrderedRotationAngles.js.map +1 -1
  87. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  88. package/lib/cjs/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  89. package/lib/cjs/geometry3d/Point2dArrayCarrier.js +14 -0
  90. package/lib/cjs/geometry3d/Point2dArrayCarrier.js.map +1 -1
  91. package/lib/cjs/geometry3d/Point2dVector2d.js +4 -6
  92. package/lib/cjs/geometry3d/Point2dVector2d.js.map +1 -1
  93. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  94. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  95. package/lib/cjs/geometry3d/Point3dArrayCarrier.js +0 -6
  96. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  97. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +57 -57
  98. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  99. package/lib/cjs/geometry3d/Point3dVector3d.js +63 -65
  100. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  101. package/lib/cjs/geometry3d/PointHelpers.d.ts +14 -1
  102. package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
  103. package/lib/cjs/geometry3d/PointHelpers.js +33 -1
  104. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  105. package/lib/cjs/geometry3d/PolygonOps.d.ts +127 -19
  106. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  107. package/lib/cjs/geometry3d/PolygonOps.js +420 -22
  108. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  109. package/lib/cjs/geometry3d/Ray3d.js +1 -1
  110. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  111. package/lib/cjs/geometry3d/Segment1d.d.ts +1 -1
  112. package/lib/cjs/geometry3d/Segment1d.js +1 -1
  113. package/lib/cjs/geometry3d/Segment1d.js.map +1 -1
  114. package/lib/cjs/numerics/Polynomials.d.ts +12 -0
  115. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  116. package/lib/cjs/numerics/Polynomials.js +14 -0
  117. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  118. package/lib/cjs/polyface/AuxData.js +1 -1
  119. package/lib/cjs/polyface/AuxData.js.map +1 -1
  120. package/lib/cjs/polyface/FacetLocationDetail.d.ts +264 -0
  121. package/lib/cjs/polyface/FacetLocationDetail.d.ts.map +1 -0
  122. package/lib/cjs/polyface/FacetLocationDetail.js +376 -0
  123. package/lib/cjs/polyface/FacetLocationDetail.js.map +1 -0
  124. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  125. package/lib/cjs/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  126. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js +5 -2
  127. package/lib/cjs/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  128. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +24 -14
  129. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  130. package/lib/cjs/polyface/PolyfaceBuilder.js +74 -23
  131. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  132. package/lib/cjs/polyface/PolyfaceClip.js +6 -7
  133. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  134. package/lib/cjs/polyface/PolyfaceData.d.ts +1 -1
  135. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  136. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  137. package/lib/cjs/polyface/PolyfaceQuery.d.ts +76 -1
  138. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  139. package/lib/cjs/polyface/PolyfaceQuery.js +123 -3
  140. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  141. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts +202 -0
  142. package/lib/cjs/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -0
  143. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js +1038 -0
  144. package/lib/cjs/polyface/multiclip/OffsetMeshContext.js.map +1 -0
  145. package/lib/cjs/serialization/BGFBReader.js +4 -4
  146. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  147. package/lib/cjs/serialization/GeometrySamples.d.ts +8 -6
  148. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  149. package/lib/cjs/serialization/GeometrySamples.js +26 -19
  150. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  151. package/lib/cjs/serialization/IModelJsonSchema.js +1 -2
  152. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  153. package/lib/cjs/solid/Sphere.d.ts +5 -5
  154. package/lib/cjs/solid/Sphere.js +5 -5
  155. package/lib/cjs/solid/Sphere.js.map +1 -1
  156. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  157. package/lib/cjs/solid/SweepContour.js +8 -1
  158. package/lib/cjs/solid/SweepContour.js.map +1 -1
  159. package/lib/cjs/topology/Graph.d.ts +113 -7
  160. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  161. package/lib/cjs/topology/Graph.js +185 -7
  162. package/lib/cjs/topology/Graph.js.map +1 -1
  163. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts +38 -0
  164. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts.map +1 -0
  165. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.js +82 -0
  166. package/lib/cjs/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -0
  167. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +2 -1
  168. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  169. package/lib/cjs/topology/HalfEdgeGraphSearch.js +1 -0
  170. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  171. package/lib/cjs/topology/Triangulation.js +1 -1
  172. package/lib/cjs/topology/Triangulation.js.map +1 -1
  173. package/lib/esm/Geometry.d.ts +56 -16
  174. package/lib/esm/Geometry.d.ts.map +1 -1
  175. package/lib/esm/Geometry.js +86 -29
  176. package/lib/esm/Geometry.js.map +1 -1
  177. package/lib/esm/bspline/BSplineCurveOps.js +4 -5
  178. package/lib/esm/bspline/BSplineCurveOps.js.map +1 -1
  179. package/lib/esm/bspline/InterpolationCurve3d.js +7 -10
  180. package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
  181. package/lib/esm/clipping/ClipPrimitive.js +2 -2
  182. package/lib/esm/clipping/ClipPrimitive.js.map +1 -1
  183. package/lib/esm/clipping/ClipUtils.js +4 -4
  184. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  185. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js +2 -2
  186. package/lib/esm/clipping/internalContexts/LineStringOffsetClipperContext.js.map +1 -1
  187. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  188. package/lib/esm/curve/CurveChainWithDistanceIndex.js +21 -14
  189. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  190. package/lib/esm/curve/CurveCollection.js +1 -1
  191. package/lib/esm/curve/CurveCollection.js.map +1 -1
  192. package/lib/esm/curve/CurveCurve.d.ts +11 -8
  193. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  194. package/lib/esm/curve/CurveCurve.js +16 -12
  195. package/lib/esm/curve/CurveCurve.js.map +1 -1
  196. package/lib/esm/curve/CurveCurveIntersectXY.d.ts +5 -1
  197. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
  198. package/lib/esm/curve/CurveCurveIntersectXY.js +11 -10
  199. package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
  200. package/lib/esm/curve/Loop.d.ts +2 -2
  201. package/lib/esm/curve/Loop.d.ts.map +1 -1
  202. package/lib/esm/curve/Loop.js +6 -0
  203. package/lib/esm/curve/Loop.js.map +1 -1
  204. package/lib/esm/curve/RegionOps.d.ts +10 -10
  205. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  206. package/lib/esm/curve/RegionOps.js +11 -11
  207. package/lib/esm/curve/RegionOps.js.map +1 -1
  208. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +2 -1
  209. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  210. package/lib/esm/curve/RegionOpsClassificationSweeps.js +5 -2
  211. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  212. package/lib/esm/curve/StrokeOptions.js +1 -2
  213. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  214. package/lib/esm/curve/spiral/DirectSpiral3d.js +1 -2
  215. package/lib/esm/curve/spiral/DirectSpiral3d.js.map +1 -1
  216. package/lib/esm/curve/spiral/IntegratedSpiral3d.js +1 -2
  217. package/lib/esm/curve/spiral/IntegratedSpiral3d.js.map +1 -1
  218. package/lib/esm/geometry3d/Angle.d.ts +19 -0
  219. package/lib/esm/geometry3d/Angle.d.ts.map +1 -1
  220. package/lib/esm/geometry3d/Angle.js +39 -0
  221. package/lib/esm/geometry3d/Angle.js.map +1 -1
  222. package/lib/esm/geometry3d/AngleSweep.d.ts +1 -0
  223. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  224. package/lib/esm/geometry3d/AngleSweep.js +1 -0
  225. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  226. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +195 -8
  227. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  228. package/lib/esm/geometry3d/BarycentricTriangle.js +459 -12
  229. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  230. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +1 -0
  231. package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
  232. package/lib/esm/geometry3d/CoincidentGeometryOps.js +3 -0
  233. package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
  234. package/lib/esm/geometry3d/GrowableFloat64Array.js +2 -2
  235. package/lib/esm/geometry3d/GrowableFloat64Array.js.map +1 -1
  236. package/lib/esm/geometry3d/GrowableXYArray.d.ts +1 -1
  237. package/lib/esm/geometry3d/GrowableXYArray.d.ts.map +1 -1
  238. package/lib/esm/geometry3d/GrowableXYArray.js +2 -2
  239. package/lib/esm/geometry3d/GrowableXYArray.js.map +1 -1
  240. package/lib/esm/geometry3d/GrowableXYZArray.js +1 -1
  241. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  242. package/lib/esm/geometry3d/IndexedXYCollection.d.ts +22 -7
  243. package/lib/esm/geometry3d/IndexedXYCollection.d.ts.map +1 -1
  244. package/lib/esm/geometry3d/IndexedXYCollection.js +41 -5
  245. package/lib/esm/geometry3d/IndexedXYCollection.js.map +1 -1
  246. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +58 -4
  247. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  248. package/lib/esm/geometry3d/IndexedXYZCollection.js +103 -5
  249. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  250. package/lib/esm/geometry3d/Matrix3d.d.ts +479 -265
  251. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  252. package/lib/esm/geometry3d/Matrix3d.js +996 -784
  253. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  254. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts +1 -0
  255. package/lib/esm/geometry3d/OrderedRotationAngles.d.ts.map +1 -1
  256. package/lib/esm/geometry3d/OrderedRotationAngles.js +1 -0
  257. package/lib/esm/geometry3d/OrderedRotationAngles.js.map +1 -1
  258. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts +10 -0
  259. package/lib/esm/geometry3d/Point2dArrayCarrier.d.ts.map +1 -1
  260. package/lib/esm/geometry3d/Point2dArrayCarrier.js +14 -0
  261. package/lib/esm/geometry3d/Point2dArrayCarrier.js.map +1 -1
  262. package/lib/esm/geometry3d/Point2dVector2d.js +4 -6
  263. package/lib/esm/geometry3d/Point2dVector2d.js.map +1 -1
  264. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts +0 -6
  265. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  266. package/lib/esm/geometry3d/Point3dArrayCarrier.js +0 -6
  267. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  268. package/lib/esm/geometry3d/Point3dVector3d.d.ts +57 -57
  269. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  270. package/lib/esm/geometry3d/Point3dVector3d.js +63 -65
  271. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  272. package/lib/esm/geometry3d/PointHelpers.d.ts +14 -1
  273. package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
  274. package/lib/esm/geometry3d/PointHelpers.js +33 -1
  275. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  276. package/lib/esm/geometry3d/PolygonOps.d.ts +127 -19
  277. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  278. package/lib/esm/geometry3d/PolygonOps.js +419 -22
  279. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  280. package/lib/esm/geometry3d/Ray3d.js +1 -1
  281. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  282. package/lib/esm/geometry3d/Segment1d.d.ts +1 -1
  283. package/lib/esm/geometry3d/Segment1d.js +1 -1
  284. package/lib/esm/geometry3d/Segment1d.js.map +1 -1
  285. package/lib/esm/numerics/Polynomials.d.ts +12 -0
  286. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  287. package/lib/esm/numerics/Polynomials.js +14 -0
  288. package/lib/esm/numerics/Polynomials.js.map +1 -1
  289. package/lib/esm/polyface/AuxData.js +1 -1
  290. package/lib/esm/polyface/AuxData.js.map +1 -1
  291. package/lib/esm/polyface/FacetLocationDetail.d.ts +264 -0
  292. package/lib/esm/polyface/FacetLocationDetail.d.ts.map +1 -0
  293. package/lib/esm/polyface/FacetLocationDetail.js +369 -0
  294. package/lib/esm/polyface/FacetLocationDetail.js.map +1 -0
  295. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts +2 -5
  296. package/lib/esm/polyface/IndexedPolyfaceVisitor.d.ts.map +1 -1
  297. package/lib/esm/polyface/IndexedPolyfaceVisitor.js +5 -2
  298. package/lib/esm/polyface/IndexedPolyfaceVisitor.js.map +1 -1
  299. package/lib/esm/polyface/PolyfaceBuilder.d.ts +24 -14
  300. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  301. package/lib/esm/polyface/PolyfaceBuilder.js +74 -23
  302. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  303. package/lib/esm/polyface/PolyfaceClip.js +6 -7
  304. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  305. package/lib/esm/polyface/PolyfaceData.d.ts +1 -1
  306. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  307. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  308. package/lib/esm/polyface/PolyfaceQuery.d.ts +76 -1
  309. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  310. package/lib/esm/polyface/PolyfaceQuery.js +121 -2
  311. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  312. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts +202 -0
  313. package/lib/esm/polyface/multiclip/OffsetMeshContext.d.ts.map +1 -0
  314. package/lib/esm/polyface/multiclip/OffsetMeshContext.js +1032 -0
  315. package/lib/esm/polyface/multiclip/OffsetMeshContext.js.map +1 -0
  316. package/lib/esm/serialization/BGFBReader.js +4 -4
  317. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  318. package/lib/esm/serialization/GeometrySamples.d.ts +8 -6
  319. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  320. package/lib/esm/serialization/GeometrySamples.js +26 -19
  321. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  322. package/lib/esm/serialization/IModelJsonSchema.js +1 -2
  323. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  324. package/lib/esm/solid/Sphere.d.ts +5 -5
  325. package/lib/esm/solid/Sphere.js +5 -5
  326. package/lib/esm/solid/Sphere.js.map +1 -1
  327. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  328. package/lib/esm/solid/SweepContour.js +8 -1
  329. package/lib/esm/solid/SweepContour.js.map +1 -1
  330. package/lib/esm/topology/Graph.d.ts +113 -7
  331. package/lib/esm/topology/Graph.d.ts.map +1 -1
  332. package/lib/esm/topology/Graph.js +185 -7
  333. package/lib/esm/topology/Graph.js.map +1 -1
  334. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts +38 -0
  335. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.d.ts.map +1 -0
  336. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.js +78 -0
  337. package/lib/esm/topology/HalfEdgeGraphFromIndexedLoopsContext.js.map +1 -0
  338. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +2 -1
  339. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  340. package/lib/esm/topology/HalfEdgeGraphSearch.js +1 -0
  341. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  342. package/lib/esm/topology/Triangulation.js +1 -1
  343. package/lib/esm/topology/Triangulation.js.map +1 -1
  344. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"RegionOpsClassificationSweeps.js","sourceRoot":"","sources":["../../../src/curve/RegionOpsClassificationSweeps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAAgG;AAChG,yEAAsE;AACtE,iDAAyD;AACzD,+DAAmE;AAEnE,2CAAqF;AACrF,iDAA8C;AAC9C,iCAA8B;AAE9B,6CAA0C;AAC1C,iEAA8D;AAC9D,0CAAuC;AAEvC,+CAA4C;AAC5C,+DAA4D;AAE5D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AC,CAAC;SACjC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB;YACnB,gBAAgB,GAAG,yCAAmB,CAAC,cAAc,CAAC;QACxD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YAC1B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1C;IACH,CAAC;CACF;AAlCD,wCAkCC;AACD;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAoB,KAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAoB,EAAE,kBAA6D;QACtG,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,yCAAmB,CAAC,iDAAiD,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;YACrD,SAAS,CAAC,aAAa,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;YACxE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjBD,kDAiBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, NodeToNumberFunction } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../topology/Merging\";\r\nimport { RegularizationContext } from \"../topology/RegularizeFace\";\r\nimport { MultiLineStringDataVariant } from \"../topology/Triangulation\";\r\nimport { GraphCheckPointFunction, RegionBinaryOpType, RegionOps } from \"./RegionOps\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Loop } from \"./Loop\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AnyRegion } from \"./CurveChain\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { Arc3d } from \"./Arc3d\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\n\r\n/**\r\n * base class for callbacks during region sweeps.\r\n * * At start of a component, `startComponent(node)` is called announcing a representative node on the outermost face.\r\n * * A Component in this usage is a component that is edge connected when ignoring \"exterior bridge edges\".\r\n * * As each face is entered, `enterFace(facePathStack, newFaceNode)` is called\r\n * * facePathStack[0] is the outermost node of the path from the outer face.\r\n * * facePathStack[1] is its inside mate.\r\n * * facePathStack[2k] is the outside node at crossing to face at depth k.\r\n * * facePathStack[2k+1] is the node where face at depth k was entered.\r\n * * newFaceNode is the entry node (redundant of stack tip)\r\n * * On retreat from a face, `leaveFace(facePathStack, faceNode)` is called.\r\n * * At end of component, `finishComponent (node)` is called.\r\n * * The base class is fully implemented to do nothing during the sweep.\r\n * @internal\r\n */\r\nabstract class RegionOpsFaceToFaceSearchCallbacks {\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce face entry */\r\n public enterFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n}\r\n/** Function signature to test if a pair of boolean states is to be accepted by area booleans (during face-to-face sweeps)\r\n * @internal\r\n */\r\ntype BinaryBooleanAcceptFunction = (stateA: boolean, stateB: boolean) => boolean;\r\n/** Function signature ot announce classification of a face.\r\n * The `faceType` parameters are\r\n * * -1 for a fully exterior face. This is a negative area face.\r\n * * 0 for a positive area face classified as \"out\" for the boolean.\r\n * * 1 for a positive area face classified as \"in\" for the boolean.\r\n */\r\ntype AnnounceClassifiedFace = (graph: HalfEdgeGraph, faceSeed: HalfEdge, faceType: -1 | 0 | 1, area: number) => void;\r\n/**\r\n * Implementation of `RegionOpsFaceToFaceSearchCallbacks` for binary boolean sweep with polygonal regions.\r\n * * For this linear-boundary case the boundary geometry is carried entirely from the coordinates in the half edges.\r\n * * This assumes the each node in the graph has edgeTag set to:\r\n * * `edgeTag === undefined` if the edge crossing does not change classification.\r\n * * for example, an edge added by regularization\r\n * * `edgeTag === 1` if this is a boundary for the first of the boolean input regions\r\n * * `edgeTag === 2` if this is a boundary for the second of the boolean input regions\r\n * * constructor\r\n * * takes caller-supplied function to decide whether to accept a face given its state relative to the two boolean terms.\r\n * * sets the in/out status of both terms to false.\r\n * * `startComponent` marks the entire outer face as `EXTERIOR`\r\n * * `enterFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * ask the faceAcceptFunction if the current term states combine to in/out for the result\r\n * * if out, set the `EXTERIOR` mask around the face.\r\n * * `leaveFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * `finishComponent` is not reimplemented.\r\n * @internal\r\n */\r\nclass RegionOpsBinaryBooleanSweepCallbacks extends RegionOpsFaceToFaceSearchCallbacks {\r\n private _faceSelectFunction: BinaryBooleanAcceptFunction;\r\n private _inComponent: boolean[];\r\n private _exteriorMask: HalfEdgeMask;\r\n public constructor(acceptFaceFunction: BinaryBooleanAcceptFunction, exteriorMask: HalfEdgeMask) {\r\n super();\r\n this._inComponent = [false, false, false]; // entry 0 is never reused.\r\n this._exteriorMask = exteriorMask;\r\n this._faceSelectFunction = acceptFaceFunction;\r\n }\r\n /** Mark this face as exterior */\r\n public override startComponent(node: HalfEdge): boolean { node.setMaskAroundFace(this._exteriorMask); return true; }\r\n /**\r\n * * If necessary, toggle a term state.\r\n * * if indicated, mark this face exterior.\r\n */\r\n public override enterFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n if (!this._faceSelectFunction(this._inComponent[1], this._inComponent[2]))\r\n node.setMaskAroundFace(this._exteriorMask);\r\n return true;\r\n }\r\n /**\r\n * * If necessary, toggle a term state.\r\n */\r\n public override leaveFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n return true;\r\n }\r\n}\r\n/**\r\n * Low level graph search for face classification.\r\n * @internal\r\n */\r\nexport class RegionOpsFaceToFaceSearch {\r\n /**\r\n * run a DFS with face-to-face step announcements.\r\n * * false return from any function terminates search immediately.\r\n * * all reachable nodes assumed to have both visit masks clear.\r\n * @param graph containing graph.\r\n * @param seed first node to visit.\r\n * @param faceHasBeenVisited mask marking faces that have been seen.\r\n * @param nodeHasBeenVisited mask marking node-to-node step around face.\r\n *\r\n */\r\n public static faceToFaceSearchFromOuterLoop(_graph: HalfEdgeGraph, seed: HalfEdge, faceHasBeenVisited: HalfEdgeMask, nodeHasBeenVisited: HalfEdgeMask, callbacks: RegionOpsFaceToFaceSearchCallbacks) {\r\n if (seed.isMaskSet(faceHasBeenVisited))\r\n return;\r\n if (!callbacks.startComponent(seed))\r\n return;\r\n const facePathStack = [];\r\n seed.setMaskAroundFace(faceHasBeenVisited);\r\n let faceWalker = seed;\r\n do {\r\n let entryNode = faceWalker;\r\n let mate = faceWalker.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n // the faceWalker seed is always on the base of the stack.\r\n // the stack then contains even-odd pairs of (entryNode, currentNode)\r\n // * entryNode is the node where a face was entered.\r\n // * faceNode is another node around that face.\r\n facePathStack.push(faceWalker);\r\n facePathStack.push(mate);\r\n let faceNode = mate.faceSuccessor;\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n entryNode = mate;\r\n if (callbacks.enterFace(facePathStack, mate)) {\r\n for (; ;) {\r\n mate = faceNode.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n if (!callbacks.enterFace(facePathStack, mate))\r\n return;\r\n facePathStack.push(faceNode);\r\n facePathStack.push(mate);\r\n faceNode = mate;\r\n entryNode = mate;\r\n }\r\n faceNode.setMask(nodeHasBeenVisited);\r\n faceNode = faceNode.faceSuccessor;\r\n if (faceNode === entryNode) {\r\n callbacks.leaveFace(facePathStack, faceNode);\r\n if (facePathStack.length <= 2) {\r\n break;\r\n }\r\n facePathStack.pop();\r\n faceNode = facePathStack[facePathStack.length - 1];\r\n facePathStack.pop();\r\n entryNode = facePathStack[facePathStack.length - 1];\r\n }\r\n if (faceNode.isMaskSet(nodeHasBeenVisited)) {\r\n // this is disaster !!!\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n // continue at outermost level .....\r\n faceWalker = faceWalker.faceSuccessor;\r\n } while (faceWalker !== seed);\r\n callbacks.finishComponent(seed);\r\n }\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * Each of the binary input terms is a collection of loops\r\n * * Within the binary term, in/out is determined by edge-crossing parity rules.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with 1 or 2 as binary term identifier.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n */\r\n public static doPolygonBoolean(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, faceSelectFunction: (inA: boolean, inB: boolean) => boolean, graphCheckPoint?: GraphCheckPointFunction): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const seedA = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsA, baseMask, 1);\r\n const seedB = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsB, baseMask, 2);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"unmerged loops\", graph, \"U\");\r\n if (seedA || seedB) {\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After splitIntersectingEdges\", graph, \"S\");\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After clusterAndMergeXYTheta\", graph, \"M\");\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After regularize\", graph, \"MR\");\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(graph);\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const faceVisitedMask = graph.grabMask();\r\n const nodeVisitedMask = graph.grabMask();\r\n const allMasksToClear = exteriorMask | faceVisitedMask | nodeVisitedMask;\r\n graph.clearMask(allMasksToClear);\r\n const callbacks = new RegionOpsBinaryBooleanSweepCallbacks(faceSelectFunction, exteriorMask);\r\n this.faceToFaceSearchFromOuterLoop(graph, exteriorHalfEdge, faceVisitedMask, nodeVisitedMask, callbacks);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After faceToFaceSearchFromOuterLoop\", graph, \"MRX\");\r\n graph.dropMask(faceVisitedMask);\r\n graph.dropMask(nodeVisitedMask);\r\n return graph;\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * the manyLoopsAndParitySets input is an array.\r\n * * Each entry is one or more loops.\r\n * * An entry that is \"just points\" is a simple loop.\r\n * * An entry that is itself an array of arrays of points is a set of loops with \"parity\" -- relation:\r\n * * typically the first is an outer loop an others are holes.\r\n * * but if there is self intersection or multiple outer loops, parity rules are applied to decide inner and outer.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with index to the outer array.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n * * assign inside/outside by parity within each set and overall union.\r\n */\r\n public static doBinaryBooleanBetweenMultiLoopInputs(\r\n dataA: MultiLineStringDataVariant[],\r\n opA: RegionGroupOpType,\r\n binaryOp: RegionBinaryOpType,\r\n dataB: MultiLineStringDataVariant[],\r\n opB: RegionGroupOpType,\r\n purgeSliverExteriorFaces: boolean\r\n ): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const callbacks = RegionBooleanContext.create(opA, opB);\r\n callbacks.graph = graph;\r\n callbacks.faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n\r\n // Add all the members in groupA ..\r\n for (const data of dataA) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupA);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n for (const data of dataB) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupB);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n callbacks.runClassificationSweep(binaryOp);\r\n if (purgeSliverExteriorFaces)\r\n callbacks.unmaskMaskedNullFaces(HalfEdgeMask.EXTERIOR);\r\n return graph;\r\n }\r\n}\r\n\r\n/**\r\n * Enumeration of operation types \"within a group operand\" for a `RegionBooleanContext`.\r\n * @internal\r\n */\r\nexport enum RegionGroupOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n NonBounding = -1,\r\n}\r\n/**\r\n * Each loop or parity region in a `RegionBooleanContext` is recorded as a `RegionGroupMember`, which carries\r\n * * the Loop or parityRegion object\r\n * * a numeric indication of the sweep state (parity) during the classification search.\r\n * * a reference to the parent group (which in turn leads back to the `RegionBooleanContext`)\r\n * @internal\r\n */\r\nclass RegionGroupMember {\r\n public region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant;\r\n public sweepState: number;\r\n public parentGroup: RegionGroup;\r\n public constructor(region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant, parentGroup: RegionGroup) {\r\n this.region = region;\r\n this.parentGroup = parentGroup;\r\n this.sweepState = 0;\r\n }\r\n public clearState() { this.sweepState = 0; }\r\n}\r\n/**\r\n * A `RegionGroup` is\r\n * * An array of `RegionGroupMembers`, carrying the regions of the Ai or Bi part of the boolean expression.\r\n * * The `RegionGroupOpType` to be applied among those members.\r\n * * Pointer to the containing context\r\n * * The count of number of regions known to be \"in\" as the search progresses.\r\n * @internal\r\n */\r\nexport class RegionGroup {\r\n public members: RegionGroupMember[];\r\n public groupOpType: RegionGroupOpType;\r\n public parent: RegionBooleanContext;\r\n private _numIn: number;\r\n public constructor(parent: RegionBooleanContext, groupOpType: RegionGroupOpType) {\r\n this.members = [];\r\n this.parent = parent;\r\n this.groupOpType = groupOpType;\r\n this._numIn = 0;\r\n }\r\n /** deep clear of state data -- group header plus all members */\r\n public clearState() {\r\n for (const member of this.members)\r\n member.clearState();\r\n this._numIn = 0;\r\n }\r\n public range(): Range3d {\r\n const range = Range3d.createNull();\r\n for (const m of this.members) {\r\n if (m.region instanceof GeometryQuery)\r\n m.region.extendRange(range);\r\n else {\r\n const range1 = Range3d.createFromVariantData(m.region);\r\n range.extendRange(range1);\r\n }\r\n }\r\n return range;\r\n }\r\n /** Ask if the current _numIn count qualifies as an \"in\" for this operation type.\r\n */\r\n public getInOut(): boolean {\r\n // UNION is true if one or more members are IN\r\n if (this.groupOpType === RegionGroupOpType.Union)\r\n return this._numIn > 0;\r\n // PARITY is true if an odd number of regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Parity)\r\n return Geometry.isOdd(this._numIn);\r\n // INTERSECTION is true if ALL the regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Intersection)\r\n return this._numIn === this.members.length;\r\n return false;\r\n }\r\n // push new members into the group.\r\n public addMember(data: AnyRegion | AnyRegion[] | LineSegment3d | undefined, allowLineSegment: boolean = false) {\r\n if (data instanceof Loop || data instanceof ParityRegion) {\r\n const cleanerData = data.clone() as (ParityRegion | Loop);\r\n RegionOps.consolidateAdjacentPrimitives(cleanerData);\r\n this.members.push(new RegionGroupMember(cleanerData, this));\r\n } else if (data instanceof UnionRegion) {\r\n for (const child of data.children) {\r\n this.addMember(child);\r\n }\r\n } else if (Array.isArray(data)) {\r\n for (const item of data) {\r\n this.addMember(item);\r\n }\r\n } else if (allowLineSegment && data instanceof LineSegment3d) {\r\n this.members.push(new RegionGroupMember(data, this));\r\n\r\n }\r\n }\r\n // update the \"in\" count _numIn according to old and new states (parity counts) for some member region.\r\n public recordMemberStateChange(oldState: number, newState: number) {\r\n const oldIn = Geometry.isOdd(oldState);\r\n const newIn = Geometry.isOdd(newState);\r\n if (!oldIn && newIn)\r\n this._numIn++;\r\n else if (oldIn && !newIn)\r\n this._numIn--;\r\n }\r\n}\r\n/**\r\n * A `RegionBooleanContext` carries structure and operations for binary operations between two sets of regions.\r\n * * In the binary operation OP (union, intersection, parity, difference), the left and right operands\r\n * are each a composite union, difference, or parity among multiple inputs, i.e.\r\n * * (operationA among Ai) OP (operationB among Bi)\r\n * * where the Ai are one set of regions, being combined by operationA\r\n * * and the Bi are the another set of regions, being combined by operationB\r\n * * Each group of Ai and Bi is a `RegionGroup`\r\n * * This is an extremely delicate structure.\r\n * * Members are public because of the unique variety of queries, but should only be used for queries.\r\n * * The graph and curves in the booleans are connected by an extended pointer chain:\r\n * * (HalfEdge in Graph).edgeTag points to a CurveLocationDetail\r\n * * (CurveLocationDetail).curve points to a curve\r\n * * (Curve).parent points to RegionGroupMember\r\n * * (RegionGroupMember) points to RegionGroup\r\n * * (RegionGroup) points to RegionBooleanBinaryContext\r\n * * So..when a graph sweep crosses an edge,\r\n * * the chain leads to a parity count in the RegionGroupMember\r\n * * that can change the number of members active in the RegionGroup\r\n * * which can change the state of the context.\r\n * @internal\r\n */\r\nexport class RegionBooleanContext implements RegionOpsFaceToFaceSearchCallbacks {\r\n public groupA!: RegionGroup;\r\n public groupB!: RegionGroup;\r\n public extraGeometry!: RegionGroup;\r\n public graph!: HalfEdgeGraph;\r\n public faceAreaFunction!: NodeToNumberFunction;\r\n public binaryOp: RegionBinaryOpType;\r\n\r\n private constructor(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType) {\r\n this.groupA = new RegionGroup(this, groupTypeA);\r\n this.groupB = new RegionGroup(this, groupTypeB);\r\n this.extraGeometry = new RegionGroup(this, RegionGroupOpType.NonBounding);\r\n this.binaryOp = RegionBinaryOpType.Union; // it will be revised on can calls.\r\n }\r\n /**\r\n * Create a context with both A and B groups empty.\r\n * * Caller follows up by calls to `context.groupA.addMember (loopOrParityRegion)` or `context.groupB.addMember (loopOrParityRegion)`\r\n * @param groupTypeA\r\n * @param groupTypeB\r\n */\r\n public static create(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType): RegionBooleanContext {\r\n return new RegionBooleanContext(groupTypeA, groupTypeB);\r\n }\r\n public addMembers(dataA: AnyRegion | AnyRegion[] | undefined, dataB: AnyRegion | AnyRegion[] | undefined) {\r\n this.groupA.addMember(dataA);\r\n this.groupB.addMember(dataB);\r\n // const doConnectives = 1;\r\n // if (doConnectives !== 0)\r\n this.addConnectives();\r\n }\r\n\r\n private _workSegment?: LineSegment3d;\r\n private static _bridgeDirection = Vector3d.createNormalized(1.0, -0.12328974132467)!; // magic unit direction to minimize vertex hits\r\n /**\r\n * The sweep operations require access to all geometry by edge crossings and face walk.\r\n * If input loops are non-overlapping, there may be disconnected islands not reachable.\r\n * This method:\r\n * * finds the total range\r\n * * creates parallel rays from the extreme point of each loop and extending beyond the overall range\r\n * * places those lines in the extraGeometry group\r\n */\r\n public addConnectives() {\r\n const rangeA = this.groupA.range();\r\n const rangeB = this.groupB.range();\r\n const rangeAB = rangeA.union(rangeB);\r\n const areaTol = RegionOps.computeXYAreaTolerance(rangeAB);\r\n let margin = 0.1;\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(rangeAB.corners(), RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n margin *= this._workSegment.point0Ref.distanceXY(this._workSegment.point1Ref); // how much further to extend each bridge ray\r\n\r\n const maxPoints: Point3d[] = [];\r\n const findExtremePointsInLoop = (region: Loop) => {\r\n const area = RegionOps.computeXYArea(region);\r\n if (area === undefined || Math.abs(area) < areaTol)\r\n return; // avoid bridging trivial faces\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(region, RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n maxPoints.push(this._workSegment.point1Ref);\r\n };\r\n\r\n for (const groupMembers of [this.groupA.members, this.groupB.members]) {\r\n for (const m of groupMembers) {\r\n if (m.region instanceof Loop) {\r\n findExtremePointsInLoop(m.region);\r\n } else if (m.region instanceof ParityRegion) {\r\n for (const loop of m.region.children)\r\n findExtremePointsInLoop(loop);\r\n }\r\n }\r\n }\r\n\r\n const ray = Ray3d.createZero();\r\n for (const p of maxPoints) {\r\n // Make a line from...\r\n // 1) exactly the max point of the loops to\r\n // 2) a point clearly outside the big range\r\n // If p came from some inner loop this will...\r\n // 1) create a bridge from the inner loop through any containing loops (always)\r\n // 2) avoid crossing any containing loop at a vertex. (with high probability, but not absolutely always)\r\n const bridgeLength = margin + Ray3d.create(p, RegionBooleanContext._bridgeDirection, ray).intersectionWithRange3d(rangeAB).high;\r\n const outside = Point3d.createAdd2Scaled(p, 1.0, RegionBooleanContext._bridgeDirection, bridgeLength);\r\n const bridgeLine = LineSegment3d.createXYXY(p.x, p.y, outside.x, outside.y);\r\n this.extraGeometry.addMember(bridgeLine, true);\r\n }\r\n }\r\n\r\n /**\r\n * Markup and assembly steps for geometry in the RegionGroups.\r\n * * Annotate connection from group to curves.\r\n * * groups with point data but no curves get no further annotation.\r\n * * compute intersections.\r\n * * assemble and merge the HalfEdgeGraph.\r\n */\r\n public annotateAndMergeCurvesInGraph() {\r\n const allPrimitives: CurvePrimitive[] = [];\r\n // ASSUME loops have fine-grained types -- no linestrings !!\r\n for (const group of [this.groupA, this.groupB, this.extraGeometry]) {\r\n for (const member of group.members) {\r\n let k = allPrimitives.length;\r\n if (member.region instanceof GeometryQuery) {\r\n RegionOps.collectCurvePrimitives(member.region, allPrimitives, true, true);\r\n for (; k < allPrimitives.length; k++)\r\n allPrimitives[k].parent = member;\r\n }\r\n }\r\n }\r\n // const range = RegionOps.curveArrayRange(allPrimitives);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(allPrimitives, intersections);\r\n this.graph = graph;\r\n this.faceAreaFunction = faceAreaFromCurvedEdgeData;\r\n }\r\n private _announceFaceFunction?: AnnounceClassifiedFace;\r\n /**\r\n * Sweep through the graph to assign in/out classifications to all faces.\r\n * * the classification is announced in two ways:\r\n * * the EXTERNAL mask is set on all half edges that are NOT interior faces.\r\n * * the announceFaceFunction is called once for each face.\r\n * @param binaryOp\r\n * @param announceFaceFunction\r\n */\r\n public runClassificationSweep(\r\n binaryOp: RegionBinaryOpType,\r\n announceFaceFunction?: AnnounceClassifiedFace) {\r\n this._announceFaceFunction = announceFaceFunction;\r\n this.binaryOp = binaryOp;\r\n this.graph.clearMask(HalfEdgeMask.EXTERIOR);\r\n for (const group of [this.groupA, this.groupB]) {\r\n group.clearState();\r\n }\r\n const faceHasBeenVisitedMask = this.graph.grabMask();\r\n const nodeHasBeenVisitedMask = this.graph.grabMask();\r\n const componentArray = GraphComponentArray.create(this.graph);\r\n for (const component of componentArray.components) {\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(component.faces, this.faceAreaFunction);\r\n if (exteriorHalfEdge) {\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const allMasksToClear = exteriorMask | faceHasBeenVisitedMask | nodeHasBeenVisitedMask;\r\n this.graph.clearMask(allMasksToClear);\r\n RegionOpsFaceToFaceSearch.faceToFaceSearchFromOuterLoop(this.graph, exteriorHalfEdge, faceHasBeenVisitedMask, nodeHasBeenVisitedMask, this);\r\n }\r\n }\r\n this.graph.dropMask(faceHasBeenVisitedMask);\r\n this.graph.dropMask(nodeHasBeenVisitedMask);\r\n }\r\n // search the graph for faces with\r\n // .. exactly 2 edges\r\n // .. both with given mask\r\n // .. at least one mate is not exterior.\r\n // .. clear that mark\r\n public unmaskMaskedNullFaces(mask: number) {\r\n for (const nodeA of this.graph.allHalfEdges) {\r\n const nodeB = nodeA.faceSuccessor;\r\n if (nodeB.faceSuccessor === nodeA) {\r\n if (nodeA.getMask(mask) && nodeB.getMask(mask)) {\r\n if (!nodeA.edgeMate.getMask(mask) || !nodeB.edgeMate.getMask(mask)) {\r\n nodeA.clearMask(mask);\r\n nodeB.clearMask(mask);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n private getInOut(): boolean {\r\n if (this.binaryOp === RegionBinaryOpType.Union)\r\n return this.groupA.getInOut() || this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Intersection)\r\n return this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.AMinusB)\r\n return this.groupA.getInOut() && !this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.BMinusA)\r\n return !this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Parity)\r\n return this.groupA.getInOut() !== this.groupB.getInOut();\r\n return false;\r\n }\r\n /**\r\n * Record transition across an edge as entry or exit from a RegionGroup.\r\n * * Work backward from the node to a RegionGroup. This path can be:\r\n * * If the node points to a CurveLocationDetail of a (possibly partial) curve, the path is (take a deep breath)\r\n * * node points to CurveLocation Detail\r\n * * CurveLocationDetail points to curve\r\n * * curve points to RegionGroupMember\r\n * * If the node points directly to a RegionGroup, it's ready to go!!!\r\n * @param node\r\n * @param delta\r\n */\r\n private recordTransitionAcrossEdge(node: HalfEdge, delta: number): RegionGroupMember | undefined {\r\n const updateRegionGroupMemberState = (member: RegionGroupMember): RegionGroupMember => {\r\n if (member.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n return member; // no transition across a bridge edge\r\n if (delta !== 0) {\r\n const oldSweepState = member.sweepState;\r\n member.sweepState += delta;\r\n member.parentGroup.recordMemberStateChange(oldSweepState, member.sweepState);\r\n }\r\n return member;\r\n };\r\n\r\n const data = node.edgeTag;\r\n if (data instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(data);\r\n\r\n if (data instanceof CurveLocationDetail) {\r\n // We trust that the caller has linked from the graph node to a curve which has a RegionGroupMember as its parent.\r\n const member = data.curve!.parent;\r\n if (member instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(member);\r\n }\r\n return undefined;\r\n }\r\n // obligations to act as sweep callback ...\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(outerFaceNode: HalfEdge): boolean {\r\n outerFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, outerFaceNode, -1, faceAreaFromCurvedEdgeData(outerFaceNode));\r\n return true;\r\n }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean {\r\n return true;\r\n }\r\n /** Announce entry to a graph face.\r\n * * Both both sides of a graph edge are from the same RegionGroupMember.\r\n * * Hence \"crossing that edge\" changes the parity count for the RegionGroupMember that owns that edge by 1.\r\n * * The parity count for other RegionGroupMembers are never affected by this crossing.\r\n * * Crossing a bridge edge does not change the parity count.\r\n */\r\n public enterFace(_facePathStack: HalfEdge[], newFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(newFaceNode, 1);\r\n const state = this.getInOut();\r\n if (!state)\r\n newFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, newFaceNode, state ? 1 : 0, faceAreaFromCurvedEdgeData(newFaceNode));\r\n return true;\r\n }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], oldFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(oldFaceNode, -1);\r\n return true;\r\n }\r\n}\r\n/** return xy area between a (part of a) curve and the x axis through a reference point.\r\n * If detail is undefined or does not have both start and end fractions, just do trapezoid area\r\n */\r\nfunction areaUnderPartialCurveXY(detail: CurveLocationDetail | undefined, xyStart: XAndY, xyEnd: XAndY, referencePoint: XAndY): number {\r\n // area between trapezoid and axis\r\n let trapezoidArea;\r\n if (detail && detail.point1) {\r\n trapezoidArea = -(detail.point1.x - detail.point.x) * (0.5 * (detail.point.y + detail.point1.y) - referencePoint.y);\r\n } else {\r\n trapezoidArea = -(xyEnd.x - xyStart.x) * (0.5 * (xyStart.y + xyEnd.y) - referencePoint.y);\r\n }\r\n let areaToChord = 0.0;\r\n if (detail && detail.curve && detail.hasFraction1) {\r\n\r\n if (detail.curve instanceof LineSegment3d) {\r\n // ah .. nothing to do for a line segment\r\n } else if (detail.curve instanceof Arc3d) {\r\n areaToChord = detail.curve.areaToChordXY(detail.fraction, detail.fraction1!);\r\n }\r\n }\r\n return trapezoidArea + areaToChord;\r\n}\r\n/** Compute face area for a face whose edges are decorated with CurveLocationDetail for their (partial) curves */\r\nfunction faceAreaFromCurvedEdgeData(faceSeed: HalfEdge): number {\r\n let area = 0.0;\r\n let edge = faceSeed;\r\n do {\r\n area += (edge.sortData as number) * areaUnderPartialCurveXY((edge.edgeTag as CurveLocationDetail), edge, edge.faceSuccessor, faceSeed);\r\n } while ((edge = edge.faceSuccessor) !== faceSeed);\r\n return area;\r\n}\r\n\r\n/**\r\n * Function to accumulate area under edges\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport type NodeAndRangeFunction = (edge: HalfEdge, range: Range2d) => void;\r\n/**\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport class GraphComponent {\r\n public faces: HalfEdge[];\r\n public faceAreas: number[];\r\n public range: Range2d;\r\n public constructor(faces: HalfEdge[]) {\r\n this.faces = faces;\r\n this.range = Range2d.createNull();\r\n this.faceAreas = [];\r\n }\r\n /**\r\n * visit all vertices and edges in the component to build face area array and composite range.\r\n *\r\n * @param extendRangeForEdge optional function to compute edge range. If undefined, linear edge is assumed.\r\n * @param faceAreaFunction optional function to compute face area. If undefined, linear edges are assumed.\r\n */\r\n public buildFaceData(extendRangeForEdge: NodeAndRangeFunction | undefined, faceAreaFunction: NodeToNumberFunction | undefined) {\r\n const vertexFunction = (node: HalfEdge) => {\r\n if (extendRangeForEdge)\r\n extendRangeForEdge(node, this.range);\r\n else\r\n this.range.extendXY(node.x, node.y);\r\n return 0;\r\n };\r\n this.range.setNull();\r\n for (const f of this.faces) {\r\n f.sumAroundFace(vertexFunction);\r\n }\r\n this.faceAreas.length = 0;\r\n if (!faceAreaFunction)\r\n faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n for (const f of this.faces) {\r\n this.faceAreas.push(faceAreaFunction(f));\r\n }\r\n }\r\n}\r\n/** build and hold an array of component data for a HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class GraphComponentArray {\r\n public components: GraphComponent[];\r\n public graph: HalfEdgeGraph;\r\n private constructor(graph: HalfEdgeGraph) {\r\n this.graph = graph;\r\n this.components = [];\r\n }\r\n public static create(graph: HalfEdgeGraph, extendRangeForEdge?: (edge: HalfEdge, range: Range2d) => void): GraphComponentArray {\r\n const result = new GraphComponentArray(graph);\r\n const componentArrays = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n for (const componentFaces of componentArrays) {\r\n const component = new GraphComponent(componentFaces);\r\n component.buildFaceData(extendRangeForEdge, faceAreaFromCurvedEdgeData);\r\n result.components.push(component);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"RegionOpsClassificationSweeps.js","sourceRoot":"","sources":["../../../src/curve/RegionOpsClassificationSweeps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AACH,6CAAgG;AAChG,yEAAsE;AACtE,iDAAyD;AACzD,+DAAmE;AAEnE,2CAAqF;AACrF,iDAA8C;AAC9C,iCAA8B;AAE9B,6CAA0C;AAC1C,iEAA8D;AAC9D,0CAAuC;AAEvC,+CAA4C;AAC5C,+DAA4D;AAE5D,mDAAgD;AAChD,mCAAgC;AAChC,+CAAuD;A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AI,IAAI,CAAC,KAAK,EAAE;YAC1B,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;SACjC;QACD,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB;YACnB,gBAAgB,GAAG,yCAAmB,CAAC,cAAc,CAAC;QACxD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,EAAE;YAC1B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;SAC1C;IACH,CAAC;CACF;AAlCD,wCAkCC;AACD;;GAEG;AACH,MAAa,mBAAmB;IAG9B,YAAoB,KAAoB;QACtC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;IACvB,CAAC;IACM,MAAM,CAAC,MAAM,CAAC,KAAoB,EAAE,kBAA6D;QACtG,MAAM,MAAM,GAAG,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAC9C,MAAM,eAAe,GAAG,yCAAmB,CAAC,iDAAiD,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QAChH,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE;YAC5C,MAAM,SAAS,GAAG,IAAI,cAAc,CAAC,cAAc,CAAC,CAAC;YACrD,SAAS,CAAC,aAAa,CAAC,kBAAkB,EAAE,0BAA0B,CAAC,CAAC;YACxE,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;SACnC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAjBD,kDAiBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask, NodeToNumberFunction } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../topology/Merging\";\r\nimport { RegularizationContext } from \"../topology/RegularizeFace\";\r\nimport { MultiLineStringDataVariant } from \"../topology/Triangulation\";\r\nimport { GraphCheckPointFunction, RegionBinaryOpType, RegionOps } from \"./RegionOps\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Loop } from \"./Loop\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { AnyRegion } from \"./CurveChain\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\nimport { CurveLocationDetail } from \"./CurveLocationDetail\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { LineSegment3d } from \"./LineSegment3d\";\r\nimport { Arc3d } from \"./Arc3d\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PlaneAltitudeRangeContext } from \"./internalContexts/PlaneAltitudeRangeContext\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\n\r\n/**\r\n * base class for callbacks during region sweeps.\r\n * * At start of a component, `startComponent(node)` is called announcing a representative node on the outermost face.\r\n * * A Component in this usage is a component that is edge connected when ignoring \"exterior bridge edges\".\r\n * * As each face is entered, `enterFace(facePathStack, newFaceNode)` is called\r\n * * facePathStack[0] is the outermost node of the path from the outer face.\r\n * * facePathStack[1] is its inside mate.\r\n * * facePathStack[2k] is the outside node at crossing to face at depth k.\r\n * * facePathStack[2k+1] is the node where face at depth k was entered.\r\n * * newFaceNode is the entry node (redundant of stack tip)\r\n * * On retreat from a face, `leaveFace(facePathStack, faceNode)` is called.\r\n * * At end of component, `finishComponent (node)` is called.\r\n * * The base class is fully implemented to do nothing during the sweep.\r\n * @internal\r\n */\r\nabstract class RegionOpsFaceToFaceSearchCallbacks {\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean { return true; }\r\n /** Announce face entry */\r\n public enterFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], _newFaceNode: HalfEdge): boolean { return true; }\r\n}\r\n/** Function signature to test if a pair of boolean states is to be accepted by area booleans (during face-to-face sweeps)\r\n * @internal\r\n */\r\ntype BinaryBooleanAcceptFunction = (stateA: boolean, stateB: boolean) => boolean;\r\n/** Function signature ot announce classification of a face.\r\n * The `faceType` parameters are\r\n * * -1 for a fully exterior face. This is a negative area face.\r\n * * 0 for a positive area face classified as \"out\" for the boolean.\r\n * * 1 for a positive area face classified as \"in\" for the boolean.\r\n */\r\ntype AnnounceClassifiedFace = (graph: HalfEdgeGraph, faceSeed: HalfEdge, faceType: -1 | 0 | 1, area: number) => void;\r\n/**\r\n * Implementation of `RegionOpsFaceToFaceSearchCallbacks` for binary boolean sweep with polygonal regions.\r\n * * For this linear-boundary case the boundary geometry is carried entirely from the coordinates in the half edges.\r\n * * This assumes the each node in the graph has edgeTag set to:\r\n * * `edgeTag === undefined` if the edge crossing does not change classification.\r\n * * for example, an edge added by regularization\r\n * * `edgeTag === 1` if this is a boundary for the first of the boolean input regions\r\n * * `edgeTag === 2` if this is a boundary for the second of the boolean input regions\r\n * * constructor\r\n * * takes caller-supplied function to decide whether to accept a face given its state relative to the two boolean terms.\r\n * * sets the in/out status of both terms to false.\r\n * * `startComponent` marks the entire outer face as `EXTERIOR`\r\n * * `enterFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * ask the faceAcceptFunction if the current term states combine to in/out for the result\r\n * * if out, set the `EXTERIOR` mask around the face.\r\n * * `leaveFace`\r\n * * if this is a bounding edge (according to `node.faceTag`) toggle the in/out status if this boolean term.\r\n * * `finishComponent` is not reimplemented.\r\n * @internal\r\n */\r\nclass RegionOpsBinaryBooleanSweepCallbacks extends RegionOpsFaceToFaceSearchCallbacks {\r\n private _faceSelectFunction: BinaryBooleanAcceptFunction;\r\n private _inComponent: boolean[];\r\n private _exteriorMask: HalfEdgeMask;\r\n public constructor(acceptFaceFunction: BinaryBooleanAcceptFunction, exteriorMask: HalfEdgeMask) {\r\n super();\r\n this._inComponent = [false, false, false]; // entry 0 is never reused.\r\n this._exteriorMask = exteriorMask;\r\n this._faceSelectFunction = acceptFaceFunction;\r\n }\r\n /** Mark this face as exterior */\r\n public override startComponent(node: HalfEdge): boolean { node.setMaskAroundFace(this._exteriorMask); return true; }\r\n /**\r\n * * If necessary, toggle a term state.\r\n * * if indicated, mark this face exterior.\r\n */\r\n public override enterFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n if (!this._faceSelectFunction(this._inComponent[1], this._inComponent[2]))\r\n node.setMaskAroundFace(this._exteriorMask);\r\n return true;\r\n }\r\n /**\r\n * * If necessary, toggle a term state.\r\n */\r\n public override leaveFace(_facePathStack: HalfEdge[], node: HalfEdge): boolean {\r\n const thisFaceIndex = node.edgeTag;\r\n if (node.edgeTag === 1 || node.edgeTag === 2)\r\n this._inComponent[thisFaceIndex] = !this._inComponent[thisFaceIndex];\r\n return true;\r\n }\r\n}\r\n/**\r\n * Low level graph search for face classification.\r\n * @internal\r\n */\r\nexport class RegionOpsFaceToFaceSearch {\r\n /**\r\n * run a DFS with face-to-face step announcements.\r\n * * false return from any function terminates search immediately.\r\n * * all reachable nodes assumed to have both visit masks clear.\r\n * @param graph containing graph.\r\n * @param seed first node to visit.\r\n * @param faceHasBeenVisited mask marking faces that have been seen.\r\n * @param nodeHasBeenVisited mask marking node-to-node step around face.\r\n *\r\n */\r\n public static faceToFaceSearchFromOuterLoop(_graph: HalfEdgeGraph, seed: HalfEdge, faceHasBeenVisited: HalfEdgeMask, nodeHasBeenVisited: HalfEdgeMask, callbacks: RegionOpsFaceToFaceSearchCallbacks) {\r\n if (seed.isMaskSet(faceHasBeenVisited))\r\n return;\r\n if (!callbacks.startComponent(seed))\r\n return;\r\n const facePathStack = [];\r\n seed.setMaskAroundFace(faceHasBeenVisited);\r\n let faceWalker = seed;\r\n do {\r\n let entryNode = faceWalker;\r\n let mate = faceWalker.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n // the faceWalker seed is always on the base of the stack.\r\n // the stack then contains even-odd pairs of (entryNode, currentNode)\r\n // * entryNode is the node where a face was entered.\r\n // * faceNode is another node around that face.\r\n facePathStack.push(faceWalker);\r\n facePathStack.push(mate);\r\n let faceNode = mate.faceSuccessor;\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n entryNode = mate;\r\n if (callbacks.enterFace(facePathStack, mate)) {\r\n for (; ;) {\r\n mate = faceNode.edgeMate;\r\n if (!mate.isMaskSet(faceHasBeenVisited)) {\r\n mate.setMaskAroundFace(faceHasBeenVisited);\r\n if (!callbacks.enterFace(facePathStack, mate))\r\n return;\r\n facePathStack.push(faceNode);\r\n facePathStack.push(mate);\r\n faceNode = mate;\r\n entryNode = mate;\r\n }\r\n faceNode.setMask(nodeHasBeenVisited);\r\n faceNode = faceNode.faceSuccessor;\r\n if (faceNode === entryNode) {\r\n callbacks.leaveFace(facePathStack, faceNode);\r\n if (facePathStack.length <= 2) {\r\n break;\r\n }\r\n facePathStack.pop();\r\n faceNode = facePathStack[facePathStack.length - 1];\r\n facePathStack.pop();\r\n entryNode = facePathStack[facePathStack.length - 1];\r\n }\r\n if (faceNode.isMaskSet(nodeHasBeenVisited)) {\r\n // this is disaster !!!\r\n return;\r\n }\r\n }\r\n }\r\n }\r\n // continue at outermost level .....\r\n faceWalker = faceWalker.faceSuccessor;\r\n } while (faceWalker !== seed);\r\n callbacks.finishComponent(seed);\r\n }\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * Each of the binary input terms is a collection of loops\r\n * * Within the binary term, in/out is determined by edge-crossing parity rules.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with 1 or 2 as binary term identifier.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n */\r\n public static doPolygonBoolean(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, faceSelectFunction: (inA: boolean, inB: boolean) => boolean, graphCheckPoint?: GraphCheckPointFunction): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const seedA = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsA, baseMask, 1);\r\n const seedB = RegionOps.addLoopsWithEdgeTagToGraph(graph, loopsB, baseMask, 2);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"unmerged loops\", graph, \"U\");\r\n if (seedA || seedB) {\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After splitIntersectingEdges\", graph, \"S\");\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After clusterAndMergeXYTheta\", graph, \"M\");\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After regularize\", graph, \"MR\");\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(graph);\r\n if (exteriorHalfEdge === undefined)\r\n return undefined;\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const faceVisitedMask = graph.grabMask();\r\n const nodeVisitedMask = graph.grabMask();\r\n const allMasksToClear = exteriorMask | faceVisitedMask | nodeVisitedMask;\r\n graph.clearMask(allMasksToClear);\r\n const callbacks = new RegionOpsBinaryBooleanSweepCallbacks(faceSelectFunction, exteriorMask);\r\n this.faceToFaceSearchFromOuterLoop(graph, exteriorHalfEdge, faceVisitedMask, nodeVisitedMask, callbacks);\r\n if (graphCheckPoint)\r\n graphCheckPoint(\"After faceToFaceSearchFromOuterLoop\", graph, \"MRX\");\r\n graph.dropMask(faceVisitedMask);\r\n graph.dropMask(nodeVisitedMask);\r\n return graph;\r\n }\r\n return undefined;\r\n }\r\n\r\n /** Complete multi-step process for polygon binary booleans starting with arrays of coordinates.\r\n * * the manyLoopsAndParitySets input is an array.\r\n * * Each entry is one or more loops.\r\n * * An entry that is \"just points\" is a simple loop.\r\n * * An entry that is itself an array of arrays of points is a set of loops with \"parity\" -- relation:\r\n * * typically the first is an outer loop an others are holes.\r\n * * but if there is self intersection or multiple outer loops, parity rules are applied to decide inner and outer.\r\n * * Processing steps are\r\n * * Build the loops for each set.\r\n * * Each edge labeled with index to the outer array.\r\n * * find crossings among the edges.\r\n * * Edges are split as needed, but split preserves the edgeTag\r\n * * sort edges around vertices\r\n * * add regularization edges so holes are connected to their parent.\r\n * * assign inside/outside by parity within each set and overall union.\r\n */\r\n public static doBinaryBooleanBetweenMultiLoopInputs(\r\n dataA: MultiLineStringDataVariant[],\r\n opA: RegionGroupOpType,\r\n binaryOp: RegionBinaryOpType,\r\n dataB: MultiLineStringDataVariant[],\r\n opB: RegionGroupOpType,\r\n purgeSliverExteriorFaces: boolean\r\n ): HalfEdgeGraph | undefined {\r\n const graph = new HalfEdgeGraph();\r\n const baseMask = HalfEdgeMask.BOUNDARY_EDGE | HalfEdgeMask.PRIMARY_EDGE;\r\n const callbacks = RegionBooleanContext.create(opA, opB);\r\n callbacks.graph = graph;\r\n callbacks.faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n\r\n // Add all the members in groupA ..\r\n for (const data of dataA) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupA);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n for (const data of dataB) {\r\n if (data.length > 2){\r\n const member = new RegionGroupMember(data, callbacks.groupB);\r\n RegionOps.addLoopsWithEdgeTagToGraph(graph, data, baseMask, member);\r\n }\r\n }\r\n // split edges where they cross . . .\r\n HalfEdgeGraphMerge.splitIntersectingEdges(graph);\r\n // sort radially around vertices.\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph);\r\n // add edges to connect various components (e.g. holes!!!)\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n callbacks.runClassificationSweep(binaryOp);\r\n if (purgeSliverExteriorFaces)\r\n callbacks.unmaskMaskedNullFaces(HalfEdgeMask.EXTERIOR);\r\n return graph;\r\n }\r\n}\r\n\r\n/**\r\n * Enumeration of operation types \"within a group operand\" for a `RegionBooleanContext`.\r\n * @internal\r\n */\r\nexport enum RegionGroupOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n NonBounding = -1,\r\n}\r\n/**\r\n * Each loop or parity region in a `RegionBooleanContext` is recorded as a `RegionGroupMember`, which carries\r\n * * the Loop or parityRegion object\r\n * * a numeric indication of the sweep state (parity) during the classification search.\r\n * * a reference to the parent group (which in turn leads back to the `RegionBooleanContext`)\r\n * @internal\r\n */\r\nclass RegionGroupMember {\r\n public region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant;\r\n public sweepState: number;\r\n public parentGroup: RegionGroup;\r\n public constructor(region: Loop | ParityRegion | CurvePrimitive | MultiLineStringDataVariant, parentGroup: RegionGroup) {\r\n this.region = region;\r\n this.parentGroup = parentGroup;\r\n this.sweepState = 0;\r\n }\r\n public clearState() { this.sweepState = 0; }\r\n}\r\n/**\r\n * A `RegionGroup` is\r\n * * An array of `RegionGroupMembers`, carrying the regions of the Ai or Bi part of the boolean expression.\r\n * * The `RegionGroupOpType` to be applied among those members.\r\n * * Pointer to the containing context\r\n * * The count of number of regions known to be \"in\" as the search progresses.\r\n * @internal\r\n */\r\nexport class RegionGroup {\r\n public members: RegionGroupMember[];\r\n public groupOpType: RegionGroupOpType;\r\n public parent: RegionBooleanContext;\r\n private _numIn: number;\r\n public constructor(parent: RegionBooleanContext, groupOpType: RegionGroupOpType) {\r\n this.members = [];\r\n this.parent = parent;\r\n this.groupOpType = groupOpType;\r\n this._numIn = 0;\r\n }\r\n /** deep clear of state data -- group header plus all members */\r\n public clearState() {\r\n for (const member of this.members)\r\n member.clearState();\r\n this._numIn = 0;\r\n }\r\n public range(): Range3d {\r\n const range = Range3d.createNull();\r\n for (const m of this.members) {\r\n if (m.region instanceof GeometryQuery)\r\n m.region.extendRange(range);\r\n else {\r\n const range1 = Range3d.createFromVariantData(m.region);\r\n range.extendRange(range1);\r\n }\r\n }\r\n return range;\r\n }\r\n /** Ask if the current _numIn count qualifies as an \"in\" for this operation type.\r\n */\r\n public getInOut(): boolean {\r\n // UNION is true if one or more members are IN\r\n if (this.groupOpType === RegionGroupOpType.Union)\r\n return this._numIn > 0;\r\n // PARITY is true if an odd number of regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Parity)\r\n return Geometry.isOdd(this._numIn);\r\n // INTERSECTION is true if ALL the regions are IN\r\n if (this.groupOpType === RegionGroupOpType.Intersection)\r\n return this._numIn === this.members.length;\r\n return false;\r\n }\r\n // push new members into the group.\r\n public addMember(data: AnyRegion | AnyRegion[] | LineSegment3d | undefined, allowLineSegment: boolean = false) {\r\n if (data instanceof Loop || data instanceof ParityRegion) {\r\n const cleanerData = data.clone() as (ParityRegion | Loop);\r\n RegionOps.consolidateAdjacentPrimitives(cleanerData);\r\n this.members.push(new RegionGroupMember(cleanerData, this));\r\n } else if (data instanceof UnionRegion) {\r\n for (const child of data.children) {\r\n this.addMember(child);\r\n }\r\n } else if (Array.isArray(data)) {\r\n for (const item of data) {\r\n this.addMember(item);\r\n }\r\n } else if (allowLineSegment && data instanceof LineSegment3d) {\r\n this.members.push(new RegionGroupMember(data, this));\r\n\r\n }\r\n }\r\n // update the \"in\" count _numIn according to old and new states (parity counts) for some member region.\r\n public recordMemberStateChange(oldState: number, newState: number) {\r\n const oldIn = Geometry.isOdd(oldState);\r\n const newIn = Geometry.isOdd(newState);\r\n if (!oldIn && newIn)\r\n this._numIn++;\r\n else if (oldIn && !newIn)\r\n this._numIn--;\r\n }\r\n}\r\n/**\r\n * A `RegionBooleanContext` carries structure and operations for binary operations between two sets of regions.\r\n * * In the binary operation OP (union, intersection, parity, difference), the left and right operands\r\n * are each a composite union, difference, or parity among multiple inputs, i.e.\r\n * * (operationA among Ai) OP (operationB among Bi)\r\n * * where the Ai are one set of regions, being combined by operationA\r\n * * and the Bi are the another set of regions, being combined by operationB\r\n * * Each group of Ai and Bi is a `RegionGroup`\r\n * * This is an extremely delicate structure.\r\n * * Members are public because of the unique variety of queries, but should only be used for queries.\r\n * * The graph and curves in the booleans are connected by an extended pointer chain:\r\n * * (HalfEdge in Graph).edgeTag points to a CurveLocationDetail\r\n * * (CurveLocationDetail).curve points to a curve\r\n * * (Curve).parent points to RegionGroupMember\r\n * * (RegionGroupMember) points to RegionGroup\r\n * * (RegionGroup) points to RegionBooleanBinaryContext\r\n * * So..when a graph sweep crosses an edge,\r\n * * the chain leads to a parity count in the RegionGroupMember\r\n * * that can change the number of members active in the RegionGroup\r\n * * which can change the state of the context.\r\n * @internal\r\n */\r\nexport class RegionBooleanContext implements RegionOpsFaceToFaceSearchCallbacks {\r\n public groupA!: RegionGroup;\r\n public groupB!: RegionGroup;\r\n public extraGeometry!: RegionGroup;\r\n public graph!: HalfEdgeGraph;\r\n public faceAreaFunction!: NodeToNumberFunction;\r\n public binaryOp: RegionBinaryOpType;\r\n\r\n private constructor(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType) {\r\n this.groupA = new RegionGroup(this, groupTypeA);\r\n this.groupB = new RegionGroup(this, groupTypeB);\r\n this.extraGeometry = new RegionGroup(this, RegionGroupOpType.NonBounding);\r\n this.binaryOp = RegionBinaryOpType.Union; // it will be revised on can calls.\r\n }\r\n /**\r\n * Create a context with both A and B groups empty.\r\n * * Caller follows up by calls to `context.groupA.addMember (loopOrParityRegion)` or `context.groupB.addMember (loopOrParityRegion)`\r\n * @param groupTypeA\r\n * @param groupTypeB\r\n */\r\n public static create(groupTypeA: RegionGroupOpType, groupTypeB: RegionGroupOpType): RegionBooleanContext {\r\n return new RegionBooleanContext(groupTypeA, groupTypeB);\r\n }\r\n public addMembers(dataA: AnyRegion | AnyRegion[] | undefined, dataB: AnyRegion | AnyRegion[] | undefined) {\r\n this.groupA.addMember(dataA);\r\n this.groupB.addMember(dataB);\r\n // const doConnectives = 1;\r\n // if (doConnectives !== 0)\r\n this.addConnectives();\r\n }\r\n\r\n private _workSegment?: LineSegment3d;\r\n private static _bridgeDirection = Vector3d.createNormalized(1.0, -0.12328974132467)!; // magic unit direction to minimize vertex hits\r\n /**\r\n * The sweep operations require access to all geometry by edge crossings and face walk.\r\n * If input loops are non-overlapping, there may be disconnected islands not reachable.\r\n * This method:\r\n * * finds the total range\r\n * * creates parallel rays from the extreme point of each loop and extending beyond the overall range\r\n * * places those lines in the extraGeometry group\r\n */\r\n public addConnectives() {\r\n const rangeA = this.groupA.range();\r\n const rangeB = this.groupB.range();\r\n const rangeAB = rangeA.union(rangeB);\r\n const areaTol = RegionOps.computeXYAreaTolerance(rangeAB);\r\n let margin = 0.1;\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(rangeAB.corners(), RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n margin *= this._workSegment.point0Ref.distanceXY(this._workSegment.point1Ref); // how much further to extend each bridge ray\r\n\r\n const maxPoints: Point3d[] = [];\r\n const findExtremePointsInLoop = (region: Loop) => {\r\n const area = RegionOps.computeXYArea(region);\r\n if (area === undefined || Math.abs(area) < areaTol)\r\n return; // avoid bridging trivial faces\r\n this._workSegment = PlaneAltitudeRangeContext.findExtremePointsInDirection(region, RegionBooleanContext._bridgeDirection, this._workSegment);\r\n if (this._workSegment)\r\n maxPoints.push(this._workSegment.point1Ref);\r\n };\r\n\r\n for (const groupMembers of [this.groupA.members, this.groupB.members]) {\r\n for (const m of groupMembers) {\r\n if (m.region instanceof Loop) {\r\n findExtremePointsInLoop(m.region);\r\n } else if (m.region instanceof ParityRegion) {\r\n for (const loop of m.region.children)\r\n findExtremePointsInLoop(loop);\r\n }\r\n }\r\n }\r\n\r\n const ray = Ray3d.createZero();\r\n for (const p of maxPoints) {\r\n // Make a line from...\r\n // 1) exactly the max point of the loops to\r\n // 2) a point clearly outside the big range\r\n // If p came from some inner loop this will...\r\n // 1) create a bridge from the inner loop through any containing loops (always)\r\n // 2) avoid crossing any containing loop at a vertex. (with high probability, but not absolutely always)\r\n const bridgeLength = margin + Ray3d.create(p, RegionBooleanContext._bridgeDirection, ray).intersectionWithRange3d(rangeAB).high;\r\n const outside = Point3d.createAdd2Scaled(p, 1.0, RegionBooleanContext._bridgeDirection, bridgeLength);\r\n const bridgeLine = LineSegment3d.createXYXY(p.x, p.y, outside.x, outside.y);\r\n this.extraGeometry.addMember(bridgeLine, true);\r\n }\r\n }\r\n\r\n /**\r\n * Markup and assembly steps for geometry in the RegionGroups.\r\n * * Annotate connection from group to curves.\r\n * * groups with point data but no curves get no further annotation.\r\n * * compute intersections.\r\n * * assemble and merge the HalfEdgeGraph.\r\n * @param mergeTolerance absolute distance tolerance for merging loops\r\n */\r\n public annotateAndMergeCurvesInGraph(mergeTolerance: number = Geometry.smallMetricDistance) {\r\n const allPrimitives: CurvePrimitive[] = [];\r\n // ASSUME loops have fine-grained types -- no linestrings !!\r\n for (const group of [this.groupA, this.groupB, this.extraGeometry]) {\r\n for (const member of group.members) {\r\n let k = allPrimitives.length;\r\n if (member.region instanceof GeometryQuery) {\r\n RegionOps.collectCurvePrimitives(member.region, allPrimitives, true, true);\r\n for (; k < allPrimitives.length; k++)\r\n allPrimitives[k].parent = member;\r\n }\r\n }\r\n }\r\n // const range = RegionOps.curveArrayRange(allPrimitives);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(allPrimitives, mergeTolerance);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(allPrimitives, intersections);\r\n this.graph = graph;\r\n this.faceAreaFunction = faceAreaFromCurvedEdgeData;\r\n }\r\n private _announceFaceFunction?: AnnounceClassifiedFace;\r\n /**\r\n * Sweep through the graph to assign in/out classifications to all faces.\r\n * * the classification is announced in two ways:\r\n * * the EXTERNAL mask is set on all half edges that are NOT interior faces.\r\n * * the announceFaceFunction is called once for each face.\r\n * @param binaryOp\r\n * @param announceFaceFunction\r\n */\r\n public runClassificationSweep(\r\n binaryOp: RegionBinaryOpType,\r\n announceFaceFunction?: AnnounceClassifiedFace) {\r\n this._announceFaceFunction = announceFaceFunction;\r\n this.binaryOp = binaryOp;\r\n this.graph.clearMask(HalfEdgeMask.EXTERIOR);\r\n for (const group of [this.groupA, this.groupB]) {\r\n group.clearState();\r\n }\r\n const faceHasBeenVisitedMask = this.graph.grabMask();\r\n const nodeHasBeenVisitedMask = this.graph.grabMask();\r\n const componentArray = GraphComponentArray.create(this.graph);\r\n for (const component of componentArray.components) {\r\n const exteriorHalfEdge = HalfEdgeGraphSearch.findMinimumAreaFace(component.faces, this.faceAreaFunction);\r\n if (exteriorHalfEdge) {\r\n const exteriorMask = HalfEdgeMask.EXTERIOR;\r\n const allMasksToClear = exteriorMask | faceHasBeenVisitedMask | nodeHasBeenVisitedMask;\r\n this.graph.clearMask(allMasksToClear);\r\n RegionOpsFaceToFaceSearch.faceToFaceSearchFromOuterLoop(this.graph, exteriorHalfEdge, faceHasBeenVisitedMask, nodeHasBeenVisitedMask, this);\r\n }\r\n }\r\n this.graph.dropMask(faceHasBeenVisitedMask);\r\n this.graph.dropMask(nodeHasBeenVisitedMask);\r\n }\r\n // search the graph for faces with\r\n // .. exactly 2 edges\r\n // .. both with given mask\r\n // .. at least one mate is not exterior.\r\n // .. clear that mark\r\n public unmaskMaskedNullFaces(mask: number) {\r\n for (const nodeA of this.graph.allHalfEdges) {\r\n const nodeB = nodeA.faceSuccessor;\r\n if (nodeB.faceSuccessor === nodeA) {\r\n if (nodeA.getMask(mask) && nodeB.getMask(mask)) {\r\n if (!nodeA.edgeMate.getMask(mask) || !nodeB.edgeMate.getMask(mask)) {\r\n nodeA.clearMask(mask);\r\n nodeB.clearMask(mask);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n private getInOut(): boolean {\r\n if (this.binaryOp === RegionBinaryOpType.Union)\r\n return this.groupA.getInOut() || this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Intersection)\r\n return this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.AMinusB)\r\n return this.groupA.getInOut() && !this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.BMinusA)\r\n return !this.groupA.getInOut() && this.groupB.getInOut();\r\n if (this.binaryOp === RegionBinaryOpType.Parity)\r\n return this.groupA.getInOut() !== this.groupB.getInOut();\r\n return false;\r\n }\r\n /**\r\n * Record transition across an edge as entry or exit from a RegionGroup.\r\n * * Work backward from the node to a RegionGroup. This path can be:\r\n * * If the node points to a CurveLocationDetail of a (possibly partial) curve, the path is (take a deep breath)\r\n * * node points to CurveLocation Detail\r\n * * CurveLocationDetail points to curve\r\n * * curve points to RegionGroupMember\r\n * * If the node points directly to a RegionGroup, it's ready to go!!!\r\n * @param node\r\n * @param delta\r\n */\r\n private recordTransitionAcrossEdge(node: HalfEdge, delta: number): RegionGroupMember | undefined {\r\n const updateRegionGroupMemberState = (member: RegionGroupMember): RegionGroupMember => {\r\n if (member.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\r\n return member; // no transition across a bridge edge\r\n if (delta !== 0) {\r\n const oldSweepState = member.sweepState;\r\n member.sweepState += delta;\r\n member.parentGroup.recordMemberStateChange(oldSweepState, member.sweepState);\r\n }\r\n return member;\r\n };\r\n\r\n const data = node.edgeTag;\r\n if (data instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(data);\r\n\r\n if (data instanceof CurveLocationDetail) {\r\n // We trust that the caller has linked from the graph node to a curve which has a RegionGroupMember as its parent.\r\n const member = data.curve!.parent;\r\n if (member instanceof RegionGroupMember)\r\n return updateRegionGroupMemberState(member);\r\n }\r\n return undefined;\r\n }\r\n // obligations to act as sweep callback ...\r\n /** Announce a representative node on the outer face of a component */\r\n public startComponent(outerFaceNode: HalfEdge): boolean {\r\n outerFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, outerFaceNode, -1, faceAreaFromCurvedEdgeData(outerFaceNode));\r\n return true;\r\n }\r\n /** Announce return to outer face */\r\n public finishComponent(_node: HalfEdge): boolean {\r\n return true;\r\n }\r\n /** Announce entry to a graph face.\r\n * * Both both sides of a graph edge are from the same RegionGroupMember.\r\n * * Hence \"crossing that edge\" changes the parity count for the RegionGroupMember that owns that edge by 1.\r\n * * The parity count for other RegionGroupMembers are never affected by this crossing.\r\n * * Crossing a bridge edge does not change the parity count.\r\n */\r\n public enterFace(_facePathStack: HalfEdge[], newFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(newFaceNode, 1);\r\n const state = this.getInOut();\r\n if (!state)\r\n newFaceNode.setMaskAroundFace(HalfEdgeMask.EXTERIOR);\r\n if (this._announceFaceFunction)\r\n this._announceFaceFunction(this.graph, newFaceNode, state ? 1 : 0, faceAreaFromCurvedEdgeData(newFaceNode));\r\n return true;\r\n }\r\n /** Announce face exit */\r\n public leaveFace(_facePathStack: HalfEdge[], oldFaceNode: HalfEdge): boolean {\r\n this.recordTransitionAcrossEdge(oldFaceNode, -1);\r\n return true;\r\n }\r\n}\r\n/** return xy area between a (part of a) curve and the x axis through a reference point.\r\n * If detail is undefined or does not have both start and end fractions, just do trapezoid area\r\n */\r\nfunction areaUnderPartialCurveXY(detail: CurveLocationDetail | undefined, xyStart: XAndY, xyEnd: XAndY, referencePoint: XAndY): number {\r\n // area between trapezoid and axis\r\n let trapezoidArea;\r\n if (detail && detail.point1) {\r\n trapezoidArea = -(detail.point1.x - detail.point.x) * (0.5 * (detail.point.y + detail.point1.y) - referencePoint.y);\r\n } else {\r\n trapezoidArea = -(xyEnd.x - xyStart.x) * (0.5 * (xyStart.y + xyEnd.y) - referencePoint.y);\r\n }\r\n let areaToChord = 0.0;\r\n if (detail && detail.curve && detail.hasFraction1) {\r\n\r\n if (detail.curve instanceof LineSegment3d) {\r\n // ah .. nothing to do for a line segment\r\n } else if (detail.curve instanceof Arc3d) {\r\n areaToChord = detail.curve.areaToChordXY(detail.fraction, detail.fraction1!);\r\n }\r\n }\r\n return trapezoidArea + areaToChord;\r\n}\r\n/** Compute face area for a face whose edges are decorated with CurveLocationDetail for their (partial) curves */\r\nfunction faceAreaFromCurvedEdgeData(faceSeed: HalfEdge): number {\r\n let area = 0.0;\r\n let edge = faceSeed;\r\n do {\r\n area += (edge.sortData as number) * areaUnderPartialCurveXY((edge.edgeTag as CurveLocationDetail), edge, edge.faceSuccessor, faceSeed);\r\n } while ((edge = edge.faceSuccessor) !== faceSeed);\r\n return area;\r\n}\r\n\r\n/**\r\n * Function to accumulate area under edges\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport type NodeAndRangeFunction = (edge: HalfEdge, range: Range2d) => void;\r\n/**\r\n * Array of nodes representing faces in a subset of a graph.\r\n * @internal\r\n */\r\nexport class GraphComponent {\r\n public faces: HalfEdge[];\r\n public faceAreas: number[];\r\n public range: Range2d;\r\n public constructor(faces: HalfEdge[]) {\r\n this.faces = faces;\r\n this.range = Range2d.createNull();\r\n this.faceAreas = [];\r\n }\r\n /**\r\n * visit all vertices and edges in the component to build face area array and composite range.\r\n *\r\n * @param extendRangeForEdge optional function to compute edge range. If undefined, linear edge is assumed.\r\n * @param faceAreaFunction optional function to compute face area. If undefined, linear edges are assumed.\r\n */\r\n public buildFaceData(extendRangeForEdge: NodeAndRangeFunction | undefined, faceAreaFunction: NodeToNumberFunction | undefined) {\r\n const vertexFunction = (node: HalfEdge) => {\r\n if (extendRangeForEdge)\r\n extendRangeForEdge(node, this.range);\r\n else\r\n this.range.extendXY(node.x, node.y);\r\n return 0;\r\n };\r\n this.range.setNull();\r\n for (const f of this.faces) {\r\n f.sumAroundFace(vertexFunction);\r\n }\r\n this.faceAreas.length = 0;\r\n if (!faceAreaFunction)\r\n faceAreaFunction = HalfEdgeGraphSearch.signedFaceArea;\r\n for (const f of this.faces) {\r\n this.faceAreas.push(faceAreaFunction(f));\r\n }\r\n }\r\n}\r\n/** build and hold an array of component data for a HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class GraphComponentArray {\r\n public components: GraphComponent[];\r\n public graph: HalfEdgeGraph;\r\n private constructor(graph: HalfEdgeGraph) {\r\n this.graph = graph;\r\n this.components = [];\r\n }\r\n public static create(graph: HalfEdgeGraph, extendRangeForEdge?: (edge: HalfEdge, range: Range2d) => void): GraphComponentArray {\r\n const result = new GraphComponentArray(graph);\r\n const componentArrays = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n for (const componentFaces of componentArrays) {\r\n const component = new GraphComponent(componentFaces);\r\n component.buildFaceData(extendRangeForEdge, faceAreaFromCurvedEdgeData);\r\n result.components.push(component);\r\n }\r\n return result;\r\n }\r\n}\r\n"]}
@@ -56,10 +56,9 @@ class StrokeOptions {
56
56
  get hasMaxEdgeLength() { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }
57
57
  /** Return a deep clone */
58
58
  clone() {
59
- var _a;
60
59
  const options = new StrokeOptions();
61
60
  options.chordTol = this.chordTol;
62
- options.angleTol = (_a = this.angleTol) === null || _a === void 0 ? void 0 : _a.clone();
61
+ options.angleTol = this.angleTol?.clone();
63
62
  options.maxEdgeLength = this.maxEdgeLength;
64
63
  options.needConvexFacets = this.needConvexFacets;
65
64
  options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeOptions.js","sourceRoot":"","sources":["../../../src/curve/StrokeOptions.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,+CAA4C;AAE5C,mEAAmE;AAEnE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,aAAa;IAA1B;QAYE,qDAAqD;QAC9C,sBAAiB,GAAY,KAAK,CAAC;QAe1C,8CAA8C;QACvC,yBAAoB,GAAG,EAAE,CAAC;IA+HnC,CAAC;IA3IC,oCAAoC;IACpC,IAAW,UAAU,KAAc,OAAO,IAAI,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACtG,IAAW,UAAU,CAAC,KAAc,IAAI,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC;IACnE,oCAAoC;IACpC,IAAW,WAAW,KAAc,OAAO,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACzG,IAAW,WAAW,CAAC,KAAc,IAAI,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC,CAAC,CAAC;IACrE,qCAAqC;IACrC,IAAW,YAAY,KAAc,OAAO,IAAI,CAAC,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5G,IAAW,YAAY,CAAC,KAAc,IAAI,IAAI,CAAC,aAAa,GAAG,KAAK,C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AAY,EAAE,QAAQ,CAAC,CAAC;SACpE;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD;OACG;IACI,+BAA+B,CAAC,QAAgB,EAAE,MAAc,EAAE,YAAoB;QAC3F,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,GAAG,GAAG,EAAE;YACxC,MAAM,MAAM,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;SAC7D;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iGAAiG;IAC1F,2BAA2B,CAAC,QAAgB;QACjD,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5JD,sCA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/** tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n *\r\n * It is rare for all three to be active at once:\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * * For curves, 15 degrees is typical\r\n * * * For facets, 22.5 degrees is typical.\r\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n\r\n /** distance from stroke to actual geometry */\r\n public chordTol?: number;\r\n /** turning angle between strokes. */\r\n public angleTol?: Angle;\r\n /** maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /** caller expects convex facets. */\r\n public needConvexFacets?: boolean;\r\n /** minimum strokes on a primitive */\r\n public minStrokesPerPrimitive?: number;\r\n /** whether or not to triangulate each added facet */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean { return this._needParams !== undefined ? this._needParams : false; }\r\n public set needParams(value: boolean) { this._needParams = value; }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean { return this._needNormals !== undefined ? this._needNormals : false; }\r\n public set needNormals(value: boolean) { this._needNormals = value; }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean { return this._needTwoSided !== undefined ? this._needTwoSided : false; }\r\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\r\n /** optional color request flag */\r\n public needColors?: boolean;\r\n /** default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** ask if angleTol is specified */\r\n public get hasAngleTol(): boolean { return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0; }\r\n /** ask if chordTol is specified */\r\n public get hasChordTol(): boolean { return this.chordTol !== undefined && this.chordTol > 0.0; }\r\n /** ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }\r\n\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.needConvexFacets = this.needConvexFacets;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n return options;\r\n }\r\n\r\n /** return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n\r\n /**\r\n * return stroke count which is the larger of the existing count or count needed for angle condition for given sweepRadians\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance from the options.\r\n */\r\n public static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength, chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tol with given arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n\r\n /** create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /** create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\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AG,GAAG,EAAE;YACxC,MAAM,MAAM,GAAG,mBAAQ,CAAC,yBAAyB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;YACxE,IAAI,MAAM,KAAK,SAAS;gBACtB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;SAC7D;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,iGAAiG;IAC1F,2BAA2B,CAAC,QAAgB;QACjD,IAAI,IAAI,CAAC,sBAAsB,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC;eACxF,IAAI,CAAC,sBAAsB,GAAG,QAAQ;YACzC,QAAQ,GAAG,IAAI,CAAC,sBAAsB,CAAC;QACzC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,eAAe;QAC3B,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;QACpC,OAAO,CAAC,QAAQ,GAAG,aAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QAC7C,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA5JD,sCA4JC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\n\r\n/** tolerance blob for various stroking methods.\r\n *\r\n * * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength\r\n * * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.\r\n * * angle is the angle between two contiguous strokes or across a facet edge.\r\n * * maxEdgeLength is the length of a stroke or a edge of a facet.\r\n *\r\n * It is rare for all three to be active at once:\r\n * * Nearly all stroke and facet use cases will apply an angle tolerance.\r\n * * * For curves, 15 degrees is typical\r\n * * * For facets, 22.5 degrees is typical.\r\n * * * Halving the angle tolerance will (roughly) make curves get twice as many strokes, and surfaces get 4 times as many facets.\r\n * * * The angle tolerance has the useful property that its effect is independent of scale of that data. If data is suddenly scaled into millimeters rather than meters, the facet counts remain the same.\r\n * * When creating output for devices such as 3D printing will want a chord tolerance.\r\n * * For graphics display, use an angle tolerance of around 15 degrees and an chord tolerance which is the size of several pixels.\r\n * * Analysis meshes (e.g. Finite Elements) commonly need to apply maxEdgeLength.\r\n * * * Using maxEdgeLength for graphics probably produces too many facets. For example, it causes long cylinders to get many nearly-square facets instead of the small number of long quads usually used for graphics.\r\n * * Facet tolerances are, as the Pirates' Code, guidelines, not absolute rules. Facet and stroke code may ignore tolerances in awkward situations.\r\n * * If multiple tolerances are in effect, the actual count will usually be based on the one that demands the most strokes or facets, unless it is so high that it violates some upper limit on the number of facets on an arc or a section of a curve.\r\n * @public\r\n */\r\nexport class StrokeOptions {\r\n\r\n /** distance from stroke to actual geometry */\r\n public chordTol?: number;\r\n /** turning angle between strokes. */\r\n public angleTol?: Angle;\r\n /** maximum length of a single stroke. */\r\n public maxEdgeLength?: number;\r\n /** caller expects convex facets. */\r\n public needConvexFacets?: boolean;\r\n /** minimum strokes on a primitive */\r\n public minStrokesPerPrimitive?: number;\r\n /** whether or not to triangulate each added facet */\r\n public shouldTriangulate: boolean = false;\r\n private _needNormals?: boolean;\r\n private _needTwoSided?: boolean;\r\n private _needParams?: boolean;\r\n /** Whether params are requested. */\r\n public get needParams(): boolean { return this._needParams !== undefined ? this._needParams : false; }\r\n public set needParams(value: boolean) { this._needParams = value; }\r\n /** Whether normals are requested */\r\n public get needNormals(): boolean { return this._needNormals !== undefined ? this._needNormals : false; }\r\n public set needNormals(value: boolean) { this._needNormals = value; }\r\n /** Whether twoSided is requested. */\r\n public get needTwoSided(): boolean { return this._needTwoSided !== undefined ? this._needTwoSided : false; }\r\n public set needTwoSided(value: boolean) { this._needTwoSided = value; }\r\n /** optional color request flag */\r\n public needColors?: boolean;\r\n /** default number of strokes for a circle. */\r\n public defaultCircleStrokes = 16;\r\n /** ask if angleTol is specified */\r\n public get hasAngleTol(): boolean { return this.angleTol !== undefined && Math.abs(this.angleTol.radians) > 0.0; }\r\n /** ask if chordTol is specified */\r\n public get hasChordTol(): boolean { return this.chordTol !== undefined && this.chordTol > 0.0; }\r\n /** ask if maxEdgeLength is specified */\r\n public get hasMaxEdgeLength(): boolean { return this.maxEdgeLength !== undefined && this.maxEdgeLength > 0.0; }\r\n\r\n /** Return a deep clone */\r\n public clone(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.chordTol = this.chordTol;\r\n options.angleTol = this.angleTol?.clone();\r\n options.maxEdgeLength = this.maxEdgeLength;\r\n options.needConvexFacets = this.needConvexFacets;\r\n options.minStrokesPerPrimitive = this.minStrokesPerPrimitive;\r\n options.shouldTriangulate = this.shouldTriangulate;\r\n options._needNormals = this._needNormals;\r\n options._needTwoSided = this._needTwoSided;\r\n options._needParams = this._needParams;\r\n options.needColors = this.needColors;\r\n options.defaultCircleStrokes = this.defaultCircleStrokes;\r\n return options;\r\n }\r\n\r\n /** return stroke count which is the larger of the minCount or count needed for edge length condition. */\r\n public applyMaxEdgeLength(minCount: number, totalLength: number): number {\r\n totalLength = Math.abs(totalLength);\r\n if (this.maxEdgeLength && this.maxEdgeLength > 0.0 && minCount * this.maxEdgeLength < totalLength) {\r\n minCount = Geometry.stepCount(this.maxEdgeLength, totalLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n\r\n /**\r\n * return stroke count which is the larger of the existing count or count needed for angle condition for given sweepRadians\r\n * * defaultStepRadians is assumed to be larger than zero.\r\n */\r\n public applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number {\r\n return StrokeOptions.applyAngleTol(this, minCount, sweepRadians, defaultStepRadians);\r\n }\r\n /**\r\n * return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance from the options.\r\n */\r\n public static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number {\r\n sweepRadians = Math.abs(sweepRadians);\r\n let stepRadians = defaultStepRadians ? defaultStepRadians : Math.PI / 8.0;\r\n if (options && options.angleTol && options.angleTol.radians > 0.0)\r\n stepRadians = options.angleTol.radians;\r\n if (minCount * stepRadians < sweepRadians)\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n return minCount;\r\n }\r\n /**\r\n * Return the number of strokes needed for given edgeLength curve.\r\n * @param options\r\n * @param minCount smallest allowed count\r\n * @param edgeLength\r\n */\r\n public static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number {\r\n if (edgeLength < 0)\r\n edgeLength = - edgeLength;\r\n if (minCount < 1)\r\n minCount = 1;\r\n if (options && options.maxEdgeLength && options.maxEdgeLength * minCount < edgeLength) {\r\n minCount = Geometry.stepCount(options.maxEdgeLength, edgeLength, minCount);\r\n }\r\n return minCount;\r\n }\r\n /**\r\n * Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength, chord, and minimum stroke.\r\n */\r\n public applyTolerancesToArc(radius: number, sweepRadians: number = Math.PI * 2): number {\r\n let numStrokes = 1;\r\n numStrokes = this.applyAngleTol(numStrokes, sweepRadians, Math.PI * 0.25);\r\n numStrokes = this.applyMaxEdgeLength(numStrokes, sweepRadians * radius);\r\n numStrokes = this.applyChordTol(numStrokes, radius, sweepRadians);\r\n numStrokes = this.applyMinStrokesPerPrimitive(numStrokes);\r\n return numStrokes;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */\r\n public applyChordTol(minCount: number, radius: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0 && this.chordTol < radius) {\r\n const a = this.chordTol;\r\n const stepRadians = 2.0 * Math.acos((1.0 - a / radius));\r\n minCount = Geometry.stepCount(stepRadians, sweepRadians, minCount);\r\n }\r\n return minCount;\r\n }\r\n /** return stroke count which is the larger of existing count or count needed for circular arc chord tol with given arc length and radians\r\n */\r\n public applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number {\r\n if (this.chordTol && this.chordTol > 0.0) {\r\n const radius = Geometry.conditionalDivideFraction(length, sweepRadians);\r\n if (radius !== undefined)\r\n return this.applyChordTol(minCount, radius, sweepRadians);\r\n }\r\n return minCount;\r\n }\r\n\r\n /** return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */\r\n public applyMinStrokesPerPrimitive(minCount: number): number {\r\n if (this.minStrokesPerPrimitive !== undefined && Number.isFinite(this.minStrokesPerPrimitive)\r\n && this.minStrokesPerPrimitive > minCount)\r\n minCount = this.minStrokesPerPrimitive;\r\n return minCount;\r\n }\r\n\r\n /** create `StrokeOptions` with defaults appropriate for curves.\r\n * * angle tolerance of 15 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForCurves(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(15.0);\r\n return options;\r\n }\r\n /** create `StrokeOptions` with defaults appropriate for surfaces facets\r\n * * angle tolerance of 22.5 degrees.\r\n * * all others inactive.\r\n */\r\n public static createForFacets(): StrokeOptions {\r\n const options = new StrokeOptions();\r\n options.angleTol = Angle.createDegrees(22.5);\r\n return options;\r\n }\r\n}\r\n"]}
@@ -322,8 +322,7 @@ class DirectSpiral3d extends TransitionSpiral3d_1.TransitionSpiral3d {
322
322
  }
323
323
  /** Deep clone of this spiral */
324
324
  clone() {
325
- var _a, _b;
326
- return new DirectSpiral3d(this.localToWorld.clone(), this._spiralType, (_a = this.designProperties) === null || _a === void 0 ? void 0 : _a.clone(), this._nominalL1, this._nominalR1, (_b = this._activeFractionInterval) === null || _b === void 0 ? void 0 : _b.clone(), this._evaluator.clone());
325
+ return new DirectSpiral3d(this.localToWorld.clone(), this._spiralType, this.designProperties?.clone(), this._nominalL1, this._nominalR1, this._activeFractionInterval?.clone(), this._evaluator.clone());
327
326
  }
328
327
  /** apply `transform` to this spiral's local to world transform. */
329
328
  tryTransformInPlace(transformA) {
@@ -1 +1 @@
1
- {"version":3,"file":"DirectSpiral3d.js","sourceRoot":"","sources":["../../../../src/curve/spiral/DirectSpiral3d.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,6CAA0C;AAO1C,0DAAuD;AAEvD,+EAA4E;AAC5E,kDAA+C;AAC/C,oDAAiD;AACjD,mFAAgF;AAChF,qDAA6D;AAC7D,iEAAsF;AACtF,uFAAoF;AACpF,qFAA4E;AAC5E,6EAAoE;AAEpE,6DAA0D;AAG1D;;;;;;;;;;;;;;;EAeE;AACF,MAAa,cAAe,SAAQ,uCAAkB;IA+BpD,sEAAsE;IACtE,iEAAiE;IACjE,YACE,YAAuB,EACvB,UAA8B,EAC9B,kBAA+D,EAC/D,SAAiB,EACjB,SAAiB,EACjB,sBAA6C,EAC7C,SAA2B;QAC3B,KAAK,CAAC,UAAU,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,CAAC,CAAC;QAvC9E,wCAAwC;QAExB,uBAAkB,GAAG,kBAAkB,CAAC;QAsCtD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,cAAc,GAAG,2BAAY,CAAC,MAAM,EAAE,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,2BAAY,CAAC,MAAM,EAAE,CAAC;QAC5C,yFAAyF;QACzF,IAAI,CAAC,yBAAyB,EAAE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uB,CAAC,aAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC;mBACzE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SACtD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1iBD,wCA0iBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Angle } from \"../../geometry3d/Angle\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\r\nimport { Segment1d } from \"../../geometry3d/Segment1d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { CurveLengthContext } from \"../internalContexts/CurveLengthContext\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\nimport { AustralianRailCorpXYEvaluator } from \"./AustralianRailCorpXYEvaluator\";\r\nimport { ClothoidSeriesRLEvaluator } from \"./ClothoidSeries\";\r\nimport { CzechSpiralEvaluator, ItalianSpiralEvaluator } from \"./CzechSpiralEvaluator\";\r\nimport { DirectHalfCosineSpiralEvaluator } from \"./DirectHalfCosineSpiralEvaluator\";\r\nimport { MXCubicAlongArcEvaluator } from \"./MXCubicAlongArcSpiralEvaluator\";\r\nimport { PolishCubicEvaluator } from \"./PolishCubicSpiralEvaluator\";\r\nimport { TransitionConditionalProperties } from \"./TransitionConditionalProperties\";\r\nimport { TransitionSpiral3d } from \"./TransitionSpiral3d\";\r\nimport { XYCurveEvaluator } from \"./XYCurveEvaluator\";\r\n\r\n/**\r\n* DirectSpiral3d acts like a TransitionSpiral3d for serialization purposes, but implements spiral types that have \"direct\" xy calculations without the integrations required\r\n* for IntegratedSpiral3d.\r\n* * Each DirectSpiral3d carries an XYCurveEvaluator to give it specialized behavior.\r\n* * Direct spirals that flow through serialization to native imodel02 are create with these static methods:\r\n* * createArema\r\n* * createJapaneseCubic\r\n* * createAustralianRail\r\n* * createDirectHalfCosine\r\n* * createChineseCubic\r\n* * createCzechCubic\r\n* * createPolishCubic\r\n* * createItalian\r\n* * createWesternAustralian\r\n* @public\r\n*/\r\nexport class DirectSpiral3d extends TransitionSpiral3d {\r\n\r\n /** String name for schema properties */\r\n\r\n public readonly curvePrimitiveType = \"transitionSpiral\";\r\n\r\n /** stroked approximation of entire spiral. This is AFTER the localToWorld transform ... */\r\n private _globalStrokes: LineString3d;\r\n /** stroked approximation of active spiral. This is AFTER the localToWorld transfomr ...\r\n * * Same count as global -- possibly overly fine, but it gives some consistency between same clothoid constructed as partial versus complete.\r\n * * If no trimming, this points to the same place as the _globalStrokes !!! Don't double transform!!!\r\n */\r\n private _activeStrokes?: LineString3d;\r\n /** Return the internal stroked form of the (possibly partial) spiral */\r\n public get activeStrokes(): LineString3d { return this._activeStrokes !== undefined ? this._activeStrokes : this._globalStrokes; }\r\n\r\n private _nominalL1: number;\r\n private _nominalR1: number;\r\n private _evaluator: XYCurveEvaluator;\r\n\r\n /** Return the nominal end radius. */\r\n public get nominalR1(): number { return this._nominalR1; }\r\n /** Return the nominal distance from inflection to endpoint. */\r\n public get nominalL1(): number { return this._nominalL1; }\r\n /** Return the nominal end curvature */\r\n public get nominalCurvature1(): number { return TransitionSpiral3d.radiusToCurvature(this._nominalR1); }\r\n /** Return the low level evaluator\r\n * @internal\r\n */\r\n public get evaluator(): XYCurveEvaluator { return this._evaluator; }\r\n\r\n // constructor demands radius1 and distance1 for nominal construction.\r\n // caller is responsible for managing intervals of partial spiral\r\n constructor(\r\n localToWorld: Transform,\r\n spiralType: string | undefined,\r\n originalProperties: TransitionConditionalProperties | undefined,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeFractionInterval: Segment1d | undefined,\r\n evaluator: XYCurveEvaluator) {\r\n super(spiralType, localToWorld, activeFractionInterval, originalProperties);\r\n this._nominalL1 = nominalL1;\r\n this._nominalR1 = nominalR1;\r\n this._evaluator = evaluator;\r\n this._globalStrokes = LineString3d.create();\r\n this._activeStrokes = LineString3d.create();\r\n // initialize for compiler -- but this will be recomputed in refreshComputeProperties ...\r\n this.refreshComputedProperties();\r\n }\r\n /**\r\n * Compute stroke data in an interval.\r\n * @param strokes strokes to clear and refill.\r\n * @param fraction0 start fraction\r\n * @param fraction1 end fraction\r\n */\r\n private computeStrokes(strokes: LineString3d, fractionA: number, fractionB: number, numInterval: number, applyLocalToWorld: boolean = true) {\r\n if (numInterval < 1)\r\n numInterval = 1;\r\n strokes.clear();\r\n strokes.ensureEmptyUVParams();\r\n strokes.ensureEmptyFractions();\r\n const distances = strokes.packedUVParams!;\r\n const nominalIntervalLength = Math.abs(fractionB - fractionA) * this._nominalL1;\r\n for (let i = 0; i <= numInterval; i++) {\r\n const fraction = Geometry.interpolate(fractionA, i / numInterval, fractionB);\r\n const nominalDistanceAlong = fraction * nominalIntervalLength;\r\n strokes.packedPoints.pushXYZ(this._evaluator.fractionToX(fraction),\r\n this._evaluator.fractionToY(fraction), 0);\r\n distances.pushXY(fraction, nominalDistanceAlong); // the second distance will be updated below\r\n }\r\n if (applyLocalToWorld)\r\n strokes.tryTransformInPlace (this._localToWorld);\r\n let fraction0 = distances.getXAtUncheckedPointIndex(0);\r\n let trueDistance0 = distances.getYAtUncheckedPointIndex(0); // whatever was assigned as start distance is fine\r\n let trueDistance1, fraction1;\r\n for (let i = 1; i <= numInterval; i++) {\r\n fraction1 = distances.getXAtUncheckedPointIndex(i);\r\n trueDistance1 = trueDistance0 + this._evaluator.integrateDistanceBetweenFractions(fraction0, fraction1);\r\n distances.setXYAtCheckedPointIndex(i, fraction1, trueDistance1);\r\n fraction0 = fraction1;\r\n trueDistance0 = trueDistance1;\r\n }\r\n\r\n }\r\n /** Recompute strokes */\r\n public override refreshComputedProperties() {\r\n const sweepRadians = this.nominalL1 / (2.0 * this.nominalR1);\r\n const radiansStep = 0.02;\r\n const numInterval = StrokeOptions.applyAngleTol(undefined, 4, sweepRadians, radiansStep);\r\n this.computeStrokes(this._globalStrokes, 0, 1, numInterval);\r\n const numActiveInterval = Math.ceil(this._activeFractionInterval.absoluteDelta() * numInterval);\r\n this._activeStrokes = LineString3d.create();\r\n this.computeStrokes(this._activeStrokes, this._activeFractionInterval.x0, this._activeFractionInterval.x1,\r\n numActiveInterval);\r\n }\r\n /**\r\n * Create a spiral object which uses numXTerm terms from the clothoid X series and numYTerm from the clothoid Y series.\r\n * @param numXTerm number of terms to use from X series\r\n * @param numYTerm number of terms to use from Y series\r\n * @param localToWorld placement frame. Inflection point is at origin, initial direction is along x axis.\r\n * @param nominalL1 design distance from inflection to end point.\r\n * @param nominalR1 design radius at end point.\r\n * @param activeInterval active interval (as fractions of nominalL1 !!!)\r\n */\r\n public static createTruncatedClothoid(\r\n spiralType: string,\r\n localToWorld: Transform,\r\n numXTerm: number, numYTerm: number,\r\n originalProperties: TransitionConditionalProperties | undefined,\r\n nominalL1: number, nominalR1: number,\r\n activeInterval: Segment1d | undefined): DirectSpiral3d | undefined {\r\n if (numXTerm < 1)\r\n numXTerm = 1;\r\n if (numYTerm < 1)\r\n numYTerm = 1;\r\n const evaluator = new ClothoidSeriesRLEvaluator(nominalL1, 1.0 / (2.0 * nominalL1 * nominalR1), numXTerm, numYTerm);\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n spiralType,\r\n originalProperties,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n /**\r\n * Create an Japanese spiral clothoid approximation\r\n * * X is 1 terms of the clothoid series as a function of nominal distance along.\r\n * * Y is 1 terms f the clothoid series as a function of nominal distance along.\r\n * * Remark: This is identical to the ChineseCubic\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createJapaneseCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"JapaneseCubic\", localToWorld, 1, 1, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create a czech cubic.\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * @param localToWorld\r\n * @param nominalLx nominal length along x axis\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createCzechCubic(\r\n localToWorld: Transform,\r\n nominalLx: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = CzechSpiralEvaluator.create(nominalLx, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"Czech\",\r\n undefined,\r\n nominalLx, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n /**\r\n * Create an italian spiral\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * * L in gamma and m is the\r\n * @param localToWorld\r\n * @param nominalL1 nominal length along the spiral\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createItalian(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = ItalianSpiralEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"Italian\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create an MX Cubic whose nominal length is close to along the curve.\r\n * This is y= m*x^3 with\r\n * * m is 1/ (6RL1)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * L1 is an along-the-x-axis distance that is slightly LESS THAN the nominal length\r\n * * x is axis position that is slightly LESS than nominal distance along\r\n * * L1, x use the approximation `x = s * ( 1 - s^4/ (40 R R L L))\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createMXCubicAlongArc(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = MXCubicAlongArcEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"MXCubicAlongArc\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create a polish cubic\r\n * This is y= m*x^3 with\r\n * * m is 1/ (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * L is nominal length\r\n * * R is nominal end radius.\r\n * * x ranges up to the x axis distance for which the polish distance series produces f(x)=L\r\n * * The support class PolishCubicEvaluator has static methods for the distance series and its inversion.\r\n */\r\n public static createPolishCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = PolishCubicEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"PolishCubic\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create an AustralianRailCorp spiral\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createAustralianRail(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = AustralianRailCorpXYEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"AustralianRailCorp\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n public static createDirectHalfCosine(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return new this(localToWorld, \"HalfCosine\", undefined, nominalL1, nominalR1, activeInterval,\r\n new DirectHalfCosineSpiralEvaluator(nominalL1, nominalR1));\r\n }\r\n /**\r\n * Create an Arema spiral clothoid approximation\r\n * * X is 2 terms of the clothoid series as a function of nominal distance along\r\n * * Y is 2 terms f the clothoid series as a function of nominal distance along\r\n * * Remark: This is identical to the ChineseCubic\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createArema(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"Arema\", localToWorld, 2, 2, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n\r\n /**\r\n * Create a Chinese clothoid approximation\r\n * * X is 2 terms of the clothoid series as a function of nominal distance along\r\n * * Y is 2 terms f the clothoid series as a function of nominal distance along\r\n * * Remark: This is identical to the Arema spiral\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createChineseCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"ChineseCubic\", localToWorld, 2, 2, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create a Western Australian direct spiral.\r\n * * X is 2 terms of the clothoid series as a function of distance along\r\n * * Y is 1 term (cubic in nominal distance along)\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createWesternAustralian(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"WesternAustralian\", localToWorld, 2, 1, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create (if possible) a DirectSpiral3d, applying various strict conditions appropriate to the spiral type.\r\n * The parameter list includes extraneous values in order to directly match IntegratedSpiral3d.create, which has greater flexibility about\r\n * mixtures of values.\r\n * * IMPORTANT RESTRICTIONS\r\n * * Direct spirals must have the inflection at the origin of their coordinate system, aligned with the x axis.\r\n * * hence bearing0 = 0\r\n * * hence radius0 = 0\r\n * * bearing1 is ignored\r\n * * radius1 must be given.\r\n * * arcLength must be given,\r\n * @param spiralType one of the types in `DirectSpiralTypeNames`\r\n * @param radius0 radius (or 0 for tangent to line) at start. Must be ZERO or UNDEFINED\r\n * @param radius1 radius (or 0 for tangent to line) at end.\r\n * @param bearing0 bearing, measured CCW from x axis at start. Must be ZERO or UNDEFINED\r\n * @param bearing1 bearing, measured CCW from x axis at end. IGNORED.\r\n * @param fractionInterval optional fractional interval for an \"active\" portion of the curve. if omitted, the full [0,1] is used.\r\n * @param localToWorld placement transform\r\n */\r\n public static createFromLengthAndRadius(\r\n spiralType: string,\r\n radius0: number | undefined,\r\n radius1: number | undefined,\r\n bearing0: Angle | undefined,\r\n _bearing1: Angle | undefined,\r\n arcLength: number | undefined,\r\n activeInterval: undefined | Segment1d,\r\n localToWorld: Transform): TransitionSpiral3d | undefined {\r\n if (bearing0 !== undefined && !bearing0.isAlmostZero)\r\n return undefined;\r\n if (radius0 !== undefined && !Geometry.isSmallMetricDistance(radius0))\r\n return undefined;\r\n if (radius1 === undefined || Geometry.isSmallMetricDistance(radius1))\r\n return undefined;\r\n if (arcLength === undefined)\r\n return undefined;\r\n if (Geometry.equalStringNoCase(spiralType, \"Arema\"))\r\n return this.createArema(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"ChineseCubic\"))\r\n return this.createChineseCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"JapaneseCubic\"))\r\n return this.createJapaneseCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"HalfCosine\"))\r\n return this.createDirectHalfCosine(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"Czech\"))\r\n return this.createCzechCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"Italian\"))\r\n return this.createItalian(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"AustralianRailCorp\"))\r\n return this.createAustralianRail(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"MXCubicAlongArc\"))\r\n return this.createMXCubicAlongArc(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"WesternAustralian\"))\r\n return this.createWesternAustralian(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"PolishCubic\"))\r\n return this.createPolishCubic(localToWorld, arcLength, radius1, activeInterval);\r\n return undefined;\r\n }\r\n /** Deep clone of this spiral */\r\n public override clone(): DirectSpiral3d {\r\n return new DirectSpiral3d(\r\n this.localToWorld.clone(),\r\n this._spiralType,\r\n this.designProperties?.clone(),\r\n this._nominalL1,\r\n this._nominalR1,\r\n this._activeFractionInterval?.clone(),\r\n this._evaluator.clone());\r\n }\r\n\r\n /** apply `transform` to this spiral's local to world transform. */\r\n public tryTransformInPlace(transformA: Transform): boolean {\r\n const rigidData = this.applyRigidPartOfTransform(transformA);\r\n if (rigidData !== undefined) {\r\n this._nominalL1 *= rigidData.scale;\r\n this._nominalR1 *= rigidData.scale;\r\n this.evaluator.scaleInPlace(rigidData.scale);\r\n }\r\n this.refreshComputedProperties();\r\n return true;\r\n }\r\n\r\n /** Return the spiral start point. */\r\n public override startPoint(): Point3d { return this.activeStrokes.startPoint(); }\r\n /** return the spiral end point. */\r\n public override endPoint(): Point3d { return this.activeStrokes.endPoint(); }\r\n /** test if the local to world transform places the spiral xy plane into `plane` */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return plane.isPointInPlane(this.localToWorld.origin as Point3d)\r\n && Geometry.isSameCoordinate(0.0, this.localToWorld.matrix.dotColumnX(plane.getNormalRef()))\r\n && Geometry.isSameCoordinate(0.0, this.localToWorld.matrix.dotColumnY(plane.getNormalRef()));\r\n }\r\n /** Return quick length of the spiral.\r\n * The tangent vector of a true clothoid is length 1 everywhere, so simple proportion of nominalL1 is a good approximation.\r\n */\r\n public quickLength() {\r\n const distanceData = this._globalStrokes.packedUVParams!;\r\n const n = distanceData.length;\r\n return distanceData.getYAtUncheckedPointIndex(n - 1);\r\n }\r\n /** Return length of the spiral.\r\n * * True length is stored at back of uvParams . . .\r\n */\r\n // use the generic integrator ... public override curveLength() { return this.quickLength(); }\r\n /** Test if `other` is an instance of `TransitionSpiral3d` */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof DirectSpiral3d; }\r\n /** Add strokes from this spiral to `dest`.\r\n * * Linestrings will usually stroke as just their points.\r\n * * If maxEdgeLength is given, this will sub-stroke within the linestring -- not what we want.\r\n */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void { this.activeStrokes.emitStrokes(dest, options); }\r\n /** emit stroke fragments to `dest` handler. */\r\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\r\n const n = this.computeStrokeCountForOptions(options);\r\n const activeStrokes = this.activeStrokes;\r\n dest.startParentCurvePrimitive(this);\r\n\r\n // hack: specify the extended range so we can compute length of an extended spiral\r\n let globalFraction0 = 0.0;\r\n let globalFraction1 = 1.0;\r\n if (dest instanceof CurveLengthContext) {\r\n if (dest.getFraction0 < 0.0)\r\n globalFraction0 = dest.getFraction0;\r\n if (dest.getFraction1 > 1.0)\r\n globalFraction1 = dest.getFraction1;\r\n }\r\n\r\n if (n <= activeStrokes.numPoints())\r\n dest.announceIntervalForUniformStepStrokes(this, 2 * activeStrokes.numPoints(), globalFraction0, globalFraction1);\r\n else\r\n dest.announceIntervalForUniformStepStrokes(this, n, globalFraction0, globalFraction1);\r\n\r\n dest.endParentCurvePrimitive(this);\r\n }\r\n\r\n /**\r\n * return the stroke count required for given options.\r\n * @param options StrokeOptions that determine count\r\n */\r\n\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n let numStroke;\r\n const nominalRadians = this._nominalL1 / (2.0 * this._nominalR1);\r\n if (options) {\r\n const rMin = Math.abs(this._nominalR1);\r\n numStroke = options.applyTolerancesToArc(rMin, nominalRadians);\r\n numStroke = options.applyMaxEdgeLength(numStroke, this.quickLength());\r\n numStroke = options.applyMinStrokesPerPrimitive(numStroke);\r\n } else {\r\n numStroke = StrokeOptions.applyAngleTol(undefined, 4, nominalRadians, 0.02);\r\n }\r\n numStroke = Math.ceil(this._activeFractionInterval.absoluteDelta() * numStroke);\r\n return numStroke;\r\n }\r\n\r\n /** Reverse the active interval and active strokes.\r\n * * Primary defining data remains unchanged !!!\r\n */\r\n\r\n public reverseInPlace(): void {\r\n this._activeFractionInterval.reverseInPlace();\r\n if (this._activeStrokes === undefined)\r\n this._activeStrokes = this._globalStrokes.clone();\r\n this._activeStrokes.reverseInPlace();\r\n }\r\n /** Evaluate curve point with respect to fraction. */\r\n public fractionToPoint(activeFraction: number, result?: Point3d): Point3d {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPoint(globalFraction, result);\r\n this.localToWorld.multiplyPoint3d(result, result);\r\n return result;\r\n }\r\n /** Evaluate curve point and derivative with respect to fraction. */\r\n public fractionToPointAndDerivative(activeFraction: number, result?: Ray3d): Ray3d {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPointAndDerivative(globalFraction, result);\r\n result.direction.scaleInPlace(this._activeFractionInterval.signedDelta());\r\n result.transformInPlace(this.localToWorld);\r\n return result;\r\n }\r\n\r\n /** Return a plane with\r\n *\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\r\n * * vectorV is the second derivative, i.e.derivative of vectorU.\r\n */\r\n\r\n public fractionToPointAnd2Derivatives(activeFraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPointAnd2Derivatives(globalFraction, result);\r\n const a = this._activeFractionInterval.signedDelta();\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n result.transformInPlace(this.localToWorld);\r\n return result;\r\n }\r\n /** Second step of double dispatch: call `handler.handleTransitionSpiral(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleTransitionSpiral(this);\r\n }\r\n /** compare various coordinate quantities */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof DirectSpiral3d) {\r\n return Geometry.isSameCoordinate(this._nominalL1, other._nominalL1)\r\n && Geometry.isSameCoordinate(this._nominalR1, other._nominalR1)\r\n && this.localToWorld.isAlmostEqual(other.localToWorld)\r\n && this._activeFractionInterval.isAlmostEqual(other._activeFractionInterval)\r\n && this._evaluator.isAlmostEqual(other._evaluator);\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"DirectSpiral3d.js","sourceRoot":"","sources":["../../../../src/curve/spiral/DirectSpiral3d.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,6CAA0C;AAO1C,0DAAuD;AAEvD,+EAA4E;AAC5E,kDAA+C;AAC/C,oDAAiD;AACjD,mFAAgF;AAChF,qDAA6D;AAC7D,iEAAsF;AACtF,uFAAoF;AACpF,qFAA4E;AAC5E,6EAAoE;AAEpE,6DAA0D;AAG1D;;;;;;;;;;;;;;;EAeE;AACF,MAAa,cAAe,SAAQ,uCAAkB;IA+BpD,sEAAsE;IACtE,iEAAiE;IACjE,YACE,YAAuB,EACvB,UAA8B,EAC9B,kBAA+D,EAC/D,SAAiB,EACjB,SAAiB,EACjB,sBAA6C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yBAAyB,CAAC,OAAwB;QACvD,OAAO,OAAO,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IACD,4CAA4C;IAC5B,aAAa,CAAC,KAAU;QACtC,IAAI,KAAK,YAAY,cAAc,EAAE;YACnC,OAAO,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;mBAC9D,mBAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC;mBAC5D,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC;mBACnD,IAAI,CAAC,uBAAuB,CAAC,aAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC;mBACzE,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SACtD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA1iBD,wCA0iBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Angle } from \"../../geometry3d/Angle\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../../geometry3d/GeometryHandler\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../../geometry3d/Plane3dByOriginAndVectors\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { Ray3d } from \"../../geometry3d/Ray3d\";\r\nimport { Segment1d } from \"../../geometry3d/Segment1d\";\r\nimport { Transform } from \"../../geometry3d/Transform\";\r\nimport { CurveLengthContext } from \"../internalContexts/CurveLengthContext\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { StrokeOptions } from \"../StrokeOptions\";\r\nimport { AustralianRailCorpXYEvaluator } from \"./AustralianRailCorpXYEvaluator\";\r\nimport { ClothoidSeriesRLEvaluator } from \"./ClothoidSeries\";\r\nimport { CzechSpiralEvaluator, ItalianSpiralEvaluator } from \"./CzechSpiralEvaluator\";\r\nimport { DirectHalfCosineSpiralEvaluator } from \"./DirectHalfCosineSpiralEvaluator\";\r\nimport { MXCubicAlongArcEvaluator } from \"./MXCubicAlongArcSpiralEvaluator\";\r\nimport { PolishCubicEvaluator } from \"./PolishCubicSpiralEvaluator\";\r\nimport { TransitionConditionalProperties } from \"./TransitionConditionalProperties\";\r\nimport { TransitionSpiral3d } from \"./TransitionSpiral3d\";\r\nimport { XYCurveEvaluator } from \"./XYCurveEvaluator\";\r\n\r\n/**\r\n* DirectSpiral3d acts like a TransitionSpiral3d for serialization purposes, but implements spiral types that have \"direct\" xy calculations without the integrations required\r\n* for IntegratedSpiral3d.\r\n* * Each DirectSpiral3d carries an XYCurveEvaluator to give it specialized behavior.\r\n* * Direct spirals that flow through serialization to native imodel02 are create with these static methods:\r\n* * createArema\r\n* * createJapaneseCubic\r\n* * createAustralianRail\r\n* * createDirectHalfCosine\r\n* * createChineseCubic\r\n* * createCzechCubic\r\n* * createPolishCubic\r\n* * createItalian\r\n* * createWesternAustralian\r\n* @public\r\n*/\r\nexport class DirectSpiral3d extends TransitionSpiral3d {\r\n\r\n /** String name for schema properties */\r\n\r\n public readonly curvePrimitiveType = \"transitionSpiral\";\r\n\r\n /** stroked approximation of entire spiral. This is AFTER the localToWorld transform ... */\r\n private _globalStrokes: LineString3d;\r\n /** stroked approximation of active spiral. This is AFTER the localToWorld transfomr ...\r\n * * Same count as global -- possibly overly fine, but it gives some consistency between same clothoid constructed as partial versus complete.\r\n * * If no trimming, this points to the same place as the _globalStrokes !!! Don't double transform!!!\r\n */\r\n private _activeStrokes?: LineString3d;\r\n /** Return the internal stroked form of the (possibly partial) spiral */\r\n public get activeStrokes(): LineString3d { return this._activeStrokes !== undefined ? this._activeStrokes : this._globalStrokes; }\r\n\r\n private _nominalL1: number;\r\n private _nominalR1: number;\r\n private _evaluator: XYCurveEvaluator;\r\n\r\n /** Return the nominal end radius. */\r\n public get nominalR1(): number { return this._nominalR1; }\r\n /** Return the nominal distance from inflection to endpoint. */\r\n public get nominalL1(): number { return this._nominalL1; }\r\n /** Return the nominal end curvature */\r\n public get nominalCurvature1(): number { return TransitionSpiral3d.radiusToCurvature(this._nominalR1); }\r\n /** Return the low level evaluator\r\n * @internal\r\n */\r\n public get evaluator(): XYCurveEvaluator { return this._evaluator; }\r\n\r\n // constructor demands radius1 and distance1 for nominal construction.\r\n // caller is responsible for managing intervals of partial spiral\r\n constructor(\r\n localToWorld: Transform,\r\n spiralType: string | undefined,\r\n originalProperties: TransitionConditionalProperties | undefined,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeFractionInterval: Segment1d | undefined,\r\n evaluator: XYCurveEvaluator) {\r\n super(spiralType, localToWorld, activeFractionInterval, originalProperties);\r\n this._nominalL1 = nominalL1;\r\n this._nominalR1 = nominalR1;\r\n this._evaluator = evaluator;\r\n this._globalStrokes = LineString3d.create();\r\n this._activeStrokes = LineString3d.create();\r\n // initialize for compiler -- but this will be recomputed in refreshComputeProperties ...\r\n this.refreshComputedProperties();\r\n }\r\n /**\r\n * Compute stroke data in an interval.\r\n * @param strokes strokes to clear and refill.\r\n * @param fraction0 start fraction\r\n * @param fraction1 end fraction\r\n */\r\n private computeStrokes(strokes: LineString3d, fractionA: number, fractionB: number, numInterval: number, applyLocalToWorld: boolean = true) {\r\n if (numInterval < 1)\r\n numInterval = 1;\r\n strokes.clear();\r\n strokes.ensureEmptyUVParams();\r\n strokes.ensureEmptyFractions();\r\n const distances = strokes.packedUVParams!;\r\n const nominalIntervalLength = Math.abs(fractionB - fractionA) * this._nominalL1;\r\n for (let i = 0; i <= numInterval; i++) {\r\n const fraction = Geometry.interpolate(fractionA, i / numInterval, fractionB);\r\n const nominalDistanceAlong = fraction * nominalIntervalLength;\r\n strokes.packedPoints.pushXYZ(this._evaluator.fractionToX(fraction),\r\n this._evaluator.fractionToY(fraction), 0);\r\n distances.pushXY(fraction, nominalDistanceAlong); // the second distance will be updated below\r\n }\r\n if (applyLocalToWorld)\r\n strokes.tryTransformInPlace (this._localToWorld);\r\n let fraction0 = distances.getXAtUncheckedPointIndex(0);\r\n let trueDistance0 = distances.getYAtUncheckedPointIndex(0); // whatever was assigned as start distance is fine\r\n let trueDistance1, fraction1;\r\n for (let i = 1; i <= numInterval; i++) {\r\n fraction1 = distances.getXAtUncheckedPointIndex(i);\r\n trueDistance1 = trueDistance0 + this._evaluator.integrateDistanceBetweenFractions(fraction0, fraction1);\r\n distances.setXYAtCheckedPointIndex(i, fraction1, trueDistance1);\r\n fraction0 = fraction1;\r\n trueDistance0 = trueDistance1;\r\n }\r\n\r\n }\r\n /** Recompute strokes */\r\n public override refreshComputedProperties() {\r\n const sweepRadians = this.nominalL1 / (2.0 * this.nominalR1);\r\n const radiansStep = 0.02;\r\n const numInterval = StrokeOptions.applyAngleTol(undefined, 4, sweepRadians, radiansStep);\r\n this.computeStrokes(this._globalStrokes, 0, 1, numInterval);\r\n const numActiveInterval = Math.ceil(this._activeFractionInterval.absoluteDelta() * numInterval);\r\n this._activeStrokes = LineString3d.create();\r\n this.computeStrokes(this._activeStrokes, this._activeFractionInterval.x0, this._activeFractionInterval.x1,\r\n numActiveInterval);\r\n }\r\n /**\r\n * Create a spiral object which uses numXTerm terms from the clothoid X series and numYTerm from the clothoid Y series.\r\n * @param numXTerm number of terms to use from X series\r\n * @param numYTerm number of terms to use from Y series\r\n * @param localToWorld placement frame. Inflection point is at origin, initial direction is along x axis.\r\n * @param nominalL1 design distance from inflection to end point.\r\n * @param nominalR1 design radius at end point.\r\n * @param activeInterval active interval (as fractions of nominalL1 !!!)\r\n */\r\n public static createTruncatedClothoid(\r\n spiralType: string,\r\n localToWorld: Transform,\r\n numXTerm: number, numYTerm: number,\r\n originalProperties: TransitionConditionalProperties | undefined,\r\n nominalL1: number, nominalR1: number,\r\n activeInterval: Segment1d | undefined): DirectSpiral3d | undefined {\r\n if (numXTerm < 1)\r\n numXTerm = 1;\r\n if (numYTerm < 1)\r\n numYTerm = 1;\r\n const evaluator = new ClothoidSeriesRLEvaluator(nominalL1, 1.0 / (2.0 * nominalL1 * nominalR1), numXTerm, numYTerm);\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n spiralType,\r\n originalProperties,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n /**\r\n * Create an Japanese spiral clothoid approximation\r\n * * X is 1 terms of the clothoid series as a function of nominal distance along.\r\n * * Y is 1 terms f the clothoid series as a function of nominal distance along.\r\n * * Remark: This is identical to the ChineseCubic\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createJapaneseCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"JapaneseCubic\", localToWorld, 1, 1, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create a czech cubic.\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * @param localToWorld\r\n * @param nominalLx nominal length along x axis\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createCzechCubic(\r\n localToWorld: Transform,\r\n nominalLx: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = CzechSpiralEvaluator.create(nominalLx, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"Czech\",\r\n undefined,\r\n nominalLx, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n /**\r\n * Create an italian spiral\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * * L in gamma and m is the\r\n * @param localToWorld\r\n * @param nominalL1 nominal length along the spiral\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createItalian(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = ItalianSpiralEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"Italian\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create an MX Cubic whose nominal length is close to along the curve.\r\n * This is y= m*x^3 with\r\n * * m is 1/ (6RL1)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * L1 is an along-the-x-axis distance that is slightly LESS THAN the nominal length\r\n * * x is axis position that is slightly LESS than nominal distance along\r\n * * L1, x use the approximation `x = s * ( 1 - s^4/ (40 R R L L))\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createMXCubicAlongArc(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = MXCubicAlongArcEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"MXCubicAlongArc\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create a polish cubic\r\n * This is y= m*x^3 with\r\n * * m is 1/ (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * L is nominal length\r\n * * R is nominal end radius.\r\n * * x ranges up to the x axis distance for which the polish distance series produces f(x)=L\r\n * * The support class PolishCubicEvaluator has static methods for the distance series and its inversion.\r\n */\r\n public static createPolishCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = PolishCubicEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"PolishCubic\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n /**\r\n * Create an AustralianRailCorp spiral\r\n * This is y= m*x^3 with\r\n * * x any point on the x axis\r\n * * `fraction` along the spiral goes to `x = fraction * L`\r\n * * m is gamma / (6RL)\r\n * * 1/(6RL) is the leading term of the sine series.\r\n * * `gamma = 2R/sqrt (4RR-LL)` pushes y up a little bit to simulate the lost series terms.\r\n * @param localToWorld\r\n * @param nominalL1\r\n * @param nominalR1\r\n * @param activeInterval\r\n */\r\n public static createAustralianRail(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n const evaluator = AustralianRailCorpXYEvaluator.create(nominalL1, nominalR1);\r\n if (evaluator === undefined)\r\n return undefined;\r\n return new DirectSpiral3d(\r\n localToWorld.clone(),\r\n \"AustralianRailCorp\",\r\n undefined,\r\n nominalL1, nominalR1,\r\n activeInterval ? activeInterval.clone() : Segment1d.create(0, 1), evaluator);\r\n }\r\n\r\n public static createDirectHalfCosine(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return new this(localToWorld, \"HalfCosine\", undefined, nominalL1, nominalR1, activeInterval,\r\n new DirectHalfCosineSpiralEvaluator(nominalL1, nominalR1));\r\n }\r\n /**\r\n * Create an Arema spiral clothoid approximation\r\n * * X is 2 terms of the clothoid series as a function of nominal distance along\r\n * * Y is 2 terms f the clothoid series as a function of nominal distance along\r\n * * Remark: This is identical to the ChineseCubic\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createArema(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"Arema\", localToWorld, 2, 2, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n\r\n /**\r\n * Create a Chinese clothoid approximation\r\n * * X is 2 terms of the clothoid series as a function of nominal distance along\r\n * * Y is 2 terms f the clothoid series as a function of nominal distance along\r\n * * Remark: This is identical to the Arema spiral\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createChineseCubic(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"ChineseCubic\", localToWorld, 2, 2, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create a Western Australian direct spiral.\r\n * * X is 2 terms of the clothoid series as a function of distance along\r\n * * Y is 1 term (cubic in nominal distance along)\r\n * @param localToWorld axes with inflection at origin, tangent along x axis\r\n * @param nominalL1 nominal length as used in series LR terms.\r\n * @param nominalR1 nominal final radius as used in series LR terms\r\n * @param activeInterval fractional interval with (0, nominalL1) range for nominal distance along\r\n */\r\n public static createWesternAustralian(\r\n localToWorld: Transform,\r\n nominalL1: number,\r\n nominalR1: number,\r\n activeInterval?: Segment1d): DirectSpiral3d | undefined {\r\n return this.createTruncatedClothoid(\"WesternAustralian\", localToWorld, 2, 1, undefined, nominalL1, nominalR1, activeInterval);\r\n }\r\n /**\r\n * Create (if possible) a DirectSpiral3d, applying various strict conditions appropriate to the spiral type.\r\n * The parameter list includes extraneous values in order to directly match IntegratedSpiral3d.create, which has greater flexibility about\r\n * mixtures of values.\r\n * * IMPORTANT RESTRICTIONS\r\n * * Direct spirals must have the inflection at the origin of their coordinate system, aligned with the x axis.\r\n * * hence bearing0 = 0\r\n * * hence radius0 = 0\r\n * * bearing1 is ignored\r\n * * radius1 must be given.\r\n * * arcLength must be given,\r\n * @param spiralType one of the types in `DirectSpiralTypeNames`\r\n * @param radius0 radius (or 0 for tangent to line) at start. Must be ZERO or UNDEFINED\r\n * @param radius1 radius (or 0 for tangent to line) at end.\r\n * @param bearing0 bearing, measured CCW from x axis at start. Must be ZERO or UNDEFINED\r\n * @param bearing1 bearing, measured CCW from x axis at end. IGNORED.\r\n * @param fractionInterval optional fractional interval for an \"active\" portion of the curve. if omitted, the full [0,1] is used.\r\n * @param localToWorld placement transform\r\n */\r\n public static createFromLengthAndRadius(\r\n spiralType: string,\r\n radius0: number | undefined,\r\n radius1: number | undefined,\r\n bearing0: Angle | undefined,\r\n _bearing1: Angle | undefined,\r\n arcLength: number | undefined,\r\n activeInterval: undefined | Segment1d,\r\n localToWorld: Transform): TransitionSpiral3d | undefined {\r\n if (bearing0 !== undefined && !bearing0.isAlmostZero)\r\n return undefined;\r\n if (radius0 !== undefined && !Geometry.isSmallMetricDistance(radius0))\r\n return undefined;\r\n if (radius1 === undefined || Geometry.isSmallMetricDistance(radius1))\r\n return undefined;\r\n if (arcLength === undefined)\r\n return undefined;\r\n if (Geometry.equalStringNoCase(spiralType, \"Arema\"))\r\n return this.createArema(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"ChineseCubic\"))\r\n return this.createChineseCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"JapaneseCubic\"))\r\n return this.createJapaneseCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"HalfCosine\"))\r\n return this.createDirectHalfCosine(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"Czech\"))\r\n return this.createCzechCubic(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"Italian\"))\r\n return this.createItalian(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"AustralianRailCorp\"))\r\n return this.createAustralianRail(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"MXCubicAlongArc\"))\r\n return this.createMXCubicAlongArc(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"WesternAustralian\"))\r\n return this.createWesternAustralian(localToWorld, arcLength, radius1, activeInterval);\r\n if (Geometry.equalStringNoCase(spiralType, \"PolishCubic\"))\r\n return this.createPolishCubic(localToWorld, arcLength, radius1, activeInterval);\r\n return undefined;\r\n }\r\n /** Deep clone of this spiral */\r\n public override clone(): DirectSpiral3d {\r\n return new DirectSpiral3d(\r\n this.localToWorld.clone(),\r\n this._spiralType,\r\n this.designProperties?.clone(),\r\n this._nominalL1,\r\n this._nominalR1,\r\n this._activeFractionInterval?.clone(),\r\n this._evaluator.clone());\r\n }\r\n\r\n /** apply `transform` to this spiral's local to world transform. */\r\n public tryTransformInPlace(transformA: Transform): boolean {\r\n const rigidData = this.applyRigidPartOfTransform(transformA);\r\n if (rigidData !== undefined) {\r\n this._nominalL1 *= rigidData.scale;\r\n this._nominalR1 *= rigidData.scale;\r\n this.evaluator.scaleInPlace(rigidData.scale);\r\n }\r\n this.refreshComputedProperties();\r\n return true;\r\n }\r\n\r\n /** Return the spiral start point. */\r\n public override startPoint(): Point3d { return this.activeStrokes.startPoint(); }\r\n /** return the spiral end point. */\r\n public override endPoint(): Point3d { return this.activeStrokes.endPoint(); }\r\n /** test if the local to world transform places the spiral xy plane into `plane` */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return plane.isPointInPlane(this.localToWorld.origin as Point3d)\r\n && Geometry.isSameCoordinate(0.0, this.localToWorld.matrix.dotColumnX(plane.getNormalRef()))\r\n && Geometry.isSameCoordinate(0.0, this.localToWorld.matrix.dotColumnY(plane.getNormalRef()));\r\n }\r\n /** Return quick length of the spiral.\r\n * The tangent vector of a true clothoid is length 1 everywhere, so simple proportion of nominalL1 is a good approximation.\r\n */\r\n public quickLength() {\r\n const distanceData = this._globalStrokes.packedUVParams!;\r\n const n = distanceData.length;\r\n return distanceData.getYAtUncheckedPointIndex(n - 1);\r\n }\r\n /** Return length of the spiral.\r\n * * True length is stored at back of uvParams . . .\r\n */\r\n // use the generic integrator ... public override curveLength() { return this.quickLength(); }\r\n /** Test if `other` is an instance of `TransitionSpiral3d` */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof DirectSpiral3d; }\r\n /** Add strokes from this spiral to `dest`.\r\n * * Linestrings will usually stroke as just their points.\r\n * * If maxEdgeLength is given, this will sub-stroke within the linestring -- not what we want.\r\n */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void { this.activeStrokes.emitStrokes(dest, options); }\r\n /** emit stroke fragments to `dest` handler. */\r\n public emitStrokableParts(dest: IStrokeHandler, options?: StrokeOptions): void {\r\n const n = this.computeStrokeCountForOptions(options);\r\n const activeStrokes = this.activeStrokes;\r\n dest.startParentCurvePrimitive(this);\r\n\r\n // hack: specify the extended range so we can compute length of an extended spiral\r\n let globalFraction0 = 0.0;\r\n let globalFraction1 = 1.0;\r\n if (dest instanceof CurveLengthContext) {\r\n if (dest.getFraction0 < 0.0)\r\n globalFraction0 = dest.getFraction0;\r\n if (dest.getFraction1 > 1.0)\r\n globalFraction1 = dest.getFraction1;\r\n }\r\n\r\n if (n <= activeStrokes.numPoints())\r\n dest.announceIntervalForUniformStepStrokes(this, 2 * activeStrokes.numPoints(), globalFraction0, globalFraction1);\r\n else\r\n dest.announceIntervalForUniformStepStrokes(this, n, globalFraction0, globalFraction1);\r\n\r\n dest.endParentCurvePrimitive(this);\r\n }\r\n\r\n /**\r\n * return the stroke count required for given options.\r\n * @param options StrokeOptions that determine count\r\n */\r\n\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n let numStroke;\r\n const nominalRadians = this._nominalL1 / (2.0 * this._nominalR1);\r\n if (options) {\r\n const rMin = Math.abs(this._nominalR1);\r\n numStroke = options.applyTolerancesToArc(rMin, nominalRadians);\r\n numStroke = options.applyMaxEdgeLength(numStroke, this.quickLength());\r\n numStroke = options.applyMinStrokesPerPrimitive(numStroke);\r\n } else {\r\n numStroke = StrokeOptions.applyAngleTol(undefined, 4, nominalRadians, 0.02);\r\n }\r\n numStroke = Math.ceil(this._activeFractionInterval.absoluteDelta() * numStroke);\r\n return numStroke;\r\n }\r\n\r\n /** Reverse the active interval and active strokes.\r\n * * Primary defining data remains unchanged !!!\r\n */\r\n\r\n public reverseInPlace(): void {\r\n this._activeFractionInterval.reverseInPlace();\r\n if (this._activeStrokes === undefined)\r\n this._activeStrokes = this._globalStrokes.clone();\r\n this._activeStrokes.reverseInPlace();\r\n }\r\n /** Evaluate curve point with respect to fraction. */\r\n public fractionToPoint(activeFraction: number, result?: Point3d): Point3d {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPoint(globalFraction, result);\r\n this.localToWorld.multiplyPoint3d(result, result);\r\n return result;\r\n }\r\n /** Evaluate curve point and derivative with respect to fraction. */\r\n public fractionToPointAndDerivative(activeFraction: number, result?: Ray3d): Ray3d {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPointAndDerivative(globalFraction, result);\r\n result.direction.scaleInPlace(this._activeFractionInterval.signedDelta());\r\n result.transformInPlace(this.localToWorld);\r\n return result;\r\n }\r\n\r\n /** Return a plane with\r\n *\r\n * * origin at fractional position along the curve\r\n * * vectorU is the first derivative, i.e. tangent vector with length equal to the rate of change with respect to the fraction.\r\n * * vectorV is the second derivative, i.e.derivative of vectorU.\r\n */\r\n\r\n public fractionToPointAnd2Derivatives(activeFraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors | undefined {\r\n const globalFraction = this._activeFractionInterval.fractionToPoint(activeFraction);\r\n result = this._evaluator.fractionToPointAnd2Derivatives(globalFraction, result);\r\n const a = this._activeFractionInterval.signedDelta();\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n result.transformInPlace(this.localToWorld);\r\n return result;\r\n }\r\n /** Second step of double dispatch: call `handler.handleTransitionSpiral(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleTransitionSpiral(this);\r\n }\r\n /** compare various coordinate quantities */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof DirectSpiral3d) {\r\n return Geometry.isSameCoordinate(this._nominalL1, other._nominalL1)\r\n && Geometry.isSameCoordinate(this._nominalR1, other._nominalR1)\r\n && this.localToWorld.isAlmostEqual(other.localToWorld)\r\n && this._activeFractionInterval.isAlmostEqual(other._activeFractionInterval)\r\n && this._evaluator.isAlmostEqual(other._evaluator);\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
@@ -186,8 +186,7 @@ class IntegratedSpiral3d extends TransitionSpiral3d_1.TransitionSpiral3d {
186
186
  }
187
187
  /** Deep clone of this spiral */
188
188
  clone() {
189
- var _a;
190
- return new IntegratedSpiral3d(this._spiralType, this._evaluator, this.radius01.clone(), this.bearing01.clone(), this.activeFractionInterval.clone(), this.localToWorld.clone(), this._arcLength01, (_a = this._designProperties) === null || _a === void 0 ? void 0 : _a.clone());
189
+ return new IntegratedSpiral3d(this._spiralType, this._evaluator, this.radius01.clone(), this.bearing01.clone(), this.activeFractionInterval.clone(), this.localToWorld.clone(), this._arcLength01, this._designProperties?.clone());
191
190
  }
192
191
  /** apply `transform` to this spiral's local to world transform. */
193
192
  tryTransformInPlace(transformA) {