@itwin/ecschema-rpcinterface-tests 5.0.0-dev.62 → 5.0.0-dev.64

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.
@@ -71063,21 +71063,12 @@ class Schema {
71063
71063
  ? refSchema.getItemSync(itemName, itemConstructor)
71064
71064
  : refSchema.getItemSync(itemName);
71065
71065
  }
71066
- /**
71067
- * Returns an iterator over all of the items in this schema.
71068
- */
71069
- getItems() {
71066
+ *getItems(itemConstructor) {
71070
71067
  if (!this._items)
71071
- return new Map().values();
71072
- return this._items.values();
71073
- }
71074
- /**
71075
- * Returns an iterator over all ECClasses within this schema
71076
- */
71077
- *getClasses() {
71078
- for (const [, value] of this._items) {
71079
- if (_Class__WEBPACK_IMPORTED_MODULE_8__.ECClass.isECClass(value))
71080
- yield value;
71068
+ return;
71069
+ for (const item of this._items.values()) {
71070
+ if (itemConstructor === undefined || (0,_ECObjects__WEBPACK_IMPORTED_MODULE_4__.isSupportedSchemaItemType)(item.schemaItemType, itemConstructor.schemaItemType))
71071
+ yield item;
71081
71072
  }
71082
71073
  }
71083
71074
  /**
@@ -183093,82 +183084,115 @@ __webpack_require__.r(__webpack_exports__);
183093
183084
  /** @packageDocumentation
183094
183085
  * @module Bspline
183095
183086
  */
183096
- // import { Point2d } from "../Geometry2d";
183097
183087
 
183098
183088
 
183099
183089
 
183100
- /** Bspline knots and poles for 1d-to-Nd.
183090
+ /**
183091
+ * Knots and poles for a B-spline function mapping R to R^n.
183101
183092
  * * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
183102
183093
  * * Derived classes (not this class) assign meaning such as x,y,z,w.
183103
- * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w
183094
+ * * For instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or
183095
+ * weighted 2D x,y,w.
183104
183096
  * @public
183105
183097
  */
183106
183098
  class BSpline1dNd {
183107
- /** knots of the bspline */
183099
+ /** Knots of the bspline. */
183108
183100
  knots;
183109
- /** poles, packed in blocks of `poleLength` doubles. */
183101
+ /** Poles packed in blocks of `poleLength` doubles. */
183110
183102
  packedData;
183111
- /** (property accessor) Return the number of numeric values per pole. */
183103
+ /** The number of numeric values per pole. */
183112
183104
  poleLength;
183113
183105
  /** (property accessor) Return the degree of the polynomials. */
183114
- get degree() { return this.knots.degree; }
183115
- /** (property accessor) Return the number of order (one more than degree) of the polynomials */
183116
- get order() { return this.knots.degree + 1; }
183117
- /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/
183118
- get numSpan() { return this.numPoles - this.knots.degree; }
183119
- /** (property accessor) Return the number of poles*/
183120
- get numPoles() { return this.packedData.length / this.poleLength; }
183121
- /** copy 3 values of pole `i` into a point.
183106
+ get degree() {
183107
+ return this.knots.degree;
183108
+ }
183109
+ /** (property accessor) Return the order (one more than degree) of the polynomials. */
183110
+ get order() {
183111
+ return this.knots.degree + 1;
183112
+ }
183113
+ /** (property accessor) Return the number of bezier spans (including null spans at multiple knots). */
183114
+ get numSpan() {
183115
+ return this.numPoles - this.knots.degree;
183116
+ }
183117
+ /** (property accessor) Return the number of poles. */
183118
+ get numPoles() {
183119
+ return this.packedData.length / this.poleLength;
183120
+ }
183121
+ /**
183122
+ * Copy 3 values of pole `i` into a point.
183122
183123
  * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
183123
183124
  */
183124
- getPoint3dPole(i, result) { return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Point3d.createFromPacked(this.packedData, i, result); }
183125
- /** preallocated array (length === `order`) used as temporary in evaluations */
183126
- basisBuffer; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183127
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
183128
- poleBuffer; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183129
- /** preallocated array (length === `order`) used as temporary in evaluations */
183130
- basisBuffer1; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183131
- /** preallocated array (length === `order`) used as temporary in evaluations */
183132
- basisBuffer2; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183133
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
183134
- poleBuffer1; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183135
- /** preallocated array (length === `poleLength`) used as temporary in evaluations */
183136
- poleBuffer2; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
183125
+ getPoint3dPole(i, result) {
183126
+ return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Point3d.createFromPacked(this.packedData, i, result);
183127
+ }
183137
183128
  /**
183138
- * initialize arrays for given spline dimensions.
183139
- * @param numPoles number of poles
183140
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
183141
- * @param order number of poles in support for a section of the bspline
183142
- * @param knots KnotVector. This is captured, not cloned.
183129
+ * Values of the `order` relevant B-spline basis functions at a parameter.
183130
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
183131
+ */
183132
+ basisBuffer;
183133
+ /**
183134
+ * Derivatives of the `order` relevant B-spline basis functions at a parameter.
183135
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
183136
+ */
183137
+ basisBuffer1;
183138
+ /**
183139
+ * Second derivatives of the `order` relevant B-spline basis functions at a parameter.
183140
+ * * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
183141
+ */
183142
+ basisBuffer2;
183143
+ /**
183144
+ * Temporary to hold a single point.
183145
+ * * Preallocated to length `poleLength` in the constructor.
183146
+ */
183147
+ poleBuffer;
183148
+ /**
183149
+ * Temporary to hold a single derivative vector.
183150
+ * * Preallocated to length `poleLength` in the constructor.
183151
+ */
183152
+ poleBuffer1;
183153
+ /**
183154
+ * Temporary to hold a single second derivative vector.
183155
+ * * Preallocated to length `poleLength` in the constructor.
183156
+ */
183157
+ poleBuffer2;
183158
+ /**
183159
+ * Initialize arrays for given spline dimensions.
183160
+ * @param numPoles number of poles.
183161
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
183162
+ * 3 for 2d weighted).
183163
+ * @param order number of poles defining a Bezier segment of the B-spline function.
183164
+ * @param knots the KnotVector. This is captured, not cloned.
183143
183165
  */
183144
183166
  constructor(numPoles, poleLength, order, knots) {
183145
183167
  this.knots = knots;
183146
183168
  this.packedData = new Float64Array(numPoles * poleLength);
183147
183169
  this.poleLength = poleLength;
183148
183170
  this.basisBuffer = new Float64Array(order);
183149
- this.poleBuffer = new Float64Array(poleLength);
183150
183171
  this.basisBuffer1 = new Float64Array(order);
183151
183172
  this.basisBuffer2 = new Float64Array(order);
183173
+ this.poleBuffer = new Float64Array(poleLength);
183152
183174
  this.poleBuffer1 = new Float64Array(poleLength);
183153
183175
  this.poleBuffer2 = new Float64Array(poleLength);
183154
183176
  }
183155
183177
  /**
183156
- * create a 1Bspline1dNd`
183157
- * @param numPoles number of poles
183158
- * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)
183159
- * @param order number of poles in support for a section of the bspline
183160
- * @param knots KnotVector. This is captured, not cloned.
183178
+ * Create a `BSpline1dNd`.
183179
+ * @param numPoles number of poles.
183180
+ * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
183181
+ * 3 for 2d weighted).
183182
+ * @param order number of poles defining a Bezier segment of the B-spline function.
183183
+ * @param knots the KnotVector. This is captured, not cloned.
183161
183184
  */
183162
183185
  static create(numPoles, poleLength, order, knots) {
183163
183186
  return new BSpline1dNd(numPoles, poleLength, order, knots);
183164
183187
  }
183165
- /** Map a span index and local fraction to knot value. */
183166
- spanFractionToKnot(span, localFraction) {
183167
- return this.knots.spanFractionToKnot(span, localFraction);
183188
+ /** Map a span index and span fraction to knot value. */
183189
+ spanFractionToKnot(spanIndex, spanFraction) {
183190
+ return this.knots.spanFractionToKnot(spanIndex, spanFraction);
183168
183191
  }
183169
183192
  /**
183170
- * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.
183171
- * @returns true if and only if output arrays are sufficiently sized
183193
+ * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within
183194
+ * indexed span.
183195
+ * @returns true if and only if output arrays are sufficiently sized.
183172
183196
  */
183173
183197
  evaluateBasisFunctionsInSpan(spanIndex, spanFraction, f, df, ddf) {
183174
183198
  if (spanIndex < 0)
@@ -183182,57 +183206,64 @@ class BSpline1dNd {
183182
183206
  this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);
183183
183207
  }
183184
183208
  /**
183185
- * * Evaluate the basis functions at spanIndex and fraction.
183186
- * * Evaluations are stored in the preallocated `this.basisBuffer`
183187
- * * Immediately do the summations of the basis values times the respective control points
183188
- * * Summations are stored in the preallocated `this.poleBuffer`
183189
- * */
183190
- evaluateBuffersInSpan(spanIndex, spanFraction) {
183191
- this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
183192
- this.sumPoleBufferForSpan(spanIndex);
183193
- }
183194
- /**
183195
- * * Evaluate the basis functions and one derivative at spanIndex and fraction.
183196
- * * Evaluations are stored in the preallocated `this.basisBuffer`
183197
- * * Immediately do the summations of the basis values times the respective control points
183198
- * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
183199
- * */
183200
- evaluateBuffersInSpan1(spanIndex, spanFraction) {
183201
- this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
183202
- this.sumPoleBufferForSpan(spanIndex);
183203
- this.sumPoleBuffer1ForSpan(spanIndex);
183204
- }
183205
- /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
183209
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer`, and store this point
183210
+ * in `poleBuffer`.
183211
+ */
183206
183212
  sumPoleBufferForSpan(spanIndex) {
183207
183213
  this.poleBuffer.fill(0);
183208
183214
  let k = spanIndex * this.poleLength;
183209
- for (const f of this.basisBuffer) {
183210
- for (let j = 0; j < this.poleLength; j++) {
183215
+ for (const f of this.basisBuffer)
183216
+ for (let j = 0; j < this.poleLength; j++)
183211
183217
  this.poleBuffer[j] += f * this.packedData[k++];
183212
- }
183213
- }
183214
183218
  }
183215
- /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */
183219
+ /**
183220
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer1`, and store this
183221
+ * derivative vector in `poleBuffer1`.
183222
+ */
183216
183223
  sumPoleBuffer1ForSpan(spanIndex) {
183217
183224
  this.poleBuffer1.fill(0);
183218
183225
  let k = spanIndex * this.poleLength;
183219
- for (const f of this.basisBuffer1) {
183220
- for (let j = 0; j < this.poleLength; j++) {
183226
+ for (const f of this.basisBuffer1)
183227
+ for (let j = 0; j < this.poleLength; j++)
183221
183228
  this.poleBuffer1[j] += f * this.packedData[k++];
183222
- }
183223
- }
183224
183229
  }
183225
- /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */
183230
+ /**
183231
+ * Compute the linear combination of the given span's poles and the weights in `basisBuffer2`, and store this
183232
+ * second derivative vector in `poleBuffer2`.
183233
+ */
183226
183234
  sumPoleBuffer2ForSpan(spanIndex) {
183227
183235
  this.poleBuffer2.fill(0);
183228
183236
  let k = spanIndex * this.poleLength;
183229
183237
  for (const f of this.basisBuffer2) {
183230
- for (let j = 0; j < this.poleLength; j++) {
183238
+ for (let j = 0; j < this.poleLength; j++)
183231
183239
  this.poleBuffer2[j] += f * this.packedData[k++];
183232
- }
183233
183240
  }
183234
183241
  }
183235
- /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */
183242
+ /**
183243
+ * * Evaluate the basis functions at spanIndex and fraction.
183244
+ * * Evaluations are stored in the preallocated `this.basisBuffer`.
183245
+ * * Immediately do the summations of the basis values times the respective poles.
183246
+ * * Summations are stored in the preallocated `this.poleBuffer`
183247
+ * */
183248
+ evaluateBuffersInSpan(spanIndex, spanFraction) {
183249
+ this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
183250
+ this.sumPoleBufferForSpan(spanIndex);
183251
+ }
183252
+ /**
183253
+ * * Evaluate the basis functions and one derivative at spanIndex and fraction.
183254
+ * * Function evaluations are stored in the preallocated `this.basisBuffer`; derivative evaluations in `this.basisBuffer1`.
183255
+ * * Immediately do the summations of the basis values times the respective poles.
183256
+ * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
183257
+ * */
183258
+ evaluateBuffersInSpan1(spanIndex, spanFraction) {
183259
+ this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
183260
+ this.sumPoleBufferForSpan(spanIndex);
183261
+ this.sumPoleBuffer1ForSpan(spanIndex);
183262
+ }
183263
+ /**
183264
+ * Evaluate the B-spline function and optional derivatives at the given parameter in knot space.
183265
+ * * Function value is stored in `poleBuffer`; optional derivative vectors in `poleBuffer1` and `poleBuffer2`.
183266
+ */
183236
183267
  evaluateBuffersAtKnot(u, numDerivative = 0) {
183237
183268
  const knotIndex0 = this.knots.knotToLeftKnotIndex(u);
183238
183269
  if (numDerivative < 1) {
@@ -183251,36 +183282,30 @@ class BSpline1dNd {
183251
183282
  this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);
183252
183283
  }
183253
183284
  }
183254
- /**
183255
- * Reverse the (blocked) poles (in `this.packedData` in place.
183256
- */
183285
+ /** Reverse the instance poles and knots in place. */
183257
183286
  reverseInPlace() {
183258
- // reverse poles in blocks ...
183259
- const b = this.poleLength;
183287
+ const pLen = this.poleLength;
183260
183288
  const data = this.packedData;
183261
- for (let i0 = 0, j0 = b * (this.numPoles - 1); i0 < j0; i0 += b, j0 -= b) {
183262
- let t = 0;
183263
- for (let i = 0; i < b; i++) {
183264
- t = data[i0 + i];
183265
- data[i0 + i] = data[j0 + i];
183266
- data[j0 + i] = t;
183267
- }
183289
+ for (let i0 = 0, j0 = pLen * (this.numPoles - 1); i0 < j0; i0 += pLen, j0 -= pLen) {
183290
+ for (let i = 0; i < pLen; i++)
183291
+ [data[i0 + i], data[j0 + i]] = [data[j0 + i], data[i0 + i]];
183268
183292
  }
183269
183293
  this.knots.reflectKnots();
183270
183294
  }
183271
183295
  /**
183272
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
183273
- * to act as a normal bspline.
183274
- * @returns true if `degree` leading and trailing polygon blocks match
183275
- * @deprecated in 4.x. Use testClosablePolygon instead.
183296
+ * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
183297
+ * which has been expanded to act as a normal bspline.
183298
+ * @returns true if `degree` leading and trailing polygon blocks match.
183299
+ * @deprecated in 4.x. Use `testClosablePolygon` instead.
183276
183300
  */
183277
183301
  testCloseablePolygon(mode) {
183278
183302
  return this.testClosablePolygon(mode);
183279
183303
  }
183280
183304
  /**
183281
- * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
183282
- * to act as a normal bspline.
183283
- * @returns true if `degree` leading and trailing polygon blocks match
183305
+ * Test if the leading and trailing poles are replicated in the manner of a "closed" B-spline function with wraparound
183306
+ * control polygon.
183307
+ * @param mode wrap mode, indicating the number of wraparound poles to check. If undefined, `knots.wrappable` is used.
183308
+ * @returns true if the expected leading and trailing poles match, according to `mode`.
183284
183309
  */
183285
183310
  testClosablePolygon(mode) {
183286
183311
  if (mode === undefined)
@@ -183302,9 +183327,10 @@ class BSpline1dNd {
183302
183327
  }
183303
183328
  return true;
183304
183329
  }
183305
- /** Insert knot and resulting pole into the instance, optionally multiple times.
183306
- * @param knot the knot to be inserted (may already exist in the KnotVector)
183307
- * @param totalMultiplicity the total multiplicity of the knot on return
183330
+ /**
183331
+ * Insert the knot and resulting pole into the instance, optionally multiple times.
183332
+ * @param knot the knot to be inserted (may already exist in the KnotVector).
183333
+ * @param totalMultiplicity the total multiplicity of the knot on return.
183308
183334
  */
183309
183335
  addKnot(knot, totalMultiplicity) {
183310
183336
  if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)
@@ -183428,83 +183454,117 @@ __webpack_require__.r(__webpack_exports__);
183428
183454
 
183429
183455
  /**
183430
183456
  * Base class for BSplineCurve3d and BSplineCurve3dH.
183431
- * * A bspline curve consists of a set of knots and a set of poles.
183432
- * * The bspline curve is a function of the independent "knot axis" variable
183433
- * * The curve "follows" the poles loosely.
183434
- * * The is a set of polynomial spans.
183457
+ * * A B-spline curve consists of an array of `knots`, an array of `poles`, and a `degree`.
183458
+ * * The knot array is a non-decreasing sequence of numbers. It is also called a "knot vector".
183459
+ * * The curve is a parametric function whose domain is a sub-range of its knots.
183460
+ * * The API sometimes refers to a domain parameter `u` as a "knot", even if `u` is not actually an entry in the
183461
+ * knot array.
183462
+ * * The curve loosely "follows" the line string formed by the poles, aka the "control polygon".
183463
+ * * The curve is a chain of polynomial segments, aka "spans" or "fragments". B-spline theory identifies these as
183464
+ * Bezier curves.
183435
183465
  * * The polynomial spans all have same `degree`.
183436
- * * Within each span, the polynomial of that `degree` is controlled by `order = degree + 1` contiguous points called poles.
183437
- * * The is a strict relationship between knot and poles counts: `numPoles + order = numKnots + 2'
183438
- * * The number of spans is `numSpan = numPoles - degree`
183439
- * * For a given `spanIndex`:
183440
- * * The `order` poles begin at index `spanIndex`.
183441
- * * The `2*order` knots begin as span index
183442
- * * The knot interval for this span is from `knot[degree+span-1] to knot[degree+span]`
183443
- * * The active part of the knot axis is `knot[degree-1] < knot < knot[degree-1 + numSpan]` i.e. `knot[degree-1] < knot < knot[numPoles]
183466
+ * * Each span is controlled by `order = degree + 1` contiguous points in the pole array.
183467
+ * * There is a strict relationship between knot and poles counts: `numPoles + order = numKnots + 2'.
183468
+ * * The number of spans is `numSpan = numPoles - degree`.
183469
+ * * For a span with index `spanIndex`:
183470
+ * * The `order` relevant poles begin at pole index `spanIndex`.
183471
+ * * The `2*degree` relevant knots begin at knot index `spanIndex`.
183472
+ * * The span domain is the knot range `[knot[spanIndex+degree-1], knot[spanIndex+degree]]`.
183473
+ * * The curve domain is the knot range `[knot[degree-1], knot[numSpan+degree-1]]`, or equivalently
183474
+ * `[knot[degree-1], knot[numPoles-1]]`. The API refers to this domain as the "active knot interval" of the curve.
183444
183475
  *
183445
- * Nearly all bsplines are "clamped ".
183446
- * * Clamping make the curve pass through its first and last poles, with tangents directed along the first and last edges of the control polygon.
183447
- * * The knots for a clamped bspline have `degree` copies of the lowest knot value and `degree` copies of the highest knot value.
183448
- * * For instance, the knot vector `[0,0,0,1,2,3,3,3]
183449
- * * can be evaluated from `0<=knot<=3`
183450
- * * has 3 spans: 0 to 1, 1 to 2, 2 to 3
183476
+ * Nearly all B-spline curves are "clamped".
183477
+ * * This means that in the `knots` array, the first `degree` knots are equal, and the last `degree` knots are equal.
183478
+ * We say the smallest knot and the largest knot have multiplicity `degree`.
183479
+ * * Clamping make the curve pass through its first and last poles, with tangents directed along the first and
183480
+ * last edges of the control polygon.
183481
+ * * For instance, a cubic B-spline curve with knot vector `[0,0,0,1,2,3,3,3]`
183482
+ * * can be evaluated at parameter values in the range `[0, 3]`
183483
+ * * has 3 spans, with domains `[0, 1]`, `[1, 2]`, and `[2, 3]`
183451
183484
  * * has 6 poles
183452
183485
  * * passes through its first and last poles.
183453
- * * `create` methods may allow classic convention that has an extra knot at the beginning and end of the knot vector.
183454
- * * The extra knots (first and last) were never referenced by the bspline recurrence relations.
183455
- * * When the `create` methods recognize the classic setup (`numPoles + order = numKnots`), the extra knot is not saved with the BSplineCurve3dBase knots.
183486
+ * * The `create` methods may allow the classic convention that has an extra knot at the beginning and end of the
183487
+ * knot vector.
183488
+ * * These two extra knots are not actually needed to define the B-spline curve.
183489
+ * * When the `create` methods recognize the classic setup (`numPoles + order = numKnots`), the extra knots are
183490
+ * not saved with the BSplineCurve3dBase knots.
183456
183491
  *
183457
- * * The weighted variant has the problem that CurvePrimitive 3d typing does not allow undefined result where Point4d has zero weight.
183458
- * * The convention for these is to return 000 in such places.
183492
+ * * The weighted variant [[BSplineCurve3dH]] has the problem that `CurvePrimitive` 3D typing does not allow the
183493
+ * undefined result where a homogeneous pole has zero weight; the convention in this case is to return 000.
183459
183494
  *
183460
183495
  * * Note the class relationships:
183461
- * * BSpline1dNd knows the bspline recurrence relations for control points (poles) with no physical meaning.
183462
- * * BsplineCurve3dBase owns a protected BSpline1dNd
183463
- * * BsplineCurve3dBase is derived from CurvePrimitive, which creates obligation to act as a 3D curve, such as
183464
- * * evaluate fraction to point and derivatives wrt fraction
183465
- * * compute intersection with plane
183466
- * * BSplineCurve3d and BSplineCurve3dH have variant logic driven by whether or not there are "weights" on the poles.
183467
- * * For `BSplineCurve3d`, the xyz value of pole calculations are "final" values for 3d evaluation
183496
+ * * [[BSpline1dNd]] knows the definitional B-spline recurrence relation with no physical interpretation for the poles.
183497
+ * * BsplineCurve3dBase owns a protected BSpline1dNd.
183498
+ * * `BsplineCurve3dBase` is derived from [[CurvePrimitive]], which creates obligation to act as a 3D curve, e.g.,
183499
+ * * evaluate fraction to point and derivatives wrt fraction.
183500
+ * * compute intersection with plane.
183501
+ * * [[BSplineCurve3d]] and [[BSplineCurve3dH]] have variant logic driven by whether or not there are "weights" on the poles.
183502
+ * * For `BSplineCurve3d`, the xyz value of pole calculations are "final" values for 3d evaluation.
183468
183503
  * * For `BSplineCurve3dH`, various `BSpline1dNd` results with xyzw have to be normalized back to xyz.
183469
183504
  *
183470
183505
  * * These classes do not support "periodic" variants.
183471
- * * Periodic curves need to have certain leading knots and poles replicated at the end
183506
+ * * Periodic curves historically have carried a flag (e.g., "closed") indicating that certain un-stored
183507
+ * leading/trailing knots and poles are understood to wrap around periodically.
183508
+ * * Instead, these classes carry no such flag. They represent such curves with explicitly wrapped knots/poles.
183509
+ *
183510
+ * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BSpline/
183472
183511
  * @public
183473
183512
  */
183474
183513
  class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_0__.CurvePrimitive {
183475
- /** String name for schema properties */
183514
+ /** String name for schema properties. */
183476
183515
  curvePrimitiveType = "bsplineCurve";
183477
- /** The underlying blocked-pole spline, with simple x,y,z poles */
183516
+ /** The underlying blocked-pole spline, with simple x,y,z poles. */
183478
183517
  _bcurve;
183479
183518
  _definitionData;
183480
- set definitionData(data) { this._definitionData = data; }
183481
- get definitionData() { return this._definitionData; }
183519
+ set definitionData(data) {
183520
+ this._definitionData = data;
183521
+ }
183522
+ get definitionData() {
183523
+ return this._definitionData;
183524
+ }
183482
183525
  constructor(poleDimension, numPoles, order, knots) {
183483
183526
  super();
183484
183527
  this._bcurve = _BSpline1dNd__WEBPACK_IMPORTED_MODULE_1__.BSpline1dNd.create(numPoles, poleDimension, order, knots);
183485
183528
  }
183486
- /** Return the degree (one less than the order) of the curve */
183487
- get degree() { return this._bcurve.degree; }
183488
- /** Return the order (one more than degree) of the curve */
183489
- get order() { return this._bcurve.order; }
183490
- /** Return the number of bezier spans in the curve. Note that this number includes the number of null spans at repeated knows */
183491
- get numSpan() { return this._bcurve.numSpan; }
183492
- /** Return the number of poles */
183493
- get numPoles() { return this._bcurve.numPoles; }
183494
- /** Return live reference to the packed control point coordinates of the curve. */
183495
- get polesRef() { return this._bcurve.packedData; }
183496
- /** Return live reference to the knots of the curve. */
183497
- get knotsRef() { return this._bcurve.knots.knots; }
183498
- /** Number of components per pole.
183499
- * * 3 for conventional (x,y,z) curve
183500
- * * 4 for weighted (wx,wy,wz,w) curve
183529
+ /** Return the degree (one less than the order) of the curve. */
183530
+ get degree() {
183531
+ return this._bcurve.degree;
183532
+ }
183533
+ /** Return the order (one more than degree) of the curve. */
183534
+ get order() {
183535
+ return this._bcurve.order;
183536
+ }
183537
+ /**
183538
+ * Return the number of Bezier spans in the curve. Note that this number includes the number of null
183539
+ * spans at repeated knows.
183501
183540
  */
183502
- get poleDimension() { return this._bcurve.poleLength; }
183541
+ get numSpan() {
183542
+ return this._bcurve.numSpan;
183543
+ }
183544
+ /** Return the number of poles. */
183545
+ get numPoles() {
183546
+ return this._bcurve.numPoles;
183547
+ }
183548
+ /** Return live reference to the poles of the curve. */
183549
+ get polesRef() {
183550
+ return this._bcurve.packedData;
183551
+ }
183552
+ /** Return live reference to the knots of the curve. */
183553
+ get knotsRef() {
183554
+ return this._bcurve.knots.knots;
183555
+ }
183503
183556
  /**
183504
- * return a simple array form of the knots. optionally replicate the first and last
183505
- * in classic over-clamped manner
183557
+ * Number of components per pole, e.g.,
183558
+ * * 3 for conventional (x,y,z) curve.
183559
+ * * 4 for weighted (wx,wy,wz,w) curve.
183506
183560
  */
183507
- copyKnots(includeExtraEndKnot) { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }
183561
+ get poleDimension() {
183562
+ return this._bcurve.poleLength;
183563
+ }
183564
+ /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
183565
+ copyKnots(includeExtraEndKnot) {
183566
+ return this._bcurve.knots.copyKnots(includeExtraEndKnot);
183567
+ }
183508
183568
  /** Get the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
183509
183569
  getWrappable() {
183510
183570
  return this._bcurve.knots.wrappable;
@@ -183514,7 +183574,7 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183514
183574
  this._bcurve.knots.wrappable = value;
183515
183575
  }
183516
183576
  /**
183517
- * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
183577
+ * Test knots and poles to determine if it is possible to close (aka "wrap") the curve.
183518
183578
  * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
183519
183579
  */
183520
183580
  get isClosableCurve() {
@@ -183527,25 +183587,18 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183527
183587
  return _KnotVector__WEBPACK_IMPORTED_MODULE_2__.BSplineWrapMode.None;
183528
183588
  return mode;
183529
183589
  }
183530
- /** Evaluate the curve point at `fraction` */
183590
+ /** Evaluate the curve point at the given fractional parameter. */
183531
183591
  fractionToPoint(fraction, result) {
183532
183592
  return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);
183533
183593
  }
183534
- /** Construct a ray with
183535
- * * origin at the fractional position along the arc
183536
- * * direction is the first derivative, i.e. tangent along the curve
183537
- */
183594
+ /** Evaluate the curve and derivative at the given fractional parameter. */
183538
183595
  fractionToPointAndDerivative(fraction, result) {
183539
183596
  const knot = this._bcurve.knots.fractionToKnot(fraction);
183540
183597
  result = this.knotToPointAndDerivative(knot, result);
183541
183598
  result.direction.scaleInPlace(this._bcurve.knots.knotLength01);
183542
183599
  return result;
183543
183600
  }
183544
- /** Construct a plane with
183545
- * * origin at the fractional position along the arc
183546
- * * x axis is the first derivative, i.e. tangent along the curve
183547
- * * y axis is the second derivative
183548
- */
183601
+ /** Evaluate the curve and two derivatives at the given fractional parameter. */
183549
183602
  fractionToPointAnd2Derivatives(fraction, result) {
183550
183603
  const knot = this._bcurve.knots.fractionToKnot(fraction);
183551
183604
  result = this.knotToPointAnd2Derivatives(knot, result);
@@ -183554,22 +183607,23 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183554
183607
  result.vectorV.scaleInPlace(a * a);
183555
183608
  return result;
183556
183609
  }
183610
+ /** Return the start point of the curve. */
183611
+ startPoint() {
183612
+ return this.evaluatePointInSpan(0, 0.0);
183613
+ }
183614
+ /** Return the end point of the curve. */
183615
+ endPoint() {
183616
+ return this.evaluatePointInSpan(this.numSpan - 1, 1.0);
183617
+ }
183557
183618
  /**
183558
- * Return the start point of the curve.
183559
- */
183560
- startPoint() { return this.evaluatePointInSpan(0, 0.0); }
183561
- /**
183562
- * Return the end point of the curve
183563
- */
183564
- endPoint() { return this.evaluatePointInSpan(this.numSpan - 1, 1.0); }
183565
- /** Reverse the curve in place.
183566
- * * Poles are reversed
183567
- * * knot values are mirrored around the middle of the
183568
- */
183569
- reverseInPlace() { this._bcurve.reverseInPlace(); }
183570
- /**
183571
- * Return an array with this curve's bezier fragments.
183619
+ * Reverse the curve in place.
183620
+ * * Poles are reversed.
183621
+ * * Knot values are mirrored around the middle of the knot array.
183572
183622
  */
183623
+ reverseInPlace() {
183624
+ this._bcurve.reverseInPlace();
183625
+ }
183626
+ /** Return an array with this curve's Bezier fragments. */
183573
183627
  collectBezierSpans(prefer3dH) {
183574
183628
  const result = [];
183575
183629
  const numSpans = this.numSpan;
@@ -183588,17 +183642,18 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183588
183642
  return poleIndex * this._bcurve.poleLength;
183589
183643
  return undefined;
183590
183644
  }
183591
- /** Search for the curve point that is closest to the spacePoint.
183592
- *
183645
+ /**
183646
+ * Search for the curve point that is closest to the spacePoint.
183593
183647
  * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
183594
- * * Since CurvePrimitive should always have start and end available as candidate points, this method should always succeed
183595
- * @param spacePoint point in space
183648
+ * * Since CurvePrimitive should always have start and end available as candidate points, this method should always
183649
+ * succeed.
183650
+ * @param spacePoint point in space.
183596
183651
  * @param _extend ignored (pass false). A BSplineCurve3dBase cannot be extended.
183597
183652
  * @param result optional pre-allocated detail to populate and return.
183598
183653
  * @returns details of the closest point.
183599
183654
  */
183600
183655
  closestPoint(spacePoint, _extend, result) {
183601
- // seed at start point -- final point comes with final bezier perpendicular step.
183656
+ // seed at start point; final point comes with final bezier perpendicular step
183602
183657
  const point = this.fractionToPoint(0);
183603
183658
  result = _curve_CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.createCurveFractionPointDistance(this, 0.0, point, point.distance(spacePoint), result);
183604
183659
  let span;
@@ -183607,9 +183662,9 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183607
183662
  if (this._bcurve.knots.isIndexOfRealSpan(i)) {
183608
183663
  span = this.getSaturatedBezierSpan3dOr3dH(i, true, span);
183609
183664
  if (span) {
183610
- // umm ... if the bspline is discontinuous, both ends should be tested. Ignore that possibility ...
183665
+ // if the B-spline is discontinuous, both ends should be tested; ignore that possibility
183611
183666
  if (span.updateClosestPointByTruePerpendicular(spacePoint, result, false, true)) {
183612
- // the detail records the span bezier -- promote it to the parent curve . ..
183667
+ // the detail records the span bezier; promote it to the parent curve
183613
183668
  result.curve = this;
183614
183669
  result.fraction = span.fractionToParentFraction(result.fraction);
183615
183670
  }
@@ -183620,13 +183675,14 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183620
183675
  }
183621
183676
  /** Return a transformed deep clone. */
183622
183677
  cloneTransformed(transform) {
183623
- const curve1 = this.clone();
183624
- curve1.tryTransformInPlace(transform);
183625
- return curve1;
183678
+ const curve = this.clone();
183679
+ curve.tryTransformInPlace(transform);
183680
+ return curve;
183626
183681
  }
183627
- /** Return a curve primitive which is a portion of this curve.
183628
- * @param fractionA [in] start fraction
183629
- * @param fractionB [in] end fraction
183682
+ /**
183683
+ * Return a curve primitive which is a portion of this curve.
183684
+ * @param fractionA start fraction.
183685
+ * @param fractionB end fraction.
183630
183686
  */
183631
183687
  clonePartialCurve(fractionA, fractionB) {
183632
183688
  const clone = this.clone();
@@ -183637,11 +183693,8 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183637
183693
  clone._bcurve.addKnot(knotB, clone.degree);
183638
183694
  if (origNumKnots === clone._bcurve.knots.knots.length)
183639
183695
  return clone; // full curve
183640
- if (knotA > knotB) {
183641
- const tmp = knotA;
183642
- knotA = knotB;
183643
- knotB = tmp;
183644
- }
183696
+ if (knotA > knotB)
183697
+ [knotA, knotB] = [knotB, knotA];
183645
183698
  // choose first/last knot and pole such that knotA/knotB has degree multiplicity in the new knot sequence
183646
183699
  const iStartKnot = clone._bcurve.knots.knotToLeftKnotIndex(knotA) - clone.degree + 1;
183647
183700
  const iStartPole = iStartKnot * clone._bcurve.poleLength;
@@ -183651,15 +183704,17 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183651
183704
  iLastKnotLeftMultiple = iLastKnot + 1;
183652
183705
  const iEndPole = (iLastKnotLeftMultiple + 1) * clone._bcurve.poleLength; // one past last pole
183653
183706
  const iEndKnot = iLastKnotLeftMultiple + clone.degree; // one past last knot
183654
- // trim the arrays (leave knots unnormalized!)
183707
+ // trim the arrays (leave knots unnormalized)
183655
183708
  clone._bcurve.knots.setKnotsCapture(clone._bcurve.knots.knots.slice(iStartKnot, iEndKnot));
183656
183709
  clone._bcurve.packedData = clone._bcurve.packedData.slice(iStartPole, iEndPole);
183657
183710
  clone.setWrappable(_KnotVector__WEBPACK_IMPORTED_MODULE_2__.BSplineWrapMode.None); // always open
183658
183711
  return clone;
183659
183712
  }
183660
- /** Implement `CurvePrimitive.appendPlaneIntersections`
183661
- * @param plane A plane (e.g. specific type Plane3dByOriginAndUnitNormal or Point4d)
183662
- * @param result growing array of plane intersections
183713
+ /**
183714
+ * Implement `CurvePrimitive.appendPlaneIntersections` to compute intersections of the curve with a plane.
183715
+ * @param plane the plane with which to intersect the curve. Concrete types include [[Plane3dByOriginAndUnitNormal]],
183716
+ * [[Point4d]], etc.
183717
+ * @param result growing array of plane intersections.
183663
183718
  * @return number of intersections appended to the array.
183664
183719
  */
183665
183720
  appendPlaneIntersectionPoints(plane, result) {
@@ -183670,34 +183725,32 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183670
183725
  const point4d = _geometry4d_Point4d__WEBPACK_IMPORTED_MODULE_4__.Point4d.create();
183671
183726
  // compute all pole altitudes from the plane
183672
183727
  const minMax = _geometry3d_Range__WEBPACK_IMPORTED_MODULE_5__.Range1d.createNull();
183673
- // Put the altitudes of all the bspline poles in one array.
183728
+ // put the altitudes of all the B-spline poles in one array
183674
183729
  for (let i = 0; i < numPole; i++) {
183675
183730
  allCoffs[i] = plane.weightedAltitude(this.getPolePoint4d(i, point4d));
183676
183731
  minMax.extendX(allCoffs[i]);
183677
183732
  }
183678
- // A univariate bspline through the altitude poles gives altitude as function of the bspline knot.
183733
+ // A univariate B-spline through the altitude poles gives altitude as function of the B-spline knot.
183679
183734
  // The (bspline) altitude function for each span is `order` consecutive altitudes.
183680
183735
  // If those altitudes bracket zero, the span may potentially have a crossing.
183681
- // When that occurs,
183682
183736
  let univariateBezier;
183683
183737
  let numFound = 0;
183684
183738
  let previousFraction = -1000.0;
183685
183739
  if (minMax.containsX(0.0)) {
183686
183740
  for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {
183687
- if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals.
183741
+ if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals
183688
183742
  // outer range test ...
183689
183743
  minMax.setNull();
183690
183744
  minMax.extendArraySubset(allCoffs, spanIndex, order);
183691
183745
  if (minMax.containsX(0.0)) {
183692
- // pack the bspline support into a univariate bezier ...
183746
+ // pack the B-spline support into a univariate bezier
183693
183747
  univariateBezier = _numerics_BezierPolynomials__WEBPACK_IMPORTED_MODULE_6__.UnivariateBezier.createArraySubset(allCoffs, spanIndex, order, univariateBezier);
183694
183748
  // saturate and solve the bezier
183695
183749
  _Bezier1dNd__WEBPACK_IMPORTED_MODULE_7__.Bezier1dNd.saturate1dInPlace(univariateBezier.coffs, this._bcurve.knots, spanIndex);
183696
183750
  const roots = univariateBezier.roots(0.0, true);
183697
183751
  if (roots) {
183698
183752
  for (const spanFraction of roots) {
183699
- // promote each local bezier fraction to global fraction.
183700
- // save the curve evaluation at that fraction.
183753
+ // promote each local bezier fraction to global fraction and save the curve evaluation at that fraction
183701
183754
  numFound++;
183702
183755
  const fraction = this._bcurve.knots.spanFractionToFraction(spanIndex, spanFraction);
183703
183756
  if (!_Geometry__WEBPACK_IMPORTED_MODULE_8__.Geometry.isAlmostEqualNumber(fraction, previousFraction)) {
@@ -183716,9 +183769,7 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183716
183769
  }
183717
183770
  /**
183718
183771
  * Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).
183719
- * * No attempt is made to join the offsets of smaller constituent primitives. To construct a fully joined offset
183720
- * for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset() instead.
183721
- * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
183772
+ * @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object.
183722
183773
  */
183723
183774
  constructOffsetXY(offsetDistanceOrOptions) {
183724
183775
  const options = _curve_OffsetOptions__WEBPACK_IMPORTED_MODULE_9__.OffsetOptions.create(offsetDistanceOrOptions);
@@ -183726,18 +183777,21 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
183726
183777
  this.emitStrokableParts(handler, options.strokeOptions);
183727
183778
  return handler.claimResult();
183728
183779
  }
183729
- /** Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters of projection.
183780
+ /**
183781
+ * Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters
183782
+ * of projection.
183730
183783
  * @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
183731
- * @param lowHigh optional receiver for output
183732
- * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the end of the ray.
183784
+ * @param lowHigh optional receiver for output.
183785
+ * @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
183786
+ * end of the ray.
183733
183787
  */
183734
183788
  projectedParameterRange(ray, lowHigh) {
183735
183789
  return _curve_internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_11__.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
183736
183790
  }
183737
183791
  }
183738
183792
  /**
183739
- * A BSplineCurve3d is a bspline curve whose poles are Point3d.
183740
- * See BSplineCurve3dBase for description of knots, order, degree.
183793
+ * A BSplineCurve3d is a B-spline curve whose poles are Point3d.
183794
+ * See BSplineCurve3dBase for description of knots, order, degree, and poles.
183741
183795
  * @public
183742
183796
  */
183743
183797
  class BSplineCurve3d extends BSplineCurve3dBase {
@@ -183747,11 +183801,19 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183747
183801
  this._workBezier = _BezierCurve3d__WEBPACK_IMPORTED_MODULE_12__.BezierCurve3d.createOrder(this.order);
183748
183802
  return this._workBezier;
183749
183803
  }
183750
- /** test of `other` is an instance of BSplineCurve3d */
183751
- isSameGeometryClass(other) { return other instanceof BSplineCurve3d; }
183804
+ constructor(numPoles, order, knots) {
183805
+ super(3, numPoles, order, knots);
183806
+ }
183807
+ /** Test if `other` is an instance of BSplineCurve3d. */
183808
+ isSameGeometryClass(other) {
183809
+ return other instanceof BSplineCurve3d;
183810
+ }
183752
183811
  /** Apply `transform` to the poles. */
183753
- tryTransformInPlace(transform) { _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.multiplyInPlace(transform, this._bcurve.packedData); return true; }
183754
- /** Get a pole as simple Point3d. */
183812
+ tryTransformInPlace(transform) {
183813
+ _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.multiplyInPlace(transform, this._bcurve.packedData);
183814
+ return true;
183815
+ }
183816
+ /** Get a pole as a simple Point3d. */
183755
183817
  getPolePoint3d(poleIndex, result) {
183756
183818
  const k = this.poleIndexToDataIndex(poleIndex);
183757
183819
  if (k !== undefined) {
@@ -183760,7 +183822,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183760
183822
  }
183761
183823
  return undefined;
183762
183824
  }
183763
- /** Get a pole as Point4d with weight 1 */
183825
+ /** Get a pole as Point4d with weight 1. */
183764
183826
  getPolePoint4d(poleIndex, result) {
183765
183827
  const k = this.poleIndexToDataIndex(poleIndex);
183766
183828
  if (k !== undefined) {
@@ -183769,23 +183831,26 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183769
183831
  }
183770
183832
  return undefined;
183771
183833
  }
183772
- /** Convert `spanIndex` and `localFraction` to a knot. */
183773
- spanFractionToKnot(span, localFraction) {
183774
- return this._bcurve.spanFractionToKnot(span, localFraction);
183775
- }
183776
- constructor(numPoles, order, knots) {
183777
- super(3, numPoles, order, knots);
183778
- }
183779
- /** Return a simple array of arrays with the control points as `[[x,y,z],[x,y,z],..]` */
183780
- copyPoints() { return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3); }
183781
- /** Return a simple array of the control points coordinates */
183782
- copyPointsFloat64Array() { return this._bcurve.packedData.slice(); }
183783
183834
  /**
183784
- * return a simple array form of the knots. optionally replicate the first and last
183785
- * in classic over-clamped manner
183835
+ * Convert the fractional position in the given span to a knot.
183836
+ * * The returned value is not necessarily a knot, but it is a valid parameter in the domain of the B-spline curve.
183786
183837
  */
183787
- copyKnots(includeExtraEndKnot) { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }
183788
- /** Create a bspline with uniform knots. */
183838
+ spanFractionToKnot(spanIndex, spanFraction) {
183839
+ return this._bcurve.spanFractionToKnot(spanIndex, spanFraction);
183840
+ }
183841
+ /** Return a simple array of arrays with the poles as `[[x,y,z],[x,y,z],..]`. */
183842
+ copyPoints() {
183843
+ return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3);
183844
+ }
183845
+ /** Return a simple array of poles' coordinates. */
183846
+ copyPointsFloat64Array() {
183847
+ return this._bcurve.packedData.slice();
183848
+ }
183849
+ /** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
183850
+ copyKnots(includeExtraEndKnot) {
183851
+ return this._bcurve.knots.copyKnots(includeExtraEndKnot);
183852
+ }
183853
+ /** Create a B-spline with uniform knots. */
183789
183854
  static createUniformKnots(poles, order) {
183790
183855
  const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;
183791
183856
  if (order < 2 || numPoles < order)
@@ -183809,9 +183874,10 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183809
183874
  }
183810
183875
  return curve;
183811
183876
  }
183812
- /** Create a smoothly closed B-spline curve with uniform knots.
183813
- * Note that the curve does not start at the first pole!
183814
- */
183877
+ /**
183878
+ * Create a smoothly closed B-spline curve with uniform knots.
183879
+ * * Note that the curve does not start at the first pole.
183880
+ */
183815
183881
  static createPeriodicUniformKnots(poles, order) {
183816
183882
  if (order < 2)
183817
183883
  return undefined;
@@ -183882,21 +183948,23 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183882
183948
  return _BSplineCurveOps__WEBPACK_IMPORTED_MODULE_16__.BSplineCurveOps.createThroughPointsC2Cubic(options);
183883
183949
  }
183884
183950
  /**
183885
- *
183951
+ * Create a B-spline curve from an Akima curve.
183886
183952
  * @param options collection of points and end conditions.
183887
183953
  */
183888
183954
  static createFromAkimaCurve3dOptions(options) {
183889
183955
  return _BSplineCurveOps__WEBPACK_IMPORTED_MODULE_16__.BSplineCurveOps.createThroughPoints(options.fitPoints, 4); // temporary
183890
183956
  }
183891
183957
  /**
183892
- * Create a bspline with given knots.
183958
+ * Create a B-spline curve with given knots.
183893
183959
  * * The poles have several variants:
183894
- * * Float64Array(3 * numPoles) in blocks of [x,y,z]
183895
- * * Point3d[]
183896
- * * number[][], with inner dimension 3
183960
+ * * Float64Array(3 * numPoles) in blocks of [x,y,z].
183961
+ * * Point3d[].
183962
+ * * number[][], with inner dimension 3.
183897
183963
  * * Two count conditions are recognized:
183898
- * * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots of classic clamping.
183964
+ * * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots
183965
+ * of classic clamping.
183899
183966
  * * If poleArray.length + order === knotArray.length + 2, the knots are in modern form.
183967
+ * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BSpline/
183900
183968
  */
183901
183969
  static create(poleArray, knotArray, order) {
183902
183970
  if (order < 2)
@@ -183934,31 +184002,42 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183934
184002
  }
183935
184003
  return curve;
183936
184004
  }
183937
- /** Return a deep clone */
184005
+ /** Return a deep clone. */
183938
184006
  clone() {
183939
- const knotVector1 = this._bcurve.knots.clone();
183940
- const curve1 = new BSplineCurve3d(this.numPoles, this.order, knotVector1);
183941
- curve1._bcurve.packedData = this._bcurve.packedData.slice();
183942
- return curve1;
184007
+ const knotVector = this._bcurve.knots.clone();
184008
+ const curve = new BSplineCurve3d(this.numPoles, this.order, knotVector);
184009
+ curve._bcurve.packedData = this._bcurve.packedData.slice();
184010
+ return curve;
183943
184011
  }
183944
- /** Evaluate at a position given by fractional position within a span. */
184012
+ /** Evaluate the curve at a fractional position within a given span. */
183945
184013
  evaluatePointInSpan(spanIndex, spanFraction) {
183946
184014
  this._bcurve.evaluateBuffersInSpan(spanIndex, spanFraction);
183947
184015
  return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Point3d.createFrom(this._bcurve.poleBuffer);
183948
184016
  }
183949
- /** Evaluate point and derivative vector at a position given by fractional position within a span.
183950
- * * The derivative is with respect to the span fraction (NOT scaled to either global fraction or knot)
184017
+ /**
184018
+ * Evaluate the curve and derivative at a fractional position within a given span.
184019
+ * * The derivative is with respect to the span fractional parameter, _not_ to the curve's parameter or fractional parameter.
183951
184020
  */
183952
184021
  evaluatePointAndDerivativeInSpan(spanIndex, spanFraction) {
183953
184022
  this._bcurve.evaluateBuffersInSpan1(spanIndex, spanFraction);
183954
184023
  return _geometry3d_Ray3d__WEBPACK_IMPORTED_MODULE_17__.Ray3d.createCapture(_geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Point3d.createFrom(this._bcurve.poleBuffer), _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Vector3d.createFrom(this._bcurve.poleBuffer1));
183955
184024
  }
183956
- /** Evaluate at a position given by a knot value. */
184025
+ /**
184026
+ * Evaluate the curve at the given parameter.
184027
+ * @param u parameter in curve domain.
184028
+ * @param result optional result.
184029
+ * @returns the point on the curve.
184030
+ */
183957
184031
  knotToPoint(u, result) {
183958
184032
  this._bcurve.evaluateBuffersAtKnot(u);
183959
184033
  return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Point3d.createFrom(this._bcurve.poleBuffer, result);
183960
184034
  }
183961
- /** Evaluate at a position given by a knot value. */
184035
+ /**
184036
+ * Evaluate the curve and derivative at the given parameter.
184037
+ * @param u parameter in curve domain.
184038
+ * @param result optional result.
184039
+ * @returns the ray with origin at the curve point and direction as the derivative.
184040
+ */
183962
184041
  knotToPointAndDerivative(u, result) {
183963
184042
  this._bcurve.evaluateBuffersAtKnot(u, 1);
183964
184043
  if (!result)
@@ -183967,12 +184046,17 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183967
184046
  result.direction.setFrom(this._bcurve.poleBuffer1);
183968
184047
  return result;
183969
184048
  }
183970
- /** Evaluate at a position given by a knot value. Return point with 2 derivatives. */
184049
+ /**
184050
+ * Evaluate the curve and two derivatives at the given parameter.
184051
+ * @param u parameter in the curve domain.
184052
+ * @param result optional result.
184053
+ * @returns the plane with origin at the curve point, vectorU as the 1st derivative, and vectorV as the 2nd derivative.
184054
+ */
183971
184055
  knotToPointAnd2Derivatives(u, result) {
183972
184056
  this._bcurve.evaluateBuffersAtKnot(u, 2);
183973
184057
  return _geometry3d_Plane3dByOriginAndVectors__WEBPACK_IMPORTED_MODULE_18__.Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(this._bcurve.poleBuffer[0], this._bcurve.poleBuffer[1], this._bcurve.poleBuffer[2], this._bcurve.poleBuffer1[0], this._bcurve.poleBuffer1[1], this._bcurve.poleBuffer1[2], this._bcurve.poleBuffer2[0], this._bcurve.poleBuffer2[1], this._bcurve.poleBuffer2[2], result);
183974
184058
  }
183975
- /** test if almost the same curve as `other` */
184059
+ /** Test if `this` is almost the same curve as `other`. */
183976
184060
  isAlmostEqual(other) {
183977
184061
  if (other instanceof BSplineCurve3d) {
183978
184062
  return this._bcurve.knots.isAlmostEqual(other._bcurve.knots)
@@ -183980,15 +184064,19 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183980
184064
  }
183981
184065
  return false;
183982
184066
  }
183983
- /** test if this curve is entirely within plane. */
184067
+ /** Test if this curve lies entirely in the given plane. */
183984
184068
  isInPlane(plane) {
183985
184069
  return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.isCloseToPlane(this._bcurve.packedData, plane);
183986
184070
  }
183987
- /** Return the control polygon length as approximation (always overestimate) of the curve length. */
183988
- quickLength() { return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.sumEdgeLengths(this._bcurve.packedData); }
183989
- /** Emit beziers or strokes (selected by the stroke options) to the handler. */
184071
+ /**
184072
+ * Return the control polygon length as an approximation to the curve length.
184073
+ * * The returned length is always an overestimate.
184074
+ */
184075
+ quickLength() {
184076
+ return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.sumEdgeLengths(this._bcurve.packedData);
184077
+ }
184078
+ /** Emit Beziers or strokes (selected by the stroke options) to the handler. */
183990
184079
  emitStrokableParts(handler, options) {
183991
- const needBeziers = handler.announceBezierCurve !== undefined;
183992
184080
  const workBezier = this.initializeWorkBezier();
183993
184081
  const numSpan = this.numSpan;
183994
184082
  let numStrokes;
@@ -183996,7 +184084,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
183996
184084
  const bezier = this.getSaturatedBezierSpan3dOr3dH(spanIndex, false, workBezier);
183997
184085
  if (bezier) {
183998
184086
  numStrokes = bezier.computeStrokeCountForOptions(options);
183999
- if (needBeziers) {
184087
+ if (handler.announceBezierCurve) {
184000
184088
  handler.announceBezierCurve(bezier, numStrokes, this, spanIndex, this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0), this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));
184001
184089
  }
184002
184090
  else {
@@ -184021,7 +184109,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184021
184109
  return numStroke;
184022
184110
  }
184023
184111
  /**
184024
- * Compute individual segment stroke counts. Attach in a StrokeCountMap.
184112
+ * Compute individual segment stroke counts. Attach in a StrokeCountMap.
184025
184113
  * @param options StrokeOptions that determine count
184026
184114
  * @param parentStrokeMap evolving parent map.
184027
184115
  * @alpha
@@ -184040,7 +184128,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184040
184128
  }
184041
184129
  _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_0__.CurvePrimitive.installStrokeCountMap(this, myData, parentStrokeMap);
184042
184130
  }
184043
- /** Append strokes to a linestring. */
184131
+ /** Append strokes to the given linestring. */
184044
184132
  emitStrokes(dest, options) {
184045
184133
  const workBezier = this.initializeWorkBezier();
184046
184134
  const numSpan = this.numSpan;
@@ -184051,16 +184139,17 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184051
184139
  }
184052
184140
  }
184053
184141
  /**
184054
- * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
184142
+ * Test knots and poles to determine if it is possible to close (aka "wrap") the curve.
184055
184143
  * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
184056
184144
  */
184057
184145
  get isClosable() {
184058
184146
  return this.isClosableCurve;
184059
184147
  }
184060
184148
  /**
184061
- * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to this type.
184062
- * @param spanIndex
184063
- * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.
184149
+ * Return the Bezier fragment corresponding to the given span of this curve.
184150
+ * * The concrete return type may be [[BezierCurve3d]] or [[BezierCurve3dH]] according to the instance type and `prefer3dH`.
184151
+ * @param spanIndex index of span.
184152
+ * @param result optional reusable curve. This will only be reused if its type and order matches.
184064
184153
  */
184065
184154
  getSaturatedBezierSpan3dOr3dH(spanIndex, prefer3dH, result) {
184066
184155
  if (prefer3dH)
@@ -184068,9 +184157,9 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184068
184157
  return this.getSaturatedBezierSpan3d(spanIndex, result);
184069
184158
  }
184070
184159
  /**
184071
- * Return a CurvePrimitive (which is a BezierCurve3d) for a specified span of this curve.
184072
- * @param spanIndex
184073
- * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.
184160
+ * Return the Bezier fragment corresponding to the given span of this curve.
184161
+ * @param spanIndex index of span.
184162
+ * @param result optional reusable curve. This will only be reused if its type and order matches.
184074
184163
  */
184075
184164
  getSaturatedBezierSpan3d(spanIndex, result) {
184076
184165
  if (spanIndex < 0 || spanIndex >= this.numSpan)
@@ -184081,13 +184170,13 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184081
184170
  const bezier = result;
184082
184171
  bezier.loadSpanPoles(this._bcurve.packedData, spanIndex);
184083
184172
  if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))
184084
- return result;
184173
+ return bezier;
184085
184174
  return undefined;
184086
184175
  }
184087
184176
  /**
184088
- * Return a CurvePrimitive (which is a BezierCurve3dH) for a specified span of this curve.
184089
- * @param spanIndex
184090
- * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.
184177
+ * Return the Bezier fragment corresponding to the given span of this curve.
184178
+ * @param spanIndex index of span.
184179
+ * @param result optional reusable curve. This will only be reused if its type and order matches.
184091
184180
  */
184092
184181
  getSaturatedBezierSpan3dH(spanIndex, result) {
184093
184182
  if (spanIndex < 0 || spanIndex >= this.numSpan)
@@ -184101,15 +184190,16 @@ class BSplineCurve3d extends BSplineCurve3dBase {
184101
184190
  return bezier;
184102
184191
  return undefined;
184103
184192
  }
184104
- /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)` */
184193
+ /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)`. */
184105
184194
  dispatchToGeometryHandler(handler) {
184106
184195
  return handler.handleBSplineCurve3d(this);
184107
184196
  }
184108
184197
  /**
184109
- * Extend a range so in includes the range of this curve
184110
- * * REMARK: this is based on the poles, not the exact curve. This is generally larger than the true curve range.
184111
- * @param rangeToExtend
184112
- * @param transform transform to apply to points as they are entered into the range.
184198
+ * Extend a range so it contains the range of this curve.
184199
+ * * This computation is based on the poles, not the curve itself, so the returned range is generally larger than the
184200
+ * tightest possible range.
184201
+ * @param rangeToExtend range to extend.
184202
+ * @param transform transform to apply to the poles as they are entered into the range.
184113
184203
  */
184114
184204
  extendRange(rangeToExtend, transform) {
184115
184205
  const buffer = this._bcurve.packedData;
@@ -186871,13 +186961,11 @@ __webpack_require__.r(__webpack_exports__);
186871
186961
 
186872
186962
 
186873
186963
 
186874
- // ================================================================================================================
186875
- // ================================================================================================================
186876
- // ================================================================================================================
186877
- // ================================================================================================================
186878
- /** 3d Bezier curve class.
186964
+ /**
186965
+ * 3d Bezier curve class.
186879
186966
  * * Use BezierCurve3dH if the curve has weights.
186880
186967
  * * The control points (xyz) are managed as the _packedData buffer in the _polygon member of BezierCurveBase.
186968
+ * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/Bezier/
186881
186969
  * @public
186882
186970
  */
186883
186971
  class BezierCurve3d extends _BezierCurveBase__WEBPACK_IMPORTED_MODULE_0__.BezierCurveBase {
@@ -188032,8 +188120,9 @@ __webpack_require__.r(__webpack_exports__);
188032
188120
  /* harmony export */ BSplineWrapMode: () => (/* binding */ BSplineWrapMode),
188033
188121
  /* harmony export */ KnotVector: () => (/* binding */ KnotVector)
188034
188122
  /* harmony export */ });
188035
- /* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
188036
- /* harmony import */ var _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../geometry3d/PointHelpers */ "../../core/geometry/lib/esm/geometry3d/PointHelpers.js");
188123
+ /* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
188124
+ /* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
188125
+ /* harmony import */ var _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/PointHelpers */ "../../core/geometry/lib/esm/geometry3d/PointHelpers.js");
188037
188126
  /*---------------------------------------------------------------------------------------------
188038
188127
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
188039
188128
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -188043,6 +188132,7 @@ __webpack_require__.r(__webpack_exports__);
188043
188132
  */
188044
188133
 
188045
188134
 
188135
+
188046
188136
  /**
188047
188137
  * B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.
188048
188138
  * This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.
@@ -188052,68 +188142,89 @@ var BSplineWrapMode;
188052
188142
  (function (BSplineWrapMode) {
188053
188143
  /** No conversion performed. */
188054
188144
  BSplineWrapMode[BSplineWrapMode["None"] = 0] = "None";
188055
- /** The B-spline was opened up by adding degree wrap-around control points to the legacy periodic data.
188056
- * * This is typical of B-splines constructed with maximum (degree - 1) continuity.
188145
+ /**
188146
+ * The legacy periodic B-spline data was opened up by adding `degree` wrap-around poles.
188147
+ * * This is typical of B-spline curves and surfaces constructed with maximum `degree - 1` continuity.
188057
188148
  * * Knots are unaffected by this conversion.
188058
188149
  */
188059
188150
  BSplineWrapMode[BSplineWrapMode["OpenByAddingControlPoints"] = 1] = "OpenByAddingControlPoints";
188060
- /** The B-spline was opened up by removing degree extreme knots from the legacy periodic data.
188151
+ /**
188152
+ * The legacy periodic B-spline data was opened up by removing `degree` exterior knots.
188061
188153
  * * This is typical of rational B-spline curves representing full circles and ellipses.
188062
188154
  * * Poles are unaffected by this conversion.
188063
188155
  */
188064
188156
  BSplineWrapMode[BSplineWrapMode["OpenByRemovingKnots"] = 2] = "OpenByRemovingKnots";
188065
188157
  })(BSplineWrapMode || (BSplineWrapMode = {}));
188066
188158
  /**
188067
- * Array of non-decreasing numbers acting as a knot array for B-splines.
188159
+ * Array of non-decreasing numbers acting as a knot vector for B-spline curves and surfaces.
188068
188160
  *
188069
188161
  * * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1
188070
- * * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation and Parasolid)
188071
- * demand order knots at each end for clamping. But only order-1 are really needed. This class uses the order-1 convention.
188162
+ * * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation
188163
+ * and Parasolid) demand order knots at each end for clamping. However, only order-1 are really needed. This class uses the
188164
+ * order-1 convention.
188072
188165
  * * A span is a single interval of the knots.
188073
- * * The left knot of span {k} is knot {k+degree-1}.
188166
+ * * The left knot of the span with index `k>=0` is the knot with index `k+degree-1`.
188167
+ * * A knot vector is clamped when the first `degree` knots are equal and the last `degree` knots are equal.
188168
+ * * The "active knot interval" is the subset of the knot vector sans its first and last `degree-1` knots, and serves as
188169
+ * the parametric domain of the associated B-spline object.
188074
188170
  * * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.
188075
- * * Core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Callers need to
188076
- * know their primary values (global knot, spanFraction).
188171
+ * * Callers need to distinguish core computational inputs such as left knot index, knot value, span index, and span fraction.
188077
188172
  * @public
188078
188173
  */
188079
188174
  class KnotVector {
188080
188175
  /** The simple array of knot values. */
188081
188176
  knots;
188082
- /** Return the degree of basis functions defined in these knots. */
188177
+ /** The degree of basis functions defined in these knots. */
188083
188178
  degree;
188179
+ /** The leftmost knot value (of the active interval, ignoring unclamped leading knots). */
188084
188180
  _knot0;
188181
+ /** The rightmost knot value (of the active interval, ignoring unclamped leading knots). */
188085
188182
  _knot1;
188086
188183
  _wrapMode;
188087
- /** tolerance for considering two knots to be the same. */
188184
+ /** Tolerance for considering two knots to be the same. */
188088
188185
  static knotTolerance = 1.0e-9;
188089
- /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/
188090
- get leftKnot() { return this._knot0; }
188091
- /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/
188092
- get rightKnot() { return this._knot1; }
188093
- /** Return the index of the leftmost knot of the active interval */
188094
- get leftKnotIndex() { return this.degree - 1; }
188095
- /** Return the index of the rightmost knot of the active interval */
188096
- get rightKnotIndex() { return this.knots.length - this.degree; }
188097
- /** Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used is specified by BSplineWrapMode, and is reversed at serialization time. */
188098
- get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }
188099
- set wrappable(value) { this._wrapMode = value; }
188100
- /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */
188101
- get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }
188186
+ /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). */
188187
+ get leftKnot() {
188188
+ return this._knot0;
188189
+ }
188190
+ /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). */
188191
+ get rightKnot() {
188192
+ return this._knot1;
188193
+ }
188194
+ /** Return the index of the leftmost knot of the active interval. */
188195
+ get leftKnotIndex() {
188196
+ return this.degree - 1;
188197
+ }
188198
+ /** Return the index of the rightmost knot of the active interval. */
188199
+ get rightKnotIndex() {
188200
+ return this.knots.length - this.degree;
188201
+ }
188102
188202
  /**
188103
- *
188104
- * * If knots is a number array or Float64Array, the those values become the local knot array.
188105
- * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.
188106
- * @param knots
188107
- * @param degree
188203
+ * Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used
188204
+ * is specified by BSplineWrapMode, and is reversed at serialization time.
188205
+ */
188206
+ get wrappable() {
188207
+ return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode;
188208
+ }
188209
+ set wrappable(value) {
188210
+ this._wrapMode = value;
188211
+ }
188212
+ /** Return the number of Bezier spans. Note that this includes zero-length spans if there are repeated knots. */
188213
+ get numSpans() {
188214
+ return this.rightKnotIndex - this.leftKnotIndex;
188215
+ }
188216
+ /**
188217
+ * Private constructor.
188218
+ * * If `knots` is a number array or Float64Array, then its values are copied to the instance array.
188219
+ * * If `knots` is a number, the instance array is allocated to this size but left as zeros.
188108
188220
  */
