@itwin/core-geometry 5.14.0-dev.5 → 5.14.0-dev.7
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 +9 -1
- package/lib/cjs/curve/CurveCollection.d.ts +6 -0
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +15 -0
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveOps.d.ts.map +1 -1
- package/lib/cjs/curve/CurveOps.js.map +1 -1
- package/lib/cjs/curve/GeometryQuery.d.ts +41 -0
- package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/cjs/curve/GeometryQuery.js +52 -0
- package/lib/cjs/curve/GeometryQuery.js.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts +36 -35
- package/lib/cjs/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/cjs/curve/Query/PlanarSubdivision.js +4 -4
- package/lib/cjs/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +3 -1
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts +2 -0
- package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Point3dVector3d.js +4 -0
- package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/cjs/geometry3d/Range.d.ts +2 -0
- package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Range.js +6 -0
- package/lib/cjs/geometry3d/Range.js.map +1 -1
- package/lib/cjs/topology/Merging.d.ts +4 -2
- package/lib/cjs/topology/Merging.d.ts.map +1 -1
- package/lib/cjs/topology/Merging.js +23 -20
- package/lib/cjs/topology/Merging.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +6 -0
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +15 -0
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveOps.d.ts.map +1 -1
- package/lib/esm/curve/CurveOps.js.map +1 -1
- package/lib/esm/curve/GeometryQuery.d.ts +41 -0
- package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/esm/curve/GeometryQuery.js +52 -0
- package/lib/esm/curve/GeometryQuery.js.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts +36 -35
- package/lib/esm/curve/Query/PlanarSubdivision.d.ts.map +1 -1
- package/lib/esm/curve/Query/PlanarSubdivision.js +4 -4
- package/lib/esm/curve/Query/PlanarSubdivision.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +3 -1
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.d.ts +2 -0
- package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
- package/lib/esm/geometry3d/Point3dVector3d.js +4 -0
- package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
- package/lib/esm/geometry3d/Range.d.ts +2 -0
- package/lib/esm/geometry3d/Range.d.ts.map +1 -1
- package/lib/esm/geometry3d/Range.js +6 -0
- package/lib/esm/geometry3d/Range.js.map +1 -1
- package/lib/esm/topology/Merging.d.ts +4 -2
- package/lib/esm/topology/Merging.d.ts.map +1 -1
- package/lib/esm/topology/Merging.js +23 -20
- package/lib/esm/topology/Merging.js.map +1 -1
- package/package.json +3 -3
|
@@ -102,7 +102,7 @@ export declare class HalfEdgeGraphOps {
|
|
|
102
102
|
* @internal
|
|
103
103
|
*/
|
|
104
104
|
export declare class HalfEdgeGraphMerge {
|
|
105
|
-
static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number;
|
|
105
|
+
static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number, radianTol?: number): number;
|
|
106
106
|
private static _announceVertexNeighborhoodFunction?;
|
|
107
107
|
/**
|
|
108
108
|
* public property setter for a function to be called with sorted edge data around a vertex.
|
|
@@ -112,6 +112,8 @@ export declare class HalfEdgeGraphMerge {
|
|
|
112
112
|
private static secondarySortAroundVertex;
|
|
113
113
|
/** Return the sort key for sorting by curvature.
|
|
114
114
|
* * This is the signed distance from the curve at the edge start, to center of curvature.
|
|
115
|
+
* * ASSUME: edgeTag is a `CurveLocationDetail` whose fractions [f0,f1] define the detail.curve segment traversed
|
|
116
|
+
* by the edge. If sortData < 0, the edge traverses the curve segment in reverse order [f1,f0].
|
|
115
117
|
* * NOTE: Currently does not account for higher derivatives in the case of higher-than-tangent match.
|
|
116
118
|
*/
|
|
117
119
|
static curvatureSortKey(node: HalfEdge): number;
|
|
@@ -133,7 +135,7 @@ export declare class HalfEdgeGraphMerge {
|
|
|
133
135
|
* @param outboundRadiansFunction optional function to compute the sort angle of an edge at its start vertex
|
|
134
136
|
* @param clusterTol optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
|
|
135
137
|
*/
|
|
136
|
-
static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number, clusterTol?: number): void;
|
|
138
|
+
static clusterAndMergeXYTheta(graph: HalfEdgeGraph, outboundRadiansFunction?: (he: HalfEdge) => number, clusterTol?: number, radianTol?: number): void;
|
|
137
139
|
private static buildVerticalSweepPriorityQueue;
|
|
138
140
|
private static computeIntersectionFractionsOnEdges;
|
|
139
141
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merging.d.ts","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oCAAoC,CAAC;AAChF,OAAO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G;WACW,qBAAqB,CAAC,YAAY,EAAE,aAAa,EAAE,GAAG,aAAa;IASjF;;;;OAIG;WACW,mBAAmB,CAAC,MAAM,EAAE,0BAA0B,EAAE,UAAU,GAAE,OAAc,EAAE,IAAI,GAAE,YAAwC,GAAG,aAAa,GAAG,SAAS;CAiB7K"}
|
|
@@ -9,6 +9,7 @@ exports.HalfEdgeGraphMerge = exports.HalfEdgeGraphOps = exports.VertexNeighborho
|
|
|
9
9
|
* @module Topology
|
|
10
10
|
*/
|
|
11
11
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const CurveLocationDetail_1 = require("../curve/CurveLocationDetail");
|
|
12
13
|
const LineSegment3d_1 = require("../curve/LineSegment3d");
|
|
13
14
|
const Geometry_1 = require("../Geometry");
|
|
14
15
|
const Angle_1 = require("../geometry3d/Angle");
|
|
@@ -252,12 +253,12 @@ class HalfEdgeGraphMerge {
|
|
|
252
253
|
// return kC such that all angles k are equal, with kA <= k < kC <= kB.
|
|
253
254
|
// * Assume: angles k are stored at extra data index 0.
|
|
254
255
|
// * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC
|
|
255
|
-
static getCommonThetaEndIndex(clusters, order, kA, kB) {
|
|
256
|
+
static getCommonThetaEndIndex(clusters, order, kA, kB, radianTol = Geometry_1.Geometry.smallAngleRadians) {
|
|
256
257
|
let kC = kA + 1;
|
|
257
258
|
const thetaA = clusters.getExtraData(order[kA], 0);
|
|
258
259
|
while (kC < kB) {
|
|
259
260
|
const thetaB = clusters.getExtraData(order[kC], 0);
|
|
260
|
-
if (!Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {
|
|
261
|
+
if (!Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB, radianTol)) {
|
|
261
262
|
return kC;
|
|
262
263
|
}
|
|
263
264
|
kC++;
|
|
@@ -289,10 +290,10 @@ class HalfEdgeGraphMerge {
|
|
|
289
290
|
// * only want to do anything here when curves are present.
|
|
290
291
|
// * k0<=k<k1 are around a vertex
|
|
291
292
|
// * These are sorted by theta.
|
|
292
|
-
static secondarySortAroundVertex(clusters, order, allNodes, k0, k1) {
|
|
293
|
+
static secondarySortAroundVertex(clusters, order, allNodes, k0, k1, radianTol = Geometry_1.Geometry.smallAngleRadians) {
|
|
293
294
|
const sortData = [];
|
|
294
295
|
for (let k = k0; k < k1;) {
|
|
295
|
-
const kB = this.getCommonThetaEndIndex(clusters, order, k, k1);
|
|
296
|
+
const kB = this.getCommonThetaEndIndex(clusters, order, k, k1, radianTol);
|
|
296
297
|
if (k + 1 < kB) {
|
|
297
298
|
sortData.length = 0;
|
|
298
299
|
for (let kA = k; kA < kB; kA++) {
|
|
@@ -311,18 +312,20 @@ class HalfEdgeGraphMerge {
|
|
|
311
312
|
}
|
|
312
313
|
/** Return the sort key for sorting by curvature.
|
|
313
314
|
* * This is the signed distance from the curve at the edge start, to center of curvature.
|
|
315
|
+
* * ASSUME: edgeTag is a `CurveLocationDetail` whose fractions [f0,f1] define the detail.curve segment traversed
|
|
316
|
+
* by the edge. If sortData < 0, the edge traverses the curve segment in reverse order [f1,f0].
|
|
314
317
|
* * NOTE: Currently does not account for higher derivatives in the case of higher-than-tangent match.
|
|
315
318
|
*/
|
|
316
319
|
static curvatureSortKey(node) {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
320
|
+
if (node.edgeTag !== undefined) {
|
|
321
|
+
if (node.edgeTag instanceof CurveLocationDetail_1.CurveLocationDetail) {
|
|
322
|
+
const cld = node.edgeTag;
|
|
323
|
+
if (cld.curve !== undefined) {
|
|
324
|
+
const reverse = node.sortData !== undefined && node.sortData < 0;
|
|
325
|
+
const fraction = (reverse && cld.fraction1 !== undefined) ? cld.fraction1 : cld.fraction;
|
|
326
|
+
const radius = cld.curve.fractionToSignedXYRadiusOfCurvature(fraction);
|
|
327
|
+
return reverse ? -radius : radius;
|
|
328
|
+
}
|
|
326
329
|
}
|
|
327
330
|
}
|
|
328
331
|
return 0.0;
|
|
@@ -347,11 +350,11 @@ class HalfEdgeGraphMerge {
|
|
|
347
350
|
* @param outboundRadiansFunction optional function to compute the sort angle of an edge at its start vertex
|
|
348
351
|
* @param clusterTol optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].
|
|
349
352
|
*/
|
|
350
|
-
static clusterAndMergeXYTheta(graph, outboundRadiansFunction, clusterTol = Geometry_1.Geometry.smallMetricDistance) {
|
|
353
|
+
static clusterAndMergeXYTheta(graph, outboundRadiansFunction, clusterTol = Geometry_1.Geometry.smallMetricDistance, radianTol = Geometry_1.Geometry.smallAngleRadians) {
|
|
351
354
|
const allNodes = graph.allHalfEdges;
|
|
352
355
|
const numNodes = allNodes.length;
|
|
353
356
|
graph.clearMask(Graph_1.HalfEdgeMask.NULL_FACE);
|
|
354
|
-
const clusters = new ClusterableArray_1.ClusterableArray(2, 2, numNodes); // data
|
|
357
|
+
const clusters = new ClusterableArray_1.ClusterableArray(2, 2, numNodes); // data block: dot,x,y,theta,nodeIndex --- dot and theta are set later
|
|
355
358
|
for (let i = 0; i < numNodes; i++) {
|
|
356
359
|
const nodeA = allNodes[i];
|
|
357
360
|
const xA = nodeA.x;
|
|
@@ -359,7 +362,7 @@ class HalfEdgeGraphMerge {
|
|
|
359
362
|
Graph_1.HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.
|
|
360
363
|
clusters.addDirect(xA, yA, 0.0, i);
|
|
361
364
|
}
|
|
362
|
-
const order = clusters.clusterIndicesLexical(clusterTol);
|
|
365
|
+
const order = clusters.clusterIndicesLexical(clusterTol); // assign primary sort dot product
|
|
363
366
|
let k0 = 0;
|
|
364
367
|
const numK = order.length;
|
|
365
368
|
for (let k1 = 0; k1 < numK; k1++) {
|
|
@@ -394,7 +397,7 @@ class HalfEdgeGraphMerge {
|
|
|
394
397
|
getPrecomputedRadians = undefined;
|
|
395
398
|
}
|
|
396
399
|
let radians = getPrecomputedRadians ? getPrecomputedRadians(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);
|
|
397
|
-
if (Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))
|
|
400
|
+
if (Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI, radianTol))
|
|
398
401
|
radians = Math.PI;
|
|
399
402
|
clusters.setExtraData(clusterTableIndex, 0, radians);
|
|
400
403
|
}
|
|
@@ -406,10 +409,10 @@ class HalfEdgeGraphMerge {
|
|
|
406
409
|
// now pinch each neighboring pair together
|
|
407
410
|
for (let k1 = 0; k1 < numK; k1++) {
|
|
408
411
|
if (order[k1] === ClusterableArray_1.ClusterableArray.clusterTerminator) {
|
|
409
|
-
// nodes identified in order[k0]..order[k1-1] are
|
|
412
|
+
// nodes identified in order[k0]..order[k1-1] are tentatively sorted around a vertex by theta
|
|
410
413
|
if (k1 > k0) {
|
|
411
414
|
if (k1 > k0 + 1)
|
|
412
|
-
this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);
|
|
415
|
+
this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1, radianTol); // finalize order by resolving ties via curvature
|
|
413
416
|
this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);
|
|
414
417
|
const iA = clusters.getExtraData(order[k0], 1);
|
|
415
418
|
thetaA = clusters.getExtraData(order[k0], 0);
|
|
@@ -444,7 +447,7 @@ class HalfEdgeGraphMerge {
|
|
|
444
447
|
// * far vertex is clustered (exactly equal)
|
|
445
448
|
// * near vertex curvatures are same (toleranced)
|
|
446
449
|
// Note that near vertex is already clustered.
|
|
447
|
-
if (Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {
|
|
450
|
+
if (Angle_1.Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB, radianTol)) {
|
|
448
451
|
const nodeA1 = nodeA.faceSuccessor;
|
|
449
452
|
const nodeB1 = nodeB.edgeMate;
|
|
450
453
|
if (nodeA1.isEqualXY(nodeB1)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Merging.js","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAA6C;AAE7C,0DAAuD;AACvD,0CAAuC;AACvC,+CAA4C;AAE5C,+CAAuD;AAEvD,mEAAgE;AAChE,yDAAsD;AACtD,mCAAgE;AAChE,mEAAgF;AAChF,qDAAyD;AACzD,mDAA+C;AAE/C,mBAAmB;AAEnB,MAAa,cAAc;IAClB,SAAS,GAAG,CAAC,CAAC;IACd,mBAAmB,GAAG,CAAC,CAAC;IACxB,QAAQ,GAAG,CAAC,CAAC;IACb,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC,CAAC;IACZ,OAAO,GAAG,CAAC,CAAC;IACnB;IACA,CAAC;CACF;AATD,wCASC;AACD;;GAEG;AACH,MAAa,0BAA0B;IAC9B,KAAK,CAAS;IACd,iBAAiB,CAAS;IAC1B,IAAI,CAAW;IACf,OAAO,CAAU;IACxB,YAAmB,KAAa,EAAE,GAAW,EAAE,IAAc,EAAE,OAAgB;QAC7E,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,iBAAiB,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAXD,gEAWC;AAID;;;GAGG;AACH,MAAa,gBAAgB;IAE3B,iFAAiF;IAC1E,MAAM,CAAC,gBAAgB,CAAC,CAAW,EAAE,CAAW;QACrD,YAAY;QACZ,4CAA4C;QAC5C,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACX,OAAO,CAAC,CAAC,CAAC;aACP,IAAI,CAAC,C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E,OAAqB,oBAAY,CAAC,YAAY;QAC9I,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YACnB,OAAO,SAAS,CAAC;QACnB,MAAM,KAAK,GAAG,IAAI,qBAAa,EAAE,CAAC;QAClC,MAAM,UAAU,GAAG,4BAAY,CAAC,iCAAiC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACjF,KAAK,MAAM,IAAI,IAAI,UAAU;YAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,IAAI,sCAAqB,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AAzWD,gDAyWC","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\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\r\nimport { SmallSystem } from \"../numerics/SmallSystem\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\r\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\r\nimport { RegularizationContext } from \"./RegularizeFace\";\r\nimport { Triangulator } from \"./Triangulation\";\r\n\r\n// cspell:word XYUV\r\n\r\nexport class GraphSplitData {\r\n public numUpEdge = 0;\r\n public numIntersectionTest = 0;\r\n public numSplit = 0;\r\n public numPopOut = 0;\r\n public numA0B0 = 0;\r\n public numA0B1 = 0;\r\n public constructor() {\r\n }\r\n}\r\n/**\r\n * Structure for data used when sorting outbound edges \"around a node\"\r\n */\r\nexport class VertexNeighborhoodSortData {\r\n public index: number;\r\n public radiusOfCurvature: number;\r\n public node: HalfEdge;\r\n public radians?: number;\r\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\r\n this.index = index;\r\n this.radiusOfCurvature = key;\r\n this.node = node;\r\n this.radians = radians;\r\n }\r\n}\r\n\r\n/** Function signature for announcing a vertex neighborhood during sorting. */\r\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\r\n/**\r\n * * Assorted methods used in algorithms on HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphOps {\r\n\r\n /** Compare function for sorting with primary y compare, secondary x compare. */\r\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\r\n // Check y's\r\n // if (!Geometry.isSameCoordinate(a.y, b.y))\r\n if (a.y < b.y)\r\n return -1;\r\n else if (a.y > b.y)\r\n return 1;\r\n // Check x's\r\n // if (!Geometry.isSameCoordinate(a.x, b.x))\r\n if (a.x < b.x)\r\n return -1;\r\n else if (a.x > b.x)\r\n return 1;\r\n return 0;\r\n }\r\n\r\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\r\n public static isDownPeak(nodeB: HalfEdge) {\r\n const nodeA = nodeB.facePredecessor;\r\n const nodeC = nodeB.faceSuccessor;\r\n return this.compareNodesYXUp(nodeB, nodeA) < 0\r\n && this.compareNodesYXUp(nodeB, nodeC) < 0\r\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\r\n }\r\n\r\n /** return the cross product of vectors from base to targetA and base to targetB\r\n * @param base base vertex of both vectors.\r\n * @param targetA target vertex of first vector\r\n * @param targetB target vertex of second vector\r\n */\r\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\r\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\r\n }\r\n\r\n /** Compute the range of the graph's vertices. */\r\n public static graphRange(graph: Readonly<HalfEdgeGraph>): Range3d {\r\n const range = Range3d.create();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXYZ(node.x, node.y, node.z);\r\n }\r\n return range;\r\n }\r\n /** Compute the xy-range of the graph's vertices. */\r\n public static graphRangeXY(graph: Readonly<HalfEdgeGraph>): Range2d {\r\n const range = Range2d.createNull();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXY(node.x, node.y);\r\n }\r\n return range;\r\n }\r\n\r\n /** Returns an array of all nodes (both ends) of edges created from segments. */\r\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\r\n const result = [];\r\n let idxCounter = 0;\r\n\r\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\r\n for (const segment of segments) {\r\n\r\n const node0 = returnGraph.createEdgeXYZXYZ(\r\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\r\n idxCounter,\r\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\r\n idxCounter + 1);\r\n\r\n const node1 = node0.edgeMate;\r\n idxCounter += 2;\r\n\r\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\r\n result.push(node0);\r\n result.push(node1);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * * Visit all nodes in `graph`.\r\n * * invoke `pinch(node, vertexPredecessor)`\r\n * * this leaves the graph as isolated edges.\r\n * @param graph graph to modify\r\n */\r\n public static isolateAllEdges(graph: HalfEdgeGraph) {\r\n for (const nodeA of graph.allHalfEdges) {\r\n const nodeB = nodeA.vertexPredecessor;\r\n HalfEdge.pinch(nodeA, nodeB);\r\n }\r\n }\r\n /**\r\n * Compute convexity of a sector of a super-face.\r\n * @param base node whose edge is to be tested for removal\r\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\r\n * @param barrier edges with this mask (on either side) will not be removed\r\n * @param signedAreaTol optional signed area tolerance to use in test for parallel vectors\r\n * @return whether removing the edge at base would create a convex sector in the super-face\r\n */\r\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask, signedAreaTol: number = 0): boolean {\r\n let vs = base;\r\n do { // loop ccw around vertex looking for a super-face predecessor\r\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\r\n break;\r\n vs = vs.vertexSuccessor;\r\n } while (vs !== base && vs.isMaskSet(ignore));\r\n if (vs === base)\r\n return false;\r\n let vp = base;\r\n do { // loop cw around vertex looking for a super-face successor\r\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\r\n break;\r\n vp = vp.vertexPredecessor;\r\n } while (vp !== base && vp.isMaskSet(ignore));\r\n if (vp === base)\r\n return false;\r\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor, signedAreaTol);\r\n }\r\n /**\r\n * Mask edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine and mark\r\n * @param mark the mask used to mark (both sides of) removable edges\r\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges masked (half the number of HalfEdges masked)\r\n */\r\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n if (HalfEdgeMask.NULL_MASK === mark)\r\n return 0;\r\n const visit = graph.grabMask(true);\r\n let numMarked = 0;\r\n for (const node of graph.allHalfEdges) {\r\n if (!node.isMaskSet(visit)) {\r\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\r\n // tol based on areas of *original* faces on each side of the edge to be removed\r\n const signedAreaTol = Geometry.smallMetricDistanceSquared * (node.signedFaceArea() + node.edgeMate.signedFaceArea());\r\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier, signedAreaTol) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier, signedAreaTol)) {\r\n node.setMaskAroundEdge(mark);\r\n ++numMarked;\r\n }\r\n }\r\n }\r\n node.setMaskAroundEdge(visit);\r\n }\r\n graph.dropMask(visit);\r\n return numMarked;\r\n }\r\n /**\r\n * Collect edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine\r\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return one HalfEdge per removable edge\r\n */\r\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\r\n const removable: HalfEdge[] = [];\r\n const mark = graph.grabMask(true);\r\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\r\n const visited = graph.grabMask(true);\r\n for (const node of graph.allHalfEdges) {\r\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\r\n node.setMaskAroundEdge(visited);\r\n removable.push(node);\r\n }\r\n }\r\n graph.dropMask(visited);\r\n }\r\n graph.dropMask(mark);\r\n return removable;\r\n }\r\n\r\n /**\r\n * Remove edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to modify\r\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges deleted\r\n */\r\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n const mark = graph.grabMask(true);\r\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\r\n if (numRemovedEdges > 0) {\r\n const numYankedEdges = 0.5 * graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\r\n assert(numYankedEdges === numRemovedEdges);\r\n }\r\n graph.dropMask(mark);\r\n return numRemovedEdges;\r\n }\r\n\r\n /**\r\n * Test desired faces for convexity.\r\n * @param graph graph to examine\r\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\r\n * @return whether every face in the graph is convex\r\n */\r\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\r\n const allFaces = graph.collectFaceLoops();\r\n for (const node of allFaces) {\r\n if (node.isMaskedAroundFace(avoid))\r\n continue;\r\n if (!node.isFaceConvex())\r\n return false;\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Note: this class uses hardcoded micrometer coordinate/cluster tolerance throughout.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphMerge {\r\n // return kC such that all angles k are equal, with kA <= k < kC <= kB.\r\n // * Assume: angles k are stored at extra data index 0.\r\n // * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC\r\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number): number {\r\n let kC = kA + 1;\r\n const thetaA = clusters.getExtraData(order[kA], 0);\r\n while (kC < kB) {\r\n const thetaB = clusters.getExtraData(order[kC], 0);\r\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n return kC;\r\n }\r\n kC++;\r\n }\r\n return kC;\r\n }\r\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\r\n /**\r\n * public property setter for a function to be called with sorted edge data around a vertex.\r\n */\r\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\r\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n if (this._announceVertexNeighborhoodFunction) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n // build and share the entire vertex order\r\n for (let k = k0; k < k1; k++) {\r\n const index = clusters.getExtraData(order[k], 1);\r\n const theta = clusters.getExtraData(order[k], 0);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\r\n }\r\n this._announceVertexNeighborhoodFunction(sortData);\r\n }\r\n\r\n }\r\n // assumptions about cluster array:\r\n // * data order is: x,y,theta,nodeIndex\r\n // * theta and nodeIndex are the \"extra\" data.\r\n // * only want to do anything here when curves are present.\r\n // * k0<=k<k1 are around a vertex\r\n // * These are sorted by theta.\r\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n\r\n for (let k = k0; k < k1;) {\r\n const kB = this.getCommonThetaEndIndex(clusters, order, k, k1);\r\n if (k + 1 < kB) {\r\n sortData.length = 0;\r\n for (let kA = k; kA < kB; kA++) {\r\n const index = clusters.getExtraData(order[kA], 1);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\r\n }\r\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\r\n for (let i = 0; i < sortData.length; i++) {\r\n order[k + i] = sortData[i].index;\r\n }\r\n }\r\n k = kB;\r\n }\r\n }\r\n /** Return the sort key for sorting by curvature.\r\n * * This is the signed distance from the curve at the edge start, to center of curvature.\r\n * * NOTE: Currently does not account for higher derivatives in the case of higher-than-tangent match.\r\n */\r\n public static curvatureSortKey(node: HalfEdge): number {\r\n const cld = node.edgeTag as CurveLocationDetail;\r\n if (cld !== undefined) {\r\n const fraction = cld.fraction;\r\n const curve = cld.curve;\r\n if (curve) {\r\n let radius = curve.fractionToSignedXYRadiusOfCurvature(fraction);\r\n if (node.sortData !== undefined && node.sortData < 0)\r\n radius = -radius;\r\n return radius;\r\n }\r\n }\r\n return 0.0;\r\n }\r\n /** Whether the HalfEdge is part of a null face, as marked by [[clusterAndMergeXYTheta]]. */\r\n public static isNullFace(node: HalfEdge): boolean {\r\n return node.isMaskSet(HalfEdgeMask.NULL_FACE) && node.faceSuccessor.isMaskSet(HalfEdgeMask.NULL_FACE) && node === node.faceSuccessor.faceSuccessor;\r\n }\r\n /**\r\n * Cluster the HalfEdges so that xy-coordinates within `mergeTolerance` are equated.\r\n * * Note that any additional data (e.g., edgeTag, faceTag) on the HalfEdges are ignored. In particular,\r\n * [[CurveLocationDetail]]s attached to clustered HalfEdges do *not* get their points adjusted.\r\n * * This is a simple merge algorithm:\r\n * * untwist all edges from the vertex loops\r\n * * collect array of (x,y,theta) at all nodes\r\n * * lexical sort of the array\r\n * * twist all edges together in sort order around each vertex\r\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\r\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\r\n * * [[HalfEdgeMask.NULL_FACE]] is cleared throughout and applied within null faces.\r\n * @param graph input graph\r\n * @param outboundRadiansFunction optional function to compute the sort angle of an edge at its start vertex\r\n * @param clusterTol optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].\r\n */\r\n public static clusterAndMergeXYTheta(\r\n graph: HalfEdgeGraph,\r\n outboundRadiansFunction?: (he: HalfEdge) => number,\r\n clusterTol: number = Geometry.smallMetricDistance,\r\n ) {\r\n const allNodes = graph.allHalfEdges;\r\n const numNodes = allNodes.length;\r\n graph.clearMask(HalfEdgeMask.NULL_FACE);\r\n const clusters = new ClusterableArray(2, 2, numNodes); // data order: x,y,theta,nodeIndex. But theta is not set in first round.\r\n for (let i = 0; i < numNodes; i++) {\r\n const nodeA = allNodes[i];\r\n const xA = nodeA.x;\r\n const yA = nodeA.y;\r\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\r\n clusters.addDirect(xA, yA, 0.0, i);\r\n }\r\n const order = clusters.clusterIndicesLexical(clusterTol);\r\n let k0 = 0;\r\n const numK = order.length;\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1-1] are at a vertex cluster; equate their xy\r\n if (k1 > k0) {\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n const nodeA0 = allNodes[iA];\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n const nodeB = allNodes[iB];\r\n nodeB.x = nodeA0.x;\r\n nodeB.y = nodeA0.y;\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n // NOW\r\n // 1) There are identical coordinates at all nodes around each vertex loop.\r\n // 2) Hence ready do sort (at each vertex) by theta.\r\n\r\n // insert theta as extra data in the sort table . . .\r\n for (const clusterTableIndex of order) {\r\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\r\n const nodeA = allNodes[clusterTableIndex];\r\n const nodeB = nodeA.faceSuccessor;\r\n let getPrecomputedRadians = outboundRadiansFunction;\r\n if (getPrecomputedRadians) {\r\n // Recompute theta when edge geometry is completely determined by the vertices, which may have been perturbed by clustering.\r\n const detail = nodeA.edgeTag as CurveLocationDetail;\r\n if (undefined === detail || undefined === detail.curve || detail.curve instanceof LineSegment3d)\r\n getPrecomputedRadians = undefined;\r\n }\r\n let radians = getPrecomputedRadians ? getPrecomputedRadians(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI))\r\n radians = Math.PI;\r\n clusters.setExtraData(clusterTableIndex, 0, radians);\r\n }\r\n }\r\n clusters.sortSubsetsBySingleKey(order, 2);\r\n const unmatchedNullFaceNodes: HalfEdge[] = [];\r\n k0 = 0;\r\n let thetaA, thetaB;\r\n\r\n // now pinch each neighboring pair together\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1-1] are properly sorted around a vertex.\r\n if (k1 > k0) {\r\n if (k1 > k0 + 1)\r\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1);\r\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n thetaA = clusters.getExtraData(order[k0], 0);\r\n const nodeA0 = allNodes[iA];\r\n let nodeA = nodeA0;\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n thetaB = clusters.getExtraData(order[k], 0);\r\n const nodeB = allNodes[iB];\r\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n // nope, this edge was flagged and pinched from the other end.\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeB === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\r\n } else {\r\n HalfEdge.pinch(nodeA, nodeB);\r\n\r\n // Detect null face using the heuristic:\r\n // * near vertex angles are same (periodic, toleranced)\r\n // * far vertex is clustered (exactly equal)\r\n // * near vertex curvatures are same (toleranced)\r\n // Note that near vertex is already clustered.\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB)) {\r\n const nodeA1 = nodeA.faceSuccessor;\r\n const nodeB1 = nodeB.edgeMate;\r\n if (nodeA1.isEqualXY(nodeB1)) {\r\n const cA = this.curvatureSortKey(nodeA);\r\n const cB = this.curvatureSortKey(nodeB);\r\n if (Geometry.isSameCoordinate(cA, cB, clusterTol)) { // rule out banana\r\n HalfEdge.pinch(nodeA1, nodeB1);\r\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\r\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\r\n unmatchedNullFaceNodes.push(nodeB1);\r\n }\r\n }\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n }\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n }\r\n\r\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\r\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\r\n for (const p of graph.allHalfEdges) {\r\n\r\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\r\n sweepHeap.priorityQueue.push(p);\r\n }\r\n }\r\n return sweepHeap;\r\n }\r\n\r\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, tol: number = Geometry.smallMetricDistance): { f0: XAndY, f1?: XAndY} | undefined {\r\n const nodeA1 = nodeA0.faceSuccessor;\r\n const aDir = { x: nodeA1.x - nodeA0.x, y: nodeA1.y - nodeA0.y };\r\n const nodeB1 = nodeB0.faceSuccessor;\r\n const bDir = { x: nodeB1.x - nodeB0.x, y: nodeB1.y - nodeB0.y };\r\n let fractions = SmallSystem.lineSegmentXYUVIntersectionUnbounded(nodeA0, aDir, nodeB0, bDir, tol);\r\n if (fractions) {\r\n const snapFractionToSegment = (fraction: number, segStart: XAndY, segEnd: XAndY): number => {\r\n const x = Geometry.interpolate(segStart.x, fraction, segEnd.x);\r\n const y = Geometry.interpolate(segStart.y, fraction, segEnd.y);\r\n if (Geometry.isSameCoordinateXY(x, y, segStart.x, segStart.y, tol))\r\n return 0.0;\r\n if (Geometry.isSameCoordinateXY(x, y, segEnd.x, segEnd.y, tol))\r\n return 1.0;\r\n return fraction;\r\n };\r\n fractions.f0.x = snapFractionToSegment(fractions.f0.x, nodeA0, nodeA1);\r\n fractions.f0.y = snapFractionToSegment(fractions.f0.y, nodeB0, nodeB1);\r\n if (fractions.f1) {\r\n fractions.f1.x = snapFractionToSegment(fractions.f1.x, nodeA0, nodeA1);\r\n fractions.f1.y = snapFractionToSegment(fractions.f1.y, nodeB0, nodeB1);\r\n }\r\n if (fractions.f1 && !(Geometry.isIn01(fractions.f1.x) && Geometry.isIn01(fractions.f1.y)))\r\n fractions.f1 = undefined; // overlap ends beyond a segment; downgrade to simple intersection\r\n if (!(Geometry.isIn01(fractions.f0.x) && Geometry.isIn01(fractions.f0.y))) {\r\n if (fractions.f1) {\r\n fractions.f0 = fractions.f1; // overlap starts beyond a segment; downgrade to simple intersection\r\n fractions.f1 = undefined;\r\n } else\r\n fractions = undefined; // intersection/overlap is outside both segments\r\n }\r\n }\r\n return fractions;\r\n }\r\n /**\r\n * Split edges at intersections.\r\n * * This is a large operation.\r\n * @param graph\r\n */\r\n public static splitIntersectingEdges(graph: HalfEdgeGraph, distanceTol: number = Geometry.smallMetricDistance, fractionTol: number = 1.0e-8): GraphSplitData {\r\n const data = new GraphSplitData();\r\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\r\n let nodeA0, nodeB1;\r\n const smallFraction = fractionTol;\r\n const largeFraction = 1.0 - smallFraction;\r\n let i;\r\n let nodeB0;\r\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\r\n data.numUpEdge++;\r\n const n0 = sweepHeap.activeEdges.length;\r\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - distanceTol);\r\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\r\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\r\n nodeB0 = sweepHeap.activeEdges[i];\r\n nodeB1 = nodeB0.faceSuccessor;\r\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y, distanceTol)) {\r\n data.numA0B0++;\r\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y, distanceTol)) {\r\n data.numA0B1++;\r\n } else {\r\n data.numIntersectionTest++;\r\n const fractions = this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, distanceTol);\r\n if (fractions) {\r\n const splitAndPush = (node: HalfEdge, fraction?: number): void => {\r\n if (fraction !== undefined && fraction > smallFraction && fraction < largeFraction) {\r\n const newNode = graph.splitEdgeAtFraction(node, fraction);\r\n sweepHeap.priorityQueue.push(newNode); // will be popped as a nodeA0 later\r\n data.numSplit++;\r\n }\r\n };\r\n splitAndPush(nodeA0, fractions.f0.x);\r\n splitAndPush(nodeA0, fractions.f1?.x);\r\n splitAndPush(nodeB0, fractions.f0.y);\r\n splitAndPush(nodeB0, fractions.f1?.y);\r\n // existing nodeA0 and its shortened edge remain for further intersections\r\n }\r\n }\r\n }\r\n sweepHeap.activeEdges.push(nodeA0);\r\n }\r\n return data;\r\n }\r\n\r\n /**\r\n * Returns a graph structure formed from the given LineSegment array\r\n *\r\n * * Find all intersections among segments, and split them if necessary\r\n * * Record endpoints of every segment in the form X, Y, Theta; This information is stored as a new node and sorted to match up\r\n * vertices.\r\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\r\n * loops\r\n */\r\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\r\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\r\n const graph = new HalfEdgeGraph();\r\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * * Input is random linestrings, not necessarily loops\r\n * * Graph gets full splitEdges, regularize (optional), and triangulate.\r\n * @returns graph, or undefined if bad data.\r\n */\r\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\r\n if (chains.length < 1)\r\n return undefined;\r\n const graph = new HalfEdgeGraph();\r\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\r\n for (const seed of chainSeeds)\r\n seed.setMaskAroundFace(mask);\r\n\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n if (regularize) {\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n }\r\n return graph;\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Merging.js","sourceRoot":"","sources":["../../../src/topology/Merging.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,sDAA6C;AAC7C,sEAAmE;AACnE,0DAAuD;AACvD,0CAAuC;AACvC,+CAA4C;AAE5C,+CAAuD;AAEvD,mEAAgE;AAChE,yDAAsD;AACtD,mCAAgE;AAChE,mEAAgF;AAChF,qDAAyD;AACzD,mDAA+C;AAE/C,mBAAmB;AAEnB,MAAa,cAAc;IAClB,SAAS,GAAG,CAAC,CAAC;IACd,mBAAmB,GAAG,CAAC,CAAC;IACxB,QAAQ,GAAG,CAAC,CAAC;IACb,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,GAAG,CAAC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QAClC,MAAM,UAAU,GAAG,4BAAY,CAAC,iCAAiC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACjF,KAAK,MAAM,IAAI,IAAI,UAAU;YAC3B,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,IAAI,sCAAqB,CAAC,KAAK,CAAC,CAAC;YACjD,OAAO,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACtC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAEF;AA5WD,gDA4WC","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\n\r\n/** @packageDocumentation\r\n * @module Topology\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { LineSegment3d } from \"../curve/LineSegment3d\";\r\nimport { Geometry } from \"../Geometry\";\r\nimport { Angle } from \"../geometry3d/Angle\";\r\nimport { MultiLineStringDataVariant } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Range2d, Range3d } from \"../geometry3d/Range\";\r\nimport { XAndY } from \"../geometry3d/XYZProps\";\r\nimport { ClusterableArray } from \"../numerics/ClusterableArray\";\r\nimport { SmallSystem } from \"../numerics/SmallSystem\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"./Graph\";\r\nimport { HalfEdgePriorityQueueWithPartnerArray } from \"./HalfEdgePriorityQueue\";\r\nimport { RegularizationContext } from \"./RegularizeFace\";\r\nimport { Triangulator } from \"./Triangulation\";\r\n\r\n// cspell:word XYUV\r\n\r\nexport class GraphSplitData {\r\n public numUpEdge = 0;\r\n public numIntersectionTest = 0;\r\n public numSplit = 0;\r\n public numPopOut = 0;\r\n public numA0B0 = 0;\r\n public numA0B1 = 0;\r\n public constructor() {\r\n }\r\n}\r\n/**\r\n * Structure for data used when sorting outbound edges \"around a node\"\r\n */\r\nexport class VertexNeighborhoodSortData {\r\n public index: number;\r\n public radiusOfCurvature: number;\r\n public node: HalfEdge;\r\n public radians?: number;\r\n public constructor(index: number, key: number, node: HalfEdge, radians?: number) {\r\n this.index = index;\r\n this.radiusOfCurvature = key;\r\n this.node = node;\r\n this.radians = radians;\r\n }\r\n}\r\n\r\n/** Function signature for announcing a vertex neighborhood during sorting. */\r\nexport type AnnounceVertexNeighborhoodSortData = (data: VertexNeighborhoodSortData[]) => any;\r\n/**\r\n * * Assorted methods used in algorithms on HalfEdgeGraph.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphOps {\r\n\r\n /** Compare function for sorting with primary y compare, secondary x compare. */\r\n public static compareNodesYXUp(a: HalfEdge, b: HalfEdge) {\r\n // Check y's\r\n // if (!Geometry.isSameCoordinate(a.y, b.y))\r\n if (a.y < b.y)\r\n return -1;\r\n else if (a.y > b.y)\r\n return 1;\r\n // Check x's\r\n // if (!Geometry.isSameCoordinate(a.x, b.x))\r\n if (a.x < b.x)\r\n return -1;\r\n else if (a.x > b.x)\r\n return 1;\r\n return 0;\r\n }\r\n\r\n /** Return true if nodeB (a) is lower than both its neighbors and (b) inflects as a downward peak (rather than an upward trough) */\r\n public static isDownPeak(nodeB: HalfEdge) {\r\n const nodeA = nodeB.facePredecessor;\r\n const nodeC = nodeB.faceSuccessor;\r\n return this.compareNodesYXUp(nodeB, nodeA) < 0\r\n && this.compareNodesYXUp(nodeB, nodeC) < 0\r\n && this.crossProductToTargets(nodeB, nodeA, nodeC) > 0;\r\n }\r\n\r\n /** return the cross product of vectors from base to targetA and base to targetB\r\n * @param base base vertex of both vectors.\r\n * @param targetA target vertex of first vector\r\n * @param targetB target vertex of second vector\r\n */\r\n public static crossProductToTargets(base: HalfEdge, targetA: HalfEdge, targetB: HalfEdge): number {\r\n return Geometry.crossProductXYXY(targetA.x - base.x, targetA.y - base.y, targetB.x - base.x, targetB.y - base.y);\r\n }\r\n\r\n /** Compute the range of the graph's vertices. */\r\n public static graphRange(graph: Readonly<HalfEdgeGraph>): Range3d {\r\n const range = Range3d.create();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXYZ(node.x, node.y, node.z);\r\n }\r\n return range;\r\n }\r\n /** Compute the xy-range of the graph's vertices. */\r\n public static graphRangeXY(graph: Readonly<HalfEdgeGraph>): Range2d {\r\n const range = Range2d.createNull();\r\n for (const node of graph.allHalfEdges) {\r\n range.extendXY(node.x, node.y);\r\n }\r\n return range;\r\n }\r\n\r\n /** Returns an array of all nodes (both ends) of edges created from segments. */\r\n public static segmentArrayToGraphEdges(segments: LineSegment3d[], returnGraph: HalfEdgeGraph, mask: HalfEdgeMask): HalfEdge[] {\r\n const result = [];\r\n let idxCounter = 0;\r\n\r\n // Push the endpoints of each segment onto arr[] in the form {(x, y, theta), Node}\r\n for (const segment of segments) {\r\n\r\n const node0 = returnGraph.createEdgeXYZXYZ(\r\n segment.point0Ref.x, segment.point0Ref.y, segment.point0Ref.z,\r\n idxCounter,\r\n segment.point1Ref.x, segment.point1Ref.y, segment.point1Ref.z,\r\n idxCounter + 1);\r\n\r\n const node1 = node0.edgeMate;\r\n idxCounter += 2;\r\n\r\n node0.setMaskAroundFace(mask); // Original given coordinates must be part of boundary\r\n result.push(node0);\r\n result.push(node1);\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * * Visit all nodes in `graph`.\r\n * * invoke `pinch(node, vertexPredecessor)`\r\n * * this leaves the graph as isolated edges.\r\n * @param graph graph to modify\r\n */\r\n public static isolateAllEdges(graph: HalfEdgeGraph) {\r\n for (const nodeA of graph.allHalfEdges) {\r\n const nodeB = nodeA.vertexPredecessor;\r\n HalfEdge.pinch(nodeA, nodeB);\r\n }\r\n }\r\n /**\r\n * Compute convexity of a sector of a super-face.\r\n * @param base node whose edge is to be tested for removal\r\n * @param ignore edges with this mask (on either side) are ignored for the purposes of computing convexity\r\n * @param barrier edges with this mask (on either side) will not be removed\r\n * @param signedAreaTol optional signed area tolerance to use in test for parallel vectors\r\n * @return whether removing the edge at base would create a convex sector in the super-face\r\n */\r\n private static isSectorConvexAfterEdgeRemoval(base: HalfEdge, ignore: HalfEdgeMask, barrier: HalfEdgeMask, signedAreaTol: number = 0): boolean {\r\n let vs = base;\r\n do { // loop ccw around vertex looking for a super-face predecessor\r\n if (vs.isMaskSet(barrier) || vs.edgeMate.isMaskSet(barrier))\r\n break;\r\n vs = vs.vertexSuccessor;\r\n } while (vs !== base && vs.isMaskSet(ignore));\r\n if (vs === base)\r\n return false;\r\n let vp = base;\r\n do { // loop cw around vertex looking for a super-face successor\r\n if (vp.isMaskSet(barrier) || vp.edgeMate.isMaskSet(barrier))\r\n break;\r\n vp = vp.vertexPredecessor;\r\n } while (vp !== base && vp.isMaskSet(ignore));\r\n if (vp === base)\r\n return false;\r\n return HalfEdge.isSectorConvex(vs.edgeMate, base, vp.faceSuccessor, signedAreaTol);\r\n }\r\n /**\r\n * Mask edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine and mark\r\n * @param mark the mask used to mark (both sides of) removable edges\r\n * @param barrier edges with this mask (on either side) will not be marked. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges masked (half the number of HalfEdges masked)\r\n */\r\n public static markRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, mark: HalfEdgeMask, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n if (HalfEdgeMask.NULL_MASK === mark)\r\n return 0;\r\n const visit = graph.grabMask(true);\r\n let numMarked = 0;\r\n for (const node of graph.allHalfEdges) {\r\n if (!node.isMaskSet(visit)) {\r\n if (!node.isMaskSet(barrier) && !node.edgeMate.isMaskSet(barrier)) {\r\n // tol based on areas of *original* faces on each side of the edge to be removed\r\n const signedAreaTol = Geometry.smallMetricDistanceSquared * (node.signedFaceArea() + node.edgeMate.signedFaceArea());\r\n if (this.isSectorConvexAfterEdgeRemoval(node, mark, barrier, signedAreaTol) && this.isSectorConvexAfterEdgeRemoval(node.edgeMate, mark, barrier, signedAreaTol)) {\r\n node.setMaskAroundEdge(mark);\r\n ++numMarked;\r\n }\r\n }\r\n }\r\n node.setMaskAroundEdge(visit);\r\n }\r\n graph.dropMask(visit);\r\n return numMarked;\r\n }\r\n /**\r\n * Collect edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to examine\r\n * @param barrier edges with this mask (on either side) will not be collected. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return one HalfEdge per removable edge\r\n */\r\n public static collectRemovableEdgesToExpandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): HalfEdge[] | undefined {\r\n const removable: HalfEdge[] = [];\r\n const mark = graph.grabMask(true);\r\n if (0 < this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier)) {\r\n const visited = graph.grabMask(true);\r\n for (const node of graph.allHalfEdges) {\r\n if (node.isMaskSet(mark) && !node.isMaskSet(visited)) {\r\n node.setMaskAroundEdge(visited);\r\n removable.push(node);\r\n }\r\n }\r\n graph.dropMask(visited);\r\n }\r\n graph.dropMask(mark);\r\n return removable;\r\n }\r\n\r\n /**\r\n * Remove edges between faces if the union of the faces is convex.\r\n * Uses a greedy algorithm with no regard to quality of resulting convex faces.\r\n * Best results when input faces are convex.\r\n * @param graph graph to modify\r\n * @param barrier edges with this mask (on either side) will not be removed. Defaults to HalfEdgeMask.BOUNDARY_EDGE.\r\n * @return number of edges deleted\r\n */\r\n public static expandConvexFaces(graph: HalfEdgeGraph, barrier: HalfEdgeMask = HalfEdgeMask.BOUNDARY_EDGE): number {\r\n const mark = graph.grabMask(true);\r\n const numRemovedEdges = this.markRemovableEdgesToExpandConvexFaces(graph, mark, barrier);\r\n if (numRemovedEdges > 0) {\r\n const numYankedEdges = 0.5 * graph.yankAndDeleteEdges((node: HalfEdge) => node.getMask(mark));\r\n assert(numYankedEdges === numRemovedEdges);\r\n }\r\n graph.dropMask(mark);\r\n return numRemovedEdges;\r\n }\r\n\r\n /**\r\n * Test desired faces for convexity.\r\n * @param graph graph to examine\r\n * @param avoid faces with this mask will not be examined. Defaults to HalfEdgeMask.EXTERIOR.\r\n * @return whether every face in the graph is convex\r\n */\r\n public static isEveryFaceConvex(graph: HalfEdgeGraph, avoid: HalfEdgeMask = HalfEdgeMask.EXTERIOR): boolean {\r\n const allFaces = graph.collectFaceLoops();\r\n for (const node of allFaces) {\r\n if (node.isMaskedAroundFace(avoid))\r\n continue;\r\n if (!node.isFaceConvex())\r\n return false;\r\n }\r\n return true;\r\n }\r\n}\r\n\r\n/**\r\n * Note: this class uses hardcoded micrometer coordinate/cluster tolerance throughout.\r\n * @internal\r\n */\r\nexport class HalfEdgeGraphMerge {\r\n // return kC such that all angles k are equal, with kA <= k < kC <= kB.\r\n // * Assume: angles k are stored at extra data index 0.\r\n // * Note that the usual case (when angle at kA is not repeated) is kA+1 === kC\r\n public static getCommonThetaEndIndex(clusters: ClusterableArray, order: Uint32Array, kA: number, kB: number, radianTol: number = Geometry.smallAngleRadians): number {\r\n let kC = kA + 1;\r\n const thetaA = clusters.getExtraData(order[kA], 0);\r\n while (kC < kB) {\r\n const thetaB = clusters.getExtraData(order[kC], 0);\r\n if (!Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB, radianTol)) {\r\n return kC;\r\n }\r\n kC++;\r\n }\r\n return kC;\r\n }\r\n private static _announceVertexNeighborhoodFunction?: AnnounceVertexNeighborhoodSortData;\r\n /**\r\n * public property setter for a function to be called with sorted edge data around a vertex.\r\n */\r\n public static set announceVertexNeighborhoodFunction(func: AnnounceVertexNeighborhoodSortData | undefined) { this._announceVertexNeighborhoodFunction = func; }\r\n private static doAnnounceVertexNeighborhood(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number) {\r\n if (this._announceVertexNeighborhoodFunction) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n // build and share the entire vertex order\r\n for (let k = k0; k < k1; k++) {\r\n const index = clusters.getExtraData(order[k], 1);\r\n const theta = clusters.getExtraData(order[k], 0);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[k], signedDistance, node, theta));\r\n }\r\n this._announceVertexNeighborhoodFunction(sortData);\r\n }\r\n\r\n }\r\n // assumptions about cluster array:\r\n // * data order is: x,y,theta,nodeIndex\r\n // * theta and nodeIndex are the \"extra\" data.\r\n // * only want to do anything here when curves are present.\r\n // * k0<=k<k1 are around a vertex\r\n // * These are sorted by theta.\r\n private static secondarySortAroundVertex(clusters: ClusterableArray, order: Uint32Array, allNodes: HalfEdge[], k0: number, k1: number, radianTol: number = Geometry.smallAngleRadians) {\r\n const sortData: VertexNeighborhoodSortData[] = [];\r\n\r\n for (let k = k0; k < k1;) {\r\n const kB = this.getCommonThetaEndIndex(clusters, order, k, k1, radianTol);\r\n if (k + 1 < kB) {\r\n sortData.length = 0;\r\n for (let kA = k; kA < kB; kA++) {\r\n const index = clusters.getExtraData(order[kA], 1);\r\n const node = allNodes[index];\r\n const signedDistance = this.curvatureSortKey(node);\r\n sortData.push(new VertexNeighborhoodSortData(order[kA], signedDistance, node));\r\n }\r\n sortData.sort((a: VertexNeighborhoodSortData, b: VertexNeighborhoodSortData) => (a.radiusOfCurvature - b.radiusOfCurvature));\r\n for (let i = 0; i < sortData.length; i++) {\r\n order[k + i] = sortData[i].index;\r\n }\r\n }\r\n k = kB;\r\n }\r\n }\r\n /** Return the sort key for sorting by curvature.\r\n * * This is the signed distance from the curve at the edge start, to center of curvature.\r\n * * ASSUME: edgeTag is a `CurveLocationDetail` whose fractions [f0,f1] define the detail.curve segment traversed\r\n * by the edge. If sortData < 0, the edge traverses the curve segment in reverse order [f1,f0].\r\n * * NOTE: Currently does not account for higher derivatives in the case of higher-than-tangent match.\r\n */\r\n public static curvatureSortKey(node: HalfEdge): number {\r\n if (node.edgeTag !== undefined) {\r\n if (node.edgeTag instanceof CurveLocationDetail) {\r\n const cld = node.edgeTag;\r\n if (cld.curve !== undefined) {\r\n const reverse = node.sortData !== undefined && node.sortData < 0;\r\n const fraction = (reverse && cld.fraction1 !== undefined) ? cld.fraction1 : cld.fraction;\r\n const radius = cld.curve.fractionToSignedXYRadiusOfCurvature(fraction);\r\n return reverse ? -radius : radius;\r\n }\r\n }\r\n }\r\n return 0.0;\r\n }\r\n /** Whether the HalfEdge is part of a null face, as marked by [[clusterAndMergeXYTheta]]. */\r\n public static isNullFace(node: HalfEdge): boolean {\r\n return node.isMaskSet(HalfEdgeMask.NULL_FACE) && node.faceSuccessor.isMaskSet(HalfEdgeMask.NULL_FACE) && node === node.faceSuccessor.faceSuccessor;\r\n }\r\n /**\r\n * Cluster the HalfEdges so that xy-coordinates within `mergeTolerance` are equated.\r\n * * Note that any additional data (e.g., edgeTag, faceTag) on the HalfEdges are ignored. In particular,\r\n * [[CurveLocationDetail]]s attached to clustered HalfEdges do *not* get their points adjusted.\r\n * * This is a simple merge algorithm:\r\n * * untwist all edges from the vertex loops\r\n * * collect array of (x,y,theta) at all nodes\r\n * * lexical sort of the array\r\n * * twist all edges together in sort order around each vertex\r\n * * This effectively creates valid face loops for a planar subdivision if there are no edge crossings.\r\n * * If there are edge crossings, the graph can be a (highly complicated) Klein bottle topology.\r\n * * [[HalfEdgeMask.NULL_FACE]] is cleared throughout and applied within null faces.\r\n * @param graph input graph\r\n * @param outboundRadiansFunction optional function to compute the sort angle of an edge at its start vertex\r\n * @param clusterTol optional distance tolerance for clustering vertices. Default value is [[Geometry.smallMetricDistance]].\r\n */\r\n public static clusterAndMergeXYTheta(\r\n graph: HalfEdgeGraph,\r\n outboundRadiansFunction?: (he: HalfEdge) => number,\r\n clusterTol: number = Geometry.smallMetricDistance,\r\n radianTol: number = Geometry.smallAngleRadians,\r\n ) {\r\n const allNodes = graph.allHalfEdges;\r\n const numNodes = allNodes.length;\r\n graph.clearMask(HalfEdgeMask.NULL_FACE);\r\n const clusters = new ClusterableArray(2, 2, numNodes); // data block: dot,x,y,theta,nodeIndex --- dot and theta are set later\r\n for (let i = 0; i < numNodes; i++) {\r\n const nodeA = allNodes[i];\r\n const xA = nodeA.x;\r\n const yA = nodeA.y;\r\n HalfEdge.pinch(nodeA, nodeA.vertexSuccessor); // pull it out of its current vertex loop.\r\n clusters.addDirect(xA, yA, 0.0, i);\r\n }\r\n const order = clusters.clusterIndicesLexical(clusterTol); // assign primary sort dot product\r\n let k0 = 0;\r\n const numK = order.length;\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1-1] are at a vertex cluster; equate their xy\r\n if (k1 > k0) {\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n const nodeA0 = allNodes[iA];\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n const nodeB = allNodes[iB];\r\n nodeB.x = nodeA0.x;\r\n nodeB.y = nodeA0.y;\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n // NOW\r\n // 1) There are identical coordinates at all nodes around each vertex loop.\r\n // 2) Hence ready do sort (at each vertex) by theta.\r\n\r\n // insert theta as extra data in the sort table . . .\r\n for (const clusterTableIndex of order) {\r\n if (clusterTableIndex !== ClusterableArray.clusterTerminator) {\r\n const nodeA = allNodes[clusterTableIndex];\r\n const nodeB = nodeA.faceSuccessor;\r\n let getPrecomputedRadians = outboundRadiansFunction;\r\n if (getPrecomputedRadians) {\r\n // Recompute theta when edge geometry is completely determined by the vertices, which may have been perturbed by clustering.\r\n const detail = nodeA.edgeTag as CurveLocationDetail;\r\n if (undefined === detail || undefined === detail.curve || detail.curve instanceof LineSegment3d)\r\n getPrecomputedRadians = undefined;\r\n }\r\n let radians = getPrecomputedRadians ? getPrecomputedRadians(nodeA) : Math.atan2(nodeB.y - nodeA.y, nodeB.x - nodeA.x);\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(radians, -Math.PI, radianTol))\r\n radians = Math.PI;\r\n clusters.setExtraData(clusterTableIndex, 0, radians);\r\n }\r\n }\r\n clusters.sortSubsetsBySingleKey(order, 2);\r\n const unmatchedNullFaceNodes: HalfEdge[] = [];\r\n k0 = 0;\r\n let thetaA, thetaB;\r\n\r\n // now pinch each neighboring pair together\r\n for (let k1 = 0; k1 < numK; k1++) {\r\n if (order[k1] === ClusterableArray.clusterTerminator) {\r\n // nodes identified in order[k0]..order[k1-1] are tentatively sorted around a vertex by theta\r\n if (k1 > k0) {\r\n if (k1 > k0 + 1)\r\n this.secondarySortAroundVertex(clusters, order, allNodes, k0, k1, radianTol); // finalize order by resolving ties via curvature\r\n this.doAnnounceVertexNeighborhood(clusters, order, allNodes, k0, k1);\r\n const iA = clusters.getExtraData(order[k0], 1);\r\n thetaA = clusters.getExtraData(order[k0], 0);\r\n const nodeA0 = allNodes[iA];\r\n let nodeA = nodeA0;\r\n for (let k = k0 + 1; k < k1; k++) {\r\n const iB = clusters.getExtraData(order[k], 1);\r\n thetaB = clusters.getExtraData(order[k], 0);\r\n const nodeB = allNodes[iB];\r\n if (nodeA.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n // nope, this edge was flagged and pinched from the other end.\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeA === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n } else if (nodeB.isMaskSet(HalfEdgeMask.NULL_FACE)) {\r\n const j = unmatchedNullFaceNodes.findIndex((node: HalfEdge) => nodeB === node);\r\n if (j >= 0) {\r\n unmatchedNullFaceNodes[j] = unmatchedNullFaceNodes[unmatchedNullFaceNodes.length - 1];\r\n unmatchedNullFaceNodes.pop();\r\n }\r\n // NO leave nodeA and thetaA ignore nodeB -- later step will get the outside of its banana.\r\n } else {\r\n HalfEdge.pinch(nodeA, nodeB);\r\n\r\n // Detect null face using the heuristic:\r\n // * near vertex angles are same (periodic, toleranced)\r\n // * far vertex is clustered (exactly equal)\r\n // * near vertex curvatures are same (toleranced)\r\n // Note that near vertex is already clustered.\r\n if (Angle.isAlmostEqualRadiansAllowPeriodShift(thetaA, thetaB, radianTol)) {\r\n const nodeA1 = nodeA.faceSuccessor;\r\n const nodeB1 = nodeB.edgeMate;\r\n if (nodeA1.isEqualXY(nodeB1)) {\r\n const cA = this.curvatureSortKey(nodeA);\r\n const cB = this.curvatureSortKey(nodeB);\r\n if (Geometry.isSameCoordinate(cA, cB, clusterTol)) { // rule out banana\r\n HalfEdge.pinch(nodeA1, nodeB1);\r\n nodeA.setMask(HalfEdgeMask.NULL_FACE);\r\n nodeB1.setMask(HalfEdgeMask.NULL_FACE);\r\n unmatchedNullFaceNodes.push(nodeB1);\r\n }\r\n }\r\n }\r\n nodeA = nodeB;\r\n thetaA = thetaB;\r\n }\r\n }\r\n }\r\n k0 = k1 + 1;\r\n }\r\n }\r\n }\r\n\r\n private static buildVerticalSweepPriorityQueue(graph: HalfEdgeGraph): HalfEdgePriorityQueueWithPartnerArray {\r\n const sweepHeap = new HalfEdgePriorityQueueWithPartnerArray();\r\n for (const p of graph.allHalfEdges) {\r\n\r\n if (HalfEdgeGraphOps.compareNodesYXUp(p, p.faceSuccessor) < 0) {\r\n sweepHeap.priorityQueue.push(p);\r\n }\r\n }\r\n return sweepHeap;\r\n }\r\n\r\n private static computeIntersectionFractionsOnEdges(nodeA0: HalfEdge, nodeB0: HalfEdge, tol: number = Geometry.smallMetricDistance): { f0: XAndY, f1?: XAndY} | undefined {\r\n const nodeA1 = nodeA0.faceSuccessor;\r\n const aDir = { x: nodeA1.x - nodeA0.x, y: nodeA1.y - nodeA0.y };\r\n const nodeB1 = nodeB0.faceSuccessor;\r\n const bDir = { x: nodeB1.x - nodeB0.x, y: nodeB1.y - nodeB0.y };\r\n let fractions = SmallSystem.lineSegmentXYUVIntersectionUnbounded(nodeA0, aDir, nodeB0, bDir, tol);\r\n if (fractions) {\r\n const snapFractionToSegment = (fraction: number, segStart: XAndY, segEnd: XAndY): number => {\r\n const x = Geometry.interpolate(segStart.x, fraction, segEnd.x);\r\n const y = Geometry.interpolate(segStart.y, fraction, segEnd.y);\r\n if (Geometry.isSameCoordinateXY(x, y, segStart.x, segStart.y, tol))\r\n return 0.0;\r\n if (Geometry.isSameCoordinateXY(x, y, segEnd.x, segEnd.y, tol))\r\n return 1.0;\r\n return fraction;\r\n };\r\n fractions.f0.x = snapFractionToSegment(fractions.f0.x, nodeA0, nodeA1);\r\n fractions.f0.y = snapFractionToSegment(fractions.f0.y, nodeB0, nodeB1);\r\n if (fractions.f1) {\r\n fractions.f1.x = snapFractionToSegment(fractions.f1.x, nodeA0, nodeA1);\r\n fractions.f1.y = snapFractionToSegment(fractions.f1.y, nodeB0, nodeB1);\r\n }\r\n if (fractions.f1 && !(Geometry.isIn01(fractions.f1.x) && Geometry.isIn01(fractions.f1.y)))\r\n fractions.f1 = undefined; // overlap ends beyond a segment; downgrade to simple intersection\r\n if (!(Geometry.isIn01(fractions.f0.x) && Geometry.isIn01(fractions.f0.y))) {\r\n if (fractions.f1) {\r\n fractions.f0 = fractions.f1; // overlap starts beyond a segment; downgrade to simple intersection\r\n fractions.f1 = undefined;\r\n } else\r\n fractions = undefined; // intersection/overlap is outside both segments\r\n }\r\n }\r\n return fractions;\r\n }\r\n /**\r\n * Split edges at intersections.\r\n * * This is a large operation.\r\n * @param graph\r\n */\r\n public static splitIntersectingEdges(graph: HalfEdgeGraph, distanceTol: number = Geometry.smallMetricDistance, fractionTol: number = 1.0e-8): GraphSplitData {\r\n const data = new GraphSplitData();\r\n const sweepHeap = this.buildVerticalSweepPriorityQueue(graph);\r\n let nodeA0, nodeB1;\r\n const smallFraction = fractionTol;\r\n const largeFraction = 1.0 - smallFraction;\r\n let i;\r\n let nodeB0;\r\n while (undefined !== (nodeA0 = sweepHeap.priorityQueue.pop())) {\r\n data.numUpEdge++;\r\n const n0 = sweepHeap.activeEdges.length;\r\n sweepHeap.removeArrayMembersWithY1Below(nodeA0.y - distanceTol);\r\n data.numPopOut += n0 - sweepHeap.activeEdges.length;\r\n for (i = 0; i < sweepHeap.activeEdges.length; i++) {\r\n nodeB0 = sweepHeap.activeEdges[i];\r\n nodeB1 = nodeB0.faceSuccessor;\r\n if (Geometry.isSameCoordinateXY(nodeA0.x, nodeA0.y, nodeB0.x, nodeB0.y, distanceTol)) {\r\n data.numA0B0++;\r\n } else if (Geometry.isSameCoordinateXY(nodeB1.x, nodeB1.y, nodeA0.x, nodeA0.y, distanceTol)) {\r\n data.numA0B1++;\r\n } else {\r\n data.numIntersectionTest++;\r\n const fractions = this.computeIntersectionFractionsOnEdges(nodeA0, nodeB0, distanceTol);\r\n if (fractions) {\r\n const splitAndPush = (node: HalfEdge, fraction?: number): void => {\r\n if (fraction !== undefined && fraction > smallFraction && fraction < largeFraction) {\r\n const newNode = graph.splitEdgeAtFraction(node, fraction);\r\n sweepHeap.priorityQueue.push(newNode); // will be popped as a nodeA0 later\r\n data.numSplit++;\r\n }\r\n };\r\n splitAndPush(nodeA0, fractions.f0.x);\r\n splitAndPush(nodeA0, fractions.f1?.x);\r\n splitAndPush(nodeB0, fractions.f0.y);\r\n splitAndPush(nodeB0, fractions.f1?.y);\r\n // existing nodeA0 and its shortened edge remain for further intersections\r\n }\r\n }\r\n }\r\n sweepHeap.activeEdges.push(nodeA0);\r\n }\r\n return data;\r\n }\r\n\r\n /**\r\n * Returns a graph structure formed from the given LineSegment array\r\n *\r\n * * Find all intersections among segments, and split them if necessary\r\n * * Record endpoints of every segment in the form X, Y, Theta; This information is stored as a new node and sorted to match up\r\n * vertices.\r\n * * For vertices that match up, pinch the nodes to create vertex loops, which in closed objects, will also eventually form face\r\n * loops\r\n */\r\n public static formGraphFromSegments(lineSegments: LineSegment3d[]): HalfEdgeGraph {\r\n // Structure of an index of the array: { xyTheta: Point3d, node: Node }\r\n const graph = new HalfEdgeGraph();\r\n HalfEdgeGraphOps.segmentArrayToGraphEdges(lineSegments, graph, HalfEdgeMask.BOUNDARY_EDGE);\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n return graph;\r\n }\r\n\r\n /**\r\n * * Input is random linestrings, not necessarily loops\r\n * * Graph gets full splitEdges, regularize (optional), and triangulate.\r\n * @returns graph, or undefined if bad data.\r\n */\r\n public static formGraphFromChains(chains: MultiLineStringDataVariant, regularize: boolean = true, mask: HalfEdgeMask = HalfEdgeMask.PRIMARY_EDGE): HalfEdgeGraph | undefined {\r\n if (chains.length < 1)\r\n return undefined;\r\n const graph = new HalfEdgeGraph();\r\n const chainSeeds = Triangulator.directCreateChainsFromCoordinates(graph, chains);\r\n for (const seed of chainSeeds)\r\n seed.setMaskAroundFace(mask);\r\n\r\n this.splitIntersectingEdges(graph);\r\n this.clusterAndMergeXYTheta(graph);\r\n if (regularize) {\r\n const context = new RegularizationContext(graph);\r\n context.regularizeGraph(true, true);\r\n }\r\n return graph;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GeometryHandler } from "../geometry3d/GeometryHandler";
|
|
2
2
|
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
3
|
+
import { Plane3dByOriginAndUnitNormal } from "../geometry3d/Plane3dByOriginAndUnitNormal";
|
|
3
4
|
import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d";
|
|
4
5
|
import { Range1d, Range3d } from "../geometry3d/Range";
|
|
5
6
|
import { Ray3d } from "../geometry3d/Ray3d";
|
|
@@ -211,6 +212,11 @@ export declare abstract class CurveCollection extends GeometryQuery {
|
|
|
211
212
|
projectedParameterRange(ray: Vector3d | Ray3d, lowHigh?: Range1d): Range1d | undefined;
|
|
212
213
|
/** Return the immediate parent of the input curve in the instance, or undefined if it is not a descendant. */
|
|
213
214
|
findParentOfDescendant(descendant: AnyCurve): CurveCollection | undefined;
|
|
215
|
+
/**
|
|
216
|
+
* Ask if the curves of the collection are within tolerance of the input plane.
|
|
217
|
+
* @returns whether the collection is nonempty and its curves lie within tolerance of the plane.
|
|
218
|
+
*/
|
|
219
|
+
isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean;
|
|
214
220
|
}
|
|
215
221
|
/**
|
|
216
222
|
* Shared base class for use by both open and closed paths.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CurveCollection.d.ts","sourceRoot":"","sources":["../../../src/curve/CurveCollection.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAElE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAuC,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACrG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,MAAM,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AKvC,kDAAkD;IAClD,IAAoB,QAAQ,IAAI,QAAQ,EAAE,CAEzC;IACD,gCAAgC;WAClB,MAAM,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,WAAW;IAOtD,gFAAgF;IACzE,eAAe,IAAI,MAAM;IAGhC,mEAAmE;IAC5D,wBAAwB,CAAC,SAAS,EAAE,uBAAuB,EAAE,aAAa,GAAE,MAAW,GAAG,IAAI;IAGrG,0CAA0C;IACnC,YAAY,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,WAAW;IAiBzD,oCAAoC;IAC7B,cAAc,IAAI,WAAW;IAGpC,mBAAmB;IACZ,WAAW,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAKxD,2BAA2B;IACpB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS;IAKhD,8EAA8E;IACvE,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG;CAGhE"}
|
|
@@ -321,6 +321,21 @@ export class CurveCollection extends GeometryQuery {
|
|
|
321
321
|
return undefined;
|
|
322
322
|
}
|
|
323
323
|
;
|
|
324
|
+
/**
|
|
325
|
+
* Ask if the curves of the collection are within tolerance of the input plane.
|
|
326
|
+
* @returns whether the collection is nonempty and its curves lie within tolerance of the plane.
|
|
327
|
+
*/
|
|
328
|
+
isInPlane(plane) {
|
|
329
|
+
if (0 === this.children.length)
|
|
330
|
+
return false; // punt on empty parent...
|
|
331
|
+
for (const child of this.children) {
|
|
332
|
+
if (child instanceof CurveCollection && 0 === child.children.length)
|
|
333
|
+
continue; // ...but ignore an empty child
|
|
334
|
+
if (!child.isInPlane(plane))
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
return true;
|
|
338
|
+
}
|
|
324
339
|
}
|
|
325
340
|
/**
|
|
326
341
|
* Shared base class for use by both open and closed paths.
|