@itwin/core-geometry 4.2.0-dev.9 → 4.3.0-dev.1

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 (478) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/lib/cjs/Geometry.d.ts +4 -4
  3. package/lib/cjs/Geometry.d.ts.map +1 -1
  4. package/lib/cjs/Geometry.js +2 -2
  5. package/lib/cjs/Geometry.js.map +1 -1
  6. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts +4 -3
  7. package/lib/cjs/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  8. package/lib/cjs/clipping/AlternatingConvexClipTree.js +1 -1
  9. package/lib/cjs/clipping/AlternatingConvexClipTree.js.map +1 -1
  10. package/lib/cjs/clipping/BooleanClipNode.d.ts +4 -3
  11. package/lib/cjs/clipping/BooleanClipNode.d.ts.map +1 -1
  12. package/lib/cjs/clipping/BooleanClipNode.js.map +1 -1
  13. package/lib/cjs/clipping/ClipPlane.d.ts +2 -1
  14. package/lib/cjs/clipping/ClipPlane.d.ts.map +1 -1
  15. package/lib/cjs/clipping/ClipPlane.js.map +1 -1
  16. package/lib/cjs/clipping/ClipUtils.d.ts +17 -11
  17. package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
  18. package/lib/cjs/clipping/ClipUtils.js +14 -8
  19. package/lib/cjs/clipping/ClipUtils.js.map +1 -1
  20. package/lib/cjs/clipping/ClipVector.d.ts +6 -5
  21. package/lib/cjs/clipping/ClipVector.d.ts.map +1 -1
  22. package/lib/cjs/clipping/ClipVector.js +1 -1
  23. package/lib/cjs/clipping/ClipVector.js.map +1 -1
  24. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts +3 -2
  25. package/lib/cjs/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  26. package/lib/cjs/clipping/ConvexClipPlaneSet.js.map +1 -1
  27. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  28. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  29. package/lib/cjs/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  30. package/lib/cjs/core-geometry.d.ts +1 -3
  31. package/lib/cjs/core-geometry.d.ts.map +1 -1
  32. package/lib/cjs/core-geometry.js +1 -3
  33. package/lib/cjs/core-geometry.js.map +1 -1
  34. package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
  35. package/lib/cjs/curve/Arc3d.js +4 -4
  36. package/lib/cjs/curve/Arc3d.js.map +1 -1
  37. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  38. package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  39. package/lib/cjs/curve/CurveChainWithDistanceIndex.js +171 -152
  40. package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
  41. package/lib/cjs/curve/CurveCollection.d.ts +19 -19
  42. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  43. package/lib/cjs/curve/CurveCollection.js +20 -22
  44. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  45. package/lib/cjs/curve/CurveCurve.d.ts +47 -30
  46. package/lib/cjs/curve/CurveCurve.d.ts.map +1 -1
  47. package/lib/cjs/curve/CurveCurve.js +81 -46
  48. package/lib/cjs/curve/CurveCurve.js.map +1 -1
  49. package/lib/cjs/curve/CurveFactory.d.ts +1 -1
  50. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  51. package/lib/cjs/curve/CurveLocationDetail.d.ts +17 -5
  52. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  53. package/lib/cjs/curve/CurveLocationDetail.js +14 -2
  54. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  55. package/lib/cjs/curve/CurveOps.d.ts +1 -1
  56. package/lib/cjs/curve/CurveOps.js.map +1 -1
  57. package/lib/cjs/curve/CurvePrimitive.d.ts +1 -2
  58. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  59. package/lib/cjs/curve/CurvePrimitive.js +2 -2
  60. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  61. package/lib/cjs/curve/CurveProcessor.d.ts +1 -1
  62. package/lib/cjs/curve/CurveProcessor.js.map +1 -1
  63. package/lib/cjs/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  64. package/lib/cjs/curve/CurveTypes.d.ts.map +1 -0
  65. package/lib/cjs/curve/{CurveChain.js → CurveTypes.js} +1 -1
  66. package/lib/cjs/curve/CurveTypes.js.map +1 -0
  67. package/lib/cjs/curve/CurveWireMomentsXYZ.d.ts +1 -1
  68. package/lib/cjs/curve/CurveWireMomentsXYZ.js.map +1 -1
  69. package/lib/cjs/curve/ParityRegion.d.ts +3 -3
  70. package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
  71. package/lib/cjs/curve/ParityRegion.js +2 -2
  72. package/lib/cjs/curve/ParityRegion.js.map +1 -1
  73. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  74. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  75. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +2 -2
  76. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  77. package/lib/cjs/curve/Query/CurveSplitContext.d.ts +1 -1
  78. package/lib/cjs/curve/Query/CurveSplitContext.js.map +1 -1
  79. package/lib/cjs/curve/Query/CylindricalRange.d.ts +1 -1
  80. package/lib/cjs/curve/Query/CylindricalRange.js.map +1 -1
  81. package/lib/cjs/curve/Query/InOutTests.d.ts +1 -1
  82. package/lib/cjs/curve/Query/InOutTests.js.map +1 -1
  83. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +1 -1
  84. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  85. package/lib/cjs/curve/RegionOps.d.ts +54 -5
  86. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  87. package/lib/cjs/curve/RegionOps.js +154 -3
  88. package/lib/cjs/curve/RegionOps.js.map +1 -1
  89. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  90. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  91. package/lib/cjs/curve/StrokeOptions.d.ts +20 -11
  92. package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
  93. package/lib/cjs/curve/StrokeOptions.js +22 -11
  94. package/lib/cjs/curve/StrokeOptions.js.map +1 -1
  95. package/lib/cjs/curve/UnionRegion.d.ts +3 -3
  96. package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
  97. package/lib/cjs/curve/UnionRegion.js +2 -2
  98. package/lib/cjs/curve/UnionRegion.js.map +1 -1
  99. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  100. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  101. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  102. package/lib/cjs/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  103. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  104. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  105. package/lib/cjs/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  106. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  107. package/lib/{esm/curve → cjs/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  108. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  109. package/lib/cjs/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +104 -115
  110. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  111. package/lib/cjs/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  112. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  113. package/lib/cjs/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  114. package/lib/cjs/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  115. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  116. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  117. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  118. package/lib/cjs/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  119. package/lib/cjs/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  120. package/lib/cjs/curve/internalContexts/MultiChainCollector.js.map +1 -1
  121. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts +1 -0
  122. package/lib/cjs/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  123. package/lib/cjs/geometry3d/BarycentricTriangle.js +1 -0
  124. package/lib/cjs/geometry3d/BarycentricTriangle.js.map +1 -1
  125. package/lib/cjs/geometry3d/FrameBuilder.d.ts +28 -11
  126. package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
  127. package/lib/cjs/geometry3d/FrameBuilder.js +57 -45
  128. package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
  129. package/lib/cjs/geometry3d/GeometryHandler.d.ts +15 -26
  130. package/lib/cjs/geometry3d/GeometryHandler.d.ts.map +1 -1
  131. package/lib/cjs/geometry3d/GeometryHandler.js +23 -32
  132. package/lib/cjs/geometry3d/GeometryHandler.js.map +1 -1
  133. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts +0 -8
  134. package/lib/cjs/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  135. package/lib/cjs/geometry3d/GrowableXYZArray.js +0 -16
  136. package/lib/cjs/geometry3d/GrowableXYZArray.js.map +1 -1
  137. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +4 -4
  138. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  139. package/lib/cjs/geometry3d/IndexedXYZCollection.js +12 -0
  140. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  141. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  142. package/lib/cjs/geometry3d/Matrix3d.js +3 -6
  143. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  144. package/lib/cjs/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  145. package/lib/cjs/geometry3d/Point3dArrayCarrier.js.map +1 -1
  146. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +1 -2
  147. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  148. package/lib/cjs/geometry3d/Point3dVector3d.js +0 -1
  149. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  150. package/lib/cjs/geometry3d/PolygonOps.d.ts +2 -2
  151. package/lib/cjs/geometry3d/PolygonOps.d.ts.map +1 -1
  152. package/lib/cjs/geometry3d/PolygonOps.js +2 -3
  153. package/lib/cjs/geometry3d/PolygonOps.js.map +1 -1
  154. package/lib/cjs/geometry3d/Range.d.ts +1 -1
  155. package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
  156. package/lib/cjs/geometry3d/Range.js +1 -1
  157. package/lib/cjs/geometry3d/Range.js.map +1 -1
  158. package/lib/cjs/geometry3d/Ray3d.d.ts +3 -1
  159. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  160. package/lib/cjs/geometry3d/Ray3d.js +4 -3
  161. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  162. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts +2 -1
  163. package/lib/cjs/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  164. package/lib/cjs/geometry3d/ReusableObjectCache.js +1 -1
  165. package/lib/cjs/geometry3d/ReusableObjectCache.js.map +1 -1
  166. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -1
  167. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  168. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  169. package/lib/cjs/geometry3d/Transform.js +4 -6
  170. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  171. package/lib/cjs/geometry3d/YawPitchRollAngles.js +1 -1
  172. package/lib/cjs/geometry3d/YawPitchRollAngles.js.map +1 -1
  173. package/lib/cjs/geometry4d/Map4d.d.ts +14 -8
  174. package/lib/cjs/geometry4d/Map4d.d.ts.map +1 -1
  175. package/lib/cjs/geometry4d/Map4d.js +38 -16
  176. package/lib/cjs/geometry4d/Map4d.js.map +1 -1
  177. package/lib/cjs/geometry4d/Matrix4d.d.ts.map +1 -1
  178. package/lib/cjs/geometry4d/Matrix4d.js +4 -2
  179. package/lib/cjs/geometry4d/Matrix4d.js.map +1 -1
  180. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  181. package/lib/cjs/numerics/Polynomials.d.ts +2 -2
  182. package/lib/cjs/numerics/Polynomials.d.ts.map +1 -1
  183. package/lib/cjs/numerics/Polynomials.js +2 -2
  184. package/lib/cjs/numerics/Polynomials.js.map +1 -1
  185. package/lib/cjs/polyface/PolyfaceBuilder.d.ts +18 -6
  186. package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
  187. package/lib/cjs/polyface/PolyfaceBuilder.js +55 -25
  188. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  189. package/lib/cjs/polyface/PolyfaceClip.d.ts +16 -7
  190. package/lib/cjs/polyface/PolyfaceClip.d.ts.map +1 -1
  191. package/lib/cjs/polyface/PolyfaceClip.js +38 -7
  192. package/lib/cjs/polyface/PolyfaceClip.js.map +1 -1
  193. package/lib/cjs/polyface/PolyfaceData.d.ts +5 -39
  194. package/lib/cjs/polyface/PolyfaceData.d.ts.map +1 -1
  195. package/lib/cjs/polyface/PolyfaceData.js +7 -41
  196. package/lib/cjs/polyface/PolyfaceData.js.map +1 -1
  197. package/lib/cjs/polyface/PolyfaceQuery.d.ts +10 -8
  198. package/lib/cjs/polyface/PolyfaceQuery.d.ts.map +1 -1
  199. package/lib/cjs/polyface/PolyfaceQuery.js +64 -18
  200. package/lib/cjs/polyface/PolyfaceQuery.js.map +1 -1
  201. package/lib/cjs/serialization/GeometrySamples.d.ts +6 -0
  202. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  203. package/lib/cjs/serialization/GeometrySamples.js +68 -2
  204. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  205. package/lib/cjs/solid/LinearSweep.d.ts +1 -1
  206. package/lib/cjs/solid/LinearSweep.js.map +1 -1
  207. package/lib/cjs/solid/RotationalSweep.d.ts +1 -1
  208. package/lib/cjs/solid/RotationalSweep.js.map +1 -1
  209. package/lib/cjs/solid/RuledSweep.d.ts +1 -1
  210. package/lib/cjs/solid/RuledSweep.js.map +1 -1
  211. package/lib/cjs/solid/SweepContour.d.ts +35 -26
  212. package/lib/cjs/solid/SweepContour.d.ts.map +1 -1
  213. package/lib/cjs/solid/SweepContour.js +84 -100
  214. package/lib/cjs/solid/SweepContour.js.map +1 -1
  215. package/lib/cjs/topology/Graph.d.ts +29 -11
  216. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  217. package/lib/cjs/topology/Graph.js +45 -26
  218. package/lib/cjs/topology/Graph.js.map +1 -1
  219. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts +2 -2
  220. package/lib/cjs/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  221. package/lib/cjs/topology/HalfEdgeMarkSet.js +4 -4
  222. package/lib/cjs/topology/HalfEdgeMarkSet.js.map +1 -1
  223. package/lib/cjs/topology/Merging.d.ts +3 -0
  224. package/lib/cjs/topology/Merging.d.ts.map +1 -1
  225. package/lib/cjs/topology/Merging.js +19 -5
  226. package/lib/cjs/topology/Merging.js.map +1 -1
  227. package/lib/cjs/topology/Triangulation.d.ts +15 -7
  228. package/lib/cjs/topology/Triangulation.d.ts.map +1 -1
  229. package/lib/cjs/topology/Triangulation.js +89 -47
  230. package/lib/cjs/topology/Triangulation.js.map +1 -1
  231. package/lib/esm/Geometry.d.ts +4 -4
  232. package/lib/esm/Geometry.d.ts.map +1 -1
  233. package/lib/esm/Geometry.js +2 -2
  234. package/lib/esm/Geometry.js.map +1 -1
  235. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts +4 -3
  236. package/lib/esm/clipping/AlternatingConvexClipTree.d.ts.map +1 -1
  237. package/lib/esm/clipping/AlternatingConvexClipTree.js +1 -1
  238. package/lib/esm/clipping/AlternatingConvexClipTree.js.map +1 -1
  239. package/lib/esm/clipping/BooleanClipNode.d.ts +4 -3
  240. package/lib/esm/clipping/BooleanClipNode.d.ts.map +1 -1
  241. package/lib/esm/clipping/BooleanClipNode.js.map +1 -1
  242. package/lib/esm/clipping/ClipPlane.d.ts +2 -1
  243. package/lib/esm/clipping/ClipPlane.d.ts.map +1 -1
  244. package/lib/esm/clipping/ClipPlane.js.map +1 -1
  245. package/lib/esm/clipping/ClipUtils.d.ts +17 -11
  246. package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
  247. package/lib/esm/clipping/ClipUtils.js +14 -8
  248. package/lib/esm/clipping/ClipUtils.js.map +1 -1
  249. package/lib/esm/clipping/ClipVector.d.ts +6 -5
  250. package/lib/esm/clipping/ClipVector.d.ts.map +1 -1
  251. package/lib/esm/clipping/ClipVector.js +1 -1
  252. package/lib/esm/clipping/ClipVector.js.map +1 -1
  253. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts +3 -2
  254. package/lib/esm/clipping/ConvexClipPlaneSet.d.ts.map +1 -1
  255. package/lib/esm/clipping/ConvexClipPlaneSet.js.map +1 -1
  256. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts +2 -1
  257. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.d.ts.map +1 -1
  258. package/lib/esm/clipping/UnionOfConvexClipPlaneSets.js.map +1 -1
  259. package/lib/esm/core-geometry.d.ts +1 -3
  260. package/lib/esm/core-geometry.d.ts.map +1 -1
  261. package/lib/esm/core-geometry.js +1 -3
  262. package/lib/esm/core-geometry.js.map +1 -1
  263. package/lib/esm/curve/Arc3d.d.ts.map +1 -1
  264. package/lib/esm/curve/Arc3d.js +4 -4
  265. package/lib/esm/curve/Arc3d.js.map +1 -1
  266. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +93 -91
  267. package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
  268. package/lib/esm/curve/CurveChainWithDistanceIndex.js +171 -152
  269. package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
  270. package/lib/esm/curve/CurveCollection.d.ts +19 -19
  271. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  272. package/lib/esm/curve/CurveCollection.js +19 -20
  273. package/lib/esm/curve/CurveCollection.js.map +1 -1
  274. package/lib/esm/curve/CurveCurve.d.ts +47 -30
  275. package/lib/esm/curve/CurveCurve.d.ts.map +1 -1
  276. package/lib/esm/curve/CurveCurve.js +81 -46
  277. package/lib/esm/curve/CurveCurve.js.map +1 -1
  278. package/lib/esm/curve/CurveFactory.d.ts +1 -1
  279. package/lib/esm/curve/CurveFactory.js.map +1 -1
  280. package/lib/esm/curve/CurveLocationDetail.d.ts +17 -5
  281. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  282. package/lib/esm/curve/CurveLocationDetail.js +12 -1
  283. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  284. package/lib/esm/curve/CurveOps.d.ts +1 -1
  285. package/lib/esm/curve/CurveOps.js.map +1 -1
  286. package/lib/esm/curve/CurvePrimitive.d.ts +1 -2
  287. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  288. package/lib/esm/curve/CurvePrimitive.js +2 -2
  289. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  290. package/lib/esm/curve/CurveProcessor.d.ts +1 -1
  291. package/lib/esm/curve/CurveProcessor.js.map +1 -1
  292. package/lib/esm/curve/{CurveChain.d.ts → CurveTypes.d.ts} +6 -6
  293. package/lib/esm/curve/CurveTypes.d.ts.map +1 -0
  294. package/lib/esm/curve/{CurveChain.js → CurveTypes.js} +1 -1
  295. package/lib/esm/curve/CurveTypes.js.map +1 -0
  296. package/lib/esm/curve/CurveWireMomentsXYZ.d.ts +1 -1
  297. package/lib/esm/curve/CurveWireMomentsXYZ.js.map +1 -1
  298. package/lib/esm/curve/ParityRegion.d.ts +3 -3
  299. package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
  300. package/lib/esm/curve/ParityRegion.js +2 -2
  301. package/lib/esm/curve/ParityRegion.js.map +1 -1
  302. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts +3 -2
  303. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  304. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +1 -1
  305. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  306. package/lib/esm/curve/Query/CurveSplitContext.d.ts +1 -1
  307. package/lib/esm/curve/Query/CurveSplitContext.js.map +1 -1
  308. package/lib/esm/curve/Query/CylindricalRange.d.ts +1 -1
  309. package/lib/esm/curve/Query/CylindricalRange.js.map +1 -1
  310. package/lib/esm/curve/Query/InOutTests.d.ts +1 -1
  311. package/lib/esm/curve/Query/InOutTests.js.map +1 -1
  312. package/lib/esm/curve/Query/StrokeCountChain.d.ts +1 -1
  313. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  314. package/lib/esm/curve/RegionOps.d.ts +54 -5
  315. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  316. package/lib/esm/curve/RegionOps.js +153 -3
  317. package/lib/esm/curve/RegionOps.js.map +1 -1
  318. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +1 -1
  319. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  320. package/lib/esm/curve/StrokeOptions.d.ts +20 -11
  321. package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
  322. package/lib/esm/curve/StrokeOptions.js +22 -11
  323. package/lib/esm/curve/StrokeOptions.js.map +1 -1
  324. package/lib/esm/curve/UnionRegion.d.ts +3 -3
  325. package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
  326. package/lib/esm/curve/UnionRegion.js +2 -2
  327. package/lib/esm/curve/UnionRegion.js.map +1 -1
  328. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts +1 -1
  329. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.d.ts.map +1 -1
  330. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js +2 -2
  331. package/lib/esm/curve/internalContexts/ClosestPointStrokeHandler.js.map +1 -1
  332. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +233 -0
  333. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts.map +1 -0
  334. package/lib/esm/curve/{CurveCurveCloseApproachXY.js → internalContexts/CurveCurveCloseApproachXY.js} +299 -202
  335. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -0
  336. package/lib/{cjs/curve → esm/curve/internalContexts}/CurveCurveIntersectXY.d.ts +45 -51
  337. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -0
  338. package/lib/esm/curve/{CurveCurveIntersectXY.js → internalContexts/CurveCurveIntersectXY.js} +103 -113
  339. package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -0
  340. package/lib/esm/curve/{CurveCurveIntersectXYZ.d.ts → internalContexts/CurveCurveIntersectXYZ.d.ts} +18 -18
  341. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.d.ts.map +1 -0
  342. package/lib/esm/curve/{CurveCurveIntersectXYZ.js → internalContexts/CurveCurveIntersectXYZ.js} +134 -108
  343. package/lib/esm/curve/internalContexts/CurveCurveIntersectXYZ.js.map +1 -0
  344. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts +2 -2
  345. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.d.ts.map +1 -1
  346. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js +9 -5
  347. package/lib/esm/curve/internalContexts/CurveOffsetXYHandler.js.map +1 -1
  348. package/lib/esm/curve/internalContexts/MultiChainCollector.d.ts +1 -1
  349. package/lib/esm/curve/internalContexts/MultiChainCollector.js.map +1 -1
  350. package/lib/esm/geometry3d/BarycentricTriangle.d.ts +1 -0
  351. package/lib/esm/geometry3d/BarycentricTriangle.d.ts.map +1 -1
  352. package/lib/esm/geometry3d/BarycentricTriangle.js +1 -0
  353. package/lib/esm/geometry3d/BarycentricTriangle.js.map +1 -1
  354. package/lib/esm/geometry3d/FrameBuilder.d.ts +28 -11
  355. package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
  356. package/lib/esm/geometry3d/FrameBuilder.js +57 -45
  357. package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
  358. package/lib/esm/geometry3d/GeometryHandler.d.ts +15 -26
  359. package/lib/esm/geometry3d/GeometryHandler.d.ts.map +1 -1
  360. package/lib/esm/geometry3d/GeometryHandler.js +23 -32
  361. package/lib/esm/geometry3d/GeometryHandler.js.map +1 -1
  362. package/lib/esm/geometry3d/GrowableXYZArray.d.ts +0 -8
  363. package/lib/esm/geometry3d/GrowableXYZArray.d.ts.map +1 -1
  364. package/lib/esm/geometry3d/GrowableXYZArray.js +0 -16
  365. package/lib/esm/geometry3d/GrowableXYZArray.js.map +1 -1
  366. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +4 -4
  367. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  368. package/lib/esm/geometry3d/IndexedXYZCollection.js +12 -0
  369. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  370. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  371. package/lib/esm/geometry3d/Matrix3d.js +3 -6
  372. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  373. package/lib/esm/geometry3d/Point3dArrayCarrier.d.ts.map +1 -1
  374. package/lib/esm/geometry3d/Point3dArrayCarrier.js.map +1 -1
  375. package/lib/esm/geometry3d/Point3dVector3d.d.ts +1 -2
  376. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  377. package/lib/esm/geometry3d/Point3dVector3d.js +0 -1
  378. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  379. package/lib/esm/geometry3d/PolygonOps.d.ts +2 -2
  380. package/lib/esm/geometry3d/PolygonOps.d.ts.map +1 -1
  381. package/lib/esm/geometry3d/PolygonOps.js +2 -3
  382. package/lib/esm/geometry3d/PolygonOps.js.map +1 -1
  383. package/lib/esm/geometry3d/Range.d.ts +1 -1
  384. package/lib/esm/geometry3d/Range.d.ts.map +1 -1
  385. package/lib/esm/geometry3d/Range.js +1 -1
  386. package/lib/esm/geometry3d/Range.js.map +1 -1
  387. package/lib/esm/geometry3d/Ray3d.d.ts +3 -1
  388. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  389. package/lib/esm/geometry3d/Ray3d.js +4 -3
  390. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  391. package/lib/esm/geometry3d/ReusableObjectCache.d.ts +2 -1
  392. package/lib/esm/geometry3d/ReusableObjectCache.d.ts.map +1 -1
  393. package/lib/esm/geometry3d/ReusableObjectCache.js +1 -1
  394. package/lib/esm/geometry3d/ReusableObjectCache.js.map +1 -1
  395. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -1
  396. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  397. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  398. package/lib/esm/geometry3d/Transform.js +4 -6
  399. package/lib/esm/geometry3d/Transform.js.map +1 -1
  400. package/lib/esm/geometry3d/YawPitchRollAngles.js +1 -1
  401. package/lib/esm/geometry3d/YawPitchRollAngles.js.map +1 -1
  402. package/lib/esm/geometry4d/Map4d.d.ts +14 -8
  403. package/lib/esm/geometry4d/Map4d.d.ts.map +1 -1
  404. package/lib/esm/geometry4d/Map4d.js +38 -16
  405. package/lib/esm/geometry4d/Map4d.js.map +1 -1
  406. package/lib/esm/geometry4d/Matrix4d.d.ts.map +1 -1
  407. package/lib/esm/geometry4d/Matrix4d.js +4 -2
  408. package/lib/esm/geometry4d/Matrix4d.js.map +1 -1
  409. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  410. package/lib/esm/numerics/Polynomials.d.ts +2 -2
  411. package/lib/esm/numerics/Polynomials.d.ts.map +1 -1
  412. package/lib/esm/numerics/Polynomials.js +2 -2
  413. package/lib/esm/numerics/Polynomials.js.map +1 -1
  414. package/lib/esm/polyface/PolyfaceBuilder.d.ts +18 -6
  415. package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
  416. package/lib/esm/polyface/PolyfaceBuilder.js +55 -25
  417. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  418. package/lib/esm/polyface/PolyfaceClip.d.ts +16 -7
  419. package/lib/esm/polyface/PolyfaceClip.d.ts.map +1 -1
  420. package/lib/esm/polyface/PolyfaceClip.js +38 -7
  421. package/lib/esm/polyface/PolyfaceClip.js.map +1 -1
  422. package/lib/esm/polyface/PolyfaceData.d.ts +5 -39
  423. package/lib/esm/polyface/PolyfaceData.d.ts.map +1 -1
  424. package/lib/esm/polyface/PolyfaceData.js +7 -41
  425. package/lib/esm/polyface/PolyfaceData.js.map +1 -1
  426. package/lib/esm/polyface/PolyfaceQuery.d.ts +10 -8
  427. package/lib/esm/polyface/PolyfaceQuery.d.ts.map +1 -1
  428. package/lib/esm/polyface/PolyfaceQuery.js +64 -18
  429. package/lib/esm/polyface/PolyfaceQuery.js.map +1 -1
  430. package/lib/esm/serialization/GeometrySamples.d.ts +6 -0
  431. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  432. package/lib/esm/serialization/GeometrySamples.js +68 -2
  433. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  434. package/lib/esm/solid/LinearSweep.d.ts +1 -1
  435. package/lib/esm/solid/LinearSweep.js.map +1 -1
  436. package/lib/esm/solid/RotationalSweep.d.ts +1 -1
  437. package/lib/esm/solid/RotationalSweep.js.map +1 -1
  438. package/lib/esm/solid/RuledSweep.d.ts +1 -1
  439. package/lib/esm/solid/RuledSweep.js.map +1 -1
  440. package/lib/esm/solid/SweepContour.d.ts +35 -26
  441. package/lib/esm/solid/SweepContour.d.ts.map +1 -1
  442. package/lib/esm/solid/SweepContour.js +84 -100
  443. package/lib/esm/solid/SweepContour.js.map +1 -1
  444. package/lib/esm/topology/Graph.d.ts +29 -11
  445. package/lib/esm/topology/Graph.d.ts.map +1 -1
  446. package/lib/esm/topology/Graph.js +45 -26
  447. package/lib/esm/topology/Graph.js.map +1 -1
  448. package/lib/esm/topology/HalfEdgeMarkSet.d.ts +2 -2
  449. package/lib/esm/topology/HalfEdgeMarkSet.d.ts.map +1 -1
  450. package/lib/esm/topology/HalfEdgeMarkSet.js +2 -2
  451. package/lib/esm/topology/HalfEdgeMarkSet.js.map +1 -1
  452. package/lib/esm/topology/Merging.d.ts +3 -0
  453. package/lib/esm/topology/Merging.d.ts.map +1 -1
  454. package/lib/esm/topology/Merging.js +19 -5
  455. package/lib/esm/topology/Merging.js.map +1 -1
  456. package/lib/esm/topology/Triangulation.d.ts +15 -7
  457. package/lib/esm/topology/Triangulation.d.ts.map +1 -1
  458. package/lib/esm/topology/Triangulation.js +89 -47
  459. package/lib/esm/topology/Triangulation.js.map +1 -1
  460. package/package.json +4 -4
  461. package/lib/cjs/curve/CurveChain.d.ts.map +0 -1
  462. package/lib/cjs/curve/CurveChain.js.map +0 -1
  463. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  464. package/lib/cjs/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  465. package/lib/cjs/curve/CurveCurveCloseApproachXY.js.map +0 -1
  466. package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  467. package/lib/cjs/curve/CurveCurveIntersectXY.js.map +0 -1
  468. package/lib/cjs/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  469. package/lib/cjs/curve/CurveCurveIntersectXYZ.js.map +0 -1
  470. package/lib/esm/curve/CurveChain.d.ts.map +0 -1
  471. package/lib/esm/curve/CurveChain.js.map +0 -1
  472. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts +0 -175
  473. package/lib/esm/curve/CurveCurveCloseApproachXY.d.ts.map +0 -1
  474. package/lib/esm/curve/CurveCurveCloseApproachXY.js.map +0 -1
  475. package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +0 -1
  476. package/lib/esm/curve/CurveCurveIntersectXY.js.map +0 -1
  477. package/lib/esm/curve/CurveCurveIntersectXYZ.d.ts.map +0 -1
  478. package/lib/esm/curve/CurveCurveIntersectXYZ.js.map +0 -1
@@ -1,11 +1,11 @@
1
- /** @packageDocumentation
2
- * @module Polyface
3
- */
4
1
  import { ClipPlane } from "../clipping/ClipPlane";
5
2
  import { ConvexClipPlaneSet } from "../clipping/ConvexClipPlaneSet";
6
3
  import { UnionOfConvexClipPlaneSets } from "../clipping/UnionOfConvexClipPlaneSets";
4
+ import { AnyRegion } from "../curve/CurveTypes";
7
5
  import { LineString3d } from "../curve/LineString3d";
6
+ import { StrokeOptions } from "../curve/StrokeOptions";
8
7
  import { PlaneAltitudeEvaluator } from "../Geometry";
8
+ import { Vector3d } from "../geometry3d/Point3dVector3d";
9
9
  import { IndexedPolyface, Polyface, PolyfaceVisitor } from "./Polyface";
10
10
  import { PolyfaceBuilder } from "./PolyfaceBuilder";
11
11
  /**
@@ -30,7 +30,7 @@ export declare class ClippedPolyfaceBuilders {
30
30
  private constructor();
31
31
  /** Simple create with default options on builder. */
32
32
  static create(keepInside?: boolean, keepOutside?: boolean, buildSideFaces?: boolean): ClippedPolyfaceBuilders;
33
- claimPolyface(selector: 0 | 1, fixup: boolean): IndexedPolyface | undefined;
33
+ claimPolyface(selector: 0 | 1, fixup: boolean, tolerance?: number): IndexedPolyface | undefined;
34
34
  }