188109
188221
  constructor(knots, degree, wrapMode) {
188110
188222
  this.degree = degree;
188111
188223
  this._wrapMode = wrapMode;
188112
- // default values to satisfy compiler -- real values happen in setupFixedValues, or final else defers to user
188224
+ // default values to satisfy compiler; real values happen in setupFixedValues or the final else clause defers to user
188113
188225
  this._knot0 = 0.0;
188114
188226
  this._knot1 = 1.0;
188115
- // satisfy the initialize checker ..
188116
- if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.
188227
+ if (Array.isArray(knots)) {
188117
188228
  this.knots = new Float64Array(knots.length);
188118
188229
  this.setKnots(knots);
188119
188230
  this.setupFixedValues();
@@ -188122,23 +188233,32 @@ class KnotVector {
188122
188233
  this.knots = knots.slice();
188123
188234
  this.setupFixedValues();
188124
188235
  }
188125
- else { // caller is responsible for filling array separately ...
188126
- this.knots = new Float64Array(knots);
188236
+ else { // caller is responsible for filling array separately
188237
+ const knotSize = knots;
188238
+ this.knots = new Float64Array(knotSize);
188127
188239
  }
188128
188240
  }
188129
- /** copy degree and knots to a new KnotVector. */
188130
- clone() { return new KnotVector(this.knots, this.degree, this.wrappable); }
188241
+ /** Copy degree and knots to a new KnotVector. */
188242
+ clone() {
188243
+ return new KnotVector(this.knots, this.degree, this.wrappable);
188244
+ }
188131
188245
  setupFixedValues() {
188132
188246
  if (this.degree > 0 && this.knots.length > this.degree) {
188133
188247
  this._knot0 = this.knots[this.degree - 1];
188134
188248
  this._knot1 = this.knots[this.knots.length - this.degree];
188135
188249
  }
188136
188250
  }
188137
- /** Return the total knot distance from beginning to end. */
188138
- get knotLength01() { return this._knot1 - this._knot0; }
188139
188251
  /**
188140
- * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified wrap mode.
188141
- * @param mode optional test mode. If undefined, use this.wrappable.
188252
+ * Return the length of the active knot interval.
188253
+ * * This is the size of (one dimension of) the parametric domain for the associated B-spline object.
188254
+ */
188255
+ get knotLength01() {
188256
+ return this._knot1 - this._knot0;
188257
+ }
188258
+ /**
188259
+ * Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified
188260
+ * wrap mode.
188261
+ * @param mode optional test mode. If undefined, use this.wrappable.
188142
188262
  */
188143
188263
  testClosable(mode) {
188144
188264
  if (mode === undefined)
@@ -188172,11 +188292,11 @@ class KnotVector {
188172
188292
  }
188173
188293
  return false;
188174
188294
  }
188175
- /** Test matching degree and knot values */
188295
+ /** Test matching degree and knot values. */
188176
188296
  isAlmostEqual(other) {
188177
188297
  if (this.degree !== other.degree)
188178
188298
  return false;
188179
- return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_0__.NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);
188299
+ return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_1__.NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);
188180
188300
  }
