@itwin/core-geometry 4.1.0-dev.4 → 4.1.0-dev.5
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/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/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/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/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/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/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/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/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/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/geometry3d/Matrix3d.d.ts +2 -2
- package/lib/esm/geometry3d/Matrix3d.js +2 -2
- package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
- package/package.json +3 -3
|
@@ -18,11 +18,12 @@ import { OffsetOptions } from "./internalContexts/PolygonOffsetContext";
|
|
|
18
18
|
import { LineSegment3d } from "./LineSegment3d";
|
|
19
19
|
import { StrokeCountMap } from "./Query/StrokeCountMap";
|
|
20
20
|
/* eslint-disable @typescript-eslint/naming-convention, no-empty */
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Starting with baseIndex and moving index by stepDirection:
|
|
23
|
+
* If the vector from baseIndex to baseIndex +1 crossed with vectorA can be normalized, accumulate it (scaled) to normal.
|
|
24
|
+
* Return when successful.
|
|
25
|
+
* (Do nothing if everything is parallel through limits of the array)
|
|
26
|
+
*/
|
|
26
27
|
function accumulateGoodUnitPerpendicular(points, vectorA, baseIndex, stepDirection, weight, normal, workVector) {
|
|
27
28
|
const n = points.length;
|
|
28
29
|
if (stepDirection > 0) {
|
|
@@ -50,43 +51,67 @@ function accumulateGoodUnitPerpendicular(points, vectorA, baseIndex, stepDirecti
|
|
|
50
51
|
return false;
|
|
51
52
|
}
|
|
52
53
|
/**
|
|
53
|
-
* * A LineString3d (sometimes called a PolyLine) is a sequence of xyz coordinates that are to be joined by line
|
|
54
|
-
*
|
|
54
|
+
* * A LineString3d (sometimes called a PolyLine) is a sequence of xyz coordinates that are to be joined by line
|
|
55
|
+
* segments.
|
|
56
|
+
* * The point coordinates are stored in a GrowableXYZArray, not as full point objects.
|
|
55
57
|
* * The parameterization of "fraction along" is
|
|
56
|
-
* * In a linestring with `N` segments (i.e. `N+1` points), each segment (regardless of physical length) occupies
|
|
58
|
+
* * In a linestring with `N` segments (i.e. `N+1` points), each segment (regardless of physical length) occupies
|
|
59
|
+
* the same fraction (1/N) of the 0-to-1 fraction space.
|
|
57
60
|
* * Within segment `i`, the fraction interval `i/N` to `(i+1)/N` is mapped proportionally to the segment
|
|
58
61
|
* * Note that this `fraction` is therefore NOT fraction of true distance along.
|
|
59
|
-
*
|
|
62
|
+
* * Use `moveSignedDistanceFromFraction` to do true-length evaluations.
|
|
60
63
|
* @public
|
|
61
64
|
*/
|
|
62
65
|
class LineString3d extends CurvePrimitive {
|
|
63
66
|
/** test if `other` is an instance of `LineString3d` */
|
|
64
|
-
isSameGeometryClass(other) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
get isExtensibleFractionSpace() {
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
isSameGeometryClass(other) {
|
|
68
|
+
return other instanceof LineString3d;
|
|
69
|
+
}
|
|
70
|
+
/** A LineString3d extends along its first and final segments. */
|
|
71
|
+
get isExtensibleFractionSpace() {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/** Return the points array (cloned). */
|
|
75
|
+
get points() {
|
|
76
|
+
return this._points.getPoint3dArray();
|
|
77
|
+
}
|
|
71
78
|
/** Return (reference to) point data in packed GrowableXYZArray. */
|
|
72
|
-
get packedPoints() {
|
|
73
|
-
|
|
79
|
+
get packedPoints() {
|
|
80
|
+
return this._points;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Return array of fraction parameters.
|
|
74
84
|
* * These Are only present during certain constructions such as faceting.
|
|
75
|
-
* * When present, these fractions are fractions of some other curve being stroked, and are NOT related to the
|
|
85
|
+
* * When present, these fractions are fractions of some other curve being stroked, and are NOT related to the
|
|
86
|
+
* linestring fraction parameters.
|
|
76
87
|
*/
|
|
77
|
-
get fractions() {
|
|
88
|
+
get fractions() {
|
|
89
|
+
return this._fractions;
|
|
90
|
+
}
|
|
78
91
|
/** Return the (optional) array of derivatives. These Are only present during certain constructions such as faceting. */
|
|
79
|
-
get packedDerivatives() {
|
|
92
|
+
get packedDerivatives() {
|
|
93
|
+
return this._derivatives;
|
|
94
|
+
}
|
|
80
95
|
/** Return the (optional) array of uv params. These Are only present during certain constructions such as faceting. */
|
|
81
|
-
get packedUVParams() {
|
|
96
|
+
get packedUVParams() {
|
|
97
|
+
return this._uvParams;
|
|
98
|
+
}
|
|
82
99
|
/** Return the (optional) array of surface normals. These Are only present during certain constructions such as faceting. */
|
|
83
|
-
get packedSurfaceNormals() {
|
|
100
|
+
get packedSurfaceNormals() {
|
|
101
|
+
return this._surfaceNormals;
|
|
102
|
+
}
|
|
84
103
|
/** Return the (optional) array of normal indices. These Are only present during certain constructions such as faceting. */
|
|
85
|
-
get normalIndices() {
|
|
104
|
+
get normalIndices() {
|
|
105
|
+
return this._normalIndices;
|
|
106
|
+
}
|
|
86
107
|
/** Return the (optional) array of param indices. These Are only present during certain constructions such as faceting. */
|
|
87
|
-
get paramIndices() {
|
|
108
|
+
get paramIndices() {
|
|
109
|
+
return this._uvIndices;
|
|
110
|
+
}
|
|
88
111
|
/** Return the (optional) array of point indices. These Are only present during certain constructions such as faceting. */
|
|
89
|
-
get pointIndices() {
|
|
112
|
+
get pointIndices() {
|
|
113
|
+
return this._pointIndices;
|
|
114
|
+
}
|
|
90
115
|
constructor(points) {
|
|
91
116
|
super();
|
|
92
117
|
/** String name for schema properties */
|
|
@@ -102,7 +127,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
102
127
|
c.tryTransformInPlace(transform);
|
|
103
128
|
return c;
|
|
104
129
|
}
|
|
105
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* Create a linestring, using flex length arg list and any typical combination of points such as
|
|
106
132
|
* Point3d, Point2d, `[1,2,3]', array of any of those, or GrowableXYZArray
|
|
107
133
|
*/
|
|
108
134
|
static create(...points) {
|
|
@@ -110,7 +136,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
110
136
|
result.addPoints(points);
|
|
111
137
|
return result;
|
|
112
138
|
}
|
|
113
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Create a linestring, capturing the given GrowableXYZArray as the points.
|
|
114
141
|
* Point3d, Point2d, `[1,2,3]', array of any of those, or GrowableXYZArray
|
|
115
142
|
*/
|
|
116
143
|
static createCapture(points) {
|
|
@@ -135,7 +162,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
135
162
|
}
|
|
136
163
|
return result;
|
|
137
164
|
}
|
|
138
|
-
/**
|
|
165
|
+
/**
|
|
166
|
+
* Add points to the linestring.
|
|
139
167
|
* Valid inputs are:
|
|
140
168
|
* * a Point2d
|
|
141
169
|
* * a point3d
|
|
@@ -287,9 +315,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
287
315
|
this._surfaceNormals = new GrowableXYZArray();
|
|
288
316
|
this._surfaceNormals.push(vector);
|
|
289
317
|
}
|
|
290
|
-
/**
|
|
291
|
-
* If the linestring is not already closed, add a closure point.
|
|
292
|
-
*/
|
|
318
|
+
/** If the linestring is not already closed, add a closure point. */
|
|
293
319
|
addClosurePoint() {
|
|
294
320
|
const distance = this._points.distanceIndexIndex(0, this._points.length - 1);
|
|
295
321
|
if (distance !== undefined && !Geometry.isSameCoordinate(distance, 0))
|
|
@@ -303,7 +329,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
303
329
|
computeUVFromXYZTransform(transform) {
|
|
304
330
|
this._uvParams = GrowableXYArray.createFromGrowableXYZArray(this._points, transform);
|
|
305
331
|
}
|
|
306
|
-
/**
|
|
332
|
+
/**
|
|
333
|
+
* Create the linestring for a rectangle parallel to the xy plane.
|
|
307
334
|
* * The z coordinate from `point0` is used for all points.
|
|
308
335
|
* * `ax` and `ay` are signed.
|
|
309
336
|
* * The point sequence is:
|
|
@@ -334,7 +361,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
334
361
|
* @param center center of the polygon.
|
|
335
362
|
* @param edgeCount number of edges.
|
|
336
363
|
* @param radius distance to vertex or edge (see `radiusToVertices`)
|
|
337
|
-
* @param radiusToVertices true if polygon is inscribed in circle (radius measured to vertices); false if polygon
|
|
364
|
+
* @param radiusToVertices true if polygon is inscribed in circle (radius measured to vertices); false if polygon
|
|
365
|
+
* is outside circle (radius to edges)
|
|
338
366
|
*/
|
|
339
367
|
static createRegularPolygonXY(center, edgeCount, radius, radiusToVertices = true) {
|
|
340
368
|
if (edgeCount < 3)
|
|
@@ -416,7 +444,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
416
444
|
retVal.setFrom(this);
|
|
417
445
|
return retVal;
|
|
418
446
|
}
|
|
419
|
-
/**
|
|
447
|
+
/**
|
|
448
|
+
* Set point coordinates from a json array, e.g. `[[1,2,3],[4,5,6] . . .]`
|
|
420
449
|
* * The `json` parameter must be an array.
|
|
421
450
|
* * Each member `i` of the array is converted to a point with `Point3d.fromJSON(json[i]`)
|
|
422
451
|
*/
|
|
@@ -441,7 +470,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
441
470
|
}
|
|
442
471
|
return value;
|
|
443
472
|
}
|
|
444
|
-
/**
|
|
473
|
+
/**
|
|
474
|
+
* Construct a new linestring.
|
|
445
475
|
* * See `LineString3d.setFromJSON ()` for remarks on `json` structure.
|
|
446
476
|
*/
|
|
447
477
|
static fromJSON(json) {
|
|
@@ -531,7 +561,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
531
561
|
}
|
|
532
562
|
/**
|
|
533
563
|
* Convert a global fraction to a segment index and local fraction.
|
|
534
|
-
* @param globalFraction a fraction f in [0,1] in the linestring parameterization, where the i_th segment
|
|
564
|
+
* @param globalFraction a fraction f in [0,1] in the linestring parameterization, where the i_th segment
|
|
565
|
+
* (0 <= i < N) is parameterized by i/N <= f <= (i+1)/N.
|
|
535
566
|
*/
|
|
536
567
|
globalFractionToSegmentIndexAndLocalFraction(globalFraction) {
|
|
537
568
|
const numSegment = this._points.length - 1;
|
|
@@ -595,7 +626,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
595
626
|
return Transform.createOriginAndMatrix(origin, matrix, result);
|
|
596
627
|
return Transform.createTranslation(origin, result);
|
|
597
628
|
}
|
|
598
|
-
/**
|
|
629
|
+
/** Evaluate the start point of the linestring. */
|
|
599
630
|
startPoint() {
|
|
600
631
|
if (this._points.length === 0)
|
|
601
632
|
return Point3d.createZero();
|
|
@@ -607,8 +638,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
607
638
|
return this._points.getPoint3dAtUncheckedPointIndex(i, result);
|
|
608
639
|
return undefined;
|
|
609
640
|
}
|
|
610
|
-
/** If i and j are both valid indices, return the vector from point i to point j
|
|
611
|
-
*/
|
|
641
|
+
/** If i and j are both valid indices, return the vector from point i to point j */
|
|
612
642
|
vectorBetween(i, j, result) {
|
|
613
643
|
return this._points.vectorIndexIndex(i, j, result);
|
|
614
644
|
}
|
|
@@ -625,8 +655,10 @@ class LineString3d extends CurvePrimitive {
|
|
|
625
655
|
return undefined;
|
|
626
656
|
}
|
|
627
657
|
/** Return the number of points in this linestring. */
|
|
628
|
-
numPoints() {
|
|
629
|
-
|
|
658
|
+
numPoints() {
|
|
659
|
+
return this._points.length;
|
|
660
|
+
}
|
|
661
|
+
/** Evaluate the end point of the linestring. */
|
|
630
662
|
endPoint() {
|
|
631
663
|
if (this._points.length === 0)
|
|
632
664
|
return Point3d.createZero();
|
|
@@ -650,7 +682,9 @@ class LineString3d extends CurvePrimitive {
|
|
|
650
682
|
return true;
|
|
651
683
|
}
|
|
652
684
|
/** Sum the lengths of segments within the linestring */
|
|
653
|
-
curveLength() {
|
|
685
|
+
curveLength() {
|
|
686
|
+
return this._points.sumLengths();
|
|
687
|
+
}
|
|
654
688
|
/** Sum the lengths of segments between fractional positions on a linestring. */
|
|
655
689
|
curveLengthBetweenFractions(fraction0, fraction1) {
|
|
656
690
|
const numSegments = this._points.length - 1;
|
|
@@ -749,10 +783,10 @@ class LineString3d extends CurvePrimitive {
|
|
|
749
783
|
return CurveLocationDetail.createCurveFractionPointDistanceCurveSearchStatus(this, context.fraction0, context.point0, -context.distance0, context.distanceStatus(), result);
|
|
750
784
|
}
|
|
751
785
|
}
|
|
752
|
-
/**
|
|
786
|
+
/** Sum lengths of segments in the linestring. (This is a true length.) */
|
|
753
787
|
quickLength() { return this.curveLength(); }
|
|
754
788
|
/**
|
|
755
|
-
*
|
|
789
|
+
* Compute and normalize cross product among 3 points on the linestring.
|
|
756
790
|
* * "any" 3 points are acceptable -- no test for positive overall sense.
|
|
757
791
|
* * This is appropriate for polygon known to be convex.
|
|
758
792
|
* * use points spread at index step n/3, hopefully avoiding colinear points.
|
|
@@ -791,7 +825,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
791
825
|
if (!extend1 || i < lastIndex)
|
|
792
826
|
segmentFraction = 1.0;
|
|
793
827
|
}
|
|
794
|
-
this._points.getPoint3dAtUncheckedPointIndex(i - 1)
|
|
828
|
+
this._points.getPoint3dAtUncheckedPointIndex(i - 1)
|
|
829
|
+
.interpolate(segmentFraction, this._points.getPoint3dAtUncheckedPointIndex(i), result.pointQ);
|
|
795
830
|
d = result.pointQ.distance(spacePoint);
|
|
796
831
|
if (d < result.a) {
|
|
797
832
|
result.setFP(this.segmentIndexAndLocalFractionToGlobalFraction(i - 1, segmentFraction), result.pointQ, undefined, d);
|
|
@@ -805,8 +840,9 @@ class LineString3d extends CurvePrimitive {
|
|
|
805
840
|
isInPlane(plane) {
|
|
806
841
|
return this._points.isCloseToPlane(plane, Geometry.smallMetricDistance);
|
|
807
842
|
}
|
|
808
|
-
/**
|
|
809
|
-
*
|
|
843
|
+
/**
|
|
844
|
+
* Push a hit, fixing up the prior entry if needed.
|
|
845
|
+
* Return the incremented counter.
|
|
810
846
|
*/
|
|
811
847
|
static pushVertexHit(result, counter, cp, fraction, point) {
|
|
812
848
|
const detail = CurveLocationDetail.createCurveFractionPoint(cp, fraction, point);
|
|
@@ -823,7 +859,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
823
859
|
detail.setIntervalRole(CurveIntervalRole.intervalEnd);
|
|
824
860
|
}
|
|
825
861
|
}
|
|
826
|
-
/**
|
|
862
|
+
/**
|
|
863
|
+
* Find intersections with a plane.
|
|
827
864
|
* Intersections within segments are recorded as CurveIntervalRole.isolated
|
|
828
865
|
* Intersections at isolated "on" vertex are recoded as CurveIntervalRole.isolatedAtVertex.
|
|
829
866
|
*/
|
|
@@ -860,7 +897,9 @@ class LineString3d extends CurvePrimitive {
|
|
|
860
897
|
return result.length - initialLength;
|
|
861
898
|
}
|
|
862
899
|
/** Extend `rangeToExtend` to include all points of this linestring. */
|
|
863
|
-
extendRange(rangeToExtend, transform) {
|
|
900
|
+
extendRange(rangeToExtend, transform) {
|
|
901
|
+
this._points.extendRange(rangeToExtend, transform);
|
|
902
|
+
}
|
|
864
903
|
/** Test if each point of this linestring isAlmostEqual with corresponding point in `other`. */
|
|
865
904
|
isAlmostEqual(other) {
|
|
866
905
|
if (!(other instanceof LineString3d))
|
|
@@ -869,7 +908,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
869
908
|
return false;
|
|
870
909
|
return true;
|
|
871
910
|
}
|
|
872
|
-
/**
|
|
911
|
+
/**
|
|
912
|
+
* Append (clone of) one point.
|
|
873
913
|
* * BUT ... skip if duplicates the tail of prior points.
|
|
874
914
|
* * if fraction is given, "duplicate" considers both point and fraction.
|
|
875
915
|
*/
|
|
@@ -889,8 +929,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
889
929
|
this.addFraction(fraction);
|
|
890
930
|
}
|
|
891
931
|
}
|
|
892
|
-
/** Compress out duplicate points (according to point.isAlmostEqual)
|
|
893
|
-
*/
|
|
932
|
+
/** Compress out duplicate points (according to point.isAlmostEqual) */
|
|
894
933
|
removeDuplicatePoints(tolerance = Geometry.smallMetricDistance) {
|
|
895
934
|
const n = this._points.length;
|
|
896
935
|
if (n < 2)
|
|
@@ -913,7 +952,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
913
952
|
if (this._derivatives)
|
|
914
953
|
this._derivatives.resize(n1);
|
|
915
954
|
}
|
|
916
|
-
/**
|
|
955
|
+
/**
|
|
956
|
+
* Append a suitable evaluation of a curve ..
|
|
917
957
|
* * always append the curve point
|
|
918
958
|
* * if fraction array is present, append the fraction
|
|
919
959
|
* * if derivative array is present, append the derivative
|
|
@@ -936,7 +976,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
936
976
|
}
|
|
937
977
|
}
|
|
938
978
|
/**
|
|
939
|
-
*
|
|
979
|
+
* Clear all array data:
|
|
940
980
|
* * points
|
|
941
981
|
* * optional fractions.
|
|
942
982
|
* * optional derivatives.
|
|
@@ -970,7 +1010,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
970
1010
|
}
|
|
971
1011
|
return ls;
|
|
972
1012
|
}
|
|
973
|
-
/**
|
|
1013
|
+
/**
|
|
1014
|
+
* Evaluate a curve at uniform fractions. Append the evaluations to this linestring.
|
|
974
1015
|
* @param curve primitive to evaluate.
|
|
975
1016
|
* @param numStrokes number of strokes (edges).
|
|
976
1017
|
* @param fraction0 starting fraction coordinate
|
|
@@ -990,7 +1031,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
990
1031
|
this.appendFractionToPoint(curve, fraction0 + i * df);
|
|
991
1032
|
}
|
|
992
1033
|
}
|
|
993
|
-
/**
|
|
1034
|
+
/**
|
|
1035
|
+
* Append points constructed as interpolation between two points.
|
|
994
1036
|
* @param numStrokes number of strokes.
|
|
995
1037
|
* @param point0 first point
|
|
996
1038
|
* @param point1 last point
|
|
@@ -1036,7 +1078,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
1036
1078
|
}
|
|
1037
1079
|
}
|
|
1038
1080
|
}
|
|
1039
|
-
/**
|
|
1081
|
+
/**
|
|
1082
|
+
* Emit strokable parts of the curve to a caller-supplied handler.
|
|
1040
1083
|
* If the stroke options does not have a maxEdgeLength, one stroke is emitted for each segment of the linestring.
|
|
1041
1084
|
* If the stroke options has a maxEdgeLength, smaller segments are emitted as needed.
|
|
1042
1085
|
*/
|
|
@@ -1063,7 +1106,7 @@ class LineString3d extends CurvePrimitive {
|
|
|
1063
1106
|
handler.endCurvePrimitive(this);
|
|
1064
1107
|
}
|
|
1065
1108
|
/**
|
|
1066
|
-
*
|
|
1109
|
+
* Return the stroke count required for given options.
|
|
1067
1110
|
* @param options StrokeOptions that determine count
|
|
1068
1111
|
*/
|
|
1069
1112
|
computeStrokeCountForOptions(options) {
|
|
@@ -1102,7 +1145,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
1102
1145
|
/**
|
|
1103
1146
|
* Find intervals of this CurvePrimitive that are interior to a clipper
|
|
1104
1147
|
* @param clipper clip structure (e.g. clip planes)
|
|
1105
|
-
* @param announce (optional) function to be called announcing fractional intervals"
|
|
1148
|
+
* @param announce (optional) function to be called announcing fractional intervals"
|
|
1149
|
+
* ` announce(fraction0, fraction1, curvePrimitive)`
|
|
1106
1150
|
* @returns true if any "in" segments are announced.
|
|
1107
1151
|
*/
|
|
1108
1152
|
announceClipIntervals(clipper, announce) {
|
|
@@ -1146,7 +1190,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
1146
1190
|
this._points.interpolate(index, fraction, index + 1, LineString3d._indexPoint);
|
|
1147
1191
|
dest.push(LineString3d._indexPoint);
|
|
1148
1192
|
}
|
|
1149
|
-
/**
|
|
1193
|
+
/**
|
|
1194
|
+
* Return a LineString which is a portion of this curve.
|
|
1150
1195
|
* * Fractions outside [0,1] extend the relevant end segment.
|
|
1151
1196
|
* @param fractionA [in] start fraction
|
|
1152
1197
|
* @param fractionB [in] end fraction
|
|
@@ -1206,14 +1251,12 @@ class LineString3d extends CurvePrimitive {
|
|
|
1206
1251
|
return LineSegment3d.create(this._points.getPoint3dAtCheckedPointIndex(index), this._points.getPoint3dAtCheckedPointIndex(index + 1));
|
|
1207
1252
|
return undefined;
|
|
1208
1253
|
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Returns true if first and last points are within metric tolerance.
|
|
1211
|
-
*/
|
|
1254
|
+
/** Returns true if first and last points are within metric tolerance. */
|
|
1212
1255
|
get isPhysicallyClosed() {
|
|
1213
1256
|
return this._points.length > 0 && Geometry.isSmallMetricDistance(this._points.distanceIndexIndex(0, this._points.length - 1));
|
|
1214
1257
|
}
|
|
1215
1258
|
/**
|
|
1216
|
-
*
|
|
1259
|
+
* Evaluate strokes at fractions indicated in a StrokeCountMap.
|
|
1217
1260
|
* * The map must have an array of component counts corresponding to the segment of this linestring.
|
|
1218
1261
|
* * "fractions" in the output are mapped within a0,a1 of the map.componentData
|
|
1219
1262
|
* @param map = stroke count data.
|
|
@@ -1250,7 +1293,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
1250
1293
|
}
|
|
1251
1294
|
return destLinestring.numPoints() - numPoint0;
|
|
1252
1295
|
}
|
|
1253
|
-
/**
|
|
1296
|
+
/**
|
|
1297
|
+
* Convert variant point data to a single level array of linestrings.
|
|
1254
1298
|
* * The result is always an array of LineString3d.
|
|
1255
1299
|
* * Single linestring is NOT bubbled out as a special case.
|
|
1256
1300
|
* * data with no point is an empty array.
|
|
@@ -1285,7 +1329,8 @@ class LineString3d extends CurvePrimitive {
|
|
|
1285
1329
|
}
|
|
1286
1330
|
/**
|
|
1287
1331
|
* Construct an offset of each segment as viewed in the xy-plane (ignoring z).
|
|
1288
|
-
* * No attempt is made to join the offset segments. Use RegionOps.constructCurveXYOffset() to return a fully
|
|
1332
|
+
* * No attempt is made to join the offset segments. Use RegionOps.constructCurveXYOffset() to return a fully
|
|
1333
|
+
* joined offset.
|
|
1289
1334
|
* @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
|
|
1290
1335
|
*/
|
|
1291
1336
|
constructOffsetXY(offsetDistanceOrOptions) {
|
|
@@ -1302,10 +1347,13 @@ class LineString3d extends CurvePrimitive {
|
|
|
1302
1347
|
}
|
|
1303
1348
|
return offsets;
|
|
1304
1349
|
}
|
|
1305
|
-
/**
|
|
1350
|
+
/**
|
|
1351
|
+
* Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters
|
|
1352
|
+
* of projection.
|
|
1306
1353
|
* @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
|
|
1307
1354
|
* @param lowHigh optional receiver for output
|
|
1308
|
-
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is
|
|
1355
|
+
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is
|
|
1356
|
+
* the end of the ray.
|
|
1309
1357
|
*/
|
|
1310
1358
|
projectedParameterRange(ray, lowHigh) {
|
|
1311
1359
|
return PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
|
|
@@ -1317,14 +1365,15 @@ LineString3d._workPointC = Point3d.create();
|
|
|
1317
1365
|
LineString3d._workRay = Ray3d.createXAxis();
|
|
1318
1366
|
LineString3d._indexPoint = Point3d.create(); // private point for addResolvedPoint
|
|
1319
1367
|
export { LineString3d };
|
|
1320
|
-
/**
|
|
1368
|
+
/**
|
|
1369
|
+
* An AnnotatedLineString3d is a linestring with additional surface-related data attached to each point
|
|
1321
1370
|
* * This is useful in facet construction.
|
|
1322
1371
|
* @internal
|
|
1323
1372
|
*/
|
|
1324
1373
|
export class AnnotatedLineString3d {
|
|
1325
1374
|
}
|
|
1326
1375
|
/**
|
|
1327
|
-
*
|
|
1376
|
+
* Context to be called to incrementally accumulate distance along line segments.
|
|
1328
1377
|
*/
|
|
1329
1378
|
class MoveByDistanceContext {
|
|
1330
1379
|
/** CAPTURE point0, fraction0, targetDistance */
|