@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
@@ -5,6 +5,7 @@
5
5
  /** @packageDocumentation
6
6
  * @module Topology
7
7
  */
8
+ import { OrderedSet } from "@itwin/core-bentley";
8
9
  import { LineSegment3d } from "../curve/LineSegment3d";
9
10
  import { Geometry } from "../Geometry";
10
11
  import { Angle } from "../geometry3d/Angle";
@@ -14,7 +15,6 @@ import { SmallSystem } from "../numerics/SmallSystem";
14
15
  import { MaskManager } from "./MaskManager";
15
16
  // import { GraphChecker } from "../test/topology/Graph.test"; // used for debugging
16
17
  /* eslint-disable @typescript-eslint/no-this-alias */
17
- // cspell:word CONSTU CONSTV USEAM VSEAM internaldocs
18
18
  /**
19
19
  * * Each node of the graph has a mask member.
20
20
  * * The mask member is a number which is used as set of single bit boolean values.
@@ -29,14 +29,6 @@ import { MaskManager } from "./MaskManager";
29
29
  */
30
30
  export var HalfEdgeMask;
31
31
  (function (HalfEdgeMask) {
32
- // REMARK: Various mask names are COMMENTED here for reference to native legacy code.
33
- // CONSTU_MASK = 0x00000004,
34
- // CONSTV_MASK = 0x00000008,
35
- // USEAM_MASK = 0x00000010,
36
- // VSEAM_MASK = 0x00000020,
37
- // BOUNDARY_VERTEX_MASK = 0x00000040,
38
- // PRIMARY_VERTEX_MASK = 0x00000080,
39
- // DIRECTED_EDGE_MASK = 0x00000100,
40
32
  /**
41
33
  * Mask commonly set consistently around exterior faces.
42
34
  * * A boundary edge with interior to one side, exterior to the other, will have EXTERIOR only on the outside.
@@ -59,22 +51,22 @@ export var HalfEdgeMask;
59
51
  * BOUNDARY_EDGE nor EXTERIOR_EDGE.
60
52
  */
61
53
  HalfEdgeMask[HalfEdgeMask["PRIMARY_EDGE"] = 4] = "PRIMARY_EDGE";
62
- /** Mask used for low level searches to identify previously-visited nodes. */
63
- HalfEdgeMask[HalfEdgeMask["VISITED"] = 16] = "VISITED";
54
+ /** Mask set on both sides of a bridge edge added by algorithms to join loops. */
55
+ HalfEdgeMask[HalfEdgeMask["BRIDGE_EDGE"] = 8] = "BRIDGE_EDGE";
56
+ /** Mask set on both sides of an edge added during graph regularization. */
57
+ HalfEdgeMask[HalfEdgeMask["REGULARIZED_EDGE"] = 16] = "REGULARIZED_EDGE";
64
58
  /** Mask applied to triangles by earcut triangulator. */
65
59
  HalfEdgeMask[HalfEdgeMask["TRIANGULATED_FACE"] = 256] = "TRIANGULATED_FACE";
66
60
  /** Mask applied in a face with 2 edges. */
67
61
  HalfEdgeMask[HalfEdgeMask["NULL_FACE"] = 512] = "NULL_FACE";
62
+ /** Temporary mask used for low level searches to identify previously-visited nodes. */
63
+ HalfEdgeMask[HalfEdgeMask["VISITED"] = 65536] = "VISITED";
68
64
  /** No mask bits. */
69
65
  HalfEdgeMask[HalfEdgeMask["NULL_MASK"] = 0] = "NULL_MASK";
70
66
  /** The "upper 12" bits of 32 bit integer reserved for grab/drop. */
71
67
  HalfEdgeMask[HalfEdgeMask["ALL_GRAB_DROP_MASKS"] = 4293918720] = "ALL_GRAB_DROP_MASKS";
72
68
  /** All mask bits */
73
69
  HalfEdgeMask[HalfEdgeMask["ALL_MASK"] = 4294967295] = "ALL_MASK";
74
- // informal convention on preassigned mask bit numbers:
75
- // byte0 (EXTERIOR, BOUNDARY_EDGE, PRIMARY_EDGE) -- edge properties
76
- // byte1 (VISITED, VISIT_A, WORK_MASK0, WORK_MASK1) -- temp masks for algorithms.
77
- // byte2 (TRIANGULATED_FACE, NULL_FACE) -- face properties.
78
70
  })(HalfEdgeMask || (HalfEdgeMask = {}));
