@itwin/core-geometry 5.1.0-dev.52 → 5.1.0-dev.53

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 (183) hide show
  1. package/lib/cjs/Geometry.d.ts +1 -1
  2. package/lib/cjs/Geometry.js.map +1 -1
  3. package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
  4. package/lib/cjs/bspline/BSplineSurface.js +0 -2
  5. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  6. package/lib/cjs/curve/CurveCollection.d.ts +7 -0
  7. package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
  8. package/lib/cjs/curve/CurveCollection.js +11 -0
  9. package/lib/cjs/curve/CurveCollection.js.map +1 -1
  10. package/lib/cjs/curve/CurveFactory.d.ts +3 -2
  11. package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
  12. package/lib/cjs/curve/CurveFactory.js +6 -5
  13. package/lib/cjs/curve/CurveFactory.js.map +1 -1
  14. package/lib/cjs/curve/CurveLocationDetail.d.ts +3 -1
  15. package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
  16. package/lib/cjs/curve/CurveLocationDetail.js +6 -1
  17. package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
  18. package/lib/cjs/curve/CurvePrimitive.d.ts +7 -0
  19. package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
  20. package/lib/cjs/curve/CurvePrimitive.js +11 -0
  21. package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
  22. package/lib/cjs/curve/LineSegment3d.d.ts +2 -0
  23. package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
  24. package/lib/cjs/curve/LineSegment3d.js +4 -0
  25. package/lib/cjs/curve/LineSegment3d.js.map +1 -1
  26. package/lib/cjs/curve/LineString3d.d.ts +7 -0
  27. package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
  28. package/lib/cjs/curve/LineString3d.js +15 -3
  29. package/lib/cjs/curve/LineString3d.js.map +1 -1
  30. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  31. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
  32. package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  33. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +25 -3
  34. package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  35. package/lib/cjs/curve/Query/PlanarSubdivision.js +102 -22
  36. package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
  37. package/lib/cjs/curve/Query/StrokeCountChain.d.ts +4 -3
  38. package/lib/cjs/curve/Query/StrokeCountChain.d.ts.map +1 -1
  39. package/lib/cjs/curve/Query/StrokeCountChain.js +20 -9
  40. package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
  41. package/lib/cjs/curve/RegionMomentsXY.d.ts +1 -1
  42. package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
  43. package/lib/cjs/curve/RegionMomentsXY.js +6 -3
  44. package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
  45. package/lib/cjs/curve/RegionOps.d.ts +23 -14
  46. package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
  47. package/lib/cjs/curve/RegionOps.js +60 -21
  48. package/lib/cjs/curve/RegionOps.js.map +1 -1
  49. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +9 -1
  50. package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  51. package/lib/cjs/curve/RegionOpsClassificationSweeps.js +91 -1
  52. package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
  53. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
  54. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
  55. package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  56. package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
  57. package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
  58. package/lib/cjs/geometry3d/AngleSweep.js +1 -1
  59. package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
  60. package/lib/cjs/geometry3d/Ellipsoid.js +1 -1
  61. package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
  62. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +9 -0
  63. package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  64. package/lib/cjs/geometry3d/IndexedXYZCollection.js +14 -0
  65. package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
  66. package/lib/cjs/geometry3d/Ray3d.d.ts +7 -9
  67. package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
  68. package/lib/cjs/geometry3d/Ray3d.js +12 -22
  69. package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
  70. package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -4
  71. package/lib/cjs/geometry3d/SortablePolygon.d.ts.map +1 -1
  72. package/lib/cjs/geometry3d/SortablePolygon.js +48 -43
  73. package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
  74. package/lib/cjs/polyface/PolyfaceBuilder.js +3 -3
  75. package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
  76. package/lib/cjs/solid/Sphere.js +1 -1
  77. package/lib/cjs/solid/Sphere.js.map +1 -1
  78. package/lib/cjs/solid/SweepContour.d.ts +1 -1
  79. package/lib/cjs/solid/SweepContour.js +1 -1
  80. package/lib/cjs/solid/SweepContour.js.map +1 -1
  81. package/lib/cjs/topology/Graph.d.ts +64 -14
  82. package/lib/cjs/topology/Graph.d.ts.map +1 -1
  83. package/lib/cjs/topology/Graph.js +149 -32
  84. package/lib/cjs/topology/Graph.js.map +1 -1
  85. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +2 -2
  86. package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  87. package/lib/cjs/topology/HalfEdgeGraphSearch.js +2 -2
  88. package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
  89. package/lib/cjs/topology/RegularizeFace.d.ts.map +1 -1
  90. package/lib/cjs/topology/RegularizeFace.js +2 -1
  91. package/lib/cjs/topology/RegularizeFace.js.map +1 -1
  92. package/lib/esm/Geometry.d.ts +1 -1
  93. package/lib/esm/Geometry.js.map +1 -1
  94. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  95. package/lib/esm/bspline/BSplineSurface.js +0 -2
  96. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  97. package/lib/esm/curve/CurveCollection.d.ts +7 -0
  98. package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
  99. package/lib/esm/curve/CurveCollection.js +11 -0
  100. package/lib/esm/curve/CurveCollection.js.map +1 -1
  101. package/lib/esm/curve/CurveFactory.d.ts +3 -2
  102. package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
  103. package/lib/esm/curve/CurveFactory.js +6 -5
  104. package/lib/esm/curve/CurveFactory.js.map +1 -1
  105. package/lib/esm/curve/CurveLocationDetail.d.ts +3 -1
  106. package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
  107. package/lib/esm/curve/CurveLocationDetail.js +6 -1
  108. package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
  109. package/lib/esm/curve/CurvePrimitive.d.ts +7 -0
  110. package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
  111. package/lib/esm/curve/CurvePrimitive.js +11 -0
  112. package/lib/esm/curve/CurvePrimitive.js.map +1 -1
  113. package/lib/esm/curve/LineSegment3d.d.ts +2 -0
  114. package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
  115. package/lib/esm/curve/LineSegment3d.js +4 -0
  116. package/lib/esm/curve/LineSegment3d.js.map +1 -1
  117. package/lib/esm/curve/LineString3d.d.ts +7 -0
  118. package/lib/esm/curve/LineString3d.d.ts.map +1 -1
  119. package/lib/esm/curve/LineString3d.js +15 -3
  120. package/lib/esm/curve/LineString3d.js.map +1 -1
  121. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
  122. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
  123. package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
  124. package/lib/esm/curve/Query/PlanarSubdivision.d.ts +25 -3
  125. package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
  126. package/lib/esm/curve/Query/PlanarSubdivision.js +104 -24
  127. package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
  128. package/lib/esm/curve/Query/StrokeCountChain.d.ts +4 -3
  129. package/lib/esm/curve/Query/StrokeCountChain.d.ts.map +1 -1
  130. package/lib/esm/curve/Query/StrokeCountChain.js +20 -9
  131. package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
  132. package/lib/esm/curve/RegionMomentsXY.d.ts +1 -1
  133. package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
  134. package/lib/esm/curve/RegionMomentsXY.js +6 -3
  135. package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
  136. package/lib/esm/curve/RegionOps.d.ts +23 -14
  137. package/lib/esm/curve/RegionOps.d.ts.map +1 -1
  138. package/lib/esm/curve/RegionOps.js +60 -21
  139. package/lib/esm/curve/RegionOps.js.map +1 -1
  140. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +9 -1
  141. package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
  142. package/lib/esm/curve/RegionOpsClassificationSweeps.js +91 -2
  143. package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
  144. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
  145. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
  146. package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
  147. package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
  148. package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
  149. package/lib/esm/geometry3d/AngleSweep.js +1 -1
  150. package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
  151. package/lib/esm/geometry3d/Ellipsoid.js +1 -1
  152. package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
  153. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +9 -0
  154. package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
  155. package/lib/esm/geometry3d/IndexedXYZCollection.js +14 -0
  156. package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
  157. package/lib/esm/geometry3d/Ray3d.d.ts +7 -9
  158. package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
  159. package/lib/esm/geometry3d/Ray3d.js +12 -22
  160. package/lib/esm/geometry3d/Ray3d.js.map +1 -1
  161. package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -4
  162. package/lib/esm/geometry3d/SortablePolygon.d.ts.map +1 -1
  163. package/lib/esm/geometry3d/SortablePolygon.js +48 -43
  164. package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
  165. package/lib/esm/polyface/PolyfaceBuilder.js +3 -3
  166. package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
  167. package/lib/esm/solid/Sphere.js +1 -1
  168. package/lib/esm/solid/Sphere.js.map +1 -1
  169. package/lib/esm/solid/SweepContour.d.ts +1 -1
  170. package/lib/esm/solid/SweepContour.js +1 -1
  171. package/lib/esm/solid/SweepContour.js.map +1 -1
  172. package/lib/esm/topology/Graph.d.ts +64 -14
  173. package/lib/esm/topology/Graph.d.ts.map +1 -1
  174. package/lib/esm/topology/Graph.js +149 -32
  175. package/lib/esm/topology/Graph.js.map +1 -1
  176. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +2 -2
  177. package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
  178. package/lib/esm/topology/HalfEdgeGraphSearch.js +2 -2
  179. package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
  180. package/lib/esm/topology/RegularizeFace.d.ts.map +1 -1
  181. package/lib/esm/topology/RegularizeFace.js +2 -1
  182. package/lib/esm/topology/RegularizeFace.js.map +1 -1
  183. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeCountChain.js","sourceRoot":"","sources":["../../../../src/curve/Query/StrokeCountChain.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6CAA0C;AAC1C,sEAA2D;AAG3D,wDAAiE;AACjE,kDAA+C;AAC/C,kCAA+B;AAC/B,kDAA+C;AAE/C,qDAAkD;AAElD,qBAAqB;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAsB,8BAA8B;IAClD;;;;;;OAMG;IACI,WAAW,CAAC,WAAmB,EAAE,eAAuB,EAAE,eAAwB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IAepH;;;OAGG;IACI,SAAS,CAAC,WAAmB,EAAE,eAAuB,EAAE,eAAwB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;CAEnH;AA7BD,wEA6BC;AACD;;;;GAIG;AACH,MAAa,kCAAmC,SAAQ,8BAA8B;IAC7E,KAAK,CAAiB;IAC7B;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,+BAAc,CAAC,wBAAwB,EAAE,CAAC;IACzD,CAAC;IACD,oDAAoD;IAC7C,SAAS,CAAC,IAAY;QAC3B,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;YACtB,oEAAoE;YACpE,OAAO,IAAI,CAAC;QACd,CAAC;QACD,0CAA0C;QAC1C,OAAO,KAAK,CAAC;IACf,CAAC;I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AAC,iCAAiC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;4BACpF,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;aAAM,IAAI,OAAO,YAAY,4BAAU,EAAE,CAAC;YACzC,IAAI,OAAO,YAAY,4BAAU,EAAE,CAAC;gBAClC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;gBACnC,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;gBACnC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;gBAC3B,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;oBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;wBAC3B,IAAI,CAAC,IAAI,CAAC,iCAAiC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;4BACpF,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA/ND,gDA+NC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../../Geometry\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Range1d } from \"../../geometry3d/Range\";\nimport { AnyCurve } from \"../CurveTypes\";\nimport { CurveChain, CurveCollection } from \"../CurveCollection\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop } from \"../Loop\";\nimport { ParityRegion } from \"../ParityRegion\";\nimport { StrokeOptions } from \"../StrokeOptions\";\nimport { StrokeCountMap } from \"./StrokeCountMap\";\n\n// cspell:word remapa\n/**\n * abstract methods for callbacks during sweeps of collections of StrokeCount Structures.\n * * A set of StrokeCountMaps are to be visited multiple times.\n * * The logic that controls the sweep is as below.\n * * The callback object controls the number of sweeps and can adapt its action to the respective sweeps.\n * * Note that a \"false\" from cb.startPass() terminates passes for this chainIndex and primitiveIndex, but all others exit the whole sequence.\n * * This logic occurs 2 or three levels deep\n * * outer level is \"chains\". Simple swept path or loops have only one outer; parity regions have one outer per loop of the parity region\n * * second level is primitive within chain.\n * * If the primitives in a set are \"single component\", second level is lowest.\n * * startSweep() and endSweep() calls are two parameters, with undefined componentIndex\n * * If the primitives in a set are multi-component, there is a third level looping through corresponding components.\n * `\n * if (!cb.startSweeps (chainIndex, primitiveIndex, componentIndex))\n * return false;\n * for (let pass = 0;cb.startPass (pass); pass++){\n * for (each map in working set)\n * if (!cb.visit (pass, map)) return false;\n * if (!cb.endPass ()) return false;\n * }\n * }\n * if (!cb.endSweeps (chainIndex, primitiveIndex, componentIndex)) return false;\n * return true;\n * `\n * @internal\n */\nexport abstract class StrokeCountMapMultipassVisitor {\n /**\n * called to announce the beginning of one or more sweeps through related StrokeCountMap's\n * @param chainIndex index of loop or path within the various contours.\n * @param primitiveIndex index of primitive within the loop or path.\n * @param componentIndex optional component index.\n * @returns the number of sweeps to perform.\n */\n public startSweeps(_chainIndex: number, _primitiveIndex: number, _componentIndex?: number): boolean { return true; }\n /**\n * announce the beginning of a sweep pass.\n * @param pass the index (0,1...) for this sweep pass.\n * @return true to execute this pass. false to break from the pass loop (next method called is endSweeps)\n */\n public abstract startPass(pass: number): boolean;\n public abstract visit(pass: number, map: StrokeCountMap): boolean;\n /**\n * announce the end of a pass\n * @param pass the index (0,1...) for this sweep pass.\n * @return true to continue the sweeps.\n */\n\n public abstract endPass(pass: number): boolean;\n /**\n * announce the end of handling for particular chainIndex and primitiveIndex;\n * @return true to continue outer loops.\n */\n public endSweeps(_chainIndex: number, _primitiveIndex: number, _componentIndex?: number): boolean { return true; }\n\n}\n/**\n * * pass 1: determine max numStroke\n * * pass 2: impose max numStroke\n * @internal\n */\nexport class StrokeCountMapVisitorApplyMaxCount extends StrokeCountMapMultipassVisitor {\n public myMap: StrokeCountMap;\n public constructor() {\n super();\n this.myMap = StrokeCountMap.createWithComponentIndex();\n }\n /** set up for a pass through corresponding maps. */\n public startPass(pass: number): boolean {\n if (pass === 0) {\n this.myMap.numStroke = 0;\n return true;\n } else if (pass === 1) {\n // nothing to change == numStroke will be applied to each primitive.\n return true;\n }\n // all other pass numbers are rejected ...\n return false;\n }\n /** visit one of the set of corresponding maps. */\n public visit(pass: number, map: StrokeCountMap): boolean {\n if (pass === 0) {\n if (map.numStroke > this.myMap.numStroke)\n this.myMap.numStroke = map.numStroke;\n return true;\n } else if (pass === 1) {\n // apply the max from prior pass\n map.numStroke = this.myMap.numStroke;\n return true;\n }\n // no other pass values should happen -- canceled by startPass.\n return false;\n }\n\n public endPass(_pass: number): boolean { return true; }\n}\n/**\n * * pass 1: determine max curveLength among maps presented.\n * * pass 2: set the a0 and a1 values to 0 and that max distance\n * @internal\n */\nexport class StrokeCountMapVisitorApplyMaxCurveLength extends StrokeCountMapMultipassVisitor {\n public maxCurveLength: number;\n public constructor() {\n super();\n this.maxCurveLength = 0.0;\n }\n /** set up for a pass through corresponding maps. */\n public startPass(pass: number): boolean {\n if (pass === 0) {\n this.maxCurveLength = 0;\n return true;\n } else if (pass === 1) {\n // nothing to change == numStroke will be applied to each primitive.\n return true;\n }\n // all other pass numbers are rejected ...\n return false;\n }\n /** visit one of the set of corresponding maps. */\n public visit(pass: number, map: StrokeCountMap): boolean {\n if (pass === 0) {\n this.maxCurveLength = Geometry.maxXY(map.curveLength, this.maxCurveLength);\n return true;\n } else if (pass === 1) {\n // apply the max from prior pass\n map.a0 = 0.0;\n map.a1 = this.maxCurveLength;\n return true;\n }\n // no other pass values should happen -- canceled by startPass.\n return false;\n }\n\n public endPass(_pass: number): boolean { return true; }\n}\n/**\n * class `StrokeCountChain` contains:\n * * `maps` = an array of `StrokeCountMap`\n * * `parent` = parent CurveCollection.\n *\n * An instance is normally created with either a `Path` or `Loop` as the parent.\n */\nexport class StrokeCountChain {\n public maps: StrokeCountMap[];\n public parent?: CurveCollection;\n /**\n * options are used (with different purposes) at two times:\n * * When the StrokeCountChain is created, the options affect the stroke counts. This is just creating markup, not actual strokes.\n * * When actual stroking happens, the options control creation of parameters and tangents.\n */\n public options?: StrokeOptions;\n\n private constructor(parent?: CurveCollection, options?: StrokeOptions) {\n this.parent = parent;\n this.maps = [];\n this.options = options;\n }\n public static createForCurveChain(chain: CurveChain, options?: StrokeOptions): StrokeCountChain {\n const result = new StrokeCountChain(chain, options);\n result.parent = chain;\n // A chain can only contain primitives !!!!\n for (const p of chain.children) {\n p.computeAndAttachRecursiveStrokeCounts(options);\n if (p.strokeData)\n result.maps.push(p.strokeData);\n }\n return result;\n }\n public getStrokes(): LineString3d {\n const ls = LineString3d.create();\n if (this.options) {\n if (this.options.needNormals || this.options.needParams) {\n ls.ensureEmptyFractions();\n ls.ensureEmptyDerivatives();\n ls.ensureEmptyUVParams();\n }\n }\n for (const m of this.maps) {\n if (m.primitive)\n m.primitive.addMappedStrokesToLineString3D(m, ls);\n }\n return ls;\n\n }\n /** internal form of */\n private static applySummed01LimitsWithinArray(maps: StrokeCountMap[], incomingSum: number): number {\n let movingSum = incomingSum;\n for (const m of maps) {\n m.a0 += movingSum;\n if (m.componentData) {\n m.a1 = this.applySummed01LimitsWithinArray(m.componentData, m.a0);\n } else {\n m.a1 += movingSum;\n }\n movingSum = m.a1;\n }\n return movingSum;\n }\n /**\n * walk the maps in the array.\n * * in maps with no component data\n * * increment map.a0 and map.a1 by the incoming distance a0\n * * in maps with component data:\n * * recurse through the component array.\n * * increment map.a0 by the incoming a0.\n * * returned a1 from the componentData array becomes a1\n * @returns upper value of a1 in final map.\n * @param maps\n * @param incomingSum lower value to add to a0 for first map.\n */\n public applySummed01Limits(incomingSum: number): number {\n return StrokeCountChain.applySummed01LimitsWithinArray(this.maps, incomingSum);\n }\n}\n\n/**\n * class `StrokeCountSection`\\\n * * contains an array of `StrokeCountChain`.\n * * Hence it is the internal node level of a (1-level-deep) tree of `StrokeCountChain`\n * @internal\n */\nexport class StrokeCountSection {\n public chains: StrokeCountChain[];\n public parent?: CurveCollection;\n private constructor(parent?: CurveCollection) { this.parent = parent; this.chains = []; }\n /**\n * construct array of arrays of `StrokeCountMap`s\n * @param parent\n */\n public static createForParityRegionOrChain(parent: CurveCollection, options?: StrokeOptions): StrokeCountSection {\n const result = new StrokeCountSection(parent);\n if (parent instanceof ParityRegion) {\n for (const child of parent.children) {\n const p = StrokeCountChain.createForCurveChain(child, options);\n result.chains.push(p);\n }\n } else if (parent instanceof CurveChain) {\n result.chains.push(StrokeCountChain.createForCurveChain(parent, options));\n }\n return result;\n }\n /** test if all sections have the same structure. */\n public static areSectionsCompatible(sections: StrokeCountSection[], enforceCounts: boolean): boolean {\n if (sections.length < 2)\n return true; // hm.. don't know if that is useful, but nothing to check here.\n const numChains = sections[0].chains.length;\n for (let i = 1; i < sections.length; i++) {\n // first level: must match number of paths or loops\n if (sections[i].chains.length !== numChains)\n return false;\n // second level: must have same number of primitives in each path or loop\n for (let j = 0; j < sections[0].chains.length; j++) {\n const numPrimitive = sections[0].chains[j].maps.length;\n if (sections[i].chains[j].maps.length !== numPrimitive)\n return false;\n for (let k = 0; k < numPrimitive; k++) {\n if (!sections[0].chains[j].maps[k].isCompatibleComponentStructure(sections[i].chains[j].maps[k], enforceCounts))\n return false;\n }\n }\n\n }\n return true;\n }\n\n /** Within each section, sweep accumulate curveLength field, recording entry and exit sum in each map.\n * * In expected use, (a0,a1) are (0,a) where a is the (previously computed) max length among corresponding maps up and down the section arrays.\n */\n public static remapa0a1WithinEachChain(sections: StrokeCountSection[]) {\n for (const section of sections) {\n for (const chain of section.chains) {\n chain.applySummed01Limits(0.0);\n }\n }\n }\n\n private static applyMultipassVisitorCallbackNoComponents(sections: StrokeCountSection[], chainIndex: number, primitiveIndex: number,\n componentIndex: number | undefined, callback: StrokeCountMapMultipassVisitor) {\n const numSection = sections.length;\n if (!callback.startSweeps(chainIndex, primitiveIndex, componentIndex)) return false;\n if (componentIndex === undefined) {\n // there are corresponding primitives directly at the section, chain, primitive index:\n for (let pass = 0; ; pass++) {\n if (!callback.startPass(pass))\n break;\n for (let sectionIndex = 0; sectionIndex < numSection; sectionIndex++)\n if (!callback.visit(pass, sections[sectionIndex].chains[chainIndex].maps[primitiveIndex]))\n return false;\n if (!callback.endPass(pass))\n return false;\n }\n } else {\n // there are corresponding primitives at the section, chain, primitive,componentIndex\n // there are corresponding primitives directly at the section, chain, primitive index:\n for (let pass = 0; ; pass++) {\n if (!callback.startPass(pass))\n break;\n for (let sectionIndex = 0; sectionIndex < numSection; sectionIndex++)\n if (!callback.visit(pass, sections[sectionIndex].chains[chainIndex].maps[primitiveIndex].componentData![componentIndex]))\n return false;\n if (!callback.endPass(pass))\n return false;\n }\n\n }\n if (!callback.endSweeps(chainIndex, primitiveIndex, componentIndex)) return false;\n return true;\n }\n\n /**\n * Walk through the sections, emitting callbacks delimiting groups of corresponding primitives.\n * @param sections array of sections (possibly a single path or loop at each section, or possibly a set of parity loops.)\n * @param callback object to be notified during the traversal\n */\n public static runMultiPassVisitorAtCorrespondingPrimitives(sections: StrokeCountSection[], callback: StrokeCountMapMultipassVisitor): boolean {\n const numChainPerSection = sections[0].chains.length;\n for (let chainIndex = 0; chainIndex < numChainPerSection; chainIndex++) {\n const numPrimitive = sections[0].chains[chainIndex].maps.length;\n for (let primitiveIndex = 0; primitiveIndex < numPrimitive; primitiveIndex++) {\n if (sections[0].chains[chainIndex].maps[primitiveIndex].componentData) {\n const numComponent = sections[0].chains[chainIndex].maps[primitiveIndex].componentData!.length;\n for (let i = 0; i < numComponent; i++)\n if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, i, callback))\n return false;\n\n } else {\n if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, undefined, callback))\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * * Confirm that all sections in the array have the same structure.\n * * Within each corresponding set of entries, apply the max count to all.\n * @param sections array of per-section stroke count entries\n */\n public static enforceStrokeCountCompatibility(sections: StrokeCountSection[]): boolean {\n\n if (sections.length < 2)\n return true;\n if (!StrokeCountSection.areSectionsCompatible(sections, false))\n return false;\n const visitor = new StrokeCountMapVisitorApplyMaxCount();\n this.runMultiPassVisitorAtCorrespondingPrimitives(sections, visitor);\n return true;\n\n }\n /**\n * * Confirm that all sections in the array have the same structure.\n * * Within each corresponding set of entries up and down the sections, set curveLength as the maximum of the respective curve lengths.\n * * Along each section, sum curveLengths (which were just reset) to get consistent along-chain parameters\n * @param sections array of per-section stroke count entries\n */\n public static enforceCompatibleDistanceSums(sections: StrokeCountSection[]): boolean {\n\n if (sections.length < 2)\n return true;\n if (!StrokeCountSection.areSectionsCompatible(sections, false))\n return false;\n const visitor = new StrokeCountMapVisitorApplyMaxCurveLength();\n this.runMultiPassVisitorAtCorrespondingPrimitives(sections, visitor);\n this.remapa0a1WithinEachChain(sections);\n return true;\n\n }\n\n /**\n * Return stroked form of the section.\n */\n public getStrokes(): AnyCurve {\n if (this.chains.length === 1) {\n return this.chains[0].getStrokes();\n } else {\n const region = ParityRegion.create();\n for (const c of this.chains) {\n const strokes = c.getStrokes();\n if (strokes instanceof LineString3d)\n region.tryAddChild(Loop.create(strokes));\n }\n return region;\n }\n }\n /**\n * Given two compatible stroke sets (as returned by getStrokes) extend a range\n * with the distances between corresponding points.\n * * Each set of strokes may be:\n * * linestring\n * * ParityRegion\n * * CurveChain (Loop or Path)\n * @param strokeA first set of strokes\n * @param strokeB second set of strokes\n * @param rangeToExtend caller-allocated range to be extended.\n * @returns true if structures are compatible.\n */\n public static extendDistanceRangeBetweenStrokes(strokeA: AnyCurve, strokeB: AnyCurve, rangeToExtend: Range1d): boolean {\n if (strokeA instanceof LineString3d) {\n if (strokeB instanceof LineString3d) {\n if (strokeA.numPoints() === strokeB.numPoints()) {\n const n = strokeA.numPoints();\n const pointA = Point3d.create();\n const pointB = Point3d.create();\n const allPointA = strokeA.packedPoints;\n const allPointB = strokeB.packedPoints;\n\n for (let i = 0; i < n; i++) {\n allPointA.getPoint3dAtCheckedPointIndex(i, pointA);\n allPointB.getPoint3dAtCheckedPointIndex(i, pointB);\n rangeToExtend.extendX(pointA.distance(pointB));\n }\n return true;\n }\n }\n } else if (strokeA instanceof ParityRegion) {\n if (strokeB instanceof ParityRegion) {\n const childrenA = strokeA.children;\n const childrenB = strokeB.children;\n const n = childrenA.length;\n if (n === childrenB.length) {\n for (let i = 0; i < n; i++) {\n if (!this.extendDistanceRangeBetweenStrokes(childrenA[i], childrenB[i], rangeToExtend))\n return false;\n }\n return true;\n }\n }\n } else if (strokeA instanceof CurveChain) {\n if (strokeB instanceof CurveChain) {\n const childrenA = strokeA.children;\n const childrenB = strokeB.children;\n const n = childrenA.length;\n if (n === childrenB.length) {\n for (let i = 0; i < n; i++) {\n if (!this.extendDistanceRangeBetweenStrokes(childrenA[i], childrenB[i], rangeToExtend))\n return false;\n }\n return true;\n }\n }\n }\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"StrokeCountChain.js","sourceRoot":"","sources":["../../../../src/curve/Query/StrokeCountChain.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,6CAA0C;AAC1C,sEAA2D;AAE3D,wDAAiE;AAEjE,kDAA+C;AAC/C,kCAA+B;AAC/B,kDAA+C;AAE/C,gDAA6C;AAC7C,qDAAkD;AAElD,qBAAqB;AACrB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAsB,8BAA8B;IAClD;;;;;;OAMG;IACI,WAAW,CAAC,WAAmB,EAAE,eAAuB,EAAE,eAAwB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;I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C,QAAQ,CAAC;gBACnC,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC;gBAC3B,IAAI,CAAC,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;oBAC3B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;wBAC3B,IAAI,CAAC,IAAI,CAAC,iCAAiC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC;4BACpF,OAAO,KAAK,CAAC;oBACjB,CAAC;oBACD,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AArOD,gDAqOC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Curve\n */\n\nimport { Geometry } from \"../../Geometry\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { Range1d } from \"../../geometry3d/Range\";\nimport { CurveChain, CurveCollection } from \"../CurveCollection\";\nimport { AnyCurve } from \"../CurveTypes\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop } from \"../Loop\";\nimport { ParityRegion } from \"../ParityRegion\";\nimport { StrokeOptions } from \"../StrokeOptions\";\nimport { UnionRegion } from \"../UnionRegion\";\nimport { StrokeCountMap } from \"./StrokeCountMap\";\n\n// cspell:word remapa\n/**\n * abstract methods for callbacks during sweeps of collections of StrokeCount Structures.\n * * A set of StrokeCountMaps are to be visited multiple times.\n * * The logic that controls the sweep is as below.\n * * The callback object controls the number of sweeps and can adapt its action to the respective sweeps.\n * * Note that a \"false\" from cb.startPass() terminates passes for this chainIndex and primitiveIndex, but all others exit the whole sequence.\n * * This logic occurs 2 or three levels deep\n * * outer level is \"chains\". Simple swept path or loops have only one outer; parity regions have one outer per loop of the parity region\n * * second level is primitive within chain.\n * * If the primitives in a set are \"single component\", second level is lowest.\n * * startSweep() and endSweep() calls are two parameters, with undefined componentIndex\n * * If the primitives in a set are multi-component, there is a third level looping through corresponding components.\n * `\n * if (!cb.startSweeps (chainIndex, primitiveIndex, componentIndex))\n * return false;\n * for (let pass = 0;cb.startPass (pass); pass++){\n * for (each map in working set)\n * if (!cb.visit (pass, map)) return false;\n * if (!cb.endPass ()) return false;\n * }\n * }\n * if (!cb.endSweeps (chainIndex, primitiveIndex, componentIndex)) return false;\n * return true;\n * `\n * @internal\n */\nexport abstract class StrokeCountMapMultipassVisitor {\n /**\n * called to announce the beginning of one or more sweeps through related StrokeCountMap's\n * @param chainIndex index of loop or path within the various contours.\n * @param primitiveIndex index of primitive within the loop or path.\n * @param componentIndex optional component index.\n * @returns the number of sweeps to perform.\n */\n public startSweeps(_chainIndex: number, _primitiveIndex: number, _componentIndex?: number): boolean { return true; }\n /**\n * announce the beginning of a sweep pass.\n * @param pass the index (0,1...) for this sweep pass.\n * @return true to execute this pass. false to break from the pass loop (next method called is endSweeps)\n */\n public abstract startPass(pass: number): boolean;\n public abstract visit(pass: number, map: StrokeCountMap): boolean;\n /**\n * announce the end of a pass\n * @param pass the index (0,1...) for this sweep pass.\n * @return true to continue the sweeps.\n */\n\n public abstract endPass(pass: number): boolean;\n /**\n * announce the end of handling for particular chainIndex and primitiveIndex;\n * @return true to continue outer loops.\n */\n public endSweeps(_chainIndex: number, _primitiveIndex: number, _componentIndex?: number): boolean { return true; }\n\n}\n/**\n * * pass 1: determine max numStroke\n * * pass 2: impose max numStroke\n * @internal\n */\nexport class StrokeCountMapVisitorApplyMaxCount extends StrokeCountMapMultipassVisitor {\n public myMap: StrokeCountMap;\n public constructor() {\n super();\n this.myMap = StrokeCountMap.createWithComponentIndex();\n }\n /** set up for a pass through corresponding maps. */\n public startPass(pass: number): boolean {\n if (pass === 0) {\n this.myMap.numStroke = 0;\n return true;\n } else if (pass === 1) {\n // nothing to change == numStroke will be applied to each primitive.\n return true;\n }\n // all other pass numbers are rejected ...\n return false;\n }\n /** visit one of the set of corresponding maps. */\n public visit(pass: number, map: StrokeCountMap): boolean {\n if (pass === 0) {\n if (map.numStroke > this.myMap.numStroke)\n this.myMap.numStroke = map.numStroke;\n return true;\n } else if (pass === 1) {\n // apply the max from prior pass\n map.numStroke = this.myMap.numStroke;\n return true;\n }\n // no other pass values should happen -- canceled by startPass.\n return false;\n }\n\n public endPass(_pass: number): boolean { return true; }\n}\n/**\n * * pass 1: determine max curveLength among maps presented.\n * * pass 2: set the a0 and a1 values to 0 and that max distance\n * @internal\n */\nexport class StrokeCountMapVisitorApplyMaxCurveLength extends StrokeCountMapMultipassVisitor {\n public maxCurveLength: number;\n public constructor() {\n super();\n this.maxCurveLength = 0.0;\n }\n /** set up for a pass through corresponding maps. */\n public startPass(pass: number): boolean {\n if (pass === 0) {\n this.maxCurveLength = 0;\n return true;\n } else if (pass === 1) {\n // nothing to change == numStroke will be applied to each primitive.\n return true;\n }\n // all other pass numbers are rejected ...\n return false;\n }\n /** visit one of the set of corresponding maps. */\n public visit(pass: number, map: StrokeCountMap): boolean {\n if (pass === 0) {\n this.maxCurveLength = Geometry.maxXY(map.curveLength, this.maxCurveLength);\n return true;\n } else if (pass === 1) {\n // apply the max from prior pass\n map.a0 = 0.0;\n map.a1 = this.maxCurveLength;\n return true;\n }\n // no other pass values should happen -- canceled by startPass.\n return false;\n }\n\n public endPass(_pass: number): boolean { return true; }\n}\n/**\n * class `StrokeCountChain` contains:\n * * `maps` = an array of `StrokeCountMap`\n * * `parent` = parent CurveCollection.\n *\n * An instance is normally created with either a `Path` or `Loop` as the parent.\n * @internal\n */\nexport class StrokeCountChain {\n public maps: StrokeCountMap[];\n public parent?: CurveCollection;\n /**\n * options are used (with different purposes) at two times:\n * * When the StrokeCountChain is created, the options affect the stroke counts. This is just creating markup, not actual strokes.\n * * When actual stroking happens, the options control creation of parameters and tangents.\n */\n public options?: StrokeOptions;\n\n private constructor(parent?: CurveCollection, options?: StrokeOptions) {\n this.parent = parent;\n this.maps = [];\n this.options = options;\n }\n public static create(chain: CurveChain, options?: StrokeOptions): StrokeCountChain {\n const result = new StrokeCountChain(chain, options);\n result.parent = chain;\n // A chain can only contain primitives !!!!\n for (const p of chain.children) {\n p.computeAndAttachRecursiveStrokeCounts(options);\n if (p.strokeData)\n result.maps.push(p.strokeData);\n }\n return result;\n }\n public getStrokes(): LineString3d {\n const ls = LineString3d.create();\n if (this.options) {\n if (this.options.needNormals || this.options.needParams) {\n ls.ensureEmptyFractions();\n ls.ensureEmptyDerivatives();\n ls.ensureEmptyUVParams();\n }\n }\n for (const m of this.maps) {\n if (m.primitive)\n m.primitive.addMappedStrokesToLineString3D(m, ls);\n }\n return ls;\n\n }\n /** internal form of */\n private static applySummed01LimitsWithinArray(maps: StrokeCountMap[], incomingSum: number): number {\n let movingSum = incomingSum;\n for (const m of maps) {\n m.a0 += movingSum;\n if (m.componentData) {\n m.a1 = this.applySummed01LimitsWithinArray(m.componentData, m.a0);\n } else {\n m.a1 += movingSum;\n }\n movingSum = m.a1;\n }\n return movingSum;\n }\n /**\n * walk the maps in the array.\n * * in maps with no component data\n * * increment map.a0 and map.a1 by the incoming distance a0\n * * in maps with component data:\n * * recurse through the component array.\n * * increment map.a0 by the incoming a0.\n * * returned a1 from the componentData array becomes a1\n * @returns upper value of a1 in final map.\n * @param maps\n * @param incomingSum lower value to add to a0 for first map.\n */\n public applySummed01Limits(incomingSum: number): number {\n return StrokeCountChain.applySummed01LimitsWithinArray(this.maps, incomingSum);\n }\n}\n\n/**\n * class `StrokeCountSection`\\\n * * contains an array of `StrokeCountChain`.\n * * Hence it is the internal node level of a (1-level-deep) tree of `StrokeCountChain`\n * @internal\n */\nexport class StrokeCountSection {\n public chains: StrokeCountChain[];\n public parent?: CurveCollection;\n private constructor(parent?: CurveCollection) { this.parent = parent; this.chains = []; }\n /**\n * construct array of arrays of `StrokeCountMap`s\n * @param parent\n */\n public static create(parent: CurveCollection, options?: StrokeOptions): StrokeCountSection {\n const result = new StrokeCountSection(parent);\n const appendCurveChain = (chain: CurveChain) => result.chains.push(StrokeCountChain.create(chain, options));\n const appendParityRegion = (region: ParityRegion) => { for (const child of region.children) appendCurveChain(child); }\n if (parent instanceof UnionRegion) {\n for (const child of parent.children) {\n if (child instanceof ParityRegion)\n appendParityRegion(child);\n else\n appendCurveChain(child);\n }\n } else if (parent instanceof ParityRegion) {\n appendParityRegion(parent);\n } else if (parent instanceof CurveChain) {\n appendCurveChain(parent);\n }\n return result;\n }\n /** test if all sections have the same structure. */\n public static areSectionsCompatible(sections: StrokeCountSection[], enforceCounts: boolean): boolean {\n if (sections.length < 2)\n return true; // hm.. don't know if that is useful, but nothing to check here.\n const numChains = sections[0].chains.length;\n for (let i = 1; i < sections.length; i++) {\n // first level: must match number of paths or loops\n if (sections[i].chains.length !== numChains)\n return false;\n // second level: must have same number of primitives in each path or loop\n for (let j = 0; j < sections[0].chains.length; j++) {\n const numPrimitive = sections[0].chains[j].maps.length;\n if (sections[i].chains[j].maps.length !== numPrimitive)\n return false;\n for (let k = 0; k < numPrimitive; k++) {\n if (!sections[0].chains[j].maps[k].isCompatibleComponentStructure(sections[i].chains[j].maps[k], enforceCounts))\n return false;\n }\n }\n\n }\n return true;\n }\n\n /** Within each section, sweep accumulate curveLength field, recording entry and exit sum in each map.\n * * In expected use, (a0,a1) are (0,a) where a is the (previously computed) max length among corresponding maps up and down the section arrays.\n */\n public static remapa0a1WithinEachChain(sections: StrokeCountSection[]) {\n for (const section of sections) {\n for (const chain of section.chains) {\n chain.applySummed01Limits(0.0);\n }\n }\n }\n\n private static applyMultipassVisitorCallbackNoComponents(sections: StrokeCountSection[], chainIndex: number, primitiveIndex: number,\n componentIndex: number | undefined, callback: StrokeCountMapMultipassVisitor) {\n const numSection = sections.length;\n if (!callback.startSweeps(chainIndex, primitiveIndex, componentIndex)) return false;\n if (componentIndex === undefined) {\n // there are corresponding primitives directly at the section, chain, primitive index:\n for (let pass = 0; ; pass++) {\n if (!callback.startPass(pass))\n break;\n for (let sectionIndex = 0; sectionIndex < numSection; sectionIndex++)\n if (!callback.visit(pass, sections[sectionIndex].chains[chainIndex].maps[primitiveIndex]))\n return false;\n if (!callback.endPass(pass))\n return false;\n }\n } else {\n // there are corresponding primitives at the section, chain, primitive,componentIndex\n // there are corresponding primitives directly at the section, chain, primitive index:\n for (let pass = 0; ; pass++) {\n if (!callback.startPass(pass))\n break;\n for (let sectionIndex = 0; sectionIndex < numSection; sectionIndex++)\n if (!callback.visit(pass, sections[sectionIndex].chains[chainIndex].maps[primitiveIndex].componentData![componentIndex]))\n return false;\n if (!callback.endPass(pass))\n return false;\n }\n\n }\n if (!callback.endSweeps(chainIndex, primitiveIndex, componentIndex)) return false;\n return true;\n }\n\n /**\n * Walk through the sections, emitting callbacks delimiting groups of corresponding primitives.\n * @param sections array of sections (possibly a single path or loop at each section, or possibly a set of parity loops.)\n * @param callback object to be notified during the traversal\n */\n public static runMultiPassVisitorAtCorrespondingPrimitives(sections: StrokeCountSection[], callback: StrokeCountMapMultipassVisitor): boolean {\n const numChainPerSection = sections[0].chains.length;\n for (let chainIndex = 0; chainIndex < numChainPerSection; chainIndex++) {\n const numPrimitive = sections[0].chains[chainIndex].maps.length;\n for (let primitiveIndex = 0; primitiveIndex < numPrimitive; primitiveIndex++) {\n const numComponent = sections[0].chains[chainIndex].maps[primitiveIndex].componentData?.length ?? 0;\n if (numComponent > 0) {\n for (let i = 0; i < numComponent; i++) {\n if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, i, callback))\n return false;\n }\n } else {\n if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, undefined, callback))\n return false;\n }\n }\n }\n return true;\n }\n\n /**\n * * Confirm that all sections in the array have the same structure.\n * * Within each corresponding set of entries, apply the max count to all.\n * @param sections array of per-section stroke count entries\n */\n public static enforceStrokeCountCompatibility(sections: StrokeCountSection[]): boolean {\n\n if (sections.length < 2)\n return true;\n if (!StrokeCountSection.areSectionsCompatible(sections, false))\n return false;\n const visitor = new StrokeCountMapVisitorApplyMaxCount();\n this.runMultiPassVisitorAtCorrespondingPrimitives(sections, visitor);\n return true;\n\n }\n /**\n * * Confirm that all sections in the array have the same structure.\n * * Within each corresponding set of entries up and down the sections, set curveLength as the maximum of the respective curve lengths.\n * * Along each section, sum curveLengths (which were just reset) to get consistent along-chain parameters\n * @param sections array of per-section stroke count entries\n */\n public static enforceCompatibleDistanceSums(sections: StrokeCountSection[]): boolean {\n\n if (sections.length < 2)\n return true;\n if (!StrokeCountSection.areSectionsCompatible(sections, false))\n return false;\n const visitor = new StrokeCountMapVisitorApplyMaxCurveLength();\n this.runMultiPassVisitorAtCorrespondingPrimitives(sections, visitor);\n this.remapa0a1WithinEachChain(sections);\n return true;\n\n }\n\n /**\n * Return stroked form of the section.\n */\n public getStrokes(): AnyCurve {\n if (this.chains.length === 1) {\n return this.chains[0].getStrokes();\n } else {\n const region = ParityRegion.create();\n for (const c of this.chains) {\n const strokes = c.getStrokes();\n if (strokes instanceof LineString3d)\n region.tryAddChild(Loop.create(strokes));\n }\n return region;\n }\n }\n /**\n * Given two compatible stroke sets (as returned by getStrokes) extend a range\n * with the distances between corresponding points.\n * * Each set of strokes may be:\n * * linestring\n * * ParityRegion\n * * CurveChain (Loop or Path)\n * @param strokeA first set of strokes\n * @param strokeB second set of strokes\n * @param rangeToExtend caller-allocated range to be extended.\n * @returns true if structures are compatible.\n */\n public static extendDistanceRangeBetweenStrokes(strokeA: AnyCurve, strokeB: AnyCurve, rangeToExtend: Range1d): boolean {\n if (strokeA instanceof LineString3d) {\n if (strokeB instanceof LineString3d) {\n if (strokeA.numPoints() === strokeB.numPoints()) {\n const n = strokeA.numPoints();\n const pointA = Point3d.create();\n const pointB = Point3d.create();\n const allPointA = strokeA.packedPoints;\n const allPointB = strokeB.packedPoints;\n\n for (let i = 0; i < n; i++) {\n allPointA.getPoint3dAtCheckedPointIndex(i, pointA);\n allPointB.getPoint3dAtCheckedPointIndex(i, pointB);\n rangeToExtend.extendX(pointA.distance(pointB));\n }\n return true;\n }\n }\n } else if (strokeA instanceof ParityRegion) {\n if (strokeB instanceof ParityRegion) {\n const childrenA = strokeA.children;\n const childrenB = strokeB.children;\n const n = childrenA.length;\n if (n === childrenB.length) {\n for (let i = 0; i < n; i++) {\n if (!this.extendDistanceRangeBetweenStrokes(childrenA[i], childrenB[i], rangeToExtend))\n return false;\n }\n return true;\n }\n }\n } else if (strokeA instanceof CurveChain) {\n if (strokeB instanceof CurveChain) {\n const childrenA = strokeA.children;\n const childrenB = strokeB.children;\n const n = childrenA.length;\n if (n === childrenB.length) {\n for (let i = 0; i < n; i++) {\n if (!this.extendDistanceRangeBetweenStrokes(childrenA[i], childrenB[i], rangeToExtend))\n return false;\n }\n return true;\n }\n }\n }\n return false;\n }\n}\n"]}