35
35
  /** PolyfaceClip is a static class gathering operations using Polyfaces and clippers.
36
36
  * @public
@@ -57,9 +57,8 @@ export declare class PolyfaceClip {
57
57
  * * outputSelect determines how the clip output is structured
58
58
  * * 0 outputs all shards -- this may have many interior edges.
59
59
  * * 1 stitches shards together to get cleaner facets.
60
- * @internal
61
60
  */
62
- static clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface: Polyface, allClippers: UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders, outputSelector?: number): void;
61
+ static clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface: Polyface | PolyfaceVisitor, allClippers: UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders, outputSelector?: number): void;
63
62
  private static addRegion;
64
63
  private static cleanupAndAddRegion;
65
64
  private static addPolygonToBuilderAndDropToCache;
@@ -115,11 +114,21 @@ export declare class PolyfaceClip {
115
114
  */
116
115
  static clipPolyfaceInsideOutside(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet | UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders, outputSelect?: number): void;
117
116
  /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet
118
- * * This method parses the variant input types and calls a more specific method.
117
+ * * This method parses the variant input types and calls a more specific method.
119
118
  * * To get both inside and outside parts, use clipPolyfaceInsideOutside
120
119
  * * WARNING: The new mesh is "points only".
121
120
  */
122
121
  static clipPolyface(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet): Polyface | undefined;
122
+ /**
123
+ * Drape the region onto the mesh.
124
+ * * This method computes the portion of the input mesh that lies inside the clipper generated from sweeping the input region in the given direction.
125
+ * @param mesh input mesh, untouched
126
+ * @param region planar region to drape onto mesh
127
+ * @param sweepVector optional sweep direction for region; if undefined, region normal is used
128
+ * @param options how to stroke the region boundary
129
+ * @returns clipped facets. No other mesh data but vertices appear in output.
130
+ */
131
+ static drapeRegion(mesh: Polyface | PolyfaceVisitor, region: AnyRegion, sweepVector?: Vector3d, options?: StrokeOptions): IndexedPolyface | undefined;
123
132
  /** Find consecutive points around a polygon (with implied closure edge) that are ON a plane
124
133
  * @param points array of points around polygon. Closure edge is implied.
125
134
  * @param chainContext context receiving edges
@@ -1 +1 @@
1
- {"version":3,"file":"PolyfaceClip.d.ts","sourceRoot":"","sources":["../../../src/polyface/PolyfaceClip.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAWrD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAgBpD;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAuB;IAClC,0DAA0D;IACnD,QAAQ,CAAC,EAAE,eAAe,CAAC;IAClC,2DAA2D;IACpD,QAAQ,CAAC,EAAE,eAAe,CAAC;IAClC,qCAAqC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACnC,OAAO;IAKP,qDAAqD;WACvC,MAAM,CAAC,UAAU,GAAE,OAAc,EAAE,WAAW,GAAE,OAAe,EAAE,cAAc,GAAE,OAAe;IAIvG,aAAa,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS;CAWnF;AACD;;GAEG;AACH,qBAAa,YAAY;IACvB;;;OAGG;WACW,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,SA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S,EAC3C,aAAa,EAAE,eAAe,GAAG,SAAS;IAsC5C;;;;;;;;;;;;;;;;OAgBG;WACW,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG;QAAE,WAAW,EAAE,eAAe,CAAC;QAAC,UAAU,EAAE,eAAe,CAAA;KAAE;CAe5I"}
@@ -5,8 +5,8 @@
5
5
  /** @packageDocumentation
6
6
  * @module Polyface
7
7
  */
8
- // import { Point2d } from "./Geometry2d";
9
8
  /* eslint-disable @typescript-eslint/naming-convention, no-empty */
9
+ import { assert } from "@itwin/core-bentley";
10
10
  import { ClipPlane } from "../clipping/ClipPlane";
11
11
  import { ConvexClipPlaneSet } from "../clipping/ConvexClipPlaneSet";
12
12
  import { UnionOfConvexClipPlaneSets } from "../clipping/UnionOfConvexClipPlaneSets";
@@ -14,6 +14,7 @@ import { LineString3d } from "../curve/LineString3d";
14
14
  import { Loop } from "../curve/Loop";
15
15
  import { RegionBinaryOpType, RegionOps } from "../curve/RegionOps";
16
16
  import { UnionRegion } from "../curve/UnionRegion";
17
+ import { Geometry } from "../Geometry";
17
18
  import { FrameBuilder } from "../geometry3d/FrameBuilder";
18
19
  import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
19
20
  import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d";
@@ -23,6 +24,7 @@ import { GrowableXYZArrayCache } from "../geometry3d/ReusableObjectCache";
23
24
  import { SweepContour } from "../solid/SweepContour";
24
25
  import { ChainMergeContext } from "../topology/ChainMerge";
25
26
  import { RangeSearch } from "./multiclip/RangeSearch";
27
+ import { Polyface } from "./Polyface";
26
28
  import { PolyfaceBuilder } from "./PolyfaceBuilder";
27
29
  import { PolyfaceQuery } from "./PolyfaceQuery";
28
30
  /**
@@ -57,12 +59,13 @@ export class ClippedPolyfaceBuilders {
57
59
  static create(keepInside = true, keepOutside = false, buildSideFaces = false) {
58
60
  return new ClippedPolyfaceBuilders(keepInside ? PolyfaceBuilder.create() : undefined, keepOutside ? PolyfaceBuilder.create() : undefined, buildSideFaces);
59
61
  }
60
- claimPolyface(selector, fixup) {
62
+ claimPolyface(selector, fixup, tolerance = Geometry.smallMetricDistance) {
61
63
  const builder = selector === 0 ? this.builderA : this.builderB;
62
64
  if (builder) {
63
- let polyface = builder.claimPolyface();
65
+ let polyface = builder.claimPolyface(true, tolerance);
64
66
  if (fixup) {
65
67
  polyface = PolyfaceQuery.cloneWithTVertexFixup(polyface);
68
+ polyface = PolyfaceQuery.cloneWithDanglingEdgesRemoved(polyface);
66
69
  }
67
70
  return polyface;
68
71
  }
@@ -110,12 +113,15 @@ export class PolyfaceClip {
110
113
  * * outputSelect determines how the clip output is structured
111
114
  * * 0 outputs all shards -- this may have many interior edges.
112
115
  * * 1 stitches shards together to get cleaner facets.
113
- * @internal
114
116
  */
115
117
  static clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface, allClippers, destination, outputSelector = 1) {
118
+ if (polyface instanceof Polyface) {
119
+ this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface.createVisitor(0), allClippers, destination, outputSelector);
120
+ return;
121
+ }
116
122
  const builderA = destination.builderA;