79
71
  /**
80
72
  * A HalfEdge is "one side of an edge" in a structure of faces, edges and vertices. From a node there are
@@ -270,6 +262,37 @@ export class HalfEdge {
270
262
  }
271
263
  return newA;
272
264
  }
265
+ /**
266
+ * Reverse of [[splitEdge]]: remove the vertex at `doomed` and merge its two incident edges.
267
+ * @param doomed one of two nodes added by [[splitEdge]]. These nodes should form a vertex loop of two nodes.
268
+ * On successful return this node and its mate are isolated.
269
+ * @param checkParallel whether to check that the doomed edge and the preceding edge in its face loop are parallel.
270
+ * When passing `true` the assumption is that edge geometry is linear. If nonlinear edge geometry is attached, the
271
+ * caller should a) verify that the geometry on either side of the doomed vertex can be merged, and if so, they
272
+ * should b) call this method passing `false`, and c) adjust the geometry of the returned edge and its edge mate
273
+ * as appropriate.
274
+ * @returns the former (surviving) face predecessor of `doomed`, or undefined if the edge can't be healed.
275
+ */
276
+ static healEdge(doomed, checkParallel = true) {
277
+ if (doomed.isIsolatedEdge)
278
+ return undefined;
279
+ const doomed1 = doomed.vertexSuccessor;
280
+ if (doomed1.vertexSuccessor !== doomed)
281
+ return undefined; // v-loop not a 2-cycle
282
+ if (checkParallel && !doomed.vectorToFaceSuccessor().isParallelTo(doomed.facePredecessor.vectorToFaceSuccessor(), false, true))
283
+ return undefined; // removing this vertex does not leave a straight edge behind
284
+ const fPred = doomed.facePredecessor;
285
+ const fSucc = doomed.faceSuccessor;
286
+ const fPred1 = doomed1.facePredecessor;
287
+ const fSucc1 = doomed1.faceSuccessor;
288
+ this.setFaceLinks(fPred, fSucc);
289
+ this.setFaceLinks(fPred1, fSucc1);
290
+ this.setEdgeMates(fPred, fPred1);
291
+ this.setFaceLinks(doomed, doomed1);
292
+ this.setFaceLinks(doomed1, doomed);
293
+ this.setEdgeMates(doomed, doomed1);
294
+ return fPred;
295
+ }
273
296
  /**
274
297
  * Create a new sliver face "inside" an existing edge.
275
298
  * * This creates two nodes that are each face predecessor and successor to the other.
@@ -297,14 +320,14 @@ export class HalfEdge {
297
320
  newB.copyDataFrom(baseB, true, true, false, false);
298
321
  return newA;
299
322
  }
300
- /** Edge property masks. */
323
+ /** Masks copied when an edge is split. */
301
324
  static _edgePropertyMasks = [
302
- HalfEdgeMask.BOUNDARY_EDGE, HalfEdgeMask.EXTERIOR, HalfEdgeMask.PRIMARY_EDGE, HalfEdgeMask.NULL_FACE,
325
+ HalfEdgeMask.EXTERIOR, HalfEdgeMask.BOUNDARY_EDGE, HalfEdgeMask.PRIMARY_EDGE, HalfEdgeMask.BRIDGE_EDGE, HalfEdgeMask.REGULARIZED_EDGE, HalfEdgeMask.NULL_FACE
303
326
  ];
304
327
  /**
305
328
  * Copy "edge based" content of `fromNode` to `toNode`:
306
329
  * * edgeTag
307
- * * masks EXTERIOR, BOUNDARY_EDGE, NULL_FACE, PRIMARY_EDGE
330
+ * * edge masks
308
331
  */
