@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
@@ -31,7 +31,7 @@ export class ConsolidateAdjacentCurvePrimitivesContext extends NullGeometryHandl
31
31
  const numOriginal = children.length;
32
32
  const points = [];
33
33
  let numAccept = 0;
34
- // i0 <=i < i1 is a range of child indices.
34
+ // i0 <= i < i1 is a range of child indices.
35
35
  // numAccept is the number of children accepted (contiguously at front of children)
36
36
  for (let i0 = 0; i0 < numOriginal;) {
37
37
  const basePrimitive = g.children[i0];
@@ -89,7 +89,7 @@ export class ConsolidateAdjacentCurvePrimitivesContext extends NullGeometryHandl
89
89
  const nextPrimitive = g.children[i0];
90
90
  if (!(nextPrimitive instanceof Arc3d))
91
91
  break;
92
- if (!CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive)) // TODO: use this._options.duplicatePointTolerance
92
+ if (!CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive, false, this._options.duplicatePointTolerance))
93
93
  break;
94
94
  }
95
95
  // i0 has already advanced
@@ -102,8 +102,32 @@ export class ConsolidateAdjacentCurvePrimitivesContext extends NullGeometryHandl
102
102
  }
103
103
  g.children.length = numAccept;
104
104
  }
105
- handlePath(g) { return this.handleCurveChain(g); }
106
- handleLoop(g) { return this.handleCurveChain(g); }
105
+ handlePath(g) {
106
+ return this.handleCurveChain(g);
107
+ }
108
+ handleLoop(g) {
109
+ this.handleCurveChain(g);
110
+ if (g.children.length > 1 && this._options.consolidateLoopSeam) {
111
+ const lastChild = g.children[g.children.length - 1];
112
+ const firstChild = g.children[0];
113
+ if ((lastChild instanceof LineSegment3d || lastChild instanceof LineString3d) && (firstChild instanceof LineSegment3d || firstChild instanceof LineString3d)) {
114
+ if (this._options.consolidateLinearGeometry && !this._options.disableLinearCompression) {
115
+ const lastPoints = lastChild.points;
116
+ lastPoints.pop(); // the original start point survives as an interior point in the new first primitive
117
+ g.children[0] = LineString3d.createPoints([...lastPoints, ...firstChild.points]);
118
+ g.children.pop();
119
+ }
120
+ }
121
+ else if (lastChild instanceof Arc3d && firstChild instanceof Arc3d) {
122
+ if (this._options.consolidateCompatibleArcs) {
123
+ if (CurveFactory.appendToArcInPlace(lastChild, firstChild, false, this._options.duplicatePointTolerance)) {
124
+ g.children[0] = lastChild;
125
+ g.children.pop();
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
107
131
  handleParityRegion(g) {
108
132
  for (const child of g.children)
109
133
  child.dispatchToGeometryHandler(this);
@@ -1 +1 @@
1
- {"version":3,"file":"ConsolidateAdjacentPrimitivesContext.js","sourceRoot":"","sources":["../../../../src/curve/Query/ConsolidateAdjacentPrimitivesContext.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,yCAAyC,EAAE,MAAM,cAAc,CAAC;AAGzE;;;;GAIG;AACH,MAAM,OAAO,yCAA0C,SAAQ,mBAAmB;IACxE,QAAQ,CAA4C;IAC5D,YAAmB,OAAmD;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,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,CAAC;IAC7D,UAAU,CAAC,CAAO,IAAS,OAAO,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,kBAAkB,CAAC,CAAe;QAChD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ;YAC5B,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACe,iBAAiB,CAAC,CAAc;QAC9C,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ;YAC5B,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","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 { NullGeometryHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { PolylineCompressionContext } from \"../../geometry3d/PolylineCompressionByEdgeOffset\";\nimport { PolylineOps } from \"../../geometry3d/PolylineOps\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveChain } from \"../CurveCollection\";\nimport { CurveFactory } from \"../CurveFactory\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop } from \"../Loop\";\nimport { ParityRegion } from \"../ParityRegion\";\nimport { Path } from \"../Path\";\nimport { ConsolidateAdjacentCurvePrimitivesOptions } from \"../RegionOps\";\nimport { UnionRegion } from \"../UnionRegion\";\n\n/**\n * * Implementation class for ConsolidateAdjacentCurvePrimitives.\n *\n * @internal\n */\nexport class ConsolidateAdjacentCurvePrimitivesContext extends NullGeometryHandler {\n private _options: ConsolidateAdjacentCurvePrimitivesOptions;\n public constructor(options?: ConsolidateAdjacentCurvePrimitivesOptions) {\n super();\n this._options = options ? options : new ConsolidateAdjacentCurvePrimitivesOptions();\n }\n /** look for adjacent compatible primitives in a path or loop. */\n public handleCurveChain(g: CurveChain) {\n const children = g.children;\n const numOriginal = children.length;\n const points: Point3d[] = [];\n let numAccept = 0;\n // i0 <=i < i1 is a range of child indices.\n // numAccept is the number of children accepted (contiguously at front of children)\n for (let i0 = 0; i0 < numOriginal;) {\n const basePrimitive = g.children[i0];\n if (this._options.consolidateLinearGeometry && (basePrimitive instanceof LineSegment3d || basePrimitive instanceof LineString3d)) {\n points.length = 0;\n let i1 = i0;\n // on exit, i1 is beyond the block of linear primitives . ..\n for (; i1 < g.children.length; i1++) {\n const nextPrimitive = g.children[i1];\n if (nextPrimitive instanceof LineSegment3d) {\n points.push(nextPrimitive.startPoint());\n points.push(nextPrimitive.endPoint());\n } else if (nextPrimitive instanceof LineString3d) {\n const source = nextPrimitive.packedPoints;\n for (let k = 0; k < source.length; k++) {\n points.push(source.getPoint3dAtUncheckedPointIndex(k));\n }\n } else {\n break;\n }\n }\n if (points.length <= 1) {\n g.children[numAccept++] = basePrimitive;\n } else if (this._options.disableLinearCompression) {\n const pointsDeduped = PolylineOps.compressShortEdges(points, Geometry.smallFloatingPoint); // remove only exact duplicate interior points\n g.children[numAccept++] = LineString3d.createPoints(pointsDeduped);\n } else { // compress points\n const compressedPointsA = PolylineOps.compressShortEdges(points, this._options.duplicatePointTolerance);\n const compressedPointsB = PolylineOps.compressByPerpendicularDistance(compressedPointsA, this._options.colinearPointTolerance);\n if (i0 === 0 && i1 === numOriginal) {\n // points is the entire curve, and the curve is closed. Maybe the first and last segments are colinear.\n PolylineCompressionContext.compressColinearWrapInPlace(compressedPointsB, this._options.duplicatePointTolerance, this._options.colinearPointTolerance);\n }\n if (compressedPointsB.length < 2) {\n // Collapsed to a point? Make a single point linestring\n g.children[numAccept++] = LineString3d.create(compressedPointsB[0]);\n } else if (compressedPointsB.length === 2) {\n g.children[numAccept++] = LineSegment3d.create(compressedPointsB[0], compressedPointsB[1]);\n } else {\n g.children[numAccept++] = LineString3d.createPoints(compressedPointsB);\n }\n }\n i0 = i1;\n } else if (this._options.consolidateCompatibleArcs && basePrimitive instanceof Arc3d) {\n // subsume subsequent arcs into basePrimitive.\n // always accept base primitive.\n for (; ++i0 < g.children.length;) {\n const nextPrimitive = g.children[i0];\n if (!(nextPrimitive instanceof Arc3d))\n break;\n if (!CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive)) // TODO: use this._options.duplicatePointTolerance\n break;\n }\n // i0 has already advanced\n g.children[numAccept++] = basePrimitive; // which has been extended 0 or more times.\n } else {\n g.children[numAccept++] = basePrimitive;\n i0++;\n }\n }\n g.children.length = numAccept;\n }\n\n public override handlePath(g: Path): any { return this.handleCurveChain(g); }\n public override handleLoop(g: Loop): any { return this.handleCurveChain(g); }\n public override handleParityRegion(g: ParityRegion): any {\n for (const child of g.children)\n child.dispatchToGeometryHandler(this);\n }\n public override handleUnionRegion(g: UnionRegion): any {\n for (const child of g.children)\n child.dispatchToGeometryHandler(this);\n }\n}\n"]}
1
+ {"version":3,"file":"ConsolidateAdjacentPrimitivesContext.js","sourceRoot":"","sources":["../../../../src/curve/Query/ConsolidateAdjacentPrimitivesContext.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,kDAAkD,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,OAAO,EAAE,yCAAyC,EAAE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BACrE,IAAI,IAAI,CAAC,QAAQ,CAAC,yBAAyB,EAAE,CAAC;oBAC5C,IAAI,YAAY,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC;wBACzG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;wBAC1B,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;oBACnB,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACe,kBAAkB,CAAC,CAAe;QAChD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ;YAC5B,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;IACe,iBAAiB,CAAC,CAAc;QAC9C,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,QAAQ;YAC5B,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","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 { NullGeometryHandler } from \"../../geometry3d/GeometryHandler\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { PolylineCompressionContext } from \"../../geometry3d/PolylineCompressionByEdgeOffset\";\nimport { PolylineOps } from \"../../geometry3d/PolylineOps\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveChain } from \"../CurveCollection\";\nimport { CurveFactory } from \"../CurveFactory\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop } from \"../Loop\";\nimport { ParityRegion } from \"../ParityRegion\";\nimport { Path } from \"../Path\";\nimport { ConsolidateAdjacentCurvePrimitivesOptions } from \"../RegionOps\";\nimport { UnionRegion } from \"../UnionRegion\";\n\n/**\n * * Implementation class for ConsolidateAdjacentCurvePrimitives.\n *\n * @internal\n */\nexport class ConsolidateAdjacentCurvePrimitivesContext extends NullGeometryHandler {\n private _options: ConsolidateAdjacentCurvePrimitivesOptions;\n public constructor(options?: ConsolidateAdjacentCurvePrimitivesOptions) {\n super();\n this._options = options ? options : new ConsolidateAdjacentCurvePrimitivesOptions();\n }\n /** look for adjacent compatible primitives in a path or loop. */\n public handleCurveChain(g: CurveChain): void {\n const children = g.children;\n const numOriginal = children.length;\n const points: Point3d[] = [];\n let numAccept = 0;\n // i0 <= i < i1 is a range of child indices.\n // numAccept is the number of children accepted (contiguously at front of children)\n for (let i0 = 0; i0 < numOriginal;) {\n const basePrimitive = g.children[i0];\n if (this._options.consolidateLinearGeometry && (basePrimitive instanceof LineSegment3d || basePrimitive instanceof LineString3d)) {\n points.length = 0;\n let i1 = i0;\n // on exit, i1 is beyond the block of linear primitives . ..\n for (; i1 < g.children.length; i1++) {\n const nextPrimitive = g.children[i1];\n if (nextPrimitive instanceof LineSegment3d) {\n points.push(nextPrimitive.startPoint());\n points.push(nextPrimitive.endPoint());\n } else if (nextPrimitive instanceof LineString3d) {\n const source = nextPrimitive.packedPoints;\n for (let k = 0; k < source.length; k++) {\n points.push(source.getPoint3dAtUncheckedPointIndex(k));\n }\n } else {\n break;\n }\n }\n if (points.length <= 1) {\n g.children[numAccept++] = basePrimitive;\n } else if (this._options.disableLinearCompression) {\n const pointsDeduped = PolylineOps.compressShortEdges(points, Geometry.smallFloatingPoint); // remove only exact duplicate interior points\n g.children[numAccept++] = LineString3d.createPoints(pointsDeduped);\n } else { // compress points\n const compressedPointsA = PolylineOps.compressShortEdges(points, this._options.duplicatePointTolerance);\n const compressedPointsB = PolylineOps.compressByPerpendicularDistance(compressedPointsA, this._options.colinearPointTolerance);\n if (i0 === 0 && i1 === numOriginal) {\n // points is the entire curve, and the curve is closed. Maybe the first and last segments are colinear.\n PolylineCompressionContext.compressColinearWrapInPlace(compressedPointsB, this._options.duplicatePointTolerance, this._options.colinearPointTolerance);\n }\n if (compressedPointsB.length < 2) {\n // Collapsed to a point? Make a single point linestring\n g.children[numAccept++] = LineString3d.create(compressedPointsB[0]);\n } else if (compressedPointsB.length === 2) {\n g.children[numAccept++] = LineSegment3d.create(compressedPointsB[0], compressedPointsB[1]);\n } else {\n g.children[numAccept++] = LineString3d.createPoints(compressedPointsB);\n }\n }\n i0 = i1;\n } else if (this._options.consolidateCompatibleArcs && basePrimitive instanceof Arc3d) {\n // subsume subsequent arcs into basePrimitive.\n // always accept base primitive.\n for (; ++i0 < g.children.length;) {\n const nextPrimitive = g.children[i0];\n if (!(nextPrimitive instanceof Arc3d))\n break;\n if (!CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive, false, this._options.duplicatePointTolerance))\n break;\n }\n // i0 has already advanced\n g.children[numAccept++] = basePrimitive; // which has been extended 0 or more times.\n } else {\n g.children[numAccept++] = basePrimitive;\n i0++;\n }\n }\n g.children.length = numAccept;\n }\n\n public override handlePath(g: Path): any {\n return this.handleCurveChain(g);\n }\n public override handleLoop(g: Loop): any {\n this.handleCurveChain(g);\n if (g.children.length > 1 && this._options.consolidateLoopSeam) {\n const lastChild = g.children[g.children.length - 1];\n const firstChild = g.children[0];\n if ((lastChild instanceof LineSegment3d || lastChild instanceof LineString3d) && (firstChild instanceof LineSegment3d || firstChild instanceof LineString3d)) {\n if (this._options.consolidateLinearGeometry && !this._options.disableLinearCompression) {\n const lastPoints = lastChild.points;\n lastPoints.pop(); // the original start point survives as an interior point in the new first primitive\n g.children[0] = LineString3d.createPoints([...lastPoints, ...firstChild.points]);\n g.children.pop();\n }\n } else if (lastChild instanceof Arc3d && firstChild instanceof Arc3d) {\n if (this._options.consolidateCompatibleArcs) {\n if (CurveFactory.appendToArcInPlace(lastChild, firstChild, false, this._options.duplicatePointTolerance)) {\n g.children[0] = lastChild;\n g.children.pop();\n }\n }\n }\n }\n }\n public override handleParityRegion(g: ParityRegion): any {\n for (const child of g.children)\n child.dispatchToGeometryHandler(this);\n }\n public override handleUnionRegion(g: UnionRegion): any {\n for (const child of g.children)\n child.dispatchToGeometryHandler(this);\n }\n}\n"]}
@@ -1,7 +1,8 @@
1
- import { HalfEdge, HalfEdgeGraph } from "../../topology/Graph";
1
+ import { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from "../../topology/Graph";
2
2
  import { CurveLocationDetailPair } from "../CurveLocationDetail";
3
3
  import { CurvePrimitive } from "../CurvePrimitive";
4
4
  import { Loop, SignedLoops } from "../Loop";
5
+ import { ParityRegion } from "../ParityRegion";
5
6
  /**
6
7
  * @internal
7
8
  */
@@ -31,9 +32,30 @@ export declare class PlanarSubdivision {
31
32
  * @returns the area (forced to zero if within tolerance)
32
33
  */
33
34
  static collectSignedLoop(loop: Loop, outLoops: SignedLoops, zeroAreaTolerance?: number, isSliverFace?: boolean): number;
34
- static createLoopInFace(faceSeed: HalfEdge, announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void): Loop;
35
+ /** Extract geometric info from a topological edge. */
36
+ private static extractGeometryFromEdge;
37
+ /** Create the geometry for a topological edge. */
38
+ private static createCurveInEdge;
39
+ /**
40
+ * Create a [[Loop]] for the given face or super face.
41
+ * @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).
42
+ * @param announce optional callback invoked on each edge/curve of the face/Loop.
43
+ * @param compress whether to consolidate adjacent curves in the output Loop (default `false`).
44
+ * If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
45
+ */
46
+ static createLoopInFace(face: HalfEdge | HalfEdge[], announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void, compress?: boolean): Loop | undefined;
47
+ /**
48
+ * Create a [[Loop]] or [[ParityRegion]] for the given face.
49
+ * * A ParityRegion is created for a split-washer type face by removing bridge edges.
50
+ * @param face a node in the face loop.
51
+ * @param bridgeMask mask preset on bridge edges (default is `HalfEdgeMask.BRIDGE_EDGE`).
52
+ * @param visitMask mask to use for visiting edges in the face loop (default is `HalfEdgeMask.VISITED`).
53
+ */
54
+ static createLoopOrParityRegionInFace(face: HalfEdge, bridgeMask?: HalfEdgeMask, visitMask?: HalfEdgeMask): Loop | ParityRegion | undefined;
55
+ /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */
35
56
  private static isNullFace;
36
- private static nonNullEdgeMate;
57
+ /** Look across edge mates (possibly several) for a non-null mate face. */
58
+ private static getNonNullEdgeMate;
37
59
  static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance?: number): SignedLoops[];
38
60
  }
39
61
  //# sourceMappingURL=PlanarSubdivision.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAI/D,OAAO,EAAuB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGnD,OAAO,EAAE,IAAI,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAwEhE;;GAEG;AACH,qBAAa,iBAAiB;IAC5B;;;OAGG;WACW,qBAAqB,CACjC,UAAU,EAAE,cAAc,EAAE,EAC5B,QAAQ,EAAE,uBAAuB,EAAE,EACnC,cAAc,GAAE,MAAqC,GACpD,aAAa;IA0ChB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAsB1B;;;;;;OAMG;WACW,iBAAiB,CAC7B,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,GAAE,MAAgB,EAAE,YAAY,CAAC,EAAE,OAAO,GAC7F,MAAM;WAeK,gBAAgB,CAC5B,QAAQ,EAAE,QAAQ,EAAE,QAAQ,C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,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,KAAK,IAAI,EAAE,QAAQ,GAAE,OAAe,GAAG,IAAI,GAAG,SAAS;IAyB9K;;;;;;OAMG;WACW,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,UAAU,GAAE,YAAuC,EAAE,SAAS,GAAE,YAAmC,GAAG,IAAI,GAAG,YAAY,GAAG,SAAS;IAiClM,yGAAyG;IACzG,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB,0EAA0E;IAC1E,OAAO,CAAC,MAAM,CAAC,kBAAkB;WAWnB,oCAAoC,CAAC,KAAK,EAAE,aAAa,EAAE,iBAAiB,GAAE,MAAgB,GAAG,WAAW,EAAE;CAmC7H"}
@@ -2,8 +2,9 @@
2
2
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
3
  * See LICENSE.md in the project root for license terms and full copyright notice.
4
4
  *--------------------------------------------------------------------------------------------*/
5
+ import { assert } from "@itwin/core-bentley";
5
6
  import { Geometry } from "../../Geometry";
6
- import { HalfEdgeGraph } from "../../topology/Graph";
7
+ import { HalfEdgeGraph, HalfEdgeMask } from "../../topology/Graph";
7
8
  import { HalfEdgeGraphSearch } from "../../topology/HalfEdgeGraphSearch";
8
9
  import { HalfEdgeGraphMerge } from "../../topology/Merging";
9
10
  import { Arc3d } from "../Arc3d";
@@ -11,7 +12,9 @@ import { CurveLocationDetail, CurveLocationDetailPair } from "../CurveLocationDe
11
12
  import { LineSegment3d } from "../LineSegment3d";
12
13
  import { LineString3d } from "../LineString3d";
13
14
  import { Loop, LoopCurveLoopCurve } from "../Loop";
14
- import { RegionOps } from "../RegionOps";
15
+ import { ParityRegion } from "../ParityRegion";
16
+ import { ConsolidateAdjacentCurvePrimitivesOptions, RegionOps } from "../RegionOps";
17
+ import { RegionGroupMember, RegionGroupOpType } from "../RegionOpsClassificationSweeps";
15
18
  /** @packageDocumentation
16
19
  * @module Curve
17
20
  */
@@ -137,6 +140,8 @@ export class PlanarSubdivision {
137
140
  if (point0.isAlmostEqualXY(point1, mergeTolerance))
138
141
  return { point: point0, fraction: fraction0 };
139
142
  const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);
143
+ if (p.parent && p.parent instanceof RegionGroupMember && p.parent.parentGroup.groupOpType === RegionGroupOpType.NonBounding)
144
+ halfEdge.setMaskAroundEdge(HalfEdgeMask.BRIDGE_EDGE);
140
145
  const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);
141
146
  const mate = halfEdge.edgeMate;
142
147
  halfEdge.edgeTag = detail01;
@@ -169,28 +174,102 @@ export class PlanarSubdivision {
169
174
  outLoops.slivers.push(loop);
170
175
  return area;
171
176
  }
172
- static createLoopInFace(faceSeed, announce) {
173
- let he = faceSeed;
177
+ /** Extract geometric info from a topological edge. */
178
+ static extractGeometryFromEdge(edge) {
179
+ if (edge.sortData !== undefined && edge.edgeTag && edge.edgeTag instanceof CurveLocationDetail) {
180
+ const detail = edge.edgeTag;
181
+ if (detail.curve && detail.fraction1 !== undefined) {
182
+ const reversed = edge.sortData < 0;
183
+ return { detail, reversed };
184
+ }
185
+ }
186
+ return undefined;
187
+ }
188
+ /** Create the geometry for a topological edge. */
189
+ static createCurveInEdge(edge) {
190
+ const info = this.extractGeometryFromEdge(edge);
191
+ if (info) {
192
+ if (info.reversed)
193
+ return info.detail.curve.clonePartialCurve(info.detail.fraction1, info.detail.fraction);
194
+ return info.detail.curve.clonePartialCurve(info.detail.fraction, info.detail.fraction1);
195
+ }
196
+ return undefined;
197
+ }
198
+ /**
199
+ * Create a [[Loop]] for the given face or super face.
200
+ * @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).
201
+ * @param announce optional callback invoked on each edge/curve of the face/Loop.
202
+ * @param compress whether to consolidate adjacent curves in the output Loop (default `false`).
203
+ * If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
204
+ */
205
+ static createLoopInFace(face, announce, compress = false) {
206
+ if (announce)
207
+ compress = false;
174
208
  const loop = Loop.create();
175
- do {
176
- const detail = he.edgeTag;
177
- if (detail) {
178
- let curve;
179
- if (he.sortData > 0)
180
- curve = detail.curve.clonePartialCurve(detail.fraction, detail.fraction1);
181
- else
182
- curve = detail.curve.clonePartialCurve(detail.fraction1, detail.fraction);
183
- if (curve) {
184
- if (announce !== undefined)
185
- announce(he, curve, loop);
186
- loop.tryAddChild(curve);
209
+ const addEdgeCurve = (he) => {
210
+ const curve = this.createCurveInEdge(he);
211
+ if (curve) {
212
+ announce?.(he, curve, loop);
213
+ loop.tryAddChild(curve);
214
+ }
215
+ };
216
+ if (Array.isArray(face))
217
+ face.forEach(addEdgeCurve);
218
+ else
219
+ face.announceEdgesInFace(addEdgeCurve);
220
+ if (compress) {
221
+ const options = new ConsolidateAdjacentCurvePrimitivesOptions();
222
+ options.consolidateLoopSeam = true;
223
+ RegionOps.consolidateAdjacentPrimitives(loop, options);
224
+ }
225
+ if (loop.isPhysicallyClosedCurve(undefined, true))
226
+ return loop;
227
+ assert(false, "createLoopInFace: face is not physically closed");
228
+ return undefined;
229
+ }
230
+ /**
231
+ * Create a [[Loop]] or [[ParityRegion]] for the given face.
232
+ * * A ParityRegion is created for a split-washer type face by removing bridge edges.
233
+ * @param face a node in the face loop.
234
+ * @param bridgeMask mask preset on bridge edges (default is `HalfEdgeMask.BRIDGE_EDGE`).
235
+ * @param visitMask mask to use for visiting edges in the face loop (default is `HalfEdgeMask.VISITED`).
236
+ */
237
+ static createLoopOrParityRegionInFace(face, bridgeMask = HalfEdgeMask.BRIDGE_EDGE, visitMask = HalfEdgeMask.VISITED) {
238
+ let region;
239
+ if (face.isSplitWasherFace(bridgeMask)) {
240
+ const loops = [];
241
+ const loopEdges = [];
242
+ const bridgeStack = [face.findMaskAroundFace(bridgeMask, true)];
243
+ const announceEdge = (he) => { he.setMask(visitMask); loopEdges.push(he); };
244
+ const announceBridge = (he) => { if (!he.isMaskSet(visitMask))
245
+ bridgeStack.push(he); };
246
+ face.clearMaskAroundFace(visitMask);
247
+ let bridge;
248
+ while (undefined !== (bridge = bridgeStack.pop())) {
249
+ bridge.setMask(visitMask);
250
+ const loopSeed = bridge.findMaskAroundFace(bridgeMask, false); // advance to next loop
251
+ if (loopSeed) {
252
+ if (loopSeed.isMaskSet(visitMask))
253
+ continue;
254
+ loopEdges.length = 0;
255
+ if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {
256
+ const loop = this.createLoopInFace(loopEdges, undefined, true);
257
+ if (loop) {
258
+ loops.push(loop);
259
+ continue;
260
+ }
261
+ }
187
262
  }
188
263
  }
189
- he = he.faceSuccessor;
190
- } while (he !== faceSeed);
191
- return loop;
264
+ region = RegionOps.sortOuterAndHoleLoopsXY(loops);
265
+ region = RegionOps.simplifyRegion(region);
266
+ }
267
+ else {
268
+ region = this.createLoopInFace(face, undefined, true);
269
+ }
270
+ return (region && (region instanceof Loop || region instanceof ParityRegion)) ? region : undefined;
192
271
  }
193
- // Return true if there are only two edges in the face loop, and their start curvatures are the same.
272
+ /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */
194
273
  static isNullFace(he) {
195
274
  const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);
196
275
  let faceIsBanana = false;
@@ -202,8 +281,8 @@ export class PlanarSubdivision {
202
281
  }
203
282
  return faceHasTwoEdges && !faceIsBanana;
204
283
  }
205
- // Look across edge mates (possibly several) for a nonnull mate face.
206
- static nonNullEdgeMate(_graph, e) {
284
+ /** Look across edge mates (possibly several) for a non-null mate face. */
285
+ static getNonNullEdgeMate(_graph, e) {
207
286
  if (this.isNullFace(e))
208
287
  return undefined;
209
288
  let e1 = e.edgeMate;
@@ -225,7 +304,7 @@ export class PlanarSubdivision {
225
304
  const isNullFace = this.isNullFace(faceSeed);
226
305
  const loop = this.createLoopInFace(faceSeed, (he, curveC, loopC) => {
227
306
  if (!isNullFace) {
228
- const mate = this.nonNullEdgeMate(graph, he);
307
+ const mate = this.getNonNullEdgeMate(graph, he);
229
308
  if (mate !== undefined) {
230
309
  const e = edgeMap.get(mate);
231
310
  if (e === undefined) {
@@ -241,7 +320,8 @@ export class PlanarSubdivision {
241
320
  }
242
321
  }
243
322
  });
244
- this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);
323
+ if (loop)
324
+ this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);
245
325
  }
246
326
  componentAreas.edges = edges;
247
327
  result.push(componentAreas);
@@ -1 +1 @@
1
- {"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAY,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC;;GAEG;AAEH,MAAM,+CAA+C;IAC5C,eAAe,GAAG,IAAI,GAAG,EAA6C,CAAC;IAC9E,mDAAmD;IAC5C,gBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;IACpD,qBAAqB,GAAW,CAAC,CAAC;IACnC,oBAAoB,CAAC,SAAqC;QAC/D,IAAI,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AO,CAAC,KAAK,EAAE,CAAC;QAClB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAED,SAAS,SAAS,CAAC,KAAqB,EAAE,QAAgB,EAAE,OAAgB;IAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,KAAqB;IAC9E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { Geometry } from \"../../Geometry\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { HalfEdge, HalfEdgeGraph } from \"../../topology/Graph\";\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\nimport { RegionOps } from \"../RegionOps\";\n\n/** @packageDocumentation\n * @module Curve\n */\n\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\n // index assigned to this primitive (for debugging)\n public primitiveToIndex = new Map<CurvePrimitive, number>();\n private _numIndexedPrimitives: number = 0;\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\n if (primitive !== undefined) {\n const index = this.primitiveToIndex.get(primitive);\n if (index === undefined) {\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\n }\n }\n }\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\n if (primitive) {\n const priorPairs = this.primitiveToPair.get(primitive);\n this.assignPrimitiveIndex(primitive);\n if (!priorPairs) {\n this.primitiveToPair.set(primitive, [pair]);\n } else {\n priorPairs.push(pair);\n }\n }\n }\n public insertPair(pair: CurveLocationDetailPair) {\n const primitiveA = pair.detailA.curve;\n if (primitiveA)\n this.insertPrimitiveToPair(primitiveA, pair);\n const primitiveB = pair.detailB.curve;\n if (primitiveB)\n this.insertPrimitiveToPair(primitiveB, pair);\n }\n /**\n * Split closed missing primitives in half and add new intersection pairs.\n * * When bridge edges aren't included in the primitives array, a closed primitive with no intersections will not be\n * added to the graph because it isn't in the `primitiveToPair` map. By splitting such a missing primitive in two, we\n * introduce two intersections for each half, which allows the primitive to be represented in the map.\n */\n public splitAndAppendMissingClosedPrimitives(\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\n ): void {\n for (const p of primitives) {\n let closedCurveSplitCandidate = false;\n if (p instanceof Arc3d)\n closedCurveSplitCandidate = p.sweep.isFullCircle;\n else if (!(p instanceof LineSegment3d) && !(p instanceof LineString3d)) // TODO: probably should do this for all types. Lots of spline-type primitives can be closed.\n closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);\n if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {\n const p0 = p.clonePartialCurve(0.0, 0.5);\n const p1 = p.clonePartialCurve(0.5, 1.0);\n if (p0 && p1) {\n this.insertPair(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0),\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0),\n ));\n this.insertPair(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0),\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0),\n ));\n }\n }\n }\n }\n}\n\n/**\n * @internal\n */\nexport class PlanarSubdivision {\n /**\n * Create a graph from an array of curves, and an array of the curves' precomputed intersections.\n * Z-coordinates are ignored.\n */\n public static assembleHalfEdgeGraph(\n primitives: CurvePrimitive[],\n allPairs: CurveLocationDetailPair[],\n mergeTolerance: number = Geometry.smallMetricDistance,\n ): HalfEdgeGraph {\n // map from key CurvePrimitive to CurveLocationDetailPair\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray();\n for (const pair of allPairs)\n detailByPrimitive.insertPair(pair);\n if (primitives.length > detailByPrimitive.primitiveToPair.size) {\n // otherwise, these single-primitive loops are missing from the graph\n detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance);\n }\n const graph = new HalfEdgeGraph();\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\n const p = entry[0];\n // convert each interval intersection into two isolated intersections\n const details = entry[1].reduce((accumulator: CurveLocationDetailPair[], detailPair) => {\n if (!detailPair.detailA.hasFraction1)\n return [...accumulator, detailPair];\n const detail = getDetailOnCurve(detailPair, p)!;\n const detail0 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);\n const detail1 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1!, detail.point1!);\n return [\n ...accumulator,\n CurveLocationDetailPair.createCapture(detail0, detail0),\n CurveLocationDetailPair.createCapture(detail1, detail1),\n ];\n }, []);\n // lexical sort on p intersection fraction\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\n const fractionA = getFractionOnCurve(pairA, p)!;\n const fractionB = getFractionOnCurve(pairB, p)!;\n return fractionA - fractionB;\n });\n let last = { point: p.startPoint(), fraction: 0.0 };\n for (const detailPair of details) {\n const detail = getDetailOnCurve(detailPair, p)!;\n const detailFraction = Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later\n last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);\n }\n this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);\n }\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\n return graph;\n }\n /**\n * Create a pair of mated half edges referencing an interval of a primitive.\n * * no action if start and end points are identical.\n * @param graph containing graph\n * @param p the curve\n * @param point0 start point\n * @param fraction0 starting fraction\n * @param point1 end point\n * @param fraction1 end fraction\n * @returns end point and fraction, or start point and fraction if no action\n */\n private static addHalfEdge(\n graph: HalfEdgeGraph,\n p: CurvePrimitive,\n point0: Point3d,\n fraction0: number,\n point1: Point3d,\n fraction1: number,\n mergeTolerance: number = Geometry.smallMetricDistance,\n ): { point: Point3d, fraction: number } {\n if (point0.isAlmostEqualXY(point1, mergeTolerance))\n return { point: point0, fraction: fraction0 };\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\n const mate = halfEdge.edgeMate;\n halfEdge.edgeTag = detail01;\n halfEdge.sortData = 1.0;\n mate.edgeTag = detail01;\n mate.sortData = -1.0;\n halfEdge.sortAngle = sortAngle(p, fraction0, false);\n mate.sortAngle = sortAngle(p, fraction1, true);\n return { point: point1, fraction: fraction1 };\n }\n /**\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative,\n * or sliver loops.\n * @param zeroAreaTolerance absolute area tolerance for sliver face detection\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\n * @returns the area (forced to zero if within tolerance)\n */\n public static collectSignedLoop(\n loop: Loop, outLoops: SignedLoops, zeroAreaTolerance: number = 1.0e-10, isSliverFace?: boolean,\n ): number {\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\n if (area === undefined)\n area = 0;\n if (Math.abs(area) < zeroAreaTolerance)\n area = 0.0;\n (loop as any).computedAreaInPlanarSubdivision = area;\n if (area > 0)\n outLoops.positiveAreaLoops.push(loop);\n else if (area < 0)\n outLoops.negativeAreaLoops.push(loop);\n else\n outLoops.slivers.push(loop);\n return area;\n }\n public static createLoopInFace(\n faceSeed: HalfEdge, announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void,\n ): Loop {\n let he = faceSeed;\n const loop = Loop.create();\n do {\n const detail = he.edgeTag as CurveLocationDetail;\n if (detail) {\n let curve;\n if (he.sortData! > 0)\n curve = detail.curve!.clonePartialCurve(detail.fraction, detail.fraction1!);\n else\n curve = detail.curve!.clonePartialCurve(detail.fraction1!, detail.fraction);\n if (curve) {\n if (announce !== undefined)\n announce(he, curve, loop);\n loop.tryAddChild(curve);\n }\n }\n he = he.faceSuccessor;\n } while (he !== faceSeed);\n return loop;\n }\n // Return true if there are only two edges in the face loop, and their start curvatures are the same.\n private static isNullFace(he: HalfEdge): boolean {\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\n let faceIsBanana = false;\n if (faceHasTwoEdges) {\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\n }\n return faceHasTwoEdges && !faceIsBanana;\n }\n // Look across edge mates (possibly several) for a nonnull mate face.\n private static nonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\n if (this.isNullFace(e))\n return undefined;\n let e1 = e.edgeMate;\n while (this.isNullFace(e1)) {\n e1 = e1.faceSuccessor.edgeMate;\n if (e1 === e)\n return undefined;\n }\n return e1;\n }\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\n const result: SignedLoops[] = [];\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\n for (const faceSeeds of q) {\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\n const edges: LoopCurveLoopCurve[] = [];\n for (const faceSeed of faceSeeds) {\n const isNullFace = this.isNullFace(faceSeed);\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\n if (!isNullFace) {\n const mate = this.nonNullEdgeMate(graph, he);\n if (mate !== undefined) {\n const e = edgeMap.get(mate);\n if (e === undefined) {\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\n edgeMap.set(he, e1);\n } else if (e instanceof LoopCurveLoopCurve) {\n e.setB(loopC, curveC);\n edges.push(e);\n edgeMap.delete(mate);\n }\n }\n }\n });\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);\n }\n componentAreas.edges = edges;\n result.push(componentAreas);\n edgeMap.clear();\n }\n return result;\n }\n}\n\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\n const ray = curve.fractionToPointAndDerivative(fraction);\n const s = reverse ? -1.0 : 1.0;\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\n}\n\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA.fraction;\n if (pair.detailB.curve === curve)\n return pair.detailB.fraction;\n return undefined;\n}\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA;\n if (pair.detailB.curve === curve)\n return pair.detailB;\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAY,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAGtF,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAe,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,yCAAyC,EAAE,SAAS,EAAE,MAAM,cA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AAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,KAAqB;IAC9E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","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*--------------------------------------------------------------------------------------------*/\nimport { assert } from \"@itwin/core-bentley\";\nimport { Geometry } from \"../../Geometry\";\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../../topology/Graph\";\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\nimport { Arc3d } from \"../Arc3d\";\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\nimport { CurvePrimitive } from \"../CurvePrimitive\";\nimport { AnyRegion } from \"../CurveTypes\";\nimport { LineSegment3d } from \"../LineSegment3d\";\nimport { LineString3d } from \"../LineString3d\";\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\nimport { ParityRegion } from \"../ParityRegion\";\nimport { ConsolidateAdjacentCurvePrimitivesOptions, RegionOps } from \"../RegionOps\";\nimport { RegionGroupMember, RegionGroupOpType } from \"../RegionOpsClassificationSweeps\";\n\n/** @packageDocumentation\n * @module Curve\n */\n\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\n // index assigned to this primitive (for debugging)\n public primitiveToIndex = new Map<CurvePrimitive, number>();\n private _numIndexedPrimitives: number = 0;\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\n if (primitive !== undefined) {\n const index = this.primitiveToIndex.get(primitive);\n if (index === undefined) {\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\n }\n }\n }\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\n if (primitive) {\n const priorPairs = this.primitiveToPair.get(primitive);\n this.assignPrimitiveIndex(primitive);\n if (!priorPairs) {\n this.primitiveToPair.set(primitive, [pair]);\n } else {\n priorPairs.push(pair);\n }\n }\n }\n public insertPair(pair: CurveLocationDetailPair) {\n const primitiveA = pair.detailA.curve;\n if (primitiveA)\n this.insertPrimitiveToPair(primitiveA, pair);\n const primitiveB = pair.detailB.curve;\n if (primitiveB)\n this.insertPrimitiveToPair(primitiveB, pair);\n }\n /**\n * Split closed missing primitives in half and add new intersection pairs.\n * * When bridge edges aren't included in the primitives array, a closed primitive with no intersections will not be\n * added to the graph because it isn't in the `primitiveToPair` map. By splitting such a missing primitive in two, we\n * introduce two intersections for each half, which allows the primitive to be represented in the map.\n */\n public splitAndAppendMissingClosedPrimitives(\n primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance,\n ): void {\n for (const p of primitives) {\n let closedCurveSplitCandidate = false;\n if (p instanceof Arc3d)\n closedCurveSplitCandidate = p.sweep.isFullCircle;\n else if (!(p instanceof LineSegment3d) && !(p instanceof LineString3d)) // TODO: probably should do this for all types. Lots of spline-type primitives can be closed.\n closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);\n if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {\n const p0 = p.clonePartialCurve(0.0, 0.5);\n const p1 = p.clonePartialCurve(0.5, 1.0);\n if (p0 && p1) {\n this.insertPair(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0),\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0),\n ));\n this.insertPair(CurveLocationDetailPair.createCapture(\n CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0),\n CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0),\n ));\n }\n }\n }\n }\n}\n\n/**\n * @internal\n */\nexport class PlanarSubdivision {\n /**\n * Create a graph from an array of curves, and an array of the curves' precomputed intersections.\n * Z-coordinates are ignored.\n */\n public static assembleHalfEdgeGraph(\n primitives: CurvePrimitive[],\n allPairs: CurveLocationDetailPair[],\n mergeTolerance: number = Geometry.smallMetricDistance,\n ): HalfEdgeGraph {\n // map from key CurvePrimitive to CurveLocationDetailPair\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray();\n for (const pair of allPairs)\n detailByPrimitive.insertPair(pair);\n if (primitives.length > detailByPrimitive.primitiveToPair.size) {\n // otherwise, these single-primitive loops are missing from the graph\n detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance);\n }\n const graph = new HalfEdgeGraph();\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\n const p = entry[0];\n // convert each interval intersection into two isolated intersections\n const details = entry[1].reduce((accumulator: CurveLocationDetailPair[], detailPair) => {\n if (!detailPair.detailA.hasFraction1)\n return [...accumulator, detailPair];\n const detail = getDetailOnCurve(detailPair, p)!;\n const detail0 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);\n const detail1 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1!, detail.point1!);\n return [\n ...accumulator,\n CurveLocationDetailPair.createCapture(detail0, detail0),\n CurveLocationDetailPair.createCapture(detail1, detail1),\n ];\n }, []);\n // lexical sort on p intersection fraction\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\n const fractionA = getFractionOnCurve(pairA, p)!;\n const fractionB = getFractionOnCurve(pairB, p)!;\n return fractionA - fractionB;\n });\n let last = { point: p.startPoint(), fraction: 0.0 };\n for (const detailPair of details) {\n const detail = getDetailOnCurve(detailPair, p)!;\n const detailFraction = Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later\n last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);\n }\n this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);\n }\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\n return graph;\n }\n /**\n * Create a pair of mated half edges referencing an interval of a primitive.\n * * no action if start and end points are identical.\n * @param graph containing graph\n * @param p the curve\n * @param point0 start point\n * @param fraction0 starting fraction\n * @param point1 end point\n * @param fraction1 end fraction\n * @returns end point and fraction, or start point and fraction if no action\n */\n private static addHalfEdge(\n graph: HalfEdgeGraph,\n p: CurvePrimitive,\n point0: Point3d,\n fraction0: number,\n point1: Point3d,\n fraction1: number,\n mergeTolerance: number = Geometry.smallMetricDistance,\n ): { point: Point3d, fraction: number } {\n if (point0.isAlmostEqualXY(point1, mergeTolerance))\n return { point: point0, fraction: fraction0 };\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\n if (p.parent && p.parent instanceof RegionGroupMember && p.parent.parentGroup.groupOpType === RegionGroupOpType.NonBounding)\n halfEdge.setMaskAroundEdge(HalfEdgeMask.BRIDGE_EDGE);\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\n const mate = halfEdge.edgeMate;\n halfEdge.edgeTag = detail01;\n halfEdge.sortData = 1.0;\n mate.edgeTag = detail01;\n mate.sortData = -1.0;\n halfEdge.sortAngle = sortAngle(p, fraction0, false);\n mate.sortAngle = sortAngle(p, fraction1, true);\n return { point: point1, fraction: fraction1 };\n }\n /**\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative,\n * or sliver loops.\n * @param zeroAreaTolerance absolute area tolerance for sliver face detection\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\n * @returns the area (forced to zero if within tolerance)\n */\n public static collectSignedLoop(\n loop: Loop, outLoops: SignedLoops, zeroAreaTolerance: number = 1.0e-10, isSliverFace?: boolean,\n ): number {\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\n if (area === undefined)\n area = 0;\n if (Math.abs(area) < zeroAreaTolerance)\n area = 0.0;\n (loop as any).computedAreaInPlanarSubdivision = area;\n if (area > 0)\n outLoops.positiveAreaLoops.push(loop);\n else if (area < 0)\n outLoops.negativeAreaLoops.push(loop);\n else\n outLoops.slivers.push(loop);\n return area;\n }\n /** Extract geometric info from a topological edge. */\n private static extractGeometryFromEdge(edge: HalfEdge): { detail: CurveLocationDetail, reversed: boolean } | undefined {\n if (edge.sortData !== undefined && edge.edgeTag && edge.edgeTag instanceof CurveLocationDetail) {\n const detail = edge.edgeTag;\n if (detail.curve && detail.fraction1 !== undefined) {\n const reversed = edge.sortData < 0;\n return { detail, reversed };\n }\n }\n return undefined;\n }\n /** Create the geometry for a topological edge. */\n private static createCurveInEdge(edge: HalfEdge): CurvePrimitive | undefined {\n const info = this.extractGeometryFromEdge(edge);\n if (info) {\n if (info.reversed)\n return info.detail.curve!.clonePartialCurve(info.detail.fraction1!, info.detail.fraction);\n return info.detail.curve!.clonePartialCurve(info.detail.fraction, info.detail.fraction1!);\n }\n return undefined;\n }\n /**\n * Create a [[Loop]] for the given face or super face.\n * @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).\n * @param announce optional callback invoked on each edge/curve of the face/Loop.\n * @param compress whether to consolidate adjacent curves in the output Loop (default `false`).\n * If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.\n */\n public static createLoopInFace(face: HalfEdge | HalfEdge[], announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void, compress: boolean = false): Loop | undefined {\n if (announce)\n compress = false;\n const loop = Loop.create();\n const addEdgeCurve = (he: HalfEdge): void => {\n const curve = this.createCurveInEdge(he);\n if (curve) {\n announce?.(he, curve, loop);\n loop.tryAddChild(curve);\n }\n };\n if (Array.isArray(face))\n face.forEach(addEdgeCurve);\n else\n face.announceEdgesInFace(addEdgeCurve);\n if (compress) {\n const options = new ConsolidateAdjacentCurvePrimitivesOptions();\n options.consolidateLoopSeam = true;\n RegionOps.consolidateAdjacentPrimitives(loop, options);\n }\n if (loop.isPhysicallyClosedCurve(undefined, true))\n return loop;\n assert(false, \"createLoopInFace: face is not physically closed\");\n return undefined;\n }\n /**\n * Create a [[Loop]] or [[ParityRegion]] for the given face.\n * * A ParityRegion is created for a split-washer type face by removing bridge edges.\n * @param face a node in the face loop.\n * @param bridgeMask mask preset on bridge edges (default is `HalfEdgeMask.BRIDGE_EDGE`).\n * @param visitMask mask to use for visiting edges in the face loop (default is `HalfEdgeMask.VISITED`).\n */\n public static createLoopOrParityRegionInFace(face: HalfEdge, bridgeMask: HalfEdgeMask = HalfEdgeMask.BRIDGE_EDGE, visitMask: HalfEdgeMask = HalfEdgeMask.VISITED): Loop | ParityRegion | undefined {\n let region: AnyRegion | undefined;\n if (face.isSplitWasherFace(bridgeMask)) {\n const loops: Loop[] = [];\n const loopEdges: HalfEdge[] = [];\n const bridgeStack: HalfEdge[] = [face.findMaskAroundFace(bridgeMask, true)!];\n const announceEdge = (he: HalfEdge) => { he.setMask(visitMask); loopEdges.push(he); };\n const announceBridge = (he: HalfEdge) => { if (!he.isMaskSet(visitMask)) bridgeStack.push(he); };\n face.clearMaskAroundFace(visitMask);\n let bridge: HalfEdge | undefined;\n while (undefined !== (bridge = bridgeStack.pop())) {\n bridge.setMask(visitMask);\n const loopSeed = bridge.findMaskAroundFace(bridgeMask, false); // advance to next loop\n if (loopSeed) {\n if (loopSeed.isMaskSet(visitMask))\n continue;\n loopEdges.length = 0;\n if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {\n const loop = this.createLoopInFace(loopEdges, undefined, true);\n if (loop) {\n loops.push(loop);\n continue;\n }\n }\n }\n }\n region = RegionOps.sortOuterAndHoleLoopsXY(loops);\n region = RegionOps.simplifyRegion(region);\n } else {\n region = this.createLoopInFace(face, undefined, true);\n }\n return (region && (region instanceof Loop || region instanceof ParityRegion)) ? region : undefined;\n }\n /** Return true if there are only two edges in the face loop, and their start curvatures are the same. */\n private static isNullFace(he: HalfEdge): boolean {\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\n let faceIsBanana = false;\n if (faceHasTwoEdges) {\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\n }\n return faceHasTwoEdges && !faceIsBanana;\n }\n /** Look across edge mates (possibly several) for a non-null mate face. */\n private static getNonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\n if (this.isNullFace(e))\n return undefined;\n let e1 = e.edgeMate;\n while (this.isNullFace(e1)) {\n e1 = e1.faceSuccessor.edgeMate;\n if (e1 === e)\n return undefined;\n }\n return e1;\n }\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\n const result: SignedLoops[] = [];\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\n for (const faceSeeds of q) {\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\n const edges: LoopCurveLoopCurve[] = [];\n for (const faceSeed of faceSeeds) {\n const isNullFace = this.isNullFace(faceSeed);\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\n if (!isNullFace) {\n const mate = this.getNonNullEdgeMate(graph, he);\n if (mate !== undefined) {\n const e = edgeMap.get(mate);\n if (e === undefined) {\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\n edgeMap.set(he, e1);\n } else if (e instanceof LoopCurveLoopCurve) {\n e.setB(loopC, curveC);\n edges.push(e);\n edgeMap.delete(mate);\n }\n }\n }\n });\n if (loop)\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);\n }\n componentAreas.edges = edges;\n result.push(componentAreas);\n edgeMap.clear();\n }\n return result;\n }\n}\n\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\n const ray = curve.fractionToPointAndDerivative(fraction);\n const s = reverse ? -1.0 : 1.0;\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\n}\n\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA.fraction;\n if (pair.detailB.curve === curve)\n return pair.detailB.fraction;\n return undefined;\n}\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\n if (pair.detailA.curve === curve)\n return pair.detailA;\n if (pair.detailB.curve === curve)\n return pair.detailB;\n return undefined;\n}\n"]}
@@ -2,8 +2,8 @@
2
2
  * @module Curve
3
3
  */
4
4
  import { Range1d } from "../../geometry3d/Range";
5
- import { AnyCurve } from "../CurveTypes";
6
5
  import { CurveChain, CurveCollection } from "../CurveCollection";
6
+ import { AnyCurve } from "../CurveTypes";
7
7
  import { LineString3d } from "../LineString3d";
8
8
  import { StrokeOptions } from "../StrokeOptions";
9
9
  import { StrokeCountMap } from "./StrokeCountMap";
@@ -95,6 +95,7 @@ export declare class StrokeCountMapVisitorApplyMaxCurveLength extends StrokeCoun
95
95
  * * `parent` = parent CurveCollection.
96
96
  *
97
97
  * An instance is normally created with either a `Path` or `Loop` as the parent.
98
+ * @internal
98
99
  */
99
100
  export declare class StrokeCountChain {
100
101
  maps: StrokeCountMap[];
@@ -106,7 +107,7 @@ export declare class StrokeCountChain {
106
107
  */
107
108
  options?: StrokeOptions;
108
109
  private constructor();
109
- static createForCurveChain(chain: CurveChain, options?: StrokeOptions): StrokeCountChain;
110
+ static create(chain: CurveChain, options?: StrokeOptions): StrokeCountChain;
110
111
  getStrokes(): LineString3d;
111
112
  /** internal form of */
112
113
  private static applySummed01LimitsWithinArray;
@@ -138,7 +139,7 @@ export declare class StrokeCountSection {
138
139
  * construct array of arrays of `StrokeCountMap`s
139
140
  * @param parent
140
141
  */
141
- static createForParityRegionOrChain(parent: CurveCollection, options?: StrokeOptions): StrokeCountSection;
142
+ static create(parent: CurveCollection, options?: StrokeOptions): StrokeCountSection;
142
143
  /** test if all sections have the same structure. */
143
144
  static areSectionsCompatible(sections: StrokeCountSection[], enforceCounts: boolean): boolean;
144
145
  /** Within each section, sweep accumulate curveLength field, recording entry and exit sum in each map.
@@ -1 +1 @@
1
- {"version":3,"file":"StrokeCountChain.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/StrokeCountChain.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,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C;IAiCxD;;;;OAIG;WACW,4CAA4C,CAAC,QAAQ,EAAE,kBAAkB,EAAE,EAAE,QAAQ,EAAE,8BAA8B,GAAG,OAAO;IAoB7I;;;;OAIG;WACW,+BAA+B,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,OAAO;IAWtF;;;;;OAKG;WACW,6BAA6B,CAAC,QAAQ,EAAE,kBAAkB,EAAE,GAAG,OAAO;IAapF;;OAEG;IACI,UAAU,IAAI,QAAQ;IAa7B;;;;;;;;;;;OAWG;WACW,iCAAiC,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO;CA+CvH"}
@@ -11,6 +11,7 @@ import { CurveChain } from "../CurveCollection";
11
11
  import { LineString3d } from "../LineString3d";
12
12
  import { Loop } from "../Loop";
13
13
  import { ParityRegion } from "../ParityRegion";
14
+ import { UnionRegion } from "../UnionRegion";
14
15
  import { StrokeCountMap } from "./StrokeCountMap";
15
16
  // cspell:word remapa
16
17
  /**
@@ -142,6 +143,7 @@ export class StrokeCountMapVisitorApplyMaxCurveLength extends StrokeCountMapMult
142
143
  * * `parent` = parent CurveCollection.
143
144
  *
144
145
  * An instance is normally created with either a `Path` or `Loop` as the parent.
146
+ * @internal
145
147
  */
146
148
  export class StrokeCountChain {
147
149
  maps;
@@ -157,7 +159,7 @@ export class StrokeCountChain {
157
159
  this.maps = [];
158
160
  this.options = options;
159
161
  }
160
- static createForCurveChain(chain, options) {
162
+ static create(chain, options) {
161
163
  const result = new StrokeCountChain(chain, options);
162
164
  result.parent = chain;
163
165
  // A chain can only contain primitives !!!!
@@ -228,16 +230,24 @@ export class StrokeCountSection {
228
230
  * construct array of arrays of `StrokeCountMap`s
229
231
  * @param parent
230
232
  */
231
- static createForParityRegionOrChain(parent, options) {
233
+ static create(parent, options) {
232
234
  const result = new StrokeCountSection(parent);
233
- if (parent instanceof ParityRegion) {
235
+ const appendCurveChain = (chain) => result.chains.push(StrokeCountChain.create(chain, options));
236
+ const appendParityRegion = (region) => { for (const child of region.children)
237
+ appendCurveChain(child); };
238
+ if (parent instanceof UnionRegion) {
234
239
  for (const child of parent.children) {
235
- const p = StrokeCountChain.createForCurveChain(child, options);
236
- result.chains.push(p);
240
+ if (child instanceof ParityRegion)
241
+ appendParityRegion(child);
242
+ else
243
+ appendCurveChain(child);
237
244
  }
238
245
  }
246
+ else if (parent instanceof ParityRegion) {
247
+ appendParityRegion(parent);
248
+ }
239
249
  else if (parent instanceof CurveChain) {
240
- result.chains.push(StrokeCountChain.createForCurveChain(parent, options));
250
+ appendCurveChain(parent);
241
251
  }
242
252
  return result;
243
253
  }
@@ -316,11 +326,12 @@ export class StrokeCountSection {
316
326
  for (let chainIndex = 0; chainIndex < numChainPerSection; chainIndex++) {
317
327
  const numPrimitive = sections[0].chains[chainIndex].maps.length;
318
328
  for (let primitiveIndex = 0; primitiveIndex < numPrimitive; primitiveIndex++) {
319
- if (sections[0].chains[chainIndex].maps[primitiveIndex].componentData) {
320
- const numComponent = sections[0].chains[chainIndex].maps[primitiveIndex].componentData.length;
321
- for (let i = 0; i < numComponent; i++)
329
+ const numComponent = sections[0].chains[chainIndex].maps[primitiveIndex].componentData?.length ?? 0;
330
+ if (numComponent > 0) {
331
+ for (let i = 0; i < numComponent; i++) {
322
332
  if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, i, callback))
323
333
  return false;
334
+ }
324
335
  }
325
336
  else {
326
337
  if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, undefined, callback))