@itwin/rpcinterface-full-stack-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.
- package/lib/dist/bundled-tests.js +539 -404
- package/lib/dist/bundled-tests.js.map +1 -1
- package/package.json +13 -13
|
@@ -84600,21 +84600,12 @@ class Schema {
|
|
|
84600
84600
|
? refSchema.getItemSync(itemName, itemConstructor)
|
|
84601
84601
|
: refSchema.getItemSync(itemName);
|
|
84602
84602
|
}
|
|
84603
|
-
|
|
84604
|
-
* Returns an iterator over all of the items in this schema.
|
|
84605
|
-
*/
|
|
84606
|
-
getItems() {
|
|
84603
|
+
*getItems(itemConstructor) {
|
|
84607
84604
|
if (!this._items)
|
|
84608
|
-
return
|
|
84609
|
-
|
|
84610
|
-
|
|
84611
|
-
|
|
84612
|
-
* Returns an iterator over all ECClasses within this schema
|
|
84613
|
-
*/
|
|
84614
|
-
*getClasses() {
|
|
84615
|
-
for (const [, value] of this._items) {
|
|
84616
|
-
if (_Class__WEBPACK_IMPORTED_MODULE_8__.ECClass.isECClass(value))
|
|
84617
|
-
yield value;
|
|
84605
|
+
return;
|
|
84606
|
+
for (const item of this._items.values()) {
|
|
84607
|
+
if (itemConstructor === undefined || (0,_ECObjects__WEBPACK_IMPORTED_MODULE_4__.isSupportedSchemaItemType)(item.schemaItemType, itemConstructor.schemaItemType))
|
|
84608
|
+
yield item;
|
|
84618
84609
|
}
|
|
84619
84610
|
}
|
|
84620
84611
|
/**
|
|
@@ -196463,82 +196454,115 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
196463
196454
|
/** @packageDocumentation
|
|
196464
196455
|
* @module Bspline
|
|
196465
196456
|
*/
|
|
196466
|
-
// import { Point2d } from "../Geometry2d";
|
|
196467
196457
|
|
|
196468
196458
|
|
|
196469
196459
|
|
|
196470
|
-
/**
|
|
196460
|
+
/**
|
|
196461
|
+
* Knots and poles for a B-spline function mapping R to R^n.
|
|
196471
196462
|
* * The "pole" (aka control point) of this class is a block of `poleLength` numbers.
|
|
196472
196463
|
* * Derived classes (not this class) assign meaning such as x,y,z,w.
|
|
196473
|
-
* *
|
|
196464
|
+
* * For instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or
|
|
196465
|
+
* weighted 2D x,y,w.
|
|
196474
196466
|
* @public
|
|
196475
196467
|
*/
|
|
196476
196468
|
class BSpline1dNd {
|
|
196477
|
-
/**
|
|
196469
|
+
/** Knots of the bspline. */
|
|
196478
196470
|
knots;
|
|
196479
|
-
/**
|
|
196471
|
+
/** Poles packed in blocks of `poleLength` doubles. */
|
|
196480
196472
|
packedData;
|
|
196481
|
-
/**
|
|
196473
|
+
/** The number of numeric values per pole. */
|
|
196482
196474
|
poleLength;
|
|
196483
196475
|
/** (property accessor) Return the degree of the polynomials. */
|
|
196484
|
-
get degree() {
|
|
196485
|
-
|
|
196486
|
-
|
|
196487
|
-
/** (property accessor) Return the
|
|
196488
|
-
get
|
|
196489
|
-
|
|
196490
|
-
|
|
196491
|
-
/**
|
|
196476
|
+
get degree() {
|
|
196477
|
+
return this.knots.degree;
|
|
196478
|
+
}
|
|
196479
|
+
/** (property accessor) Return the order (one more than degree) of the polynomials. */
|
|
196480
|
+
get order() {
|
|
196481
|
+
return this.knots.degree + 1;
|
|
196482
|
+
}
|
|
196483
|
+
/** (property accessor) Return the number of bezier spans (including null spans at multiple knots). */
|
|
196484
|
+
get numSpan() {
|
|
196485
|
+
return this.numPoles - this.knots.degree;
|
|
196486
|
+
}
|
|
196487
|
+
/** (property accessor) Return the number of poles. */
|
|
196488
|
+
get numPoles() {
|
|
196489
|
+
return this.packedData.length / this.poleLength;
|
|
196490
|
+
}
|
|
196491
|
+
/**
|
|
196492
|
+
* Copy 3 values of pole `i` into a point.
|
|
196492
196493
|
* * The calling class is responsible for knowing if this is an appropriate access to the blocked data.
|
|
196493
196494
|
*/
|
|
196494
|
-
getPoint3dPole(i, result) {
|
|
196495
|
-
|
|
196496
|
-
|
|
196497
|
-
/** preallocated array (length === `poleLength`) used as temporary in evaluations */
|
|
196498
|
-
poleBuffer; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
|
|
196499
|
-
/** preallocated array (length === `order`) used as temporary in evaluations */
|
|
196500
|
-
basisBuffer1; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
|
|
196501
|
-
/** preallocated array (length === `order`) used as temporary in evaluations */
|
|
196502
|
-
basisBuffer2; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE
|
|
196503
|
-
/** preallocated array (length === `poleLength`) used as temporary in evaluations */
|
|
196504
|
-
poleBuffer1; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
|
|
196505
|
-
/** preallocated array (length === `poleLength`) used as temporary in evaluations */
|
|
196506
|
-
poleBuffer2; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE
|
|
196495
|
+
getPoint3dPole(i, result) {
|
|
196496
|
+
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Point3d.createFromPacked(this.packedData, i, result);
|
|
196497
|
+
}
|
|
196507
196498
|
/**
|
|
196508
|
-
*
|
|
196509
|
-
*
|
|
196510
|
-
|
|
196511
|
-
|
|
196512
|
-
|
|
196499
|
+
* Values of the `order` relevant B-spline basis functions at a parameter.
|
|
196500
|
+
* * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
|
|
196501
|
+
*/
|
|
196502
|
+
basisBuffer;
|
|
196503
|
+
/**
|
|
196504
|
+
* Derivatives of the `order` relevant B-spline basis functions at a parameter.
|
|
196505
|
+
* * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
|
|
196506
|
+
*/
|
|
196507
|
+
basisBuffer1;
|
|
196508
|
+
/**
|
|
196509
|
+
* Second derivatives of the `order` relevant B-spline basis functions at a parameter.
|
|
196510
|
+
* * Preallocated to length `order` in the constructor and used as a temporary in evaluations.
|
|
196511
|
+
*/
|
|
196512
|
+
basisBuffer2;
|
|
196513
|
+
/**
|
|
196514
|
+
* Temporary to hold a single point.
|
|
196515
|
+
* * Preallocated to length `poleLength` in the constructor.
|
|
196516
|
+
*/
|
|
196517
|
+
poleBuffer;
|
|
196518
|
+
/**
|
|
196519
|
+
* Temporary to hold a single derivative vector.
|
|
196520
|
+
* * Preallocated to length `poleLength` in the constructor.
|
|
196521
|
+
*/
|
|
196522
|
+
poleBuffer1;
|
|
196523
|
+
/**
|
|
196524
|
+
* Temporary to hold a single second derivative vector.
|
|
196525
|
+
* * Preallocated to length `poleLength` in the constructor.
|
|
196526
|
+
*/
|
|
196527
|
+
poleBuffer2;
|
|
196528
|
+
/**
|
|
196529
|
+
* Initialize arrays for given spline dimensions.
|
|
196530
|
+
* @param numPoles number of poles.
|
|
196531
|
+
* @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
|
|
196532
|
+
* 3 for 2d weighted).
|
|
196533
|
+
* @param order number of poles defining a Bezier segment of the B-spline function.
|
|
196534
|
+
* @param knots the KnotVector. This is captured, not cloned.
|
|
196513
196535
|
*/
|
|
196514
196536
|
constructor(numPoles, poleLength, order, knots) {
|
|
196515
196537
|
this.knots = knots;
|
|
196516
196538
|
this.packedData = new Float64Array(numPoles * poleLength);
|
|
196517
196539
|
this.poleLength = poleLength;
|
|
196518
196540
|
this.basisBuffer = new Float64Array(order);
|
|
196519
|
-
this.poleBuffer = new Float64Array(poleLength);
|
|
196520
196541
|
this.basisBuffer1 = new Float64Array(order);
|
|
196521
196542
|
this.basisBuffer2 = new Float64Array(order);
|
|
196543
|
+
this.poleBuffer = new Float64Array(poleLength);
|
|
196522
196544
|
this.poleBuffer1 = new Float64Array(poleLength);
|
|
196523
196545
|
this.poleBuffer2 = new Float64Array(poleLength);
|
|
196524
196546
|
}
|
|
196525
196547
|
/**
|
|
196526
|
-
*
|
|
196527
|
-
* @param numPoles number of poles
|
|
196528
|
-
* @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
|
|
196529
|
-
*
|
|
196530
|
-
* @param
|
|
196548
|
+
* Create a `BSpline1dNd`.
|
|
196549
|
+
* @param numPoles number of poles.
|
|
196550
|
+
* @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted,
|
|
196551
|
+
* 3 for 2d weighted).
|
|
196552
|
+
* @param order number of poles defining a Bezier segment of the B-spline function.
|
|
196553
|
+
* @param knots the KnotVector. This is captured, not cloned.
|
|
196531
196554
|
*/
|
|
196532
196555
|
static create(numPoles, poleLength, order, knots) {
|
|
196533
196556
|
return new BSpline1dNd(numPoles, poleLength, order, knots);
|
|
196534
196557
|
}
|
|
196535
|
-
/** Map a span index and
|
|
196536
|
-
spanFractionToKnot(
|
|
196537
|
-
return this.knots.spanFractionToKnot(
|
|
196558
|
+
/** Map a span index and span fraction to knot value. */
|
|
196559
|
+
spanFractionToKnot(spanIndex, spanFraction) {
|
|
196560
|
+
return this.knots.spanFractionToKnot(spanIndex, spanFraction);
|
|
196538
196561
|
}
|
|
196539
196562
|
/**
|
|
196540
|
-
* Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within
|
|
196541
|
-
*
|
|
196563
|
+
* Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within
|
|
196564
|
+
* indexed span.
|
|
196565
|
+
* @returns true if and only if output arrays are sufficiently sized.
|
|
196542
196566
|
*/
|
|
196543
196567
|
evaluateBasisFunctionsInSpan(spanIndex, spanFraction, f, df, ddf) {
|
|
196544
196568
|
if (spanIndex < 0)
|
|
@@ -196552,57 +196576,64 @@ class BSpline1dNd {
|
|
|
196552
196576
|
this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);
|
|
196553
196577
|
}
|
|
196554
196578
|
/**
|
|
196555
|
-
*
|
|
196556
|
-
*
|
|
196557
|
-
|
|
196558
|
-
* * Summations are stored in the preallocated `this.poleBuffer`
|
|
196559
|
-
* */
|
|
196560
|
-
evaluateBuffersInSpan(spanIndex, spanFraction) {
|
|
196561
|
-
this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
|
|
196562
|
-
this.sumPoleBufferForSpan(spanIndex);
|
|
196563
|
-
}
|
|
196564
|
-
/**
|
|
196565
|
-
* * Evaluate the basis functions and one derivative at spanIndex and fraction.
|
|
196566
|
-
* * Evaluations are stored in the preallocated `this.basisBuffer`
|
|
196567
|
-
* * Immediately do the summations of the basis values times the respective control points
|
|
196568
|
-
* * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
|
|
196569
|
-
* */
|
|
196570
|
-
evaluateBuffersInSpan1(spanIndex, spanFraction) {
|
|
196571
|
-
this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
|
|
196572
|
-
this.sumPoleBufferForSpan(spanIndex);
|
|
196573
|
-
this.sumPoleBuffer1ForSpan(spanIndex);
|
|
196574
|
-
}
|
|
196575
|
-
/** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */
|
|
196579
|
+
* Compute the linear combination of the given span's poles and the weights in `basisBuffer`, and store this point
|
|
196580
|
+
* in `poleBuffer`.
|
|
196581
|
+
*/
|
|
196576
196582
|
sumPoleBufferForSpan(spanIndex) {
|
|
196577
196583
|
this.poleBuffer.fill(0);
|
|
196578
196584
|
let k = spanIndex * this.poleLength;
|
|
196579
|
-
for (const f of this.basisBuffer)
|
|
196580
|
-
for (let j = 0; j < this.poleLength; j++)
|
|
196585
|
+
for (const f of this.basisBuffer)
|
|
196586
|
+
for (let j = 0; j < this.poleLength; j++)
|
|
196581
196587
|
this.poleBuffer[j] += f * this.packedData[k++];
|
|
196582
|
-
}
|
|
196583
|
-
}
|
|
196584
196588
|
}
|
|
196585
|
-
/**
|
|
196589
|
+
/**
|
|
196590
|
+
* Compute the linear combination of the given span's poles and the weights in `basisBuffer1`, and store this
|
|
196591
|
+
* derivative vector in `poleBuffer1`.
|
|
196592
|
+
*/
|
|
196586
196593
|
sumPoleBuffer1ForSpan(spanIndex) {
|
|
196587
196594
|
this.poleBuffer1.fill(0);
|
|
196588
196595
|
let k = spanIndex * this.poleLength;
|
|
196589
|
-
for (const f of this.basisBuffer1)
|
|
196590
|
-
for (let j = 0; j < this.poleLength; j++)
|
|
196596
|
+
for (const f of this.basisBuffer1)
|
|
196597
|
+
for (let j = 0; j < this.poleLength; j++)
|
|
196591
196598
|
this.poleBuffer1[j] += f * this.packedData[k++];
|
|
196592
|
-
}
|
|
196593
|
-
}
|
|
196594
196599
|
}
|
|
196595
|
-
/**
|
|
196600
|
+
/**
|
|
196601
|
+
* Compute the linear combination of the given span's poles and the weights in `basisBuffer2`, and store this
|
|
196602
|
+
* second derivative vector in `poleBuffer2`.
|
|
196603
|
+
*/
|
|
196596
196604
|
sumPoleBuffer2ForSpan(spanIndex) {
|
|
196597
196605
|
this.poleBuffer2.fill(0);
|
|
196598
196606
|
let k = spanIndex * this.poleLength;
|
|
196599
196607
|
for (const f of this.basisBuffer2) {
|
|
196600
|
-
for (let j = 0; j < this.poleLength; j++)
|
|
196608
|
+
for (let j = 0; j < this.poleLength; j++)
|
|
196601
196609
|
this.poleBuffer2[j] += f * this.packedData[k++];
|
|
196602
|
-
}
|
|
196603
196610
|
}
|
|
196604
196611
|
}
|
|
196605
|
-
/**
|
|
196612
|
+
/**
|
|
196613
|
+
* * Evaluate the basis functions at spanIndex and fraction.
|
|
196614
|
+
* * Evaluations are stored in the preallocated `this.basisBuffer`.
|
|
196615
|
+
* * Immediately do the summations of the basis values times the respective poles.
|
|
196616
|
+
* * Summations are stored in the preallocated `this.poleBuffer`
|
|
196617
|
+
* */
|
|
196618
|
+
evaluateBuffersInSpan(spanIndex, spanFraction) {
|
|
196619
|
+
this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);
|
|
196620
|
+
this.sumPoleBufferForSpan(spanIndex);
|
|
196621
|
+
}
|
|
196622
|
+
/**
|
|
196623
|
+
* * Evaluate the basis functions and one derivative at spanIndex and fraction.
|
|
196624
|
+
* * Function evaluations are stored in the preallocated `this.basisBuffer`; derivative evaluations in `this.basisBuffer1`.
|
|
196625
|
+
* * Immediately do the summations of the basis values times the respective poles.
|
|
196626
|
+
* * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`
|
|
196627
|
+
* */
|
|
196628
|
+
evaluateBuffersInSpan1(spanIndex, spanFraction) {
|
|
196629
|
+
this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);
|
|
196630
|
+
this.sumPoleBufferForSpan(spanIndex);
|
|
196631
|
+
this.sumPoleBuffer1ForSpan(spanIndex);
|
|
196632
|
+
}
|
|
196633
|
+
/**
|
|
196634
|
+
* Evaluate the B-spline function and optional derivatives at the given parameter in knot space.
|
|
196635
|
+
* * Function value is stored in `poleBuffer`; optional derivative vectors in `poleBuffer1` and `poleBuffer2`.
|
|
196636
|
+
*/
|
|
196606
196637
|
evaluateBuffersAtKnot(u, numDerivative = 0) {
|
|
196607
196638
|
const knotIndex0 = this.knots.knotToLeftKnotIndex(u);
|
|
196608
196639
|
if (numDerivative < 1) {
|
|
@@ -196621,36 +196652,30 @@ class BSpline1dNd {
|
|
|
196621
196652
|
this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);
|
|
196622
196653
|
}
|
|
196623
196654
|
}
|
|
196624
|
-
/**
|
|
196625
|
-
* Reverse the (blocked) poles (in `this.packedData` in place.
|
|
196626
|
-
*/
|
|
196655
|
+
/** Reverse the instance poles and knots in place. */
|
|
196627
196656
|
reverseInPlace() {
|
|
196628
|
-
|
|
196629
|
-
const b = this.poleLength;
|
|
196657
|
+
const pLen = this.poleLength;
|
|
196630
196658
|
const data = this.packedData;
|
|
196631
|
-
for (let i0 = 0, j0 =
|
|
196632
|
-
let
|
|
196633
|
-
|
|
196634
|
-
t = data[i0 + i];
|
|
196635
|
-
data[i0 + i] = data[j0 + i];
|
|
196636
|
-
data[j0 + i] = t;
|
|
196637
|
-
}
|
|
196659
|
+
for (let i0 = 0, j0 = pLen * (this.numPoles - 1); i0 < j0; i0 += pLen, j0 -= pLen) {
|
|
196660
|
+
for (let i = 0; i < pLen; i++)
|
|
196661
|
+
[data[i0 + i], data[j0 + i]] = [data[j0 + i], data[i0 + i]];
|
|
196638
196662
|
}
|
|
196639
196663
|
this.knots.reflectKnots();
|
|
196640
196664
|
}
|
|
196641
196665
|
/**
|
|
196642
|
-
* Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
|
|
196643
|
-
* to act as a normal bspline.
|
|
196644
|
-
* @returns true if `degree` leading and trailing polygon blocks match
|
|
196645
|
-
* @deprecated in 4.x. Use testClosablePolygon instead.
|
|
196666
|
+
* Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
|
|
196667
|
+
* which has been expanded to act as a normal bspline.
|
|
196668
|
+
* @returns true if `degree` leading and trailing polygon blocks match.
|
|
196669
|
+
* @deprecated in 4.x. Use `testClosablePolygon` instead.
|
|
196646
196670
|
*/
|
|
196647
196671
|
testCloseablePolygon(mode) {
|
|
196648
196672
|
return this.testClosablePolygon(mode);
|
|
196649
196673
|
}
|
|
196650
196674
|
/**
|
|
196651
|
-
* Test if the leading and trailing
|
|
196652
|
-
*
|
|
196653
|
-
* @
|
|
196675
|
+
* Test if the leading and trailing poles are replicated in the manner of a "closed" B-spline function with wraparound
|
|
196676
|
+
* control polygon.
|
|
196677
|
+
* @param mode wrap mode, indicating the number of wraparound poles to check. If undefined, `knots.wrappable` is used.
|
|
196678
|
+
* @returns true if the expected leading and trailing poles match, according to `mode`.
|
|
196654
196679
|
*/
|
|
196655
196680
|
testClosablePolygon(mode) {
|
|
196656
196681
|
if (mode === undefined)
|
|
@@ -196672,9 +196697,10 @@ class BSpline1dNd {
|
|
|
196672
196697
|
}
|
|
196673
196698
|
return true;
|
|
196674
196699
|
}
|
|
196675
|
-
/**
|
|
196676
|
-
*
|
|
196677
|
-
* @param
|
|
196700
|
+
/**
|
|
196701
|
+
* Insert the knot and resulting pole into the instance, optionally multiple times.
|
|
196702
|
+
* @param knot the knot to be inserted (may already exist in the KnotVector).
|
|
196703
|
+
* @param totalMultiplicity the total multiplicity of the knot on return.
|
|
196678
196704
|
*/
|
|
196679
196705
|
addKnot(knot, totalMultiplicity) {
|
|
196680
196706
|
if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)
|
|
@@ -196798,83 +196824,117 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
196798
196824
|
|
|
196799
196825
|
/**
|
|
196800
196826
|
* Base class for BSplineCurve3d and BSplineCurve3dH.
|
|
196801
|
-
* * A
|
|
196802
|
-
* * The
|
|
196803
|
-
*
|
|
196804
|
-
*
|
|
196827
|
+
* * A B-spline curve consists of an array of `knots`, an array of `poles`, and a `degree`.
|
|
196828
|
+
* * The knot array is a non-decreasing sequence of numbers. It is also called a "knot vector".
|
|
196829
|
+
* * The curve is a parametric function whose domain is a sub-range of its knots.
|
|
196830
|
+
* * The API sometimes refers to a domain parameter `u` as a "knot", even if `u` is not actually an entry in the
|
|
196831
|
+
* knot array.
|
|
196832
|
+
* * The curve loosely "follows" the line string formed by the poles, aka the "control polygon".
|
|
196833
|
+
* * The curve is a chain of polynomial segments, aka "spans" or "fragments". B-spline theory identifies these as
|
|
196834
|
+
* Bezier curves.
|
|
196805
196835
|
* * The polynomial spans all have same `degree`.
|
|
196806
|
-
* *
|
|
196807
|
-
* *
|
|
196808
|
-
* * The number of spans is `numSpan = numPoles - degree
|
|
196809
|
-
* * For a
|
|
196810
|
-
* * The `order` poles begin at index `spanIndex`.
|
|
196811
|
-
* * The `2*
|
|
196812
|
-
* * The
|
|
196813
|
-
* * The
|
|
196836
|
+
* * Each span is controlled by `order = degree + 1` contiguous points in the pole array.
|
|
196837
|
+
* * There is a strict relationship between knot and poles counts: `numPoles + order = numKnots + 2'.
|
|
196838
|
+
* * The number of spans is `numSpan = numPoles - degree`.
|
|
196839
|
+
* * For a span with index `spanIndex`:
|
|
196840
|
+
* * The `order` relevant poles begin at pole index `spanIndex`.
|
|
196841
|
+
* * The `2*degree` relevant knots begin at knot index `spanIndex`.
|
|
196842
|
+
* * The span domain is the knot range `[knot[spanIndex+degree-1], knot[spanIndex+degree]]`.
|
|
196843
|
+
* * The curve domain is the knot range `[knot[degree-1], knot[numSpan+degree-1]]`, or equivalently
|
|
196844
|
+
* `[knot[degree-1], knot[numPoles-1]]`. The API refers to this domain as the "active knot interval" of the curve.
|
|
196814
196845
|
*
|
|
196815
|
-
* Nearly all
|
|
196816
|
-
* *
|
|
196817
|
-
*
|
|
196818
|
-
* *
|
|
196819
|
-
*
|
|
196820
|
-
*
|
|
196846
|
+
* Nearly all B-spline curves are "clamped".
|
|
196847
|
+
* * This means that in the `knots` array, the first `degree` knots are equal, and the last `degree` knots are equal.
|
|
196848
|
+
* We say the smallest knot and the largest knot have multiplicity `degree`.
|
|
196849
|
+
* * Clamping make the curve pass through its first and last poles, with tangents directed along the first and
|
|
196850
|
+
* last edges of the control polygon.
|
|
196851
|
+
* * For instance, a cubic B-spline curve with knot vector `[0,0,0,1,2,3,3,3]`
|
|
196852
|
+
* * can be evaluated at parameter values in the range `[0, 3]`
|
|
196853
|
+
* * has 3 spans, with domains `[0, 1]`, `[1, 2]`, and `[2, 3]`
|
|
196821
196854
|
* * has 6 poles
|
|
196822
196855
|
* * passes through its first and last poles.
|
|
196823
|
-
* * `create` methods may allow classic convention that has an extra knot at the beginning and end of the
|
|
196824
|
-
*
|
|
196825
|
-
* *
|
|
196856
|
+
* * The `create` methods may allow the classic convention that has an extra knot at the beginning and end of the
|
|
196857
|
+
* knot vector.
|
|
196858
|
+
* * These two extra knots are not actually needed to define the B-spline curve.
|
|
196859
|
+
* * When the `create` methods recognize the classic setup (`numPoles + order = numKnots`), the extra knots are
|
|
196860
|
+
* not saved with the BSplineCurve3dBase knots.
|
|
196826
196861
|
*
|
|
196827
|
-
* * The weighted variant has the problem that CurvePrimitive
|
|
196828
|
-
*
|
|
196862
|
+
* * The weighted variant [[BSplineCurve3dH]] has the problem that `CurvePrimitive` 3D typing does not allow the
|
|
196863
|
+
* undefined result where a homogeneous pole has zero weight; the convention in this case is to return 000.
|
|
196829
196864
|
*
|
|
196830
196865
|
* * Note the class relationships:
|
|
196831
|
-
* * BSpline1dNd knows the
|
|
196832
|
-
* * BsplineCurve3dBase owns a protected BSpline1dNd
|
|
196833
|
-
* * BsplineCurve3dBase is derived from CurvePrimitive, which creates obligation to act as a 3D curve,
|
|
196834
|
-
* * evaluate fraction to point and derivatives wrt fraction
|
|
196835
|
-
* * compute intersection with plane
|
|
196836
|
-
* * BSplineCurve3d and BSplineCurve3dH have variant logic driven by whether or not there are "weights" on the poles.
|
|
196837
|
-
* * For `BSplineCurve3d`, the xyz value of pole calculations are "final" values for 3d evaluation
|
|
196866
|
+
* * [[BSpline1dNd]] knows the definitional B-spline recurrence relation with no physical interpretation for the poles.
|
|
196867
|
+
* * BsplineCurve3dBase owns a protected BSpline1dNd.
|
|
196868
|
+
* * `BsplineCurve3dBase` is derived from [[CurvePrimitive]], which creates obligation to act as a 3D curve, e.g.,
|
|
196869
|
+
* * evaluate fraction to point and derivatives wrt fraction.
|
|
196870
|
+
* * compute intersection with plane.
|
|
196871
|
+
* * [[BSplineCurve3d]] and [[BSplineCurve3dH]] have variant logic driven by whether or not there are "weights" on the poles.
|
|
196872
|
+
* * For `BSplineCurve3d`, the xyz value of pole calculations are "final" values for 3d evaluation.
|
|
196838
196873
|
* * For `BSplineCurve3dH`, various `BSpline1dNd` results with xyzw have to be normalized back to xyz.
|
|
196839
196874
|
*
|
|
196840
196875
|
* * These classes do not support "periodic" variants.
|
|
196841
|
-
* * Periodic curves
|
|
196876
|
+
* * Periodic curves historically have carried a flag (e.g., "closed") indicating that certain un-stored
|
|
196877
|
+
* leading/trailing knots and poles are understood to wrap around periodically.
|
|
196878
|
+
* * Instead, these classes carry no such flag. They represent such curves with explicitly wrapped knots/poles.
|
|
196879
|
+
*
|
|
196880
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BSpline/
|
|
196842
196881
|
* @public
|
|
196843
196882
|
*/
|
|
196844
196883
|
class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_0__.CurvePrimitive {
|
|
196845
|
-
/** String name for schema properties */
|
|
196884
|
+
/** String name for schema properties. */
|
|
196846
196885
|
curvePrimitiveType = "bsplineCurve";
|
|
196847
|
-
/** The underlying blocked-pole spline, with simple x,y,z poles */
|
|
196886
|
+
/** The underlying blocked-pole spline, with simple x,y,z poles. */
|
|
196848
196887
|
_bcurve;
|
|
196849
196888
|
_definitionData;
|
|
196850
|
-
set definitionData(data) {
|
|
196851
|
-
|
|
196889
|
+
set definitionData(data) {
|
|
196890
|
+
this._definitionData = data;
|
|
196891
|
+
}
|
|
196892
|
+
get definitionData() {
|
|
196893
|
+
return this._definitionData;
|
|
196894
|
+
}
|
|
196852
196895
|
constructor(poleDimension, numPoles, order, knots) {
|
|
196853
196896
|
super();
|
|
196854
196897
|
this._bcurve = _BSpline1dNd__WEBPACK_IMPORTED_MODULE_1__.BSpline1dNd.create(numPoles, poleDimension, order, knots);
|
|
196855
196898
|
}
|
|
196856
|
-
/** Return the degree (one less than the order) of the curve */
|
|
196857
|
-
get degree() {
|
|
196858
|
-
|
|
196859
|
-
|
|
196860
|
-
/** Return the
|
|
196861
|
-
get
|
|
196862
|
-
|
|
196863
|
-
|
|
196864
|
-
/**
|
|
196865
|
-
|
|
196866
|
-
|
|
196867
|
-
get knotsRef() { return this._bcurve.knots.knots; }
|
|
196868
|
-
/** Number of components per pole.
|
|
196869
|
-
* * 3 for conventional (x,y,z) curve
|
|
196870
|
-
* * 4 for weighted (wx,wy,wz,w) curve
|
|
196899
|
+
/** Return the degree (one less than the order) of the curve. */
|
|
196900
|
+
get degree() {
|
|
196901
|
+
return this._bcurve.degree;
|
|
196902
|
+
}
|
|
196903
|
+
/** Return the order (one more than degree) of the curve. */
|
|
196904
|
+
get order() {
|
|
196905
|
+
return this._bcurve.order;
|
|
196906
|
+
}
|
|
196907
|
+
/**
|
|
196908
|
+
* Return the number of Bezier spans in the curve. Note that this number includes the number of null
|
|
196909
|
+
* spans at repeated knows.
|
|
196871
196910
|
*/
|
|
196872
|
-
get
|
|
196911
|
+
get numSpan() {
|
|
196912
|
+
return this._bcurve.numSpan;
|
|
196913
|
+
}
|
|
196914
|
+
/** Return the number of poles. */
|
|
196915
|
+
get numPoles() {
|
|
196916
|
+
return this._bcurve.numPoles;
|
|
196917
|
+
}
|
|
196918
|
+
/** Return live reference to the poles of the curve. */
|
|
196919
|
+
get polesRef() {
|
|
196920
|
+
return this._bcurve.packedData;
|
|
196921
|
+
}
|
|
196922
|
+
/** Return live reference to the knots of the curve. */
|
|
196923
|
+
get knotsRef() {
|
|
196924
|
+
return this._bcurve.knots.knots;
|
|
196925
|
+
}
|
|
196873
196926
|
/**
|
|
196874
|
-
*
|
|
196875
|
-
*
|
|
196927
|
+
* Number of components per pole, e.g.,
|
|
196928
|
+
* * 3 for conventional (x,y,z) curve.
|
|
196929
|
+
* * 4 for weighted (wx,wy,wz,w) curve.
|
|
196876
196930
|
*/
|
|
196877
|
-
|
|
196931
|
+
get poleDimension() {
|
|
196932
|
+
return this._bcurve.poleLength;
|
|
196933
|
+
}
|
|
196934
|
+
/** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
|
|
196935
|
+
copyKnots(includeExtraEndKnot) {
|
|
196936
|
+
return this._bcurve.knots.copyKnots(includeExtraEndKnot);
|
|
196937
|
+
}
|
|
196878
196938
|
/** Get the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
|
|
196879
196939
|
getWrappable() {
|
|
196880
196940
|
return this._bcurve.knots.wrappable;
|
|
@@ -196884,7 +196944,7 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196884
196944
|
this._bcurve.knots.wrappable = value;
|
|
196885
196945
|
}
|
|
196886
196946
|
/**
|
|
196887
|
-
* Test knots and
|
|
196947
|
+
* Test knots and poles to determine if it is possible to close (aka "wrap") the curve.
|
|
196888
196948
|
* @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
|
|
196889
196949
|
*/
|
|
196890
196950
|
get isClosableCurve() {
|
|
@@ -196897,25 +196957,18 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196897
196957
|
return _KnotVector__WEBPACK_IMPORTED_MODULE_2__.BSplineWrapMode.None;
|
|
196898
196958
|
return mode;
|
|
196899
196959
|
}
|
|
196900
|
-
/** Evaluate the curve point at
|
|
196960
|
+
/** Evaluate the curve point at the given fractional parameter. */
|
|
196901
196961
|
fractionToPoint(fraction, result) {
|
|
196902
196962
|
return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);
|
|
196903
196963
|
}
|
|
196904
|
-
/**
|
|
196905
|
-
* * origin at the fractional position along the arc
|
|
196906
|
-
* * direction is the first derivative, i.e. tangent along the curve
|
|
196907
|
-
*/
|
|
196964
|
+
/** Evaluate the curve and derivative at the given fractional parameter. */
|
|
196908
196965
|
fractionToPointAndDerivative(fraction, result) {
|
|
196909
196966
|
const knot = this._bcurve.knots.fractionToKnot(fraction);
|
|
196910
196967
|
result = this.knotToPointAndDerivative(knot, result);
|
|
196911
196968
|
result.direction.scaleInPlace(this._bcurve.knots.knotLength01);
|
|
196912
196969
|
return result;
|
|
196913
196970
|
}
|
|
196914
|
-
/**
|
|
196915
|
-
* * origin at the fractional position along the arc
|
|
196916
|
-
* * x axis is the first derivative, i.e. tangent along the curve
|
|
196917
|
-
* * y axis is the second derivative
|
|
196918
|
-
*/
|
|
196971
|
+
/** Evaluate the curve and two derivatives at the given fractional parameter. */
|
|
196919
196972
|
fractionToPointAnd2Derivatives(fraction, result) {
|
|
196920
196973
|
const knot = this._bcurve.knots.fractionToKnot(fraction);
|
|
196921
196974
|
result = this.knotToPointAnd2Derivatives(knot, result);
|
|
@@ -196924,22 +196977,23 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196924
196977
|
result.vectorV.scaleInPlace(a * a);
|
|
196925
196978
|
return result;
|
|
196926
196979
|
}
|
|
196980
|
+
/** Return the start point of the curve. */
|
|
196981
|
+
startPoint() {
|
|
196982
|
+
return this.evaluatePointInSpan(0, 0.0);
|
|
196983
|
+
}
|
|
196984
|
+
/** Return the end point of the curve. */
|
|
196985
|
+
endPoint() {
|
|
196986
|
+
return this.evaluatePointInSpan(this.numSpan - 1, 1.0);
|
|
196987
|
+
}
|
|
196927
196988
|
/**
|
|
196928
|
-
*
|
|
196929
|
-
|
|
196930
|
-
|
|
196931
|
-
/**
|
|
196932
|
-
* Return the end point of the curve
|
|
196933
|
-
*/
|
|
196934
|
-
endPoint() { return this.evaluatePointInSpan(this.numSpan - 1, 1.0); }
|
|
196935
|
-
/** Reverse the curve in place.
|
|
196936
|
-
* * Poles are reversed
|
|
196937
|
-
* * knot values are mirrored around the middle of the
|
|
196938
|
-
*/
|
|
196939
|
-
reverseInPlace() { this._bcurve.reverseInPlace(); }
|
|
196940
|
-
/**
|
|
196941
|
-
* Return an array with this curve's bezier fragments.
|
|
196989
|
+
* Reverse the curve in place.
|
|
196990
|
+
* * Poles are reversed.
|
|
196991
|
+
* * Knot values are mirrored around the middle of the knot array.
|
|
196942
196992
|
*/
|
|
196993
|
+
reverseInPlace() {
|
|
196994
|
+
this._bcurve.reverseInPlace();
|
|
196995
|
+
}
|
|
196996
|
+
/** Return an array with this curve's Bezier fragments. */
|
|
196943
196997
|
collectBezierSpans(prefer3dH) {
|
|
196944
196998
|
const result = [];
|
|
196945
196999
|
const numSpans = this.numSpan;
|
|
@@ -196958,17 +197012,18 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196958
197012
|
return poleIndex * this._bcurve.poleLength;
|
|
196959
197013
|
return undefined;
|
|
196960
197014
|
}
|
|
196961
|
-
/**
|
|
196962
|
-
*
|
|
197015
|
+
/**
|
|
197016
|
+
* Search for the curve point that is closest to the spacePoint.
|
|
196963
197017
|
* * If the space point is exactly on the curve, this is the reverse of fractionToPoint.
|
|
196964
|
-
* * Since CurvePrimitive should always have start and end available as candidate points, this method should always
|
|
196965
|
-
*
|
|
197018
|
+
* * Since CurvePrimitive should always have start and end available as candidate points, this method should always
|
|
197019
|
+
* succeed.
|
|
197020
|
+
* @param spacePoint point in space.
|
|
196966
197021
|
* @param _extend ignored (pass false). A BSplineCurve3dBase cannot be extended.
|
|
196967
197022
|
* @param result optional pre-allocated detail to populate and return.
|
|
196968
197023
|
* @returns details of the closest point.
|
|
196969
197024
|
*/
|
|
196970
197025
|
closestPoint(spacePoint, _extend, result) {
|
|
196971
|
-
// seed at start point
|
|
197026
|
+
// seed at start point; final point comes with final bezier perpendicular step
|
|
196972
197027
|
const point = this.fractionToPoint(0);
|
|
196973
197028
|
result = _curve_CurveLocationDetail__WEBPACK_IMPORTED_MODULE_3__.CurveLocationDetail.createCurveFractionPointDistance(this, 0.0, point, point.distance(spacePoint), result);
|
|
196974
197029
|
let span;
|
|
@@ -196977,9 +197032,9 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196977
197032
|
if (this._bcurve.knots.isIndexOfRealSpan(i)) {
|
|
196978
197033
|
span = this.getSaturatedBezierSpan3dOr3dH(i, true, span);
|
|
196979
197034
|
if (span) {
|
|
196980
|
-
//
|
|
197035
|
+
// if the B-spline is discontinuous, both ends should be tested; ignore that possibility
|
|
196981
197036
|
if (span.updateClosestPointByTruePerpendicular(spacePoint, result, false, true)) {
|
|
196982
|
-
// the detail records the span bezier
|
|
197037
|
+
// the detail records the span bezier; promote it to the parent curve
|
|
196983
197038
|
result.curve = this;
|
|
196984
197039
|
result.fraction = span.fractionToParentFraction(result.fraction);
|
|
196985
197040
|
}
|
|
@@ -196990,13 +197045,14 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
196990
197045
|
}
|
|
196991
197046
|
/** Return a transformed deep clone. */
|
|
196992
197047
|
cloneTransformed(transform) {
|
|
196993
|
-
const
|
|
196994
|
-
|
|
196995
|
-
return
|
|
197048
|
+
const curve = this.clone();
|
|
197049
|
+
curve.tryTransformInPlace(transform);
|
|
197050
|
+
return curve;
|
|
196996
197051
|
}
|
|
196997
|
-
/**
|
|
196998
|
-
*
|
|
196999
|
-
* @param
|
|
197052
|
+
/**
|
|
197053
|
+
* Return a curve primitive which is a portion of this curve.
|
|
197054
|
+
* @param fractionA start fraction.
|
|
197055
|
+
* @param fractionB end fraction.
|
|
197000
197056
|
*/
|
|
197001
197057
|
clonePartialCurve(fractionA, fractionB) {
|
|
197002
197058
|
const clone = this.clone();
|
|
@@ -197007,11 +197063,8 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
197007
197063
|
clone._bcurve.addKnot(knotB, clone.degree);
|
|
197008
197064
|
if (origNumKnots === clone._bcurve.knots.knots.length)
|
|
197009
197065
|
return clone; // full curve
|
|
197010
|
-
if (knotA > knotB)
|
|
197011
|
-
|
|
197012
|
-
knotA = knotB;
|
|
197013
|
-
knotB = tmp;
|
|
197014
|
-
}
|
|
197066
|
+
if (knotA > knotB)
|
|
197067
|
+
[knotA, knotB] = [knotB, knotA];
|
|
197015
197068
|
// choose first/last knot and pole such that knotA/knotB has degree multiplicity in the new knot sequence
|
|
197016
197069
|
const iStartKnot = clone._bcurve.knots.knotToLeftKnotIndex(knotA) - clone.degree + 1;
|
|
197017
197070
|
const iStartPole = iStartKnot * clone._bcurve.poleLength;
|
|
@@ -197021,15 +197074,17 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
197021
197074
|
iLastKnotLeftMultiple = iLastKnot + 1;
|
|
197022
197075
|
const iEndPole = (iLastKnotLeftMultiple + 1) * clone._bcurve.poleLength; // one past last pole
|
|
197023
197076
|
const iEndKnot = iLastKnotLeftMultiple + clone.degree; // one past last knot
|
|
197024
|
-
// trim the arrays (leave knots unnormalized
|
|
197077
|
+
// trim the arrays (leave knots unnormalized)
|
|
197025
197078
|
clone._bcurve.knots.setKnotsCapture(clone._bcurve.knots.knots.slice(iStartKnot, iEndKnot));
|
|
197026
197079
|
clone._bcurve.packedData = clone._bcurve.packedData.slice(iStartPole, iEndPole);
|
|
197027
197080
|
clone.setWrappable(_KnotVector__WEBPACK_IMPORTED_MODULE_2__.BSplineWrapMode.None); // always open
|
|
197028
197081
|
return clone;
|
|
197029
197082
|
}
|
|
197030
|
-
/**
|
|
197031
|
-
*
|
|
197032
|
-
* @param
|
|
197083
|
+
/**
|
|
197084
|
+
* Implement `CurvePrimitive.appendPlaneIntersections` to compute intersections of the curve with a plane.
|
|
197085
|
+
* @param plane the plane with which to intersect the curve. Concrete types include [[Plane3dByOriginAndUnitNormal]],
|
|
197086
|
+
* [[Point4d]], etc.
|
|
197087
|
+
* @param result growing array of plane intersections.
|
|
197033
197088
|
* @return number of intersections appended to the array.
|
|
197034
197089
|
*/
|
|
197035
197090
|
appendPlaneIntersectionPoints(plane, result) {
|
|
@@ -197040,34 +197095,32 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
197040
197095
|
const point4d = _geometry4d_Point4d__WEBPACK_IMPORTED_MODULE_4__.Point4d.create();
|
|
197041
197096
|
// compute all pole altitudes from the plane
|
|
197042
197097
|
const minMax = _geometry3d_Range__WEBPACK_IMPORTED_MODULE_5__.Range1d.createNull();
|
|
197043
|
-
//
|
|
197098
|
+
// put the altitudes of all the B-spline poles in one array
|
|
197044
197099
|
for (let i = 0; i < numPole; i++) {
|
|
197045
197100
|
allCoffs[i] = plane.weightedAltitude(this.getPolePoint4d(i, point4d));
|
|
197046
197101
|
minMax.extendX(allCoffs[i]);
|
|
197047
197102
|
}
|
|
197048
|
-
// A univariate
|
|
197103
|
+
// A univariate B-spline through the altitude poles gives altitude as function of the B-spline knot.
|
|
197049
197104
|
// The (bspline) altitude function for each span is `order` consecutive altitudes.
|
|
197050
197105
|
// If those altitudes bracket zero, the span may potentially have a crossing.
|
|
197051
|
-
// When that occurs,
|
|
197052
197106
|
let univariateBezier;
|
|
197053
197107
|
let numFound = 0;
|
|
197054
197108
|
let previousFraction = -1000.0;
|
|
197055
197109
|
if (minMax.containsX(0.0)) {
|
|
197056
197110
|
for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {
|
|
197057
|
-
if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals
|
|
197111
|
+
if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals
|
|
197058
197112
|
// outer range test ...
|
|
197059
197113
|
minMax.setNull();
|
|
197060
197114
|
minMax.extendArraySubset(allCoffs, spanIndex, order);
|
|
197061
197115
|
if (minMax.containsX(0.0)) {
|
|
197062
|
-
// pack the
|
|
197116
|
+
// pack the B-spline support into a univariate bezier
|
|
197063
197117
|
univariateBezier = _numerics_BezierPolynomials__WEBPACK_IMPORTED_MODULE_6__.UnivariateBezier.createArraySubset(allCoffs, spanIndex, order, univariateBezier);
|
|
197064
197118
|
// saturate and solve the bezier
|
|
197065
197119
|
_Bezier1dNd__WEBPACK_IMPORTED_MODULE_7__.Bezier1dNd.saturate1dInPlace(univariateBezier.coffs, this._bcurve.knots, spanIndex);
|
|
197066
197120
|
const roots = univariateBezier.roots(0.0, true);
|
|
197067
197121
|
if (roots) {
|
|
197068
197122
|
for (const spanFraction of roots) {
|
|
197069
|
-
// promote each local bezier fraction to global fraction
|
|
197070
|
-
// save the curve evaluation at that fraction.
|
|
197123
|
+
// promote each local bezier fraction to global fraction and save the curve evaluation at that fraction
|
|
197071
197124
|
numFound++;
|
|
197072
197125
|
const fraction = this._bcurve.knots.spanFractionToFraction(spanIndex, spanFraction);
|
|
197073
197126
|
if (!_Geometry__WEBPACK_IMPORTED_MODULE_8__.Geometry.isAlmostEqualNumber(fraction, previousFraction)) {
|
|
@@ -197086,9 +197139,7 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
197086
197139
|
}
|
|
197087
197140
|
/**
|
|
197088
197141
|
* Construct an offset of the instance curve as viewed in the xy-plane (ignoring z).
|
|
197089
|
-
*
|
|
197090
|
-
* for an aggregate instance (e.g., LineString3d, CurveChainWithDistanceIndex), use RegionOps.constructCurveXYOffset() instead.
|
|
197091
|
-
* @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object
|
|
197142
|
+
* @param offsetDistanceOrOptions offset distance (positive to left of the instance curve), or options object.
|
|
197092
197143
|
*/
|
|
197093
197144
|
constructOffsetXY(offsetDistanceOrOptions) {
|
|
197094
197145
|
const options = _curve_OffsetOptions__WEBPACK_IMPORTED_MODULE_9__.OffsetOptions.create(offsetDistanceOrOptions);
|
|
@@ -197096,18 +197147,21 @@ class BSplineCurve3dBase extends _curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_
|
|
|
197096
197147
|
this.emitStrokableParts(handler, options.strokeOptions);
|
|
197097
197148
|
return handler.claimResult();
|
|
197098
197149
|
}
|
|
197099
|
-
/**
|
|
197150
|
+
/**
|
|
197151
|
+
* Project instance geometry (via dispatch) onto the given ray, and return the extreme fractional parameters
|
|
197152
|
+
* of projection.
|
|
197100
197153
|
* @param ray ray onto which the instance is projected. A `Vector3d` is treated as a `Ray3d` with zero origin.
|
|
197101
|
-
* @param lowHigh optional receiver for output
|
|
197102
|
-
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
197154
|
+
* @param lowHigh optional receiver for output.
|
|
197155
|
+
* @returns range of fractional projection parameters onto the ray, where 0.0 is start of the ray and 1.0 is the
|
|
197156
|
+
* end of the ray.
|
|
197103
197157
|
*/
|
|
197104
197158
|
projectedParameterRange(ray, lowHigh) {
|
|
197105
197159
|
return _curve_internalContexts_PlaneAltitudeRangeContext__WEBPACK_IMPORTED_MODULE_11__.PlaneAltitudeRangeContext.findExtremeFractionsAlongDirection(this, ray, lowHigh);
|
|
197106
197160
|
}
|
|
197107
197161
|
}
|
|
197108
197162
|
/**
|
|
197109
|
-
* A BSplineCurve3d is a
|
|
197110
|
-
* See BSplineCurve3dBase for description of knots, order, degree.
|
|
197163
|
+
* A BSplineCurve3d is a B-spline curve whose poles are Point3d.
|
|
197164
|
+
* See BSplineCurve3dBase for description of knots, order, degree, and poles.
|
|
197111
197165
|
* @public
|
|
197112
197166
|
*/
|
|
197113
197167
|
class BSplineCurve3d extends BSplineCurve3dBase {
|
|
@@ -197117,11 +197171,19 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197117
197171
|
this._workBezier = _BezierCurve3d__WEBPACK_IMPORTED_MODULE_12__.BezierCurve3d.createOrder(this.order);
|
|
197118
197172
|
return this._workBezier;
|
|
197119
197173
|
}
|
|
197120
|
-
|
|
197121
|
-
|
|
197174
|
+
constructor(numPoles, order, knots) {
|
|
197175
|
+
super(3, numPoles, order, knots);
|
|
197176
|
+
}
|
|
197177
|
+
/** Test if `other` is an instance of BSplineCurve3d. */
|
|
197178
|
+
isSameGeometryClass(other) {
|
|
197179
|
+
return other instanceof BSplineCurve3d;
|
|
197180
|
+
}
|
|
197122
197181
|
/** Apply `transform` to the poles. */
|
|
197123
|
-
tryTransformInPlace(transform) {
|
|
197124
|
-
|
|
197182
|
+
tryTransformInPlace(transform) {
|
|
197183
|
+
_geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.multiplyInPlace(transform, this._bcurve.packedData);
|
|
197184
|
+
return true;
|
|
197185
|
+
}
|
|
197186
|
+
/** Get a pole as a simple Point3d. */
|
|
197125
197187
|
getPolePoint3d(poleIndex, result) {
|
|
197126
197188
|
const k = this.poleIndexToDataIndex(poleIndex);
|
|
197127
197189
|
if (k !== undefined) {
|
|
@@ -197130,7 +197192,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197130
197192
|
}
|
|
197131
197193
|
return undefined;
|
|
197132
197194
|
}
|
|
197133
|
-
/** Get a pole as Point4d with weight 1 */
|
|
197195
|
+
/** Get a pole as Point4d with weight 1. */
|
|
197134
197196
|
getPolePoint4d(poleIndex, result) {
|
|
197135
197197
|
const k = this.poleIndexToDataIndex(poleIndex);
|
|
197136
197198
|
if (k !== undefined) {
|
|
@@ -197139,23 +197201,26 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197139
197201
|
}
|
|
197140
197202
|
return undefined;
|
|
197141
197203
|
}
|
|
197142
|
-
/** Convert `spanIndex` and `localFraction` to a knot. */
|
|
197143
|
-
spanFractionToKnot(span, localFraction) {
|
|
197144
|
-
return this._bcurve.spanFractionToKnot(span, localFraction);
|
|
197145
|
-
}
|
|
197146
|
-
constructor(numPoles, order, knots) {
|
|
197147
|
-
super(3, numPoles, order, knots);
|
|
197148
|
-
}
|
|
197149
|
-
/** Return a simple array of arrays with the control points as `[[x,y,z],[x,y,z],..]` */
|
|
197150
|
-
copyPoints() { return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3); }
|
|
197151
|
-
/** Return a simple array of the control points coordinates */
|
|
197152
|
-
copyPointsFloat64Array() { return this._bcurve.packedData.slice(); }
|
|
197153
197204
|
/**
|
|
197154
|
-
*
|
|
197155
|
-
* in
|
|
197205
|
+
* Convert the fractional position in the given span to a knot.
|
|
197206
|
+
* * The returned value is not necessarily a knot, but it is a valid parameter in the domain of the B-spline curve.
|
|
197156
197207
|
*/
|
|
197157
|
-
|
|
197158
|
-
|
|
197208
|
+
spanFractionToKnot(spanIndex, spanFraction) {
|
|
197209
|
+
return this._bcurve.spanFractionToKnot(spanIndex, spanFraction);
|
|
197210
|
+
}
|
|
197211
|
+
/** Return a simple array of arrays with the poles as `[[x,y,z],[x,y,z],..]`. */
|
|
197212
|
+
copyPoints() {
|
|
197213
|
+
return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3);
|
|
197214
|
+
}
|
|
197215
|
+
/** Return a simple array of poles' coordinates. */
|
|
197216
|
+
copyPointsFloat64Array() {
|
|
197217
|
+
return this._bcurve.packedData.slice();
|
|
197218
|
+
}
|
|
197219
|
+
/** Return a simple array form of the knots. Optionally replicate the first and last in classic over-clamped manner. */
|
|
197220
|
+
copyKnots(includeExtraEndKnot) {
|
|
197221
|
+
return this._bcurve.knots.copyKnots(includeExtraEndKnot);
|
|
197222
|
+
}
|
|
197223
|
+
/** Create a B-spline with uniform knots. */
|
|
197159
197224
|
static createUniformKnots(poles, order) {
|
|
197160
197225
|
const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;
|
|
197161
197226
|
if (order < 2 || numPoles < order)
|
|
@@ -197179,9 +197244,10 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197179
197244
|
}
|
|
197180
197245
|
return curve;
|
|
197181
197246
|
}
|
|
197182
|
-
/**
|
|
197183
|
-
*
|
|
197184
|
-
|
|
197247
|
+
/**
|
|
197248
|
+
* Create a smoothly closed B-spline curve with uniform knots.
|
|
197249
|
+
* * Note that the curve does not start at the first pole.
|
|
197250
|
+
*/
|
|
197185
197251
|
static createPeriodicUniformKnots(poles, order) {
|
|
197186
197252
|
if (order < 2)
|
|
197187
197253
|
return undefined;
|
|
@@ -197252,21 +197318,23 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197252
197318
|
return _BSplineCurveOps__WEBPACK_IMPORTED_MODULE_16__.BSplineCurveOps.createThroughPointsC2Cubic(options);
|
|
197253
197319
|
}
|
|
197254
197320
|
/**
|
|
197255
|
-
*
|
|
197321
|
+
* Create a B-spline curve from an Akima curve.
|
|
197256
197322
|
* @param options collection of points and end conditions.
|
|
197257
197323
|
*/
|
|
197258
197324
|
static createFromAkimaCurve3dOptions(options) {
|
|
197259
197325
|
return _BSplineCurveOps__WEBPACK_IMPORTED_MODULE_16__.BSplineCurveOps.createThroughPoints(options.fitPoints, 4); // temporary
|
|
197260
197326
|
}
|
|
197261
197327
|
/**
|
|
197262
|
-
* Create a
|
|
197328
|
+
* Create a B-spline curve with given knots.
|
|
197263
197329
|
* * The poles have several variants:
|
|
197264
|
-
* * Float64Array(3 * numPoles) in blocks of [x,y,z]
|
|
197265
|
-
* * Point3d[]
|
|
197266
|
-
* * number[][], with inner dimension 3
|
|
197330
|
+
* * Float64Array(3 * numPoles) in blocks of [x,y,z].
|
|
197331
|
+
* * Point3d[].
|
|
197332
|
+
* * number[][], with inner dimension 3.
|
|
197267
197333
|
* * Two count conditions are recognized:
|
|
197268
|
-
* * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots
|
|
197334
|
+
* * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots
|
|
197335
|
+
* of classic clamping.
|
|
197269
197336
|
* * If poleArray.length + order === knotArray.length + 2, the knots are in modern form.
|
|
197337
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/BSpline/
|
|
197270
197338
|
*/
|
|
197271
197339
|
static create(poleArray, knotArray, order) {
|
|
197272
197340
|
if (order < 2)
|
|
@@ -197304,31 +197372,42 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197304
197372
|
}
|
|
197305
197373
|
return curve;
|
|
197306
197374
|
}
|
|
197307
|
-
/** Return a deep clone */
|
|
197375
|
+
/** Return a deep clone. */
|
|
197308
197376
|
clone() {
|
|
197309
|
-
const
|
|
197310
|
-
const
|
|
197311
|
-
|
|
197312
|
-
return
|
|
197377
|
+
const knotVector = this._bcurve.knots.clone();
|
|
197378
|
+
const curve = new BSplineCurve3d(this.numPoles, this.order, knotVector);
|
|
197379
|
+
curve._bcurve.packedData = this._bcurve.packedData.slice();
|
|
197380
|
+
return curve;
|
|
197313
197381
|
}
|
|
197314
|
-
/** Evaluate at a
|
|
197382
|
+
/** Evaluate the curve at a fractional position within a given span. */
|
|
197315
197383
|
evaluatePointInSpan(spanIndex, spanFraction) {
|
|
197316
197384
|
this._bcurve.evaluateBuffersInSpan(spanIndex, spanFraction);
|
|
197317
197385
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Point3d.createFrom(this._bcurve.poleBuffer);
|
|
197318
197386
|
}
|
|
197319
|
-
/**
|
|
197320
|
-
*
|
|
197387
|
+
/**
|
|
197388
|
+
* Evaluate the curve and derivative at a fractional position within a given span.
|
|
197389
|
+
* * The derivative is with respect to the span fractional parameter, _not_ to the curve's parameter or fractional parameter.
|
|
197321
197390
|
*/
|
|
197322
197391
|
evaluatePointAndDerivativeInSpan(spanIndex, spanFraction) {
|
|
197323
197392
|
this._bcurve.evaluateBuffersInSpan1(spanIndex, spanFraction);
|
|
197324
197393
|
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));
|
|
197325
197394
|
}
|
|
197326
|
-
/**
|
|
197395
|
+
/**
|
|
197396
|
+
* Evaluate the curve at the given parameter.
|
|
197397
|
+
* @param u parameter in curve domain.
|
|
197398
|
+
* @param result optional result.
|
|
197399
|
+
* @returns the point on the curve.
|
|
197400
|
+
*/
|
|
197327
197401
|
knotToPoint(u, result) {
|
|
197328
197402
|
this._bcurve.evaluateBuffersAtKnot(u);
|
|
197329
197403
|
return _geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_14__.Point3d.createFrom(this._bcurve.poleBuffer, result);
|
|
197330
197404
|
}
|
|
197331
|
-
/**
|
|
197405
|
+
/**
|
|
197406
|
+
* Evaluate the curve and derivative at the given parameter.
|
|
197407
|
+
* @param u parameter in curve domain.
|
|
197408
|
+
* @param result optional result.
|
|
197409
|
+
* @returns the ray with origin at the curve point and direction as the derivative.
|
|
197410
|
+
*/
|
|
197332
197411
|
knotToPointAndDerivative(u, result) {
|
|
197333
197412
|
this._bcurve.evaluateBuffersAtKnot(u, 1);
|
|
197334
197413
|
if (!result)
|
|
@@ -197337,12 +197416,17 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197337
197416
|
result.direction.setFrom(this._bcurve.poleBuffer1);
|
|
197338
197417
|
return result;
|
|
197339
197418
|
}
|
|
197340
|
-
/**
|
|
197419
|
+
/**
|
|
197420
|
+
* Evaluate the curve and two derivatives at the given parameter.
|
|
197421
|
+
* @param u parameter in the curve domain.
|
|
197422
|
+
* @param result optional result.
|
|
197423
|
+
* @returns the plane with origin at the curve point, vectorU as the 1st derivative, and vectorV as the 2nd derivative.
|
|
197424
|
+
*/
|
|
197341
197425
|
knotToPointAnd2Derivatives(u, result) {
|
|
197342
197426
|
this._bcurve.evaluateBuffersAtKnot(u, 2);
|
|
197343
197427
|
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);
|
|
197344
197428
|
}
|
|
197345
|
-
/**
|
|
197429
|
+
/** Test if `this` is almost the same curve as `other`. */
|
|
197346
197430
|
isAlmostEqual(other) {
|
|
197347
197431
|
if (other instanceof BSplineCurve3d) {
|
|
197348
197432
|
return this._bcurve.knots.isAlmostEqual(other._bcurve.knots)
|
|
@@ -197350,15 +197434,19 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197350
197434
|
}
|
|
197351
197435
|
return false;
|
|
197352
197436
|
}
|
|
197353
|
-
/**
|
|
197437
|
+
/** Test if this curve lies entirely in the given plane. */
|
|
197354
197438
|
isInPlane(plane) {
|
|
197355
197439
|
return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.isCloseToPlane(this._bcurve.packedData, plane);
|
|
197356
197440
|
}
|
|
197357
|
-
/**
|
|
197358
|
-
|
|
197359
|
-
|
|
197441
|
+
/**
|
|
197442
|
+
* Return the control polygon length as an approximation to the curve length.
|
|
197443
|
+
* * The returned length is always an overestimate.
|
|
197444
|
+
*/
|
|
197445
|
+
quickLength() {
|
|
197446
|
+
return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_13__.Point3dArray.sumEdgeLengths(this._bcurve.packedData);
|
|
197447
|
+
}
|
|
197448
|
+
/** Emit Beziers or strokes (selected by the stroke options) to the handler. */
|
|
197360
197449
|
emitStrokableParts(handler, options) {
|
|
197361
|
-
const needBeziers = handler.announceBezierCurve !== undefined;
|
|
197362
197450
|
const workBezier = this.initializeWorkBezier();
|
|
197363
197451
|
const numSpan = this.numSpan;
|
|
197364
197452
|
let numStrokes;
|
|
@@ -197366,7 +197454,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197366
197454
|
const bezier = this.getSaturatedBezierSpan3dOr3dH(spanIndex, false, workBezier);
|
|
197367
197455
|
if (bezier) {
|
|
197368
197456
|
numStrokes = bezier.computeStrokeCountForOptions(options);
|
|
197369
|
-
if (
|
|
197457
|
+
if (handler.announceBezierCurve) {
|
|
197370
197458
|
handler.announceBezierCurve(bezier, numStrokes, this, spanIndex, this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0), this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));
|
|
197371
197459
|
}
|
|
197372
197460
|
else {
|
|
@@ -197391,7 +197479,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197391
197479
|
return numStroke;
|
|
197392
197480
|
}
|
|
197393
197481
|
/**
|
|
197394
|
-
* Compute individual segment stroke counts.
|
|
197482
|
+
* Compute individual segment stroke counts. Attach in a StrokeCountMap.
|
|
197395
197483
|
* @param options StrokeOptions that determine count
|
|
197396
197484
|
* @param parentStrokeMap evolving parent map.
|
|
197397
197485
|
* @alpha
|
|
@@ -197410,7 +197498,7 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197410
197498
|
}
|
|
197411
197499
|
_curve_CurvePrimitive__WEBPACK_IMPORTED_MODULE_0__.CurvePrimitive.installStrokeCountMap(this, myData, parentStrokeMap);
|
|
197412
197500
|
}
|
|
197413
|
-
/** Append strokes to
|
|
197501
|
+
/** Append strokes to the given linestring. */
|
|
197414
197502
|
emitStrokes(dest, options) {
|
|
197415
197503
|
const workBezier = this.initializeWorkBezier();
|
|
197416
197504
|
const numSpan = this.numSpan;
|
|
@@ -197421,16 +197509,17 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197421
197509
|
}
|
|
197422
197510
|
}
|
|
197423
197511
|
/**
|
|
197424
|
-
* Test knots and
|
|
197512
|
+
* Test knots and poles to determine if it is possible to close (aka "wrap") the curve.
|
|
197425
197513
|
* @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
|
|
197426
197514
|
*/
|
|
197427
197515
|
get isClosable() {
|
|
197428
197516
|
return this.isClosableCurve;
|
|
197429
197517
|
}
|
|
197430
197518
|
/**
|
|
197431
|
-
* Return
|
|
197432
|
-
*
|
|
197433
|
-
* @param
|
|
197519
|
+
* Return the Bezier fragment corresponding to the given span of this curve.
|
|
197520
|
+
* * The concrete return type may be [[BezierCurve3d]] or [[BezierCurve3dH]] according to the instance type and `prefer3dH`.
|
|
197521
|
+
* @param spanIndex index of span.
|
|
197522
|
+
* @param result optional reusable curve. This will only be reused if its type and order matches.
|
|
197434
197523
|
*/
|
|
197435
197524
|
getSaturatedBezierSpan3dOr3dH(spanIndex, prefer3dH, result) {
|
|
197436
197525
|
if (prefer3dH)
|
|
@@ -197438,9 +197527,9 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197438
197527
|
return this.getSaturatedBezierSpan3d(spanIndex, result);
|
|
197439
197528
|
}
|
|
197440
197529
|
/**
|
|
197441
|
-
* Return
|
|
197442
|
-
* @param spanIndex
|
|
197443
|
-
* @param result optional reusable curve.
|
|
197530
|
+
* Return the Bezier fragment corresponding to the given span of this curve.
|
|
197531
|
+
* @param spanIndex index of span.
|
|
197532
|
+
* @param result optional reusable curve. This will only be reused if its type and order matches.
|
|
197444
197533
|
*/
|
|
197445
197534
|
getSaturatedBezierSpan3d(spanIndex, result) {
|
|
197446
197535
|
if (spanIndex < 0 || spanIndex >= this.numSpan)
|
|
@@ -197451,13 +197540,13 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197451
197540
|
const bezier = result;
|
|
197452
197541
|
bezier.loadSpanPoles(this._bcurve.packedData, spanIndex);
|
|
197453
197542
|
if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))
|
|
197454
|
-
return
|
|
197543
|
+
return bezier;
|
|
197455
197544
|
return undefined;
|
|
197456
197545
|
}
|
|
197457
197546
|
/**
|
|
197458
|
-
* Return
|
|
197459
|
-
* @param spanIndex
|
|
197460
|
-
* @param result optional reusable curve.
|
|
197547
|
+
* Return the Bezier fragment corresponding to the given span of this curve.
|
|
197548
|
+
* @param spanIndex index of span.
|
|
197549
|
+
* @param result optional reusable curve. This will only be reused if its type and order matches.
|
|
197461
197550
|
*/
|
|
197462
197551
|
getSaturatedBezierSpan3dH(spanIndex, result) {
|
|
197463
197552
|
if (spanIndex < 0 || spanIndex >= this.numSpan)
|
|
@@ -197471,15 +197560,16 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
197471
197560
|
return bezier;
|
|
197472
197561
|
return undefined;
|
|
197473
197562
|
}
|
|
197474
|
-
/** Second step of double dispatch:
|
|
197563
|
+
/** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)`. */
|
|
197475
197564
|
dispatchToGeometryHandler(handler) {
|
|
197476
197565
|
return handler.handleBSplineCurve3d(this);
|
|
197477
197566
|
}
|
|
197478
197567
|
/**
|
|
197479
|
-
* Extend a range so
|
|
197480
|
-
* *
|
|
197481
|
-
*
|
|
197482
|
-
* @param
|
|
197568
|
+
* Extend a range so it contains the range of this curve.
|
|
197569
|
+
* * This computation is based on the poles, not the curve itself, so the returned range is generally larger than the
|
|
197570
|
+
* tightest possible range.
|
|
197571
|
+
* @param rangeToExtend range to extend.
|
|
197572
|
+
* @param transform transform to apply to the poles as they are entered into the range.
|
|
197483
197573
|
*/
|
|
197484
197574
|
extendRange(rangeToExtend, transform) {
|
|
197485
197575
|
const buffer = this._bcurve.packedData;
|
|
@@ -200241,13 +200331,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
200241
200331
|
|
|
200242
200332
|
|
|
200243
200333
|
|
|
200244
|
-
|
|
200245
|
-
|
|
200246
|
-
// ================================================================================================================
|
|
200247
|
-
// ================================================================================================================
|
|
200248
|
-
/** 3d Bezier curve class.
|
|
200334
|
+
/**
|
|
200335
|
+
* 3d Bezier curve class.
|
|
200249
200336
|
* * Use BezierCurve3dH if the curve has weights.
|
|
200250
200337
|
* * The control points (xyz) are managed as the _packedData buffer in the _polygon member of BezierCurveBase.
|
|
200338
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/Bezier/
|
|
200251
200339
|
* @public
|
|
200252
200340
|
*/
|
|
200253
200341
|
class BezierCurve3d extends _BezierCurveBase__WEBPACK_IMPORTED_MODULE_0__.BezierCurveBase {
|
|
@@ -201402,8 +201490,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
201402
201490
|
/* harmony export */ BSplineWrapMode: () => (/* binding */ BSplineWrapMode),
|
|
201403
201491
|
/* harmony export */ KnotVector: () => (/* binding */ KnotVector)
|
|
201404
201492
|
/* harmony export */ });
|
|
201405
|
-
/* harmony import */ var
|
|
201406
|
-
/* harmony import */ var
|
|
201493
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
201494
|
+
/* harmony import */ var _Geometry__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Geometry */ "../../core/geometry/lib/esm/Geometry.js");
|
|
201495
|
+
/* harmony import */ var _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../geometry3d/PointHelpers */ "../../core/geometry/lib/esm/geometry3d/PointHelpers.js");
|
|
201407
201496
|
/*---------------------------------------------------------------------------------------------
|
|
201408
201497
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
201409
201498
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -201413,6 +201502,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
201413
201502
|
*/
|
|
201414
201503
|
|
|
201415
201504
|
|
|
201505
|
+
|
|
201416
201506
|
/**
|
|
201417
201507
|
* B-spline curve and surface types in this library are non-periodic. But they can be created from legacy periodic data.
|
|
201418
201508
|
* This enumeration lists the possible ways a B-spline object can have been created from legacy periodic data.
|
|
@@ -201422,68 +201512,89 @@ var BSplineWrapMode;
|
|
|
201422
201512
|
(function (BSplineWrapMode) {
|
|
201423
201513
|
/** No conversion performed. */
|
|
201424
201514
|
BSplineWrapMode[BSplineWrapMode["None"] = 0] = "None";
|
|
201425
|
-
/**
|
|
201426
|
-
*
|
|
201515
|
+
/**
|
|
201516
|
+
* The legacy periodic B-spline data was opened up by adding `degree` wrap-around poles.
|
|
201517
|
+
* * This is typical of B-spline curves and surfaces constructed with maximum `degree - 1` continuity.
|
|
201427
201518
|
* * Knots are unaffected by this conversion.
|
|
201428
201519
|
*/
|
|
201429
201520
|
BSplineWrapMode[BSplineWrapMode["OpenByAddingControlPoints"] = 1] = "OpenByAddingControlPoints";
|
|
201430
|
-
/**
|
|
201521
|
+
/**
|
|
201522
|
+
* The legacy periodic B-spline data was opened up by removing `degree` exterior knots.
|
|
201431
201523
|
* * This is typical of rational B-spline curves representing full circles and ellipses.
|
|
201432
201524
|
* * Poles are unaffected by this conversion.
|
|
201433
201525
|
*/
|
|
201434
201526
|
BSplineWrapMode[BSplineWrapMode["OpenByRemovingKnots"] = 2] = "OpenByRemovingKnots";
|
|
201435
201527
|
})(BSplineWrapMode || (BSplineWrapMode = {}));
|
|
201436
201528
|
/**
|
|
201437
|
-
* Array of non-decreasing numbers acting as a knot
|
|
201529
|
+
* Array of non-decreasing numbers acting as a knot vector for B-spline curves and surfaces.
|
|
201438
201530
|
*
|
|
201439
201531
|
* * Essential identity: numKnots = numPoles + order - 2 = numPoles + degree - 1
|
|
201440
|
-
* * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation
|
|
201441
|
-
* demand order knots at each end for clamping.
|
|
201532
|
+
* * Various B-spline libraries have confusion over how many "end knots" are needed. Many libraries (including MicroStation
|
|
201533
|
+
* and Parasolid) demand order knots at each end for clamping. However, only order-1 are really needed. This class uses the
|
|
201534
|
+
* order-1 convention.
|
|
201442
201535
|
* * A span is a single interval of the knots.
|
|
201443
|
-
* * The left knot of span
|
|
201536
|
+
* * The left knot of the span with index `k>=0` is the knot with index `k+degree-1`.
|
|
201537
|
+
* * A knot vector is clamped when the first `degree` knots are equal and the last `degree` knots are equal.
|
|
201538
|
+
* * The "active knot interval" is the subset of the knot vector sans its first and last `degree-1` knots, and serves as
|
|
201539
|
+
* the parametric domain of the associated B-spline object.
|
|
201444
201540
|
* * This class provides queries to convert among spanIndex, knotIndex, spanFraction, fraction of knot range, and knot.
|
|
201445
|
-
* *
|
|
201446
|
-
* know their primary values (global knot, spanFraction).
|
|
201541
|
+
* * Callers need to distinguish core computational inputs such as left knot index, knot value, span index, and span fraction.
|
|
201447
201542
|
* @public
|
|
201448
201543
|
*/
|
|
201449
201544
|
class KnotVector {
|
|
201450
201545
|
/** The simple array of knot values. */
|
|
201451
201546
|
knots;
|
|
201452
|
-
/**
|
|
201547
|
+
/** The degree of basis functions defined in these knots. */
|
|
201453
201548
|
degree;
|
|
201549
|
+
/** The leftmost knot value (of the active interval, ignoring unclamped leading knots). */
|
|
201454
201550
|
_knot0;
|
|
201551
|
+
/** The rightmost knot value (of the active interval, ignoring unclamped leading knots). */
|
|
201455
201552
|
_knot1;
|
|
201456
201553
|
_wrapMode;
|
|
201457
|
-
/**
|
|
201554
|
+
/** Tolerance for considering two knots to be the same. */
|
|
201458
201555
|
static knotTolerance = 1.0e-9;
|
|
201459
|
-
/** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/
|
|
201460
|
-
get leftKnot() {
|
|
201461
|
-
|
|
201462
|
-
|
|
201463
|
-
/** Return the
|
|
201464
|
-
get
|
|
201465
|
-
|
|
201466
|
-
|
|
201467
|
-
/**
|
|
201468
|
-
get
|
|
201469
|
-
|
|
201470
|
-
|
|
201471
|
-
|
|
201556
|
+
/** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots). */
|
|
201557
|
+
get leftKnot() {
|
|
201558
|
+
return this._knot0;
|
|
201559
|
+
}
|
|
201560
|
+
/** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots). */
|
|
201561
|
+
get rightKnot() {
|
|
201562
|
+
return this._knot1;
|
|
201563
|
+
}
|
|
201564
|
+
/** Return the index of the leftmost knot of the active interval. */
|
|
201565
|
+
get leftKnotIndex() {
|
|
201566
|
+
return this.degree - 1;
|
|
201567
|
+
}
|
|
201568
|
+
/** Return the index of the rightmost knot of the active interval. */
|
|
201569
|
+
get rightKnotIndex() {
|
|
201570
|
+
return this.knots.length - this.degree;
|
|
201571
|
+
}
|
|
201472
201572
|
/**
|
|
201473
|
-
*
|
|
201474
|
-
*
|
|
201475
|
-
|
|
201476
|
-
|
|
201477
|
-
|
|
201573
|
+
* Whether this KnotVector was created by converting legacy periodic data during deserialization. The conversion used
|
|
201574
|
+
* is specified by BSplineWrapMode, and is reversed at serialization time.
|
|
201575
|
+
*/
|
|
201576
|
+
get wrappable() {
|
|
201577
|
+
return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode;
|
|
201578
|
+
}
|
|
201579
|
+
set wrappable(value) {
|
|
201580
|
+
this._wrapMode = value;
|
|
201581
|
+
}
|
|
201582
|
+
/** Return the number of Bezier spans. Note that this includes zero-length spans if there are repeated knots. */
|
|
201583
|
+
get numSpans() {
|
|
201584
|
+
return this.rightKnotIndex - this.leftKnotIndex;
|
|
201585
|
+
}
|
|
201586
|
+
/**
|
|
201587
|
+
* Private constructor.
|
|
201588
|
+
* * If `knots` is a number array or Float64Array, then its values are copied to the instance array.
|
|
201589
|
+
* * If `knots` is a number, the instance array is allocated to this size but left as zeros.
|
|
201478
201590
|
*/
|
|
201479
201591
|
constructor(knots, degree, wrapMode) {
|
|
201480
201592
|
this.degree = degree;
|
|
201481
201593
|
this._wrapMode = wrapMode;
|
|
201482
|
-
// default values to satisfy compiler
|
|
201594
|
+
// default values to satisfy compiler; real values happen in setupFixedValues or the final else clause defers to user
|
|
201483
201595
|
this._knot0 = 0.0;
|
|
201484
201596
|
this._knot1 = 1.0;
|
|
201485
|
-
|
|
201486
|
-
if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.
|
|
201597
|
+
if (Array.isArray(knots)) {
|
|
201487
201598
|
this.knots = new Float64Array(knots.length);
|
|
201488
201599
|
this.setKnots(knots);
|
|
201489
201600
|
this.setupFixedValues();
|
|
@@ -201492,23 +201603,32 @@ class KnotVector {
|
|
|
201492
201603
|
this.knots = knots.slice();
|
|
201493
201604
|
this.setupFixedValues();
|
|
201494
201605
|
}
|
|
201495
|
-
else { // caller is responsible for filling array separately
|
|
201496
|
-
|
|
201606
|
+
else { // caller is responsible for filling array separately
|
|
201607
|
+
const knotSize = knots;
|
|
201608
|
+
this.knots = new Float64Array(knotSize);
|
|
201497
201609
|
}
|
|
201498
201610
|
}
|
|
201499
|
-
/**
|
|
201500
|
-
clone() {
|
|
201611
|
+
/** Copy degree and knots to a new KnotVector. */
|
|
201612
|
+
clone() {
|
|
201613
|
+
return new KnotVector(this.knots, this.degree, this.wrappable);
|
|
201614
|
+
}
|
|
201501
201615
|
setupFixedValues() {
|
|
201502
201616
|
if (this.degree > 0 && this.knots.length > this.degree) {
|
|
201503
201617
|
this._knot0 = this.knots[this.degree - 1];
|
|
201504
201618
|
this._knot1 = this.knots[this.knots.length - this.degree];
|
|
201505
201619
|
}
|
|
201506
201620
|
}
|
|
201507
|
-
/** Return the total knot distance from beginning to end. */
|
|
201508
|
-
get knotLength01() { return this._knot1 - this._knot0; }
|
|
201509
201621
|
/**
|
|
201510
|
-
*
|
|
201511
|
-
*
|
|
201622
|
+
* Return the length of the active knot interval.
|
|
201623
|
+
* * This is the size of (one dimension of) the parametric domain for the associated B-spline object.
|
|
201624
|
+
*/
|
|
201625
|
+
get knotLength01() {
|
|
201626
|
+
return this._knot1 - this._knot0;
|
|
201627
|
+
}
|
|
201628
|
+
/**
|
|
201629
|
+
* Returns true if all numeric values have wraparound conditions that allow the knots to be closed with specified
|
|
201630
|
+
* wrap mode.
|
|
201631
|
+
* @param mode optional test mode. If undefined, use this.wrappable.
|
|
201512
201632
|
*/
|
|
201513
201633
|
testClosable(mode) {
|
|
201514
201634
|
if (mode === undefined)
|
|
@@ -201542,11 +201662,11 @@ class KnotVector {
|
|
|
201542
201662
|
}
|
|
201543
201663
|
return false;
|
|
201544
201664
|
}
|
|
201545
|
-
/** Test matching degree and knot values */
|
|
201665
|
+
/** Test matching degree and knot values. */
|
|
201546
201666
|
isAlmostEqual(other) {
|
|
201547
201667
|
if (this.degree !== other.degree)
|
|
201548
201668
|
return false;
|
|
201549
|
-
return
|
|
201669
|
+
return _geometry3d_PointHelpers__WEBPACK_IMPORTED_MODULE_1__.NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);
|
|
201550
201670
|
}
|
|
201551
201671
|
/** Compute the multiplicity of the input knot, or zero if not a knot. */
|
|
201552
201672
|
getKnotMultiplicity(knot) {
|
|
@@ -201582,8 +201702,9 @@ class KnotVector {
|
|
|
201582
201702
|
}
|
|
201583
201703
|
return m;
|
|
201584
201704
|
}
|
|
201585
|
-
/**
|
|
201586
|
-
*
|
|
201705
|
+
/**
|
|
201706
|
+
* Transform knots such that the active knot range becomes [0,1].
|
|
201707
|
+
* @returns false if and only if `this.knotLength01` is trivial.
|
|
201587
201708
|
*/
|
|
201588
201709
|
normalize() {
|
|
201589
201710
|
if (this.knotLength01 < KnotVector.knotTolerance)
|
|
@@ -201601,8 +201722,7 @@ class KnotVector {
|
|
|
201601
201722
|
this.setupFixedValues();
|
|
201602
201723
|
return true;
|
|
201603
201724
|
}
|
|
201604
|
-
/**
|
|
201605
|
-
*/
|
|
201725
|
+
/** Install knot values from an array, optionally ignoring first and last. */
|
|
201606
201726
|
setKnots(knots, skipFirstAndLast) {
|
|
201607
201727
|
const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;
|
|
201608
201728
|
if (numAllocate !== this.knots.length)
|
|
@@ -201617,17 +201737,17 @@ class KnotVector {
|
|
|
201617
201737
|
}
|
|
201618
201738
|
this.setupFixedValues();
|
|
201619
201739
|
}
|
|
201620
|
-
/** Set knots to input array (CAPTURED) */
|
|
201740
|
+
/** Set knots to input array (CAPTURED). */
|
|
201621
201741
|
setKnotsCapture(knots) {
|
|
201622
201742
|
this.knots = knots;
|
|
201623
201743
|
this.setupFixedValues();
|
|
201624
201744
|
}
|
|
201625
201745
|
/**
|
|
201626
201746
|
* Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.
|
|
201627
|
-
* @param numPoles
|
|
201628
|
-
* @param degree degree of polynomial
|
|
201629
|
-
* @param a0 left knot value for active interval
|
|
201630
|
-
* @param a1 right knot value for active interval
|
|
201747
|
+
* @param numPoles number of poles.
|
|
201748
|
+
* @param degree degree of polynomial.
|
|
201749
|
+
* @param a0 left knot value for active interval.
|
|
201750
|
+
* @param a1 right knot value for active interval.
|
|
201631
201751
|
*/
|
|
201632
201752
|
static createUniformClamped(numPoles, degree, a0, a1) {
|
|
201633
201753
|
const knots = new KnotVector(numPoles + degree - 1, degree);
|
|
@@ -201644,24 +201764,26 @@ class KnotVector {
|
|
|
201644
201764
|
}
|
|
201645
201765
|
/**
|
|
201646
201766
|
* Create knot vector with wraparound knots at start and end, and uniform knots between.
|
|
201647
|
-
* @param
|
|
201648
|
-
*
|
|
201649
|
-
*
|
|
201650
|
-
*
|
|
201767
|
+
* @param numInterval the number of intervals into which to uniformly divide the active knot interval `[a0,a1]`,
|
|
201768
|
+
* creating `numInterval-1` equally spaced interior knots between `a0` and `a1`.
|
|
201769
|
+
* This number is equal to the number of Bezier spans in the associated B-spline object.
|
|
201770
|
+
* It is _not_ the pole count.
|
|
201771
|
+
* @param degree degree of polynomial.
|
|
201772
|
+
* @param a0 left knot value for active interval.
|
|
201773
|
+
* @param a1 right knot value for active interval.
|
|
201651
201774
|
*/
|
|
201652
201775
|
static createUniformWrapped(numInterval, degree, a0, a1) {
|
|
201653
201776
|
const knots = new KnotVector(numInterval + 2 * degree - 1, degree);
|
|
201654
201777
|
const du = 1.0 / numInterval;
|
|
201655
|
-
for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++)
|
|
201656
|
-
knots.knots[k] =
|
|
201657
|
-
}
|
|
201778
|
+
for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++)
|
|
201779
|
+
knots.knots[k] = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.interpolate(a0, i * du, a1);
|
|
201658
201780
|
knots.setupFixedValues();
|
|
201659
201781
|
return knots;
|
|
201660
201782
|
}
|
|
201661
201783
|
/**
|
|
201662
201784
|
* Create knot vector with given knot values and degree.
|
|
201663
|
-
* @param knotArray knot values
|
|
201664
|
-
* @param degree degree of polynomial
|
|
201785
|
+
* @param knotArray knot values.
|
|
201786
|
+
* @param degree degree of polynomial.
|
|
201665
201787
|
* @param skipFirstAndLast true to skip copying the first and last knot values.
|
|
201666
201788
|
*/
|
|
201667
201789
|
static create(knotArray, degree, skipFirstAndLast) {
|
|
@@ -201672,29 +201794,34 @@ class KnotVector {
|
|
|
201672
201794
|
}
|
|
201673
201795
|
/**
|
|
201674
201796
|
* Return the average of degree consecutive knots beginning at knotIndex.
|
|
201797
|
+
* * If `knotIndex` is negative, return `leftKnot`.
|
|
201798
|
+
* * If `knotIndex > rightKnotIndex` return `rightKnot`.
|
|
201675
201799
|
*/
|
|
201676
201800
|
grevilleKnot(knotIndex) {
|
|
201677
201801
|
if (knotIndex < 0)
|
|
201678
201802
|
return this.leftKnot;
|
|
201679
201803
|
if (knotIndex > this.rightKnotIndex)
|
|
201680
201804
|
return this.rightKnot;
|
|
201805
|
+
knotIndex = Math.floor(knotIndex);
|
|
201681
201806
|
let sum = 0.0;
|
|
201682
201807
|
for (let i = knotIndex; i < knotIndex + this.degree; i++)
|
|
201683
201808
|
sum += this.knots[i];
|
|
201684
201809
|
return sum / this.degree;
|
|
201685
201810
|
}
|
|
201686
|
-
/** Return an array
|
|
201687
|
-
createBasisArray() {
|
|
201811
|
+
/** Return an array of size `degree + 1`, e.g., to hold the set of relevant basis function values at a parameter. */
|
|
201812
|
+
createBasisArray() {
|
|
201813
|
+
return new Float64Array(this.degree + 1);
|
|
201814
|
+
}
|
|
201688
201815
|
/** Convert localFraction within the interval following an indexed knot to a knot value. */
|
|
201689
201816
|
baseKnotFractionToKnot(knotIndex0, localFraction) {
|
|
201690
201817
|
const knot0 = this.knots[knotIndex0];
|
|
201691
|
-
localFraction =
|
|
201818
|
+
localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(localFraction, 0, 1);
|
|
201692
201819
|
return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);
|
|
201693
201820
|
}
|
|
201694
201821
|
/** Convert localFraction within an indexed bezier span to a knot value. */
|
|
201695
201822
|
spanFractionToKnot(spanIndex, localFraction) {
|
|
201696
201823
|
const k = this.spanIndexToLeftKnotIndex(spanIndex);
|
|
201697
|
-
localFraction =
|
|
201824
|
+
localFraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(localFraction, 0, 1);
|
|
201698
201825
|
return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);
|
|
201699
201826
|
}
|
|
201700
201827
|
/** Convert localFraction within an indexed bezier span to fraction of active knot range. */
|
|
@@ -201704,35 +201831,41 @@ class KnotVector {
|
|
|
201704
201831
|
}
|
|
201705
201832
|
/** Return fraction of active knot range to knot value. */
|
|
201706
201833
|
fractionToKnot(fraction) {
|
|
201707
|
-
fraction =
|
|
201708
|
-
return
|
|
201834
|
+
fraction = _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.clamp(fraction, 0, 1); // B-splines are not extendable
|
|
201835
|
+
return _Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);
|
|
201836
|
+
}
|
|
201837
|
+
isKnotInValidSpan(knotIndex0, u) {
|
|
201838
|
+
const spanIsValid = knotIndex0 >= this.degree - 1 && knotIndex0 + this.degree < this.knots.length;
|
|
201839
|
+
const uIsInSpan = this.knots[knotIndex0] <= u && u <= this.knots[knotIndex0 + 1];
|
|
201840
|
+
return spanIsValid && uIsInSpan;
|
|
201709
201841
|
}
|
|
201710
201842
|
/**
|
|
201711
201843
|
* Evaluate the B-spline basis functions f[] at a parameter u in a knot span.
|
|
201712
201844
|
* * This method implements the Mansfield-Cox-de Boor recurrence relation.
|
|
201713
201845
|
* @param knotIndex0 index of the left knot of the span.
|
|
201714
201846
|
* @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
|
|
201715
|
-
* @param f preallocated output array of order basis function values
|
|
201716
|
-
* @returns true if and only if output array is sufficiently sized
|
|
201847
|
+
* @param f preallocated output array of order basis function values.
|
|
201848
|
+
* @returns true if and only if output array is sufficiently sized.
|
|
201717
201849
|
*/
|
|
201718
201850
|
evaluateBasisFunctions(knotIndex0, u, f) {
|
|
201719
201851
|
if (f.length < this.degree + 1)
|
|
201720
201852
|
return false;
|
|
201853
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
|
|
201721
201854
|
f[0] = 1.0;
|
|
201722
201855
|
if (this.degree < 1)
|
|
201723
201856
|
return true;
|
|
201724
|
-
// direct compute for linear part
|
|
201857
|
+
// direct compute for linear part
|
|
201725
201858
|
const u0 = this.knots[knotIndex0];
|
|
201726
201859
|
const u1 = this.knots[knotIndex0 + 1];
|
|
201727
201860
|
f[1] = (u - u0) / (u1 - u0);
|
|
201728
201861
|
f[0] = 1.0 - f[1];
|
|
201729
201862
|
if (this.degree < 2)
|
|
201730
201863
|
return true;
|
|
201731
|
-
//
|
|
201732
|
-
// one or two values of the basis functions of one less degree from the preceding iteration
|
|
201864
|
+
// each iteration of the outer loop evaluates the basis functions of degree depth+1 using
|
|
201865
|
+
// one or two values of the basis functions of one less degree from the preceding iteration
|
|
201733
201866
|
for (let depth = 1; depth < this.degree; depth++) {
|
|
201734
201867
|
let kLeft = knotIndex0 - depth;
|
|
201735
|
-
let kRight =
|
|
201868
|
+
let kRight = knotIndex0 + 1;
|
|
201736
201869
|
let gCarry = 0.0;
|
|
201737
201870
|
for (let step = 0; step <= depth; step++) {
|
|
201738
201871
|
const tLeft = this.knots[kLeft++];
|
|
@@ -201754,10 +201887,10 @@ class KnotVector {
|
|
|
201754
201887
|
* in a knot span.
|
|
201755
201888
|
* @param knotIndex0 index of the left knot of the span.
|
|
201756
201889
|
* @param u value in the knot span: knot[knotIndex0] <= u <= knot[knotIndex0 + 1].
|
|
201757
|
-
* @param f preallocated output array of order basis function values
|
|
201758
|
-
* @param df preallocated output array of order basis derivative values
|
|
201759
|
-
* @param ddf optional preallocated output array of order basis second derivative values
|
|
201760
|
-
* @returns true if and only if output arrays are sufficiently sized
|
|
201890
|
+
* @param f preallocated output array of order basis function values.
|
|
201891
|
+
* @param df preallocated output array of order basis derivative values.
|
|
201892
|
+
* @param ddf optional preallocated output array of order basis second derivative values.
|
|
201893
|
+
* @returns true if and only if output arrays are sufficiently sized.
|
|
201761
201894
|
*/
|
|
201762
201895
|
evaluateBasisFunctions1(knotIndex0, u, f, df, ddf) {
|
|
201763
201896
|
if (f.length < this.degree + 1)
|
|
@@ -201766,15 +201899,16 @@ class KnotVector {
|
|
|
201766
201899
|
return false;
|
|
201767
201900
|
if (ddf && ddf.length < this.degree + 1)
|
|
201768
201901
|
return false;
|
|
201902
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(() => this.isKnotInValidSpan(knotIndex0, u), "knot is in a valid span");
|
|
201769
201903
|
f[0] = 1.0;
|
|
201770
201904
|
df[0] = 0.0;
|
|
201771
201905
|
if (this.degree < 1)
|
|
201772
201906
|
return true;
|
|
201773
|
-
// direct compute for linear part
|
|
201907
|
+
// direct compute for linear part
|
|
201774
201908
|
const u0 = this.knots[knotIndex0];
|
|
201775
201909
|
const u1 = this.knots[knotIndex0 + 1];
|
|
201776
|
-
// ah = 1/(u1-u0)
|
|
201777
|
-
//
|
|
201910
|
+
// ah = 1/(u1-u0) is the derivative of fraction0
|
|
201911
|
+
// -ah is the derivative of fraction1
|
|
201778
201912
|
let ah = 1.0 / (u1 - u0);
|
|
201779
201913
|
f[1] = (u - u0) * ah;
|
|
201780
201914
|
f[0] = 1.0 - f[1];
|
|
@@ -201793,7 +201927,7 @@ class KnotVector {
|
|
|
201793
201927
|
let dgCarry = 0.0;
|
|
201794
201928
|
let ddgCarry = 0.0;
|
|
201795
201929
|
// f, df, ddf, are each row vectors with product of `step` linear terms.
|
|
201796
|
-
// f is multiplied on the right by matrix V. Each row has 2 nonzero entries (which sum to 1)
|
|
201930
|
+
// 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)
|
|
201797
201931
|
// Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)
|
|
201798
201932
|
// Hence fnew = f * V
|
|
201799
201933
|
// dfnew = df * V + f * dV
|
|
@@ -201815,7 +201949,7 @@ class KnotVector {
|
|
|
201815
201949
|
df[step] = dgCarry + dg0;
|
|
201816
201950
|
gCarry = g1;
|
|
201817
201951
|
dgCarry = dg1;
|
|
201818
|
-
if (ddf) { // do the backward reference to df before rewriting df
|
|
201952
|
+
if (ddf) { // do the backward reference to df before rewriting df
|
|
201819
201953
|
const ddg1 = ddf[step] * fraction + dfSave;
|
|
201820
201954
|
const ddg0 = ddf[step] * fraction1 - dfSave;
|
|
201821
201955
|
ddf[step] = ddgCarry + ddg0;
|
|
@@ -201829,9 +201963,10 @@ class KnotVector {
|
|
|
201829
201963
|
}
|
|
201830
201964
|
return true;
|
|
201831
201965
|
}
|
|
201832
|
-
/**
|
|
201966
|
+
/**
|
|
201967
|
+
* Find the knot span bracketing knots[i] <= u < knots[i+1] and return i.
|
|
201833
201968
|
* * If u has no such bracket, return the smaller index of the closest nontrivial bracket.
|
|
201834
|
-
* @param u value to bracket
|
|
201969
|
+
* @param u value to bracket.
|
|
201835
201970
|
*/
|
|
201836
201971
|
knotToLeftKnotIndex(u) {
|
|
201837
201972
|
for (let i = this.leftKnotIndex; i < this.rightKnotIndex; ++i) {
|
|
@@ -201847,7 +201982,7 @@ class KnotVector {
|
|
|
201847
201982
|
}
|
|
201848
201983
|
/**
|
|
201849
201984
|
* Given a span index, return the index of the knot at its left.
|
|
201850
|
-
* @param spanIndex index of span
|
|
201985
|
+
* @param spanIndex index of span.
|
|
201851
201986
|
*/
|
|
201852
201987
|
spanIndexToLeftKnotIndex(spanIndex) {
|
|
201853
201988
|
const d = this.degree;
|
|
@@ -201862,15 +201997,16 @@ class KnotVector {
|
|
|
201862
201997
|
}
|
|
201863
201998
|
/**
|
|
201864
201999
|
* Given a span index, test if it is within range and has nonzero length.
|
|
201865
|
-
* * note that a false return does not imply there are no more spans.
|
|
202000
|
+
* * note that a false return does not imply there are no more spans. This may be a double knot (zero length span)
|
|
202001
|
+
* followed by more real spans
|
|
201866
202002
|
* @param spanIndex index of span to test.
|
|
201867
202003
|
*/
|
|
201868
202004
|
isIndexOfRealSpan(spanIndex) {
|
|
201869
202005
|
if (spanIndex >= 0 && spanIndex < this.numSpans)
|
|
201870
|
-
return !
|
|
202006
|
+
return !_Geometry__WEBPACK_IMPORTED_MODULE_2__.Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));
|
|
201871
202007
|
return false;
|
|
201872
202008
|
}
|
|
201873
|
-
/** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths
|
|
202009
|
+
/** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths are reversed. */
|
|
201874
202010
|
reflectKnots() {
|
|
201875
202011
|
const a = this.leftKnot;
|
|
201876
202012
|
const b = this.rightKnot;
|
|
@@ -209201,6 +209337,8 @@ class Arc3d extends _CurvePrimitive__WEBPACK_IMPORTED_MODULE_1__.CurvePrimitive
|
|
|
209201
209337
|
}
|
|
209202
209338
|
/**
|
|
209203
209339
|
* Construct a circular arc chain approximation to the instance elliptical arc.
|
|
209340
|
+
* * Visualization can be found at https://www.itwinjs.org/sandbox/SaeedTorabi/ArcApproximationGeneral and
|
|
209341
|
+
* https://www.itwinjs.org/sandbox/SaeedTorabi/ArcApproximation
|
|
209204
209342
|
* @param options bundle of options for sampling an elliptical arc (use default options if undefined).
|
|
209205
209343
|
* @returns the approximating curve chain, the circular instance, or undefined if construction fails.
|
|
209206
209344
|
*/
|
|
@@ -243172,9 +243310,9 @@ class Point3dArray {
|
|
|
243172
243310
|
return result;
|
|
243173
243311
|
}
|
|
243174
243312
|
/**
|
|
243175
|
-
*
|
|
243176
|
-
* @param data simple array of numbers
|
|
243177
|
-
* @param numPerBlock number of values in each block at first level down
|
|
243313
|
+
* Return a 2-dimensional array containing all the values of `data` in arrays of numPerBlock
|
|
243314
|
+
* @param data simple array of numbers.
|
|
243315
|
+
* @param numPerBlock number of values in each block at first level down.
|
|
243178
243316
|
*/
|
|
243179
243317
|
static unpackNumbersToNestedArrays(data, numPerBlock) {
|
|
243180
243318
|
const result = [];
|
|
@@ -248444,8 +248582,8 @@ class Ray3d {
|
|
|
248444
248582
|
* @param vertex2 third vertex of the triangle
|
|
248445
248583
|
* @param distanceTol optional tolerance used to check if ray is parallel to the triangle or if we have line
|
|
248446
248584
|
* intersection but not ray intersection (if tolerance is not provided, Geometry.smallMetricDistance is used)
|
|
248447
|
-
* @param parameterTol optional tolerance used to
|
|
248448
|
-
*
|
|
248585
|
+
* @param parameterTol optional tolerance used to allow intersections just beyond an edge/vertex in barycentric
|
|
248586
|
+
* coordinate space (if tolerance is not provided, Geometry.smallFloatingPoint is used)
|
|
248449
248587
|
* @param result optional pre-allocated object to fill and return
|
|
248450
248588
|
* @returns the intersection point if ray intersects the triangle. Otherwise, return undefined.
|
|
248451
248589
|
*/
|
|
@@ -248501,13 +248639,13 @@ class Ray3d {
|
|
|
248501
248639
|
const s = Ray3d._workVector3 = _Point3dVector3d__WEBPACK_IMPORTED_MODULE_0__.Vector3d.createStartEnd(vertex0, this.origin, Ray3d._workVector3);
|
|
248502
248640
|
let u = f * s.dotProduct(h);
|
|
248503
248641
|
if (u < 0.0) {
|
|
248504
|
-
if (u
|
|
248642
|
+
if (u >= -parameterTol)
|
|
248505
248643
|
u = 0.0;
|
|
248506
248644
|
else
|
|
248507
248645
|
return undefined; // ray does not intersect the triangle
|
|
248508
248646
|
}
|
|
248509
248647
|
else if (u > 1.0) {
|
|
248510
|
-
if (u
|
|
248648
|
+
if (u <= 1.0 + parameterTol)
|
|
248511
248649
|
u = 1.0;
|
|
248512
248650
|
else
|
|
248513
248651
|
return undefined; // ray does not intersect the triangle
|
|
@@ -248515,20 +248653,17 @@ class Ray3d {
|
|
|
248515
248653
|
const q = Ray3d._workVector4 = s.crossProduct(edge1, Ray3d._workVector4);
|
|
248516
248654
|
let v = f * this.direction.dotProduct(q);
|
|
248517
248655
|
if (v < 0.0) {
|
|
248518
|
-
if (v
|
|
248656
|
+
if (v >= -parameterTol)
|
|
248519
248657
|
v = 0.0;
|
|
248520
248658
|
else
|
|
248521
248659
|
return undefined; // ray does not intersect the triangle
|
|
248522
248660
|
}
|
|
248523
|
-
else if (u + v > 1.0) {
|
|
248524
|
-
|
|
248525
|
-
v = 1.0 - u;
|
|
248526
|
-
else
|
|
248527
|
-
return undefined; // ray does not intersect the triangle
|
|
248661
|
+
else if (u + v > 1.0 + parameterTol) {
|
|
248662
|
+
return undefined; // ray does not intersect the triangle
|
|
248528
248663
|
}
|
|
248529
248664
|
// at this stage, we know the line (parameterized as the ray) intersects the triangle
|
|
248530
248665
|
const t = f * edge2.dotProduct(q);
|
|
248531
|
-
if (t
|
|
248666
|
+
if (t < -distanceTol) // line intersection but not ray intersection
|
|
248532
248667
|
return undefined;
|
|
248533
248668
|
return this.origin.plusScaled(this.direction, t, result); // ray intersection
|
|
248534
248669
|
}
|
|
@@ -313113,7 +313248,7 @@ class TestContext {
|
|
|
313113
313248
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
313114
313249
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
313115
313250
|
await core_frontend_1.NoRenderApp.startup({
|
|
313116
|
-
applicationVersion: "5.0.0-dev.
|
|
313251
|
+
applicationVersion: "5.0.0-dev.64",
|
|
313117
313252
|
applicationId: this.settings.gprid,
|
|
313118
313253
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
313119
313254
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -339141,7 +339276,7 @@ function __rewriteRelativeImportExtension(path, preserveJsx) {
|
|
|
339141
339276
|
/***/ ((module) => {
|
|
339142
339277
|
|
|
339143
339278
|
"use strict";
|
|
339144
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.0.0-dev.
|
|
339279
|
+
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"}}');
|
|
339145
339280
|
|
|
339146
339281
|
/***/ }),
|
|
339147
339282
|
|