@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
|
@@ -34,7 +34,7 @@ class ConsolidateAdjacentCurvePrimitivesContext extends GeometryHandler_1.NullGe
|
|
|
34
34
|
const numOriginal = children.length;
|
|
35
35
|
const points = [];
|
|
36
36
|
let numAccept = 0;
|
|
37
|
-
// i0 <=i < i1 is a range of child indices.
|
|
37
|
+
// i0 <= i < i1 is a range of child indices.
|
|
38
38
|
// numAccept is the number of children accepted (contiguously at front of children)
|
|
39
39
|
for (let i0 = 0; i0 < numOriginal;) {
|
|
40
40
|
const basePrimitive = g.children[i0];
|
|
@@ -92,7 +92,7 @@ class ConsolidateAdjacentCurvePrimitivesContext extends GeometryHandler_1.NullGe
|
|
|
92
92
|
const nextPrimitive = g.children[i0];
|
|
93
93
|
if (!(nextPrimitive instanceof Arc3d_1.Arc3d))
|
|
94
94
|
break;
|
|
95
|
-
if (!CurveFactory_1.CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive
|
|
95
|
+
if (!CurveFactory_1.CurveFactory.appendToArcInPlace(basePrimitive, nextPrimitive, false, this._options.duplicatePointTolerance))
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
// i0 has already advanced
|
|
@@ -105,8 +105,32 @@ class ConsolidateAdjacentCurvePrimitivesContext extends GeometryHandler_1.NullGe
|
|
|
105
105
|
}
|
|
106
106
|
g.children.length = numAccept;
|
|
107
107
|
}
|
|
108
|
-
handlePath(g) {
|
|
109
|
-
|
|
108
|
+
handlePath(g) {
|
|
109
|
+
return this.handleCurveChain(g);
|
|
110
|
+
}
|
|
111
|
+
handleLoop(g) {
|
|
112
|
+
this.handleCurveChain(g);
|
|
113
|
+
if (g.children.length > 1 && this._options.consolidateLoopSeam) {
|
|
114
|
+
const lastChild = g.children[g.children.length - 1];
|
|
115
|
+
const firstChild = g.children[0];
|
|
116
|
+
if ((lastChild instanceof LineSegment3d_1.LineSegment3d || lastChild instanceof LineString3d_1.LineString3d) && (firstChild instanceof LineSegment3d_1.LineSegment3d || firstChild instanceof LineString3d_1.LineString3d)) {
|
|
117
|
+
if (this._options.consolidateLinearGeometry && !this._options.disableLinearCompression) {
|
|
118
|
+
const lastPoints = lastChild.points;
|
|
119
|
+
lastPoints.pop(); // the original start point survives as an interior point in the new first primitive
|
|
120
|
+
g.children[0] = LineString3d_1.LineString3d.createPoints([...lastPoints, ...firstChild.points]);
|
|
121
|
+
g.children.pop();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else if (lastChild instanceof Arc3d_1.Arc3d && firstChild instanceof Arc3d_1.Arc3d) {
|
|
125
|
+
if (this._options.consolidateCompatibleArcs) {
|
|
126
|
+
if (CurveFactory_1.CurveFactory.appendToArcInPlace(lastChild, firstChild, false, this._options.duplicatePointTolerance)) {
|
|
127
|
+
g.children[0] = lastChild;
|
|
128
|
+
g.children.pop();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
110
134
|
handleParityRegion(g) {
|
|
111
135
|
for (const child of g.children)
|
|
112
136
|
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,6CAA0C;AAC1C,sEAAuE;AAEvE,sGAA8F;AAC9F,8DAA2D;AAC3D,oCAAiC;AAEjC,kDAA+C;AAC/C,oDAAiD;AACjD,kDAA+C;AAI/C,4CAAyE;AAGzE;;;;GAIG;AACH,MAAa,yCAA0C,SAAQ,qCAAmB;IACxE,QAAQ,CAA4C;IAC5D,YAAmB,OAAmD;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,qDAAyC,EAAE,CAAC;IACtF,CAAC;IACD,iEAAiE;IAC1D,gBAAgB,CAAC,CAAa;QACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC5B,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC;QACpC,MAAM,MAAM,GAAc,EAAE,CAAC;QAC7B,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,2CAA2C;QAC3C,mFAAmF;QACnF,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,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AC,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF;AAtFD,8FAsFC","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,6CAA0C;AAC1C,sEAAuE;AAEvE,sGAA8F;AAC9F,8DAA2D;AAC3D,oCAAiC;AAEjC,kDAA+C;AAC/C,oDAAiD;AACjD,kDAA+C;AAI/C,4CAAyE;AAGzE;;;;GAIG;AACH,MAAa,yCAA0C,SAAQ,qCAAmB;IACxE,QAAQ,CAA4C;IAC5D,YAAmB,OAAmD;QACpE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,qDAAyC,EAAE,CAAC;IACtF,CAAC;IACD,iEAAiE;IAC1D,gBAAgB,CAAC,CAAa;QACnC,MAAM,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC;QAC5B,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC;QACpC,MAAM,MAAM,GAAc,EAAE,CAAC;QAC7B,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,4CAA4C;QAC5C,mFAAmF;QACnF,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,WAAW,GAAG,CAAC;YACnC,MAAM,aAAa,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC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AAC;IAC1C,CAAC;CACF;AA7GD,8FA6GC","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
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"PlanarSubdivision.d.ts","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI7E,OAAO,EAAuB,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,OAAO,EAAE,IAAI,EAAsB,WAAW,EAAE,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAyE/C;;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;IAwB1B;;;;;;OAMG;WACW,iBAAiB,CAC7B,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,GAAE,MAAgB,EAAE,YAAY,CAAC,EAAE,OAAO,GAC7F,MAAM;IAeT,sDAAsD;IACtD,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAUtC,kDAAkD;IAClD,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAShC;;;;;;OAMG;WACW,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,EAAE,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"}
|
|
@@ -5,6 +5,7 @@ exports.PlanarSubdivision = void 0;
|
|
|
5
5
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
6
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
8
9
|
const Geometry_1 = require("../../Geometry");
|
|
9
10
|
const Graph_1 = require("../../topology/Graph");
|
|
10
11
|
const HalfEdgeGraphSearch_1 = require("../../topology/HalfEdgeGraphSearch");
|
|
@@ -14,7 +15,9 @@ const CurveLocationDetail_1 = require("../CurveLocationDetail");
|
|
|
14
15
|
const LineSegment3d_1 = require("../LineSegment3d");
|
|
15
16
|
const LineString3d_1 = require("../LineString3d");
|
|
16
17
|
const Loop_1 = require("../Loop");
|
|
18
|
+
const ParityRegion_1 = require("../ParityRegion");
|
|
17
19
|
const RegionOps_1 = require("../RegionOps");
|
|
20
|
+
const RegionOpsClassificationSweeps_1 = require("../RegionOpsClassificationSweeps");
|
|
18
21
|
/** @packageDocumentation
|
|
19
22
|
* @module Curve
|
|
20
23
|
*/
|
|
@@ -140,6 +143,8 @@ class PlanarSubdivision {
|
|
|
140
143
|
if (point0.isAlmostEqualXY(point1, mergeTolerance))
|
|
141
144
|
return { point: point0, fraction: fraction0 };
|
|
142
145
|
const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);
|
|
146
|
+
if (p.parent && p.parent instanceof RegionOpsClassificationSweeps_1.RegionGroupMember && p.parent.parentGroup.groupOpType === RegionOpsClassificationSweeps_1.RegionGroupOpType.NonBounding)
|
|
147
|
+
halfEdge.setMaskAroundEdge(Graph_1.HalfEdgeMask.BRIDGE_EDGE);
|
|
143
148
|
const detail01 = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);
|
|
144
149
|
const mate = halfEdge.edgeMate;
|
|
145
150
|
halfEdge.edgeTag = detail01;
|
|
@@ -172,28 +177,102 @@ class PlanarSubdivision {
|
|
|
172
177
|
outLoops.slivers.push(loop);
|
|
173
178
|
return area;
|
|
174
179
|
}
|
|
175
|
-
|
|
176
|
-
|
|
180
|
+
/** Extract geometric info from a topological edge. */
|
|
181
|
+
static extractGeometryFromEdge(edge) {
|
|
182
|
+
if (edge.sortData !== undefined && edge.edgeTag && edge.edgeTag instanceof CurveLocationDetail_1.CurveLocationDetail) {
|
|
183
|
+
const detail = edge.edgeTag;
|
|
184
|
+
if (detail.curve && detail.fraction1 !== undefined) {
|
|
185
|
+
const reversed = edge.sortData < 0;
|
|
186
|
+
return { detail, reversed };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
/** Create the geometry for a topological edge. */
|
|
192
|
+
static createCurveInEdge(edge) {
|
|
193
|
+
const info = this.extractGeometryFromEdge(edge);
|
|
194
|
+
if (info) {
|
|
195
|
+
if (info.reversed)
|
|
196
|
+
return info.detail.curve.clonePartialCurve(info.detail.fraction1, info.detail.fraction);
|
|
197
|
+
return info.detail.curve.clonePartialCurve(info.detail.fraction, info.detail.fraction1);
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Create a [[Loop]] for the given face or super face.
|
|
203
|
+
* @param face a node in the face loop, or an array of HalfEdges that comprise a loop (e.g., a super face).
|
|
204
|
+
* @param announce optional callback invoked on each edge/curve of the face/Loop.
|
|
205
|
+
* @param compress whether to consolidate adjacent curves in the output Loop (default `false`).
|
|
206
|
+
* If `announce` is provided, no compression is performed, as edges and curves would no longer be in 1-1 correspondence.
|
|
207
|
+
*/
|
|
208
|
+
static createLoopInFace(face, announce, compress = false) {
|
|
209
|
+
if (announce)
|
|
210
|
+
compress = false;
|
|
177
211
|
const loop = Loop_1.Loop.create();
|
|
178
|
-
|
|
179
|
-
const
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
const addEdgeCurve = (he) => {
|
|
213
|
+
const curve = this.createCurveInEdge(he);
|
|
214
|
+
if (curve) {
|
|
215
|
+
announce?.(he, curve, loop);
|
|
216
|
+
loop.tryAddChild(curve);
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
if (Array.isArray(face))
|
|
220
|
+
face.forEach(addEdgeCurve);
|
|
221
|
+
else
|
|
222
|
+
face.announceEdgesInFace(addEdgeCurve);
|
|
223
|
+
if (compress) {
|
|
224
|
+
const options = new RegionOps_1.ConsolidateAdjacentCurvePrimitivesOptions();
|
|
225
|
+
options.consolidateLoopSeam = true;
|
|
226
|
+
RegionOps_1.RegionOps.consolidateAdjacentPrimitives(loop, options);
|
|
227
|
+
}
|
|
228
|
+
if (loop.isPhysicallyClosedCurve(undefined, true))
|
|
229
|
+
return loop;
|
|
230
|
+
(0, core_bentley_1.assert)(false, "createLoopInFace: face is not physically closed");
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Create a [[Loop]] or [[ParityRegion]] for the given face.
|
|
235
|
+
* * A ParityRegion is created for a split-washer type face by removing bridge edges.
|
|
236
|
+
* @param face a node in the face loop.
|
|
237
|
+
* @param bridgeMask mask preset on bridge edges (default is `HalfEdgeMask.BRIDGE_EDGE`).
|
|
238
|
+
* @param visitMask mask to use for visiting edges in the face loop (default is `HalfEdgeMask.VISITED`).
|
|
239
|
+
*/
|
|
240
|
+
static createLoopOrParityRegionInFace(face, bridgeMask = Graph_1.HalfEdgeMask.BRIDGE_EDGE, visitMask = Graph_1.HalfEdgeMask.VISITED) {
|
|
241
|
+
let region;
|
|
242
|
+
if (face.isSplitWasherFace(bridgeMask)) {
|
|
243
|
+
const loops = [];
|
|
244
|
+
const loopEdges = [];
|
|
245
|
+
const bridgeStack = [face.findMaskAroundFace(bridgeMask, true)];
|
|
246
|
+
const announceEdge = (he) => { he.setMask(visitMask); loopEdges.push(he); };
|
|
247
|
+
const announceBridge = (he) => { if (!he.isMaskSet(visitMask))
|
|
248
|
+
bridgeStack.push(he); };
|
|
249
|
+
face.clearMaskAroundFace(visitMask);
|
|
250
|
+
let bridge;
|
|
251
|
+
while (undefined !== (bridge = bridgeStack.pop())) {
|
|
252
|
+
bridge.setMask(visitMask);
|
|
253
|
+
const loopSeed = bridge.findMaskAroundFace(bridgeMask, false); // advance to next loop
|
|
254
|
+
if (loopSeed) {
|
|
255
|
+
if (loopSeed.isMaskSet(visitMask))
|
|
256
|
+
continue;
|
|
257
|
+
loopEdges.length = 0;
|
|
258
|
+
if (loopSeed.announceEdgesInSuperFace(bridgeMask, announceEdge, announceBridge)) {
|
|
259
|
+
const loop = this.createLoopInFace(loopEdges, undefined, true);
|
|
260
|
+
if (loop) {
|
|
261
|
+
loops.push(loop);
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
190
265
|
}
|
|
191
266
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
267
|
+
region = RegionOps_1.RegionOps.sortOuterAndHoleLoopsXY(loops);
|
|
268
|
+
region = RegionOps_1.RegionOps.simplifyRegion(region);
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
region = this.createLoopInFace(face, undefined, true);
|
|
272
|
+
}
|
|
273
|
+
return (region && (region instanceof Loop_1.Loop || region instanceof ParityRegion_1.ParityRegion)) ? region : undefined;
|
|
195
274
|
}
|
|
196
|
-
|
|
275
|
+
/** Return true if there are only two edges in the face loop, and their start curvatures are the same. */
|
|
197
276
|
static isNullFace(he) {
|
|
198
277
|
const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);
|
|
199
278
|
let faceIsBanana = false;
|
|
@@ -205,8 +284,8 @@ class PlanarSubdivision {
|
|
|
205
284
|
}
|
|
206
285
|
return faceHasTwoEdges && !faceIsBanana;
|
|
207
286
|
}
|
|
208
|
-
|
|
209
|
-
static
|
|
287
|
+
/** Look across edge mates (possibly several) for a non-null mate face. */
|
|
288
|
+
static getNonNullEdgeMate(_graph, e) {
|
|
210
289
|
if (this.isNullFace(e))
|
|
211
290
|
return undefined;
|
|
212
291
|
let e1 = e.edgeMate;
|
|
@@ -228,7 +307,7 @@ class PlanarSubdivision {
|
|
|
228
307
|
const isNullFace = this.isNullFace(faceSeed);
|
|
229
308
|
const loop = this.createLoopInFace(faceSeed, (he, curveC, loopC) => {
|
|
230
309
|
if (!isNullFace) {
|
|
231
|
-
const mate = this.
|
|
310
|
+
const mate = this.getNonNullEdgeMate(graph, he);
|
|
232
311
|
if (mate !== undefined) {
|
|
233
312
|
const e = edgeMap.get(mate);
|
|
234
313
|
if (e === undefined) {
|
|
@@ -244,7 +323,8 @@ class PlanarSubdivision {
|
|
|
244
323
|
}
|
|
245
324
|
}
|
|
246
325
|
});
|
|
247
|
-
|
|
326
|
+
if (loop)
|
|
327
|
+
this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);
|
|
248
328
|
}
|
|
249
329
|
componentAreas.edges = edges;
|
|
250
330
|
result.push(componentAreas);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts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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,sDAA6C;AAC7C,6CAA0C;AAE1C,gDAA6E;AAC7E,4EAAyE;AACzE,oDAA4D;AAC5D,oCAAiC;AACjC,gEAAsF;AAGtF,oDAAiD;AACjD,kDAA+C;AAC/C,kCAAgE;AAChE,kDAA+C;AAC/C,4CAAoF;AACpF,oFAAwF;AAExF;;GAEG;AAEH,MAAM,+CAA+C;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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
|
|
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
|
|
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,OAA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E,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"}
|
|
@@ -14,6 +14,7 @@ const CurveCollection_1 = require("../CurveCollection");
|
|
|
14
14
|
const LineString3d_1 = require("../LineString3d");
|
|
15
15
|
const Loop_1 = require("../Loop");
|
|
16
16
|
const ParityRegion_1 = require("../ParityRegion");
|
|
17
|
+
const UnionRegion_1 = require("../UnionRegion");
|
|
17
18
|
const StrokeCountMap_1 = require("./StrokeCountMap");
|
|
18
19
|
// cspell:word remapa
|
|
19
20
|
/**
|
|
@@ -148,6 +149,7 @@ exports.StrokeCountMapVisitorApplyMaxCurveLength = StrokeCountMapVisitorApplyMax
|
|
|
148
149
|
* * `parent` = parent CurveCollection.
|
|
149
150
|
*
|
|
150
151
|
* An instance is normally created with either a `Path` or `Loop` as the parent.
|
|
152
|
+
* @internal
|
|
151
153
|
*/
|
|
152
154
|
class StrokeCountChain {
|
|
153
155
|
maps;
|
|
@@ -163,7 +165,7 @@ class StrokeCountChain {
|
|
|
163
165
|
this.maps = [];
|
|
164
166
|
this.options = options;
|
|
165
167
|
}
|
|
166
|
-
static
|
|
168
|
+
static create(chain, options) {
|
|
167
169
|
const result = new StrokeCountChain(chain, options);
|
|
168
170
|
result.parent = chain;
|
|
169
171
|
// A chain can only contain primitives !!!!
|
|
@@ -235,16 +237,24 @@ class StrokeCountSection {
|
|
|
235
237
|
* construct array of arrays of `StrokeCountMap`s
|
|
236
238
|
* @param parent
|
|
237
239
|
*/
|
|
238
|
-
static
|
|
240
|
+
static create(parent, options) {
|
|
239
241
|
const result = new StrokeCountSection(parent);
|
|
240
|
-
|
|
242
|
+
const appendCurveChain = (chain) => result.chains.push(StrokeCountChain.create(chain, options));
|
|
243
|
+
const appendParityRegion = (region) => { for (const child of region.children)
|
|
244
|
+
appendCurveChain(child); };
|
|
245
|
+
if (parent instanceof UnionRegion_1.UnionRegion) {
|
|
241
246
|
for (const child of parent.children) {
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
if (child instanceof ParityRegion_1.ParityRegion)
|
|
248
|
+
appendParityRegion(child);
|
|
249
|
+
else
|
|
250
|
+
appendCurveChain(child);
|
|
244
251
|
}
|
|
245
252
|
}
|
|
253
|
+
else if (parent instanceof ParityRegion_1.ParityRegion) {
|
|
254
|
+
appendParityRegion(parent);
|
|
255
|
+
}
|
|
246
256
|
else if (parent instanceof CurveCollection_1.CurveChain) {
|
|
247
|
-
|
|
257
|
+
appendCurveChain(parent);
|
|
248
258
|
}
|
|
249
259
|
return result;
|
|
250
260
|
}
|
|
@@ -323,11 +333,12 @@ class StrokeCountSection {
|
|
|
323
333
|
for (let chainIndex = 0; chainIndex < numChainPerSection; chainIndex++) {
|
|
324
334
|
const numPrimitive = sections[0].chains[chainIndex].maps.length;
|
|
325
335
|
for (let primitiveIndex = 0; primitiveIndex < numPrimitive; primitiveIndex++) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
for (let i = 0; i < numComponent; i++)
|
|
336
|
+
const numComponent = sections[0].chains[chainIndex].maps[primitiveIndex].componentData?.length ?? 0;
|
|
337
|
+
if (numComponent > 0) {
|
|
338
|
+
for (let i = 0; i < numComponent; i++) {
|
|
329
339
|
if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, i, callback))
|
|
330
340
|
return false;
|
|
341
|
+
}
|
|
331
342
|
}
|
|
332
343
|
else {
|
|
333
344
|
if (!this.applyMultipassVisitorCallbackNoComponents(sections, chainIndex, primitiveIndex, undefined, callback))
|