188181
188301
  /** Compute the multiplicity of the input knot, or zero if not a knot. */
188182
188302
  getKnotMultiplicity(knot) {
@@ -188212,8 +188332,9 @@ class KnotVector {
188212
188332
  }
188213
188333
  return m;
188214
188334
  }
188215
- /** Transform knots to span [0,1].
188216
- * @returns false if and only if this.knotLength01 is trivial
188335
+ /**
188336
+ * Transform knots such that the active knot range becomes [0,1].
188337
+ * @returns false if and only if `this.knotLength01` is trivial.
188217
188338
  */
188218
188339
  normalize() {
188219
188340
  if (this.knotLength01 < KnotVector.knotTolerance)
@@ -188231,8 +188352,7 @@ class KnotVector {
188231
188352
  this.setupFixedValues();
188232
188353
  return true;
188233
188354
  }
188234
- /** install knot values from an array, optionally ignoring first and last.
188235
- */
188355
+ /** Install knot values from an array, optionally ignoring first and last. */
188236
188356
  setKnots(knots, skipFirstAndLast) {
188237
188357
  const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;
188238
188358
  if (numAllocate !== this.knots.length)
@@ -188247,17 +188367,17 @@ class KnotVector {
188247
188367
  }
188248
188368
  this.setupFixedValues();
188249
188369
  }
188250
- /** Set knots to input array (CAPTURED) */
188370
+ /** Set knots to input array (CAPTURED). */
188251
188371
  setKnotsCapture(knots) {
188252
188372
  this.knots = knots;
188253
188373
  this.setupFixedValues();
188254
188374
  }
188255
188375
  /**
188256
188376
  * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.
188257
- * @param numPoles Number of poles
188258
- * @param degree degree of polynomial
188259
- * @param a0 left knot value for active interval
188260
- * @param a1 right knot value for active interval
188377
+ * @param numPoles number of poles.
188378
+ * @param degree degree of polynomial.
188379
+ * @param a0 left knot value for active interval.
188380
+ * @param a1 right knot value for active interval.
188261
188381
  */
188262
188382
  static createUniformClamped(numPoles, degree, a0, a1) {
188263
188383
  const knots = new KnotVector(numPoles + degree - 1, degree);
@@ -188274,24 +188394,26 @@ class KnotVector {
188274
188394
  }
188275
188395
  /**
188276
188396
  * Create knot vector with wraparound knots at start and end, and uniform knots between.
188277
- * @param numInterval number of intervals in knot space. (NOT POLE COUNT)
188278
- * @param degree degree of polynomial
188279
- * @param a0 left knot value for active interval
188280
- * @param a1 right knot value for active interval
188397
+ * @param numInterval the number of intervals into which to uniformly divide the active knot interval `[a0,a1]`,
188398
+ * creating `numInterval-1` equally spaced interior knots between `a0` and `a1`.
188399
+ * This number is equal to the number of Bezier spans in the associated B-spline object.
188400
+ * It is _not_ the pole count.
188401
+ * @param degree degree of polynomial.
188402
+ * @param a0 left knot value for active interval.
188403
+ * @param a1 right knot value for active interval.
188281
188404
  */
188282
188405
  static createUniformWrapped(numInterval, degree, a0, a1) {
188283
188406
  const knots = new KnotVector(numInterval + 2 * degree - 1, degree);
188284
188407
  const du = 1.0 / numInterval;
188285
- for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {
188286
- knots.knots[k] = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.interpolate(a0, i * du, a1);
188287
- }
188408
+ for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++)
188409
+ knots.knots[k] = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.interpolate(a0, i * du, a1);
188288
188410
  knots.setupFixedValues();
188289
188411
  return knots;
188290
188412
  }
188291
188413
  /**
188292
188414
  * Create knot vector with given knot values and degree.
188293
- * @param knotArray knot values
188294
- * @param degree degree of polynomial
188415
+ * @param knotArray knot values.
188416
+ * @param degree degree of polynomial.
188295
188417
  * @param skipFirstAndLast true to skip copying the first and last knot values.
188296
188418
  */
188297
188419
  static create(knotArray, degree, skipFirstAndLast) {
@@ -188302,29 +188424,34 @@ class KnotVector {
188302
188424
  }
188303
188425
  /**
188304
188426
  * Return the average of degree consecutive knots beginning at knotIndex.
188427
+ * * If `knotIndex` is negative, return `leftKnot`.
188428
+ * * If `knotIndex > rightKnotIndex` return `rightKnot`.
188305
188429
  */
188306
188430
  grevilleKnot(knotIndex) {
188307
188431
  if (knotIndex < 0)
188308
188432
  return this.leftKnot;
188309
188433
  if (knotIndex > this.rightKnotIndex)
188310
188434
  return this.rightKnot;
188435
+ knotIndex = Math.floor(knotIndex);
188311
188436
  let sum = 0.0;
188312
188437
  for (let i = knotIndex; i < knotIndex + this.degree; i++)
188313
188438
  sum += this.knots[i];
188314
188439
  return sum / this.degree;
188315
188440
  }
188316
- /** Return an array sized for a set of the basis function values. */
188317
- createBasisArray() { return new Float64Array(this.degree + 1); }
188441
+ /** Return an array of size `degree + 1`, e.g., to hold the set of relevant basis function values at a parameter. */
188442
+ createBasisArray() {
188443
+ return new Float64Array(this.degree + 1);
188444
+ }
188318
188445
  /** Convert localFraction within the interval following an indexed knot to a knot value. */
188319
188446
  baseKnotFractionToKnot(knotIndex0, localFraction) {
188320
188447
  const knot0 = this.knots[knotIndex0];
188321
- localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.clamp(localFraction, 0, 1);
188448
+ localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(localFraction, 0, 1);
188322
188449
  return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);
188323
188450
  }
188324
188451
  /** Convert localFraction within an indexed bezier span to a knot value. */
188325
188452
  spanFractionToKnot(spanIndex, localFraction) {
188326
188453
  const k = this.spanIndexToLeftKnotIndex(spanIndex);
188327
- localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.clamp(localFraction, 0, 1);
188454
+ localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(localFraction, 0, 1);
188328
188455
  return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);
188329
188456
  }