@@ -31,7 +31,7 @@ export declare class RegionMomentsXY extends NullGeometryHandler {
31
31
  handleLineString3d(ls: LineString3d): void;
32
32
  /** Accumulate integrals over the (triangular) area from the origin to this line segment. */
33
33
  handleLineSegment3d(segment: LineSegment3d): void;
34
- /** Accumulate integrals from origin to all primitives in the chain. */
34
+ /** Accumulate integrals from origin to all primitives in the loop. */
35
35
  handleLoop(loop: Loop): MomentData | undefined;
36
36
  private handleAnyRegion;
37
37
  /** Accumulate integrals from origin to the components of the parity region. */
@@ -1 +1 @@
1
- {"version":3,"file":"RegionMomentsXY.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":"AAKA;;GAEG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,KAA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AU,GAAG,SAAS;IAQ9D,OAAO,CAAC,eAAe;IAmBvB,+EAA+E;IAC/D,kBAAkB,CAAC,MAAM,EAAE,YAAY,GAAG,UAAU,GAAG,SAAS;IAGhF,8EAA8E;IAC9D,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS;IAI9E,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,OAAO,CAAC,gBAAgB;IASxB;;;OAGG;IACI,oBAAoB,CAAC,EAAE,EAAE,cAAc,GAAG,IAAI;IAMrD,yEAAyE;IACzD,oBAAoB,CAAC,CAAC,EAAE,cAAc,GAAG,IAAI;IAG7D,0EAA0E;IAC1D,qBAAqB,CAAC,CAAC,EAAE,eAAe,GAAG,IAAI;IAG/D,0EAA0E;IAC1D,sBAAsB,CAAC,CAAC,EAAE,kBAAkB,GAAG,IAAI;CAGpE"}
@@ -11,6 +11,7 @@ const Point3dVector3d_1 = require("../geometry3d/Point3dVector3d");
11
11
  const MomentData_1 = require("../geometry4d/MomentData");
12
12
  const LineString3d_1 = require("./LineString3d");
13
13
  const Loop_1 = require("./Loop");
14
+ const ParityRegion_1 = require("./ParityRegion");
14
15
  const RegionOps_1 = require("./RegionOps");
15
16
  const StrokeOptions_1 = require("./StrokeOptions");
16
17
  /**
@@ -68,7 +69,7 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
68
69
  segment.endPoint(this._point1);
69
70
  momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);
70
71
  }
71
- /** Accumulate integrals from origin to all primitives in the chain. */
72
+ /** Accumulate integrals from origin to all primitives in the loop. */
72
73
  handleLoop(loop) {
73
74
  const momentData = this._activeMomentData = MomentData_1.MomentData.create();
74
75
  momentData.needOrigin = false;
@@ -78,7 +79,7 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
78
79
  return momentData;
79
80
  }
80
81
  handleAnyRegion(region) {
81
- // guarantee there is no overlapping children
82
+ // guarantee there are no overlapping children and parity loops have been properly oriented
82
83
  const merged = RegionOps_1.RegionOps.regionBooleanXY(region, undefined, RegionOps_1.RegionBinaryOpType.Union);
83
84
  if (!merged)
84
85
  return undefined;
@@ -88,7 +89,9 @@ class RegionMomentsXY extends GeometryHandler_1.NullGeometryHandler {
88
89
  for (const child of merged.children) {
89
90
  const childMoments = child.dispatchToGeometryHandler(this);
90
91
  if (childMoments) {
91
- const sign0 = childMoments.signFactor(1.0);
92
+ // parity region hole sums subtract; all other regions add
93
+ const scale = (merged instanceof ParityRegion_1.ParityRegion && childMoments.quantitySum < 0) ? -1.0 : 1.0;
94
+ const sign0 = childMoments.signFactor(scale);
92
95
  summedMoments.accumulateProducts(childMoments, sign0);
93
96
  }
94
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAU/F,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAKtD,iDAA8C;AAC9C,iCAA8B;AAE9B,2CAA4D;AAE5D,mDAAgD;AAGhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACa,WAAW,CAAC,GAAU;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAkB,CAAC;QAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;QACxC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/B,IAAI,EAAE,GAAG,IAAI,CA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O,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,oBAAoB,CAAC,EAAkB;QAC5C,MAAM,OAAO,GAAG,2BAAY,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,yEAAyE;IACzD,oBAAoB,CAAC,CAAiB;QACpD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAkB;QACtD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB;QAC1D,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACF;AAxHD,0CAwHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { AnyRegion } from \"./CurveTypes\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { RegionBinaryOpType, RegionOps } from \"./RegionOps\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /**\n * Accumulate (independent) integrations over:\n * * The area between the arc and the chord connecting its endpoints.\n * * The triangle with vertices: origin, arc start, arc end.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(\n productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV,\n );\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment. */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the chain. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n private handleAnyRegion(region: AnyRegion): MomentData | undefined {\n // guarantee there is no overlapping children\n const merged = RegionOps.regionBooleanXY(region, undefined, RegionBinaryOpType.Union);\n if (!merged)\n return undefined;\n if (merged instanceof Loop)\n return this.handleLoop(merged);\n const summedMoments = MomentData.create();\n for (const child of merged.children) {\n const childMoments = child.dispatchToGeometryHandler(this);\n if (childMoments) {\n const sign0 = childMoments.signFactor(1.0);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n /** Accumulate integrals from origin to the components of the parity region. */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n /** Accumulate integrals from origin to the components of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n\n private _strokeOptions?: StrokeOptions; // TODO: expose to callers in RegionOps\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /**\n * Handle a single curve primitive (not loop).\n * * Stroke the curve and accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive): void {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** Handle strongly typed BSplineCurve3d as generic curve primitive. */\n public override handleBSplineCurve3d(g: BSplineCurve3d): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed TransitionSpiral as generic curve primitive. */\n public override handleTransitionSpiral(g: TransitionSpiral3d): void {\n this.handleCurvePrimitive(g);\n }\n}\n"]}
1
+ {"version":3,"file":"RegionMomentsXY.js","sourceRoot":"","sources":["../../../src/curve/RegionMomentsXY.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAU/F,+CAA4C;AAC5C,mEAAoE;AACpE,mEAAwD;AACxD,yDAAsD;AAKtD,iDAA8C;AAC9C,iCAA8B;AAC9B,iDAA8C;AAC9C,2CAA4D;AAE5D,mDAAgD;AAGhD;;;GAGG;AACH,MAAa,eAAgB,SAAQ,qCAAmB;IAC9C,iBAAiB,CAAc;IAC/B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IAC3B,OAAO,GAAG,yBAAO,CAAC,MAAM,EAAE,CAAC;IACnC;;;;OAIG;IACa,WAAW,CAAC,GAAU;QACpC,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAkB,CAAC;QAC3C,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC;QAC5C,MAAM,YAAY,GAAG,YAAY,GAAG,GAAG,CAAC;QACxC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAC/B,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAChC,IAAI,aAAK,CAAC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AAQ,GAAG,aAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;QAC5C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD;;;OAGG;IACI,oBAAoB,CAAC,EAAkB;QAC5C,MAAM,OAAO,GAAG,2BAAY,CAAC,MAAM,EAAE,CAAC;QACtC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACxC,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnC,CAAC;IACD,yEAAyE;IACzD,oBAAoB,CAAC,CAAiB;QACpD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,qBAAqB,CAAC,CAAkB;QACtD,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,0EAA0E;IAC1D,sBAAsB,CAAC,CAAqB;QAC1D,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAC/B,CAAC;CACF;AA1HD,0CA0HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\n/** @packageDocumentation\n * @module Curve\n */\n\n// import { Geometry, Angle, AngleSweep } from \"../Geometry\";\n\nimport { BSplineCurve3d } from \"../bspline/BSplineCurve\";\nimport { BSplineCurve3dH } from \"../bspline/BSplineCurve3dH\";\nimport { Angle } from \"../geometry3d/Angle\";\nimport { NullGeometryHandler } from \"../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\nimport { MomentData } from \"../geometry4d/MomentData\";\nimport { Arc3d } from \"./Arc3d\";\nimport { CurvePrimitive } from \"./CurvePrimitive\";\nimport { AnyRegion } from \"./CurveTypes\";\nimport { LineSegment3d } from \"./LineSegment3d\";\nimport { LineString3d } from \"./LineString3d\";\nimport { Loop } from \"./Loop\";\nimport { ParityRegion } from \"./ParityRegion\";\nimport { RegionBinaryOpType, RegionOps } from \"./RegionOps\";\nimport { TransitionSpiral3d } from \"./spiral/TransitionSpiral3d\";\nimport { StrokeOptions } from \"./StrokeOptions\";\nimport { UnionRegion } from \"./UnionRegion\";\n\n/**\n * Implementation class for computing XY area moments.\n * @internal\n */\nexport class RegionMomentsXY extends NullGeometryHandler {\n private _activeMomentData?: MomentData;\n private _point0 = Point3d.create();\n private _point1 = Point3d.create();\n /**\n * Accumulate (independent) integrations over:\n * * The area between the arc and the chord connecting its endpoints.\n * * The triangle with vertices: origin, arc start, arc end.\n */\n public override handleArc3d(arc: Arc3d): void {\n const momentData = this._activeMomentData!;\n const sweepRadians = arc.sweep.sweepRadians;\n const alphaRadians = sweepRadians * 0.5;\n let s = Math.sin(alphaRadians);\n let c = Math.cos(alphaRadians);\n let s1 = Math.sin(sweepRadians);\n if (Angle.isFullCircleRadians(sweepRadians)) {\n s = 0.0;\n c = -1.0;\n s1 = 0.0;\n }\n const q = 2 * s * s * s * c / (alphaRadians - s * c);\n const s3 = s * s * s;\n const s6 = s3 * s3;\n const area = 0.5 * (sweepRadians - s1);\n const inertiaXX = 0.25 * area * (1.0 - q / 3.0);\n const inertiaYY1 = 0.25 * area * (1.0 + q);\n const inertiaYY = inertiaYY1 - 4.0 * s6 / (9.0 * area);\n const productXX = inertiaYY;\n const productYY = inertiaXX;\n const centerToCentroid = 4.0 * s * s * s / (3.0 * (sweepRadians - s1));\n const midRadians = arc.sweep.fractionToRadians(0.5);\n const centralPlane = arc.radiansToRotatedBasis(midRadians);\n const centroid = centralPlane.origin.plusScaled(centralPlane.vectorU, centerToCentroid);\n momentData.accumulateXYProductsInCentroidalFrame(\n productXX, 0.0, productYY, area, centroid, centralPlane.vectorU, centralPlane.vectorV,\n );\n const pointB = arc.fractionToPoint(0.0);\n const pointC = arc.fractionToPoint(1.0);\n momentData.accumulateTriangleMomentsXY(undefined, pointB, pointC);\n }\n /** Accumulate integrals over the (triangular) areas from the origin to each line segment. */\n public override handleLineString3d(ls: LineString3d): void {\n const momentData = this._activeMomentData!;\n momentData.accumulateTriangleToLineStringMomentsXY(undefined, ls.packedPoints);\n }\n /** Accumulate integrals over the (triangular) area from the origin to this line segment. */\n public override handleLineSegment3d(segment: LineSegment3d): void {\n const momentData = this._activeMomentData!;\n segment.startPoint(this._point0);\n segment.endPoint(this._point1);\n momentData.accumulateTriangleMomentsXY(undefined, this._point0, this._point1);\n }\n /** Accumulate integrals from origin to all primitives in the loop. */\n public override handleLoop(loop: Loop): MomentData | undefined {\n const momentData = this._activeMomentData = MomentData.create();\n momentData.needOrigin = false;\n for (const child of loop.children)\n child.dispatchToGeometryHandler(this);\n this._activeMomentData = undefined;\n return momentData;\n }\n private handleAnyRegion(region: AnyRegion): MomentData | undefined {\n // guarantee there are no overlapping children and parity loops have been properly oriented\n const merged = RegionOps.regionBooleanXY(region, undefined, RegionBinaryOpType.Union);\n if (!merged)\n return undefined;\n if (merged instanceof Loop)\n return this.handleLoop(merged);\n const summedMoments = MomentData.create();\n for (const child of merged.children) {\n const childMoments = child.dispatchToGeometryHandler(this) as MomentData | undefined;\n if (childMoments) {\n // parity region hole sums subtract; all other regions add\n const scale = (merged instanceof ParityRegion && childMoments.quantitySum < 0) ? -1.0 : 1.0;\n const sign0 = childMoments.signFactor(scale);\n summedMoments.accumulateProducts(childMoments, sign0);\n }\n }\n return summedMoments;\n }\n /** Accumulate integrals from origin to the components of the parity region. */\n public override handleParityRegion(region: ParityRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n /** Accumulate integrals from origin to the components of the union region. */\n public override handleUnionRegion(region: UnionRegion): MomentData | undefined {\n return this.handleAnyRegion(region);\n }\n\n private _strokeOptions?: StrokeOptions; // TODO: expose to callers in RegionOps\n private getStrokeOptions(): StrokeOptions {\n if (this._strokeOptions)\n return this._strokeOptions;\n const options = StrokeOptions.createForCurves();\n // this is unusually fine for stroking, but appropriate for sum.\n options.angleTol = Angle.createDegrees(5.0);\n this._strokeOptions = options;\n return options;\n }\n /**\n * Handle a single curve primitive (not loop).\n * * Stroke the curve and accumulate stroke array.\n */\n public handleCurvePrimitive(cp: CurvePrimitive): void {\n const strokes = LineString3d.create();\n const options = this.getStrokeOptions();\n cp.emitStrokes(strokes, options);\n this.handleLineString3d(strokes);\n }\n /** Handle strongly typed BSplineCurve3d as generic curve primitive. */\n public override handleBSplineCurve3d(g: BSplineCurve3d): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed BSplineCurve3dH as generic curve primitive. */\n public override handleBSplineCurve3dH(g: BSplineCurve3dH): void {\n this.handleCurvePrimitive(g);\n }\n /** Handle strongly typed TransitionSpiral as generic curve primitive. */\n public override handleTransitionSpiral(g: TransitionSpiral3d): void {\n this.handleCurvePrimitive(g);\n }\n}\n"]}
@@ -169,8 +169,7 @@ export declare class RegionOps {
169
169
  * @param loopsB second set of loops (treated as a union)
170
170
  * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
171
171
  * @param mergeTolerance absolute distance tolerance for merging loops
172
- * @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added
173
- * to connect interior loops to exterior loops.
172
+ * @returns a region resulting from merging input loops and the boolean operation.
174
173
  */
175
174
  static regionBooleanXY(loopsA: AnyRegion | AnyRegion[] | undefined, loopsB: AnyRegion | AnyRegion[] | undefined, operation: RegionBinaryOpType, mergeTolerance?: number): AnyRegion | undefined;
176
175
  /**
@@ -337,19 +336,27 @@ export declare class RegionOps {
337
336
  * @see [[PolygonOps.sortOuterAndHoleLoopsXY]]
338
337
  */
339
338
  static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion;
339
+ /**
340
+ * Collect inputs that are nominally closed: regions, and physically closed curves.
341
+ * * Physically closed input curves are each returned wrapped in a Loop to facilitate xy-algorithms,
342
+ * but outside this limited context, these Loops only makes sense if they are planar.
343
+ */
344
+ private static collectRegionsAndClosedPrimitives;
340
345
  /**
341
346
  * Find all xy-areas bounded by the unstructured, possibly intersecting curves.
342
347
  * * For best results, input curves should be parallel to the xy-plane, as z-coordinates are ignored.
343
- * * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the
344
- * input curves. Note that "holes" implied by inputs are _not_ preserved in output.
345
- * * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop,
346
- * regardless of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]]
347
- * to add bridge edges so that [[constructAllXYRegionLoops]] will return outer and inner loops in the same
348
- * SignedLoops object.
349
- * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
350
- * primitives, stripped of parity context. This means holes are _not_ preserved in output.
348
+ * * "Holes" implied/bounded by inputs are _not_ preserved/discovered in output; in particular [[ParityRegion]]
349
+ * hole loops are treated like any other positive area loops.
350
+ * * A common use case of this method is to assemble the bounding negative-area "exterior" loop for each connected
351
+ * component of input curves. Passing `addBridges = true` decreases the number of connected components for nested
352
+ * input [[Loop]]s, and thus increases the likelihood of returning exactly one exterior loop. (This is why the
353
+ * default value for `addBridges` is `true`.)
354
+ * @param curvesAndRegions Any collection of curves. Each [[AnyRegion]] contributes its children _stripped of
355
+ * parity context_.
351
356
  * @param tolerance optional distance tolerance for coincidence.
352
- * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
357
+ * @param addBridges whether to add line segments to connect nested input [[Loop]]s (default is `true`). When `false`,
358
+ * no line segments are added to the input curves, but the number of output components may be greater than expected.
359
+ * @returns array of [[SignedLoops]], each entry of which describes the areas bounded by a single connected component:
353
360
  * * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
354
361
  * positive area and counterclockwise orientation.
355
362
  * * `negativeAreaLoops` contains (probably just one) "exterior" loop which is ordered clockwise.
@@ -357,7 +364,7 @@ export declare class RegionOps {
357
364
  * * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent
358
365
  * to the edge and a constituent curve in each.
359
366
  */
360
- static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[], tolerance?: number): SignedLoops[];
367
+ static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[], tolerance?: number, addBridges?: boolean): SignedLoops[];
361
368
  /**
362
369
  * Collect all `CurvePrimitives` in loosely typed input.
363
370
  * * Always recurses into primitives within explicit collections (Path, Loop, ParityRegion, UnionRegion).
@@ -426,9 +433,11 @@ export declare class ConsolidateAdjacentCurvePrimitivesOptions {
426
433
  consolidateLinearGeometry: boolean;
427
434
  /** True to consolidate contiguous compatible arcs into a single Arc3d. */
428
435
  consolidateCompatibleArcs: boolean;
436
+ /** True to consolidate the first and last primitives of a [[Loop]], allowing the start/end point to change. */
437
+ consolidateLoopSeam: boolean;
429
438
  /** Disable LineSegment3d and LineString3d point compression. */
430
- disableLinearCompression?: boolean;
431
- /** Tolerance for collapsing identical points (if `!disableLinearCompression`). */
439
+ disableLinearCompression: boolean;
440
+ /** Tolerance for detecting identical points. */
432
441
  duplicatePointTolerance: number;
433
442
  /** Tolerance for removing interior colinear points (if `!disableLinearCompression`). */
434
443
  colinearPointTolerance: number;
@@ -1 +1 @@
1
- {"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAC0B,oBAAoB,EAAyB,0BAA0B,EACvG,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAGlE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAA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AS;IACjD,gDAAgD;IACzC,uBAAuB,EAAE,MAAM,CAAgC;IACtE,wFAAwF;IACjF,sBAAsB,EAAE,MAAM,CAAgC;CACtE"}
@@ -36,6 +36,7 @@ const GeometryQuery_1 = require("./GeometryQuery");
36
36
  const ChainCollectorContext_1 = require("./internalContexts/ChainCollectorContext");
37
37
  const PolygonOffsetContext_1 = require("./internalContexts/PolygonOffsetContext");
38
38
  const TransferWithSplitArcs_1 = require("./internalContexts/TransferWithSplitArcs");
39
+ const LineSegment3d_1 = require("./LineSegment3d");
39
40
  const LineString3d_1 = require("./LineString3d");
40
41
  const Loop_1 = require("./Loop");
41
42
  const OffsetOptions_1 = require("./OffsetOptions");
@@ -347,16 +348,17 @@ class RegionOps {
347
348
  * @param loopsB second set of loops (treated as a union)
348
349
  * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
349
350
  * @param mergeTolerance absolute distance tolerance for merging loops
350
- * @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added
351
- * to connect interior loops to exterior loops.
351
+ * @returns a region resulting from merging input loops and the boolean operation.
352
352
  */
353
353
  static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
354
- let result;
354
+ const result = UnionRegion_1.UnionRegion.create();
355
355
  const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(RegionOpsClassificationSweeps_1.RegionGroupOpType.Union, RegionOpsClassificationSweeps_1.RegionGroupOpType.Union);
356
356
  context.addMembers(loopsA, loopsB);
357
357
  context.annotateAndMergeCurvesInGraph(mergeTolerance);
358
+ const visitMask = context.graph.grabMask(false);
358
359
  const range = context.groupA.range().union(context.groupB.range());
359
360
  const areaTol = this.computeXYAreaTolerance(range, mergeTolerance);
361
+ const bridgeMask = Graph_1.HalfEdgeMask.BRIDGE_EDGE;
360
362
  context.runClassificationSweep(operation, (_graph, face, faceType, area) => {
361
363
  // ignore danglers and null faces, but not 2-edge "banana" faces with nonzero area
362
364
  if (face.countEdgesAroundFace() < 2)
@@ -364,15 +366,13 @@ class RegionOps {
364
366
  if (Math.abs(area) < areaTol)
365
367
  return;
366
368
  if (faceType === 1) {
367
- const loop = PlanarSubdivision_1.PlanarSubdivision.createLoopInFace(face);
368
- if (loop) {
369
- if (!result)
370
- result = UnionRegion_1.UnionRegion.create();
371
- result.tryAddChild(loop);
372
- }
369
+ const loopOrParityRegion = PlanarSubdivision_1.PlanarSubdivision.createLoopOrParityRegionInFace(face, bridgeMask, visitMask);
370
+ if (loopOrParityRegion)
371
+ result.tryAddChild(loopOrParityRegion);
373
372
  }
374
373
  });
375
- return result ? this.simplifyRegion(result) : undefined;
374
+ context.graph.dropMask(visitMask);
375
+ return this.simplifyRegion(result);
376
376
  }
377
377
  /**
378
378
  * Return a polyface whose facets are a boolean operation between the input regions.
@@ -687,19 +687,45 @@ class RegionOps {
687
687
  }
688
688
  return SortablePolygon_1.SortablePolygon.sortAsAnyRegion(loopAndArea);
689
689
  }
690
+ /**
691
+ * Collect inputs that are nominally closed: regions, and physically closed curves.
692
+ * * Physically closed input curves are each returned wrapped in a Loop to facilitate xy-algorithms,
693
+ * but outside this limited context, these Loops only makes sense if they are planar.
694
+ */
695
+ static collectRegionsAndClosedPrimitives(curves, tolerance = Geometry_1.Geometry.smallMetricDistance) {
696
+ const regions = [];
697
+ if (!Array.isArray(curves))
698
+ curves = [curves];
699
+ for (const curve of curves) {
700
+ if (curve instanceof Loop_1.Loop || curve instanceof ParityRegion_1.ParityRegion || curve instanceof UnionRegion_1.UnionRegion) {
701
+ regions.push(curve);
702
+ }
703
+ else if (curve instanceof Path_1.Path) {
704
+ if (curve.isPhysicallyClosedCurve(tolerance))
705
+ regions.push(Loop_1.Loop.create(...curve.children));
706
+ }
707
+ else if (curve instanceof CurvePrimitive_1.CurvePrimitive) {
708
+ if (curve.isPhysicallyClosedCurve(tolerance))
709
+ regions.push(Loop_1.Loop.create(curve));
710
+ }
711
+ }
712
+ return regions;
713
+ }
690
714
  /**
691
715
  * Find all xy-areas bounded by the unstructured, possibly intersecting curves.
692
716
  * * For best results, input curves should be parallel to the xy-plane, as z-coordinates are ignored.
693
- * * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the
694
- * input curves. Note that "holes" implied by inputs are _not_ preserved in output.
695
- * * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop,
696
- * regardless of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]]
697
- * to add bridge edges so that [[constructAllXYRegionLoops]] will return outer and inner loops in the same
698
- * SignedLoops object.
699
- * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
700
- * primitives, stripped of parity context. This means holes are _not_ preserved in output.
717
+ * * "Holes" implied/bounded by inputs are _not_ preserved/discovered in output; in particular [[ParityRegion]]
718
+ * hole loops are treated like any other positive area loops.
719
+ * * A common use case of this method is to assemble the bounding negative-area "exterior" loop for each connected
720
+ * component of input curves. Passing `addBridges = true` decreases the number of connected components for nested
721
+ * input [[Loop]]s, and thus increases the likelihood of returning exactly one exterior loop. (This is why the
722
+ * default value for `addBridges` is `true`.)
723
+ * @param curvesAndRegions Any collection of curves. Each [[AnyRegion]] contributes its children _stripped of
724
+ * parity context_.
701
725
  * @param tolerance optional distance tolerance for coincidence.
702
- * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
726
+ * @param addBridges whether to add line segments to connect nested input [[Loop]]s (default is `true`). When `false`,
727
+ * no line segments are added to the input curves, but the number of output components may be greater than expected.
728
+ * @returns array of [[SignedLoops]], each entry of which describes the areas bounded by a single connected component:
703
729
  * * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
704
730
  * positive area and counterclockwise orientation.
705
731
  * * `negativeAreaLoops` contains (probably just one) "exterior" loop which is ordered clockwise.
@@ -707,11 +733,22 @@ class RegionOps {
707
733
  * * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent
708
734
  * to the edge and a constituent curve in each.
709
735
  */
710
- static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance) {
736
+ static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance, addBridges = true) {
711
737
  let primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
712
738
  primitives = TransferWithSplitArcs_1.TransferWithSplitArcs.clone(CurveCollection_1.BagOfCurves.create(...primitives)).children;
713
739
  const range = this.curveArrayRange(primitives);
714
740
  const areaTol = this.computeXYAreaTolerance(range, tolerance);
741
+ if (addBridges) { // generate a temp graph to extract its bridge edges
742
+ const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(RegionOpsClassificationSweeps_1.RegionGroupOpType.Union, RegionOpsClassificationSweeps_1.RegionGroupOpType.Union);
743
+ const regions = this.collectRegionsAndClosedPrimitives(curvesAndRegions, tolerance);
744
+ context.addMembers(regions, undefined);
745
+ context.annotateAndMergeCurvesInGraph(tolerance);
746
+ context.graph.announceEdges((_graph, edge) => {
747
+ if (edge.isMaskSet(Graph_1.HalfEdgeMask.BRIDGE_EDGE))
748
+ primitives.push(LineSegment3d_1.LineSegment3d.create(edge.getPoint3d(), edge.faceSuccessor.getPoint3d()));
749
+ return true;
750
+ });
751
+ }
715
752
  const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);
716
753
  const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance);
717
754
  return PlanarSubdivision_1.PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);
@@ -937,9 +974,11 @@ class ConsolidateAdjacentCurvePrimitivesOptions {
937
974
  consolidateLinearGeometry = true;
938
975
  /** True to consolidate contiguous compatible arcs into a single Arc3d. */
939
976
  consolidateCompatibleArcs = true;
977
+ /** True to consolidate the first and last primitives of a [[Loop]], allowing the start/end point to change. */
978
+ consolidateLoopSeam = false;
940
979
  /** Disable LineSegment3d and LineString3d point compression. */
941
980
  disableLinearCompression = false;
942
- /** Tolerance for collapsing identical points (if `!disableLinearCompression`). */
981
+ /** Tolerance for detecting identical points. */
943
982
  duplicatePointTolerance = Geometry_1.Geometry.smallMetricDistance;
944
983
  /** Tolerance for removing interior colinear points (if `!disableLinearCompression`). */
945
984
  colinearPointTolerance = Geometry_1.Geometry.smallMetricDistance;