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