188330
188457
  /** Convert localFraction within an indexed bezier span to fraction of active knot range. */
@@ -188334,35 +188461,41 @@ class KnotVector {
188334
188461
  }
188335
188462
  /** Return fraction of active knot range to knot value. */
188336
188463
  fractionToKnot(fraction) {
188337
- fraction = _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.clamp(fraction, 0, 1); // B-splines are not extendable
188338
- return _Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);
188464
+ fraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(fraction, 0, 1); // B-splines are not extendable
188465
+ return _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);
188466
+ }
188467
+ isKnotInValidSpan(knotIndex0, u) {
188468
+ const spanIsValid = knotIndex0 >= this.degree - 1 && knotIndex0 + this.degree < this.knots.length;
188469
+ const uIsInSpan = this.knots[knotIndex0] <= u && u <= this.knots[knotIndex0 + 1];
188470
+ return spanIsValid && uIsInSpan;
188339
188471
  }
188340
188472
  /**
188341
188473
  * Evaluate the B-spline basis functions f[] at a parameter u in a knot span.
188342
188474
  * * This method implements the Mansfield-Cox-de Boor recurrence relation.
188343
188475
  * @param knotIndex0 index of the left knot of the span.
188344
188476
  * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
188345
- * @param f preallocated output array of order basis function values
188346
- * @returns true if and only if output array is sufficiently sized
188477
+ * @param f preallocated output array of order basis function values.
188478
+ * @returns true if and only if output array is sufficiently sized.
188347
188479
  */