117
123
  const builderB = destination.builderB;
118
- const visitor = polyface.createVisitor(0);
124
+ const visitor = polyface; // alias; we have a visitor now
119
125
  const cache = new GrowableXYZArrayCache();
120
126
  const insideShards = [];
121
127
  const outsideShards = [];
@@ -193,6 +199,9 @@ export class PolyfaceClip {
193
199
  for (const child of region.children)
194
200
  this.addRegion(builder, child);
195
201
  }
202
+ else {
203
+ assert(!"unexpected region encountered");
204
+ }
196
205
  }
197
206
  }
198
207
  // WARNING: shards are transformed into local system, not reverted!!!
@@ -204,7 +213,7 @@ export class PolyfaceClip {
204
213
  if (outsidePieces && outsidePieces.children.length > 0) {
205
214
  if (localToWorld)
206
215
  outsidePieces.tryTransformInPlace(localToWorld);
207
- RegionOps.consolidateAdjacentPrimitives(outsidePieces);
216
+ RegionOps.consolidateAdjacentPrimitives(outsidePieces); // source of the T-vertices removed in claimPolyface
208
217
  this.addRegion(builder, outsidePieces);
209
218
  }
210
219
  }
@@ -431,7 +440,7 @@ export class PolyfaceClip {
431
440
  }
432
441
  }
433
442
  /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet
434
- * * This method parses the variant input types and calls a more specific method.
443
+ * * This method parses the variant input types and calls a more specific method.
435
444
  * * To get both inside and outside parts, use clipPolyfaceInsideOutside
436
445
  * * WARNING: The new mesh is "points only".
437
446
  */
@@ -443,6 +452,28 @@ export class PolyfaceClip {
443
452
  // (The if tests exhaust the type space -- this line is unreachable.)
444
453
  return undefined;
445
454
  }