309
332
  static transferEdgeProperties(fromNode, toNode) {
310
333
  toNode.edgeTag = fromNode.edgeTag;
@@ -477,7 +500,7 @@ export class HalfEdge {
477
500
  /**
478
501
  * Returns the number of nodes that match (or do not match) the given mask value around this face loop.
479
502
  * @param mask the mask to check.
480
- * @param value true for mask match and false for mask not match.
503
+ * @param value true for mask match and false for mask not match. Default is `true`.
481
504
  */
482
505
  countMaskAroundFace(mask, value = true) {
483
506
  let count = 0;
@@ -524,16 +547,17 @@ export class HalfEdge {
524
547
  }
525
548
  /**
526
549
  * Returns the first node that matches (or does not match) the given mask value around this vertex loop, starting
527
- * with the instance node and proceeding via vertex successors.
550
+ * with the instance node and proceeding via `vertexSuccessor`.
528
551
  * @param mask the mask to check.
529
- * @param value true for mask match and false for mask not match.
552
+ * @param value true for mask match and false for mask not match. Default is `true`.
553
+ * @param reverse if true, search in reverse order via `vertexPredecessor`. Default is `false`.
530
554
  */
531
- findMaskAroundVertex(mask, value = true) {
555
+ findMaskAroundVertex(mask, value = true, reverse = false) {
532
556
  let node = this;
533
557
  do {
534
558
  if (node.isMaskSet(mask) === value)
535
559
  return node;
536
- node = node.vertexSuccessor;
560
+ node = reverse ? node.vertexPredecessor : node.vertexSuccessor;
537
561
  } while (node !== this);
538
562
  return undefined;
539
563
  }
@@ -541,7 +565,7 @@ export class HalfEdge {
541
565
  * Returns the first node that matches (or does not match) the given mask value around this face loop, starting
542
566
  * with the instance node and proceeding via face successors.
543
567
  * @param mask the mask to check.
544
- * @param value true for mask match and false for mask not match.
568
+ * @param value true for mask match and false for mask not match. Default is `true`.
545
569
  */
546
570
  findMaskAroundFace(mask, value = true) {
547
571
  let node = this;
@@ -653,6 +677,10 @@ export class HalfEdge {
653
677
  predA._faceSuccessor = nodeB;
654
678
  }
655
679
  }
680
+ /** Return whether the edge is dangling at its base. */
681
+ get isDangling() {
682
+ return this.edgeMate.faceSuccessor === this;
683
+ }
656
684
  /**
657
685
  * Pinch this half edge out of its base vertex loop.
658
686
  * @return the surviving HalfEdge in the vertex loop or `undefined` if the instance HalfEdge is already dangling.
@@ -856,7 +884,10 @@ export class HalfEdge {
856
884
  this.yankFromVertexLoop();
857
885
  mate.yankFromVertexLoop();
858
886
  }
859
- /** Specify whether this edge is isolated from the rest of the graph. */
887
+ /**
888
+ * Specify whether this edge is isolated from the rest of the graph.
889
+ * * Both edge mates of an isolated edge return true for [[isDangling]].
890
+ */
860
891
  get isIsolatedEdge() {
861
892
  return this === this.vertexSuccessor && this.edgeMate === this.edgeMate.vertexSuccessor;
862
893
  }
@@ -904,6 +935,71 @@ export class HalfEdge {
904
935
  distanceXYZ(other) {
905
936
  return Geometry.distanceXYZXYZ(this.x, this.y, this.z, other.x, other.y, other.z);
906
937
  }
938
+ /**
939
+ * Search around the instance's face loop for nodes with the specified mask value.
940
+ * * Returned nodes satisfy `node.isMaskSet(mask) === value`.
941
+ * @param mask target mask.
942
+ * @param value target boolean value for mask on half edges (default `true`).
943
+ * @param result optional array to be cleared, populated with masked nodes, and returned.
944
+ * @return array of masked half edges
945
+ */
946
+ collectMaskedEdgesAroundFace(mask, value = true, result) {
947
+ if (result === undefined)
948
+ result = [];
949
+ else
950
+ result.length = 0;
951
+ let node = this;
952
+ do {
953
+ if (node.isMaskSet(mask) === value)
954
+ result.push(node);
955
+ node = node.faceSuccessor;
956
+ } while (node !== this);
957
+ return result;
958
+ }
959
+ /**
960
+ * Announce edges in the face loop, starting with the instance and proceeding in a `faceSuccessor` traversal.
961
+ * @param announceEdge function to call at each edge
962
+ */
963
+ announceEdgesInFace(announceEdge) {
964
+ let node = this;
965
+ do {
966
+ announceEdge(node);
967
+ node = node.faceSuccessor;
968
+ } while (node !== this);
969
+ }
970
+ /**
971
+ * Announce edges in the super face loop, starting with the instance.
972
+ * * A super face admits a `faceSuccessor` traversal, where the next edge at the far vertex is the first one lacking `skipMask` in a `vertexPredecessor` traversal.
973
+ * @param skipMask mask on edges to skip.
974
+ * @param announceEdge function to call at each edge that is not skipped.
975
+ * @param announceSkipped optional function to call at each edge that is skipped.
976
+ * @return whether a super face was found. Specifically, if a vertex loop has all edges with `skipMask` set, the return value is `false`.
977
+ */
978
+ announceEdgesInSuperFace(skipMask, announceEdge, announceSkipped) {
979
+ const maxIter = 1000; // safeguard against infinite loops
980
+ let iter = 0;
981
+ const findNextNodeAroundVertex = (he) => {
982
+ let vNode = he;
983
+ do {
984
+ if (!vNode.isMaskSet(skipMask))
985
+ return vNode;
986
+ announceSkipped?.(vNode);
987
+ vNode = vNode.vertexPredecessor;
988
+ } while (vNode !== he);
989
+ return undefined;
990
+ };
991
+ const firstNode = findNextNodeAroundVertex(this);
992
+ if (!firstNode)
993
+ return false;
994
+ let node = firstNode;
995
+ do {
996
+ announceEdge(node);
997
+ node = findNextNodeAroundVertex(node.faceSuccessor);
998
+ if (!node)
999
+ return false;
1000
+ } while (node !== firstNode && iter++ < maxIter);
1001
+ return iter < maxIter;
1002
+ }
907
1003
  /**
908
1004
  * Evaluate `f(node)` at each node around `this` node's face loop. Collect the function values.
909
1005
  * @param f optional node function. If `undefined`, collect the nodes themselves.
@@ -1181,16 +1277,37 @@ export class HalfEdge {
1181
1277
  this.y = source.y;
1182
1278
  this.z = source.z;
1183
1279
  }
1184
- if (copyVertexData) {
1280
+ if (copyVertexData)
1185
1281
  this.i = source.i;
1186
- }
1187
- if (copyEdgeData) {
1282
+ if (copyEdgeData)
1188
1283
  HalfEdge.transferEdgeProperties(source, this);
1189
- this.edgeTag = source.edgeTag;
1190
- }
1191
- if (copyFaceData) {
1284
+ if (copyFaceData)
1192
1285
  this.faceTag = source.faceTag;
1286
+ }
1287
+ /**
1288
+ * Is the instance's face loop a split-washer type face?
1289
+ * * A split-washer face contains at least one bridge edge.
1290
+ * * A bridge edge and its edge mate have the same `bridgeMask` and live in the same face loop.
1291
+ * * By connecting hole/outer loops with bridge edges, a split-washer face can represent a parity region.
1292
+ * @param bridgeMask mask preset on bridge edges (default is [[HalfEdgeMask.BRIDGE_EDGE]]).
1293
+ */
1294
+ isSplitWasherFace(bridgeMask = HalfEdgeMask.BRIDGE_EDGE) {
1295
+ if (!this.countMaskAroundFace(HalfEdgeMask.BRIDGE_EDGE))
1296
+ return false;
1297
+ const bridges = new OrderedSet((a, b) => a.id - b.id);
1298
+ let node = this;
1299
+ do {
1300
+ if (node.isMaskSet(bridgeMask))
1301
+ bridges.add(node);
1302
+ node = node.faceSuccessor;
1303
+ } while (node !== this);
1304
+ if (bridges.size === 0)
1305
+ return false;
1306
+ for (const bridge of bridges) {
1307
+ if (!bridges.has(bridge.edgeMate) || !bridge.edgeMate.isMaskSet(bridgeMask))
1308
+ return false;
1193
1309
  }
1310
+ return true;
1194
1311
  }
1195
1312
  }
1196
1313
  /**
@@ -1210,7 +1327,7 @@ export class HalfEdgeGraph {
1210
1327
  }
1211
1328
  /**
1212
1329
  * Ask for a mask (from the graph's free pool) for caller's use.
1213
- * * Optionally clear the mask throughout the graph.
1330
+ * @param clearInAllHalfEdges optionally clear the mask throughout the graph (default `true`).
1214
1331
  */
1215
1332
  grabMask(clearInAllHalfEdges = true) {
1216
1333
  const mask = this._maskManager.grabMask();