@itwin/core-geometry 5.12.0-dev.12 → 5.12.0-dev.14
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/bspline/AkimaCurve3d.d.ts +5 -0
- package/lib/cjs/bspline/AkimaCurve3d.d.ts.map +1 -1
- package/lib/cjs/bspline/AkimaCurve3d.js +8 -0
- package/lib/cjs/bspline/AkimaCurve3d.js.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.d.ts +5 -0
- package/lib/cjs/bspline/InterpolationCurve3d.d.ts.map +1 -1
- package/lib/cjs/bspline/InterpolationCurve3d.js +8 -0
- package/lib/cjs/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +2 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +5 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +2 -0
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +5 -0
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +60 -6
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +241 -79
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts +2 -3
- package/lib/cjs/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +4 -5
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js +82 -58
- package/lib/cjs/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/geometry3d/Transform.d.ts +1 -4
- package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Transform.js +1 -4
- package/lib/cjs/geometry3d/Transform.js.map +1 -1
- package/lib/cjs/numerics/Polynomials.d.ts +3 -3
- package/lib/cjs/numerics/Polynomials.js +5 -5
- package/lib/cjs/numerics/Polynomials.js.map +1 -1
- package/lib/cjs/topology/Graph.d.ts +5 -2
- package/lib/cjs/topology/Graph.d.ts.map +1 -1
- package/lib/cjs/topology/Graph.js +5 -2
- package/lib/cjs/topology/Graph.js.map +1 -1
- package/lib/esm/bspline/AkimaCurve3d.d.ts +5 -0
- package/lib/esm/bspline/AkimaCurve3d.d.ts.map +1 -1
- package/lib/esm/bspline/AkimaCurve3d.js +8 -0
- package/lib/esm/bspline/AkimaCurve3d.js.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.d.ts +5 -0
- package/lib/esm/bspline/InterpolationCurve3d.d.ts.map +1 -1
- package/lib/esm/bspline/InterpolationCurve3d.js +8 -0
- package/lib/esm/bspline/InterpolationCurve3d.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +2 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +5 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +2 -0
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +5 -0
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +60 -6
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +241 -79
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts +2 -3
- package/lib/esm/curve/RegionOpsClassificationSweeps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +4 -5
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js +82 -58
- package/lib/esm/curve/internalContexts/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/geometry3d/Transform.d.ts +1 -4
- package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
- package/lib/esm/geometry3d/Transform.js +1 -4
- package/lib/esm/geometry3d/Transform.js.map +1 -1
- package/lib/esm/numerics/Polynomials.d.ts +3 -3
- package/lib/esm/numerics/Polynomials.js +5 -5
- package/lib/esm/numerics/Polynomials.js.map +1 -1
- package/lib/esm/topology/Graph.d.ts +5 -2
- package/lib/esm/topology/Graph.d.ts.map +1 -1
- package/lib/esm/topology/Graph.js +5 -2
- package/lib/esm/topology/Graph.js.map +1 -1
- package/package.json +5 -5
|
@@ -378,13 +378,23 @@ class RegionOps {
|
|
|
378
378
|
const localToWorld = FrameBuilder_1.FrameBuilder.createRightHandedFrame(undefined, xyRegion);
|
|
379
379
|
return localToWorld ? localToWorld.origin.z : 0;
|
|
380
380
|
}
|
|
381
|
+
/** Convert overlapping enums, from public to internal. */
|
|
382
|
+
static convertToRegionGroupOpType(op) {
|
|
383
|
+
if (RegionBinaryOpType.Parity === op)
|
|
384
|
+
return RegionOpsClassificationSweeps_1.RegionGroupOpType.Parity;
|
|
385
|
+
if (RegionBinaryOpType.Intersection === op)
|
|
386
|
+
return RegionOpsClassificationSweeps_1.RegionGroupOpType.Intersection;
|
|
387
|
+
return RegionOpsClassificationSweeps_1.RegionGroupOpType.Union;
|
|
388
|
+
}
|
|
381
389
|
/**
|
|
382
390
|
* Return areas defined by a boolean operation.
|
|
383
391
|
* @note For best results, input regions should have correctly oriented loops. See [[sortOuterAndHoleLoopsXY]].
|
|
384
392
|
* @note A common use case of this method is to split (a region with) overlapping loops into a `UnionRegion` with
|
|
385
393
|
* adjacent `Loop`s: `regionOut = RegionOps.regionBooleanXY(regionIn, undefined, RegionBinaryOpType.Union)`.
|
|
386
|
-
*
|
|
387
|
-
*
|
|
394
|
+
* Such a union can be further simplified by passing the option `RegionBooleanXYOptions.simplifyUnion = true`.
|
|
395
|
+
* @note By default, this method does not discover holes implicitly formed by input loops. For example, the union of
|
|
396
|
+
* the four trapezoids that comprise a picture frame is not returned as a [[ParityRegion]] unless the option
|
|
397
|
+
* `simplifyUnion = true`.
|
|
388
398
|
* @param loopsA first set of loops (treated as a union)
|
|
389
399
|
* @param loopsB second set of loops (treated as a union)
|
|
390
400
|
* @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
|
|
@@ -392,48 +402,70 @@ class RegionOps {
|
|
|
392
402
|
* @returns a region resulting from merging input loops and the boolean operation.
|
|
393
403
|
*/
|
|
394
404
|
static regionBooleanXY(loopsA, loopsB, operation, mergeToleranceOrOptions = Geometry_1.Geometry.smallMetricDistance) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
mergeTolerance = mergeToleranceOrOptions.mergeTolerance ?? Geometry_1.Geometry.smallMetricDistance;
|
|
403
|
-
simplifyUnion = mergeToleranceOrOptions.simplifyUnion ?? false;
|
|
404
|
-
}
|
|
405
|
-
let result = UnionRegion_1.UnionRegion.create();
|
|
406
|
-
const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(RegionOpsClassificationSweeps_1.RegionGroupOpType.Union, RegionOpsClassificationSweeps_1.RegionGroupOpType.Union);
|
|
405
|
+
const optionIsNumber = typeof mergeToleranceOrOptions === "number";
|
|
406
|
+
const mergeTolerance = optionIsNumber ? mergeToleranceOrOptions : mergeToleranceOrOptions.mergeTolerance ?? Geometry_1.Geometry.smallMetricDistance;
|
|
407
|
+
const simplifyUnion = optionIsNumber ? false : mergeToleranceOrOptions.simplifyUnion ?? false;
|
|
408
|
+
const operationGroupA = optionIsNumber ? RegionOpsClassificationSweeps_1.RegionGroupOpType.Union : RegionOps.convertToRegionGroupOpType(mergeToleranceOrOptions.operationGroupA);
|
|
409
|
+
const operationGroupB = optionIsNumber ? RegionOpsClassificationSweeps_1.RegionGroupOpType.Union : RegionOps.convertToRegionGroupOpType(mergeToleranceOrOptions.operationGroupB);
|
|
410
|
+
let result;
|
|
411
|
+
const context = RegionOpsClassificationSweeps_1.RegionBooleanContext.create(operationGroupA, operationGroupB);
|
|
407
412
|
context.addMembers(loopsA, loopsB);
|
|
408
413
|
context.annotateAndMergeCurvesInGraph(mergeTolerance);
|
|
409
414
|
const bridgeMask = Graph_1.HalfEdgeMask.BRIDGE_EDGE;
|
|
410
415
|
const visitMask = context.graph.grabMask(false);
|
|
416
|
+
// use our own outMask: we cannot use EXTERIOR as sweep clears it before processing each component
|
|
417
|
+
const outMask = simplifyUnion ? context.graph.grabMask(false) : Graph_1.HalfEdgeMask.NULL_MASK;
|
|
418
|
+
const outSeeds = simplifyUnion ? [] : undefined;
|
|
419
|
+
context.graph.clearMask(visitMask | outMask);
|
|
411
420
|
const range = context.groupA.range().union(context.groupB.range());
|
|
412
421
|
const areaTol = this.computeXYAreaTolerance(range, mergeTolerance);
|
|
413
422
|
const z = RegionOps.getZCoordinate(operation === RegionBinaryOpType.BMinusA ? loopsB : loopsA);
|
|
414
423
|
const options = { compress: true, closureTol: mergeTolerance, bridgeMask, visitMask, z };
|
|
424
|
+
let numFacesIn = 0;
|
|
415
425
|
context.runClassificationSweep(operation, (_graph, face, faceType, area) => {
|
|
416
426
|
// ignore danglers and null faces, but not 2-edge "banana" faces with nonzero area
|
|
417
427
|
if (face.countEdgesAroundFace() < 2)
|
|
418
428
|
return;
|
|
419
429
|
if (Math.abs(area) < areaTol)
|
|
420
430
|
return;
|
|
421
|
-
if (
|
|
431
|
+
if (simplifyUnion) { // process the outer/negative faces later
|
|
432
|
+
if (faceType === 1) {
|
|
433
|
+
numFacesIn++;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
face.setMaskAroundFace(outMask);
|
|
437
|
+
outSeeds?.push(face);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
else if (faceType === 1) { // collect the inner faces now
|
|
422
441
|
const loopOrParityRegion = PlanarSubdivision_1.PlanarSubdivision.createLoopOrParityRegionInFace(face, options);
|
|
423
|
-
if (loopOrParityRegion)
|
|
424
|
-
result
|
|
442
|
+
if (loopOrParityRegion) {
|
|
443
|
+
if (!result)
|
|
444
|
+
result = UnionRegion_1.UnionRegion.create();
|
|
445
|
+
if (result.tryAddChild(loopOrParityRegion))
|
|
446
|
+
numFacesIn++;
|
|
447
|
+
}
|
|
425
448
|
}
|
|
426
449
|
});
|
|
427
|
-
|
|
428
|
-
if (simplifyUnion &&
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
450
|
+
// the outer faces are marked; now we collect their boundary super face loops and sort them
|
|
451
|
+
if (simplifyUnion && numFacesIn > 0 && outSeeds && outSeeds.length > 0) {
|
|
452
|
+
context.graph.clearMask(visitMask);
|
|
453
|
+
const outLoops = [];
|
|
454
|
+
for (const outSeed of outSeeds) {
|
|
455
|
+
const superFace = [];
|
|
456
|
+
const skipEdge = (he) => he.isMaskSet(visitMask) || !he.isMaskSet(outMask) || he.edgeMate.isMaskSet(outMask);
|
|
457
|
+
const announceEdge = (he) => superFace.push(he);
|
|
458
|
+
if (outSeed.announceEdgesInSuperFace(skipEdge, announceEdge)) {
|
|
459
|
+
superFace.forEach((he) => he.setMask(visitMask));
|
|
460
|
+
const outLoop = PlanarSubdivision_1.PlanarSubdivision.createLoopInFace(superFace, options);
|
|
461
|
+
if (outLoop)
|
|
462
|
+
outLoops.push(outLoop);
|
|
463
|
+
}
|
|
434
464
|
}
|
|
465
|
+
result = this.sortOuterAndHoleLoopsXY(outLoops);
|
|
435
466
|
}
|
|
436
|
-
|
|
467
|
+
context.graph.dropMask(visitMask | outMask);
|
|
468
|
+
return result ? this.simplifyRegion(result) : undefined;
|
|
437
469
|
}
|
|
438
470
|
/**
|
|
439
471
|
* Return a polyface whose facets are a boolean operation between the input regions.
|
|
@@ -750,86 +782,216 @@ class RegionOps {
|
|
|
750
782
|
return SortablePolygon_1.SortablePolygon.sortAsAnyRegion(loopAndArea);
|
|
751
783
|
}
|
|
752
784
|
/**
|
|
753
|
-
*
|
|
754
|
-
*
|
|
785
|
+
* Compare two edges' geometry from CurveLocationDetail edge tags.
|
|
786
|
+
* @returns an object with following properties:
|
|
787
|
+
* * sameCurves: whether the edges' curve definitions are equivalent.
|
|
788
|
+
* * reversedCurves: whether the edges' curve definitions are equivalent after reversing one of them.
|
|
789
|
+
* * senseEdge0/1: whether the topological edge is oriented in the same direction as the curve geometry, or the opposite direction.
|
|
790
|
+
*/
|
|
791
|
+
static getEdgeGeometry(edge0, edge1) {
|
|
792
|
+
let sameCurves = false;
|
|
793
|
+
let reversedCurves = false;
|
|
794
|
+
let senseEdge0 = false;
|
|
795
|
+
let senseEdge1 = false;
|
|
796
|
+
if (edge0.edgeTag instanceof CurveLocationDetail_1.CurveLocationDetail && edge0.edgeTag.curve !== undefined && edge0.edgeTag.isInterval() && edge0.sortData &&
|
|
797
|
+
edge1.edgeTag instanceof CurveLocationDetail_1.CurveLocationDetail && edge1.edgeTag.curve !== undefined && edge1.edgeTag.isInterval() && edge1.sortData) {
|
|
798
|
+
sameCurves = edge0.edgeTag.curve === edge1.edgeTag.curve || edge0.edgeTag.curve.isAlmostEqual(edge1.edgeTag.curve);
|
|
799
|
+
reversedCurves = !sameCurves && edge0.edgeTag.curve.isAlmostEqual(edge1.edgeTag.curve.clone().reverse());
|
|
800
|
+
senseEdge0 = edge0.sortData > 0;
|
|
801
|
+
senseEdge1 = edge1.sortData > 0;
|
|
802
|
+
}
|
|
803
|
+
return { sameCurves, reversedCurves, senseEdge0, senseEdge1 };
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Compare two edges' orientations. They do not have to be adjacent.
|
|
807
|
+
* * Requires CurveLocationDetail edge tags.
|
|
808
|
+
* @returns an object with following properties:
|
|
809
|
+
* * diametric: whether edges have same/reversed curves and are oriented diametrically opposite each other.
|
|
810
|
+
* * reversedCurves: whether the underlying curve definitions are reversed.
|
|
811
|
+
* * senseEdge0/1: whether the topological edge is oriented in the same direction as the curve geometry, or the opposite direction.
|
|
812
|
+
*/
|
|
813
|
+
static areEdgesDiametric(edge0, edge1) {
|
|
814
|
+
let diametric = false;
|
|
815
|
+
let reversedCurves = false;
|
|
816
|
+
let senseEdge0 = false;
|
|
817
|
+
let senseEdge1 = false;
|
|
818
|
+
if (edge0 !== edge1) {
|
|
819
|
+
const data = RegionOps.getEdgeGeometry(edge0, edge1);
|
|
820
|
+
reversedCurves = data.reversedCurves;
|
|
821
|
+
senseEdge0 = data.senseEdge0;
|
|
822
|
+
senseEdge1 = data.senseEdge1;
|
|
823
|
+
diametric = (data.sameCurves && (senseEdge0 !== senseEdge1)) || (reversedCurves && (senseEdge0 === senseEdge1));
|
|
824
|
+
}
|
|
825
|
+
return { diametric, reversedCurves, senseEdge0, senseEdge1 };
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Determine if the edges at a vertex were created by splitting an edge or null face.
|
|
829
|
+
* * Requires CurveLocationDetail edge tags.
|
|
830
|
+
* @param he an edge created by the split operation.
|
|
831
|
+
* @param vs another edge at the same vertex. If undefined, use `vs = he.vertexSuccessor` and check for a
|
|
832
|
+
* degree-2 vertex (e.g., split edge); otherwise, ignore the degree check (e.g., inputs are a null face pair).
|
|
833
|
+
*/
|
|
834
|
+
static isHealableEdgeOrNullFace(he, vs) {
|
|
835
|
+
if (vs) {
|
|
836
|
+
if (!he.findAroundVertex(vs))
|
|
837
|
+
return false;
|
|
838
|
+
}
|
|
839
|
+
else {
|
|
840
|
+
vs = he.vertexSuccessor;
|
|
841
|
+
if (vs.vertexSuccessor !== he)
|
|
842
|
+
return false; // not a split edge
|
|
843
|
+
}
|
|
844
|
+
const directionData = RegionOps.areEdgesDiametric(he, vs);
|
|
845
|
+
if (!directionData.diametric)
|
|
846
|
+
return false;
|
|
847
|
+
const heVertexFraction = directionData.senseEdge0 ? he.edgeTag.fraction : he.edgeTag.fraction1;
|
|
848
|
+
let vsVertexFraction = directionData.senseEdge1 ? vs.edgeTag.fraction : vs.edgeTag.fraction1;
|
|
849
|
+
if (directionData.reversedCurves)
|
|
850
|
+
vsVertexFraction = 1.0 - vsVertexFraction;
|
|
851
|
+
return Geometry_1.Geometry.isSmallRelative(heVertexFraction - vsVertexFraction); // unrelated vertex fractions are not healable
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Determine if the vertex loop resulted from splitting a null face into two null faces (and thus can be healed).
|
|
855
|
+
* * Requires CurveLocationDetail edge tags.
|
|
856
|
+
* * If there are multiple null faces at the vertex (a null face bundle), they must be adjacent and positioned in
|
|
857
|
+
* diametrically opposite pairs, each of which resulted from splitting a null face. This implies there are exactly
|
|
858
|
+
* two non-null faces opposite each other in the vertex loop.
|
|
859
|
+
* @returns an object with properties:
|
|
860
|
+
* * isHealable: whether the input is a healable vertex loop in a null face bundle
|
|
861
|
+
* * nullFacePairs: if `isHealable` is true, an array of the matching null face pairs around the vertex.
|
|
862
|
+
*/
|
|
863
|
+
static isHealableNullFaceBundle(vertex) {
|
|
864
|
+
const nonNullFaceIndex = [];
|
|
865
|
+
const vertexLoop = [];
|
|
866
|
+
// lambda: null face detector, with curve check to rule out banana faces
|
|
867
|
+
const isNullFace = (face) => {
|
|
868
|
+
const fSucc = face.faceSuccessor;
|
|
869
|
+
return (fSucc.faceSuccessor === face) && RegionOps.areEdgesDiametric(face, fSucc).diametric;
|
|
870
|
+
};
|
|
871
|
+
vertex.announceEdgesAroundVertex((e) => {
|
|
872
|
+
if (!isNullFace(e))
|
|
873
|
+
nonNullFaceIndex.push(vertexLoop.length);
|
|
874
|
+
vertexLoop.push(e);
|
|
875
|
+
});
|
|
876
|
+
const degree = vertexLoop.length;
|
|
877
|
+
if (degree < 4 || nonNullFaceIndex.length !== 2 || Geometry_1.Geometry.modulo(degree, 2) > 0)
|
|
878
|
+
return { isHealable: false };
|
|
879
|
+
const iNonNull0 = nonNullFaceIndex[0];
|
|
880
|
+
if (nonNullFaceIndex[1] - iNonNull0 !== degree / 2)
|
|
881
|
+
return { isHealable: false };
|
|
882
|
+
const nullFacePairs = [];
|
|
883
|
+
for (let i = 1; i < degree / 2; i++) {
|
|
884
|
+
const iNullFace = Geometry_1.Geometry.modulo(iNonNull0 + i, degree);
|
|
885
|
+
const iMatchingNullFace = Geometry_1.Geometry.modulo(2 * iNonNull0 - iNullFace, degree);
|
|
886
|
+
if (!RegionOps.isHealableEdgeOrNullFace(vertexLoop[iNullFace], vertexLoop[iMatchingNullFace]))
|
|
887
|
+
return { isHealable: false };
|
|
888
|
+
nullFacePairs.push([vertexLoop[iNullFace], vertexLoop[iMatchingNullFace]]);
|
|
889
|
+
}
|
|
890
|
+
return { isHealable: true, nullFacePairs };
|
|
891
|
+
}
|
|
892
|
+
/** Heal a split edge by removing the redundant vertex loop and extending the surviving curve details. */
|
|
893
|
+
static healSplitEdgeAndCurve(v) {
|
|
894
|
+
const vs = v.vertexSuccessor;
|
|
895
|
+
const fPred = Graph_1.HalfEdge.healEdge(v, false);
|
|
896
|
+
if (!fPred)
|
|
897
|
+
return;
|
|
898
|
+
// lambda to extend the surviving node's curve interval. Inputs are on the same side of the healed edge.
|
|
899
|
+
const extendDetailInterval = (doomed, survivor) => {
|
|
900
|
+
const doomedData = RegionOps.getEdgeGeometry(doomed, survivor);
|
|
901
|
+
(0, core_bentley_1.assert)(doomedData.sameCurves || doomedData.reversedCurves, "expect related curves");
|
|
902
|
+
let newEndFraction = doomedData.senseEdge0 ? doomed.edgeTag.fraction1 : doomed.edgeTag.fraction;
|
|
903
|
+
if (doomedData.reversedCurves)
|
|
904
|
+
newEndFraction = 1.0 - newEndFraction;
|
|
905
|
+
const newEndPoint = doomedData.senseEdge0 ? doomed.edgeTag.point1 : doomed.edgeTag.point;
|
|
906
|
+
if (doomedData.senseEdge1)
|
|
907
|
+
survivor.edgeTag.captureFraction1Point1(newEndFraction, newEndPoint);
|
|
908
|
+
else
|
|
909
|
+
survivor.edgeTag.captureFractionPoint(newEndFraction, newEndPoint);
|
|
910
|
+
};
|
|
911
|
+
extendDetailInterval(v, fPred);
|
|
912
|
+
extendDetailInterval(vs, fPred.edgeMate);
|
|
913
|
+
}
|
|
914
|
+
/**
|
|
915
|
+
* Disconnect extraneous bridge edges, which remain in the graph as isolated edges.
|
|
755
916
|
* @param graph half edges to process.
|
|
756
|
-
* @param isBridgeEdge optional
|
|
757
|
-
* @param faceToArea optional
|
|
758
|
-
* @returns
|
|
759
|
-
* @internal
|
|
917
|
+
* @param isBridgeEdge optional callback to identify a bridge edge.
|
|
918
|
+
* @param faceToArea optional callback to compute face area.
|
|
919
|
+
* @returns array of surviving vertices formerly adjacent to the isolated bridge edges (e.g., for the caller to heal).
|
|
760
920
|
*/
|
|
761
|
-
static
|
|
921
|
+
static isolateExtraneousBridgeEdges(graph, isBridgeEdge, faceToArea) {
|
|
762
922
|
const toHeal = [];
|
|
763
923
|
const interiorBridges = [];
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
924
|
+
const isolateBridgeEdge = (edge) => {
|
|
925
|
+
if (!edge.isDangling)
|
|
926
|
+
toHeal.push(edge.vertexSuccessor);
|
|
927
|
+
if (!edge.edgeMate.isDangling)
|
|
928
|
+
toHeal.push(edge.edgeMate.vertexSuccessor);
|
|
929
|
+
edge.isolateEdge();
|
|
930
|
+
};
|
|
768
931
|
// isolate dangling bridges, bridges separating different faces, and "exterior" bridges in the negative area face
|
|
769
932
|
graph.announceEdges((_g, node) => {
|
|
770
933
|
if (isBridgeEdge(node)) {
|
|
771
|
-
if (node.isDangling || node.edgeMate.isDangling || !node.findAroundFace(node.edgeMate) || faceToArea(node) < 0.0)
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
node.isolateEdge();
|
|
775
|
-
}
|
|
776
|
-
else {
|
|
934
|
+
if (node.isDangling || node.edgeMate.isDangling || !node.findAroundFace(node.edgeMate) || faceToArea(node) < 0.0)
|
|
935
|
+
isolateBridgeEdge(node);
|
|
936
|
+
else
|
|
777
937
|
interiorBridges.push(node);
|
|
778
|
-
}
|
|
779
938
|
}
|
|
780
939
|
return true;
|
|
781
940
|
});
|
|
782
|
-
//
|
|
783
|
-
const
|
|
941
|
+
// lambda: check if a non-isolated interior bridge edge is extraneous, relying solely on face loop orientation (not HalfEdgeMasks!)
|
|
942
|
+
const isBridgeEdgeExtraneous = (node) => {
|
|
943
|
+
if (node.isIsolatedEdge)
|
|
944
|
+
return false; // already extraneous
|
|
784
945
|
if (faceToArea(node) < 0.0)
|
|
785
946
|
return true; // exterior face
|
|
786
947
|
if (node.findAroundFace(node.edgeMate))
|
|
787
948
|
return false; // interior washer face
|
|
788
949
|
return faceToArea(node.edgeMate) < 0.0; // adjacent to exterior face
|
|
789
950
|
};
|
|
790
|
-
// All bridges in the negative area face were isolated, but this may have
|
|
791
|
-
// negative area face. Keep isolating these bridge edges until none remain.
|
|
951
|
+
// All bridges in the negative area face were isolated, but this may have caused surviving bridges to become extraneous
|
|
952
|
+
// (e.g., by swelling the negative area face around them). Keep isolating these bridge edges until none remain.
|
|
792
953
|
let numIsolatedThisPass;
|
|
793
954
|
do {
|
|
794
955
|
numIsolatedThisPass = 0;
|
|
795
956
|
for (const node of interiorBridges) {
|
|
796
|
-
if (
|
|
797
|
-
|
|
798
|
-
toHeal.push(node.edgeMate.vertexSuccessor);
|
|
799
|
-
node.isolateEdge();
|
|
957
|
+
if (isBridgeEdgeExtraneous(node)) {
|
|
958
|
+
isolateBridgeEdge(node);
|
|
800
959
|
numIsolatedThisPass++;
|
|
801
960
|
}
|
|
802
961
|
}
|
|
803
962
|
} while (numIsolatedThisPass > 0);
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
963
|
+
return toHeal.filter((edge) => !edge.isIsolatedEdge);
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Simplify the graph by removing bridge edges that do not serve to connect inner and outer loops.
|
|
967
|
+
* * If edgeTags are `CurveLocationDetail`s, e.g., as set by `PlanarSubdivision.assembleHalfEdgeGraph`, attempt to heal edges split by removed bridge edges.
|
|
968
|
+
* @param graph half edges to process.
|
|
969
|
+
* @param isBridgeEdge optional callback to identify a bridge edge. Default looks for `HalfEdgeMask.BRIDGE_EDGE`.
|
|
970
|
+
* @param faceToArea optional callback to compute face area. Default is `HalfEdgeGraphSearch.signedFaceArea`.
|
|
971
|
+
* @returns the number of extraneous bridge edges removed from the graph.
|
|
972
|
+
* @internal
|
|
973
|
+
*/
|
|
974
|
+
static removeExtraneousBridgeEdges(graph, isBridgeEdge, faceToArea) {
|
|
975
|
+
if (!faceToArea)
|
|
976
|
+
faceToArea = (node) => HalfEdgeGraphSearch_1.HalfEdgeGraphSearch.signedFaceArea(node);
|
|
977
|
+
if (!isBridgeEdge)
|
|
978
|
+
isBridgeEdge = (node) => node.isMaskSet(Graph_1.HalfEdgeMask.BRIDGE_EDGE);
|
|
979
|
+
const toHeal = RegionOps.isolateExtraneousBridgeEdges(graph, isBridgeEdge, faceToArea);
|
|
980
|
+
// clean up the isolated bridge edges' original vertex loops, if possible
|
|
981
|
+
for (const vertex of toHeal) {
|
|
982
|
+
if (vertex.isDangling || vertex.isIsolatedEdge)
|
|
983
|
+
continue;
|
|
984
|
+
if (RegionOps.isHealableEdgeOrNullFace(vertex)) {
|
|
985
|
+
RegionOps.healSplitEdgeAndCurve(vertex);
|
|
986
|
+
continue;
|
|
811
987
|
}
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
doomedB.edgeTag instanceof CurveLocationDetail_1.CurveLocationDetail && doomedB.sortData !== undefined &&
|
|
820
|
-
doomedA.edgeTag.curve === doomedB.edgeTag.curve &&
|
|
821
|
-
doomedA.edgeTag.isInterval() && doomedB.edgeTag.isInterval() &&
|
|
822
|
-
doomedA.sortData * doomedB.sortData < 0 &&
|
|
823
|
-
((doomedA.sortData > 0 && Geometry_1.Geometry.isSmallRelative(doomedA.edgeTag.fraction - doomedB.edgeTag.fraction1)) ||
|
|
824
|
-
(doomedA.sortData < 0 && Geometry_1.Geometry.isSmallRelative(doomedA.edgeTag.fraction1 - doomedB.edgeTag.fraction)))) {
|
|
825
|
-
const survivorA = Graph_1.HalfEdge.healEdge(doomedA, false);
|
|
826
|
-
if (survivorA) {
|
|
827
|
-
const endFractionA = (doomedA.sortData > 0) ? doomedA.edgeTag.fraction1 : doomedA.edgeTag.fraction;
|
|
828
|
-
const endPointA = (doomedA.sortData > 0) ? doomedA.edgeTag.point1 : doomedA.edgeTag.point;
|
|
829
|
-
mergeDetails(survivorA, endFractionA, endPointA);
|
|
830
|
-
const endFractionB = (doomedB.sortData > 0) ? doomedB.edgeTag.fraction1 : doomedB.edgeTag.fraction;
|
|
831
|
-
const endPointB = (doomedB.sortData > 0) ? doomedB.edgeTag.point1 : doomedB.edgeTag.point;
|
|
832
|
-
mergeDetails(survivorA.edgeMate, endFractionB, endPointB);
|
|
988
|
+
const bundleData = RegionOps.isHealableNullFaceBundle(vertex);
|
|
989
|
+
if (bundleData.isHealable && bundleData.nullFacePairs) {
|
|
990
|
+
for (const [f0, f1] of bundleData.nullFacePairs)
|
|
991
|
+
Graph_1.HalfEdge.pinch(f0, f1); // merge the null face pair into a single null face (with 2 split edges)
|
|
992
|
+
for (const [e0, e1] of bundleData.nullFacePairs) {
|
|
993
|
+
RegionOps.healSplitEdgeAndCurve(e0);
|
|
994
|
+
RegionOps.healSplitEdgeAndCurve(e1);
|
|
833
995
|
}
|
|
834
996
|
}
|
|
835
997
|
}
|