455
+ /**
456
+ * Drape the region onto the mesh.
457
+ * * This method computes the portion of the input mesh that lies inside the clipper generated from sweeping the input region in the given direction.
458
+ * @param mesh input mesh, untouched
459
+ * @param region planar region to drape onto mesh
460
+ * @param sweepVector optional sweep direction for region; if undefined, region normal is used
461
+ * @param options how to stroke the region boundary
462
+ * @returns clipped facets. No other mesh data but vertices appear in output.
463
+ */
464
+ static drapeRegion(mesh, region, sweepVector, options) {
465
+ if (mesh instanceof Polyface)
466
+ return this.drapeRegion(mesh.createVisitor(0), region, sweepVector, options);
467
+ const contour = SweepContour.createForLinearSweep(region);
468
+ if (!contour)
469
+ return undefined;
470
+ const clipper = contour.sweepToUnionOfConvexClipPlaneSets(sweepVector, false, false, options);
471
+ if (!clipper)
472
+ return undefined;
473
+ const builders = ClippedPolyfaceBuilders.create(true);
474
+ this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(mesh, clipper, builders, 1);
475
+ return builders.claimPolyface(0, true);
476
+ }
446
477
  /** Find consecutive points around a polygon (with implied closure edge) that are ON a plane
447
478
  * @param points array of points around polygon. Closure edge is implied.
448
479
  * @param chainContext context receiving edges
@@ -1 +1 @@
1
- {"version":3,"file":"PolyfaceClip.js","sourceRoot":"","sources":["../../../src/polyface/PolyfaceClip.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,0CA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AC,aAAa,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,KAAK,CAAC,aAAa,EAAE,CAAC;QACvC,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;QAChD,MAAM,aAAa,GAAG,eAAe,CAAC,MAAM,EAAE,CAAC;QAC/C,cAAc,CAAC,uBAAuB,EAAE,CAAC;QACzC,IAAI,CAAC,+CAA+C,CAAC,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;QACxG,cAAc,CAAC,uBAAuB,EAAE,CAAC;QACzC,aAAa,CAAC,uBAAuB,EAAE,CAAC;QACxC,IAAI,CAAC,+CAA+C,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QACxG,OAAO;YACL,WAAW,EAAE,cAAc,CAAC,aAAa,EAAE;YAC3C,UAAU,EAAE,aAAa,CAAC,aAAa,EAAE;SAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n// import { Point2d } from \"./Geometry2d\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { AnyRegion } from \"../curve/CurveChain\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { RegionBinaryOpType, RegionOps } from \"../curve/RegionOps\";\r\nimport { UnionRegion } from \"../curve/UnionRegion\";\r\nimport { PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { SweepContour } from \"../solid/SweepContour\";\r\nimport { ChainMergeContext } from \"../topology/ChainMerge\";\r\nimport { RangeSearch } from \"./multiclip/RangeSearch\";\r\nimport { IndexedPolyface, Polyface, PolyfaceVisitor } from \"./Polyface\";\r\nimport { PolyfaceBuilder } from \"./PolyfaceBuilder\";\r\nimport { PolyfaceQuery } from \"./PolyfaceQuery\";\r\n\r\n /**\r\n * carrier for a point array with an index into UnionOfConvexClipPlaneSets\r\n * @private\r\n */\r\n class ClipCandidate {\r\n public nextConvexSetIndex: number;\r\n public points: GrowableXYZArray;\r\n public constructor(points: GrowableXYZArray, nextConvexSetIndex: number) {\r\n this.nextConvexSetIndex = nextConvexSetIndex;\r\n this.points = points;\r\n }\r\n }\r\n\r\n/**\r\n * A pair of PolyfaceBuilder objects, for use by clippers that emit inside and outside parts.\r\n * * There are nominally 4 builders:\r\n * * builderA collects simple \"inside\" clip.\r\n * * builderB collects simple \"outside\" clip.\r\n * * builderA1 collects \"side\" clip for inside.\r\n * * builderB1 collets \"side\" clip for outside.\r\n * * `static ClippedPolyfaceBuilders.create(keepInside, keepOutside)` initializes `builderA` and `builderB` (each optionally to undefined), with undefined `builderA1` and `builderB1`\r\n * * `builders.enableSideBuilders()` makes `builderA1` and `builderB1` match `builderA` and `builderB`.\r\n * * construction methods aim their facets at appropriate builders if defined.\r\n * * @public\r\n */\r\nexport class ClippedPolyfaceBuilders {\r\n /** An available builder. Typically the \"inside\" parts */\r\n public builderA?: PolyfaceBuilder;\r\n /** An available builder. Typically the \"outside\" parts */\r\n public builderB?: PolyfaceBuilder;\r\n /** request to construct cut faces */\r\n public buildClosureFaces?: boolean;\r\n private constructor(builderA: PolyfaceBuilder | undefined, builderB: PolyfaceBuilder | undefined, buildClosureFaces: boolean = false) {\r\n this.builderA = builderA;\r\n this.builderB = builderB;\r\n this.buildClosureFaces = buildClosureFaces;\r\n }\r\n /** Simple create with default options on builder. */\r\n public static create(keepInside: boolean = true, keepOutside: boolean = false, buildSideFaces: boolean = false) {\r\n return new ClippedPolyfaceBuilders(keepInside ? PolyfaceBuilder.create() : undefined, keepOutside ? PolyfaceBuilder.create() : undefined, buildSideFaces);\r\n }\r\n\r\n public claimPolyface(selector: 0 | 1, fixup: boolean): IndexedPolyface | undefined {\r\n const builder = selector === 0 ? this.builderA : this.builderB;\r\n if (builder) {\r\n let polyface = builder.claimPolyface();\r\n if (fixup) {\r\n polyface = PolyfaceQuery.cloneWithTVertexFixup(polyface);\r\n }\r\n return polyface;\r\n }\r\n return undefined;\r\n }\r\n}\r\n/** PolyfaceClip is a static class gathering operations using Polyfaces and clippers.\r\n * @public\r\n */\r\nexport class PolyfaceClip {\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return all surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\" -- parameters, normals, etc are not interpolated\r\n */\r\n public static clipPolyfaceClipPlaneWithClosureFace(polyface: Polyface, clipper: ClipPlane, insideClip: boolean = true, buildClosureFaces: boolean = true) {\r\n return this.clipPolyfaceClipPlane(polyface, clipper, insideClip, buildClosureFaces);\r\n }\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return all surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\" -- parameters, normals, etc are not interpolated\r\n */\r\n public static clipPolyfaceClipPlane(polyface: Polyface, clipper: ClipPlane, insideClip: boolean = true, buildClosureFaces: boolean = false): Polyface {\r\n const builders = ClippedPolyfaceBuilders.create(insideClip, !insideClip, buildClosureFaces);\r\n this.clipPolyfaceInsideOutside(polyface, clipper, builders);\r\n return builders.claimPolyface(insideClip ? 0 : 1, true)!;\r\n }\r\n\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\".\r\n */\r\n public static clipPolyfaceConvexClipPlaneSet(polyface: Polyface, clipper: ConvexClipPlaneSet): Polyface {\r\n const visitor = polyface.createVisitor(0);\r\n const builder = PolyfaceBuilder.create();\r\n const work = new GrowableXYZArray(10);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n clipper.clipConvexPolygonInPlace(visitor.point, work);\r\n if (visitor.point.length > 2)\r\n builder.addPolygonGrowableXYZArray(visitor.point);\r\n }\r\n return builder.claimPolyface(true);\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * * outputSelect determines how the clip output is structured\r\n * * 0 outputs all shards -- this may have many interior edges.\r\n * * 1 stitches shards together to get cleaner facets.\r\n * @internal\r\n */\r\n public static clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface: Polyface, allClippers: UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders, outputSelector: number = 1) {\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface.createVisitor(0);\r\n const cache = new GrowableXYZArrayCache();\r\n const insideShards: GrowableXYZArray[] = [];\r\n const outsideShards: GrowableXYZArray[] = [];\r\n const residualPolygons: ClipCandidate[] = [];\r\n let candidate: ClipCandidate | undefined;\r\n const outsideParts: GrowableXYZArray[] = [];\r\n\r\n const numConvexSet = allClippers.convexSets.length;\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n residualPolygons.push(new ClipCandidate(cache.grabAndFill(visitor.point), 0));\r\n while ((candidate = residualPolygons.pop()) !== undefined) {\r\n const convexSetIndex = candidate.nextConvexSetIndex;\r\n if (convexSetIndex >= numConvexSet) {\r\n // ths remnant polygon is OUT ...\r\n if (candidate.points.length > 2)\r\n outsideShards.push(candidate.points);\r\n } else {\r\n const clipper = allClippers.convexSets[convexSetIndex];\r\n outsideParts.length = 0; // NO NO -- why isn't it empty from prior step cleanup?\r\n const insidePart = clipper.clipInsidePushOutside(candidate.points, outsideParts, cache);\r\n if (insidePart) {\r\n if (insidePart.length > 2)\r\n insideShards.push(insidePart);\r\n // Keep outside parts active for clip by later facets . . .\r\n for (const outsidePolygon of outsideParts) {\r\n residualPolygons.push(new ClipCandidate(outsidePolygon, convexSetIndex + 1));\r\n }\r\n } else {\r\n // Nothing was insidePart. The outside parts might be split by intermediate steps -- but all the pieces are there.\r\n candidate.nextConvexSetIndex++;\r\n residualPolygons.push(candidate);\r\n }\r\n outsideParts.length = 0;\r\n }\r\n }\r\n if (outsideShards.length === 0) {\r\n builderA?.addPolygonGrowableXYZArray(visitor.point);\r\n } else if (insideShards.length === 0) {\r\n // the facet spanned clippers but is intact outside\r\n builderB?.addPolygonGrowableXYZArray(visitor.point);\r\n } else {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, visitor.point);\r\n let worldToLocal: Transform | undefined;\r\n if (outputSelector === 1 && localToWorld !== undefined\r\n && undefined !== (worldToLocal = localToWorld.inverse())) {\r\n this.cleanupAndAddRegion(builderA, insideShards, worldToLocal, localToWorld);\r\n\r\n this.cleanupAndAddRegion(builderB, outsideShards, worldToLocal, localToWorld);\r\n } else {\r\n for (const shard of insideShards)\r\n this.addPolygonToBuilderAndDropToCache(shard, builderA, cache);\r\n for (const shard of outsideShards)\r\n this.addPolygonToBuilderAndDropToCache(shard, builderB, cache);\r\n }\r\n }\r\n outsideShards.length = 0;\r\n insideShards.length = 0;\r\n }\r\n cache.dropAllToCache(outsideParts);\r\n if (destination.buildClosureFaces) {\r\n for (const clipper of allClippers.convexSets) {\r\n this.buildClosureFacesForConvexSet(visitor, clipper, destination, cache);\r\n }\r\n }\r\n }\r\n private static addRegion(builder: PolyfaceBuilder | undefined, region: AnyRegion | undefined) {\r\n if (builder !== undefined && region !== undefined) {\r\n if (region instanceof Loop && region.children.length === 1 && region.children[0] instanceof LineString3d) {\r\n builder.addPolygonGrowableXYZArray(region.children[0].packedPoints);\r\n } else if (region instanceof UnionRegion) {\r\n for (const child of region.children)\r\n this.addRegion(builder, child);\r\n }\r\n }\r\n }\r\n // WARNING: shards are transformed into local system, not reverted!!!\r\n private static cleanupAndAddRegion(builder: PolyfaceBuilder | undefined, shards: GrowableXYZArray[],\r\n worldToLocal: Transform | undefined, localToWorld: Transform | undefined) {\r\n if (builder !== undefined && shards.length > 0) {\r\n if (worldToLocal)\r\n GrowableXYZArray.multiplyTransformInPlace(worldToLocal, shards);\r\n const outsidePieces = RegionOps.polygonBooleanXYToLoops(shards, RegionBinaryOpType.Union, []);\r\n if (outsidePieces && outsidePieces.children.length > 0){\r\n if (localToWorld)\r\n outsidePieces.tryTransformInPlace(localToWorld);\r\n RegionOps.consolidateAdjacentPrimitives(outsidePieces);\r\n this.addRegion(builder, outsidePieces);\r\n }\r\n }\r\n }\r\n private static addPolygonToBuilderAndDropToCache(polygon: GrowableXYZArray | undefined, builder: PolyfaceBuilder | undefined, cache: GrowableXYZArrayCache) {\r\n if (polygon) {\r\n if (builder)\r\n builder.addPolygonGrowableXYZArray(polygon);\r\n cache.dropToCache(polygon);\r\n }\r\n }\r\n private static addPolygonArrayToBuilderAndDropToCache(polygonArray: GrowableXYZArray[], builder: PolyfaceBuilder | undefined, cache: GrowableXYZArrayCache) {\r\n let polygon;\r\n while ((polygon = polygonArray.pop()) !== undefined) {\r\n this.addPolygonToBuilderAndDropToCache(polygon, builder, cache);\r\n }\r\n }\r\n private static createChainContextsForConvexClipPlaneSet(clipper: ConvexClipPlaneSet): ChainMergeContext[] {\r\n const chainContexts = [];\r\n for (const plane of clipper.planes) {\r\n if (!plane.interior) {\r\n const c = ChainMergeContext.create();\r\n c.plane = plane;\r\n c.convexClipper = clipper;\r\n chainContexts.push(c);\r\n }\r\n }\r\n return chainContexts;\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * @internal\r\n */\r\n public static clipPolyfaceConvexClipPlaneSetToBuilders(polyface: Polyface, clipper: ConvexClipPlaneSet, destination: ClippedPolyfaceBuilders) {\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface.createVisitor(0);\r\n const cache = new GrowableXYZArrayCache();\r\n const outsideParts: GrowableXYZArray[] = [];\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n // !!! currentCandidates and next candidates are empty at this point !!!\r\n const insidePart = clipper.clipInsidePushOutside(visitor.point, outsideParts, cache);\r\n if (insidePart === undefined) {\r\n // everything is out ... outsideParts might be fragmented. Save only the original polygon\r\n builderB?.addPolygonGrowableXYZArray(visitor.point);\r\n cache.dropToCache(insidePart);\r\n cache.dropAllToCache(outsideParts);\r\n }\r\n this.addPolygonToBuilderAndDropToCache(insidePart, builderA, cache);\r\n this.addPolygonArrayToBuilderAndDropToCache(outsideParts, builderB, cache);\r\n }\r\n this.buildClosureFacesForConvexSet(visitor, clipper, destination, cache);\r\n }\r\n /**\r\n *\r\n * @param visitor visitor for all facets of interest (entire polyface)\r\n * @param clipper ConvexClipPlaneSet to apply\r\n * @param destination builders to receive inside, outside parts\r\n * @param cache GrowableArray cache.\r\n */\r\n private static buildClosureFacesForConvexSet(visitor: PolyfaceVisitor, clipper: ConvexClipPlaneSet, destination: ClippedPolyfaceBuilders,\r\n cache: GrowableXYZArrayCache) {\r\n if (destination.buildClosureFaces) {\r\n const chainContexts = this.createChainContextsForConvexClipPlaneSet(clipper);\r\n const workPoints = cache.grabFromCache();\r\n const facetPoints = cache.grabFromCache();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n for (const chainContext of chainContexts) {\r\n const plane = chainContext.plane;\r\n facetPoints.clear();\r\n facetPoints.pushFrom(visitor.point);\r\n IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(plane!, facetPoints, workPoints);\r\n chainContext.addSegmentsOnPlane(facetPoints, true);\r\n }\r\n }\r\n cache.dropToCache(facetPoints);\r\n cache.dropToCache(workPoints);\r\n for (const chainContext of chainContexts) {\r\n this.addClosureFacets(chainContext, destination, cache);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param visitor visitor for all facets of interest (entire polyface)\r\n * @param clipper ConvexClipPlaneSet to apply\r\n * @param destination builders to receive inside, outside parts\r\n * @param cache GrowableArray cache.\r\n */\r\n private static buildClosureFacesForPlane(visitor: PolyfaceVisitor, plane: PlaneAltitudeEvaluator, destination: ClippedPolyfaceBuilders,\r\n cache: GrowableXYZArrayCache) {\r\n if (destination.buildClosureFaces) {\r\n const chainContext = ChainMergeContext.create();\r\n chainContext.plane = plane;\r\n const workPoints = cache.grabFromCache();\r\n const facetPoints = cache.grabFromCache();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n facetPoints.clear();\r\n facetPoints.pushFrom(visitor.point);\r\n IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(plane, facetPoints, workPoints);\r\n chainContext.addSegmentsOnPlane(facetPoints, true);\r\n }\r\n cache.dropToCache(facetPoints);\r\n cache.dropToCache(workPoints);\r\n this.addClosureFacets(chainContext, destination, cache);\r\n }\r\n }\r\n private static evaluateInwardPlaneNormal(plane: PlaneAltitudeEvaluator, scale: number): Vector3d {\r\n return Vector3d.create(plane.velocityXYZ(scale, 0, 0), plane.velocityXYZ(0, scale, 0), plane.velocityXYZ(0, 0, scale));\r\n }\r\n /**\r\n * * Triangulate the contour.\r\n * * Add all the triangles to both builders\r\n * * reversed in builderB.\r\n */\r\n private static addClippedContour(contour: SweepContour, clipper: ConvexClipPlaneSet | undefined, destination: ClippedPolyfaceBuilders, cache: GrowableXYZArrayCache) {\r\n const polygonA = cache.grabFromCache();\r\n const polygonB = cache.grabFromCache();\r\n if (destination.builderB)\r\n destination.builderB.toggleReversedFacetFlag();\r\n contour.announceFacets((facets: IndexedPolyface) => {\r\n const visitor = facets.createVisitor();\r\n // The contour facets are convex .. easy clip ..\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n polygonA.clear();\r\n polygonA.pushFromGrowableXYZArray(visitor.point);\r\n clipper?.clipConvexPolygonInPlace(polygonA, polygonB);\r\n if (polygonA.length > 2) {\r\n destination.builderA?.addPolygonGrowableXYZArray(polygonA);\r\n destination.builderB?.addPolygonGrowableXYZArray(polygonA);\r\n }\r\n }\r\n }, undefined);\r\n if (destination.builderB)\r\n destination.builderB.toggleReversedFacetFlag();\r\n cache.dropToCache(polygonA);\r\n cache.dropToCache(polygonB);\r\n }\r\n\r\n /**\r\n * Gather loops out of the ChainMergeContext. Add to destination arrays.\r\n * @param chainContext ASSUMED TO HAVE A PLANE\r\n * @param destination\r\n */\r\n private static addClosureFacets(chainContext: ChainMergeContext, destination: ClippedPolyfaceBuilders, cache: GrowableXYZArrayCache) {\r\n const clipper = chainContext.convexClipper;\r\n const plane = chainContext.plane!;\r\n const outwardNormal = this.evaluateInwardPlaneNormal(plane, -1.0);\r\n chainContext.clusterAndMergeVerticesXYZ();\r\n const loops = chainContext.collectMaximalGrowableXYZArrays();\r\n if (loops.length > 1) {\r\n const loopSets = PolygonOps.sortOuterAndHoleLoops(loops, outwardNormal);\r\n for (const loopSet of loopSets) {\r\n PolygonOps.orientLoopsCCWForOutwardNormalInPlace(loopSet, outwardNormal);\r\n const contour = SweepContour.createForPolygon(loopSet, outwardNormal);\r\n if (contour !== undefined) {\r\n if (clipper) {\r\n this.addClippedContour(contour, clipper, destination, cache);\r\n } else {\r\n if (destination.builderA)\r\n contour.emitFacets(destination.builderA, true, clipper);\r\n if (destination.builderB)\r\n contour.emitFacets(destination.builderB, false, clipper);\r\n }\r\n }\r\n }\r\n } else {\r\n PolygonOps.orientLoopsCCWForOutwardNormalInPlace(loops, outwardNormal);\r\n const contour = SweepContour.createForPolygon(loops, outwardNormal);\r\n if (contour !== undefined) {\r\n if (clipper) {\r\n this.addClippedContour(contour, clipper, destination, cache);\r\n } else {\r\n if (destination.builderA)\r\n contour.emitFacets(destination.builderA, true, clipper);\r\n if (destination.builderB)\r\n contour.emitFacets(destination.builderB, false, clipper);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * @internal\r\n */\r\n public static clipPolyfaceClipPlaneToBuilders(polyface: Polyface, clipper: PlaneAltitudeEvaluator, destination: ClippedPolyfaceBuilders) {\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface.createVisitor(0);\r\n const cache = new GrowableXYZArrayCache();\r\n const inside = cache.grabFromCache();\r\n const outside = cache.grabFromCache();\r\n const range = Range1d.createNull();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n // !!! currentCandidates and next candidates are empty at this point !!!\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(clipper, visitor.point, inside, outside, range);\r\n if (builderA)\r\n builderA.addPolygonGrowableXYZArray(inside);\r\n if (builderB)\r\n builderB.addPolygonGrowableXYZArray(outside);\r\n }\r\n this.buildClosureFacesForPlane(visitor, clipper, destination, cache);\r\n cache.dropToCache(inside);\r\n cache.dropToCache(outside);\r\n }\r\n\r\n /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet\r\n * * accumulate inside and outside facets -- to destination.builderA and destination.builderB\r\n * * if `destination.buildClosureFaces` is set, and also build closure facets\r\n * * This method parses the variant input types and calls a more specific method.\r\n * * WARNING: The new mesh is \"points only\".\r\n * * outputSelect applies only for UnionOfConvexClipPlaneSets -- see [[PolyfaceClip.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders]]\r\n */\r\n public static clipPolyfaceInsideOutside(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet | UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders,\r\n outputSelect: number = 0) {\r\n if (clipper instanceof ClipPlane) {\r\n this.clipPolyfaceClipPlaneToBuilders(polyface, clipper, destination);\r\n } else if (clipper instanceof ConvexClipPlaneSet) {\r\n this.clipPolyfaceConvexClipPlaneSetToBuilders(polyface, clipper, destination);\r\n } else if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface, clipper, destination, outputSelect);\r\n }\r\n }\r\n /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet\r\n * * This method parses the variant input types and calls a more specific method.\r\n * * To get both inside and outside parts, use clipPolyfaceInsideOutside\r\n * * WARNING: The new mesh is \"points only\".\r\n */\r\n public static clipPolyface(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet): Polyface | undefined {\r\n if (clipper instanceof ClipPlane)\r\n return this.clipPolyfaceClipPlane(polyface, clipper);\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.clipPolyfaceConvexClipPlaneSet(polyface, clipper);\r\n // (The if tests exhaust the type space -- this line is unreachable.)\r\n return undefined;\r\n }\r\n /** Find consecutive points around a polygon (with implied closure edge) that are ON a plane\r\n * @param points array of points around polygon. Closure edge is implied.\r\n * @param chainContext context receiving edges\r\n * @param point0 work point\r\n * @param point1 work point\r\n */\r\n private static collectEdgesOnPlane(points: GrowableXYZArray, clipper: ClipPlane, chainContext: ChainMergeContext, point0: Point3d, point1: Point3d) {\r\n const n = points.length;\r\n if (n > 1) {\r\n points.getPoint3dAtUncheckedPointIndex(n - 1, point0);\r\n for (let i = 0; i < n; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, point1);\r\n if (clipper.isPointOn(point0) && clipper.isPointOn(point1))\r\n chainContext.addSegment(point0, point1);\r\n point0.setFromPoint3d(point1);\r\n }\r\n }\r\n }\r\n /** Intersect each facet with the clip plane. (Producing intersection edges.)\r\n * * Return all edges chained as array of LineString3d.\r\n */\r\n public static sectionPolyfaceClipPlane(polyface: Polyface, clipper: ClipPlane): LineString3d[] {\r\n const chainContext = ChainMergeContext.create();\r\n\r\n const visitor = polyface.createVisitor(0);\r\n const work = new GrowableXYZArray(10);\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n clipper.clipConvexPolygonInPlace(visitor.point, work, true);\r\n this.collectEdgesOnPlane(visitor.point, clipper, chainContext, point0, point1);\r\n }\r\n chainContext.clusterAndMergeVerticesXYZ();\r\n return chainContext.collectMaximalChains();\r\n }\r\n\r\n /**\r\n * * Split facets of mesh \"A\" into parts that are\r\n * * under mesh \"B\"\r\n * * over mesh \"B\"\r\n * * both meshes are represented by visitors rather than the meshes themselves\r\n * * If the data in-hand is a mesh, call with `mesh.createVisitor`\r\n * * The respective clip parts are fed to caller-supplied builders.\r\n * * Caller may set either or both builders to toggle facet order (e.g. toggle the lower facets to make them \"point down\" in cut-fill application)\r\n * * This step is commonly one-half of \"cut fill\".\r\n * * A \"cut fill\" wrapper will call this twice with the visitor and builder roles reversed.\r\n * * Both polyfaces are assumed convex with CCW orientation viewed from above.\r\n * @param visitorA iterator over polyface to be split.\r\n * @param visitorB iterator over polyface that acts as a splitter\r\n * @param orientUnderMeshDownward if true, the \"meshAUnderB\" output is oriented with its normals reversed so it can act as the bottom side of a cut-fill pair.\r\n */\r\n public static clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorA: PolyfaceVisitor, visitorB: PolyfaceVisitor,\r\n builderAUnderB: PolyfaceBuilder | undefined,\r\n builderAOverB: PolyfaceBuilder | undefined) {\r\n const rangeDataA = PolyfaceQuery.collectRangeLengthData(visitorA);\r\n const searchA = RangeSearch.create2dSearcherForRangeLengthData<number>(rangeDataA);\r\n if (!searchA)\r\n return;\r\n const range = Range3d.create();\r\n for (visitorA.reset(); visitorA.moveToNextFacet();) {\r\n visitorA.point.setRange(range);\r\n searchA.addRange(range, visitorA.currentReadIndex());\r\n }\r\n const xyClip = new GrowableXYZArray(10);\r\n const workArray = new GrowableXYZArray(10);\r\n const xyFrustum = ConvexClipPlaneSet.createEmpty();\r\n const below = new GrowableXYZArray(10);\r\n const above = new GrowableXYZArray(10);\r\n const planeOfFacet = ClipPlane.createNormalAndPointXYZXYZ(0, 0, 1, 0, 0, 0)!;\r\n const altitudeRange = Range1d.createNull();\r\n\r\n for (visitorB.reset(); visitorB.moveToNextFacet();) {\r\n visitorB.point.setRange(range);\r\n ConvexClipPlaneSet.setPlaneAndXYLoopCCW(visitorB.point, planeOfFacet, xyFrustum);\r\n searchA.searchRange2d(range, (_rangeA: Range2d, readIndexA: number) => {\r\n visitorA.moveToReadIndex(readIndexA);\r\n xyFrustum.polygonClip(visitorA.point, xyClip, workArray);\r\n // builderAOverB.addPolygonGrowableXYZArray(xyClip);\r\n if (xyClip.length > 0) {\r\n // planeOfFacet.convexPolygonSplitInsideOutsideGrowableArrays(xyClip, below, above, altitudeRange);\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(planeOfFacet, xyClip, below, above, altitudeRange);\r\n if (below.length > 0 && builderAUnderB)\r\n builderAUnderB.addPolygonGrowableXYZArray(below);\r\n if (above.length > 0 && builderAOverB)\r\n builderAOverB.addPolygonGrowableXYZArray(above);\r\n }\r\n return true;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * * Split facets into vertically overlapping sections\r\n * * both meshes are represented by visitors rather than the meshes themselves\r\n * * If the data in-hand is a mesh, call with `mesh.createVisitor`\r\n * * The respective clip parts are returned as separate meshes.\r\n * * Caller may set either or both builders to toggle facet order (e.g. toggle the lower facets to make them \"point down\" in cut-fill application)\r\n * * Both polyfaces are assumed convex with CCW orientation viewed from above.\r\n * * Each output contains some facets from meshA and some from meshB:\r\n * * meshAUnderB -- areas where meshA is underneath mesh B.\r\n * * If A is \"design surface\" and B is existing DTM, this is \"cut\" volume\r\n * * meshAOverB -- areas where meshB is over meshB.\r\n * * If A is \"design surface\" and B is existing DTM, this is \"fill\" volume\r\n *\r\n * @param visitorA iterator over polyface to be split.\r\n * @param visitorB iterator over polyface that acts as a splitter\r\n * @param orientUnderMeshDownward if true, the \"meshAUnderB\" output is oriented with its normals reversed so it can act as the bottom side of a cut-fill pair.\r\n */\r\n public static computeCutFill(meshA: IndexedPolyface, meshB: IndexedPolyface): { meshAUnderB: IndexedPolyface, meshAOverB: IndexedPolyface } {\r\n const visitorA = meshA.createVisitor();\r\n const visitorB = meshB.createVisitor();\r\n const builderAUnderB = PolyfaceBuilder.create();\r\n const builderAOverB = PolyfaceBuilder.create();\r\n builderAUnderB.toggleReversedFacetFlag();\r\n this.clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorA, visitorB, builderAUnderB, builderAOverB);\r\n builderAUnderB.toggleReversedFacetFlag();\r\n builderAOverB.toggleReversedFacetFlag();\r\n this.clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorB, visitorA, builderAOverB, builderAUnderB);\r\n return {\r\n meshAUnderB: builderAUnderB.claimPolyface(),\r\n meshAOverB: builderAOverB.claimPolyface(),\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PolyfaceClip.js","sourceRoot":"","sources":["../../../src/polyface/PolyfaceClip.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F;;GAEG;AAEH,mEAAmE;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAEpF,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,E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EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QACxG,OAAO;YACL,WAAW,EAAE,cAAc,CAAC,aAAa,EAAE;YAC3C,UAAU,EAAE,aAAa,CAAC,aAAa,EAAE;SAC1C,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\n/** @packageDocumentation\r\n * @module Polyface\r\n */\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { ClipPlane } from \"../clipping/ClipPlane\";\r\nimport { ConvexClipPlaneSet } from \"../clipping/ConvexClipPlaneSet\";\r\nimport { UnionOfConvexClipPlaneSets } from \"../clipping/UnionOfConvexClipPlaneSets\";\r\nimport { AnyRegion } from \"../curve/CurveTypes\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { Loop } from \"../curve/Loop\";\r\nimport { RegionBinaryOpType, RegionOps } from \"../curve/RegionOps\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { UnionRegion } from \"../curve/UnionRegion\";\r\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { FrameBuilder } from \"../geometry3d/FrameBuilder\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { IndexedXYZCollectionPolygonOps, PolygonOps } from \"../geometry3d/PolygonOps\";\r\nimport { Range1d, Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { GrowableXYZArrayCache } from \"../geometry3d/ReusableObjectCache\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { SweepContour } from \"../solid/SweepContour\";\r\nimport { ChainMergeContext } from \"../topology/ChainMerge\";\r\nimport { RangeSearch } from \"./multiclip/RangeSearch\";\r\nimport { IndexedPolyface, Polyface, PolyfaceVisitor } from \"./Polyface\";\r\nimport { PolyfaceBuilder } from \"./PolyfaceBuilder\";\r\nimport { PolyfaceQuery } from \"./PolyfaceQuery\";\r\n\r\n/**\r\n * carrier for a point array with an index into UnionOfConvexClipPlaneSets\r\n * @private\r\n */\r\nclass ClipCandidate {\r\n public nextConvexSetIndex: number;\r\n public points: GrowableXYZArray;\r\n public constructor(points: GrowableXYZArray, nextConvexSetIndex: number) {\r\n this.nextConvexSetIndex = nextConvexSetIndex;\r\n this.points = points;\r\n }\r\n}\r\n\r\n/**\r\n * A pair of PolyfaceBuilder objects, for use by clippers that emit inside and outside parts.\r\n * * There are nominally 4 builders:\r\n * * builderA collects simple \"inside\" clip.\r\n * * builderB collects simple \"outside\" clip.\r\n * * builderA1 collects \"side\" clip for inside.\r\n * * builderB1 collets \"side\" clip for outside.\r\n * * `static ClippedPolyfaceBuilders.create(keepInside, keepOutside)` initializes `builderA` and `builderB` (each optionally to undefined), with undefined `builderA1` and `builderB1`\r\n * * `builders.enableSideBuilders()` makes `builderA1` and `builderB1` match `builderA` and `builderB`.\r\n * * construction methods aim their facets at appropriate builders if defined.\r\n * * @public\r\n */\r\nexport class ClippedPolyfaceBuilders {\r\n /** An available builder. Typically the \"inside\" parts */\r\n public builderA?: PolyfaceBuilder;\r\n /** An available builder. Typically the \"outside\" parts */\r\n public builderB?: PolyfaceBuilder;\r\n /** request to construct cut faces */\r\n public buildClosureFaces?: boolean;\r\n private constructor(builderA: PolyfaceBuilder | undefined, builderB: PolyfaceBuilder | undefined, buildClosureFaces: boolean = false) {\r\n this.builderA = builderA;\r\n this.builderB = builderB;\r\n this.buildClosureFaces = buildClosureFaces;\r\n }\r\n /** Simple create with default options on builder. */\r\n public static create(keepInside: boolean = true, keepOutside: boolean = false, buildSideFaces: boolean = false) {\r\n return new ClippedPolyfaceBuilders(keepInside ? PolyfaceBuilder.create() : undefined, keepOutside ? PolyfaceBuilder.create() : undefined, buildSideFaces);\r\n }\r\n\r\n public claimPolyface(selector: 0 | 1, fixup: boolean, tolerance: number = Geometry.smallMetricDistance): IndexedPolyface | undefined {\r\n const builder = selector === 0 ? this.builderA : this.builderB;\r\n if (builder) {\r\n let polyface = builder.claimPolyface(true, tolerance);\r\n if (fixup) {\r\n polyface = PolyfaceQuery.cloneWithTVertexFixup(polyface);\r\n polyface = PolyfaceQuery.cloneWithDanglingEdgesRemoved(polyface);\r\n }\r\n return polyface;\r\n }\r\n return undefined;\r\n }\r\n}\r\n/** PolyfaceClip is a static class gathering operations using Polyfaces and clippers.\r\n * @public\r\n */\r\nexport class PolyfaceClip {\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return all surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\" -- parameters, normals, etc are not interpolated\r\n */\r\n public static clipPolyfaceClipPlaneWithClosureFace(polyface: Polyface, clipper: ClipPlane, insideClip: boolean = true, buildClosureFaces: boolean = true) {\r\n return this.clipPolyfaceClipPlane(polyface, clipper, insideClip, buildClosureFaces);\r\n }\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return all surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\" -- parameters, normals, etc are not interpolated\r\n */\r\n public static clipPolyfaceClipPlane(polyface: Polyface, clipper: ClipPlane, insideClip: boolean = true, buildClosureFaces: boolean = false): Polyface {\r\n const builders = ClippedPolyfaceBuilders.create(insideClip, !insideClip, buildClosureFaces);\r\n this.clipPolyfaceInsideOutside(polyface, clipper, builders);\r\n return builders.claimPolyface(insideClip ? 0 : 1, true)!;\r\n }\r\n\r\n /** Clip each facet of polyface to the ClipPlane.\r\n * * Return surviving clip as a new mesh.\r\n * * WARNING: The new mesh is \"points only\".\r\n */\r\n public static clipPolyfaceConvexClipPlaneSet(polyface: Polyface, clipper: ConvexClipPlaneSet): Polyface {\r\n const visitor = polyface.createVisitor(0);\r\n const builder = PolyfaceBuilder.create();\r\n const work = new GrowableXYZArray(10);\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n clipper.clipConvexPolygonInPlace(visitor.point, work);\r\n if (visitor.point.length > 2)\r\n builder.addPolygonGrowableXYZArray(visitor.point);\r\n }\r\n return builder.claimPolyface(true);\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * * outputSelect determines how the clip output is structured\r\n * * 0 outputs all shards -- this may have many interior edges.\r\n * * 1 stitches shards together to get cleaner facets.\r\n */\r\n public static clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface: Polyface | PolyfaceVisitor, allClippers: UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders, outputSelector: number = 1) {\r\n if (polyface instanceof Polyface) {\r\n this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface.createVisitor(0), allClippers, destination, outputSelector);\r\n return;\r\n }\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface; // alias; we have a visitor now\r\n const cache = new GrowableXYZArrayCache();\r\n const insideShards: GrowableXYZArray[] = [];\r\n const outsideShards: GrowableXYZArray[] = [];\r\n const residualPolygons: ClipCandidate[] = [];\r\n let candidate: ClipCandidate | undefined;\r\n const outsideParts: GrowableXYZArray[] = [];\r\n\r\n const numConvexSet = allClippers.convexSets.length;\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n residualPolygons.push(new ClipCandidate(cache.grabAndFill(visitor.point), 0));\r\n while ((candidate = residualPolygons.pop()) !== undefined) {\r\n const convexSetIndex = candidate.nextConvexSetIndex;\r\n if (convexSetIndex >= numConvexSet) {\r\n // ths remnant polygon is OUT ...\r\n if (candidate.points.length > 2)\r\n outsideShards.push(candidate.points);\r\n } else {\r\n const clipper = allClippers.convexSets[convexSetIndex];\r\n outsideParts.length = 0; // NO NO -- why isn't it empty from prior step cleanup?\r\n const insidePart = clipper.clipInsidePushOutside(candidate.points, outsideParts, cache);\r\n if (insidePart) {\r\n if (insidePart.length > 2)\r\n insideShards.push(insidePart);\r\n // Keep outside parts active for clip by later facets . . .\r\n for (const outsidePolygon of outsideParts) {\r\n residualPolygons.push(new ClipCandidate(outsidePolygon, convexSetIndex + 1));\r\n }\r\n } else {\r\n // Nothing was insidePart. The outside parts might be split by intermediate steps -- but all the pieces are there.\r\n candidate.nextConvexSetIndex++;\r\n residualPolygons.push(candidate);\r\n }\r\n outsideParts.length = 0;\r\n }\r\n }\r\n if (outsideShards.length === 0) {\r\n builderA?.addPolygonGrowableXYZArray(visitor.point);\r\n } else if (insideShards.length === 0) {\r\n // the facet spanned clippers but is intact outside\r\n builderB?.addPolygonGrowableXYZArray(visitor.point);\r\n } else {\r\n const localToWorld = FrameBuilder.createRightHandedFrame(undefined, visitor.point);\r\n let worldToLocal: Transform | undefined;\r\n if (outputSelector === 1 && localToWorld !== undefined\r\n && undefined !== (worldToLocal = localToWorld.inverse())) {\r\n this.cleanupAndAddRegion(builderA, insideShards, worldToLocal, localToWorld);\r\n this.cleanupAndAddRegion(builderB, outsideShards, worldToLocal, localToWorld);\r\n } else {\r\n for (const shard of insideShards)\r\n this.addPolygonToBuilderAndDropToCache(shard, builderA, cache);\r\n for (const shard of outsideShards)\r\n this.addPolygonToBuilderAndDropToCache(shard, builderB, cache);\r\n }\r\n }\r\n outsideShards.length = 0;\r\n insideShards.length = 0;\r\n }\r\n cache.dropAllToCache(outsideParts);\r\n if (destination.buildClosureFaces) {\r\n for (const clipper of allClippers.convexSets) {\r\n this.buildClosureFacesForConvexSet(visitor, clipper, destination, cache);\r\n }\r\n }\r\n }\r\n private static addRegion(builder: PolyfaceBuilder | undefined, region: AnyRegion | undefined) {\r\n if (builder !== undefined && region !== undefined) {\r\n if (region instanceof Loop && region.children.length === 1 && region.children[0] instanceof LineString3d) {\r\n builder.addPolygonGrowableXYZArray(region.children[0].packedPoints);\r\n } else if (region instanceof UnionRegion) {\r\n for (const child of region.children)\r\n this.addRegion(builder, child);\r\n } else {\r\n assert(!\"unexpected region encountered\");\r\n }\r\n }\r\n }\r\n // WARNING: shards are transformed into local system, not reverted!!!\r\n private static cleanupAndAddRegion(builder: PolyfaceBuilder | undefined, shards: GrowableXYZArray[],\r\n worldToLocal: Transform | undefined, localToWorld: Transform | undefined) {\r\n if (builder !== undefined && shards.length > 0) {\r\n if (worldToLocal)\r\n GrowableXYZArray.multiplyTransformInPlace(worldToLocal, shards);\r\n const outsidePieces = RegionOps.polygonBooleanXYToLoops(shards, RegionBinaryOpType.Union, []);\r\n if (outsidePieces && outsidePieces.children.length > 0) {\r\n if (localToWorld)\r\n outsidePieces.tryTransformInPlace(localToWorld);\r\n RegionOps.consolidateAdjacentPrimitives(outsidePieces); // source of the T-vertices removed in claimPolyface\r\n this.addRegion(builder, outsidePieces);\r\n }\r\n }\r\n }\r\n private static addPolygonToBuilderAndDropToCache(polygon: GrowableXYZArray | undefined, builder: PolyfaceBuilder | undefined, cache: GrowableXYZArrayCache) {\r\n if (polygon) {\r\n if (builder)\r\n builder.addPolygonGrowableXYZArray(polygon);\r\n cache.dropToCache(polygon);\r\n }\r\n }\r\n private static addPolygonArrayToBuilderAndDropToCache(polygonArray: GrowableXYZArray[], builder: PolyfaceBuilder | undefined, cache: GrowableXYZArrayCache) {\r\n let polygon;\r\n while ((polygon = polygonArray.pop()) !== undefined) {\r\n this.addPolygonToBuilderAndDropToCache(polygon, builder, cache);\r\n }\r\n }\r\n private static createChainContextsForConvexClipPlaneSet(clipper: ConvexClipPlaneSet): ChainMergeContext[] {\r\n const chainContexts = [];\r\n for (const plane of clipper.planes) {\r\n if (!plane.interior) {\r\n const c = ChainMergeContext.create();\r\n c.plane = plane;\r\n c.convexClipper = clipper;\r\n chainContexts.push(c);\r\n }\r\n }\r\n return chainContexts;\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * @internal\r\n */\r\n public static clipPolyfaceConvexClipPlaneSetToBuilders(polyface: Polyface, clipper: ConvexClipPlaneSet, destination: ClippedPolyfaceBuilders) {\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface.createVisitor(0);\r\n const cache = new GrowableXYZArrayCache();\r\n const outsideParts: GrowableXYZArray[] = [];\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n // !!! currentCandidates and next candidates are empty at this point !!!\r\n const insidePart = clipper.clipInsidePushOutside(visitor.point, outsideParts, cache);\r\n if (insidePart === undefined) {\r\n // everything is out ... outsideParts might be fragmented. Save only the original polygon\r\n builderB?.addPolygonGrowableXYZArray(visitor.point);\r\n cache.dropToCache(insidePart);\r\n cache.dropAllToCache(outsideParts);\r\n }\r\n this.addPolygonToBuilderAndDropToCache(insidePart, builderA, cache);\r\n this.addPolygonArrayToBuilderAndDropToCache(outsideParts, builderB, cache);\r\n }\r\n this.buildClosureFacesForConvexSet(visitor, clipper, destination, cache);\r\n }\r\n /**\r\n *\r\n * @param visitor visitor for all facets of interest (entire polyface)\r\n * @param clipper ConvexClipPlaneSet to apply\r\n * @param destination builders to receive inside, outside parts\r\n * @param cache GrowableArray cache.\r\n */\r\n private static buildClosureFacesForConvexSet(visitor: PolyfaceVisitor, clipper: ConvexClipPlaneSet, destination: ClippedPolyfaceBuilders,\r\n cache: GrowableXYZArrayCache) {\r\n if (destination.buildClosureFaces) {\r\n const chainContexts = this.createChainContextsForConvexClipPlaneSet(clipper);\r\n const workPoints = cache.grabFromCache();\r\n const facetPoints = cache.grabFromCache();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n for (const chainContext of chainContexts) {\r\n const plane = chainContext.plane;\r\n facetPoints.clear();\r\n facetPoints.pushFrom(visitor.point);\r\n IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(plane!, facetPoints, workPoints);\r\n chainContext.addSegmentsOnPlane(facetPoints, true);\r\n }\r\n }\r\n cache.dropToCache(facetPoints);\r\n cache.dropToCache(workPoints);\r\n for (const chainContext of chainContexts) {\r\n this.addClosureFacets(chainContext, destination, cache);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @param visitor visitor for all facets of interest (entire polyface)\r\n * @param clipper ConvexClipPlaneSet to apply\r\n * @param destination builders to receive inside, outside parts\r\n * @param cache GrowableArray cache.\r\n */\r\n private static buildClosureFacesForPlane(visitor: PolyfaceVisitor, plane: PlaneAltitudeEvaluator, destination: ClippedPolyfaceBuilders,\r\n cache: GrowableXYZArrayCache) {\r\n if (destination.buildClosureFaces) {\r\n const chainContext = ChainMergeContext.create();\r\n chainContext.plane = plane;\r\n const workPoints = cache.grabFromCache();\r\n const facetPoints = cache.grabFromCache();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n facetPoints.clear();\r\n facetPoints.pushFrom(visitor.point);\r\n IndexedXYZCollectionPolygonOps.clipConvexPolygonInPlace(plane, facetPoints, workPoints);\r\n chainContext.addSegmentsOnPlane(facetPoints, true);\r\n }\r\n cache.dropToCache(facetPoints);\r\n cache.dropToCache(workPoints);\r\n this.addClosureFacets(chainContext, destination, cache);\r\n }\r\n }\r\n private static evaluateInwardPlaneNormal(plane: PlaneAltitudeEvaluator, scale: number): Vector3d {\r\n return Vector3d.create(plane.velocityXYZ(scale, 0, 0), plane.velocityXYZ(0, scale, 0), plane.velocityXYZ(0, 0, scale));\r\n }\r\n /**\r\n * * Triangulate the contour.\r\n * * Add all the triangles to both builders\r\n * * reversed in builderB.\r\n */\r\n private static addClippedContour(contour: SweepContour, clipper: ConvexClipPlaneSet | undefined, destination: ClippedPolyfaceBuilders, cache: GrowableXYZArrayCache) {\r\n const polygonA = cache.grabFromCache();\r\n const polygonB = cache.grabFromCache();\r\n if (destination.builderB)\r\n destination.builderB.toggleReversedFacetFlag();\r\n contour.announceFacets((facets: IndexedPolyface) => {\r\n const visitor = facets.createVisitor();\r\n // The contour facets are convex .. easy clip ..\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n polygonA.clear();\r\n polygonA.pushFromGrowableXYZArray(visitor.point);\r\n clipper?.clipConvexPolygonInPlace(polygonA, polygonB);\r\n if (polygonA.length > 2) {\r\n destination.builderA?.addPolygonGrowableXYZArray(polygonA);\r\n destination.builderB?.addPolygonGrowableXYZArray(polygonA);\r\n }\r\n }\r\n }, undefined);\r\n if (destination.builderB)\r\n destination.builderB.toggleReversedFacetFlag();\r\n cache.dropToCache(polygonA);\r\n cache.dropToCache(polygonB);\r\n }\r\n\r\n /**\r\n * Gather loops out of the ChainMergeContext. Add to destination arrays.\r\n * @param chainContext ASSUMED TO HAVE A PLANE\r\n * @param destination\r\n */\r\n private static addClosureFacets(chainContext: ChainMergeContext, destination: ClippedPolyfaceBuilders, cache: GrowableXYZArrayCache) {\r\n const clipper = chainContext.convexClipper;\r\n const plane = chainContext.plane!;\r\n const outwardNormal = this.evaluateInwardPlaneNormal(plane, -1.0);\r\n chainContext.clusterAndMergeVerticesXYZ();\r\n const loops = chainContext.collectMaximalGrowableXYZArrays();\r\n if (loops.length > 1) {\r\n const loopSets = PolygonOps.sortOuterAndHoleLoops(loops, outwardNormal);\r\n for (const loopSet of loopSets) {\r\n PolygonOps.orientLoopsCCWForOutwardNormalInPlace(loopSet, outwardNormal);\r\n const contour = SweepContour.createForPolygon(loopSet, outwardNormal);\r\n if (contour !== undefined) {\r\n if (clipper) {\r\n this.addClippedContour(contour, clipper, destination, cache);\r\n } else {\r\n if (destination.builderA)\r\n contour.emitFacets(destination.builderA, true, clipper);\r\n if (destination.builderB)\r\n contour.emitFacets(destination.builderB, false, clipper);\r\n }\r\n }\r\n }\r\n } else {\r\n PolygonOps.orientLoopsCCWForOutwardNormalInPlace(loops, outwardNormal);\r\n const contour = SweepContour.createForPolygon(loops, outwardNormal);\r\n if (contour !== undefined) {\r\n if (clipper) {\r\n this.addClippedContour(contour, clipper, destination, cache);\r\n } else {\r\n if (destination.builderA)\r\n contour.emitFacets(destination.builderA, true, clipper);\r\n if (destination.builderB)\r\n contour.emitFacets(destination.builderB, false, clipper);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Clip each facet of polyface to the the clippers.\r\n * * Add inside, outside fragments to builderA, builderB\r\n * * This does not consider params, normals, colors. Just points.\r\n * @internal\r\n */\r\n public static clipPolyfaceClipPlaneToBuilders(polyface: Polyface, clipper: PlaneAltitudeEvaluator, destination: ClippedPolyfaceBuilders) {\r\n const builderA = destination.builderA;\r\n const builderB = destination.builderB;\r\n const visitor = polyface.createVisitor(0);\r\n const cache = new GrowableXYZArrayCache();\r\n const inside = cache.grabFromCache();\r\n const outside = cache.grabFromCache();\r\n const range = Range1d.createNull();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n // !!! currentCandidates and next candidates are empty at this point !!!\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(clipper, visitor.point, inside, outside, range);\r\n if (builderA)\r\n builderA.addPolygonGrowableXYZArray(inside);\r\n if (builderB)\r\n builderB.addPolygonGrowableXYZArray(outside);\r\n }\r\n this.buildClosureFacesForPlane(visitor, clipper, destination, cache);\r\n cache.dropToCache(inside);\r\n cache.dropToCache(outside);\r\n }\r\n\r\n /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet\r\n * * accumulate inside and outside facets -- to destination.builderA and destination.builderB\r\n * * if `destination.buildClosureFaces` is set, and also build closure facets\r\n * * This method parses the variant input types and calls a more specific method.\r\n * * WARNING: The new mesh is \"points only\".\r\n * * outputSelect applies only for UnionOfConvexClipPlaneSets -- see [[PolyfaceClip.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders]]\r\n */\r\n public static clipPolyfaceInsideOutside(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet | UnionOfConvexClipPlaneSets, destination: ClippedPolyfaceBuilders,\r\n outputSelect: number = 0) {\r\n if (clipper instanceof ClipPlane) {\r\n this.clipPolyfaceClipPlaneToBuilders(polyface, clipper, destination);\r\n } else if (clipper instanceof ConvexClipPlaneSet) {\r\n this.clipPolyfaceConvexClipPlaneSetToBuilders(polyface, clipper, destination);\r\n } else if (clipper instanceof UnionOfConvexClipPlaneSets) {\r\n this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(polyface, clipper, destination, outputSelect);\r\n }\r\n }\r\n /** Clip each facet of polyface to the ClipPlane or ConvexClipPlaneSet\r\n * * This method parses the variant input types and calls a more specific method.\r\n * * To get both inside and outside parts, use clipPolyfaceInsideOutside\r\n * * WARNING: The new mesh is \"points only\".\r\n */\r\n public static clipPolyface(polyface: Polyface, clipper: ClipPlane | ConvexClipPlaneSet): Polyface | undefined {\r\n if (clipper instanceof ClipPlane)\r\n return this.clipPolyfaceClipPlane(polyface, clipper);\r\n if (clipper instanceof ConvexClipPlaneSet)\r\n return this.clipPolyfaceConvexClipPlaneSet(polyface, clipper);\r\n // (The if tests exhaust the type space -- this line is unreachable.)\r\n return undefined;\r\n }\r\n /**\r\n * Drape the region onto the mesh.\r\n * * This method computes the portion of the input mesh that lies inside the clipper generated from sweeping the input region in the given direction.\r\n * @param mesh input mesh, untouched\r\n * @param region planar region to drape onto mesh\r\n * @param sweepVector optional sweep direction for region; if undefined, region normal is used\r\n * @param options how to stroke the region boundary\r\n * @returns clipped facets. No other mesh data but vertices appear in output.\r\n */\r\n public static drapeRegion(mesh: Polyface | PolyfaceVisitor, region: AnyRegion, sweepVector?: Vector3d, options?: StrokeOptions): IndexedPolyface | undefined {\r\n if (mesh instanceof Polyface)\r\n return this.drapeRegion(mesh.createVisitor(0), region, sweepVector, options);\r\n const contour = SweepContour.createForLinearSweep(region);\r\n if (!contour)\r\n return undefined;\r\n const clipper = contour.sweepToUnionOfConvexClipPlaneSets(sweepVector, false, false, options);\r\n if (!clipper)\r\n return undefined;\r\n const builders = ClippedPolyfaceBuilders.create(true);\r\n this.clipPolyfaceUnionOfConvexClipPlaneSetsToBuilders(mesh, clipper, builders, 1);\r\n return builders.claimPolyface(0, true);\r\n }\r\n /** Find consecutive points around a polygon (with implied closure edge) that are ON a plane\r\n * @param points array of points around polygon. Closure edge is implied.\r\n * @param chainContext context receiving edges\r\n * @param point0 work point\r\n * @param point1 work point\r\n */\r\n private static collectEdgesOnPlane(points: GrowableXYZArray, clipper: ClipPlane, chainContext: ChainMergeContext, point0: Point3d, point1: Point3d) {\r\n const n = points.length;\r\n if (n > 1) {\r\n points.getPoint3dAtUncheckedPointIndex(n - 1, point0);\r\n for (let i = 0; i < n; i++) {\r\n points.getPoint3dAtUncheckedPointIndex(i, point1);\r\n if (clipper.isPointOn(point0) && clipper.isPointOn(point1))\r\n chainContext.addSegment(point0, point1);\r\n point0.setFromPoint3d(point1);\r\n }\r\n }\r\n }\r\n /** Intersect each facet with the clip plane. (Producing intersection edges.)\r\n * * Return all edges chained as array of LineString3d.\r\n */\r\n public static sectionPolyfaceClipPlane(polyface: Polyface, clipper: ClipPlane): LineString3d[] {\r\n const chainContext = ChainMergeContext.create();\r\n\r\n const visitor = polyface.createVisitor(0);\r\n const work = new GrowableXYZArray(10);\r\n const point0 = Point3d.create();\r\n const point1 = Point3d.create();\r\n for (visitor.reset(); visitor.moveToNextFacet();) {\r\n clipper.clipConvexPolygonInPlace(visitor.point, work, true);\r\n this.collectEdgesOnPlane(visitor.point, clipper, chainContext, point0, point1);\r\n }\r\n chainContext.clusterAndMergeVerticesXYZ();\r\n return chainContext.collectMaximalChains();\r\n }\r\n\r\n /**\r\n * * Split facets of mesh \"A\" into parts that are\r\n * * under mesh \"B\"\r\n * * over mesh \"B\"\r\n * * both meshes are represented by visitors rather than the meshes themselves\r\n * * If the data in-hand is a mesh, call with `mesh.createVisitor`\r\n * * The respective clip parts are fed to caller-supplied builders.\r\n * * Caller may set either or both builders to toggle facet order (e.g. toggle the lower facets to make them \"point down\" in cut-fill application)\r\n * * This step is commonly one-half of \"cut fill\".\r\n * * A \"cut fill\" wrapper will call this twice with the visitor and builder roles reversed.\r\n * * Both polyfaces are assumed convex with CCW orientation viewed from above.\r\n * @param visitorA iterator over polyface to be split.\r\n * @param visitorB iterator over polyface that acts as a splitter\r\n * @param orientUnderMeshDownward if true, the \"meshAUnderB\" output is oriented with its normals reversed so it can act as the bottom side of a cut-fill pair.\r\n */\r\n public static clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorA: PolyfaceVisitor, visitorB: PolyfaceVisitor,\r\n builderAUnderB: PolyfaceBuilder | undefined,\r\n builderAOverB: PolyfaceBuilder | undefined) {\r\n const rangeDataA = PolyfaceQuery.collectRangeLengthData(visitorA);\r\n const searchA = RangeSearch.create2dSearcherForRangeLengthData<number>(rangeDataA);\r\n if (!searchA)\r\n return;\r\n const range = Range3d.create();\r\n for (visitorA.reset(); visitorA.moveToNextFacet();) {\r\n visitorA.point.setRange(range);\r\n searchA.addRange(range, visitorA.currentReadIndex());\r\n }\r\n const xyClip = new GrowableXYZArray(10);\r\n const workArray = new GrowableXYZArray(10);\r\n const xyFrustum = ConvexClipPlaneSet.createEmpty();\r\n const below = new GrowableXYZArray(10);\r\n const above = new GrowableXYZArray(10);\r\n const planeOfFacet = ClipPlane.createNormalAndPointXYZXYZ(0, 0, 1, 0, 0, 0)!;\r\n const altitudeRange = Range1d.createNull();\r\n\r\n for (visitorB.reset(); visitorB.moveToNextFacet();) {\r\n visitorB.point.setRange(range);\r\n ConvexClipPlaneSet.setPlaneAndXYLoopCCW(visitorB.point, planeOfFacet, xyFrustum);\r\n searchA.searchRange2d(range, (_rangeA: Range2d, readIndexA: number) => {\r\n visitorA.moveToReadIndex(readIndexA);\r\n xyFrustum.polygonClip(visitorA.point, xyClip, workArray);\r\n // builderAOverB.addPolygonGrowableXYZArray(xyClip);\r\n if (xyClip.length > 0) {\r\n // planeOfFacet.convexPolygonSplitInsideOutsideGrowableArrays(xyClip, below, above, altitudeRange);\r\n IndexedXYZCollectionPolygonOps.splitConvexPolygonInsideOutsidePlane(planeOfFacet, xyClip, below, above, altitudeRange);\r\n if (below.length > 0 && builderAUnderB)\r\n builderAUnderB.addPolygonGrowableXYZArray(below);\r\n if (above.length > 0 && builderAOverB)\r\n builderAOverB.addPolygonGrowableXYZArray(above);\r\n }\r\n return true;\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * * Split facets into vertically overlapping sections\r\n * * both meshes are represented by visitors rather than the meshes themselves\r\n * * If the data in-hand is a mesh, call with `mesh.createVisitor`\r\n * * The respective clip parts are returned as separate meshes.\r\n * * Caller may set either or both builders to toggle facet order (e.g. toggle the lower facets to make them \"point down\" in cut-fill application)\r\n * * Both polyfaces are assumed convex with CCW orientation viewed from above.\r\n * * Each output contains some facets from meshA and some from meshB:\r\n * * meshAUnderB -- areas where meshA is underneath mesh B.\r\n * * If A is \"design surface\" and B is existing DTM, this is \"cut\" volume\r\n * * meshAOverB -- areas where meshB is over meshB.\r\n * * If A is \"design surface\" and B is existing DTM, this is \"fill\" volume\r\n *\r\n * @param visitorA iterator over polyface to be split.\r\n * @param visitorB iterator over polyface that acts as a splitter\r\n * @param orientUnderMeshDownward if true, the \"meshAUnderB\" output is oriented with its normals reversed so it can act as the bottom side of a cut-fill pair.\r\n */\r\n public static computeCutFill(meshA: IndexedPolyface, meshB: IndexedPolyface): { meshAUnderB: IndexedPolyface, meshAOverB: IndexedPolyface } {\r\n const visitorA = meshA.createVisitor();\r\n const visitorB = meshB.createVisitor();\r\n const builderAUnderB = PolyfaceBuilder.create();\r\n const builderAOverB = PolyfaceBuilder.create();\r\n builderAUnderB.toggleReversedFacetFlag();\r\n this.clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorA, visitorB, builderAUnderB, builderAOverB);\r\n builderAUnderB.toggleReversedFacetFlag();\r\n builderAOverB.toggleReversedFacetFlag();\r\n this.clipPolyfaceUnderOverConvexPolyfaceIntoBuilders(visitorB, visitorA, builderAOverB, builderAUnderB);\r\n return {\r\n meshAUnderB: builderAUnderB.claimPolyface(),\r\n meshAOverB: builderAOverB.claimPolyface(),\r\n };\r\n }\r\n}\r\n"]}
@@ -146,11 +146,13 @@ export declare class PolyfaceData {
146
146
  */
147
147
  tryTransformInPlace(transform: Transform): boolean;
148
148
  /**
149
+ * Compress the instance by equating duplicate data.
149
150
  * * Search for duplicates within points, normals, params, and colors.
150
- * * compress the data arrays.
151
- * * revise all indexing for the relocated data.
151
+ * * Compress each data array.
152
+ * * Revise all indexing for the relocated data.
153
+ * @param tolerance optional tolerance for clustering mesh vertices. Default is [[Geometry.smallMetricDistance]].
152
154
  */
153
- compress(): void;
155
+ compress(tolerance?: number): void;
154
156
  /**
155
157
  * Test if facetStartIndex is (minimally!) valid:
156
158
  * * length must be nonzero (recall that for "no facets" the facetStartIndexArray still must contain a 0)
@@ -167,40 +169,4 @@ export declare class PolyfaceData {
167
169
  */
168
170
  static reverseIndicesSingleFacet<T>(facetId: number, facetStartIndex: number[], indices: T[] | undefined, preserveStart: boolean): boolean;
169
171
  }
