@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.
- package/lib/cjs/Geometry.d.ts +1 -1
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineSurface.js +0 -2
- package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +7 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +11 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveFactory.d.ts +3 -2
- package/lib/cjs/curve/CurveFactory.d.ts.map +1 -1
- package/lib/cjs/curve/CurveFactory.js +6 -5
- package/lib/cjs/curve/CurveFactory.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +3 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +6 -1
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +7 -0
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +11 -0
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts +2 -0
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +4 -0
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +7 -0
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +15 -3
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
- package/lib/cjs/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +25 -3
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +102 -22
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.d.ts +4 -3
- package/lib/cjs/curve/Query/StrokeCountChain.d.ts.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountChain.js +20 -9
- package/lib/cjs/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.d.ts +1 -1
- package/lib/cjs/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/cjs/curve/RegionMomentsXY.js +6 -3
- package/lib/cjs/curve/RegionMomentsXY.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +23 -14
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +60 -21
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +9 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +91 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
- package/lib/cjs/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/cjs/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js +1 -1
- package/lib/cjs/geometry3d/AngleSweep.js.map +1 -1
- package/lib/cjs/geometry3d/Ellipsoid.js +1 -1
- package/lib/cjs/geometry3d/Ellipsoid.js.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts +9 -0
- package/lib/cjs/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/cjs/geometry3d/IndexedXYZCollection.js +14 -0
- package/lib/cjs/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.d.ts +7 -9
- package/lib/cjs/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Ray3d.js +12 -22
- package/lib/cjs/geometry3d/Ray3d.js.map +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.d.ts +1 -4
- package/lib/cjs/geometry3d/SortablePolygon.d.ts.map +1 -1
- package/lib/cjs/geometry3d/SortablePolygon.js +48 -43
- package/lib/cjs/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +3 -3
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/cjs/solid/Sphere.js +1 -1
- package/lib/cjs/solid/Sphere.js.map +1 -1
- package/lib/cjs/solid/SweepContour.d.ts +1 -1
- package/lib/cjs/solid/SweepContour.js +1 -1
- package/lib/cjs/solid/SweepContour.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +64 -14
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +149 -32
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts +2 -2
- package/lib/cjs/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
- package/lib/cjs/topology/HalfEdgeGraphSearch.js +2 -2
- package/lib/cjs/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/cjs/topology/RegularizeFace.d.ts.map +1 -1
- package/lib/cjs/topology/RegularizeFace.js +2 -1
- package/lib/cjs/topology/RegularizeFace.js.map +1 -1
- package/lib/esm/Geometry.d.ts +1 -1
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineSurface.js +0 -2
- package/lib/esm/bspline/BSplineSurface.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +7 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +11 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveFactory.d.ts +3 -2
- package/lib/esm/curve/CurveFactory.d.ts.map +1 -1
- package/lib/esm/curve/CurveFactory.js +6 -5
- package/lib/esm/curve/CurveFactory.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +3 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +6 -1
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +7 -0
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +11 -0
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts +2 -0
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +4 -0
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +7 -0
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +15 -3
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.d.ts.map +1 -1
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js +28 -4
- package/lib/esm/curve/Query/ConsolidateAdjacentPrimitivesContext.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts +25 -3
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +104 -24
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.d.ts +4 -3
- package/lib/esm/curve/Query/StrokeCountChain.d.ts.map +1 -1
- package/lib/esm/curve/Query/StrokeCountChain.js +20 -9
- package/lib/esm/curve/Query/StrokeCountChain.js.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.d.ts +1 -1
- package/lib/esm/curve/RegionMomentsXY.d.ts.map +1 -1
- package/lib/esm/curve/RegionMomentsXY.js +6 -3
- package/lib/esm/curve/RegionMomentsXY.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +23 -14
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +60 -21
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +9 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +91 -2
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.d.ts +2 -2
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js +6 -6
- package/lib/esm/curve/internalContexts/CurveCurveCloseApproachXY.js.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts +1 -1
- package/lib/esm/geometry3d/AngleSweep.d.ts.map +1 -1
- package/lib/esm/geometry3d/AngleSweep.js +1 -1
- package/lib/esm/geometry3d/AngleSweep.js.map +1 -1
- package/lib/esm/geometry3d/Ellipsoid.js +1 -1
- package/lib/esm/geometry3d/Ellipsoid.js.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts +9 -0
- package/lib/esm/geometry3d/IndexedXYZCollection.d.ts.map +1 -1
- package/lib/esm/geometry3d/IndexedXYZCollection.js +14 -0
- package/lib/esm/geometry3d/IndexedXYZCollection.js.map +1 -1
- package/lib/esm/geometry3d/Ray3d.d.ts +7 -9
- package/lib/esm/geometry3d/Ray3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Ray3d.js +12 -22
- package/lib/esm/geometry3d/Ray3d.js.map +1 -1
- package/lib/esm/geometry3d/SortablePolygon.d.ts +1 -4
- package/lib/esm/geometry3d/SortablePolygon.d.ts.map +1 -1
- package/lib/esm/geometry3d/SortablePolygon.js +48 -43
- package/lib/esm/geometry3d/SortablePolygon.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +3 -3
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/solid/Sphere.js +1 -1
- package/lib/esm/solid/Sphere.js.map +1 -1
- package/lib/esm/solid/SweepContour.d.ts +1 -1
- package/lib/esm/solid/SweepContour.js +1 -1
- package/lib/esm/solid/SweepContour.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +64 -14
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +149 -32
- package/lib/esm/topology/Graph.js.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.d.ts +2 -2
- package/lib/esm/topology/HalfEdgeGraphSearch.d.ts.map +1 -1
- package/lib/esm/topology/HalfEdgeGraphSearch.js +2 -2
- package/lib/esm/topology/HalfEdgeGraphSearch.js.map +1 -1
- package/lib/esm/topology/RegularizeFace.d.ts.map +1 -1
- package/lib/esm/topology/RegularizeFace.js +2 -1
- package/lib/esm/topology/RegularizeFace.js.map +1 -1
- 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
|
|
63
|
-
HalfEdgeMask[HalfEdgeMask["
|
|
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
|
-
/**
|
|
323
|
+
/** Masks copied when an edge is split. */
|
|
301
324
|
static _edgePropertyMasks = [
|
|
302
|
-
HalfEdgeMask.
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
-
*
|
|
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();
|