@itwin/core-geometry 4.3.0-dev.15 → 4.3.0-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/clipping/ClipUtils.d.ts +32 -5
- package/lib/cjs/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/cjs/clipping/ClipUtils.js +92 -11
- package/lib/cjs/clipping/ClipUtils.js.map +1 -1
- package/lib/cjs/numerics/Newton.js +2 -1
- package/lib/cjs/numerics/Newton.js.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts +1 -0
- package/lib/cjs/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/cjs/polyface/PolyfaceBuilder.js +1 -0
- package/lib/cjs/polyface/PolyfaceBuilder.js.map +1 -1
- package/lib/esm/clipping/ClipUtils.d.ts +32 -5
- package/lib/esm/clipping/ClipUtils.d.ts.map +1 -1
- package/lib/esm/clipping/ClipUtils.js +92 -11
- package/lib/esm/clipping/ClipUtils.js.map +1 -1
- package/lib/esm/numerics/Newton.js +2 -1
- package/lib/esm/numerics/Newton.js.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.d.ts +1 -0
- package/lib/esm/polyface/PolyfaceBuilder.d.ts.map +1 -1
- package/lib/esm/polyface/PolyfaceBuilder.js +1 -0
- package/lib/esm/polyface/PolyfaceBuilder.js.map +1 -1
- package/package.json +3 -3
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @module CartesianGeometry
|
|
3
3
|
*/
|
|
4
4
|
import { Arc3d } from "../curve/Arc3d";
|
|
5
|
-
import { AnyCurve, AnyRegion } from "../curve/CurveTypes";
|
|
6
5
|
import { AnnounceNumberNumber, AnnounceNumberNumberCurvePrimitive, CurvePrimitive } from "../curve/CurvePrimitive";
|
|
6
|
+
import { AnyCurve, AnyRegion } from "../curve/CurveTypes";
|
|
7
7
|
import { GeometryQuery } from "../curve/GeometryQuery";
|
|
8
8
|
import { GrowableFloat64Array } from "../geometry3d/GrowableFloat64Array";
|
|
9
9
|
import { GrowableXYZArray } from "../geometry3d/GrowableXYZArray";
|
|
@@ -238,17 +238,44 @@ export declare class ClipUtilities {
|
|
|
238
238
|
* @param ignoreInvisiblePlanes if true, do NOT compute a facet for convex set faces marked invisible.
|
|
239
239
|
*/
|
|
240
240
|
static doesConvexClipPlaneSetIntersectRange(convexSet: ConvexClipPlaneSet, range: Range3d, includeConvexSetFaces?: boolean, includeRangeFaces?: boolean, ignoreInvisiblePlanes?: boolean): boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Create a clipper from the transformed range.
|
|
243
|
+
* @param range input range to create clipper from
|
|
244
|
+
* @param transform how to transform the range (NOTE: applied to the range faces without swelling the range volume)
|
|
245
|
+
* @param degeneratePoints optionally populated with the 1 or 2 points defining the transformed range if it is degenerate (all points colinear/coincident); otherwise untouched
|
|
246
|
+
* @returns newly constructed clipper. If no clip planes could be computed, fill `degeneratePoints` and return undefined.
|
|
247
|
+
*/
|
|
248
|
+
private static createClipperFromTransformedRange3d;
|
|
249
|
+
/**
|
|
250
|
+
* Handle pathological cases of range-range intersection, where one of the ranges defines no area or volume (is a line segment or single point).
|
|
251
|
+
* @param range local range to intersect with the point/segment
|
|
252
|
+
* @param points isolated local point, or local segment's start and end
|
|
253
|
+
* @param localToWorld optional transform for output range
|
|
254
|
+
* @param intersection optional range of the intersection, in world coordinates, or null range if no intersection.
|
|
255
|
+
* @returns whether the point/segment intersects the range
|
|
256
|
+
*/
|
|
257
|
+
private static rangeIntersectPointOrSegment;
|
|
241
258
|
/**
|
|
242
259
|
* Test for intersection of two ranges in different local coordinates.
|
|
243
260
|
* * Useful for clash detection of elements in iModels, using their stored (tight) local ranges and placement transforms.
|
|
244
|
-
* @param range0 range in local coordinates
|
|
245
|
-
* @param local0ToWorld placement transform for first
|
|
246
|
-
* @param range1 range in local coordinates
|
|
247
|
-
* @param local1ToWorld placement transform for second
|
|
261
|
+
* @param range0 first range in local coordinates
|
|
262
|
+
* @param local0ToWorld placement transform for first range
|
|
263
|
+
* @param range1 second range in local coordinates
|
|
264
|
+
* @param local1ToWorld placement transform for second range. Assumed to be invertible.
|
|
248
265
|
* @param range1Margin optional signed local distance to expand/contract the second range before intersection. Positive expands.
|
|
249
266
|
* @return whether the local ranges are adjacent or intersect. Also returns false if local1ToWorld is singular.
|
|
250
267
|
*/
|
|
251
268
|
static doLocalRangesIntersect(range0: Range3d, local0ToWorld: Transform, range1: Range3d, local1ToWorld: Transform, range1Margin?: number): boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Compute the range of the intersection between two local (e.g., element-aligned) ranges.
|
|
271
|
+
* @param range0 first range in local coordinates
|
|
272
|
+
* @param local0ToWorld placement transform for first range
|
|
273
|
+
* @param range1 second range in local coordinates
|
|
274
|
+
* @param local1ToWorld placement transform for second range. Assumed to be invertible.
|
|
275
|
+
* @param result optional pre-allocated range to fill and return
|
|
276
|
+
* @return range of the intersection (aligned to world axes). Returns null range if local1ToWorld is singular.
|
|
277
|
+
*/
|
|
278
|
+
static rangeOfIntersectionOfLocalRanges(range0: Range3d, local0ToWorld: Transform, range1: Range3d, local1ToWorld: Transform, result?: Range3d): Range3d;
|
|
252
279
|
/**
|
|
253
280
|
* Test if `obj` is a `Clipper` object.
|
|
254
281
|
* * This is implemented by testing for each of the methods in the `Clipper` interface.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClipUtils.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"ClipUtils.d.ts","sourceRoot":"","sources":["../../../src/clipping/ClipUtils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGvC,OAAO,EAAE,oBAAoB,EAAE,kCAAkC,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE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EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,GACxF,IAAI;IAQP;;;;OAIG;WACW,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM;IAShF;;;;;;;;;;;;;;;;;OAiBG;WACW,qBAAqB,CACjC,GAAG,EAAE,oBAAoB,EACzB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC3C,eAAe,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC/C,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,cAAc,EACzB,mBAAmB,EAAE,cAAc,EACnC,UAAU,EAAE,qBAAqB,GAAG,SAAS;IAmC/C,qFAAqF;WACvE,2BAA2B,CACvC,GAAG,EAAE,oBAAoB,EACzB,QAAQ,EAAE,OAAO,EAAE,EACnB,UAAU,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC1C,WAAW,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAC3C,UAAU,EAAE,qBAAqB,GAAG,SAAS;IA6C/C;;;OAGG;WACW,wBAAwB,CAAC,OAAO,EAAE,kBAAkB,GAAG,0BAA0B;CA6BhG"}
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module CartesianGeometry
|
|
7
7
|
*/
|
|
8
|
+
import { assert } from "@itwin/core-bentley";
|
|
8
9
|
import { BagOfCurves } from "../curve/CurveCollection";
|
|
9
10
|
import { CurveFactory } from "../curve/CurveFactory";
|
|
10
11
|
import { CurvePrimitive } from "../curve/CurvePrimitive";
|
|
12
|
+
import { LineSegment3d } from "../curve/LineSegment3d";
|
|
11
13
|
import { LineString3d } from "../curve/LineString3d";
|
|
12
14
|
import { Loop } from "../curve/Loop";
|
|
13
15
|
import { Path } from "../curve/Path";
|
|
@@ -20,6 +22,7 @@ import { Point3dArrayCarrier } from "../geometry3d/Point3dArrayCarrier";
|
|
|
20
22
|
import { Point3d, Vector3d } from "../geometry3d/Point3dVector3d";
|
|
21
23
|
import { Range1d, Range3d } from "../geometry3d/Range";
|
|
22
24
|
import { GrowableXYZArrayCache } from "../geometry3d/ReusableObjectCache";
|
|
25
|
+
import { Transform } from "../geometry3d/Transform";
|
|
23
26
|
import { PolyfaceBuilder } from "../polyface/PolyfaceBuilder";
|
|
24
27
|
import { ClipPlane } from "./ClipPlane";
|
|
25
28
|
import { ClipPrimitive } from "./ClipPrimitive";
|
|
@@ -495,32 +498,110 @@ class ClipUtilities {
|
|
|
495
498
|
}
|
|
496
499
|
return false;
|
|
497
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Create a clipper from the transformed range.
|
|
503
|
+
* @param range input range to create clipper from
|
|
504
|
+
* @param transform how to transform the range (NOTE: applied to the range faces without swelling the range volume)
|
|
505
|
+
* @param degeneratePoints optionally populated with the 1 or 2 points defining the transformed range if it is degenerate (all points colinear/coincident); otherwise untouched
|
|
506
|
+
* @returns newly constructed clipper. If no clip planes could be computed, fill `degeneratePoints` and return undefined.
|
|
507
|
+
*/
|
|
508
|
+
static createClipperFromTransformedRange3d(range, transform, degeneratePoints) {
|
|
509
|
+
if (!transform)
|
|
510
|
+
transform = Transform.createIdentity();
|
|
511
|
+
const builder = PolyfaceBuilder.create();
|
|
512
|
+
builder.addTransformedRangeMesh(transform, range);
|
|
513
|
+
const mesh = builder.claimPolyface();
|
|
514
|
+
const clipper = this._workClipper = ConvexClipPlaneSet.createConvexPolyface(mesh, this._workClipper).clipper;
|
|
515
|
+
if (clipper.planes.length > 0)
|
|
516
|
+
return clipper;
|
|
517
|
+
// no faces found in the compressed mesh
|
|
518
|
+
if (degeneratePoints) {
|
|
519
|
+
assert(mesh.data.point.length <= 2);
|
|
520
|
+
for (let i = 0; i < 2; ++i) {
|
|
521
|
+
const point = mesh.data.point.getPoint3dAtCheckedPointIndex(i);
|
|
522
|
+
if (point)
|
|
523
|
+
degeneratePoints.push(point);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return undefined;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Handle pathological cases of range-range intersection, where one of the ranges defines no area or volume (is a line segment or single point).
|
|
530
|
+
* @param range local range to intersect with the point/segment
|
|
531
|
+
* @param points isolated local point, or local segment's start and end
|
|
532
|
+
* @param localToWorld optional transform for output range
|
|
533
|
+
* @param intersection optional range of the intersection, in world coordinates, or null range if no intersection.
|
|
534
|
+
* @returns whether the point/segment intersects the range
|
|
535
|
+
*/
|
|
536
|
+
static rangeIntersectPointOrSegment(range, points, localToWorld, intersection) {
|
|
537
|
+
const announceInterval = intersection ?
|
|
538
|
+
(f0, f1, cp) => {
|
|
539
|
+
intersection.extendPoint(cp.fractionToPoint(f0), localToWorld);
|
|
540
|
+
intersection.extendPoint(cp.fractionToPoint(f1), localToWorld);
|
|
541
|
+
} : undefined;
|
|
542
|
+
let hasIntersection = false;
|
|
543
|
+
if (points.length > 1) {
|
|
544
|
+
const segment = LineSegment3d.createCapture(points[0], points[1]);
|
|
545
|
+
const clipper = ConvexClipPlaneSet.createRange3dPlanes(range);
|
|
546
|
+
hasIntersection = segment.announceClipIntervals(clipper, announceInterval);
|
|
547
|
+
}
|
|
548
|
+
else if (points.length > 0) {
|
|
549
|
+
hasIntersection = range.containsPoint(points[0]);
|
|
550
|
+
if (hasIntersection && intersection)
|
|
551
|
+
intersection.extendPoint(points[0], localToWorld);
|
|
552
|
+
}
|
|
553
|
+
return hasIntersection;
|
|
554
|
+
}
|
|
498
555
|
/**
|
|
499
556
|
* Test for intersection of two ranges in different local coordinates.
|
|
500
557
|
* * Useful for clash detection of elements in iModels, using their stored (tight) local ranges and placement transforms.
|
|
501
|
-
* @param range0 range in local coordinates
|
|
502
|
-
* @param local0ToWorld placement transform for first
|
|
503
|
-
* @param range1 range in local coordinates
|
|
504
|
-
* @param local1ToWorld placement transform for second
|
|
558
|
+
* @param range0 first range in local coordinates
|
|
559
|
+
* @param local0ToWorld placement transform for first range
|
|
560
|
+
* @param range1 second range in local coordinates
|
|
561
|
+
* @param local1ToWorld placement transform for second range. Assumed to be invertible.
|
|
505
562
|
* @param range1Margin optional signed local distance to expand/contract the second range before intersection. Positive expands.
|
|
506
563
|
* @return whether the local ranges are adjacent or intersect. Also returns false if local1ToWorld is singular.
|
|
507
564
|
*/
|
|
508
565
|
static doLocalRangesIntersect(range0, local0ToWorld, range1, local1ToWorld, range1Margin) {
|
|
509
|
-
const worldToLocal1 =
|
|
566
|
+
const worldToLocal1 = this._workTransform = local1ToWorld.inverse(this._workTransform);
|
|
510
567
|
if (!worldToLocal1)
|
|
511
568
|
return false;
|
|
512
569
|
let myRange1 = range1;
|
|
513
570
|
if (range1Margin) {
|
|
514
|
-
myRange1 =
|
|
571
|
+
myRange1 = this._workRange = range1.clone(this._workRange);
|
|
515
572
|
myRange1.expandInPlace(range1Margin);
|
|
516
573
|
}
|
|
574
|
+
const degeneratePoints = [];
|
|
575
|
+
const local0ToLocal1 = worldToLocal1.multiplyTransformTransform(local0ToWorld, worldToLocal1);
|
|
517
576
|
// convert range0 into a clipper in local1 coordinates, then intersect with range1
|
|
577
|
+
const clipper = this.createClipperFromTransformedRange3d(range0, local0ToLocal1, degeneratePoints);
|
|
578
|
+
if (clipper)
|
|
579
|
+
return this.doesClipperIntersectRange(clipper, myRange1);
|
|
580
|
+
return this.rangeIntersectPointOrSegment(myRange1, degeneratePoints, local1ToWorld);
|
|
581
|
+
}
|
|
582
|
+
/**
|
|
583
|
+
* Compute the range of the intersection between two local (e.g., element-aligned) ranges.
|
|
584
|
+
* @param range0 first range in local coordinates
|
|
585
|
+
* @param local0ToWorld placement transform for first range
|
|
586
|
+
* @param range1 second range in local coordinates
|
|
587
|
+
* @param local1ToWorld placement transform for second range. Assumed to be invertible.
|
|
588
|
+
* @param result optional pre-allocated range to fill and return
|
|
589
|
+
* @return range of the intersection (aligned to world axes). Returns null range if local1ToWorld is singular.
|
|
590
|
+
*/
|
|
591
|
+
static rangeOfIntersectionOfLocalRanges(range0, local0ToWorld, range1, local1ToWorld, result) {
|
|
592
|
+
const myResult = Range3d.createNull(result);
|
|
593
|
+
const worldToLocal1 = this._workTransform = local1ToWorld.inverse(this._workTransform);
|
|
594
|
+
if (!worldToLocal1)
|
|
595
|
+
return myResult;
|
|
596
|
+
const degeneratePoints = [];
|
|
518
597
|
const local0ToLocal1 = worldToLocal1.multiplyTransformTransform(local0ToWorld, worldToLocal1);
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
598
|
+
// convert range0 into a clipper in local1 coordinates, then intersect with range1
|
|
599
|
+
const clipper = this.createClipperFromTransformedRange3d(range0, local0ToLocal1, degeneratePoints);
|
|
600
|
+
if (clipper)
|
|
601
|
+
this.announceLoopsOfConvexClipPlaneSetIntersectRange(clipper, range1, (loopPoints) => { loopPoints.extendRange(myResult, local1ToWorld); });
|
|
602
|
+
else
|
|
603
|
+
this.rangeIntersectPointOrSegment(range1, degeneratePoints, local1ToWorld, myResult);
|
|
604
|
+
return myResult;
|
|
524
605
|
}
|
|
525
606
|
/**
|
|
526
607
|
* Test if `obj` is a `Clipper` object.
|