170
- /**
171
- * pack out data entries that are unreferenced.
172
- * @param data data to pack
173
- * @param indices indices into the data.
174
-
175
- function compressUnusedGrowableXYZArray(data: GrowableXYZArray, indices: number[]): boolean {
176
- // 1 entry per data[i]
177
- // pass 0: number of references
178
- // pass 1: post-compression index (or -1)
179
- const n0 = data.length;
180
- const work = new Int32Array(data.length);
181
- for (const k of indices) {
182
- if (k < 0 || k >= n0)
183
- return false;
184
- work[k]++;
185
- }
186
- let n1 = 0;
187
- for (let i = 0; i < n0; i++) {
188
- if (work[i] === 0)
189
- work[i] = -1;
190
- else
191
- work[i] = n1++;
192
- }
193
- const numIndex = indices.length;
194
- for (let i = 0; i < numIndex; i++) {
195
- indices[i] = work[indices[i]];
196
- }
197
- for (let i = 0; i < n0; i++) {
198
- const j = work[i];
199
- if (j >= 0)
200
- data.moveIndexToIndex(i, j);
201
- }
202
- data.length = n1;
203
- return true;
204
- }
205
- */
206
172
  //# sourceMappingURL=PolyfaceData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PolyfaceData.d.ts","sourceRoot":"","sources":["../../../src/polyface/PolyfaceData.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,+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AyB,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE;IAW3E,kCAAkC;IAC3B,cAAc;IAIrB;;;OAGG;IACI,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO;IAQzD;;;;;;OAMG;IACI,QAAQ,CAAC,SAAS,GAAE,MAAqC,GAAG,IAAI;IAuBvE;;;;;OAKG;WACW,2BAA2B,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG,OAAO;IAS7E;;OAEG;WACW,cAAc,CAAC,CAAC,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO;IAiCrH;;OAEG;WACW,yBAAyB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,SAAS,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO;CA+BlJ"}
