@itwin/core-geometry 4.1.0-dev.3 → 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
|
@@ -19,20 +19,21 @@ import { AppendPlaneIntersectionStrokeHandler } from "./internalContexts/AppendP
|
|
|
19
19
|
import { ClosestPointStrokeHandler } from "./internalContexts/ClosestPointStrokeHandler";
|
|
20
20
|
import { CurveLengthContext } from "./internalContexts/CurveLengthContext";
|
|
21
21
|
/**
|
|
22
|
-
* A curve primitive is bounded
|
|
22
|
+
* A curve primitive is bounded.
|
|
23
23
|
* A curve primitive maps fractions in 0..1 to points in space.
|
|
24
24
|
* As the fraction proceeds from 0 towards 1, the point moves "forward" along the curve.
|
|
25
25
|
* True distance along the curve is not always strictly proportional to fraction.
|
|
26
|
-
* * LineSegment3d always has proportional fraction and distance
|
|
27
|
-
* *
|
|
28
|
-
* *
|
|
29
|
-
* * A Spiral3d is proportional
|
|
26
|
+
* * A LineSegment3d always has proportional fraction and distance.
|
|
27
|
+
* * An Arc3d which is true circular has proportional fraction and distance.
|
|
28
|
+
* * A LineString3d is not proportional (except for special case of all segments of equal length).
|
|
29
|
+
* * A Spiral3d is proportional.
|
|
30
30
|
* * A BsplineCurve3d is only proportional for special cases.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* For fractions outside 0..1, the curve primitive class may either (a) return the near endpoint or (b) evaluate
|
|
32
|
+
* an extended curve.
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
35
|
export class CurvePrimitive extends GeometryQuery {
|
|
36
|
+
/** Constructor */
|
|
36
37
|
constructor() {
|
|
37
38
|
super();
|
|
38
39
|
/** String name for schema properties */
|
|
@@ -60,30 +61,35 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
60
61
|
const b = data.vectorU.magnitude();
|
|
61
62
|
return Geometry.conditionalDivideFraction(a, b * b * b);
|
|
62
63
|
}
|
|
63
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Construct a frenet frame:
|
|
64
66
|
* * origin at the point on the curve
|
|
65
67
|
* * x axis is unit vector along the curve (tangent)
|
|
66
|
-
* * y axis is perpendicular and in the plane of the osculating circle.
|
|
67
|
-
* * z axis perpendicular to those.
|
|
68
|
+
* * y axis is perpendicular and in the plane of the osculating circle. y axis is called "main normal"
|
|
69
|
+
* * z axis perpendicular to those. z axis is called "bi-normal"
|
|
68
70
|
*/
|
|
69
71
|
fractionToFrenetFrame(fraction, result) {
|
|
70
72
|
const plane = this.fractionToPointAnd2Derivatives(fraction);
|
|
71
73
|
if (!plane)
|
|
72
74
|
return undefined;
|
|
75
|
+
// first derivative (plane.vectorU) and second derivative (plane.vectorV) are not essentially
|
|
76
|
+
// perpendicular so we use createRigidFromColumns to make 3 perpendicular vectors.
|
|
73
77
|
let axes = Matrix3d.createRigidFromColumns(plane.vectorU, plane.vectorV, AxisOrder.XYZ);
|
|
74
78
|
if (axes)
|
|
75
79
|
return Transform.createRefs(plane.origin, axes, result);
|
|
76
|
-
// 2nd derivative not distinct
|
|
80
|
+
// 2nd derivative not distinct. for example if curve is linear at fraction so second derivative is 0.
|
|
81
|
+
// in this case we find perpendicular vector to plane.vectorU and pass it to createRigidFromColumns.
|
|
77
82
|
const perpVector = Matrix3d.createPerpendicularVectorFavorXYPlane(plane.vectorU, plane.vectorV);
|
|
78
83
|
axes = Matrix3d.createRigidFromColumns(plane.vectorU, perpVector, AxisOrder.XYZ);
|
|
79
84
|
if (axes)
|
|
80
85
|
return Transform.createRefs(plane.origin, axes, result);
|
|
81
86
|
return undefined;
|
|
82
87
|
}
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
* *
|
|
86
|
-
* *
|
|
88
|
+
/**
|
|
89
|
+
* Construct signed distance from a point on the planar curve to its center of curvature (in xy only).
|
|
90
|
+
* * Positive distance means the center is to the left of the curve at fraction.
|
|
91
|
+
* * Negative distance means the center is to the right of the curve at fraction.
|
|
92
|
+
* * Zero distance means curve is linear at fraction.
|
|
87
93
|
*/
|
|
88
94
|
fractionToSignedXYRadiusOfCurvature(fraction) {
|
|
89
95
|
const plane = this.fractionToPointAnd2Derivatives(fraction);
|
|
@@ -108,7 +114,7 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
108
114
|
return ray.fractionToPoint(distance);
|
|
109
115
|
}
|
|
110
116
|
/**
|
|
111
|
-
*
|
|
117
|
+
* Return the length of the curve.
|
|
112
118
|
* * Curve length is always positive.
|
|
113
119
|
*/
|
|
114
120
|
curveLength() {
|
|
@@ -117,9 +123,9 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
117
123
|
return context.getSum();
|
|
118
124
|
}
|
|
119
125
|
/**
|
|
120
|
-
* Returns a (high accuracy) length of the curve between fractional positions
|
|
126
|
+
* Returns a (high accuracy) length of the curve between fractional positions.
|
|
121
127
|
* * Curve length is always positive.
|
|
122
|
-
* * Default implementation applies a generic
|
|
128
|
+
* * Default implementation applies a generic Gaussian integration.
|
|
123
129
|
* * Most curve classes (certainly LineSegment, LineString, Arc) are expected to provide efficient implementations.
|
|
124
130
|
*/
|
|
125
131
|
curveLengthBetweenFractions(fraction0, fraction1) {
|
|
@@ -127,7 +133,7 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
127
133
|
return 0.0;
|
|
128
134
|
const scale = this.getFractionToDistanceScale();
|
|
129
135
|
if (scale !== undefined) {
|
|
130
|
-
// We are in luck! simple proportions determine it all
|
|
136
|
+
// We are in luck! simple proportions determine it all !!!
|
|
131
137
|
// (for example, a LineSegment3d or a circular arc)
|
|
132
138
|
const totalLength = this.curveLength();
|
|
133
139
|
return Math.abs((fraction1 - fraction0) * totalLength);
|
|
@@ -138,14 +144,14 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
138
144
|
}
|
|
139
145
|
/**
|
|
140
146
|
* Returns a (high accuracy) range of the curve between fractional positions
|
|
141
|
-
* * Default implementation returns
|
|
147
|
+
* * Default implementation returns the range of the curve from clonePartialCurve
|
|
142
148
|
*/
|
|
143
149
|
rangeBetweenFractions(fraction0, fraction1, transform) {
|
|
144
150
|
return this.rangeBetweenFractionsByClone(fraction0, fraction1, transform);
|
|
145
151
|
}
|
|
146
152
|
/**
|
|
147
153
|
* Returns a (high accuracy) range of the curve between fractional positions
|
|
148
|
-
* * Default implementation returns
|
|
154
|
+
* * Default implementation returns the range of the curve from clonePartialCurve
|
|
149
155
|
*/
|
|
150
156
|
rangeBetweenFractionsByClone(fraction0, fraction1, transform) {
|
|
151
157
|
if (fraction0 === fraction1)
|
|
@@ -159,12 +165,16 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
159
165
|
* Returns an approximate range based on a fixed number of evaluations
|
|
160
166
|
* * Default implementation returns a range determined by evaluating a specified number of points on the curve.
|
|
161
167
|
* * Optional evaluate again at interval midpoints and extrapolate any increase
|
|
162
|
-
* * For a smooth curve, Richardson extrapolation suggests each subdivision moves 3/4 of the way to final. So
|
|
163
|
-
*
|
|
168
|
+
* * For a smooth curve, Richardson extrapolation suggests each subdivision moves 3/4 of the way to final. So
|
|
169
|
+
* extrapolationFactor of 1/3 gets speculatively moves closer to the tight range, and larger multipliers increase
|
|
170
|
+
* confidence in being safely larger.
|
|
171
|
+
* * This function is faster version to compute the range of a portion of a curve (because some curves can be
|
|
172
|
+
* expensive to compute the partial curve and/or to compute the partial curve's range.
|
|
164
173
|
* @param fraction0 start fraction for evaluation
|
|
165
174
|
* @param fraction1 end fraction for evaluation
|
|
166
175
|
* @param count number of points to evaluate
|
|
167
|
-
* @param extrapolationFactor if positive, evaluate again at interval midpoints and apply this fraction multiplier
|
|
176
|
+
* @param extrapolationFactor if positive, evaluate again at interval midpoints and apply this fraction multiplier
|
|
177
|
+
* to any increase in size.
|
|
168
178
|
*/
|
|
169
179
|
rangeBetweenFractionsByCount(fraction0, fraction1, count, transform, extrapolationFactor = 0.0) {
|
|
170
180
|
const range = Range3d.createNull();
|
|
@@ -189,8 +199,8 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
189
199
|
evaluateSteps(fraction0 + globalFractionStep, globalFractionStep, interiorCount);
|
|
190
200
|
}
|
|
191
201
|
if (extrapolationFactor > 0.0) {
|
|
192
|
-
// Evaluate at midpoints. Where this makes the range larger, apply extrapolationFactor to move it to safer
|
|
193
|
-
// same interior step, but shift to interval midpoints
|
|
202
|
+
// Evaluate at midpoints. Where this makes the range larger, apply extrapolationFactor to move it to safer
|
|
203
|
+
// excess value. same interior step, but shift to interval midpoints.
|
|
194
204
|
const baseRange = range.clone();
|
|
195
205
|
const interiorCount1 = interiorCount + 1;
|
|
196
206
|
const localFraction0 = 0.5 / interiorCount1; // we only evaluate at new midpoints.
|
|
@@ -201,13 +211,13 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
201
211
|
return range;
|
|
202
212
|
}
|
|
203
213
|
/**
|
|
204
|
-
*
|
|
205
|
-
* * Run an integration (with a default gaussian quadrature) with a fixed fractional step
|
|
214
|
+
* Run an integration (with a default Gaussian quadrature) with a fixed fractional step
|
|
206
215
|
* * This is typically called by specific curve type implementations of curveLengthBetweenFractions.
|
|
207
|
-
*
|
|
216
|
+
* * For example, in Arc3d implementation of curveLengthBetweenFractions:
|
|
208
217
|
* * If the Arc3d is true circular, it the arc is true circular, use the direct `arcLength = radius * sweepRadians`
|
|
209
|
-
* * If the Arc3d is not true circular, call this method with an interval count appropriate to eccentricity and
|
|
210
|
-
*
|
|
218
|
+
* * If the Arc3d is not true circular, call this method with an interval count appropriate to eccentricity and
|
|
219
|
+
* sweepRadians.
|
|
220
|
+
* @returns Returns the curve length via an integral estimated by numerical quadrature between the fractional positions.
|
|
211
221
|
* @param fraction0 start fraction for integration
|
|
212
222
|
* @param fraction1 end fraction for integration
|
|
213
223
|
* @param numInterval number of quadrature intervals
|
|
@@ -223,33 +233,39 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
223
233
|
return Math.abs(context.getSum());
|
|
224
234
|
}
|
|
225
235
|
/**
|
|
226
|
-
*
|
|
227
|
-
* * (Attempt to) find a position on the curve at a signed distance from start fraction.
|
|
236
|
+
* (Attempt to) find a position on the curve at a signed distance from start fraction.
|
|
228
237
|
* * Return the position as a CurveLocationDetail.
|
|
229
238
|
* * In the `CurveLocationDetail`, record:
|
|
230
239
|
* * `fraction` = fractional position
|
|
231
240
|
* * `point` = coordinates of the point
|
|
232
|
-
* * `a` = (signed!) distance moved. If `allowExtension` is false and the move reached the start or end of the
|
|
241
|
+
* * `a` = (signed!) distance moved. If `allowExtension` is false and the move reached the start or end of the
|
|
242
|
+
* curve, this distance is smaller than the requested signedDistance.
|
|
233
243
|
* * `curveSearchStatus` indicates one of:
|
|
234
244
|
* * `error` (unusual) computation failed not supported for this curve.
|
|
235
245
|
* * `success` full movement completed
|
|
236
246
|
* * `stoppedAtBoundary` partial movement completed. This can be due to either
|
|
237
247
|
* * `allowExtension` parameter sent as `false`
|
|
238
248
|
* * the curve type (e.g. bspline) does not support extended range.
|
|
239
|
-
* * if `allowExtension` is true, movement may still end at the startPoint or end point for curves that do not support
|
|
240
|
-
*
|
|
249
|
+
* * if `allowExtension` is true, movement may still end at the startPoint or end point for curves that do not support
|
|
250
|
+
* extended geometry (specifically bsplines)
|
|
251
|
+
* * if the curve returns a value (i.e. not `undefined`) for `curve.getFractionToDistanceScale()`, the base class
|
|
252
|
+
* carries out the computation
|
|
241
253
|
* and returns a final location.
|
|
242
254
|
* * LineSegment3d relies on this.
|
|
243
|
-
* * If the curve does not implement the computation or the curve has zero length, the returned `CurveLocationDetail`
|
|
255
|
+
* * If the curve does not implement the computation or the curve has zero length, the returned `CurveLocationDetail`
|
|
256
|
+
* has
|
|
244
257
|
* * `fraction` = the value of `startFraction`
|
|
245
258
|
* * `point` = result of `curve.fractionToPoint(startFraction)`
|
|
246
259
|
* * `a` = 0
|
|
247
260
|
* * `curveStartState` = `CurveSearchStatus.error`
|
|
248
261
|
* @param startFraction fractional position where the move starts
|
|
249
262
|
* @param signedDistance distance to move. Negative distance is backwards in the fraction space
|
|
250
|
-
* @param allowExtension if true, all the move to go beyond the startPoint or endpoint of the curve. If false, do not
|
|
263
|
+
* @param allowExtension if true, all the move to go beyond the startPoint or endpoint of the curve. If false, do not
|
|
264
|
+
* allow movement beyond the startPoint or endpoint
|
|
251
265
|
* @param result optional result.
|
|
252
|
-
* @returns A CurveLocationDetail annotated as above.
|
|
266
|
+
* @returns A CurveLocationDetail annotated as above. Note that if the curve does not support the calculation, there is
|
|
267
|
+
* still a result which contains the point at the input startFraction, with failure indicated in the `curveStartState`
|
|
268
|
+
* member
|
|
253
269
|
*/
|
|
254
270
|
moveSignedDistanceFromFraction(startFraction, signedDistance, allowExtension, result) {
|
|
255
271
|
const scale = this.getFractionToDistanceScale();
|
|
@@ -269,13 +285,14 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
269
285
|
* Generic algorithm to search for point at signed distance from a fractional startPoint.
|
|
270
286
|
* * This will work for well for smooth curves.
|
|
271
287
|
* * Curves with tangent or other low-order-derivative discontinuities may need to implement specialized algorithms.
|
|
272
|
-
* * We need to find an endFraction which is the end-of-interval (usually upper) limit of integration of the tangent
|
|
288
|
+
* * We need to find an endFraction which is the end-of-interval (usually upper) limit of integration of the tangent
|
|
289
|
+
* magnitude from startFraction to endFraction
|
|
273
290
|
* * That integral is a function of endFraction.
|
|
274
291
|
* * The derivative of that integral with respect to end fraction is the tangent magnitude at end fraction.
|
|
275
292
|
* * Use that function and (easily evaluated!) derivative for a Newton iteration
|
|
276
|
-
* * TO ALL WHO HAVE FUZZY MEMORIES OF CALCULUS CLASS: "The derivative of the integral wrt upper limit is the value
|
|
277
|
-
*
|
|
278
|
-
*
|
|
293
|
+
* * TO ALL WHO HAVE FUZZY MEMORIES OF CALCULUS CLASS: "The derivative of the integral wrt upper limit is the value
|
|
294
|
+
* of the integrand there" is the fundamental theorem of integral calculus !!! The fundamental theorem is not just
|
|
295
|
+
* an abstraction !!! It is being used here in its barest possible form !!!
|
|
279
296
|
* * See https://en.wikipedia.org/wiki/Fundamental_theorem_of_calculus
|
|
280
297
|
* @param startFraction
|
|
281
298
|
* @param signedDistance
|
|
@@ -356,20 +373,25 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
356
373
|
return result;
|
|
357
374
|
}
|
|
358
375
|
/**
|
|
359
|
-
* * Returns true if the curve
|
|
376
|
+
* * Returns true if the curve can be easily extended past its start/end point (i.e., beyond the usual
|
|
377
|
+
* fraction space [0,1]). Otherwise, returns false.
|
|
360
378
|
* * Base class default implementation returns false.
|
|
361
|
-
* * These
|
|
379
|
+
* * These classes (and perhaps others in the future) will return true:
|
|
362
380
|
* * LineSegment3d
|
|
363
381
|
* * LineString3d
|
|
364
382
|
* * Arc3d
|
|
365
383
|
*/
|
|
366
|
-
get isExtensibleFractionSpace() {
|
|
367
|
-
|
|
368
|
-
|
|
384
|
+
get isExtensibleFractionSpace() {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Search for a point on the curve that is closest to the spacePoint.
|
|
369
389
|
* * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
|
|
370
|
-
* * Since CurvePrimitive should always have start and end available as candidate points, this method should always
|
|
390
|
+
* * Since CurvePrimitive should always have start and end available as candidate points, this method should always
|
|
391
|
+
* succeed
|
|
371
392
|
* @param spacePoint point in space
|
|
372
|
-
* @param extend true to extend the curve (if possible), false for no extend, single CurveExtendOptions (for both
|
|
393
|
+
* @param extend true to extend the curve (if possible), false for no extend, single CurveExtendOptions (for both
|
|
394
|
+
* directions), or array of distinct CurveExtendOptions for start and end.
|
|
373
395
|
* @returns Returns a CurveLocationDetail structure that holds the details of the close point.
|
|
374
396
|
*/
|
|
375
397
|
closestPoint(spacePoint, extend) {
|
|
@@ -380,14 +402,16 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
380
402
|
/**
|
|
381
403
|
* Find intervals of this curvePrimitive that are interior to a clipper
|
|
382
404
|
* @param clipper clip structure (e.g. clip planes)
|
|
383
|
-
* @param announce (optional) function to be called announcing fractional intervals
|
|
405
|
+
* @param announce (optional) function to be called announcing fractional intervals
|
|
406
|
+
* `announce(fraction0, fraction1, curvePrimitive)`
|
|
384
407
|
* @returns true if any "in" segments are announced.
|
|
385
408
|
*/
|
|
386
409
|
announceClipIntervals(_clipper, _announce) {
|
|
387
410
|
// DEFAULT IMPLEMENTATION -- no interior parts
|
|
388
411
|
return false;
|
|
389
412
|
}
|
|
390
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Return (if possible) a curve primitive which is a portion of this curve.
|
|
391
415
|
* @param _fractionA [in] start fraction
|
|
392
416
|
* @param _fractionB [in] end fraction
|
|
393
417
|
*/
|
|
@@ -395,8 +419,8 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
395
419
|
return undefined;
|
|
396
420
|
}
|
|
397
421
|
/**
|
|
398
|
-
*
|
|
399
|
-
*
|
|
422
|
+
* If the curve primitive has distance-along-curve strictly proportional to curve fraction, return the scale factor.
|
|
423
|
+
* If distance-along-the-curve is not proportional, return undefined.
|
|
400
424
|
* * When defined, the scale factor is always the length of the curve.
|
|
401
425
|
* * This scale factor is typically available for these curve types:
|
|
402
426
|
* * * All `LineSegment3d`
|
|
@@ -407,12 +431,14 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
407
431
|
* * * bspline and bezier curves
|
|
408
432
|
* @returns scale factor or undefined
|
|
409
433
|
*/
|
|
410
|
-
getFractionToDistanceScale() {
|
|
434
|
+
getFractionToDistanceScale() {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
411
437
|
/**
|
|
412
|
-
* Compute intersections with a plane.
|
|
438
|
+
* Compute intersections of the curve with a plane.
|
|
413
439
|
* * The intersections are appended to the result array.
|
|
414
|
-
* * The base class implementation emits strokes to an AppendPlaneIntersectionStrokeHandler object, which uses a
|
|
415
|
-
*
|
|
440
|
+
* * The base class implementation emits strokes to an AppendPlaneIntersectionStrokeHandler object, which uses a
|
|
441
|
+
* Newton iteration to get high-accuracy intersection points within strokes.
|
|
416
442
|
* * Derived classes should override this default implementation if there are easy analytic solutions.
|
|
417
443
|
* * Derived classes are free to implement extended intersections (e.g. arc!!!)
|
|
418
444
|
* @param plane The plane to be intersected.
|
|
@@ -429,8 +455,8 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
429
455
|
* Examine contents of an array of CurveLocationDetail.
|
|
430
456
|
* Filter the intersections according to the parameters.
|
|
431
457
|
* @param allowExtend if false, remove points on the extension.
|
|
432
|
-
* @param applySnappedCoordinates if true, change the stored fractions and coordinates to exact end values.
|
|
433
|
-
*
|
|
458
|
+
* @param applySnappedCoordinates if true, change the stored fractions and coordinates to exact end values.
|
|
459
|
+
* Otherwise use the exact values only for purpose of updating the curveIntervalRole.
|
|
434
460
|
* @param startEndFractionTolerance if nonzero, adjust fraction to 0 or 1 with this tolerance.
|
|
435
461
|
* @param startEndXYZTolerance if nonzero, adjust to endpoint with this tolerance.
|
|
436
462
|
* @internal
|
|
@@ -493,12 +519,16 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
493
519
|
if (acceptIndex < n0)
|
|
494
520
|
details.length = acceptIndex;
|
|
495
521
|
}
|
|
496
|
-
/**
|
|
497
|
-
startPoint(result) {
|
|
498
|
-
|
|
499
|
-
|
|
522
|
+
/** Return the startPoint of the primitive. The default implementation returns fractionToPoint(0.0) */
|
|
523
|
+
startPoint(result) {
|
|
524
|
+
return this.fractionToPoint(0.0, result);
|
|
525
|
+
}
|
|
526
|
+
/** Return the end point of the primitive. The default implementation returns fractionToPoint(1.0) */
|
|
527
|
+
endPoint(result) {
|
|
528
|
+
return this.fractionToPoint(1.0, result);
|
|
529
|
+
}
|
|
500
530
|
/**
|
|
501
|
-
*
|
|
531
|
+
* Attach StrokeCountMap structure to this primitive (and recursively to any children)
|
|
502
532
|
* * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and attaches it.
|
|
503
533
|
* * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.
|
|
504
534
|
* * Subdivided primitives (linestring, bspline curve) implement themselves and attach a StrokeCountMap containing the
|
|
@@ -506,7 +536,8 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
506
536
|
* * For CurvePrimitiveWithDistanceIndex, the top level gets (only) a total count, and each child gets
|
|
507
537
|
* its own StrokeCountMap with appropriate structure.
|
|
508
538
|
* @param options StrokeOptions that determine count
|
|
509
|
-
* @param parentStrokeMap optional map from parent. Its count, curveLength, and a1 values are increased with count
|
|
539
|
+
* @param parentStrokeMap optional map from parent. Its count, curveLength, and a1 values are increased with count
|
|
540
|
+
* and distance from this primitive.
|
|
510
541
|
* @return sum of `a0+this.curveLength()`, for use as `a0` of successor in chain.
|
|
511
542
|
*/
|
|
512
543
|
computeAndAttachRecursiveStrokeCounts(options, parentMap) {
|
|
@@ -515,8 +546,9 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
515
546
|
CurvePrimitive.installStrokeCountMap(this, StrokeCountMap.createWithCurvePrimitive(this, n, a, 0, a), parentMap);
|
|
516
547
|
}
|
|
517
548
|
/**
|
|
518
|
-
*
|
|
519
|
-
* * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and strokes at
|
|
549
|
+
* Evaluate strokes at fractions indicated in a StrokeCountMap.
|
|
550
|
+
* * Base class implementation (here) gets the simple count from computeStrokeCountForOptions and strokes at
|
|
551
|
+
* uniform fractions.
|
|
520
552
|
* * LineString3d, arc3d, BezierCurve3d, BezierCurve3dH accept that default.
|
|
521
553
|
* * Subdivided primitives (linestring, bspline curve) implement themselves and evaluate within components.
|
|
522
554
|
* * CurvePrimitiveWithDistanceIndex recurses to its children.
|
|
@@ -536,7 +568,7 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
536
568
|
return linestring.numPoints() - numPoint0;
|
|
537
569
|
}
|
|
538
570
|
/**
|
|
539
|
-
*
|
|
571
|
+
* Final install step to save curveMap in curve. If parentMap is given, update its length, count, and a1 fields
|
|
540
572
|
* @param curve curve to receive the annotation
|
|
541
573
|
* @param map
|
|
542
574
|
* @param parentMap
|
|
@@ -550,8 +582,10 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
550
582
|
* Return an array containing only the curve primitives.
|
|
551
583
|
* * This DEFAULT implementation simply pushes `this` to the collectorArray.
|
|
552
584
|
* @param collectorArray array to receive primitives (pushed -- the array is not cleared)
|
|
553
|
-
* @param smallestPossiblePrimitives if true, a [[CurvePrimitiveWithDistanceIndex]] recurses on its (otherwise hidden)
|
|
554
|
-
*
|
|
585
|
+
* @param smallestPossiblePrimitives if true, a [[CurvePrimitiveWithDistanceIndex]] recurses on its (otherwise hidden)
|
|
586
|
+
* children. If false, it returns only itself.
|
|
587
|
+
* @param explodeLinestrings if true, push a [[LineSegment3d]] for each segment of a [[LineString3d]]. If false,
|
|
588
|
+
* push only the [[LineString3d]].
|
|
555
589
|
*/
|
|
556
590
|
collectCurvePrimitivesGo(collectorArray, _smallestPossiblePrimitives, _explodeLinestrings = false) {
|
|
557
591
|
collectorArray.push(this);
|
|
@@ -559,18 +593,23 @@ export class CurvePrimitive extends GeometryQuery {
|
|
|
559
593
|
/**
|
|
560
594
|
* Return an array containing only the curve primitives.
|
|
561
595
|
* * This DEFAULT implementation captures the optional collector and calls [[collectCurvePrimitivesGo]].
|
|
562
|
-
* @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without
|
|
563
|
-
*
|
|
596
|
+
* @param collectorArray optional array to receive primitives. If present, new primitives are ADDED (without
|
|
597
|
+
* clearing the array.)
|
|
598
|
+
* @param smallestPossiblePrimitives if false, CurvePrimitiveWithDistanceIndex returns only itself. If true,
|
|
599
|
+
* it recurses to its (otherwise hidden) children.
|
|
564
600
|
*/
|
|
565
601
|
collectCurvePrimitives(collectorArray, smallestPossiblePrimitives = false, explodeLinestrings = false) {
|
|
566
602
|
const results = collectorArray === undefined ? [] : collectorArray;
|
|
567
603
|
this.collectCurvePrimitivesGo(results, smallestPossiblePrimitives, explodeLinestrings);
|
|
568
604
|
return results;
|
|
569
605
|
}
|
|
570
|
-
/**
|
|
606
|
+
/**
|
|
607
|
+
* Project instance geometry (via dispatch) onto the line of the given ray, and return the extreme fractional
|
|
608
|
+
* parameters of projection.
|
|
571
609
|
* @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
|
|
572
610
|
* @param lowHigh optional receiver for output
|
|
573
|
-
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
611
|
+
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
612
|
+
* end of the ray.
|
|
574
613
|
*/
|
|
575
614
|
projectedParameterRange(_ray, _lowHigh) {
|
|
576
615
|
return undefined; // common implementation delegated to subclasses to avoid circular dependency
|