@itwin/core-geometry 4.0.0-dev.98 → 4.0.0
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/CHANGELOG.md +32 -1
- package/lib/cjs/Geometry.d.ts.map +1 -1
- package/lib/cjs/Geometry.js +8 -5
- package/lib/cjs/Geometry.js.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/cjs/curve/CurveCurveIntersectXY.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +57 -43
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +7 -5
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +17 -16
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/cjs/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/cjs/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/cjs/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js +1 -1
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +1 -0
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +1 -0
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/Geometry.d.ts.map +1 -1
- package/lib/esm/Geometry.js +8 -5
- package/lib/esm/Geometry.js.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.d.ts.map +1 -1
- package/lib/esm/curve/CurveCurveIntersectXY.js +3 -3
- package/lib/esm/curve/CurveCurveIntersectXY.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +1 -1
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts +3 -2
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +58 -44
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +7 -5
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +17 -16
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js +1 -1
- package/lib/esm/curve/RegionOpsClassificationSweeps.js.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts +9 -9
- package/lib/esm/geometry3d/CoincidentGeometryOps.d.ts.map +1 -1
- package/lib/esm/geometry3d/CoincidentGeometryOps.js +82 -56
- package/lib/esm/geometry3d/CoincidentGeometryOps.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.js +1 -1
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +1 -0
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +1 -0
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +3 -3
|
@@ -9,7 +9,10 @@ const Geometry_1 = require("../../Geometry");
|
|
|
9
9
|
const Graph_1 = require("../../topology/Graph");
|
|
10
10
|
const HalfEdgeGraphSearch_1 = require("../../topology/HalfEdgeGraphSearch");
|
|
11
11
|
const Merging_1 = require("../../topology/Merging");
|
|
12
|
+
const Arc3d_1 = require("../Arc3d");
|
|
12
13
|
const CurveLocationDetail_1 = require("../CurveLocationDetail");
|
|
14
|
+
const LineSegment3d_1 = require("../LineSegment3d");
|
|
15
|
+
const LineString3d_1 = require("../LineString3d");
|
|
13
16
|
const Loop_1 = require("../Loop");
|
|
14
17
|
const RegionOps_1 = require("../RegionOps");
|
|
15
18
|
/** @packageDocumentation
|
|
@@ -18,7 +21,7 @@ const RegionOps_1 = require("../RegionOps");
|
|
|
18
21
|
class MapCurvePrimitiveToCurveLocationDetailPairArray {
|
|
19
22
|
constructor() {
|
|
20
23
|
this.primitiveToPair = new Map();
|
|
21
|
-
// index assigned to this primitive for
|
|
24
|
+
// index assigned to this primitive (for debugging)
|
|
22
25
|
this.primitiveToIndex = new Map();
|
|
23
26
|
this._numIndexedPrimitives = 0;
|
|
24
27
|
}
|
|
@@ -50,52 +53,61 @@ class MapCurvePrimitiveToCurveLocationDetailPairArray {
|
|
|
50
53
|
if (primitiveB)
|
|
51
54
|
this.insertPrimitiveToPair(primitiveB, pair);
|
|
52
55
|
}
|
|
56
|
+
/** Split closed missing primitives in half and add new intersection pairs */
|
|
57
|
+
splitAndAppendMissingClosedPrimitives(primitives, tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
58
|
+
for (const p of primitives) {
|
|
59
|
+
let closedCurveSplitCandidate = false;
|
|
60
|
+
if (p instanceof Arc3d_1.Arc3d)
|
|
61
|
+
closedCurveSplitCandidate = p.sweep.isFullCircle;
|
|
62
|
+
else if (!(p instanceof LineSegment3d_1.LineSegment3d) && !(p instanceof LineString3d_1.LineString3d))
|
|
63
|
+
closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);
|
|
64
|
+
if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {
|
|
65
|
+
const p0 = p.clonePartialCurve(0.0, 0.5);
|
|
66
|
+
const p1 = p.clonePartialCurve(0.5, 1.0);
|
|
67
|
+
if (p0 && p1) {
|
|
68
|
+
this.insertPair(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0), CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0)));
|
|
69
|
+
this.insertPair(CurveLocationDetail_1.CurveLocationDetailPair.createCapture(CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0), CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0)));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
53
74
|
}
|
|
54
|
-
/*
|
|
55
|
-
function getDetailString(detail: CurveLocationDetail | undefined): string {
|
|
56
|
-
if (!detail)
|
|
57
|
-
return "{}";
|
|
58
|
-
else return tagString("primitive", this.primitiveToIndex.get(detail.curve!)) + tagString("f0", detail.fraction) + tagString("f1", detail.fraction1);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
function tagString(name: string, value: number | undefined): string {
|
|
62
|
-
if (value !== undefined)
|
|
63
|
-
return "(" + name + " " + value + ")";
|
|
64
|
-
return "";
|
|
65
|
-
}
|
|
66
|
-
*/
|
|
67
75
|
/**
|
|
68
76
|
* @internal
|
|
69
77
|
*/
|
|
70
78
|
class PlanarSubdivision {
|
|
71
|
-
/** Create a graph from an array of curves, and an array of the curves' precomputed intersections. */
|
|
72
|
-
static assembleHalfEdgeGraph(primitives, allPairs) {
|
|
79
|
+
/** Create a graph from an array of curves, and an array of the curves' precomputed intersections. Z-coordinates are ignored. */
|
|
80
|
+
static assembleHalfEdgeGraph(primitives, allPairs, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
73
81
|
const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray(); // map from key CurvePrimitive to CurveLocationDetailPair.
|
|
74
|
-
for (const
|
|
75
|
-
detailByPrimitive.assignPrimitiveIndex(p);
|
|
76
|
-
for (const pair of allPairs) {
|
|
82
|
+
for (const pair of allPairs)
|
|
77
83
|
detailByPrimitive.insertPair(pair);
|
|
78
|
-
|
|
84
|
+
if (primitives.length > detailByPrimitive.primitiveToPair.size)
|
|
85
|
+
detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance); // otherwise, these single-primitive loops are missing from the graph
|
|
79
86
|
const graph = new Graph_1.HalfEdgeGraph();
|
|
80
87
|
for (const entry of detailByPrimitive.primitiveToPair.entries()) {
|
|
81
88
|
const p = entry[0];
|
|
82
|
-
|
|
89
|
+
// convert each interval intersection into two isolated intersections
|
|
90
|
+
const details = entry[1].reduce((accumulator, detailPair) => {
|
|
91
|
+
if (!detailPair.detailA.hasFraction1)
|
|
92
|
+
return [...accumulator, detailPair];
|
|
93
|
+
const detail = getDetailOnCurve(detailPair, p);
|
|
94
|
+
const detail0 = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);
|
|
95
|
+
const detail1 = CurveLocationDetail_1.CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1, detail.point1);
|
|
96
|
+
return [...accumulator, CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detail0, detail0), CurveLocationDetail_1.CurveLocationDetailPair.createCapture(detail1, detail1)];
|
|
97
|
+
}, []);
|
|
98
|
+
// lexical sort on p intersection fraction
|
|
83
99
|
details.sort((pairA, pairB) => {
|
|
84
100
|
const fractionA = getFractionOnCurve(pairA, p);
|
|
85
101
|
const fractionB = getFractionOnCurve(pairB, p);
|
|
86
|
-
if (fractionA === undefined || fractionB === undefined)
|
|
87
|
-
return -1000.0;
|
|
88
102
|
return fractionA - fractionB;
|
|
89
103
|
});
|
|
90
|
-
let
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.addHalfEdge(graph, p, detail0.point, detail0.fraction, detail1.point, detail1.fraction);
|
|
96
|
-
detail0 = detail1;
|
|
104
|
+
let last = { point: p.startPoint(), fraction: 0.0 };
|
|
105
|
+
for (const detailPair of details) {
|
|
106
|
+
const detail = getDetailOnCurve(detailPair, p);
|
|
107
|
+
const detailFraction = Geometry_1.Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later
|
|
108
|
+
last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);
|
|
97
109
|
}
|
|
98
|
-
this.addHalfEdge(graph, p,
|
|
110
|
+
this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);
|
|
99
111
|
}
|
|
100
112
|
Merging_1.HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he) => he.sortAngle);
|
|
101
113
|
return graph;
|
|
@@ -109,19 +121,21 @@ class PlanarSubdivision {
|
|
|
109
121
|
* @param point0 start point
|
|
110
122
|
* @param fraction1 end fraction
|
|
111
123
|
* @param point1 end point
|
|
124
|
+
* @returns end point and fraction, or start point and fraction if no action
|
|
112
125
|
*/
|
|
113
|
-
static addHalfEdge(graph, p, point0, fraction0, point1, fraction1) {
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
static addHalfEdge(graph, p, point0, fraction0, point1, fraction1, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
127
|
+
if (point0.isAlmostEqualXY(point1, mergeTolerance))
|
|
128
|
+
return { point: point0, fraction: fraction0 };
|
|
129
|
+
const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);
|
|
130
|
+
const detail01 = CurveLocationDetail_1.CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);
|
|
131
|
+
const mate = halfEdge.edgeMate;
|
|
132
|
+
halfEdge.edgeTag = detail01;
|
|
133
|
+
halfEdge.sortData = 1.0;
|
|
134
|
+
mate.edgeTag = detail01;
|
|
135
|
+
mate.sortData = -1.0;
|
|
136
|
+
halfEdge.sortAngle = sortAngle(p, fraction0, false);
|
|
137
|
+
mate.sortAngle = sortAngle(p, fraction1, true);
|
|
138
|
+
return { point: point1, fraction: fraction1 };
|
|
125
139
|
}
|
|
126
140
|
/**
|
|
127
141
|
* Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative, or sliver loops.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,6CAA0C;AAE1C,gDAA+D;AAC/D,4EAAyE;AACzE,oDAA4D;AAC5D,gEAAsF;AAEtF,kCAAgE;AAChE,4CAAyC;AAEzC;;GAEG;AAEH,MAAM,+CAA+C;IAArD;QACS,oBAAe,GAAG,IAAI,GAAG,EAA6C,CAAC;QAC9E,yDAAyD;QAClD,qBAAgB,GAAG,IAAI,GAAG,EAA0B,CAAC;QACpD,0BAAqB,GAAW,CAAC,CAAC;IA4B5C,CAAC;IA3BQ,oBAAoB,CAAC,SAAqC;QAC/D,IAAI,SAAS,KAAK,SAAS,EAAE;YAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACnD,IAAI,KAAK,KAAK,SAAS,EAAE;gBACvB,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,qBAAqB,EAAE,CAAC,CAAC;aACpE;SACF;IACH,CAAC;IACM,qBAAqB,CAAC,SAAqC,EAAE,IAA6B;QAC/F,IAAI,SAAS,EAAE;YACb,MAAM,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACvD,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;YACrC,IA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C,KAAqB,EAAE,QAAgB,EAAE,OAAgB;IAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,KAAqB;IAC9E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { HalfEdge, HalfEdgeGraph } from \"../../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\r\nimport { RegionOps } from \"../RegionOps\";\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\r\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\r\n // index assigned to this primitive for this calculation.\r\n public primitiveToIndex = new Map<CurvePrimitive, number>();\r\n private _numIndexedPrimitives: number = 0;\r\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\r\n if (primitive !== undefined) {\r\n const index = this.primitiveToIndex.get(primitive);\r\n if (index === undefined) {\r\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\r\n }\r\n }\r\n }\r\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\r\n if (primitive) {\r\n const priorPairs = this.primitiveToPair.get(primitive);\r\n this.assignPrimitiveIndex(primitive);\r\n if (!priorPairs) {\r\n this.primitiveToPair.set(primitive, [pair]);\r\n } else {\r\n priorPairs.push(pair);\r\n }\r\n }\r\n }\r\n public insertPair(pair: CurveLocationDetailPair) {\r\n const primitiveA = pair.detailA.curve;\r\n if (primitiveA)\r\n this.insertPrimitiveToPair(primitiveA, pair);\r\n const primitiveB = pair.detailB.curve;\r\n if (primitiveB)\r\n this.insertPrimitiveToPair(primitiveB, pair);\r\n }\r\n}\r\n/*\r\n function getDetailString(detail: CurveLocationDetail | undefined): string {\r\n if (!detail)\r\n return \"{}\";\r\n else return tagString(\"primitive\", this.primitiveToIndex.get(detail.curve!)) + tagString(\"f0\", detail.fraction) + tagString(\"f1\", detail.fraction1);\r\n }\r\n}\r\nfunction tagString(name: string, value: number | undefined): string {\r\n if (value !== undefined)\r\n return \"(\" + name + \" \" + value + \")\";\r\n return \"\";\r\n}\r\n*/\r\n/**\r\n * @internal\r\n */\r\nexport class PlanarSubdivision {\r\n /** Create a graph from an array of curves, and an array of the curves' precomputed intersections. */\r\n public static assembleHalfEdgeGraph(primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[]): HalfEdgeGraph {\r\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray(); // map from key CurvePrimitive to CurveLocationDetailPair.\r\n for (const p of primitives)\r\n detailByPrimitive.assignPrimitiveIndex(p);\r\n for (const pair of allPairs) {\r\n detailByPrimitive.insertPair(pair);\r\n }\r\n const graph = new HalfEdgeGraph();\r\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\r\n const p = entry[0];\r\n const details = entry[1];\r\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\r\n const fractionA = getFractionOnCurve(pairA, p);\r\n const fractionB = getFractionOnCurve(pairB, p);\r\n if (fractionA === undefined || fractionB === undefined)\r\n return -1000.0;\r\n return fractionA - fractionB;\r\n });\r\n let detail0 = getDetailOnCurve(details[0], p)!;\r\n this.addHalfEdge(graph, p, p.startPoint (), 0.0, detail0.point, detail0.fraction);\r\n for (let i = 1; i < details.length; i++) {\r\n // create (both sides of) a graph edge . . .\r\n const detail1 = getDetailOnCurve(details[i], p)!;\r\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, detail1.point, detail1.fraction);\r\n detail0 = detail1;\r\n }\r\n this.addHalfEdge(graph, p, detail0.point, detail0.fraction, p.endPoint(), 1.0);\r\n }\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\r\n return graph;\r\n }\r\n /**\r\n * Create a pair of mated half edges referencing an interval of a primitive\r\n * * no action if start and end points are identical.\r\n * @param graph containing graph.\r\n * @param p the curve\r\n * @param fraction0 starting fraction\r\n * @param point0 start point\r\n * @param fraction1 end fraction\r\n * @param point1 end point\r\n */\r\n private static addHalfEdge(graph: HalfEdgeGraph, p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number) {\r\n if (!point0.isAlmostEqual (point1)){\r\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\r\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\r\n const mate = halfEdge.edgeMate;\r\n halfEdge.edgeTag = detail01;\r\n halfEdge.sortData = 1.0;\r\n mate.edgeTag = detail01;\r\n mate.sortData = -1.0;\r\n halfEdge.sortAngle = sortAngle(detail01.curve!, detail01.fraction, false);\r\n mate.sortAngle = sortAngle(detail01.curve!, detail01.fraction1!, true);\r\n }\r\n }\r\n /**\r\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative, or sliver loops.\r\n * @param zeroAreaTolerance absolute area tolerance for sliver face detection\r\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\r\n * @returns the area (forced to zero if within tolerance)\r\n */\r\n public static collectSignedLoop(loop: Loop, outLoops: SignedLoops, zeroAreaTolerance: number = 1.0e-10, isSliverFace?: boolean): number{\r\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\r\n if (area === undefined)\r\n area = 0;\r\n if (Math.abs(area) < zeroAreaTolerance)\r\n area = 0.0;\r\n (loop as any).computedAreaInPlanarSubdivision = area;\r\n if (area > 0)\r\n outLoops.positiveAreaLoops.push(loop);\r\n else if (area < 0)\r\n outLoops.negativeAreaLoops.push(loop);\r\n else\r\n outLoops.slivers.push(loop);\r\n return area;\r\n }\r\n public static createLoopInFace(faceSeed: HalfEdge,\r\n announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void): Loop {\r\n let he = faceSeed;\r\n const loop = Loop.create();\r\n do {\r\n const detail = he.edgeTag as CurveLocationDetail;\r\n if (detail) {\r\n let curve;\r\n if (he.sortData! > 0)\r\n curve = detail.curve!.clonePartialCurve(detail.fraction, detail.fraction1!);\r\n else\r\n curve = detail.curve!.clonePartialCurve(detail.fraction1!, detail.fraction);\r\n if (curve) {\r\n if (announce !== undefined)\r\n announce(he, curve, loop);\r\n loop.tryAddChild(curve);\r\n }\r\n }\r\n he = he.faceSuccessor;\r\n } while (he !== faceSeed);\r\n return loop;\r\n }\r\n // Return true if there are only two edges in the face loop, and their start curvatures are the same.\r\n private static isNullFace(he: HalfEdge): boolean {\r\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\r\n let faceIsBanana = false;\r\n if (faceHasTwoEdges) {\r\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\r\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\r\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\r\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\r\n }\r\n return faceHasTwoEdges && !faceIsBanana;\r\n }\r\n // Look across edge mates (possibly several) for a nonnull mate face.\r\n private static nonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\r\n if (this.isNullFace (e))\r\n return undefined;\r\n let e1 = e.edgeMate;\r\n while (this.isNullFace(e1)){\r\n e1 = e1.faceSuccessor.edgeMate;\r\n if (e1 === e)\r\n return undefined;\r\n }\r\n return e1;\r\n }\r\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\r\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n const result: SignedLoops[] = [];\r\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\r\n for (const faceSeeds of q) {\r\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\r\n const edges: LoopCurveLoopCurve[] = [];\r\n for (const faceSeed of faceSeeds) {\r\n const isNullFace = this.isNullFace(faceSeed);\r\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\r\n if (!isNullFace) {\r\n const mate = this.nonNullEdgeMate(graph, he);\r\n if (mate !== undefined) {\r\n const e = edgeMap.get(mate);\r\n if (e === undefined) {\r\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\r\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\r\n edgeMap.set(he, e1);\r\n } else if (e instanceof LoopCurveLoopCurve) {\r\n e.setB(loopC, curveC);\r\n edges.push(e);\r\n edgeMap.delete(mate);\r\n }\r\n }\r\n }\r\n });\r\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);\r\n }\r\n componentAreas.edges = edges;\r\n result.push(componentAreas);\r\n edgeMap.clear();\r\n }\r\n return result;\r\n }\r\n}\r\n\r\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\r\n const ray = curve.fractionToPointAndDerivative(fraction);\r\n const s = reverse ? -1.0 : 1.0;\r\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\r\n}\r\n\r\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\r\n if (pair.detailA.curve === curve)\r\n return pair.detailA.fraction;\r\n if (pair.detailB.curve === curve)\r\n return pair.detailB.fraction;\r\n return undefined;\r\n}\r\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\r\n if (pair.detailA.curve === curve)\r\n return pair.detailA;\r\n if (pair.detailB.curve === curve)\r\n return pair.detailB;\r\n return undefined;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"PlanarSubdivision.js","sourceRoot":"","sources":["../../../../src/curve/Query/PlanarSubdivision.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,6CAA0C;AAE1C,gDAA+D;AAC/D,4EAAyE;AACzE,oDAA4D;AAC5D,oCAAiC;AACjC,gEAAsF;AAEtF,oDAAiD;AACjD,kDAA+C;AAC/C,kCAAgE;AAChE,4CAAyC;AAEzC;;GAEG;AAEH,MAAM,+CA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F;AAnKD,8CAmKC;AAED,SAAS,SAAS,CAAC,KAAqB,EAAE,QAAgB,EAAE,OAAgB;IAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;IAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,kBAAkB,CAAC,IAA6B,EAAE,KAAqB;IAC9E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC/B,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,SAAS,gBAAgB,CAAC,IAA6B,EAAE,KAAqB;IAC5E,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,KAAK,KAAK;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { Geometry } from \"../../Geometry\";\r\nimport { Point3d } from \"../../geometry3d/Point3dVector3d\";\r\nimport { HalfEdge, HalfEdgeGraph } from \"../../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../../topology/HalfEdgeGraphSearch\";\r\nimport { HalfEdgeGraphMerge } from \"../../topology/Merging\";\r\nimport { Arc3d } from \"../Arc3d\";\r\nimport { CurveLocationDetail, CurveLocationDetailPair } from \"../CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../CurvePrimitive\";\r\nimport { LineSegment3d } from \"../LineSegment3d\";\r\nimport { LineString3d } from \"../LineString3d\";\r\nimport { Loop, LoopCurveLoopCurve, SignedLoops } from \"../Loop\";\r\nimport { RegionOps } from \"../RegionOps\";\r\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nclass MapCurvePrimitiveToCurveLocationDetailPairArray {\r\n public primitiveToPair = new Map<CurvePrimitive, CurveLocationDetailPair[]>();\r\n // index assigned to this primitive (for debugging)\r\n public primitiveToIndex = new Map<CurvePrimitive, number>();\r\n private _numIndexedPrimitives: number = 0;\r\n public assignPrimitiveIndex(primitive: CurvePrimitive | undefined) {\r\n if (primitive !== undefined) {\r\n const index = this.primitiveToIndex.get(primitive);\r\n if (index === undefined) {\r\n this.primitiveToIndex.set(primitive, this._numIndexedPrimitives++);\r\n }\r\n }\r\n }\r\n public insertPrimitiveToPair(primitive: CurvePrimitive | undefined, pair: CurveLocationDetailPair) {\r\n if (primitive) {\r\n const priorPairs = this.primitiveToPair.get(primitive);\r\n this.assignPrimitiveIndex(primitive);\r\n if (!priorPairs) {\r\n this.primitiveToPair.set(primitive, [pair]);\r\n } else {\r\n priorPairs.push(pair);\r\n }\r\n }\r\n }\r\n public insertPair(pair: CurveLocationDetailPair) {\r\n const primitiveA = pair.detailA.curve;\r\n if (primitiveA)\r\n this.insertPrimitiveToPair(primitiveA, pair);\r\n const primitiveB = pair.detailB.curve;\r\n if (primitiveB)\r\n this.insertPrimitiveToPair(primitiveB, pair);\r\n }\r\n /** Split closed missing primitives in half and add new intersection pairs */\r\n public splitAndAppendMissingClosedPrimitives(primitives: CurvePrimitive[], tolerance: number = Geometry.smallMetricDistance) {\r\n for (const p of primitives) {\r\n let closedCurveSplitCandidate = false;\r\n if (p instanceof Arc3d)\r\n closedCurveSplitCandidate = p.sweep.isFullCircle;\r\n else if (!(p instanceof LineSegment3d) && !(p instanceof LineString3d))\r\n closedCurveSplitCandidate = p.startPoint().isAlmostEqualXY(p.endPoint(), tolerance);\r\n if (closedCurveSplitCandidate && !this.primitiveToPair.has(p)) {\r\n const p0 = p.clonePartialCurve(0.0, 0.5);\r\n const p1 = p.clonePartialCurve(0.5, 1.0);\r\n if (p0 && p1) {\r\n this.insertPair(CurveLocationDetailPair.createCapture(CurveLocationDetail.createCurveEvaluatedFraction(p0, 0.0), CurveLocationDetail.createCurveEvaluatedFraction(p1, 1.0)));\r\n this.insertPair(CurveLocationDetailPair.createCapture(CurveLocationDetail.createCurveEvaluatedFraction(p0, 1.0), CurveLocationDetail.createCurveEvaluatedFraction(p1, 0.0)));\r\n }\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class PlanarSubdivision {\r\n /** Create a graph from an array of curves, and an array of the curves' precomputed intersections. Z-coordinates are ignored. */\r\n public static assembleHalfEdgeGraph(primitives: CurvePrimitive[], allPairs: CurveLocationDetailPair[], mergeTolerance: number = Geometry.smallMetricDistance): HalfEdgeGraph {\r\n const detailByPrimitive = new MapCurvePrimitiveToCurveLocationDetailPairArray(); // map from key CurvePrimitive to CurveLocationDetailPair.\r\n for (const pair of allPairs)\r\n detailByPrimitive.insertPair(pair);\r\n if (primitives.length > detailByPrimitive.primitiveToPair.size)\r\n detailByPrimitive.splitAndAppendMissingClosedPrimitives(primitives, mergeTolerance); // otherwise, these single-primitive loops are missing from the graph\r\n const graph = new HalfEdgeGraph();\r\n for (const entry of detailByPrimitive.primitiveToPair.entries()) {\r\n const p = entry[0];\r\n // convert each interval intersection into two isolated intersections\r\n const details = entry[1].reduce((accumulator: CurveLocationDetailPair[], detailPair) => {\r\n if (!detailPair.detailA.hasFraction1)\r\n return [...accumulator, detailPair];\r\n const detail = getDetailOnCurve(detailPair, p)!;\r\n const detail0 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction, detail.point);\r\n const detail1 = CurveLocationDetail.createCurveFractionPoint(p, detail.fraction1!, detail.point1!);\r\n return [...accumulator, CurveLocationDetailPair.createCapture(detail0, detail0), CurveLocationDetailPair.createCapture(detail1, detail1)];\r\n }, []);\r\n // lexical sort on p intersection fraction\r\n details.sort((pairA: CurveLocationDetailPair, pairB: CurveLocationDetailPair) => {\r\n const fractionA = getFractionOnCurve(pairA, p)!;\r\n const fractionB = getFractionOnCurve(pairB, p)!;\r\n return fractionA - fractionB;\r\n });\r\n let last = {point: p.startPoint(), fraction: 0.0};\r\n for (const detailPair of details) {\r\n const detail = getDetailOnCurve(detailPair, p)!;\r\n const detailFraction = Geometry.restrictToInterval(detail.fraction, 0, 1); // truncate fraction, but don't snap point; clustering happens later\r\n last = this.addHalfEdge(graph, p, last.point, last.fraction, detail.point, detailFraction, mergeTolerance);\r\n }\r\n this.addHalfEdge(graph, p, last.point, last.fraction, p.endPoint(), 1.0, mergeTolerance);\r\n }\r\n HalfEdgeGraphMerge.clusterAndMergeXYTheta(graph, (he: HalfEdge) => he.sortAngle!);\r\n return graph;\r\n }\r\n /**\r\n * Create a pair of mated half edges referencing an interval of a primitive\r\n * * no action if start and end points are identical.\r\n * @param graph containing graph.\r\n * @param p the curve\r\n * @param fraction0 starting fraction\r\n * @param point0 start point\r\n * @param fraction1 end fraction\r\n * @param point1 end point\r\n * @returns end point and fraction, or start point and fraction if no action\r\n */\r\n private static addHalfEdge(graph: HalfEdgeGraph, p: CurvePrimitive, point0: Point3d, fraction0: number, point1: Point3d, fraction1: number, mergeTolerance: number = Geometry.smallMetricDistance): {point: Point3d, fraction: number} {\r\n if (point0.isAlmostEqualXY(point1, mergeTolerance))\r\n return {point: point0, fraction: fraction0};\r\n const halfEdge = graph.createEdgeXYAndZ(point0, 0, point1, 0);\r\n const detail01 = CurveLocationDetail.createCurveEvaluatedFractionFraction(p, fraction0, fraction1);\r\n const mate = halfEdge.edgeMate;\r\n halfEdge.edgeTag = detail01;\r\n halfEdge.sortData = 1.0;\r\n mate.edgeTag = detail01;\r\n mate.sortData = -1.0;\r\n halfEdge.sortAngle = sortAngle(p, fraction0, false);\r\n mate.sortAngle = sortAngle(p, fraction1, true);\r\n return {point: point1, fraction: fraction1};\r\n }\r\n /**\r\n * Based on computed (and toleranced) area, push the loop (pointer) onto the appropriate array of positive, negative, or sliver loops.\r\n * @param zeroAreaTolerance absolute area tolerance for sliver face detection\r\n * @param isSliverFace whether the loop is known a priori (e.g., via topology) to have zero area\r\n * @returns the area (forced to zero if within tolerance)\r\n */\r\n public static collectSignedLoop(loop: Loop, outLoops: SignedLoops, zeroAreaTolerance: number = 1.0e-10, isSliverFace?: boolean): number{\r\n let area = isSliverFace ? 0.0 : RegionOps.computeXYArea(loop);\r\n if (area === undefined)\r\n area = 0;\r\n if (Math.abs(area) < zeroAreaTolerance)\r\n area = 0.0;\r\n (loop as any).computedAreaInPlanarSubdivision = area;\r\n if (area > 0)\r\n outLoops.positiveAreaLoops.push(loop);\r\n else if (area < 0)\r\n outLoops.negativeAreaLoops.push(loop);\r\n else\r\n outLoops.slivers.push(loop);\r\n return area;\r\n }\r\n public static createLoopInFace(faceSeed: HalfEdge,\r\n announce?: (he: HalfEdge, curve: CurvePrimitive, loop: Loop) => void): Loop {\r\n let he = faceSeed;\r\n const loop = Loop.create();\r\n do {\r\n const detail = he.edgeTag as CurveLocationDetail;\r\n if (detail) {\r\n let curve;\r\n if (he.sortData! > 0)\r\n curve = detail.curve!.clonePartialCurve(detail.fraction, detail.fraction1!);\r\n else\r\n curve = detail.curve!.clonePartialCurve(detail.fraction1!, detail.fraction);\r\n if (curve) {\r\n if (announce !== undefined)\r\n announce(he, curve, loop);\r\n loop.tryAddChild(curve);\r\n }\r\n }\r\n he = he.faceSuccessor;\r\n } while (he !== faceSeed);\r\n return loop;\r\n }\r\n // Return true if there are only two edges in the face loop, and their start curvatures are the same.\r\n private static isNullFace(he: HalfEdge): boolean {\r\n const faceHasTwoEdges = (he.faceSuccessor.faceSuccessor === he);\r\n let faceIsBanana = false;\r\n if (faceHasTwoEdges) {\r\n const c0 = HalfEdgeGraphMerge.curvatureSortKey(he);\r\n const c1 = HalfEdgeGraphMerge.curvatureSortKey(he.faceSuccessor.edgeMate);\r\n if (!Geometry.isSameCoordinate(c0, c1)) // default tol!\r\n faceIsBanana = true; // heuristic: we could also check end curvatures, and/or higher derivatives...\r\n }\r\n return faceHasTwoEdges && !faceIsBanana;\r\n }\r\n // Look across edge mates (possibly several) for a nonnull mate face.\r\n private static nonNullEdgeMate(_graph: HalfEdgeGraph, e: HalfEdge): HalfEdge | undefined {\r\n if (this.isNullFace (e))\r\n return undefined;\r\n let e1 = e.edgeMate;\r\n while (this.isNullFace(e1)){\r\n e1 = e1.faceSuccessor.edgeMate;\r\n if (e1 === e)\r\n return undefined;\r\n }\r\n return e1;\r\n }\r\n public static collectSignedLoopSetsInHalfEdgeGraph(graph: HalfEdgeGraph, zeroAreaTolerance: number = 1.0e-10): SignedLoops[] {\r\n const q = HalfEdgeGraphSearch.collectConnectedComponentsWithExteriorParityMasks(graph, undefined);\r\n const result: SignedLoops[] = [];\r\n const edgeMap = new Map<HalfEdge, LoopCurveLoopCurve>();\r\n for (const faceSeeds of q) {\r\n const componentAreas: SignedLoops = { positiveAreaLoops: [], negativeAreaLoops: [], slivers: [] };\r\n const edges: LoopCurveLoopCurve[] = [];\r\n for (const faceSeed of faceSeeds) {\r\n const isNullFace = this.isNullFace(faceSeed);\r\n const loop = this.createLoopInFace(faceSeed, (he: HalfEdge, curveC: CurvePrimitive, loopC: Loop) => {\r\n if (!isNullFace) {\r\n const mate = this.nonNullEdgeMate(graph, he);\r\n if (mate !== undefined) {\r\n const e = edgeMap.get(mate);\r\n if (e === undefined) {\r\n // Record this as loopA,edgeA of a shared edge to be completed later from the other side of the edge\r\n const e1 = new LoopCurveLoopCurve(loopC, curveC, undefined, undefined);\r\n edgeMap.set(he, e1);\r\n } else if (e instanceof LoopCurveLoopCurve) {\r\n e.setB(loopC, curveC);\r\n edges.push(e);\r\n edgeMap.delete(mate);\r\n }\r\n }\r\n }\r\n });\r\n this.collectSignedLoop(loop, componentAreas, zeroAreaTolerance, isNullFace);\r\n }\r\n componentAreas.edges = edges;\r\n result.push(componentAreas);\r\n edgeMap.clear();\r\n }\r\n return result;\r\n }\r\n}\r\n\r\nfunction sortAngle(curve: CurvePrimitive, fraction: number, reverse: boolean): number {\r\n const ray = curve.fractionToPointAndDerivative(fraction);\r\n const s = reverse ? -1.0 : 1.0;\r\n return Math.atan2(s * ray.direction.y, s * ray.direction.x);\r\n}\r\n\r\nfunction getFractionOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): number | undefined {\r\n if (pair.detailA.curve === curve)\r\n return pair.detailA.fraction;\r\n if (pair.detailB.curve === curve)\r\n return pair.detailB.fraction;\r\n return undefined;\r\n}\r\nfunction getDetailOnCurve(pair: CurveLocationDetailPair, curve: CurvePrimitive): CurveLocationDetail | undefined {\r\n if (pair.detailA.curve === curve)\r\n return pair.detailA;\r\n if (pair.detailB.curve === curve)\r\n return pair.detailB;\r\n return undefined;\r\n}\r\n"]}
|
|
@@ -129,7 +129,7 @@ export declare class RegionOps {
|
|
|
129
129
|
* @param loopsB second set of loops
|
|
130
130
|
* @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
|
|
131
131
|
* @param mergeTolerance absolute distance tolerance for merging loops
|
|
132
|
-
* @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges
|
|
132
|
+
* @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added to connect interior loops to exterior loops.
|
|
133
133
|
*/
|
|
134
134
|
static regionBooleanXY(loopsA: AnyRegion | AnyRegion[] | undefined, loopsB: AnyRegion | AnyRegion[] | undefined, operation: RegionBinaryOpType, mergeTolerance?: number): AnyRegion | undefined;
|
|
135
135
|
/**
|
|
@@ -290,17 +290,19 @@ export declare class RegionOps {
|
|
|
290
290
|
static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion;
|
|
291
291
|
/**
|
|
292
292
|
* Find all areas bounded by the unstructured, possibly intersecting curves.
|
|
293
|
-
* *
|
|
294
|
-
*
|
|
295
|
-
* [[regionBooleanXY]]
|
|
293
|
+
* * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the input curves.
|
|
294
|
+
* * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop, regardless
|
|
295
|
+
* of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]] to add bridge edges so that
|
|
296
|
+
* [[constructAllXYRegionLoops]] will return outer and inner loops in the same SignedLoops object.
|
|
296
297
|
* @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve primitives.
|
|
298
|
+
* @param tolerance optional distance tolerance for coincidence
|
|
297
299
|
* @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
|
|
298
300
|
* * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have positive area and counterclockwise orientation.
|
|
299
301
|
* * `negativeAreaLoops` contains (probably just one) "exterior" loop which is ordered clockwise.
|
|
300
302
|
* * `slivers` contains sliver loops that have zero area, such as appear between coincident curves.
|
|
301
303
|
* * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent to the edge and a constituent curve in each.
|
|
302
304
|
*/
|
|
303
|
-
static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[]): SignedLoops[];
|
|
305
|
+
static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[], tolerance?: number): SignedLoops[];
|
|
304
306
|
/**
|
|
305
307
|
* Collect all `CurvePrimitives` in loosely typed input.
|
|
306
308
|
* * Always recurses into primitives within explicit collections (Path, Loop, ParityRegion, UnionRegion).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOps.d.ts","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts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,oBAAoB,EAAE,mBAAmB,GAAE,OAAc,GAAG,SAAS,GAAG,SAAS;IA6CnJ;;;;;;;;;;OAUG;WACW,6BAA6B,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,yCAAyC;IAIxH;;;;;;;;;OASG;WACW,uBAAuB,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,GAAG,oBAAoB,CAAC,GAAG,SAAS;IAY3F;;;;;;;;;;;;;OAaG;WACW,yBAAyB,CAAC,gBAAgB,EAAE,QAAQ,GAAG,QAAQ,EAAE,EAAE,SAAS,GAAE,MAAqC,GAAG,WAAW,EAAE;IASjJ;;;;;;;;OAQG;WACW,sBAAsB,CAAC,UAAU,EAAE,QAAQ,GAAG,QAAQ,EAAE,EAAE,cAAc,CAAC,EAAE,cAAc,EAAE,EACvG,0BAA0B,GAAE,OAAe,EAC3C,kBAAkB,GAAE,OAAe,GAAG,cAAc,EAAE;IAaxD;;;;OAIG;WACW,iBAAiB,CAAC,UAAU,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE;IAe/E;;;;OAIG;WACW,eAAe,CAAC,IAAI,EAAE,GAAG,EAAE,YAAY,CAAC,EAAE,SAAS,GAAG,OAAO;CAkB5E"}
|
|
@@ -20,27 +20,27 @@ const Transform_1 = require("../geometry3d/Transform");
|
|
|
20
20
|
const MomentData_1 = require("../geometry4d/MomentData");
|
|
21
21
|
const PolyfaceBuilder_1 = require("../polyface/PolyfaceBuilder");
|
|
22
22
|
const Graph_1 = require("../topology/Graph");
|
|
23
|
+
const HalfEdgeGraphSearch_1 = require("../topology/HalfEdgeGraphSearch");
|
|
23
24
|
const Triangulation_1 = require("../topology/Triangulation");
|
|
24
25
|
const ChainCollectorContext_1 = require("./ChainCollectorContext");
|
|
25
26
|
const CurveCollection_1 = require("./CurveCollection");
|
|
26
27
|
const CurveCurve_1 = require("./CurveCurve");
|
|
27
28
|
const CurvePrimitive_1 = require("./CurvePrimitive");
|
|
28
29
|
const CurveWireMomentsXYZ_1 = require("./CurveWireMomentsXYZ");
|
|
30
|
+
const GeometryQuery_1 = require("./GeometryQuery");
|
|
31
|
+
const MultiChainCollector_1 = require("./internalContexts/MultiChainCollector");
|
|
29
32
|
const PolygonOffsetContext_1 = require("./internalContexts/PolygonOffsetContext");
|
|
30
33
|
const LineString3d_1 = require("./LineString3d");
|
|
31
34
|
const Loop_1 = require("./Loop");
|
|
35
|
+
const ParityRegion_1 = require("./ParityRegion");
|
|
32
36
|
const Path_1 = require("./Path");
|
|
33
37
|
const ConsolidateAdjacentPrimitivesContext_1 = require("./Query/ConsolidateAdjacentPrimitivesContext");
|
|
34
38
|
const CurveSplitContext_1 = require("./Query/CurveSplitContext");
|
|
35
39
|
const InOutTests_1 = require("./Query/InOutTests");
|
|
36
40
|
const PlanarSubdivision_1 = require("./Query/PlanarSubdivision");
|
|
37
41
|
const RegionMomentsXY_1 = require("./RegionMomentsXY");
|
|
38
|
-
const MultiChainCollector_1 = require("./internalContexts/MultiChainCollector");
|
|
39
|
-
const GeometryQuery_1 = require("./GeometryQuery");
|
|
40
42
|
const RegionOpsClassificationSweeps_1 = require("./RegionOpsClassificationSweeps");
|
|
41
43
|
const UnionRegion_1 = require("./UnionRegion");
|
|
42
|
-
const HalfEdgeGraphSearch_1 = require("../topology/HalfEdgeGraphSearch");
|
|
43
|
-
const ParityRegion_1 = require("./ParityRegion");
|
|
44
44
|
/**
|
|
45
45
|
* Enumeration of the binary operation types for a booleans among regions
|
|
46
46
|
* @public
|
|
@@ -239,7 +239,7 @@ class RegionOps {
|
|
|
239
239
|
* @param loopsB second set of loops
|
|
240
240
|
* @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
|
|
241
241
|
* @param mergeTolerance absolute distance tolerance for merging loops
|
|
242
|
-
* @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges
|
|
242
|
+
* @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added to connect interior loops to exterior loops.
|
|
243
243
|
*/
|
|
244
244
|
static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
245
245
|
const result = UnionRegion_1.UnionRegion.create();
|
|
@@ -247,7 +247,7 @@ class RegionOps {
|
|
|
247
247
|
context.addMembers(loopsA, loopsB);
|
|
248
248
|
context.annotateAndMergeCurvesInGraph(mergeTolerance);
|
|
249
249
|
const range = context.groupA.range().union(context.groupB.range());
|
|
250
|
-
const areaTol = this.computeXYAreaTolerance(range);
|
|
250
|
+
const areaTol = this.computeXYAreaTolerance(range, mergeTolerance);
|
|
251
251
|
context.runClassificationSweep(operation, (_graph, face, faceType, area) => {
|
|
252
252
|
// ignore danglers and null faces, but not 2-edge "banana" faces with nonzero area
|
|
253
253
|
if (face.countEdgesAroundFace() < 2)
|
|
@@ -565,23 +565,24 @@ class RegionOps {
|
|
|
565
565
|
}
|
|
566
566
|
/**
|
|
567
567
|
* Find all areas bounded by the unstructured, possibly intersecting curves.
|
|
568
|
-
* *
|
|
569
|
-
*
|
|
570
|
-
* [[regionBooleanXY]]
|
|
568
|
+
* * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the input curves.
|
|
569
|
+
* * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop, regardless
|
|
570
|
+
* of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]] to add bridge edges so that
|
|
571
|
+
* [[constructAllXYRegionLoops]] will return outer and inner loops in the same SignedLoops object.
|
|
571
572
|
* @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve primitives.
|
|
573
|
+
* @param tolerance optional distance tolerance for coincidence
|
|
572
574
|
* @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
|
|
573
575
|
* * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have positive area and counterclockwise orientation.
|
|
574
576
|
* * `negativeAreaLoops` contains (probably just one) "exterior" loop which is ordered clockwise.
|
|
575
577
|
* * `slivers` contains sliver loops that have zero area, such as appear between coincident curves.
|
|
576
578
|
* * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent to the edge and a constituent curve in each.
|
|
577
579
|
*/
|
|
578
|
-
static constructAllXYRegionLoops(curvesAndRegions) {
|
|
579
|
-
const
|
|
580
|
-
const
|
|
581
|
-
const
|
|
582
|
-
const
|
|
583
|
-
const
|
|
584
|
-
const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(primitivesB, intersections);
|
|
580
|
+
static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
581
|
+
const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
|
|
582
|
+
const range = this.curveArrayRange(primitives);
|
|
583
|
+
const areaTol = this.computeXYAreaTolerance(range, tolerance);
|
|
584
|
+
const intersections = CurveCurve_1.CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);
|
|
585
|
+
const graph = PlanarSubdivision_1.PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance);
|
|
585
586
|
return PlanarSubdivision_1.PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);
|
|
586
587
|
}
|
|
587
588
|
/**
|