@itwin/core-geometry 4.1.0-dev.2 → 4.1.0-dev.21
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/curve/Arc3d.d.ts +70 -86
- package/lib/cjs/curve/Arc3d.d.ts.map +1 -1
- package/lib/cjs/curve/Arc3d.js +109 -96
- package/lib/cjs/curve/Arc3d.js.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts +61 -41
- package/lib/cjs/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js +69 -46
- package/lib/cjs/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/cjs/curve/CurveCollection.d.ts +47 -30
- package/lib/cjs/curve/CurveCollection.d.ts.map +1 -1
- package/lib/cjs/curve/CurveCollection.js +63 -34
- package/lib/cjs/curve/CurveCollection.js.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.d.ts +40 -41
- package/lib/cjs/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/cjs/curve/CurveLocationDetail.js +31 -35
- package/lib/cjs/curve/CurveLocationDetail.js.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.d.ts +137 -92
- package/lib/cjs/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/cjs/curve/CurvePrimitive.js +114 -75
- package/lib/cjs/curve/CurvePrimitive.js.map +1 -1
- package/lib/cjs/curve/GeometryQuery.d.ts +26 -20
- package/lib/cjs/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/cjs/curve/GeometryQuery.js +11 -9
- package/lib/cjs/curve/GeometryQuery.js.map +1 -1
- package/lib/cjs/curve/LineSegment3d.d.ts +34 -25
- package/lib/cjs/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineSegment3d.js +76 -38
- package/lib/cjs/curve/LineSegment3d.js.map +1 -1
- package/lib/cjs/curve/LineString3d.d.ts +70 -51
- package/lib/cjs/curve/LineString3d.d.ts.map +1 -1
- package/lib/cjs/curve/LineString3d.js +120 -71
- package/lib/cjs/curve/LineString3d.js.map +1 -1
- package/lib/cjs/curve/Loop.d.ts +7 -5
- package/lib/cjs/curve/Loop.d.ts.map +1 -1
- package/lib/cjs/curve/Loop.js +18 -6
- package/lib/cjs/curve/Loop.js.map +1 -1
- package/lib/cjs/curve/ParityRegion.d.ts +7 -7
- package/lib/cjs/curve/ParityRegion.d.ts.map +1 -1
- package/lib/cjs/curve/ParityRegion.js +19 -11
- package/lib/cjs/curve/ParityRegion.js.map +1 -1
- package/lib/cjs/curve/Path.d.ts +6 -6
- package/lib/cjs/curve/Path.d.ts.map +1 -1
- package/lib/cjs/curve/Path.js +15 -9
- package/lib/cjs/curve/Path.js.map +1 -1
- package/lib/cjs/curve/ProxyCurve.d.ts +4 -6
- package/lib/cjs/curve/ProxyCurve.d.ts.map +1 -1
- package/lib/cjs/curve/ProxyCurve.js +7 -7
- package/lib/cjs/curve/ProxyCurve.js.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountMap.d.ts +14 -13
- package/lib/cjs/curve/Query/StrokeCountMap.d.ts.map +1 -1
- package/lib/cjs/curve/Query/StrokeCountMap.js +9 -8
- package/lib/cjs/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/cjs/curve/RegionOps.d.ts +70 -43
- package/lib/cjs/curve/RegionOps.d.ts.map +1 -1
- package/lib/cjs/curve/RegionOps.js +71 -43
- package/lib/cjs/curve/RegionOps.js.map +1 -1
- package/lib/cjs/curve/StrokeOptions.d.ts +29 -21
- package/lib/cjs/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/cjs/curve/StrokeOptions.js +44 -22
- package/lib/cjs/curve/StrokeOptions.js.map +1 -1
- package/lib/cjs/curve/UnionRegion.d.ts +6 -5
- package/lib/cjs/curve/UnionRegion.d.ts.map +1 -1
- package/lib/cjs/curve/UnionRegion.js +17 -8
- package/lib/cjs/curve/UnionRegion.js.map +1 -1
- package/lib/cjs/curve/internalContexts/GapSearchContext.d.ts +2 -1
- package/lib/cjs/curve/internalContexts/GapSearchContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/GapSearchContext.js +6 -2
- package/lib/cjs/curve/internalContexts/GapSearchContext.js.map +1 -1
- package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +14 -8
- package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js +14 -8
- package/lib/cjs/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
- package/lib/cjs/curve/internalContexts/SumLengthsContext.d.ts.map +1 -1
- package/lib/cjs/curve/internalContexts/SumLengthsContext.js +4 -1
- package/lib/cjs/curve/internalContexts/SumLengthsContext.js.map +1 -1
- package/lib/cjs/geometry3d/Matrix3d.d.ts +2 -2
- package/lib/cjs/geometry3d/Matrix3d.js +2 -2
- package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
- package/lib/cjs/geometry3d/Range.d.ts +133 -93
- package/lib/cjs/geometry3d/Range.d.ts.map +1 -1
- package/lib/cjs/geometry3d/Range.js +296 -144
- package/lib/cjs/geometry3d/Range.js.map +1 -1
- package/lib/esm/curve/Arc3d.d.ts +70 -86
- package/lib/esm/curve/Arc3d.d.ts.map +1 -1
- package/lib/esm/curve/Arc3d.js +109 -96
- package/lib/esm/curve/Arc3d.js.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts +61 -41
- package/lib/esm/curve/CurveChainWithDistanceIndex.d.ts.map +1 -1
- package/lib/esm/curve/CurveChainWithDistanceIndex.js +69 -46
- package/lib/esm/curve/CurveChainWithDistanceIndex.js.map +1 -1
- package/lib/esm/curve/CurveCollection.d.ts +47 -30
- package/lib/esm/curve/CurveCollection.d.ts.map +1 -1
- package/lib/esm/curve/CurveCollection.js +63 -34
- package/lib/esm/curve/CurveCollection.js.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.d.ts +40 -41
- package/lib/esm/curve/CurveLocationDetail.d.ts.map +1 -1
- package/lib/esm/curve/CurveLocationDetail.js +31 -35
- package/lib/esm/curve/CurveLocationDetail.js.map +1 -1
- package/lib/esm/curve/CurvePrimitive.d.ts +137 -92
- package/lib/esm/curve/CurvePrimitive.d.ts.map +1 -1
- package/lib/esm/curve/CurvePrimitive.js +114 -75
- package/lib/esm/curve/CurvePrimitive.js.map +1 -1
- package/lib/esm/curve/GeometryQuery.d.ts +26 -20
- package/lib/esm/curve/GeometryQuery.d.ts.map +1 -1
- package/lib/esm/curve/GeometryQuery.js +11 -9
- package/lib/esm/curve/GeometryQuery.js.map +1 -1
- package/lib/esm/curve/LineSegment3d.d.ts +34 -25
- package/lib/esm/curve/LineSegment3d.d.ts.map +1 -1
- package/lib/esm/curve/LineSegment3d.js +76 -38
- package/lib/esm/curve/LineSegment3d.js.map +1 -1
- package/lib/esm/curve/LineString3d.d.ts +70 -51
- package/lib/esm/curve/LineString3d.d.ts.map +1 -1
- package/lib/esm/curve/LineString3d.js +120 -71
- package/lib/esm/curve/LineString3d.js.map +1 -1
- package/lib/esm/curve/Loop.d.ts +7 -5
- package/lib/esm/curve/Loop.d.ts.map +1 -1
- package/lib/esm/curve/Loop.js +18 -6
- package/lib/esm/curve/Loop.js.map +1 -1
- package/lib/esm/curve/ParityRegion.d.ts +7 -7
- package/lib/esm/curve/ParityRegion.d.ts.map +1 -1
- package/lib/esm/curve/ParityRegion.js +19 -11
- package/lib/esm/curve/ParityRegion.js.map +1 -1
- package/lib/esm/curve/Path.d.ts +6 -6
- package/lib/esm/curve/Path.d.ts.map +1 -1
- package/lib/esm/curve/Path.js +15 -9
- package/lib/esm/curve/Path.js.map +1 -1
- package/lib/esm/curve/ProxyCurve.d.ts +4 -6
- package/lib/esm/curve/ProxyCurve.d.ts.map +1 -1
- package/lib/esm/curve/ProxyCurve.js +7 -7
- package/lib/esm/curve/ProxyCurve.js.map +1 -1
- package/lib/esm/curve/Query/StrokeCountMap.d.ts +14 -13
- package/lib/esm/curve/Query/StrokeCountMap.d.ts.map +1 -1
- package/lib/esm/curve/Query/StrokeCountMap.js +9 -8
- package/lib/esm/curve/Query/StrokeCountMap.js.map +1 -1
- package/lib/esm/curve/RegionOps.d.ts +70 -43
- package/lib/esm/curve/RegionOps.d.ts.map +1 -1
- package/lib/esm/curve/RegionOps.js +71 -43
- package/lib/esm/curve/RegionOps.js.map +1 -1
- package/lib/esm/curve/StrokeOptions.d.ts +29 -21
- package/lib/esm/curve/StrokeOptions.d.ts.map +1 -1
- package/lib/esm/curve/StrokeOptions.js +44 -22
- package/lib/esm/curve/StrokeOptions.js.map +1 -1
- package/lib/esm/curve/UnionRegion.d.ts +6 -5
- package/lib/esm/curve/UnionRegion.d.ts.map +1 -1
- package/lib/esm/curve/UnionRegion.js +17 -8
- package/lib/esm/curve/UnionRegion.js.map +1 -1
- package/lib/esm/curve/internalContexts/GapSearchContext.d.ts +2 -1
- package/lib/esm/curve/internalContexts/GapSearchContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/GapSearchContext.js +6 -2
- package/lib/esm/curve/internalContexts/GapSearchContext.js.map +1 -1
- package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts +14 -8
- package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js +14 -8
- package/lib/esm/curve/internalContexts/PlaneAltitudeRangeContext.js.map +1 -1
- package/lib/esm/curve/internalContexts/SumLengthsContext.d.ts.map +1 -1
- package/lib/esm/curve/internalContexts/SumLengthsContext.js +4 -1
- package/lib/esm/curve/internalContexts/SumLengthsContext.js.map +1 -1
- package/lib/esm/geometry3d/Matrix3d.d.ts +2 -2
- package/lib/esm/geometry3d/Matrix3d.js +2 -2
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/lib/esm/geometry3d/Range.d.ts +133 -93
- package/lib/esm/geometry3d/Range.d.ts.map +1 -1
- package/lib/esm/geometry3d/Range.js +296 -144
- package/lib/esm/geometry3d/Range.js.map +1 -1
- package/package.json +3 -3
|
@@ -60,7 +60,8 @@ var RegionBinaryOpType;
|
|
|
60
60
|
* * `ParityRegion` -- a collection of loops, interpreted by parity rules.
|
|
61
61
|
* The common "One outer loop and many Inner loops" is a parity region.
|
|
62
62
|
* * `UnionRegion` -- a collection of `Loop` and `ParityRegion` objects understood as a (probably disjoint) union.
|
|
63
|
-
* * Most of the methods in this class ignore z-coordinates, so callers should ensure that input geometry has been
|
|
63
|
+
* * Most of the methods in this class ignore z-coordinates, so callers should ensure that input geometry has been
|
|
64
|
+
* rotated parallel to the xy-plane.
|
|
64
65
|
* @public
|
|
65
66
|
*/
|
|
66
67
|
class RegionOps {
|
|
@@ -79,7 +80,8 @@ class RegionOps {
|
|
|
79
80
|
}
|
|
80
81
|
return undefined;
|
|
81
82
|
}
|
|
82
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Return an area tolerance for a given xy-range and optional distance tolerance.
|
|
83
85
|
* @param range range of planar region to tolerance
|
|
84
86
|
* @param distanceTolerance optional absolute distance tolerance
|
|
85
87
|
*/
|
|
@@ -102,7 +104,8 @@ class RegionOps {
|
|
|
102
104
|
}
|
|
103
105
|
return undefined;
|
|
104
106
|
}
|
|
105
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Return MomentData with the sums of wire moments.
|
|
106
109
|
* * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with
|
|
107
110
|
* call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`
|
|
108
111
|
* @param root any CurveCollection or CurvePrimitive.
|
|
@@ -115,7 +118,7 @@ class RegionOps {
|
|
|
115
118
|
return result;
|
|
116
119
|
}
|
|
117
120
|
/**
|
|
118
|
-
*
|
|
121
|
+
* Create loops in the graph.
|
|
119
122
|
* @internal
|
|
120
123
|
*/
|
|
121
124
|
static addLoopsToGraph(graph, data, announceIsolatedLoop) {
|
|
@@ -159,7 +162,8 @@ class RegionOps {
|
|
|
159
162
|
}
|
|
160
163
|
}
|
|
161
164
|
}
|
|
162
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Add multiple loops to a graph.
|
|
163
167
|
* * Apply edgeTag and mask to each edge.
|
|
164
168
|
* @internal
|
|
165
169
|
*/
|
|
@@ -178,7 +182,6 @@ class RegionOps {
|
|
|
178
182
|
/**
|
|
179
183
|
* Given a graph just produced by booleans, convert to a polyface
|
|
180
184
|
* * "just produced" implies exterior face markup.
|
|
181
|
-
*
|
|
182
185
|
* @param graph
|
|
183
186
|
* @param triangulate
|
|
184
187
|
*/
|
|
@@ -239,7 +242,8 @@ class RegionOps {
|
|
|
239
242
|
* @param loopsB second set of loops
|
|
240
243
|
* @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA
|
|
241
244
|
* @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 added
|
|
245
|
+
* @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added
|
|
246
|
+
* to connect interior loops to exterior loops.
|
|
243
247
|
*/
|
|
244
248
|
static regionBooleanXY(loopsA, loopsB, operation, mergeTolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
245
249
|
const result = UnionRegion_1.UnionRegion.create();
|
|
@@ -306,10 +310,13 @@ class RegionOps {
|
|
|
306
310
|
}
|
|
307
311
|
return RegionOps.sortOuterAndHoleLoopsXY(allLoops);
|
|
308
312
|
}
|
|
309
|
-
/**
|
|
313
|
+
/**
|
|
314
|
+
* Construct a wire (not area!!) that is offset from given polyline or polygon.
|
|
310
315
|
* * This is a simple wire offset, not an area.
|
|
311
|
-
* * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not
|
|
312
|
-
*
|
|
316
|
+
* * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not
|
|
317
|
+
* guarantee a simple area offset.
|
|
318
|
+
* * The construction algorithm is subject to being changed, resulting in different (hopefully better)
|
|
319
|
+
* self-intersection behavior on the future.
|
|
313
320
|
* @param points a single loop or path
|
|
314
321
|
* @param wrap true to include wraparound
|
|
315
322
|
* @param offsetDistance distance of offset from wire. Positive is left.
|
|
@@ -319,19 +326,22 @@ class RegionOps {
|
|
|
319
326
|
return context.constructPolygonWireXYOffset(points, wrap, offsetDistance);
|
|
320
327
|
}
|
|
321
328
|
/**
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
*
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
329
|
+
* Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).
|
|
330
|
+
* * The construction will remove "some" local effects of features smaller than the offset distance, but will
|
|
331
|
+
* not detect self intersection among widely separated edges.
|
|
332
|
+
* * If offsetDistance is given as a number, default OffsetOptions are applied.
|
|
333
|
+
* * When the offset needs to do an "outside" turn, the first applicable construction is applied:
|
|
334
|
+
* * If the turn is larger than `options.minArcDegrees`, a circular arc is constructed.
|
|
335
|
+
* * If the turn is less than or equal to `options.maxChamferTurnDegrees`, extend curves along tangent to
|
|
336
|
+
* single intersection point.
|
|
337
|
+
* * If the turn is larger than `options.maxChamferDegrees`, the turn is constructed as a sequence of straight
|
|
338
|
+
* lines that are:
|
|
339
|
+
* * outside the arc
|
|
340
|
+
* * have uniform turn angle less than `options.maxChamferDegrees`
|
|
341
|
+
* * each line segment (except first and last) touches the arc at its midpoint.
|
|
342
|
+
* @param curves base curves.
|
|
343
|
+
* @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.
|
|
344
|
+
*/
|
|
335
345
|
static constructCurveXYOffset(curves, offsetDistanceOrOptions) {
|
|
336
346
|
return PolygonOffsetContext_1.CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);
|
|
337
347
|
}
|
|
@@ -345,7 +355,8 @@ class RegionOps {
|
|
|
345
355
|
static testPointInOnOutRegionXY(curves, x, y) {
|
|
346
356
|
return InOutTests_1.PointInOnOutContext.testPointInOnOutRegionXY(curves, x, y);
|
|
347
357
|
}
|
|
348
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Create curve collection of subtype determined by gaps between the input curves.
|
|
349
360
|
* * If (a) wrap is requested and (b) all curves connect head-to-tail (including wraparound), assemble as a `loop`.
|
|
350
361
|
* * If all curves connect head-to-tail except for closure, return a `Path`.
|
|
351
362
|
* * If there are internal gaps, return a `BagOfCurves`
|
|
@@ -382,7 +393,9 @@ class RegionOps {
|
|
|
382
393
|
* Announce Checkpoint function for use during booleans
|
|
383
394
|
* @internal
|
|
384
395
|
*/
|
|
385
|
-
static setCheckPointFunction(f) {
|
|
396
|
+
static setCheckPointFunction(f) {
|
|
397
|
+
this._graphCheckPointFunction = f;
|
|
398
|
+
}
|
|
386
399
|
/**
|
|
387
400
|
* Find all intersections among curves in `curvesToCut` and `cutterCurves` and return fragments of `curvesToCut`.
|
|
388
401
|
* * For a `Loop`, `ParityRegion`, or `UnionRegion` in `curvesToCut`:
|
|
@@ -397,7 +410,8 @@ class RegionOps {
|
|
|
397
410
|
}
|
|
398
411
|
/**
|
|
399
412
|
* Create paths assembled from many curves.
|
|
400
|
-
* * Assemble paths from consecutive curves NOT separated by either gaps or the split markup set by
|
|
413
|
+
* * Assemble paths from consecutive curves NOT separated by either gaps or the split markup set by
|
|
414
|
+
* [[cloneCurvesWithXYSplits]].
|
|
401
415
|
* * Return simplest form -- single primitive, single path, or bag of curves.
|
|
402
416
|
*/
|
|
403
417
|
static splitToPathsBetweenBreaks(source, makeClones) {
|
|
@@ -434,7 +448,8 @@ class RegionOps {
|
|
|
434
448
|
return MultiChainCollector_1.OffsetHelpers.collectChains(fragments, gapTolerance);
|
|
435
449
|
}
|
|
436
450
|
/**
|
|
437
|
-
* Find all intersections among curves in `curvesToCut` against the boundaries of `region` and return fragments
|
|
451
|
+
* Find all intersections among curves in `curvesToCut` against the boundaries of `region` and return fragments
|
|
452
|
+
* of `curvesToCut`.
|
|
438
453
|
* * Break `curvesToCut` into parts inside, outside, and coincident.
|
|
439
454
|
* @returns output object with all fragments split among `insideParts`, `outsideParts`, and `coincidentParts`
|
|
440
455
|
*/
|
|
@@ -460,7 +475,8 @@ class RegionOps {
|
|
|
460
475
|
}
|
|
461
476
|
return result;
|
|
462
477
|
}
|
|
463
|
-
/**
|
|
478
|
+
/**
|
|
479
|
+
* If `data` is one of several forms of a rectangle, return its edge Transform.
|
|
464
480
|
* * Points are considered a rectangle if, within the first 4 points:
|
|
465
481
|
* * vectors from 0 to 1 and 0 to 3 are perpendicular and have a non-zero cross product
|
|
466
482
|
* * vectors from 0 to 3 and 1 to 2 are the same
|
|
@@ -471,7 +487,8 @@ class RegionOps {
|
|
|
471
487
|
* * Array of Point3d[]
|
|
472
488
|
* * IndexedXYZCollection
|
|
473
489
|
* @param requireClosurePoint whether to require a 5th point equal to the 1st point.
|
|
474
|
-
* @returns Transform with origin at one corner, x and y columns extending along two adjacent sides, and unit
|
|
490
|
+
* @returns Transform with origin at one corner, x and y columns extending along two adjacent sides, and unit
|
|
491
|
+
* normal in z column. If not a rectangle, return undefined.
|
|
475
492
|
*/
|
|
476
493
|
static rectangleEdgeTransform(data, requireClosurePoint = true) {
|
|
477
494
|
if (data instanceof LineString3d_1.LineString3d) {
|
|
@@ -531,9 +548,10 @@ class RegionOps {
|
|
|
531
548
|
* * Contiguous `LineSegment3d` and `LineString3d` objects.
|
|
532
549
|
* * collect all points
|
|
533
550
|
* * eliminate duplicated points
|
|
534
|
-
* * eliminate points colinear with surrounding points
|
|
535
|
-
* *
|
|
551
|
+
* * eliminate points colinear with surrounding points
|
|
552
|
+
* * contiguous concentric circular or elliptic arcs
|
|
536
553
|
* * combine angular ranges
|
|
554
|
+
* * This function can be used to compress adjacent LineSegment3ds into a LineString3d
|
|
537
555
|
* @param curves Path or loop (or larger collection containing paths and loops) to be simplified
|
|
538
556
|
* @param options options for tolerance and selective simplification.
|
|
539
557
|
*/
|
|
@@ -547,8 +565,10 @@ class RegionOps {
|
|
|
547
565
|
* @returns a region that captures the input pointers. This region is a:
|
|
548
566
|
* * `Loop` if there is exactly one input loop. It is oriented counterclockwise.
|
|
549
567
|
* * `ParityRegion` if input consists of exactly one outer loop with at least one hole loop.
|
|
550
|
-
* Its first child is an outer loop oriented counterclockwise; all subsequent children are holes oriented
|
|
551
|
-
*
|
|
568
|
+
* Its first child is an outer loop oriented counterclockwise; all subsequent children are holes oriented
|
|
569
|
+
* clockwise.
|
|
570
|
+
* * `UnionRegion` if any other input configuration. Its children are individually ordered/oriented as in
|
|
571
|
+
* the above cases.
|
|
552
572
|
* @see [[PolygonOps.sortOuterAndHoleLoopsXY]]
|
|
553
573
|
*/
|
|
554
574
|
static sortOuterAndHoleLoopsXY(loops) {
|
|
@@ -565,17 +585,22 @@ class RegionOps {
|
|
|
565
585
|
}
|
|
566
586
|
/**
|
|
567
587
|
* Find all areas bounded by the unstructured, possibly intersecting curves.
|
|
568
|
-
* * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
*
|
|
588
|
+
* * A common use case of this method is to assemble the bounding "exterior" loop (or loops) containing the
|
|
589
|
+
* input curves.
|
|
590
|
+
* * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop,
|
|
591
|
+
* regardless of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]]
|
|
592
|
+
* to add bridge edges so that [[constructAllXYRegionLoops]] will return outer and inner loops in the same
|
|
593
|
+
* SignedLoops object.
|
|
594
|
+
* @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve
|
|
595
|
+
* primitives.
|
|
573
596
|
* @param tolerance optional distance tolerance for coincidence
|
|
574
597
|
* @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:
|
|
575
|
-
* * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
|
|
598
|
+
* * `positiveAreaLoops` contains "interior" loops, _including holes in ParityRegion input_. These loops have
|
|
599
|
+
* positive area and counterclockwise orientation.
|
|
576
600
|
* * `negativeAreaLoops` contains (probably just one) "exterior" loop which is ordered clockwise.
|
|
577
601
|
* * `slivers` contains sliver loops that have zero area, such as appear between coincident curves.
|
|
578
|
-
* * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent
|
|
602
|
+
* * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent
|
|
603
|
+
* to the edge and a constituent curve in each.
|
|
579
604
|
*/
|
|
580
605
|
static constructAllXYRegionLoops(curvesAndRegions, tolerance = Geometry_1.Geometry.smallMetricDistance) {
|
|
581
606
|
const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);
|
|
@@ -591,8 +616,10 @@ class RegionOps {
|
|
|
591
616
|
* * Optionally recurses into hidden primitives if `smallestPossiblePrimitives` is true.
|
|
592
617
|
* @param candidates input curves
|
|
593
618
|
* @param collectorArray optional pre-defined output array. If defined, it is NOT cleared: primitives are appended.
|
|
594
|
-
* @param smallestPossiblePrimitives if true, recurse into the children of a [[CurveChainWithDistanceIndex]]. If
|
|
595
|
-
*
|
|
619
|
+
* @param smallestPossiblePrimitives if true, recurse into the children of a [[CurveChainWithDistanceIndex]]. If
|
|
620
|
+
* false, push the [[CurveChainWithDistanceIndex]] instead.
|
|
621
|
+
* @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false,
|
|
622
|
+
* push the [[LineString3d]] instead.
|
|
596
623
|
*/
|
|
597
624
|
static collectCurvePrimitives(candidates, collectorArray, smallestPossiblePrimitives = false, explodeLinestrings = false) {
|
|
598
625
|
const results = collectorArray === undefined ? [] : collectorArray;
|
|
@@ -610,7 +637,8 @@ class RegionOps {
|
|
|
610
637
|
return results;
|
|
611
638
|
}
|
|
612
639
|
/**
|
|
613
|
-
* Copy primitive pointers from candidates to result array, replacing each [[LineString3d]] by newly constructed
|
|
640
|
+
* Copy primitive pointers from candidates to result array, replacing each [[LineString3d]] by newly constructed
|
|
641
|
+
* instances of [[LineSegment3d]].
|
|
614
642
|
* @param candidates input curves
|
|
615
643
|
* @return copied (captured) inputs except for the linestrings, which are exploded
|
|
616
644
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegionOps.js","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,qEAAkE;AAClE,6EAA0E;AAC1E,2EAAwE;AACxE,mEAAwD;AACxD,mGAA2F;AAC3F,+CAA8C;AAC9C,mEAAgE;AAChE,uDAAoD;AACpD,yDAAsD;AAEtD,iEAA8D;AAC9D,6CAA0E;AAC1E,yEAAsE;AACtE,6DAA4G;AAC5G,mEAAgE;AAEhE,uDAAwH;AACxH,6CAA0C;AAC1C,qDAAkD;AAClD,+DAA4D;AAC5D,mDAAgD;AAChD,gFAAuE;AACvE,kFAA6I;AAC7I,iDAA8C;AAC9C,iCAA2C;AAC3C,iDAA8C;AAC9C,iCAA8B;AAC9B,uGAAyG;AACzG,iEAA8D;AAC9D,mDAAyD;AACzD,iEAA8D;AAC9D,uDAAoD;AACpD,mFAAqH;AACrH,+CAA4C;AAiB5C;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,+DAAU,CAAA;IACV,2EAAgB,CAAA;IAChB,iEAAW,CAAA;IACX,iEAAW,CAAA;AACb,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B;AAED;;;;;;;;;GASG;AACH,MAAa,SAAS;IACpB;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CAAC,IAAe;QAChD,MAAM,OAAO,GAAG,IAAI,iCAAe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yB;IACpI,IAAI,MAAM,GAAG,CAAC;QACZ,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACvB,IAAI,MAAM,GAAG,CAAC;QACjB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;QAE1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvB,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\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"../geometry3d/PolylineCompressionByEdgeOffset\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { SortablePolygon } from \"../geometry3d/SortablePolygon\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { MomentData } from \"../geometry4d/MomentData\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { LineStringDataVariant, MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\nimport { ChainCollectorContext } from \"./ChainCollectorContext\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveChain\";\r\nimport { BagOfCurves, ConsolidateAdjacentCurvePrimitivesOptions, CurveChain, CurveCollection } from \"./CurveCollection\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveWireMomentsXYZ } from \"./CurveWireMomentsXYZ\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { OffsetHelpers } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext, JointOptions, OffsetOptions, PolygonWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop, SignedLoops } from \"./Loop\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Path } from \"./Path\";\r\nimport { ConsolidateAdjacentCurvePrimitivesContext } from \"./Query/ConsolidateAdjacentPrimitivesContext\";\r\nimport { CurveSplitContext } from \"./Query/CurveSplitContext\";\r\nimport { PointInOnOutContext } from \"./Query/InOutTests\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { RegionMomentsXY } from \"./RegionMomentsXY\";\r\nimport { RegionBooleanContext, RegionGroupOpType, RegionOpsFaceToFaceSearch } from \"./RegionOpsClassificationSweeps\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\n\r\n/**\r\n * Possible return types from [[splitToPathsBetweenBreaks]], [[collectInsideAndOutsideOffsets]] and [[collectChains]].\r\n * @public\r\n */\r\nexport type ChainTypes = CurvePrimitive | Path | BagOfCurves | Loop | undefined;\r\n\r\n/**\r\n * * `properties` is a string with special characters indicating\r\n * * \"U\" -- contains unmerged stick data\r\n * * \"M\" -- merged\r\n * * \"R\" -- regularized\r\n * * \"X\" -- has exterior markup\r\n * @internal\r\n */\r\nexport type GraphCheckPointFunction = (name: string, graph: HalfEdgeGraph, properties: string, extraData?: any) => any;\r\n/**\r\n * Enumeration of the binary operation types for a booleans among regions\r\n * @public\r\n */\r\nexport enum RegionBinaryOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n AMinusB = 3,\r\n BMinusA = 4,\r\n}\r\n\r\n/**\r\n * Class `RegionOps` has static members for calculations on regions (areas).\r\n * * Regions are represented by these `CurveCollection` subclasses:\r\n * * `Loop` -- a single loop\r\n * * `ParityRegion` -- a collection of loops, interpreted by parity rules.\r\n * The common \"One outer loop and many Inner loops\" is a parity region.\r\n * * `UnionRegion` -- a collection of `Loop` and `ParityRegion` objects understood as a (probably disjoint) union.\r\n * * Most of the methods in this class ignore z-coordinates, so callers should ensure that input geometry has been rotated parallel to the xy-plane.\r\n * @public\r\n */\r\nexport class RegionOps {\r\n /**\r\n * Return moment sums for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYAreaMoments(root: AnyRegion): MomentData | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /** Return an area tolerance for a given xy-range and optional distance tolerance.\r\n * @param range range of planar region to tolerance\r\n * @param distanceTolerance optional absolute distance tolerance\r\n */\r\n public static computeXYAreaTolerance(range: Range3d, distanceTolerance: number = Geometry.smallMetricDistance): number {\r\n // if A = bh and e is distance tolerance, then A' := (b+e/2)(h+e/2) = A + e/2(b+h+e/2), so A'-A = e/2(b+h+e/2).\r\n const halfDistTol = 0.5 * distanceTolerance;\r\n return halfDistTol * (range.xLength() + range.yLength() + halfDistTol);\r\n }\r\n /**\r\n * Return an xy area for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYArea(root: AnyRegion): number | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n return result.quantitySum;\r\n }\r\n return undefined;\r\n }\r\n /** Return MomentData with the sums of wire moments.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any CurveCollection or CurvePrimitive.\r\n */\r\n public static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined {\r\n const handler = new CurveWireMomentsXYZ();\r\n handler.visitLeaves(root);\r\n const result = handler.momentData;\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n\r\n /**\r\n * * create loops in the graph.\r\n * @internal\r\n */\r\n public static addLoopsToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, announceIsolatedLoop: (graph: HalfEdgeGraph, seed: HalfEdge) => void) {\r\n if (data instanceof Loop) {\r\n const points = data.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n } else if (data instanceof ParityRegion) {\r\n for (const child of data.children) {\r\n const points = child.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n }\r\n } else if (data instanceof IndexedXYZCollection) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n } else if (Array.isArray(data)) {\r\n if (data.length > 0) {\r\n if (Point3d.isAnyImmediatePointType(data[0])) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data as LineStringDataVariant);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n\r\n } else if (data[0] instanceof IndexedXYZCollection) {\r\n for (const loop of data) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, loop as IndexedXYZCollection);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n }\r\n } else {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addLoopsToGraph(graph, child as MultiLineStringDataVariant, announceIsolatedLoop);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /** Add multiple loops to a graph.\r\n * * Apply edgeTag and mask to each edge.\r\n * @internal\r\n */\r\n public static addLoopsWithEdgeTagToGraph(graph: HalfEdgeGraph, data: MultiLineStringDataVariant, mask: HalfEdgeMask, edgeTag: any): HalfEdge[] | undefined {\r\n const loopSeeds: HalfEdge[] = [];\r\n this.addLoopsToGraph(graph, data, (_graph: HalfEdgeGraph, seed: HalfEdge) => {\r\n if (seed) {\r\n loopSeeds.push(seed);\r\n seed.setMaskAndEdgeTagAroundFace(mask, edgeTag, true);\r\n }\r\n });\r\n if (loopSeeds.length > 0)\r\n return loopSeeds;\r\n return undefined;\r\n }\r\n /**\r\n * Given a graph just produced by booleans, convert to a polyface\r\n * * \"just produced\" implies exterior face markup.\r\n *\r\n * @param graph\r\n * @param triangulate\r\n */\r\n private static finishGraphToPolyface(graph: HalfEdgeGraph | undefined, triangulate: boolean): Polyface | undefined {\r\n if (graph) {\r\n if (triangulate) {\r\n Triangulator.triangulateAllPositiveAreaFaces(graph);\r\n Triangulator.flipTriangles(graph);\r\n }\r\n return PolyfaceBuilder.graphToPolyface(graph);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return a polyface containing the area intersection of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaIntersectLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * Return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaUnionLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA || inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return a polyface containing the area difference of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaDifferenceLoopsToPolyface(loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(loopsA, loopsB,\r\n (inA: boolean, inB: boolean) => (inA && !inB),\r\n this._graphCheckPointFunction);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n\r\n /**\r\n * Return areas defined by a boolean operation.\r\n * * If there are multiple regions in loopsA, they are treated as a union.\r\n * * If there are multiple regions in loopsB, they are treated as a union.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param mergeTolerance absolute distance tolerance for merging loops\r\n * @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added to connect interior loops to exterior loops.\r\n */\r\n public static regionBooleanXY(loopsA: AnyRegion | AnyRegion[] | undefined, loopsB: AnyRegion | AnyRegion[] | undefined, operation: RegionBinaryOpType, mergeTolerance: number = Geometry.smallMetricDistance): AnyRegion | undefined {\r\n const result = UnionRegion.create();\r\n const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);\r\n context.addMembers(loopsA, loopsB);\r\n context.annotateAndMergeCurvesInGraph(mergeTolerance);\r\n const range = context.groupA.range().union(context.groupB.range());\r\n const areaTol = this.computeXYAreaTolerance(range, mergeTolerance);\r\n context.runClassificationSweep(operation, (_graph: HalfEdgeGraph, face: HalfEdge, faceType: -1 | 0 | 1, area: number) => {\r\n // ignore danglers and null faces, but not 2-edge \"banana\" faces with nonzero area\r\n if (face.countEdgesAroundFace() < 2)\r\n return;\r\n if (Math.abs(area) < areaTol)\r\n return;\r\n if (faceType === 1) {\r\n const loop = PlanarSubdivision.createLoopInFace(face);\r\n if (loop)\r\n result.tryAddChild(loop);\r\n }\r\n });\r\n return result;\r\n }\r\n\r\n /**\r\n * Return a polyface whose facets are a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param inputA first set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param inputB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonBooleanXYToPolyface(inputA: MultiLineStringDataVariant[], operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[], triangulate: boolean = false): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return loops of linestrings around areas of a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param inputA first set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param inputB second set of loops\r\n */\r\n public static polygonBooleanXYToLoops(\r\n inputA: MultiLineStringDataVariant[],\r\n operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[]): AnyRegion | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union, true);\r\n if (!graph)\r\n return undefined;\r\n const loopEdges = HalfEdgeGraphSearch.collectExtendedBoundaryLoopsInGraph(graph, HalfEdgeMask.EXTERIOR);\r\n const allLoops: Loop[] = [];\r\n for (const graphLoop of loopEdges) {\r\n const points = new GrowableXYZArray();\r\n for (const edge of graphLoop)\r\n points.pushXYZ(edge.x, edge.y, edge.z);\r\n points.pushWrap(1);\r\n const loop = Loop.create();\r\n loop.tryAddChild(LineString3d.createCapture(points));\r\n allLoops.push(loop);\r\n }\r\n return RegionOps.sortOuterAndHoleLoopsXY(allLoops);\r\n }\r\n\r\n /** Construct a wire (not area!!) that is offset from given polyline or polygon.\r\n * * This is a simple wire offset, not an area.\r\n * * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not guarantee a simple area offset.\r\n * * The construction algorithm is subject to being changed, resulting in different (hopefully better) self-intersection behavior on the future.\r\n * @param points a single loop or path\r\n * @param wrap true to include wraparound\r\n * @param offsetDistance distance of offset from wire. Positive is left.\r\n */\r\n public static constructPolygonWireXYOffset(points: Point3d[], wrap: boolean, offsetDistance: number): CurveCollection | undefined {\r\n const context = new PolygonWireOffsetContext();\r\n return context.constructPolygonWireXYOffset(points, wrap, offsetDistance);\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will not detect self intersection among widely separated edges.\r\n * * If offsetDistance is given as a number, default OffsetOptions are applied.\r\n * * When the offset needs to do an \"outside\" turn, the first applicable construction is applied:\r\n * * If the turn is larger than `options.minArcDegrees`, a circular arc is constructed.\r\n * * If the turn is less than or equal to `options.maxChamferTurnDegrees`, extend curves along tangent to single intersection point.\r\n * * If the turn is larger than `options.maxChamferDegrees`, the turn is constructed as a sequence of straight lines that are:\r\n * * outside the arc\r\n * * have uniform turn angle less than `options.maxChamferDegrees`\r\n * * each line segment (except first and last) touches the arc at its midpoint.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(curves: Path | Loop, offsetDistanceOrOptions: number | JointOptions | OffsetOptions): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a region.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param curves input region\r\n * @param x x coordinate of point to test\r\n * @param y y coordinate of point to test\r\n */\r\n public static testPointInOnOutRegionXY(curves: AnyRegion, x: number, y: number): number {\r\n return PointInOnOutContext.testPointInOnOutRegionXY(curves, x, y);\r\n }\r\n /** Create curve collection of subtype determined by gaps between the input curves.\r\n * * If (a) wrap is requested and (b) all curves connect head-to-tail (including wraparound), assemble as a `loop`.\r\n * * If all curves connect head-to-tail except for closure, return a `Path`.\r\n * * If there are internal gaps, return a `BagOfCurves`\r\n * * If input array has zero length, return undefined.\r\n * @param curves input curves\r\n * @param wrap whether to create a Loop (true) or Path (false) if maximum gap is minimal\r\n * @param consolidateAdjacentPrimitives whether to simplify the result by calling [[consolidateAdjacentPrimitives]]\r\n */\r\n public static createLoopPathOrBagOfCurves(curves: CurvePrimitive[], wrap: boolean = true, consolidateAdjacentPrimitives: boolean = false): CurveCollection | undefined {\r\n const n = curves.length;\r\n if (n === 0)\r\n return undefined;\r\n let maxGap = 0.0;\r\n let isPath = false;\r\n if (wrap)\r\n maxGap = Geometry.maxXY(maxGap, curves[0].startPoint().distance(curves[n - 1].endPoint()));\r\n for (let i = 0; i + 1 < n; i++)\r\n maxGap = Geometry.maxXY(maxGap, curves[i].endPoint().distance(curves[i + 1].startPoint()));\r\n let collection: Loop | Path | BagOfCurves;\r\n if (Geometry.isSmallMetricDistance(maxGap)) {\r\n collection = wrap ? Loop.create() : Path.create();\r\n isPath = true;\r\n } else {\r\n collection = BagOfCurves.create();\r\n }\r\n for (const c of curves)\r\n collection.tryAddChild(c);\r\n if (isPath && consolidateAdjacentPrimitives)\r\n RegionOps.consolidateAdjacentPrimitives(collection);\r\n return collection;\r\n }\r\n\r\n private static _graphCheckPointFunction?: GraphCheckPointFunction;\r\n /**\r\n * Announce Checkpoint function for use during booleans\r\n * @internal\r\n */\r\n public static setCheckPointFunction(f?: GraphCheckPointFunction) { this._graphCheckPointFunction = f; }\r\n /**\r\n * Find all intersections among curves in `curvesToCut` and `cutterCurves` and return fragments of `curvesToCut`.\r\n * * For a `Loop`, `ParityRegion`, or `UnionRegion` in `curvesToCut`:\r\n * * if it is never cut by any `cutter` curve, it will be left unchanged.\r\n * * if cut, the input is downgraded to a set of `Path` curves joining at the cut points.\r\n * * All cutting is \"as viewed in the xy plane\"\r\n * @param curvesToCut input curves to be fragmented at intersections with `cutterCurves`\r\n * @param cutterCurves input curves to intersect with `curvesToCut`\r\n */\r\n public static cloneCurvesWithXYSplits(curvesToCut: AnyCurve | undefined, cutterCurves: CurveCollection): AnyCurve | undefined {\r\n return CurveSplitContext.cloneCurvesWithXYSplits(curvesToCut, cutterCurves);\r\n }\r\n /**\r\n * Create paths assembled from many curves.\r\n * * Assemble paths from consecutive curves NOT separated by either gaps or the split markup set by [[cloneCurvesWithXYSplits]].\r\n * * Return simplest form -- single primitive, single path, or bag of curves.\r\n */\r\n public static splitToPathsBetweenBreaks(source: AnyCurve | undefined, makeClones: boolean): ChainTypes {\r\n if (source === undefined)\r\n return undefined;\r\n if (source instanceof CurvePrimitive)\r\n return source;\r\n // source is a collection . ..\r\n const primitives = source.collectCurvePrimitives();\r\n const chainCollector = new ChainCollectorContext(makeClones);\r\n for (const primitive of primitives) {\r\n chainCollector.announceCurvePrimitive(primitive);\r\n }\r\n return chainCollector.grabResult();\r\n }\r\n /**\r\n * Restructure curve fragments as chains, and construct (left and right) chain offsets in the xy-plane.\r\n * * BEWARE that if the input is not a loop, the classification of outputs is suspect.\r\n * @param fragments fragments to be chained, z-coordinates ignored\r\n * @param offsetDistance offset distance\r\n * @param gapTolerance absolute endpoint tolerance for computing chains\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideOffsets(fragments: AnyCurve[], offsetDistance: number, gapTolerance: number): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains: ChainTypes } {\r\n return OffsetHelpers.collectInsideAndOutsideOffsets(fragments, offsetDistance, gapTolerance);\r\n }\r\n /**\r\n * Restructure curve fragments as chains.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance absolute endpoint tolerance for computing chains\r\n * @returns chains, possibly wrapped in BagOfCurves if there multiple chains\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance): ChainTypes {\r\n return OffsetHelpers.collectChains(fragments, gapTolerance);\r\n }\r\n\r\n /**\r\n * Find all intersections among curves in `curvesToCut` against the boundaries of `region` and return fragments of `curvesToCut`.\r\n * * Break `curvesToCut` into parts inside, outside, and coincident.\r\n * @returns output object with all fragments split among `insideParts`, `outsideParts`, and `coincidentParts`\r\n */\r\n public static splitPathsByRegionInOnOutXY(curvesToCut: AnyCurve | undefined, region: AnyRegion): { insideParts: AnyCurve[], outsideParts: AnyCurve[], coincidentParts: AnyCurve[] } {\r\n const result = { insideParts: [], outsideParts: [], coincidentParts: [] };\r\n const pathWithIntersectionMarkup = RegionOps.cloneCurvesWithXYSplits(curvesToCut, region);\r\n const splitPaths = RegionOps.splitToPathsBetweenBreaks(pathWithIntersectionMarkup, true);\r\n if (splitPaths instanceof CurveCollection) {\r\n for (const child of splitPaths.children) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(child);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(child, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n } else if (splitPaths instanceof CurvePrimitive) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(splitPaths);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(splitPaths, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n return result;\r\n }\r\n /** If `data` is one of several forms of a rectangle, return its edge Transform.\r\n * * Points are considered a rectangle if, within the first 4 points:\r\n * * vectors from 0 to 1 and 0 to 3 are perpendicular and have a non-zero cross product\r\n * * vectors from 0 to 3 and 1 to 2 are the same\r\n * @param data points in one of several formats:\r\n * * LineString\r\n * * Loop containing rectangle content\r\n * * Path containing rectangle content\r\n * * Array of Point3d[]\r\n * * IndexedXYZCollection\r\n * @param requireClosurePoint whether to require a 5th point equal to the 1st point.\r\n * @returns Transform with origin at one corner, x and y columns extending along two adjacent sides, and unit normal in z column. If not a rectangle, return undefined.\r\n */\r\n public static rectangleEdgeTransform(data: AnyCurve | Point3d[] | IndexedXYZCollection, requireClosurePoint: boolean = true): Transform | undefined {\r\n if (data instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.packedPoints);\r\n } else if (data instanceof IndexedXYZCollection) {\r\n let dataToUse;\r\n if (requireClosurePoint && data.length === 5) {\r\n if (!Geometry.isSmallMetricDistance(data.distanceIndexIndex(0, 4)!))\r\n return undefined;\r\n dataToUse = data;\r\n } else if (!requireClosurePoint && data.length === 4) {\r\n dataToUse = data;\r\n } else if (data.length < (requireClosurePoint ? 5 : 4)) {\r\n return undefined;\r\n } else {\r\n dataToUse = GrowableXYZArray.create(data);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dataToUse, Geometry.smallMetricDistance);\r\n if (dataToUse.length < (requireClosurePoint ? 5 : 4))\r\n return undefined;\r\n }\r\n const vector01 = dataToUse.vectorIndexIndex(0, 1)!;\r\n const vector03 = dataToUse.vectorIndexIndex(0, 3)!;\r\n const vector12 = dataToUse.vectorIndexIndex(1, 2)!;\r\n const normalVector = vector01.crossProduct(vector03);\r\n if (normalVector.normalizeInPlace()\r\n && vector12.isAlmostEqual(vector03)\r\n && vector01.isPerpendicularTo(vector03)) {\r\n return Transform.createOriginAndMatrixColumns(dataToUse.getPoint3dAtUncheckedPointIndex(0), vector01, vector03, normalVector);\r\n }\r\n } else if (Array.isArray(data)) {\r\n return this.rectangleEdgeTransform(new Point3dArrayCarrier(data), requireClosurePoint);\r\n } else if (data instanceof Loop && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, true);\r\n } else if (data instanceof Path && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, requireClosurePoint);\r\n } else if (data instanceof CurveChain) {\r\n if (!data.checkForNonLinearPrimitives()) {\r\n // const linestring = LineString3d.create();\r\n const strokes = data.getPackedStrokes();\r\n if (strokes) {\r\n return this.rectangleEdgeTransform(strokes);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Look for and simplify:\r\n * * Contiguous `LineSegment3d` and `LineString3d` objects.\r\n * * collect all points\r\n * * eliminate duplicated points\r\n * * eliminate points colinear with surrounding points.\r\n * * Contiguous concentric circular or elliptic arcs\r\n * * combine angular ranges\r\n * @param curves Path or loop (or larger collection containing paths and loops) to be simplified\r\n * @param options options for tolerance and selective simplification.\r\n */\r\n public static consolidateAdjacentPrimitives(curves: CurveCollection, options?: ConsolidateAdjacentCurvePrimitivesOptions) {\r\n const context = new ConsolidateAdjacentCurvePrimitivesContext(options);\r\n curves.dispatchToGeometryHandler(context);\r\n }\r\n /**\r\n * Reverse and reorder loops in the xy-plane for consistency and containment.\r\n * @param loops multiple loops in any order and orientation, z-coordinates ignored\r\n * @returns a region that captures the input pointers. This region is a:\r\n * * `Loop` if there is exactly one input loop. It is oriented counterclockwise.\r\n * * `ParityRegion` if input consists of exactly one outer loop with at least one hole loop.\r\n * Its first child is an outer loop oriented counterclockwise; all subsequent children are holes oriented clockwise.\r\n * * `UnionRegion` if any other input configuration. Its children are individually ordered/oriented as in the above cases.\r\n * @see [[PolygonOps.sortOuterAndHoleLoopsXY]]\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const candidate of loops) {\r\n if (candidate instanceof Loop)\r\n SortablePolygon.pushLoop(loopAndArea, candidate);\r\n else if (candidate instanceof IndexedXYZCollection) {\r\n const loop = Loop.createPolygon(candidate);\r\n SortablePolygon.pushLoop(loopAndArea, loop);\r\n }\r\n }\r\n return SortablePolygon.sortAsAnyRegion(loopAndArea);\r\n }\r\n /**\r\n * Find all areas bounded by the unstructured, possibly intersecting curves.\r\n * * A common use case of this method is to assemble the bounding \"exterior\" loop (or loops) containing the input curves.\r\n * * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop, regardless\r\n * of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]] to add bridge edges so that\r\n * [[constructAllXYRegionLoops]] will return outer and inner loops in the same SignedLoops object.\r\n * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve primitives.\r\n * @param tolerance optional distance tolerance for coincidence\r\n * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:\r\n * * `positiveAreaLoops` contains \"interior\" loops, _including holes in ParityRegion input_. These loops have positive area and counterclockwise orientation.\r\n * * `negativeAreaLoops` contains (probably just one) \"exterior\" loop which is ordered clockwise.\r\n * * `slivers` contains sliver loops that have zero area, such as appear between coincident curves.\r\n * * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent to the edge and a constituent curve in each.\r\n */\r\n public static constructAllXYRegionLoops(curvesAndRegions: AnyCurve | AnyCurve[], tolerance: number = Geometry.smallMetricDistance): SignedLoops[] {\r\n const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);\r\n const range = this.curveArrayRange(primitives);\r\n const areaTol = this.computeXYAreaTolerance(range, tolerance);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance);\r\n return PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);\r\n }\r\n\r\n /**\r\n * Collect all `CurvePrimitives` in loosely typed input.\r\n * * Always recurses into primitives within explicit collections (Path, Loop, ParityRegion, UnionRegion).\r\n * * Optionally recurses into hidden primitives if `smallestPossiblePrimitives` is true.\r\n * @param candidates input curves\r\n * @param collectorArray optional pre-defined output array. If defined, it is NOT cleared: primitives are appended.\r\n * @param smallestPossiblePrimitives if true, recurse into the children of a [[CurveChainWithDistanceIndex]]. If false, push the [[CurveChainWithDistanceIndex]] instead.\r\n * @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false, push the [[LineString3d]] instead.\r\n */\r\n public static collectCurvePrimitives(candidates: AnyCurve | AnyCurve[], collectorArray?: CurvePrimitive[],\r\n smallestPossiblePrimitives: boolean = false,\r\n explodeLinestrings: boolean = false): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n if (candidates instanceof CurvePrimitive) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (candidates instanceof CurveCollection) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (Array.isArray(candidates)) {\r\n for (const c of candidates) {\r\n this.collectCurvePrimitives(c, results, smallestPossiblePrimitives, explodeLinestrings);\r\n }\r\n }\r\n return results;\r\n }\r\n /**\r\n * Copy primitive pointers from candidates to result array, replacing each [[LineString3d]] by newly constructed instances of [[LineSegment3d]].\r\n * @param candidates input curves\r\n * @return copied (captured) inputs except for the linestrings, which are exploded\r\n */\r\n public static expandLineStrings(candidates: CurvePrimitive[]): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n for (const c of candidates) {\r\n if (c instanceof LineString3d) {\r\n for (let i = 0; i + 1 < c.packedPoints.length; i++) {\r\n const q = c.getIndexedSegment(i);\r\n if (q !== undefined)\r\n result.push(q);\r\n }\r\n } else {\r\n result.push(c);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the overall range of given curves.\r\n * @param data candidate curves\r\n * @param worldToLocal transform to apply to data before computing its range\r\n */\r\n public static curveArrayRange(data: any, worldToLocal?: Transform): Range3d {\r\n const range = Range3d.create();\r\n if (data instanceof GeometryQuery)\r\n data.extendRange(range, worldToLocal);\r\n else if (Array.isArray(data)) {\r\n for (const c of data) {\r\n if (c instanceof GeometryQuery)\r\n c.extendRange(range, worldToLocal);\r\n else if (c instanceof Point3d)\r\n range.extendPoint(c, worldToLocal);\r\n else if (c instanceof GrowableXYZArray)\r\n range.extendRange(c.getRange(worldToLocal));\r\n else if (Array.isArray(c))\r\n range.extendRange(this.curveArrayRange(c, worldToLocal));\r\n }\r\n }\r\n return range;\r\n }\r\n}\r\n\r\n/** @internal */\r\nfunction pushToInOnOutArrays(curve: AnyCurve, select: number, arrayNegative: AnyCurve[], array0: AnyCurve[], arrayPositive: AnyCurve[]) {\r\n if (select > 0)\r\n arrayPositive.push(curve);\r\n else if (select < 0)\r\n arrayNegative.push(curve);\r\n else\r\n array0.push(curve);\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"RegionOps.js","sourceRoot":"","sources":["../../../src/curve/RegionOps.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F;;GAEG;AAEH,0CAAuC;AACvC,qEAAkE;AAClE,6EAA0E;AAC1E,2EAAwE;AACxE,mEAAwD;AACxD,mGAA2F;AAC3F,+CAA8C;AAC9C,mEAAgE;AAChE,uDAAoD;AACpD,yDAAsD;AAEtD,iEAA8D;AAC9D,6CAA0E;AAC1E,yEAAsE;AACtE,6DAA4G;AAC5G,mEAAgE;AAEhE,uDAAwH;AACxH,6CAA0C;AAC1C,qDAAkD;AAClD,+DAA4D;AAC5D,mDAAgD;AAChD,gFAAuE;AACvE,kFAA6I;AAC7I,iDAA8C;AAC9C,iCAA2C;AAC3C,iDAA8C;AAC9C,iCAA8B;AAC9B,uGAAyG;AACzG,iEAA8D;AAC9D,mDAAyD;AACzD,iEAA8D;AAC9D,uDAAoD;AACpD,mFAAqH;AACrH,+CAA4C;AAmB5C;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,+DAAU,CAAA;IACV,2EAAgB,CAAA;IAChB,iEAAW,CAAA;IACX,iEAAW,CAAA;AACb,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B;AAED;;;;;;;;;;GAUG;AACH,MAAa,SAAS;IACpB;;;;;OAKG;IACI,MAAM,CAAC,oBAAoB,CAAC,IAAe;QAChD,MAAM,OAAO,GAAG,IAAI,iCAAe,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;QACvD,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IAAI,CAAC,KAAK,CAAC,CAAC;SACvB,IAAI,MAAM,GAAG,CAAC;QACjB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;;QAE1B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACvB,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\n\r\n/** @packageDocumentation\r\n * @module Curve\r\n */\r\n\r\nimport { Geometry } from \"../Geometry\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { IndexedXYZCollection } from \"../geometry3d/IndexedXYZCollection\";\r\nimport { Point3dArrayCarrier } from \"../geometry3d/Point3dArrayCarrier\";\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { PolylineCompressionContext } from \"../geometry3d/PolylineCompressionByEdgeOffset\";\r\nimport { Range3d } from \"../geometry3d/Range\";\r\nimport { SortablePolygon } from \"../geometry3d/SortablePolygon\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { MomentData } from \"../geometry4d/MomentData\";\r\nimport { Polyface } from \"../polyface/Polyface\";\r\nimport { PolyfaceBuilder } from \"../polyface/PolyfaceBuilder\";\r\nimport { HalfEdge, HalfEdgeGraph, HalfEdgeMask } from \"../topology/Graph\";\r\nimport { HalfEdgeGraphSearch } from \"../topology/HalfEdgeGraphSearch\";\r\nimport { LineStringDataVariant, MultiLineStringDataVariant, Triangulator } from \"../topology/Triangulation\";\r\nimport { ChainCollectorContext } from \"./ChainCollectorContext\";\r\nimport { AnyCurve, AnyRegion } from \"./CurveChain\";\r\nimport { BagOfCurves, ConsolidateAdjacentCurvePrimitivesOptions, CurveChain, CurveCollection } from \"./CurveCollection\";\r\nimport { CurveCurve } from \"./CurveCurve\";\r\nimport { CurvePrimitive } from \"./CurvePrimitive\";\r\nimport { CurveWireMomentsXYZ } from \"./CurveWireMomentsXYZ\";\r\nimport { GeometryQuery } from \"./GeometryQuery\";\r\nimport { OffsetHelpers } from \"./internalContexts/MultiChainCollector\";\r\nimport { CurveChainWireOffsetContext, JointOptions, OffsetOptions, PolygonWireOffsetContext } from \"./internalContexts/PolygonOffsetContext\";\r\nimport { LineString3d } from \"./LineString3d\";\r\nimport { Loop, SignedLoops } from \"./Loop\";\r\nimport { ParityRegion } from \"./ParityRegion\";\r\nimport { Path } from \"./Path\";\r\nimport { ConsolidateAdjacentCurvePrimitivesContext } from \"./Query/ConsolidateAdjacentPrimitivesContext\";\r\nimport { CurveSplitContext } from \"./Query/CurveSplitContext\";\r\nimport { PointInOnOutContext } from \"./Query/InOutTests\";\r\nimport { PlanarSubdivision } from \"./Query/PlanarSubdivision\";\r\nimport { RegionMomentsXY } from \"./RegionMomentsXY\";\r\nimport { RegionBooleanContext, RegionGroupOpType, RegionOpsFaceToFaceSearch } from \"./RegionOpsClassificationSweeps\";\r\nimport { UnionRegion } from \"./UnionRegion\";\r\n\r\n/**\r\n * Possible return types from [[splitToPathsBetweenBreaks]], [[collectInsideAndOutsideOffsets]] and\r\n * [[collectChains]].\r\n * @public\r\n */\r\nexport type ChainTypes = CurvePrimitive | Path | BagOfCurves | Loop | undefined;\r\n\r\n/**\r\n * * `properties` is a string with special characters indicating\r\n * * \"U\" -- contains unmerged stick data\r\n * * \"M\" -- merged\r\n * * \"R\" -- regularized\r\n * * \"X\" -- has exterior markup\r\n * @internal\r\n */\r\nexport type GraphCheckPointFunction = (name: string, graph: HalfEdgeGraph, properties: string, extraData?: any) => any;\r\n\r\n/**\r\n * Enumeration of the binary operation types for a booleans among regions\r\n * @public\r\n */\r\nexport enum RegionBinaryOpType {\r\n Union = 0,\r\n Parity = 1,\r\n Intersection = 2,\r\n AMinusB = 3,\r\n BMinusA = 4,\r\n}\r\n\r\n/**\r\n * Class `RegionOps` has static members for calculations on regions (areas).\r\n * * Regions are represented by these `CurveCollection` subclasses:\r\n * * `Loop` -- a single loop\r\n * * `ParityRegion` -- a collection of loops, interpreted by parity rules.\r\n * The common \"One outer loop and many Inner loops\" is a parity region.\r\n * * `UnionRegion` -- a collection of `Loop` and `ParityRegion` objects understood as a (probably disjoint) union.\r\n * * Most of the methods in this class ignore z-coordinates, so callers should ensure that input geometry has been\r\n * rotated parallel to the xy-plane.\r\n * @public\r\n */\r\nexport class RegionOps {\r\n /**\r\n * Return moment sums for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYAreaMoments(root: AnyRegion): MomentData | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return an area tolerance for a given xy-range and optional distance tolerance.\r\n * @param range range of planar region to tolerance\r\n * @param distanceTolerance optional absolute distance tolerance\r\n */\r\n public static computeXYAreaTolerance(range: Range3d, distanceTolerance: number = Geometry.smallMetricDistance): number {\r\n // if A = bh and e is distance tolerance, then A' := (b+e/2)(h+e/2) = A + e/2(b+h+e/2), so A'-A = e/2(b+h+e/2).\r\n const halfDistTol = 0.5 * distanceTolerance;\r\n return halfDistTol * (range.xLength() + range.yLength() + halfDistTol);\r\n }\r\n /**\r\n * Return an xy area for a loop, parity region, or union region.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any Loop, ParityRegion, or UnionRegion.\r\n */\r\n public static computeXYArea(root: AnyRegion): number | undefined {\r\n const handler = new RegionMomentsXY();\r\n const result = root.dispatchToGeometryHandler(handler);\r\n if (result instanceof MomentData) {\r\n return result.quantitySum;\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return MomentData with the sums of wire moments.\r\n * * If `rawMomentData` is the MomentData returned by computeXYAreaMoments, convert to principal axes and moments with\r\n * call `principalMomentData = MomentData.inertiaProductsToPrincipalAxes (rawMomentData.origin, rawMomentData.sums);`\r\n * @param root any CurveCollection or CurvePrimitive.\r\n */\r\n public static computeXYZWireMomentSums(root: AnyCurve): MomentData | undefined {\r\n const handler = new CurveWireMomentsXYZ();\r\n handler.visitLeaves(root);\r\n const result = handler.momentData;\r\n result.shiftOriginAndSumsToCentroidOfSums();\r\n return result;\r\n }\r\n /**\r\n * Create loops in the graph.\r\n * @internal\r\n */\r\n public static addLoopsToGraph(\r\n graph: HalfEdgeGraph,\r\n data: MultiLineStringDataVariant,\r\n announceIsolatedLoop: (graph: HalfEdgeGraph, seed: HalfEdge) => void\r\n ): void {\r\n if (data instanceof Loop) {\r\n const points = data.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n } else if (data instanceof ParityRegion) {\r\n for (const child of data.children) {\r\n const points = child.getPackedStrokes();\r\n if (points)\r\n this.addLoopsToGraph(graph, points, announceIsolatedLoop);\r\n }\r\n } else if (data instanceof IndexedXYZCollection) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n } else if (Array.isArray(data)) {\r\n if (data.length > 0) {\r\n if (Point3d.isAnyImmediatePointType(data[0])) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, data as LineStringDataVariant);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n\r\n } else if (data[0] instanceof IndexedXYZCollection) {\r\n for (const loop of data) {\r\n const loopSeed = Triangulator.directCreateFaceLoopFromCoordinates(graph, loop as IndexedXYZCollection);\r\n if (loopSeed !== undefined)\r\n announceIsolatedLoop(graph, loopSeed);\r\n }\r\n } else {\r\n for (const child of data) {\r\n if (Array.isArray(child))\r\n this.addLoopsToGraph(graph, child as MultiLineStringDataVariant, announceIsolatedLoop);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n /**\r\n * Add multiple loops to a graph.\r\n * * Apply edgeTag and mask to each edge.\r\n * @internal\r\n */\r\n public static addLoopsWithEdgeTagToGraph(\r\n graph: HalfEdgeGraph, data: MultiLineStringDataVariant, mask: HalfEdgeMask, edgeTag: any\r\n ): HalfEdge[] | undefined {\r\n const loopSeeds: HalfEdge[] = [];\r\n this.addLoopsToGraph(graph, data, (_graph: HalfEdgeGraph, seed: HalfEdge) => {\r\n if (seed) {\r\n loopSeeds.push(seed);\r\n seed.setMaskAndEdgeTagAroundFace(mask, edgeTag, true);\r\n }\r\n });\r\n if (loopSeeds.length > 0)\r\n return loopSeeds;\r\n return undefined;\r\n }\r\n /**\r\n * Given a graph just produced by booleans, convert to a polyface\r\n * * \"just produced\" implies exterior face markup.\r\n * @param graph\r\n * @param triangulate\r\n */\r\n private static finishGraphToPolyface(graph: HalfEdgeGraph | undefined, triangulate: boolean): Polyface | undefined {\r\n if (graph) {\r\n if (triangulate) {\r\n Triangulator.triangulateAllPositiveAreaFaces(graph);\r\n Triangulator.flipTriangles(graph);\r\n }\r\n return PolyfaceBuilder.graphToPolyface(graph);\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Return a polyface containing the area intersection of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaIntersectLoopsToPolyface(\r\n loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false\r\n ): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(\r\n loopsA,\r\n loopsB,\r\n (inA: boolean, inB: boolean) => (inA && inB),\r\n this._graphCheckPointFunction\r\n );\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return a polyface containing the area union of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaUnionLoopsToPolyface(\r\n loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false\r\n ): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(\r\n loopsA,\r\n loopsB,\r\n (inA: boolean, inB: boolean) => (inA || inB),\r\n this._graphCheckPointFunction\r\n );\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return a polyface containing the area difference of two XY regions.\r\n * * Within each region, in and out is determined by parity rules.\r\n * * Any face that is an odd number of crossings from the far outside is IN\r\n * * Any face that is an even number of crossings from the far outside is OUT\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonXYAreaDifferenceLoopsToPolyface(\r\n loopsA: MultiLineStringDataVariant, loopsB: MultiLineStringDataVariant, triangulate: boolean = false\r\n ): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doPolygonBoolean(\r\n loopsA,\r\n loopsB,\r\n (inA: boolean, inB: boolean) => (inA && !inB),\r\n this._graphCheckPointFunction\r\n );\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return areas defined by a boolean operation.\r\n * * If there are multiple regions in loopsA, they are treated as a union.\r\n * * If there are multiple regions in loopsB, they are treated as a union.\r\n * @param loopsA first set of loops\r\n * @param loopsB second set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param mergeTolerance absolute distance tolerance for merging loops\r\n * @returns a region resulting from merging input loops and the boolean operation. May contain bridge edges added\r\n * to connect interior loops to exterior loops.\r\n */\r\n public static regionBooleanXY(\r\n loopsA: AnyRegion | AnyRegion[] | undefined,\r\n loopsB: AnyRegion | AnyRegion[] | undefined,\r\n operation: RegionBinaryOpType,\r\n mergeTolerance: number = Geometry.smallMetricDistance\r\n ): AnyRegion | undefined {\r\n const result = UnionRegion.create();\r\n const context = RegionBooleanContext.create(RegionGroupOpType.Union, RegionGroupOpType.Union);\r\n context.addMembers(loopsA, loopsB);\r\n context.annotateAndMergeCurvesInGraph(mergeTolerance);\r\n const range = context.groupA.range().union(context.groupB.range());\r\n const areaTol = this.computeXYAreaTolerance(range, mergeTolerance);\r\n context.runClassificationSweep(\r\n operation,\r\n (_graph: HalfEdgeGraph, face: HalfEdge, faceType: -1 | 0 | 1, area: number) => {\r\n // ignore danglers and null faces, but not 2-edge \"banana\" faces with nonzero area\r\n if (face.countEdgesAroundFace() < 2)\r\n return;\r\n if (Math.abs(area) < areaTol)\r\n return;\r\n if (faceType === 1) {\r\n const loop = PlanarSubdivision.createLoopInFace(face);\r\n if (loop)\r\n result.tryAddChild(loop);\r\n }\r\n }\r\n );\r\n return result;\r\n }\r\n /**\r\n * Return a polyface whose facets are a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param inputA first set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param inputB second set of loops\r\n * @param triangulate whether to triangulate the result\r\n */\r\n public static polygonBooleanXYToPolyface(\r\n inputA: MultiLineStringDataVariant[],\r\n operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[],\r\n triangulate: boolean = false\r\n ): Polyface | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA, RegionGroupOpType.Union,\r\n operation,\r\n inputB, RegionGroupOpType.Union,\r\n true\r\n );\r\n return this.finishGraphToPolyface(graph, triangulate);\r\n }\r\n /**\r\n * Return loops of linestrings around areas of a boolean operation between the input regions.\r\n * * Each of the two inputs is an array of multiple loops or parity regions.\r\n * * Within each of these input arrays, the various entries (loop or set of loops) are interpreted as a union.\r\n * * In each \"array of loops and parity regions\", each entry inputA[i] or inputB[i] is one of:\r\n * * A simple loop, e.g. array of Point3d.\r\n * * Several simple loops, each of which is an array of Point3d.\r\n * @param inputA first set of loops\r\n * @param operation indicates Union, Intersection, Parity, AMinusB, or BMinusA\r\n * @param inputB second set of loops\r\n */\r\n public static polygonBooleanXYToLoops(\r\n inputA: MultiLineStringDataVariant[],\r\n operation: RegionBinaryOpType,\r\n inputB: MultiLineStringDataVariant[]\r\n ): AnyRegion | undefined {\r\n const graph = RegionOpsFaceToFaceSearch.doBinaryBooleanBetweenMultiLoopInputs(\r\n inputA,\r\n RegionGroupOpType.Union,\r\n operation,\r\n inputB,\r\n RegionGroupOpType.Union,\r\n true\r\n );\r\n if (!graph)\r\n return undefined;\r\n const loopEdges = HalfEdgeGraphSearch.collectExtendedBoundaryLoopsInGraph(graph, HalfEdgeMask.EXTERIOR);\r\n const allLoops: Loop[] = [];\r\n for (const graphLoop of loopEdges) {\r\n const points = new GrowableXYZArray();\r\n for (const edge of graphLoop)\r\n points.pushXYZ(edge.x, edge.y, edge.z);\r\n points.pushWrap(1);\r\n const loop = Loop.create();\r\n loop.tryAddChild(LineString3d.createCapture(points));\r\n allLoops.push(loop);\r\n }\r\n return RegionOps.sortOuterAndHoleLoopsXY(allLoops);\r\n }\r\n /**\r\n * Construct a wire (not area!!) that is offset from given polyline or polygon.\r\n * * This is a simple wire offset, not an area.\r\n * * The construction algorithm attempts to eliminate some self-intersections within the offsets, but does not\r\n * guarantee a simple area offset.\r\n * * The construction algorithm is subject to being changed, resulting in different (hopefully better)\r\n * self-intersection behavior on the future.\r\n * @param points a single loop or path\r\n * @param wrap true to include wraparound\r\n * @param offsetDistance distance of offset from wire. Positive is left.\r\n */\r\n public static constructPolygonWireXYOffset(\r\n points: Point3d[], wrap: boolean, offsetDistance: number\r\n ): CurveCollection | undefined {\r\n const context = new PolygonWireOffsetContext();\r\n return context.constructPolygonWireXYOffset(points, wrap, offsetDistance);\r\n }\r\n /**\r\n * Construct curves that are offset from a Path or Loop as viewed in xy-plane (ignoring z).\r\n * * The construction will remove \"some\" local effects of features smaller than the offset distance, but will\r\n * not detect self intersection among widely separated edges.\r\n * * If offsetDistance is given as a number, default OffsetOptions are applied.\r\n * * When the offset needs to do an \"outside\" turn, the first applicable construction is applied:\r\n * * If the turn is larger than `options.minArcDegrees`, a circular arc is constructed.\r\n * * If the turn is less than or equal to `options.maxChamferTurnDegrees`, extend curves along tangent to\r\n * single intersection point.\r\n * * If the turn is larger than `options.maxChamferDegrees`, the turn is constructed as a sequence of straight\r\n * lines that are:\r\n * * outside the arc\r\n * * have uniform turn angle less than `options.maxChamferDegrees`\r\n * * each line segment (except first and last) touches the arc at its midpoint.\r\n * @param curves base curves.\r\n * @param offsetDistanceOrOptions offset distance (positive to left of curve, negative to right) or options object.\r\n */\r\n public static constructCurveXYOffset(\r\n curves: Path | Loop, offsetDistanceOrOptions: number | JointOptions | OffsetOptions\r\n ): CurveCollection | undefined {\r\n return CurveChainWireOffsetContext.constructCurveXYOffset(curves, offsetDistanceOrOptions);\r\n }\r\n /**\r\n * Test if point (x,y) is IN, OUT or ON a region.\r\n * @return (1) for in, (-1) for OUT, (0) for ON\r\n * @param curves input region\r\n * @param x x coordinate of point to test\r\n * @param y y coordinate of point to test\r\n */\r\n public static testPointInOnOutRegionXY(curves: AnyRegion, x: number, y: number): number {\r\n return PointInOnOutContext.testPointInOnOutRegionXY(curves, x, y);\r\n }\r\n /**\r\n * Create curve collection of subtype determined by gaps between the input curves.\r\n * * If (a) wrap is requested and (b) all curves connect head-to-tail (including wraparound), assemble as a `loop`.\r\n * * If all curves connect head-to-tail except for closure, return a `Path`.\r\n * * If there are internal gaps, return a `BagOfCurves`\r\n * * If input array has zero length, return undefined.\r\n * @param curves input curves\r\n * @param wrap whether to create a Loop (true) or Path (false) if maximum gap is minimal\r\n * @param consolidateAdjacentPrimitives whether to simplify the result by calling [[consolidateAdjacentPrimitives]]\r\n */\r\n public static createLoopPathOrBagOfCurves(\r\n curves: CurvePrimitive[], wrap: boolean = true, consolidateAdjacentPrimitives: boolean = false\r\n ): CurveCollection | undefined {\r\n const n = curves.length;\r\n if (n === 0)\r\n return undefined;\r\n let maxGap = 0.0;\r\n let isPath = false;\r\n if (wrap)\r\n maxGap = Geometry.maxXY(maxGap, curves[0].startPoint().distance(curves[n - 1].endPoint()));\r\n for (let i = 0; i + 1 < n; i++)\r\n maxGap = Geometry.maxXY(maxGap, curves[i].endPoint().distance(curves[i + 1].startPoint()));\r\n let collection: Loop | Path | BagOfCurves;\r\n if (Geometry.isSmallMetricDistance(maxGap)) {\r\n collection = wrap ? Loop.create() : Path.create();\r\n isPath = true;\r\n } else {\r\n collection = BagOfCurves.create();\r\n }\r\n for (const c of curves)\r\n collection.tryAddChild(c);\r\n if (isPath && consolidateAdjacentPrimitives)\r\n RegionOps.consolidateAdjacentPrimitives(collection);\r\n return collection;\r\n }\r\n private static _graphCheckPointFunction?: GraphCheckPointFunction;\r\n /**\r\n * Announce Checkpoint function for use during booleans\r\n * @internal\r\n */\r\n public static setCheckPointFunction(f?: GraphCheckPointFunction) {\r\n this._graphCheckPointFunction = f;\r\n }\r\n /**\r\n * Find all intersections among curves in `curvesToCut` and `cutterCurves` and return fragments of `curvesToCut`.\r\n * * For a `Loop`, `ParityRegion`, or `UnionRegion` in `curvesToCut`:\r\n * * if it is never cut by any `cutter` curve, it will be left unchanged.\r\n * * if cut, the input is downgraded to a set of `Path` curves joining at the cut points.\r\n * * All cutting is \"as viewed in the xy plane\"\r\n * @param curvesToCut input curves to be fragmented at intersections with `cutterCurves`\r\n * @param cutterCurves input curves to intersect with `curvesToCut`\r\n */\r\n public static cloneCurvesWithXYSplits(\r\n curvesToCut: AnyCurve | undefined, cutterCurves: CurveCollection\r\n ): AnyCurve | undefined {\r\n return CurveSplitContext.cloneCurvesWithXYSplits(curvesToCut, cutterCurves);\r\n }\r\n /**\r\n * Create paths assembled from many curves.\r\n * * Assemble paths from consecutive curves NOT separated by either gaps or the split markup set by\r\n * [[cloneCurvesWithXYSplits]].\r\n * * Return simplest form -- single primitive, single path, or bag of curves.\r\n */\r\n public static splitToPathsBetweenBreaks(source: AnyCurve | undefined, makeClones: boolean): ChainTypes {\r\n if (source === undefined)\r\n return undefined;\r\n if (source instanceof CurvePrimitive)\r\n return source;\r\n // source is a collection . ..\r\n const primitives = source.collectCurvePrimitives();\r\n const chainCollector = new ChainCollectorContext(makeClones);\r\n for (const primitive of primitives) {\r\n chainCollector.announceCurvePrimitive(primitive);\r\n }\r\n return chainCollector.grabResult();\r\n }\r\n /**\r\n * Restructure curve fragments as chains, and construct (left and right) chain offsets in the xy-plane.\r\n * * BEWARE that if the input is not a loop, the classification of outputs is suspect.\r\n * @param fragments fragments to be chained, z-coordinates ignored\r\n * @param offsetDistance offset distance\r\n * @param gapTolerance absolute endpoint tolerance for computing chains\r\n * @returns object with named chains, insideOffsets, outsideOffsets\r\n */\r\n public static collectInsideAndOutsideOffsets(\r\n fragments: AnyCurve[], offsetDistance: number, gapTolerance: number\r\n ): { insideOffsets: AnyCurve[], outsideOffsets: AnyCurve[], chains: ChainTypes } {\r\n return OffsetHelpers.collectInsideAndOutsideOffsets(fragments, offsetDistance, gapTolerance);\r\n }\r\n /**\r\n * Restructure curve fragments as chains.\r\n * @param fragments fragments to be chained\r\n * @param gapTolerance absolute endpoint tolerance for computing chains\r\n * @returns chains, possibly wrapped in BagOfCurves if there multiple chains\r\n */\r\n public static collectChains(fragments: AnyCurve[], gapTolerance: number = Geometry.smallMetricDistance): ChainTypes {\r\n return OffsetHelpers.collectChains(fragments, gapTolerance);\r\n }\r\n /**\r\n * Find all intersections among curves in `curvesToCut` against the boundaries of `region` and return fragments\r\n * of `curvesToCut`.\r\n * * Break `curvesToCut` into parts inside, outside, and coincident.\r\n * @returns output object with all fragments split among `insideParts`, `outsideParts`, and `coincidentParts`\r\n */\r\n public static splitPathsByRegionInOnOutXY(\r\n curvesToCut: AnyCurve | undefined, region: AnyRegion\r\n ): { insideParts: AnyCurve[], outsideParts: AnyCurve[], coincidentParts: AnyCurve[] } {\r\n const result = { insideParts: [], outsideParts: [], coincidentParts: [] };\r\n const pathWithIntersectionMarkup = RegionOps.cloneCurvesWithXYSplits(curvesToCut, region);\r\n const splitPaths = RegionOps.splitToPathsBetweenBreaks(pathWithIntersectionMarkup, true);\r\n if (splitPaths instanceof CurveCollection) {\r\n for (const child of splitPaths.children) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(child);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(child, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n } else if (splitPaths instanceof CurvePrimitive) {\r\n const pointOnChild = CurveCollection.createCurveLocationDetailOnAnyCurvePrimitive(splitPaths);\r\n if (pointOnChild) {\r\n const inOnOut = RegionOps.testPointInOnOutRegionXY(region, pointOnChild.point.x, pointOnChild.point.y);\r\n pushToInOnOutArrays(splitPaths, inOnOut, result.outsideParts, result.coincidentParts, result.insideParts);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * If `data` is one of several forms of a rectangle, return its edge Transform.\r\n * * Points are considered a rectangle if, within the first 4 points:\r\n * * vectors from 0 to 1 and 0 to 3 are perpendicular and have a non-zero cross product\r\n * * vectors from 0 to 3 and 1 to 2 are the same\r\n * @param data points in one of several formats:\r\n * * LineString\r\n * * Loop containing rectangle content\r\n * * Path containing rectangle content\r\n * * Array of Point3d[]\r\n * * IndexedXYZCollection\r\n * @param requireClosurePoint whether to require a 5th point equal to the 1st point.\r\n * @returns Transform with origin at one corner, x and y columns extending along two adjacent sides, and unit\r\n * normal in z column. If not a rectangle, return undefined.\r\n */\r\n public static rectangleEdgeTransform(\r\n data: AnyCurve | Point3d[] | IndexedXYZCollection, requireClosurePoint: boolean = true\r\n ): Transform | undefined {\r\n if (data instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.packedPoints);\r\n } else if (data instanceof IndexedXYZCollection) {\r\n let dataToUse;\r\n if (requireClosurePoint && data.length === 5) {\r\n if (!Geometry.isSmallMetricDistance(data.distanceIndexIndex(0, 4)!))\r\n return undefined;\r\n dataToUse = data;\r\n } else if (!requireClosurePoint && data.length === 4) {\r\n dataToUse = data;\r\n } else if (data.length < (requireClosurePoint ? 5 : 4)) {\r\n return undefined;\r\n } else {\r\n dataToUse = GrowableXYZArray.create(data);\r\n PolylineCompressionContext.compressInPlaceByShortEdgeLength(dataToUse, Geometry.smallMetricDistance);\r\n if (dataToUse.length < (requireClosurePoint ? 5 : 4))\r\n return undefined;\r\n }\r\n const vector01 = dataToUse.vectorIndexIndex(0, 1)!;\r\n const vector03 = dataToUse.vectorIndexIndex(0, 3)!;\r\n const vector12 = dataToUse.vectorIndexIndex(1, 2)!;\r\n const normalVector = vector01.crossProduct(vector03);\r\n if (normalVector.normalizeInPlace()\r\n && vector12.isAlmostEqual(vector03)\r\n && vector01.isPerpendicularTo(vector03)) {\r\n return Transform.createOriginAndMatrixColumns(\r\n dataToUse.getPoint3dAtUncheckedPointIndex(0), vector01, vector03, normalVector\r\n );\r\n }\r\n } else if (Array.isArray(data)) {\r\n return this.rectangleEdgeTransform(new Point3dArrayCarrier(data), requireClosurePoint);\r\n } else if (data instanceof Loop && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, true);\r\n } else if (data instanceof Path && data.children.length === 1 && data.children[0] instanceof LineString3d) {\r\n return this.rectangleEdgeTransform(data.children[0].packedPoints, requireClosurePoint);\r\n } else if (data instanceof CurveChain) {\r\n if (!data.checkForNonLinearPrimitives()) {\r\n // const linestring = LineString3d.create();\r\n const strokes = data.getPackedStrokes();\r\n if (strokes) {\r\n return this.rectangleEdgeTransform(strokes);\r\n }\r\n }\r\n }\r\n return undefined;\r\n }\r\n /**\r\n * Look for and simplify:\r\n * * Contiguous `LineSegment3d` and `LineString3d` objects.\r\n * * collect all points\r\n * * eliminate duplicated points\r\n * * eliminate points colinear with surrounding points\r\n * * contiguous concentric circular or elliptic arcs\r\n * * combine angular ranges\r\n * * This function can be used to compress adjacent LineSegment3ds into a LineString3d\r\n * @param curves Path or loop (or larger collection containing paths and loops) to be simplified\r\n * @param options options for tolerance and selective simplification.\r\n */\r\n public static consolidateAdjacentPrimitives(\r\n curves: CurveCollection, options?: ConsolidateAdjacentCurvePrimitivesOptions\r\n ): void {\r\n const context = new ConsolidateAdjacentCurvePrimitivesContext(options);\r\n curves.dispatchToGeometryHandler(context);\r\n }\r\n /**\r\n * Reverse and reorder loops in the xy-plane for consistency and containment.\r\n * @param loops multiple loops in any order and orientation, z-coordinates ignored\r\n * @returns a region that captures the input pointers. This region is a:\r\n * * `Loop` if there is exactly one input loop. It is oriented counterclockwise.\r\n * * `ParityRegion` if input consists of exactly one outer loop with at least one hole loop.\r\n * Its first child is an outer loop oriented counterclockwise; all subsequent children are holes oriented\r\n * clockwise.\r\n * * `UnionRegion` if any other input configuration. Its children are individually ordered/oriented as in\r\n * the above cases.\r\n * @see [[PolygonOps.sortOuterAndHoleLoopsXY]]\r\n */\r\n public static sortOuterAndHoleLoopsXY(loops: Array<Loop | IndexedXYZCollection>): AnyRegion {\r\n const loopAndArea: SortablePolygon[] = [];\r\n for (const candidate of loops) {\r\n if (candidate instanceof Loop)\r\n SortablePolygon.pushLoop(loopAndArea, candidate);\r\n else if (candidate instanceof IndexedXYZCollection) {\r\n const loop = Loop.createPolygon(candidate);\r\n SortablePolygon.pushLoop(loopAndArea, loop);\r\n }\r\n }\r\n return SortablePolygon.sortAsAnyRegion(loopAndArea);\r\n }\r\n /**\r\n * Find all areas bounded by the unstructured, possibly intersecting curves.\r\n * * A common use case of this method is to assemble the bounding \"exterior\" loop (or loops) containing the\r\n * input curves.\r\n * * This method does not add bridge edges to connect outer loops to inner loops. Each disconnected loop,\r\n * regardless of its containment, is returned as its own SignedLoops object. Pre-process with [[regionBooleanXY]]\r\n * to add bridge edges so that [[constructAllXYRegionLoops]] will return outer and inner loops in the same\r\n * SignedLoops object.\r\n * @param curvesAndRegions Any collection of curves. Each Loop/ParityRegion/UnionRegion contributes its curve\r\n * primitives.\r\n * @param tolerance optional distance tolerance for coincidence\r\n * @returns array of [[SignedLoops]], each entry of which describes the faces in a single connected component:\r\n * * `positiveAreaLoops` contains \"interior\" loops, _including holes in ParityRegion input_. These loops have\r\n * positive area and counterclockwise orientation.\r\n * * `negativeAreaLoops` contains (probably just one) \"exterior\" loop which is ordered clockwise.\r\n * * `slivers` contains sliver loops that have zero area, such as appear between coincident curves.\r\n * * `edges` contains a [[LoopCurveLoopCurve]] object for each component edge, collecting both loops adjacent\r\n * to the edge and a constituent curve in each.\r\n */\r\n public static constructAllXYRegionLoops(\r\n curvesAndRegions: AnyCurve | AnyCurve[], tolerance: number = Geometry.smallMetricDistance\r\n ): SignedLoops[] {\r\n const primitives = RegionOps.collectCurvePrimitives(curvesAndRegions, undefined, true, true);\r\n const range = this.curveArrayRange(primitives);\r\n const areaTol = this.computeXYAreaTolerance(range, tolerance);\r\n const intersections = CurveCurve.allIntersectionsAmongPrimitivesXY(primitives, tolerance);\r\n const graph = PlanarSubdivision.assembleHalfEdgeGraph(primitives, intersections, tolerance);\r\n return PlanarSubdivision.collectSignedLoopSetsInHalfEdgeGraph(graph, areaTol);\r\n }\r\n /**\r\n * Collect all `CurvePrimitives` in loosely typed input.\r\n * * Always recurses into primitives within explicit collections (Path, Loop, ParityRegion, UnionRegion).\r\n * * Optionally recurses into hidden primitives if `smallestPossiblePrimitives` is true.\r\n * @param candidates input curves\r\n * @param collectorArray optional pre-defined output array. If defined, it is NOT cleared: primitives are appended.\r\n * @param smallestPossiblePrimitives if true, recurse into the children of a [[CurveChainWithDistanceIndex]]. If\r\n * false, push the [[CurveChainWithDistanceIndex]] instead.\r\n * @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false,\r\n * push the [[LineString3d]] instead.\r\n */\r\n public static collectCurvePrimitives(\r\n candidates: AnyCurve | AnyCurve[],\r\n collectorArray?: CurvePrimitive[],\r\n smallestPossiblePrimitives: boolean = false,\r\n explodeLinestrings: boolean = false\r\n ): CurvePrimitive[] {\r\n const results: CurvePrimitive[] = collectorArray === undefined ? [] : collectorArray;\r\n if (candidates instanceof CurvePrimitive) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (candidates instanceof CurveCollection) {\r\n candidates.collectCurvePrimitives(results, smallestPossiblePrimitives, explodeLinestrings);\r\n } else if (Array.isArray(candidates)) {\r\n for (const c of candidates) {\r\n this.collectCurvePrimitives(c, results, smallestPossiblePrimitives, explodeLinestrings);\r\n }\r\n }\r\n return results;\r\n }\r\n /**\r\n * Copy primitive pointers from candidates to result array, replacing each [[LineString3d]] by newly constructed\r\n * instances of [[LineSegment3d]].\r\n * @param candidates input curves\r\n * @return copied (captured) inputs except for the linestrings, which are exploded\r\n */\r\n public static expandLineStrings(candidates: CurvePrimitive[]): CurvePrimitive[] {\r\n const result: CurvePrimitive[] = [];\r\n for (const c of candidates) {\r\n if (c instanceof LineString3d) {\r\n for (let i = 0; i + 1 < c.packedPoints.length; i++) {\r\n const q = c.getIndexedSegment(i);\r\n if (q !== undefined)\r\n result.push(q);\r\n }\r\n } else {\r\n result.push(c);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return the overall range of given curves.\r\n * @param data candidate curves\r\n * @param worldToLocal transform to apply to data before computing its range\r\n */\r\n public static curveArrayRange(data: any, worldToLocal?: Transform): Range3d {\r\n const range = Range3d.create();\r\n if (data instanceof GeometryQuery)\r\n data.extendRange(range, worldToLocal);\r\n else if (Array.isArray(data)) {\r\n for (const c of data) {\r\n if (c instanceof GeometryQuery)\r\n c.extendRange(range, worldToLocal);\r\n else if (c instanceof Point3d)\r\n range.extendPoint(c, worldToLocal);\r\n else if (c instanceof GrowableXYZArray)\r\n range.extendRange(c.getRange(worldToLocal));\r\n else if (Array.isArray(c))\r\n range.extendRange(this.curveArrayRange(c, worldToLocal));\r\n }\r\n }\r\n return range;\r\n }\r\n}\r\n/** @internal */\r\nfunction pushToInOnOutArrays(\r\n curve: AnyCurve, select: number, arrayNegative: AnyCurve[], array0: AnyCurve[], arrayPositive: AnyCurve[]\r\n): void {\r\n if (select > 0)\r\n arrayPositive.push(curve);\r\n else if (select < 0)\r\n arrayNegative.push(curve);\r\n else\r\n array0.push(curve);\r\n}\r\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Angle } from "../geometry3d/Angle";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Tolerance blob for various stroking methods.
|
|
3
4
|
*
|
|
4
5
|
* * Across many applications, the critical concepts are: chordTol, angleTol, maxEdgeLength
|
|
5
6
|
* * Chord error is an distance measured from a curve or facet to its approximating stroke or facet.
|
|
@@ -21,17 +22,17 @@ import { Angle } from "../geometry3d/Angle";
|
|
|
21
22
|
* @public
|
|
22
23
|
*/
|
|
23
24
|
export declare class StrokeOptions {
|
|
24
|
-
/**
|
|
25
|
+
/** Distance from stroke to actual geometry */
|
|
25
26
|
chordTol?: number;
|
|
26
|
-
/**
|
|
27
|
+
/** Turning angle between strokes. */
|
|
27
28
|
angleTol?: Angle;
|
|
28
|
-
/**
|
|
29
|
+
/** Maximum length of a single stroke. */
|
|
29
30
|
maxEdgeLength?: number;
|
|
30
|
-
/**
|
|
31
|
+
/** Caller expects convex facets. */
|
|
31
32
|
needConvexFacets?: boolean;
|
|
32
|
-
/**
|
|
33
|
+
/** Minimum strokes on a primitive */
|
|
33
34
|
minStrokesPerPrimitive?: number;
|
|
34
|
-
/**
|
|
35
|
+
/** Whether or not to triangulate each added facet */
|
|
35
36
|
shouldTriangulate: boolean;
|
|
36
37
|
private _needNormals?;
|
|
37
38
|
private _needTwoSided?;
|
|
@@ -45,27 +46,29 @@ export declare class StrokeOptions {
|
|
|
45
46
|
/** Whether twoSided is requested. */
|
|
46
47
|
get needTwoSided(): boolean;
|
|
47
48
|
set needTwoSided(value: boolean);
|
|
48
|
-
/**
|
|
49
|
+
/** Optional color request flag */
|
|
49
50
|
needColors?: boolean;
|
|
50
|
-
/**
|
|
51
|
+
/** Default number of strokes for a circle. */
|
|
51
52
|
defaultCircleStrokes: number;
|
|
52
|
-
/**
|
|
53
|
+
/** Ask if angleTol is specified */
|
|
53
54
|
get hasAngleTol(): boolean;
|
|
54
|
-
/**
|
|
55
|
+
/** Ask if chordTol is specified */
|
|
55
56
|
get hasChordTol(): boolean;
|
|
56
|
-
/**
|
|
57
|
+
/** Ask if maxEdgeLength is specified */
|
|
57
58
|
get hasMaxEdgeLength(): boolean;
|
|
58
59
|
/** Return a deep clone */
|
|
59
60
|
clone(): StrokeOptions;
|
|
60
|
-
/**
|
|
61
|
+
/** Return stroke count which is the larger of the minCount or count needed for edge length condition. */
|
|
61
62
|
applyMaxEdgeLength(minCount: number, totalLength: number): number;
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
+
* Return stroke count which is the larger of the existing count or count needed for angle condition for given
|
|
65
|
+
* sweepRadians.
|
|
64
66
|
* * defaultStepRadians is assumed to be larger than zero.
|
|
65
67
|
*/
|
|
66
68
|
applyAngleTol(minCount: number, sweepRadians: number, defaultStepRadians: number): number;
|
|
67
69
|
/**
|
|
68
|
-
*
|
|
70
|
+
* Return stroke count which is the larger of minCount and the count required to turn sweepRadians, using tolerance
|
|
71
|
+
* from the options.
|
|
69
72
|
*/
|
|
70
73
|
static applyAngleTol(options: StrokeOptions | undefined, minCount: number, sweepRadians: number, defaultStepRadians?: number): number;
|
|
71
74
|
/**
|
|
@@ -76,22 +79,27 @@ export declare class StrokeOptions {
|
|
|
76
79
|
*/
|
|
77
80
|
static applyMaxEdgeLength(options: StrokeOptions | undefined, minCount: number, edgeLength: number): number;
|
|
78
81
|
/**
|
|
79
|
-
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
82
|
+
* Determine a stroke count for a (partial) circular arc of given radius. This considers angle, maxEdgeLength,
|
|
83
|
+
* chord, and minimum stroke.
|
|
80
84
|
*/
|
|
81
85
|
applyTolerancesToArc(radius: number, sweepRadians?: number): number;
|
|
82
|
-
/**
|
|
86
|
+
/** Return stroke count which is the larger of existing count or count needed for circular arc chord tolerance condition. */
|
|
83
87
|
applyChordTol(minCount: number, radius: number, sweepRadians: number): number;
|
|
84
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Return stroke count which is the larger of existing count or count needed for circular arc chord tol with given
|
|
90
|
+
* arc length and radians
|
|
85
91
|
*/
|
|
86
92
|
applyChordTolToLengthAndRadians(minCount: number, length: number, sweepRadians: number): number;
|
|
87
|
-
/**
|
|
93
|
+
/** Return stroke count which is the larger of existing count or `this.minStrokesPerPrimitive` */
|
|
88
94
|
applyMinStrokesPerPrimitive(minCount: number): number;
|
|
89
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Create `StrokeOptions` with defaults appropriate for curves.
|
|
90
97
|
* * angle tolerance of 15 degrees.
|
|
91
98
|
* * all others inactive.
|
|
92
99
|
*/
|
|
93
100
|
static createForCurves(): StrokeOptions;
|
|
94
|
-
/**
|
|
101
|
+
/**
|
|
102
|
+
* Create `StrokeOptions` with defaults appropriate for surfaces facets
|
|
95
103
|
* * angle tolerance of 22.5 degrees.
|
|
96
104
|
* * all others inactive.
|
|
97
105
|
*/
|