@@ -366,15 +366,17 @@ class PolyfaceData {
366
366
  return undefined === this.auxData || this.auxData.tryTransformInPlace(transform);
367
367
  }
368
368
  /**
369
+ * Compress the instance by equating duplicate data.
369
370
  * * Search for duplicates within points, normals, params, and colors.
370
- * * compress the data arrays.
371
- * * revise all indexing for the relocated data.
371
+ * * Compress each data array.
372
+ * * Revise all indexing for the relocated data.
373
+ * @param tolerance optional tolerance for clustering mesh vertices. Default is [[Geometry.smallMetricDistance]].
372
374
  */
373
- compress() {
374
- const packedPoints = ClusterableArray.clusterGrowablePoint3dArray(this.point);
375
+ compress(tolerance = Geometry.smallMetricDistance) {
376
+ const packedPoints = ClusterableArray.clusterGrowablePoint3dArray(this.point, tolerance);
375
377
  this.point = packedPoints.growablePackedPoints;
376
378
  packedPoints.updateIndices(this.pointIndex);
377
- // compressUnusedGrowableXYZArray(this.point, this.pointIndex);
379
+ // for now, normals, params, and colors use the default tolerance for clustering...
378
380
  if (this.normalIndex && this.normal) {
379
381
  const packedNormals = ClusterableArray.clusterGrowablePoint3dArray(this.normal);
380
382
  this.normal = packedNormals.growablePackedPoints;
@@ -494,40 +496,4 @@ class PolyfaceData {
494
496
  */
495
497
  PolyfaceData.planarityLocalRelTol = 1.0e-13;
496
498
  export { PolyfaceData };
497
- /**
498
- * pack out data entries that are unreferenced.
499
- * @param data data to pack
500
- * @param indices indices into the data.
501
-
502
- function compressUnusedGrowableXYZArray(data: GrowableXYZArray, indices: number[]): boolean {
503
- // 1 entry per data[i]
504
- // pass 0: number of references
505
- // pass 1: post-compression index (or -1)
506
- const n0 = data.length;
507
- const work = new Int32Array(data.length);
508
- for (const k of indices) {
509
- if (k < 0 || k >= n0)
510
- return false;
511
- work[k]++;
512
- }
513
- let n1 = 0;
514
- for (let i = 0; i < n0; i++) {
515
- if (work[i] === 0)
516
- work[i] = -1;
517
- else
518
- work[i] = n1++;
519
- }
520
- const numIndex = indices.length;
521
- for (let i = 0; i < numIndex; i++) {
522
- indices[i] = work[indices[i]];
523
- }
524
- for (let i = 0; i < n0; i++) {
525
- const j = work[i];
526
- if (j >= 0)
527
- data.moveIndexToIndex(i, j);
528
- }
529
- data.length = n1;
530
- return true;
531
- }
532
- */
533
499
  //# sourceMappingURL=PolyfaceData.js.map