188348
188480
  evaluateBasisFunctions(knotIndex0, u, f) {
188349
188481
  if (f.length < this.degree + 1)
188350
188482
  return false;
188483
+ (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
188351
188484
  f[0] = 1.0;
188352
188485
  if (this.degree < 1)
188353
188486
  return true;
188354
- // direct compute for linear part ...
188487
+ // direct compute for linear part
188355
188488
  const u0 = this.knots[knotIndex0];
188356
188489
  const u1 = this.knots[knotIndex0 + 1];
188357
188490
  f[1] = (u - u0) / (u1 - u0);
188358
188491
  f[0] = 1.0 - f[1];
188359
188492
  if (this.degree < 2)
188360
188493
  return true;
188361
- // Each iteration of the outer loop evaluates the basis functions of degree depth+1 using
188362
- // one or two values of the basis functions of one less degree from the preceding iteration.
188494
+ // each iteration of the outer loop evaluates the basis functions of degree depth+1 using
188495
+ // one or two values of the basis functions of one less degree from the preceding iteration
188363
188496
  for (let depth = 1; depth < this.degree; depth++) {
188364
188497
  let kLeft = knotIndex0 - depth;
188365
- let kRight = kLeft + depth + 1;
188498
+ let kRight = knotIndex0 + 1;
188366
188499
  let gCarry = 0.0;
188367
188500
  for (let step = 0; step <= depth; step++) {
188368
188501
  const tLeft = this.knots[kLeft++];
@@ -188384,10 +188517,10 @@ class KnotVector {
188384
188517
  * in a knot span.
188385
188518
  * @param knotIndex0 index of the left knot of the span.
188386
188519
  * @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
188387
- * @param f preallocated output array of order basis function values
188388
- * @param df preallocated output array of order basis derivative values
188389
- * @param ddf optional preallocated output array of order basis second derivative values
188390
- * @returns true if and only if output arrays are sufficiently sized
188520
+ * @param f preallocated output array of order basis function values.
188521
+ * @param df preallocated output array of order basis derivative values.
188522
+ * @param ddf optional preallocated output array of order basis second derivative values.
188523
+ * @returns true if and only if output arrays are sufficiently sized.
188391
188524
  */
188392
188525
  evaluateBasisFunctions1(knotIndex0, u, f, df, ddf) {
188393
188526
  if (f.length < this.degree + 1)
@@ -188396,15 +188529,16 @@ class KnotVector {
188396
188529
  return false;
188397
188530
  if (ddf && ddf.length < this.degree + 1)
188398
188531
  return false;
188532
+ (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
188399
188533
  f[0] = 1.0;
188400
188534
  df[0] = 0.0;
188401
188535
  if (this.degree < 1)
188402
188536
  return true;
188403
- // direct compute for linear part ...
188537
+ // direct compute for linear part
188404
188538
  const u0 = this.knots[knotIndex0];
188405
188539
  const u1 = this.knots[knotIndex0 + 1];
188406
- // ah = 1/(u1-u0) is the derivative of fraction0
188407
- // (-ah) is the derivative of fraction1.
188540
+ // ah = 1/(u1-u0) is the derivative of fraction0
188541
+ // -ah is the derivative of fraction1
188408
188542
  let ah = 1.0 / (u1 - u0);
188409
188543
  f[1] = (u - u0) * ah;
188410
188544
  f[0] = 1.0 - f[1];
@@ -188423,7 +188557,7 @@ class KnotVector {
188423
188557
  let dgCarry = 0.0;
188424
188558
  let ddgCarry = 0.0;
188425
188559
  // f, df, ddf, are each row vectors with product of `step` linear terms.
188426
- // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)
188560
+ // f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1) (0,0,1-fraction, fraction,0,0,0)
188427
188561
  // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)
188428
188562
  // Hence fnew = f * V
188429
188563
  // dfnew = df * V + f * dV
@@ -188445,7 +188579,7 @@ class KnotVector {
188445
188579
  df[step] = dgCarry + dg0;
188446
188580
  gCarry = g1;
188447
188581
  dgCarry = dg1;
188448
- if (ddf) { // do the backward reference to df before rewriting df !!!
188582
+ if (ddf) { // do the backward reference to df before rewriting df
188449
188583
  const ddg1 = ddf[step] * fraction + dfSave;
188450
188584
  const ddg0 = ddf[step] * fraction1 - dfSave;
188451
188585
  ddf[step] = ddgCarry + ddg0;
@@ -188459,9 +188593,10 @@ class KnotVector {
188459
188593
  }
188460
188594
  return true;
188461
188595
  }
188462
- /** Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
188596
+ /**
188597
+ * Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
188463
188598
  * * If u has no such bracket, return the smaller index of the closest nontrivial bracket.
188464
- * @param u value to bracket
188599
+ * @param u value to bracket.
188465
188600
  */
188466
188601
  knotToLeftKnotIndex(u) {
188467
188602
  for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {
@@ -188477,7 +188612,7 @@ class KnotVector {
188477
188612
  }
188478
188613
  /**
188479
188614
  * Given a span index, return the index of the knot at its left.
188480
- * @param spanIndex index of span
188615
+ * @param spanIndex index of span.
188481
188616
  */
188482
188617
  spanIndexToLeftKnotIndex(spanIndex) {
188483
188618
  const d = this.degree;
@@ -188492,15 +188627,16 @@ class KnotVector {
188492
188627
  }
188493
188628
  /**
188494
188629
  * Given a span index, test if it is within range and has nonzero length.
188495
- * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans
188630
+ * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span)
188631
+ * followed by more real spans
188496
188632
  * @param spanIndex index of span to test.
188497
188633
  */
188498
188634
  isIndexOfRealSpan(spanIndex) {
188499
188635
  if (spanIndex >= 0 && spanIndex < this.numSpans)
188500
- return !_Geometry__WEBPACK_IMPORTED_MODULE_1__.Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));
188636
+ return !_Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));
188501
188637
  return false;
188502
188638
  }
188503
- /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */
188639
+ /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths are reversed. */
188504
188640
  reflectKnots() {
188505
188641
  const a = this.leftKnot;
188506
188642
  const b = this.rightKnot;
@@ -195831,6 +195967,8 @@ class Arc3d extends _CurvePrimitive__WEBPACK_IMPORTED_MODULE_1__.CurvePrimitive
195831
195967
  }
195832
195968
  /**
195833
195969
  * Construct a circular arc chain approximation to the instance elliptical arc.
195970
+ * * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ArcApproximationGeneral and
195971
+ * https://www.itwinjs.org/sandbox/SaeedTorabi/ArcApproximation
195834
195972
  * @param options bundle of options for sampling an elliptical arc (use default options if undefined).
195835
195973
  * @returns the approximating curve chain, the circular instance, or undefined if construction fails.
195836
195974
  */
@@ -229802,9 +229940,9 @@ class Point3dArray {
229802
229940
  return result;
229803
229941
  }
229804
229942
  /**
229805
- * return an 2-dimensional array containing all the values of `data` in arrays of numPerBlock
229806
- * @param data simple array of numbers
229807
- * @param numPerBlock number of values in each block at first level down
229943
+ * Return a 2-dimensional array containing all the values of `data` in arrays of numPerBlock
229944
+ * @param data simple array of numbers.
229945
+ * @param numPerBlock number of values in each block at first level down.
229808
229946
  */
229809
229947
  static unpackNumbersToNestedArrays(data, numPerBlock) {
229810
229948
  const result = [];
@@ -235074,8 +235212,8 @@ class Ray3d {
235074
235212
  * @param vertex2 third vertex of the triangle
235075
235213
  * @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line
235076
235214
  * intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)
235077
- * @param parameterTol optional tolerance used to snap barycentric coordinates of the intersection point to
235078
- * a triangle edge or vertex (if tolerance is not provided, Geometry.smallFloatingPoint is used)
235215
+ * @param parameterTol optional tolerance used to allow intersections just beyond an edge/vertex in barycentric
235216
+ * coordinate space (if tolerance is not provided, Geometry.smallFloatingPoint is used)
235079
235217
  * @param result optional pre-allocated object to fill and return
235080
235218
  * @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.
235081
235219
  */
@@ -235131,13 +235269,13 @@ class Ray3d {
235131
235269
  const s = Ray3d._workVector3 = _Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);
235132
235270
  let u = f * s.dotProduct(h);
235133
235271
  if (u < 0.0) {
235134
- if (u > -parameterTol)
235272
+ if (u >= -parameterTol)
235135
235273
  u = 0.0;
235136
235274
  else
235137
235275
  return undefined; // ray does not intersect the triangle
235138
235276
  }
235139
235277
  else if (u > 1.0) {
235140
- if (u < 1.0 + parameterTol)
235278
+ if (u <= 1.0 + parameterTol)
235141
235279
  u = 1.0;
235142
235280
  else
235143
235281
  return undefined; // ray does not intersect the triangle
@@ -235145,20 +235283,17 @@ class Ray3d {
235145
235283
  const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);
235146
235284
  let v = f * this.direction.dotProduct(q);
235147
235285
  if (v < 0.0) {
235148
- if (v > -parameterTol)
235286
+ if (v >= -parameterTol)
235149
235287
  v = 0.0;
235150
235288
  else
235151
235289
  return undefined; // ray does not intersect the triangle
235152
235290
  }
235153
- else if (u + v > 1.0) {
235154
- if (u + v < 1.0 + parameterTol)
235155
- v = 1.0 - u;
235156
- else
235157
- return undefined; // ray does not intersect the triangle
235291
+ else if (u + v > 1.0 + parameterTol) {
235292
+ return undefined; // ray does not intersect the triangle
235158
235293
  }
235159
235294
  // at this stage, we know the line (parameterized as the ray) intersects the triangle
235160
235295
  const t = f * edge2.dotProduct(q);
235161
- if (t <= distanceTol) // line intersection but not ray intersection
235296
+ if (t < -distanceTol) // line intersection but not ray intersection
235162
235297
  return undefined;
235163
235298
  return this.origin.plusScaled(this.direction, t, result); // ray intersection
235164
235299
  }
@@ -312363,7 +312498,7 @@ var loadLanguages = instance.loadLanguages;
312363
312498
  /***/ ((module) => {
312364
312499
 
312365
312500
  "use strict";
312366
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.0.0-dev.62","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run --coverage","test:debug":"vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/eslint-plugin":"5.0.0-dev.1","@types/chai-as-promised":"^7","@vitest/browser":"^2.1.0","@vitest/coverage-v8":"^2.1.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","cpx2":"^3.0.0","eslint":"^9.13.0","glob":"^10.3.12","playwright":"~1.47.1","rimraf":"^3.0.2","source-map-loader":"^4.0.0","typescript":"~5.6.2","typemoq":"^2.1.0","vitest":"^2.1.0","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"1.0.6","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/cloud-agnostic-core":"^2.2.4","@itwin/object-storage-core":"^2.2.5","@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
312501
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.0.0-dev.64","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run --coverage","test:debug":"vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/eslint-plugin":"5.0.0-dev.1","@types/chai-as-promised":"^7","@vitest/browser":"^2.1.0","@vitest/coverage-v8":"^2.1.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","cpx2":"^3.0.0","eslint":"^9.13.0","glob":"^10.3.12","playwright":"~1.47.1","rimraf":"^3.0.2","source-map-loader":"^4.0.0","typescript":"~5.6.2","typemoq":"^2.1.0","vitest":"^2.1.0","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"1.0.6","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/cloud-agnostic-core":"^2.2.4","@itwin/object-storage-core":"^2.2.5","@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
312367
312502
 
312368
312503
  /***/ })
312369
312504