@itwin/core-geometry 3.0.0-dev.141 → 3.0.0-dev.146
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/bspline/BSplineCurve.d.ts +4 -0
- package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/cjs/bspline/BSplineCurve.js +39 -0
- package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
- package/lib/cjs/bspline/KnotVector.d.ts +2 -2
- package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
- package/lib/cjs/bspline/KnotVector.js +2 -2
- package/lib/cjs/bspline/KnotVector.js.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/cjs/geometry3d/FrameBuilder.js +9 -2
- package/lib/cjs/geometry3d/FrameBuilder.js.map +1 -1
- package/lib/esm/bspline/BSplineCurve.d.ts +4 -0
- package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
- package/lib/esm/bspline/BSplineCurve.js +39 -0
- package/lib/esm/bspline/BSplineCurve.js.map +1 -1
- package/lib/esm/bspline/KnotVector.d.ts +2 -2
- package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
- package/lib/esm/bspline/KnotVector.js +2 -2
- package/lib/esm/bspline/KnotVector.js.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.d.ts.map +1 -1
- package/lib/esm/geometry3d/FrameBuilder.js +9 -2
- package/lib/esm/geometry3d/FrameBuilder.js.map +1 -1
- package/package.json +4 -4
|
@@ -200,6 +200,10 @@ export declare class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
200
200
|
copyKnots(includeExtraEndKnot: boolean): number[];
|
|
201
201
|
/** Create a bspline with uniform knots. */
|
|
202
202
|
static createUniformKnots(poles: Point3d[] | Float64Array | GrowableXYZArray, order: number): BSplineCurve3d | undefined;
|
|
203
|
+
/** Create a smoothly closed B-spline curve with uniform knots.
|
|
204
|
+
* Note that the curve does not start at the first pole.
|
|
205
|
+
*/
|
|
206
|
+
static createPeriodicUniformKnots(poles: Point3d[] | Float64Array | GrowableXYZArray, order: number): BSplineCurve3d | undefined;
|
|
203
207
|
/**
|
|
204
208
|
* Create a C2 cubic B-spline curve that interpolates the given points and optional end tangents.
|
|
205
209
|
* @param options collection of points and end conditions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BSplineCurve.d.ts","sourceRoot":"","sources":["../../../src/bspline/BSplineCurve.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAqB,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAY,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAE,OAAO,EAAY,MAAM,+BAA+B,CAAC;AAElE,OAAO,EAAW,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAGrD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OA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Ae,GAAG,eAAe,GAAG,SAAS;IAMlI;;;;OAIG;IACI,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,eAAe,GAAG,SAAS;IAazG;;;;OAIG;IACI,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,GAAG,cAAc,GAAG,SAAS;IAczG;;OAEG;IACa,YAAY,CAAC,KAAK,EAAE,eAAe;IAGnD,iFAAiF;IAC1E,yBAAyB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG;IAG/D;;;;;OAKG;IACI,WAAW,CAAC,aAAa,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI;CAYxE"}
|
|
@@ -323,6 +323,45 @@ class BSplineCurve3d extends BSplineCurve3dBase {
|
|
|
323
323
|
}
|
|
324
324
|
return curve;
|
|
325
325
|
}
|
|
326
|
+
/** Create a smoothly closed B-spline curve with uniform knots.
|
|
327
|
+
* Note that the curve does not start at the first pole.
|
|
328
|
+
*/
|
|
329
|
+
static createPeriodicUniformKnots(poles, order) {
|
|
330
|
+
const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;
|
|
331
|
+
if (order < 1 || numPoles < order)
|
|
332
|
+
return undefined;
|
|
333
|
+
const degree = order - 1;
|
|
334
|
+
const numIntervals = numPoles;
|
|
335
|
+
const knots = KnotVector_1.KnotVector.createUniformWrapped(numIntervals, degree, 0.0, 1.0);
|
|
336
|
+
knots.wrappable = KnotVector_1.BSplineWrapMode.OpenByAddingControlPoints;
|
|
337
|
+
// append degree wraparound poles
|
|
338
|
+
const curve = new BSplineCurve3d(numPoles + degree, order, knots);
|
|
339
|
+
if (poles instanceof Float64Array) {
|
|
340
|
+
for (let i = 0; i < 3 * numPoles; i++)
|
|
341
|
+
curve._bcurve.packedData[i] = poles[i];
|
|
342
|
+
for (let i = 0; i < 3 * degree; i++)
|
|
343
|
+
curve._bcurve.packedData[3 * numPoles + i] = poles[i];
|
|
344
|
+
}
|
|
345
|
+
else if (poles instanceof GrowableXYZArray_1.GrowableXYZArray) {
|
|
346
|
+
curve._bcurve.packedData = poles.float64Data().slice(0, 3 * numPoles);
|
|
347
|
+
for (let i = 0; i < 3 * degree; i++)
|
|
348
|
+
curve._bcurve.packedData[3 * numPoles + i] = poles.float64Data()[i];
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
let i = 0;
|
|
352
|
+
for (const p of poles) {
|
|
353
|
+
curve._bcurve.packedData[i++] = p.x;
|
|
354
|
+
curve._bcurve.packedData[i++] = p.y;
|
|
355
|
+
curve._bcurve.packedData[i++] = p.z;
|
|
356
|
+
}
|
|
357
|
+
for (let j = 0; j < degree; j++) {
|
|
358
|
+
curve._bcurve.packedData[i++] = poles[j].x;
|
|
359
|
+
curve._bcurve.packedData[i++] = poles[j].y;
|
|
360
|
+
curve._bcurve.packedData[i++] = poles[j].z;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
return curve;
|
|
364
|
+
}
|
|
326
365
|
/**
|
|
327
366
|
* Create a C2 cubic B-spline curve that interpolates the given points and optional end tangents.
|
|
328
367
|
* @param options collection of points and end conditions.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BSplineCurve.js","sourceRoot":"","sources":["../../../src/bspline/BSplineCurve.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,sEAAsF;AACtF,4DAAyD;AAEzD,kEAA+D;AAE/D,0CAA+D;AAE/D,qEAAkE;AAElE,uFAAoF;AACpF,8EAA8E;AAC9E,mEAAkE;AAClE,6DAA0D;AAC1D,+CAAuD;AACvD,+CAA4C;AAE5C,mDAAgD;AAChD,qEAAiE;AAEjE,6CAA0C;AAC1C,mDAAgD;AAChD,qDAAkD;AAElD,+CAA4C;AAC5C,uDAAoD;AAEpD,6CAA2D;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC,CAAC;SACvE;IACH,CAAC;CAEF;AA/WD,wCA+WC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\nimport { CurveIntervalRole, CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty, no-console*/\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { UnivariateBezier } from \"../numerics/BezierPolynomials\";\r\nimport { AkimaCurve3dOptions } from \"./AkimaCurve3d\";\r\nimport { Bezier1dNd } from \"./Bezier1dNd\";\r\nimport { BezierCurve3d } from \"./BezierCurve3d\";\r\nimport { BezierCurve3dH } from \"./BezierCurve3dH\";\r\nimport { BezierCurveBase } from \"./BezierCurveBase\";\r\nimport { BSpline1dNd } from \"./BSpline1dNd\";\r\nimport { BSplineCurveOps } from \"./BSplineCurveOps\";\r\nimport { InterpolationCurve3dOptions } from \"./InterpolationCurve3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/**\r\n * Base class for BSplineCurve3d and BSplineCurve3dH.\r\n * * A bspline curve consists of a set of knots and a set of poles.\r\n * * The bspline curve is a function of the independent \"knot axis\" variable\r\n * * The curve \"follows\" the poles loosely.\r\n * * The is a set of polynomial spans.\r\n * * The polynomial spans all have same `degree`.\r\n * * Within each span, the polynomial of that `degree` is controlled by `order = degree + 1` contiguous points called poles.\r\n * * The is a strict relationship between knot and poles counts: `numPoles + order = numKnots + 2'\r\n * * The number of spans is `numSpan = numPoles - degree`\r\n * * For a given `spanIndex`:\r\n * * The `order` poles begin at index `spanIndex`.\r\n * * The `2*order` knots begin as span index\r\n * * The knot interval for this span is from `knot[degree+span-1] to knot[degree+span]`\r\n * * The active part of the knot axis is `knot[degree-1] < knot < knot[degree-1 + numSpan]` i.e. `knot[degree-1] < knot < knot[numPoles]\r\n *\r\n * Nearly all bsplines are \"clamped \".\r\n * * Clamping make the curve pass through its first and last poles, with tangents directed along the first and last edges of the control polygon.\r\n * * The knots for a clamped bspline have `degree` copies of the lowest knot value and `degree` copies of the highest knot value.\r\n * * For instance, the knot vector `[0,0,0,1,2,3,3,3]\r\n * * can be evaluated from `0<=knot<=3`\r\n * * has 3 spans: 0 to 1, 1 to 2, 2 to 3\r\n * * has 6 poles\r\n * * passes through its first and last poles.\r\n * * `create` methods may allow classic convention that has an extra knot at the beginning and end of the knot vector.\r\n * * The extra knots (first and last) were never referenced by the bspline recurrence relations.\r\n * * When the `create` methods recognize the classic setup (`numPoles + order = numKnots`), the extra knot is not saved with the BSplineCurve3dBase knots.\r\n *\r\n * * The weighted variant has the problem that CurvePrimitive 3d typing does not allow undefined result where Point4d has zero weight.\r\n * * The convention for these is to return 000 in such places.\r\n *\r\n * * Note the class relationships:\r\n * * BSpline1dNd knows the bspline recurrence relations for control points (poles) with no physical meaning.\r\n * * BsplineCurve3dBase owns a protected BSpline1dNd\r\n * * BsplineCurve3dBase is derived from CurvePrimitive, which creates obligation to act as a 3D curve, such as\r\n * * evaluate fraction to point and derivatives wrt fraction\r\n * * compute intersection with plane\r\n * * BSplineCurve3d and BSplineCurve3dH have variant logic driven by whether or not there are \"weights\" on the poles.\r\n * * For `BSplineCurve3d`, the xyz value of pole calculations are \"final\" values for 3d evaluation\r\n * * For `BSplineCurve3dH`, various `BSpline1dNd` results with xyzw have to be normalized back to xyz.\r\n *\r\n * * These classes do not support \"periodic\" variants.\r\n * * Periodic curves need to have certain leading knots and poles replicated at the end\r\n * @public\r\n */\r\nexport abstract class BSplineCurve3dBase extends CurvePrimitive {\r\n /** String name for schema properties */\r\n public readonly curvePrimitiveType = \"bsplineCurve\";\r\n\r\n /** The underlying blocked-pole spline, with simple x,y,z poles */\r\n protected _bcurve: BSpline1dNd;\r\n private _definitionData?: any;\r\n public set definitionData(data: any) { this._definitionData = data; }\r\n public get definitionData(): any { return this._definitionData; }\r\n protected constructor(poleDimension: number, numPoles: number, order: number, knots: KnotVector) {\r\n super();\r\n this._bcurve = BSpline1dNd.create(numPoles, poleDimension, order, knots) as BSpline1dNd;\r\n }\r\n /** Return the degree (one less than the order) of the curve */\r\n public get degree(): number { return this._bcurve.degree; }\r\n /** Return the order (one more than degree) of the curve */\r\n public get order(): number { return this._bcurve.order; }\r\n /** Return the number of bezier spans in the curve. Note that this number includes the number of null spans at repeated knows */\r\n public get numSpan(): number { return this._bcurve.numSpan; }\r\n /** Return the number of poles */\r\n public get numPoles(): number { return this._bcurve.numPoles; }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }\r\n\r\n /**\r\n * Set the flag indicating the bspline might be suitable for having wrapped \"closed\" interpretation.\r\n */\r\n public setWrappable(value: BSplineWrapMode) {\r\n this._bcurve.knots.wrappable = value;\r\n }\r\n\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public abstract evaluatePointInSpan(spanIndex: number, spanFraction: number, result?: Point3d): Point3d;\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public abstract evaluatePointAndDerivativeInSpan(spanIndex: number, spanFraction: number, result?: Ray3d): Ray3d;\r\n /** Evaluate xyz at a position given by knot. */\r\n public abstract knotToPoint(knot: number, result?: Point3d): Point3d;\r\n /** Evaluate xyz and derivative at position given by a knot value. */\r\n public abstract knotToPointAndDerivative(knot: number, result?: Ray3d): Ray3d;\r\n /** Evaluate xyz and 2 derivatives at position given by a knot value. */\r\n public abstract knotToPointAnd2Derivatives(knot: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors;\r\n /** Evaluate the curve point at `fraction` */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);\r\n }\r\n /** Construct a ray with\r\n * * origin at the fractional position along the arc\r\n * * direction is the first derivative, i.e. tangent along the curve\r\n */\r\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAndDerivative(knot, result);\r\n result.direction.scaleInPlace(this._bcurve.knots.knotLength01);\r\n return result;\r\n }\r\n\r\n /** Construct a plane with\r\n * * origin at the fractional position along the arc\r\n * * x axis is the first derivative, i.e. tangent along the curve\r\n * * y axis is the second derivative\r\n */\r\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAnd2Derivatives(knot, result);\r\n const a = this._bcurve.knots.knotLength01;\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n return result;\r\n }\r\n /**\r\n * Return the start point of the curve.\r\n */\r\n public override startPoint(): Point3d { return this.evaluatePointInSpan(0, 0.0); }\r\n /**\r\n * Return the end point of the curve\r\n */\r\n public override endPoint(): Point3d { return this.evaluatePointInSpan(this.numSpan - 1, 1.0); }\r\n /** Reverse the curve in place.\r\n * * Poles are reversed\r\n * * knot values are mirrored around the middle of the\r\n */\r\n public reverseInPlace(): void { this._bcurve.reverseInPlace(); }\r\n /**\r\n * Return an array with this curve's bezier fragments.\r\n */\r\n public collectBezierSpans(prefer3dH: boolean): BezierCurveBase[] {\r\n const result: BezierCurveBase[] = [];\r\n const numSpans = this.numSpan;\r\n for (let i = 0; i < numSpans; i++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(i)) {\r\n const span = this.getSaturatedBezierSpan3dOr3dH(i, prefer3dH);\r\n if (span)\r\n result.push(span);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to the instance type and the prefer3dH parameter.\r\n * @param spanIndex\r\n * @param prefer3dH true to force promotion to homogeneous.\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public abstract getSaturatedBezierSpan3dOr3dH(spanIndex: number, prefer3dH: boolean, result?: BezierCurveBase): BezierCurveBase | undefined;\r\n /** Return a specified pole as a Point4d.\r\n * * BSplineCurve3d appends weight 1 to its xyz\r\n * * BSplineCurve3dH with pole whose \"normalized\" point is (x,y,z) but has weight w returns its weighted (wx,wy,wz,w)\r\n */\r\n public abstract getPolePoint4d(poleIndex: number, result?: Point4d): Point4d | undefined;\r\n /** Return a specified pole as a Point3d\r\n * * BSplineCurve3d returns its simple xyz\r\n * * BSplineCurve3dH attempts to normalize its (wx,wy,wz,w) back to (x,y,z), and returns undefined if weight is zero.\r\n * @param poleIndex\r\n * @param result optional result\r\n */\r\n public abstract getPolePoint3d(poleIndex: number, result?: Point3d): Point3d | undefined;\r\n\r\n /** Given a pole index, return the starting index for the contiguous array. */\r\n public poleIndexToDataIndex(poleIndex: number): number | undefined {\r\n if (poleIndex >= 0 && poleIndex < this.numPoles)\r\n return poleIndex * this._bcurve.poleLength;\r\n return undefined;\r\n }\r\n\r\n /** Search for the curve point that is closest to the spacePoint.\r\n *\r\n * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.\r\n * * Since CurvePrimitive should always have start and end available as candidate points, this method should always succeed\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve (if possible)\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public override closestPoint(spacePoint: Point3d, _extend: boolean): CurveLocationDetail | undefined {\r\n const point = this.fractionToPoint(0);\r\n const result = CurveLocationDetail.createCurveFractionPointDistance(this, 0.0, point, point.distance(spacePoint));\r\n this.fractionToPoint(1.0, point);\r\n result.updateIfCloserCurveFractionPointDistance(this, 1.0, point, spacePoint.distance(point));\r\n\r\n let span: BezierCurve3dH | undefined;\r\n const numSpans = this.numSpan;\r\n for (let i = 0; i < numSpans; i++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(i)) {\r\n span = this.getSaturatedBezierSpan3dOr3dH(i, true, span) as BezierCurve3dH;\r\n if (span) {\r\n if (span.updateClosestPointByTruePerpendicular(spacePoint, result)) {\r\n // the detail records the span bezier -- promote it to the parent curve . ..\r\n result.curve = this;\r\n result.fraction = span.fractionToParentFraction(result.fraction);\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n /** Implement `CurvePrimitive.appendPlaneIntersections`\r\n * @param plane A plane (e.g. specific type Plane3dByOriginAndUnitNormal or Point4d)\r\n * @param result growing array of plane intersections\r\n * @return number of intersections appended to the array.\r\n */\r\n public override appendPlaneIntersectionPoints(plane: PlaneAltitudeEvaluator, result: CurveLocationDetail[]): number {\r\n const numPole = this.numPoles;\r\n const order = this.order;\r\n const allCoffs = new Float64Array(numPole);\r\n const numSpan = this.numSpan;\r\n const point4d = Point4d.create();\r\n // compute all pole altitudes from the plane\r\n const minMax = Range1d.createNull();\r\n // Put the altitudes of all the bspline poles in one array.\r\n for (let i = 0; i < numPole; i++) {\r\n allCoffs[i] = plane.weightedAltitude(this.getPolePoint4d(i, point4d)!);\r\n minMax.extendX(allCoffs[i]);\r\n }\r\n // A univariate bspline through the altitude poles gives altitude as function of the bspline knot.\r\n // The (bspline) altitude function for each span is `order` consecutive altitudes.\r\n // If those altitudes bracket zero, the span may potentially have a crossing.\r\n // When that occurs,\r\n let univariateBezier: UnivariateBezier | undefined;\r\n let numFound = 0;\r\n let previousFraction = -1000.0;\r\n if (minMax.containsX(0.0)) {\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals.\r\n // outer range test ...\r\n minMax.setNull();\r\n minMax.extendArraySubset(allCoffs, spanIndex, order);\r\n if (minMax.containsX(0.0)) {\r\n // pack the bspline support into a univariate bezier ...\r\n univariateBezier = UnivariateBezier.createArraySubset(allCoffs, spanIndex, order, univariateBezier)!;\r\n // saturate and solve the bezier\r\n Bezier1dNd.saturate1dInPlace(univariateBezier.coffs, this._bcurve.knots, spanIndex);\r\n const roots = univariateBezier.roots(0.0, true);\r\n if (roots) {\r\n for (const spanFraction of roots) {\r\n // promote each local bezier fraction to global fraction.\r\n // save the curve evaluation at that fraction.\r\n numFound++;\r\n const fraction = this._bcurve.knots.spanFractionToFraction(spanIndex, spanFraction);\r\n if (!Geometry.isAlmostEqualNumber(fraction, previousFraction)) {\r\n const detail = CurveLocationDetail.createCurveEvaluatedFraction(this, fraction);\r\n detail.intervalRole = CurveIntervalRole.isolated;\r\n result.push(detail);\r\n previousFraction = fraction;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return numFound;\r\n }\r\n\r\n}\r\n/**\r\n * A BSplineCurve3d is a bspline curve whose poles are Point3d.\r\n * See BSplineCurve3dBase for description of knots, order, degree.\r\n * @public\r\n */\r\nexport class BSplineCurve3d extends BSplineCurve3dBase {\r\n\r\n private _workBezier?: BezierCurve3dH;\r\n private initializeWorkBezier(): BezierCurve3dH {\r\n if (this._workBezier === undefined)\r\n this._workBezier = BezierCurve3dH.createOrder(this.order);\r\n return this._workBezier;\r\n }\r\n /** test of `other` is an instance of BSplineCurve3d */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof BSplineCurve3d; }\r\n /** Apply `transform` to the poles. */\r\n public tryTransformInPlace(transform: Transform): boolean { Point3dArray.multiplyInPlace(transform, this._bcurve.packedData); return true; }\r\n /** Get a pole as simple Point3d. */\r\n public getPolePoint3d(poleIndex: number, result?: Point3d): Point3d | undefined {\r\n const k = this.poleIndexToDataIndex(poleIndex);\r\n if (k !== undefined) {\r\n const data = this._bcurve.packedData;\r\n return Point3d.create(data[k], data[k + 1], data[k + 2], result);\r\n }\r\n return undefined;\r\n }\r\n /** Get a pole as Point4d with weight 1 */\r\n public getPolePoint4d(poleIndex: number, result?: Point4d): Point4d | undefined {\r\n const k = this.poleIndexToDataIndex(poleIndex);\r\n if (k !== undefined) {\r\n const data = this._bcurve.packedData;\r\n return Point4d.create(data[k], data[k + 1], data[k + 2], 1.0, result);\r\n }\r\n return undefined;\r\n }\r\n /** Convert `spanIndex` and `localFraction` to a knot. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this._bcurve.spanFractionToKnot(span, localFraction);\r\n }\r\n private constructor(numPoles: number, order: number, knots: KnotVector) {\r\n super(3, numPoles, order, knots);\r\n }\r\n /** Return a simple array of arrays with the control points as `[[x,y,z],[x,y,z],..]` */\r\n public copyPoints(): any[] { return Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3); }\r\n /** Return a simple array of the control points coordinates */\r\n public copyPointsFloat64Array(): Float64Array { return this._bcurve.packedData.slice(); }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public override copyKnots(includeExtraEndKnot: boolean): number[] { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }\r\n\r\n /** Create a bspline with uniform knots. */\r\n public static createUniformKnots(poles: Point3d[] | Float64Array | GrowableXYZArray, order: number): BSplineCurve3d | undefined {\r\n const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;\r\n if (order < 1 || numPoles < order)\r\n return undefined;\r\n const knots = KnotVector.createUniformClamped(numPoles, order - 1, 0.0, 1.0);\r\n const curve = new BSplineCurve3d(numPoles, order, knots);\r\n if (poles instanceof Float64Array) {\r\n for (let i = 0; i < 3 * numPoles; i++)\r\n curve._bcurve.packedData[i] = poles[i];\r\n } else if (poles instanceof GrowableXYZArray) {\r\n curve._bcurve.packedData = poles.float64Data().slice(0, 3 * numPoles);\r\n } else {\r\n let i = 0;\r\n for (const p of poles) { curve._bcurve.packedData[i++] = p.x; curve._bcurve.packedData[i++] = p.y; curve._bcurve.packedData[i++] = p.z; }\r\n }\r\n return curve;\r\n }\r\n\r\n /**\r\n * Create a C2 cubic B-spline curve that interpolates the given points and optional end tangents.\r\n * @param options collection of points and end conditions.\r\n */\r\n public static createFromInterpolationCurve3dOptions(options: InterpolationCurve3dOptions): BSplineCurve3d | undefined {\r\n return BSplineCurveOps.createThroughPointsC2Cubic(options);\r\n }\r\n\r\n /**\r\n *\r\n * @param options collection of points and end conditions.\r\n */\r\n public static createFromAkimaCurve3dOptions(options: AkimaCurve3dOptions): BSplineCurve3d | undefined {\r\n return BSplineCurveOps.createThroughPoints(options.fitPoints, 4); // temporary\r\n }\r\n\r\n /** Create a bspline with given knots.\r\n *\r\n * * Two count conditions are recognized:\r\n *\r\n * ** If poleArray.length + order == knotArray.length, the first and last are assumed to be the\r\n * extraneous knots of classic clamping.\r\n * ** If poleArray.length + order == knotArray.length + 2, the knots are in modern form.\r\n *\r\n */\r\n public static create(poleArray: Float64Array | Point3d[], knotArray: Float64Array | number[], order: number): BSplineCurve3d | undefined {\r\n let numPoles = poleArray.length;\r\n if (poleArray instanceof Float64Array) {\r\n numPoles /= 3; // blocked as xyz\r\n }\r\n const numKnots = knotArray.length;\r\n // shift knots-of-interest limits for overclamped case ...\r\n const skipFirstAndLast = (numPoles + order === numKnots);\r\n if (order < 1 || numPoles < order)\r\n return undefined;\r\n const knots = KnotVector.create(knotArray, order - 1, skipFirstAndLast);\r\n const curve = new BSplineCurve3d(numPoles, order, knots);\r\n if (poleArray instanceof Float64Array) {\r\n let i = 0;\r\n for (const coordinate of poleArray) { curve._bcurve.packedData[i++] = coordinate; }\r\n } else {\r\n let i = 0;\r\n for (const p of poleArray) { curve._bcurve.packedData[i++] = p.x; curve._bcurve.packedData[i++] = p.y; curve._bcurve.packedData[i++] = p.z; }\r\n }\r\n return curve;\r\n }\r\n /** Return a deep clone */\r\n public clone(): BSplineCurve3d {\r\n const knotVector1 = this._bcurve.knots.clone();\r\n const curve1 = new BSplineCurve3d(this.numPoles, this.order, knotVector1);\r\n curve1._bcurve.packedData = this._bcurve.packedData.slice();\r\n return curve1;\r\n }\r\n /** Return a transformed deep clone. */\r\n public cloneTransformed(transform: Transform): BSplineCurve3d {\r\n const curve1 = this.clone();\r\n curve1.tryTransformInPlace(transform);\r\n return curve1;\r\n }\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public evaluatePointInSpan(spanIndex: number, spanFraction: number): Point3d {\r\n this._bcurve.evaluateBuffersInSpan(spanIndex, spanFraction);\r\n return Point3d.createFrom(this._bcurve.poleBuffer);\r\n }\r\n /** Evaluate point and derivative vector at a position given by fractional position within a span.\r\n * * The derivative is with respect to the span fraction (NOT scaled to either global fraction or knot)\r\n */\r\n public evaluatePointAndDerivativeInSpan(spanIndex: number, spanFraction: number): Ray3d {\r\n this._bcurve.evaluateBuffersInSpan1(spanIndex, spanFraction);\r\n return Ray3d.createCapture(\r\n Point3d.createFrom(this._bcurve.poleBuffer),\r\n Vector3d.createFrom(this._bcurve.poleBuffer1));\r\n }\r\n\r\n /** Evaluate at a position given by a knot value. */\r\n public knotToPoint(u: number, result?: Point3d): Point3d {\r\n this._bcurve.evaluateBuffersAtKnot(u);\r\n return Point3d.createFrom(this._bcurve.poleBuffer, result);\r\n }\r\n /** Evaluate at a position given by a knot value. */\r\n public knotToPointAndDerivative(u: number, result?: Ray3d): Ray3d {\r\n this._bcurve.evaluateBuffersAtKnot(u, 1);\r\n if (!result) return Ray3d.createCapture(\r\n Point3d.createFrom(this._bcurve.poleBuffer),\r\n Vector3d.createFrom(this._bcurve.poleBuffer1));\r\n result.origin.setFrom(this._bcurve.poleBuffer);\r\n result.direction.setFrom(this._bcurve.poleBuffer1);\r\n return result;\r\n }\r\n\r\n /** Evaluate at a position given by a knot value. Return point with 2 derivatives. */\r\n public knotToPointAnd2Derivatives(u: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n this._bcurve.evaluateBuffersAtKnot(u, 2);\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\r\n this._bcurve.poleBuffer[0], this._bcurve.poleBuffer[1], this._bcurve.poleBuffer[2],\r\n this._bcurve.poleBuffer1[0], this._bcurve.poleBuffer1[1], this._bcurve.poleBuffer1[2],\r\n this._bcurve.poleBuffer2[0], this._bcurve.poleBuffer2[1], this._bcurve.poleBuffer2[2], result);\r\n }\r\n /** Evaluate the curve point at a fractional of the entire knot range. */\r\n public override fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);\r\n }\r\n\r\n /** Evaluate the curve point at a fractional of the entire knot range. */\r\n public override fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAndDerivative(knot, result);\r\n result.direction.scaleInPlace(this._bcurve.knots.knotLength01);\r\n return result;\r\n }\r\n\r\n /** Construct a plane with\r\n * * origin at the fractional position along the arc\r\n * * x axis is the first derivative, i.e. tangent along the arc\r\n * * y axis is the second derivative, i.e. in the plane and on the center side of the tangent.\r\n * If the arc is circular, the second derivative is directly towards the center\r\n */\r\n public override fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAnd2Derivatives(knot, result);\r\n const a = this._bcurve.knots.knotLength01;\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n return result;\r\n }\r\n /** test if almost the same curve as `other` */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof BSplineCurve3d) {\r\n return this._bcurve.knots.isAlmostEqual(other._bcurve.knots)\r\n && Point3dArray.isAlmostEqual(this._bcurve.packedData, other._bcurve.packedData);\r\n }\r\n return false;\r\n }\r\n /** test if this curve is entirely within plane. */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return Point3dArray.isCloseToPlane(this._bcurve.packedData, plane);\r\n }\r\n /** Return the control polygon length as approximation (always overestimate) of the curve length. */\r\n public quickLength(): number { return Point3dArray.sumEdgeLengths(this._bcurve.packedData); }\r\n /** Emit beziers or strokes (selected by the stroke options) to the handler. */\r\n public emitStrokableParts(handler: IStrokeHandler, options?: StrokeOptions): void {\r\n const needBeziers = handler.announceBezierCurve !== undefined;\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n let numStrokes;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dOr3dH(spanIndex, false, workBezier);\r\n if (bezier) {\r\n numStrokes = bezier.computeStrokeCountForOptions(options);\r\n if (needBeziers) {\r\n handler.announceBezierCurve!(bezier, numStrokes, this,\r\n spanIndex,\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0),\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));\r\n\r\n } else {\r\n handler.announceIntervalForUniformStepStrokes(this, numStrokes,\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0),\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Assess length and turn to determine a stroke count.\r\n * @param options stroke options structure.\r\n */\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n let numStroke = 0;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier)\r\n numStroke += bezier.computeStrokeCountForOptions(options);\r\n }\r\n return numStroke;\r\n }\r\n /**\r\n * Compute individual segment stroke counts. Attach in a StrokeCountMap.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap evolving parent map.\r\n * @alpha\r\n */\r\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n const myData = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap, []);\r\n\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier) {\r\n const segmentLength = workBezier.curveLength();\r\n const numStrokeOnSegment = workBezier.computeStrokeCountForOptions(options);\r\n myData.addToCountAndLength(numStrokeOnSegment, segmentLength);\r\n }\r\n }\r\n CurvePrimitive.installStrokeCountMap(this, myData, parentStrokeMap);\r\n }\r\n /** Append strokes to a linestring. */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier)\r\n bezier.emitStrokes(dest, options);\r\n }\r\n }\r\n /**\r\n * Test knots, control points, and wrappable flag to see if all agree for a possible wrapping.\r\n * @returns the manner of closing. Se BSplineWrapMode for particulars of each mode.\r\n *\r\n */\r\n public get isClosable(): BSplineWrapMode {\r\n const mode = this._bcurve.knots.wrappable;\r\n if (mode === BSplineWrapMode.None)\r\n return BSplineWrapMode.None;\r\n if (!this._bcurve.knots.testClosable(mode))\r\n return BSplineWrapMode.None;\r\n if (!this._bcurve.testCloseablePolygon(mode))\r\n return BSplineWrapMode.None;\r\n return mode;\r\n }\r\n /**\r\n * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to this type.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3dOr3dH(spanIndex: number, prefer3dH: boolean, result?: BezierCurveBase): BezierCurveBase | undefined {\r\n if (prefer3dH)\r\n return this.getSaturatedBezierSpan3dH(spanIndex, result);\r\n return this.getSaturatedBezierSpan3d(spanIndex, result);\r\n }\r\n\r\n /**\r\n * Return a CurvePrimitive (which is a BezierCurve3d) for a specified span of this curve.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3d(spanIndex: number, result?: BezierCurveBase): BezierCurveBase | undefined {\r\n if (spanIndex < 0 || spanIndex >= this.numSpan)\r\n return undefined;\r\n\r\n const order = this.order;\r\n if (result === undefined || !(result instanceof BezierCurve3d) || result.order !== order)\r\n result = BezierCurve3d.createOrder(order);\r\n const bezier = result as BezierCurve3d;\r\n bezier.loadSpanPoles(this._bcurve.packedData, spanIndex);\r\n if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))\r\n return result;\r\n return undefined;\r\n }\r\n /**\r\n * Return a CurvePrimitive (which is a BezierCurve3dH) for a specified span of this curve.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3dH(spanIndex: number, result?: BezierCurveBase): BezierCurve3dH | undefined {\r\n if (spanIndex < 0 || spanIndex >= this.numSpan)\r\n return undefined;\r\n\r\n const order = this.order;\r\n if (result === undefined || !(result instanceof BezierCurve3dH) || result.order !== order)\r\n result = BezierCurve3dH.createOrder(order);\r\n const bezier = result as BezierCurve3dH;\r\n bezier.loadSpan3dPolesWithWeight(this._bcurve.packedData, spanIndex, 1.0);\r\n if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))\r\n return bezier;\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Set the flag indicating the bspline might be suitable for having wrapped \"closed\" interpretation.\r\n */\r\n public override setWrappable(value: BSplineWrapMode) {\r\n this._bcurve.knots.wrappable = value;\r\n }\r\n /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleBSplineCurve3d(this);\r\n }\r\n /**\r\n * Extend a range so in includes the range of this curve\r\n * * REMARK: this is based on the poles, not the exact curve. This is generally larger than the true curve range.\r\n * @param rangeToExtend\r\n * @param transform transform to apply to points as they are entered into the range.\r\n */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n const buffer = this._bcurve.packedData;\r\n const n = buffer.length - 2;\r\n if (transform) {\r\n for (let i0 = 0; i0 < n; i0 += 3)\r\n rangeToExtend.extendTransformedXYZ(transform, buffer[i0], buffer[i0 + 1], buffer[i0 + 2]);\r\n } else {\r\n for (let i0 = 0; i0 < n; i0 += 3)\r\n rangeToExtend.extendXYZ(buffer[i0], buffer[i0 + 1], buffer[i0 + 2]);\r\n }\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BSplineCurve.js","sourceRoot":"","sources":["../../../src/bspline/BSplineCurve.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,sEAAsF;AACtF,4DAAyD;AAEzD,kEAA+D;AAE/D,0CAA+D;AAE/D,qEAAkE;AAElE,uFAAoF;AACpF,8EAA8E;AAC9E,mEAAkE;AAClE,6DAA0D;AAC1D,+CAAuD;A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AG,CAAC,CAAC,CAAC,CAAC;SACvE;IACH,CAAC;CAEF;AAjZD,wCAiZC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\nimport { CurveIntervalRole, CurveLocationDetail } from \"../curve/CurveLocationDetail\";\r\nimport { CurvePrimitive } from \"../curve/CurvePrimitive\";\r\nimport { LineString3d } from \"../curve/LineString3d\";\r\nimport { StrokeCountMap } from \"../curve/Query/StrokeCountMap\";\r\nimport { StrokeOptions } from \"../curve/StrokeOptions\";\r\nimport { Geometry, PlaneAltitudeEvaluator } from \"../Geometry\";\r\nimport { GeometryHandler, IStrokeHandler } from \"../geometry3d/GeometryHandler\";\r\nimport { GrowableXYZArray } from \"../geometry3d/GrowableXYZArray\";\r\nimport { Plane3dByOriginAndUnitNormal } from \"../geometry3d/Plane3dByOriginAndUnitNormal\";\r\nimport { Plane3dByOriginAndVectors } from \"../geometry3d/Plane3dByOriginAndVectors\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty, no-console*/\r\nimport { Point3d, Vector3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { Point3dArray } from \"../geometry3d/PointHelpers\";\r\nimport { Range1d, Range3d } from \"../geometry3d/Range\";\r\nimport { Ray3d } from \"../geometry3d/Ray3d\";\r\nimport { Transform } from \"../geometry3d/Transform\";\r\nimport { Point4d } from \"../geometry4d/Point4d\";\r\nimport { UnivariateBezier } from \"../numerics/BezierPolynomials\";\r\nimport { AkimaCurve3dOptions } from \"./AkimaCurve3d\";\r\nimport { Bezier1dNd } from \"./Bezier1dNd\";\r\nimport { BezierCurve3d } from \"./BezierCurve3d\";\r\nimport { BezierCurve3dH } from \"./BezierCurve3dH\";\r\nimport { BezierCurveBase } from \"./BezierCurveBase\";\r\nimport { BSpline1dNd } from \"./BSpline1dNd\";\r\nimport { BSplineCurveOps } from \"./BSplineCurveOps\";\r\nimport { InterpolationCurve3dOptions } from \"./InterpolationCurve3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/**\r\n * Base class for BSplineCurve3d and BSplineCurve3dH.\r\n * * A bspline curve consists of a set of knots and a set of poles.\r\n * * The bspline curve is a function of the independent \"knot axis\" variable\r\n * * The curve \"follows\" the poles loosely.\r\n * * The is a set of polynomial spans.\r\n * * The polynomial spans all have same `degree`.\r\n * * Within each span, the polynomial of that `degree` is controlled by `order = degree + 1` contiguous points called poles.\r\n * * The is a strict relationship between knot and poles counts: `numPoles + order = numKnots + 2'\r\n * * The number of spans is `numSpan = numPoles - degree`\r\n * * For a given `spanIndex`:\r\n * * The `order` poles begin at index `spanIndex`.\r\n * * The `2*order` knots begin as span index\r\n * * The knot interval for this span is from `knot[degree+span-1] to knot[degree+span]`\r\n * * The active part of the knot axis is `knot[degree-1] < knot < knot[degree-1 + numSpan]` i.e. `knot[degree-1] < knot < knot[numPoles]\r\n *\r\n * Nearly all bsplines are \"clamped \".\r\n * * Clamping make the curve pass through its first and last poles, with tangents directed along the first and last edges of the control polygon.\r\n * * The knots for a clamped bspline have `degree` copies of the lowest knot value and `degree` copies of the highest knot value.\r\n * * For instance, the knot vector `[0,0,0,1,2,3,3,3]\r\n * * can be evaluated from `0<=knot<=3`\r\n * * has 3 spans: 0 to 1, 1 to 2, 2 to 3\r\n * * has 6 poles\r\n * * passes through its first and last poles.\r\n * * `create` methods may allow classic convention that has an extra knot at the beginning and end of the knot vector.\r\n * * The extra knots (first and last) were never referenced by the bspline recurrence relations.\r\n * * When the `create` methods recognize the classic setup (`numPoles + order = numKnots`), the extra knot is not saved with the BSplineCurve3dBase knots.\r\n *\r\n * * The weighted variant has the problem that CurvePrimitive 3d typing does not allow undefined result where Point4d has zero weight.\r\n * * The convention for these is to return 000 in such places.\r\n *\r\n * * Note the class relationships:\r\n * * BSpline1dNd knows the bspline recurrence relations for control points (poles) with no physical meaning.\r\n * * BsplineCurve3dBase owns a protected BSpline1dNd\r\n * * BsplineCurve3dBase is derived from CurvePrimitive, which creates obligation to act as a 3D curve, such as\r\n * * evaluate fraction to point and derivatives wrt fraction\r\n * * compute intersection with plane\r\n * * BSplineCurve3d and BSplineCurve3dH have variant logic driven by whether or not there are \"weights\" on the poles.\r\n * * For `BSplineCurve3d`, the xyz value of pole calculations are \"final\" values for 3d evaluation\r\n * * For `BSplineCurve3dH`, various `BSpline1dNd` results with xyzw have to be normalized back to xyz.\r\n *\r\n * * These classes do not support \"periodic\" variants.\r\n * * Periodic curves need to have certain leading knots and poles replicated at the end\r\n * @public\r\n */\r\nexport abstract class BSplineCurve3dBase extends CurvePrimitive {\r\n /** String name for schema properties */\r\n public readonly curvePrimitiveType = \"bsplineCurve\";\r\n\r\n /** The underlying blocked-pole spline, with simple x,y,z poles */\r\n protected _bcurve: BSpline1dNd;\r\n private _definitionData?: any;\r\n public set definitionData(data: any) { this._definitionData = data; }\r\n public get definitionData(): any { return this._definitionData; }\r\n protected constructor(poleDimension: number, numPoles: number, order: number, knots: KnotVector) {\r\n super();\r\n this._bcurve = BSpline1dNd.create(numPoles, poleDimension, order, knots) as BSpline1dNd;\r\n }\r\n /** Return the degree (one less than the order) of the curve */\r\n public get degree(): number { return this._bcurve.degree; }\r\n /** Return the order (one more than degree) of the curve */\r\n public get order(): number { return this._bcurve.order; }\r\n /** Return the number of bezier spans in the curve. Note that this number includes the number of null spans at repeated knows */\r\n public get numSpan(): number { return this._bcurve.numSpan; }\r\n /** Return the number of poles */\r\n public get numPoles(): number { return this._bcurve.numPoles; }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }\r\n\r\n /**\r\n * Set the flag indicating the bspline might be suitable for having wrapped \"closed\" interpretation.\r\n */\r\n public setWrappable(value: BSplineWrapMode) {\r\n this._bcurve.knots.wrappable = value;\r\n }\r\n\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public abstract evaluatePointInSpan(spanIndex: number, spanFraction: number, result?: Point3d): Point3d;\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public abstract evaluatePointAndDerivativeInSpan(spanIndex: number, spanFraction: number, result?: Ray3d): Ray3d;\r\n /** Evaluate xyz at a position given by knot. */\r\n public abstract knotToPoint(knot: number, result?: Point3d): Point3d;\r\n /** Evaluate xyz and derivative at position given by a knot value. */\r\n public abstract knotToPointAndDerivative(knot: number, result?: Ray3d): Ray3d;\r\n /** Evaluate xyz and 2 derivatives at position given by a knot value. */\r\n public abstract knotToPointAnd2Derivatives(knot: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors;\r\n /** Evaluate the curve point at `fraction` */\r\n public fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);\r\n }\r\n /** Construct a ray with\r\n * * origin at the fractional position along the arc\r\n * * direction is the first derivative, i.e. tangent along the curve\r\n */\r\n public fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAndDerivative(knot, result);\r\n result.direction.scaleInPlace(this._bcurve.knots.knotLength01);\r\n return result;\r\n }\r\n\r\n /** Construct a plane with\r\n * * origin at the fractional position along the arc\r\n * * x axis is the first derivative, i.e. tangent along the curve\r\n * * y axis is the second derivative\r\n */\r\n public fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAnd2Derivatives(knot, result);\r\n const a = this._bcurve.knots.knotLength01;\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n return result;\r\n }\r\n /**\r\n * Return the start point of the curve.\r\n */\r\n public override startPoint(): Point3d { return this.evaluatePointInSpan(0, 0.0); }\r\n /**\r\n * Return the end point of the curve\r\n */\r\n public override endPoint(): Point3d { return this.evaluatePointInSpan(this.numSpan - 1, 1.0); }\r\n /** Reverse the curve in place.\r\n * * Poles are reversed\r\n * * knot values are mirrored around the middle of the\r\n */\r\n public reverseInPlace(): void { this._bcurve.reverseInPlace(); }\r\n /**\r\n * Return an array with this curve's bezier fragments.\r\n */\r\n public collectBezierSpans(prefer3dH: boolean): BezierCurveBase[] {\r\n const result: BezierCurveBase[] = [];\r\n const numSpans = this.numSpan;\r\n for (let i = 0; i < numSpans; i++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(i)) {\r\n const span = this.getSaturatedBezierSpan3dOr3dH(i, prefer3dH);\r\n if (span)\r\n result.push(span);\r\n }\r\n }\r\n return result;\r\n }\r\n /**\r\n * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to the instance type and the prefer3dH parameter.\r\n * @param spanIndex\r\n * @param prefer3dH true to force promotion to homogeneous.\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public abstract getSaturatedBezierSpan3dOr3dH(spanIndex: number, prefer3dH: boolean, result?: BezierCurveBase): BezierCurveBase | undefined;\r\n /** Return a specified pole as a Point4d.\r\n * * BSplineCurve3d appends weight 1 to its xyz\r\n * * BSplineCurve3dH with pole whose \"normalized\" point is (x,y,z) but has weight w returns its weighted (wx,wy,wz,w)\r\n */\r\n public abstract getPolePoint4d(poleIndex: number, result?: Point4d): Point4d | undefined;\r\n /** Return a specified pole as a Point3d\r\n * * BSplineCurve3d returns its simple xyz\r\n * * BSplineCurve3dH attempts to normalize its (wx,wy,wz,w) back to (x,y,z), and returns undefined if weight is zero.\r\n * @param poleIndex\r\n * @param result optional result\r\n */\r\n public abstract getPolePoint3d(poleIndex: number, result?: Point3d): Point3d | undefined;\r\n\r\n /** Given a pole index, return the starting index for the contiguous array. */\r\n public poleIndexToDataIndex(poleIndex: number): number | undefined {\r\n if (poleIndex >= 0 && poleIndex < this.numPoles)\r\n return poleIndex * this._bcurve.poleLength;\r\n return undefined;\r\n }\r\n\r\n /** Search for the curve point that is closest to the spacePoint.\r\n *\r\n * * If the space point is exactly on the curve, this is the reverse of fractionToPoint.\r\n * * Since CurvePrimitive should always have start and end available as candidate points, this method should always succeed\r\n * @param spacePoint point in space\r\n * @param extend true to extend the curve (if possible)\r\n * @returns Returns a CurveLocationDetail structure that holds the details of the close point.\r\n */\r\n public override closestPoint(spacePoint: Point3d, _extend: boolean): CurveLocationDetail | undefined {\r\n const point = this.fractionToPoint(0);\r\n const result = CurveLocationDetail.createCurveFractionPointDistance(this, 0.0, point, point.distance(spacePoint));\r\n this.fractionToPoint(1.0, point);\r\n result.updateIfCloserCurveFractionPointDistance(this, 1.0, point, spacePoint.distance(point));\r\n\r\n let span: BezierCurve3dH | undefined;\r\n const numSpans = this.numSpan;\r\n for (let i = 0; i < numSpans; i++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(i)) {\r\n span = this.getSaturatedBezierSpan3dOr3dH(i, true, span) as BezierCurve3dH;\r\n if (span) {\r\n if (span.updateClosestPointByTruePerpendicular(spacePoint, result)) {\r\n // the detail records the span bezier -- promote it to the parent curve . ..\r\n result.curve = this;\r\n result.fraction = span.fractionToParentFraction(result.fraction);\r\n }\r\n }\r\n }\r\n }\r\n return result;\r\n }\r\n /** Implement `CurvePrimitive.appendPlaneIntersections`\r\n * @param plane A plane (e.g. specific type Plane3dByOriginAndUnitNormal or Point4d)\r\n * @param result growing array of plane intersections\r\n * @return number of intersections appended to the array.\r\n */\r\n public override appendPlaneIntersectionPoints(plane: PlaneAltitudeEvaluator, result: CurveLocationDetail[]): number {\r\n const numPole = this.numPoles;\r\n const order = this.order;\r\n const allCoffs = new Float64Array(numPole);\r\n const numSpan = this.numSpan;\r\n const point4d = Point4d.create();\r\n // compute all pole altitudes from the plane\r\n const minMax = Range1d.createNull();\r\n // Put the altitudes of all the bspline poles in one array.\r\n for (let i = 0; i < numPole; i++) {\r\n allCoffs[i] = plane.weightedAltitude(this.getPolePoint4d(i, point4d)!);\r\n minMax.extendX(allCoffs[i]);\r\n }\r\n // A univariate bspline through the altitude poles gives altitude as function of the bspline knot.\r\n // The (bspline) altitude function for each span is `order` consecutive altitudes.\r\n // If those altitudes bracket zero, the span may potentially have a crossing.\r\n // When that occurs,\r\n let univariateBezier: UnivariateBezier | undefined;\r\n let numFound = 0;\r\n let previousFraction = -1000.0;\r\n if (minMax.containsX(0.0)) {\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n if (this._bcurve.knots.isIndexOfRealSpan(spanIndex)) { // ignore trivial knot intervals.\r\n // outer range test ...\r\n minMax.setNull();\r\n minMax.extendArraySubset(allCoffs, spanIndex, order);\r\n if (minMax.containsX(0.0)) {\r\n // pack the bspline support into a univariate bezier ...\r\n univariateBezier = UnivariateBezier.createArraySubset(allCoffs, spanIndex, order, univariateBezier)!;\r\n // saturate and solve the bezier\r\n Bezier1dNd.saturate1dInPlace(univariateBezier.coffs, this._bcurve.knots, spanIndex);\r\n const roots = univariateBezier.roots(0.0, true);\r\n if (roots) {\r\n for (const spanFraction of roots) {\r\n // promote each local bezier fraction to global fraction.\r\n // save the curve evaluation at that fraction.\r\n numFound++;\r\n const fraction = this._bcurve.knots.spanFractionToFraction(spanIndex, spanFraction);\r\n if (!Geometry.isAlmostEqualNumber(fraction, previousFraction)) {\r\n const detail = CurveLocationDetail.createCurveEvaluatedFraction(this, fraction);\r\n detail.intervalRole = CurveIntervalRole.isolated;\r\n result.push(detail);\r\n previousFraction = fraction;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n return numFound;\r\n }\r\n\r\n}\r\n/**\r\n * A BSplineCurve3d is a bspline curve whose poles are Point3d.\r\n * See BSplineCurve3dBase for description of knots, order, degree.\r\n * @public\r\n */\r\nexport class BSplineCurve3d extends BSplineCurve3dBase {\r\n\r\n private _workBezier?: BezierCurve3dH;\r\n private initializeWorkBezier(): BezierCurve3dH {\r\n if (this._workBezier === undefined)\r\n this._workBezier = BezierCurve3dH.createOrder(this.order);\r\n return this._workBezier;\r\n }\r\n /** test of `other` is an instance of BSplineCurve3d */\r\n public isSameGeometryClass(other: any): boolean { return other instanceof BSplineCurve3d; }\r\n /** Apply `transform` to the poles. */\r\n public tryTransformInPlace(transform: Transform): boolean { Point3dArray.multiplyInPlace(transform, this._bcurve.packedData); return true; }\r\n /** Get a pole as simple Point3d. */\r\n public getPolePoint3d(poleIndex: number, result?: Point3d): Point3d | undefined {\r\n const k = this.poleIndexToDataIndex(poleIndex);\r\n if (k !== undefined) {\r\n const data = this._bcurve.packedData;\r\n return Point3d.create(data[k], data[k + 1], data[k + 2], result);\r\n }\r\n return undefined;\r\n }\r\n /** Get a pole as Point4d with weight 1 */\r\n public getPolePoint4d(poleIndex: number, result?: Point4d): Point4d | undefined {\r\n const k = this.poleIndexToDataIndex(poleIndex);\r\n if (k !== undefined) {\r\n const data = this._bcurve.packedData;\r\n return Point4d.create(data[k], data[k + 1], data[k + 2], 1.0, result);\r\n }\r\n return undefined;\r\n }\r\n /** Convert `spanIndex` and `localFraction` to a knot. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this._bcurve.spanFractionToKnot(span, localFraction);\r\n }\r\n private constructor(numPoles: number, order: number, knots: KnotVector) {\r\n super(3, numPoles, order, knots);\r\n }\r\n /** Return a simple array of arrays with the control points as `[[x,y,z],[x,y,z],..]` */\r\n public copyPoints(): any[] { return Point3dArray.unpackNumbersToNestedArrays(this._bcurve.packedData, 3); }\r\n /** Return a simple array of the control points coordinates */\r\n public copyPointsFloat64Array(): Float64Array { return this._bcurve.packedData.slice(); }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public override copyKnots(includeExtraEndKnot: boolean): number[] { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }\r\n\r\n /** Create a bspline with uniform knots. */\r\n public static createUniformKnots(poles: Point3d[] | Float64Array | GrowableXYZArray, order: number): BSplineCurve3d | undefined {\r\n const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;\r\n if (order < 1 || numPoles < order)\r\n return undefined;\r\n const knots = KnotVector.createUniformClamped(numPoles, order - 1, 0.0, 1.0);\r\n const curve = new BSplineCurve3d(numPoles, order, knots);\r\n if (poles instanceof Float64Array) {\r\n for (let i = 0; i < 3 * numPoles; i++)\r\n curve._bcurve.packedData[i] = poles[i];\r\n } else if (poles instanceof GrowableXYZArray) {\r\n curve._bcurve.packedData = poles.float64Data().slice(0, 3 * numPoles);\r\n } else {\r\n let i = 0;\r\n for (const p of poles) { curve._bcurve.packedData[i++] = p.x; curve._bcurve.packedData[i++] = p.y; curve._bcurve.packedData[i++] = p.z; }\r\n }\r\n return curve;\r\n }\r\n\r\n /** Create a smoothly closed B-spline curve with uniform knots.\r\n * Note that the curve does not start at the first pole.\r\n */\r\n public static createPeriodicUniformKnots(poles: Point3d[] | Float64Array | GrowableXYZArray, order: number): BSplineCurve3d | undefined {\r\n const numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;\r\n if (order < 1 || numPoles < order)\r\n return undefined;\r\n const degree = order - 1;\r\n const numIntervals = numPoles;\r\n const knots = KnotVector.createUniformWrapped(numIntervals, degree, 0.0, 1.0);\r\n knots.wrappable = BSplineWrapMode.OpenByAddingControlPoints;\r\n // append degree wraparound poles\r\n const curve = new BSplineCurve3d(numPoles + degree, order, knots);\r\n if (poles instanceof Float64Array) {\r\n for (let i = 0; i < 3 * numPoles; i++)\r\n curve._bcurve.packedData[i] = poles[i];\r\n for (let i = 0; i < 3 * degree; i++)\r\n curve._bcurve.packedData[3 * numPoles + i] = poles[i];\r\n } else if (poles instanceof GrowableXYZArray) {\r\n curve._bcurve.packedData = poles.float64Data().slice(0, 3 * numPoles);\r\n for (let i = 0; i < 3 * degree; i++)\r\n curve._bcurve.packedData[3 * numPoles + i] = poles.float64Data()[i];\r\n } else {\r\n let i = 0;\r\n for (const p of poles) { curve._bcurve.packedData[i++] = p.x; curve._bcurve.packedData[i++] = p.y; curve._bcurve.packedData[i++] = p.z; }\r\n for (let j = 0; j < degree; j++) {\r\n curve._bcurve.packedData[i++] = poles[j].x;\r\n curve._bcurve.packedData[i++] = poles[j].y;\r\n curve._bcurve.packedData[i++] = poles[j].z;\r\n }\r\n }\r\n return curve;\r\n }\r\n\r\n /**\r\n * Create a C2 cubic B-spline curve that interpolates the given points and optional end tangents.\r\n * @param options collection of points and end conditions.\r\n */\r\n public static createFromInterpolationCurve3dOptions(options: InterpolationCurve3dOptions): BSplineCurve3d | undefined {\r\n return BSplineCurveOps.createThroughPointsC2Cubic(options);\r\n }\r\n\r\n /**\r\n *\r\n * @param options collection of points and end conditions.\r\n */\r\n public static createFromAkimaCurve3dOptions(options: AkimaCurve3dOptions): BSplineCurve3d | undefined {\r\n return BSplineCurveOps.createThroughPoints(options.fitPoints, 4); // temporary\r\n }\r\n\r\n /** Create a bspline with given knots.\r\n *\r\n * * Two count conditions are recognized:\r\n *\r\n * ** If poleArray.length + order == knotArray.length, the first and last are assumed to be the\r\n * extraneous knots of classic clamping.\r\n * ** If poleArray.length + order == knotArray.length + 2, the knots are in modern form.\r\n *\r\n */\r\n public static create(poleArray: Float64Array | Point3d[], knotArray: Float64Array | number[], order: number): BSplineCurve3d | undefined {\r\n let numPoles = poleArray.length;\r\n if (poleArray instanceof Float64Array) {\r\n numPoles /= 3; // blocked as xyz\r\n }\r\n const numKnots = knotArray.length;\r\n // shift knots-of-interest limits for overclamped case ...\r\n const skipFirstAndLast = (numPoles + order === numKnots);\r\n if (order < 1 || numPoles < order)\r\n return undefined;\r\n const knots = KnotVector.create(knotArray, order - 1, skipFirstAndLast);\r\n const curve = new BSplineCurve3d(numPoles, order, knots);\r\n if (poleArray instanceof Float64Array) {\r\n let i = 0;\r\n for (const coordinate of poleArray) { curve._bcurve.packedData[i++] = coordinate; }\r\n } else {\r\n let i = 0;\r\n for (const p of poleArray) { curve._bcurve.packedData[i++] = p.x; curve._bcurve.packedData[i++] = p.y; curve._bcurve.packedData[i++] = p.z; }\r\n }\r\n return curve;\r\n }\r\n /** Return a deep clone */\r\n public clone(): BSplineCurve3d {\r\n const knotVector1 = this._bcurve.knots.clone();\r\n const curve1 = new BSplineCurve3d(this.numPoles, this.order, knotVector1);\r\n curve1._bcurve.packedData = this._bcurve.packedData.slice();\r\n return curve1;\r\n }\r\n /** Return a transformed deep clone. */\r\n public cloneTransformed(transform: Transform): BSplineCurve3d {\r\n const curve1 = this.clone();\r\n curve1.tryTransformInPlace(transform);\r\n return curve1;\r\n }\r\n /** Evaluate at a position given by fractional position within a span. */\r\n public evaluatePointInSpan(spanIndex: number, spanFraction: number): Point3d {\r\n this._bcurve.evaluateBuffersInSpan(spanIndex, spanFraction);\r\n return Point3d.createFrom(this._bcurve.poleBuffer);\r\n }\r\n /** Evaluate point and derivative vector at a position given by fractional position within a span.\r\n * * The derivative is with respect to the span fraction (NOT scaled to either global fraction or knot)\r\n */\r\n public evaluatePointAndDerivativeInSpan(spanIndex: number, spanFraction: number): Ray3d {\r\n this._bcurve.evaluateBuffersInSpan1(spanIndex, spanFraction);\r\n return Ray3d.createCapture(\r\n Point3d.createFrom(this._bcurve.poleBuffer),\r\n Vector3d.createFrom(this._bcurve.poleBuffer1));\r\n }\r\n\r\n /** Evaluate at a position given by a knot value. */\r\n public knotToPoint(u: number, result?: Point3d): Point3d {\r\n this._bcurve.evaluateBuffersAtKnot(u);\r\n return Point3d.createFrom(this._bcurve.poleBuffer, result);\r\n }\r\n /** Evaluate at a position given by a knot value. */\r\n public knotToPointAndDerivative(u: number, result?: Ray3d): Ray3d {\r\n this._bcurve.evaluateBuffersAtKnot(u, 1);\r\n if (!result) return Ray3d.createCapture(\r\n Point3d.createFrom(this._bcurve.poleBuffer),\r\n Vector3d.createFrom(this._bcurve.poleBuffer1));\r\n result.origin.setFrom(this._bcurve.poleBuffer);\r\n result.direction.setFrom(this._bcurve.poleBuffer1);\r\n return result;\r\n }\r\n\r\n /** Evaluate at a position given by a knot value. Return point with 2 derivatives. */\r\n public knotToPointAnd2Derivatives(u: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n this._bcurve.evaluateBuffersAtKnot(u, 2);\r\n return Plane3dByOriginAndVectors.createOriginAndVectorsXYZ(\r\n this._bcurve.poleBuffer[0], this._bcurve.poleBuffer[1], this._bcurve.poleBuffer[2],\r\n this._bcurve.poleBuffer1[0], this._bcurve.poleBuffer1[1], this._bcurve.poleBuffer1[2],\r\n this._bcurve.poleBuffer2[0], this._bcurve.poleBuffer2[1], this._bcurve.poleBuffer2[2], result);\r\n }\r\n /** Evaluate the curve point at a fractional of the entire knot range. */\r\n public override fractionToPoint(fraction: number, result?: Point3d): Point3d {\r\n return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);\r\n }\r\n\r\n /** Evaluate the curve point at a fractional of the entire knot range. */\r\n public override fractionToPointAndDerivative(fraction: number, result?: Ray3d): Ray3d {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAndDerivative(knot, result);\r\n result.direction.scaleInPlace(this._bcurve.knots.knotLength01);\r\n return result;\r\n }\r\n\r\n /** Construct a plane with\r\n * * origin at the fractional position along the arc\r\n * * x axis is the first derivative, i.e. tangent along the arc\r\n * * y axis is the second derivative, i.e. in the plane and on the center side of the tangent.\r\n * If the arc is circular, the second derivative is directly towards the center\r\n */\r\n public override fractionToPointAnd2Derivatives(fraction: number, result?: Plane3dByOriginAndVectors): Plane3dByOriginAndVectors {\r\n const knot = this._bcurve.knots.fractionToKnot(fraction);\r\n result = this.knotToPointAnd2Derivatives(knot, result);\r\n const a = this._bcurve.knots.knotLength01;\r\n result.vectorU.scaleInPlace(a);\r\n result.vectorV.scaleInPlace(a * a);\r\n return result;\r\n }\r\n /** test if almost the same curve as `other` */\r\n public override isAlmostEqual(other: any): boolean {\r\n if (other instanceof BSplineCurve3d) {\r\n return this._bcurve.knots.isAlmostEqual(other._bcurve.knots)\r\n && Point3dArray.isAlmostEqual(this._bcurve.packedData, other._bcurve.packedData);\r\n }\r\n return false;\r\n }\r\n /** test if this curve is entirely within plane. */\r\n public isInPlane(plane: Plane3dByOriginAndUnitNormal): boolean {\r\n return Point3dArray.isCloseToPlane(this._bcurve.packedData, plane);\r\n }\r\n /** Return the control polygon length as approximation (always overestimate) of the curve length. */\r\n public quickLength(): number { return Point3dArray.sumEdgeLengths(this._bcurve.packedData); }\r\n /** Emit beziers or strokes (selected by the stroke options) to the handler. */\r\n public emitStrokableParts(handler: IStrokeHandler, options?: StrokeOptions): void {\r\n const needBeziers = handler.announceBezierCurve !== undefined;\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n let numStrokes;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dOr3dH(spanIndex, false, workBezier);\r\n if (bezier) {\r\n numStrokes = bezier.computeStrokeCountForOptions(options);\r\n if (needBeziers) {\r\n handler.announceBezierCurve!(bezier, numStrokes, this,\r\n spanIndex,\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0),\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));\r\n\r\n } else {\r\n handler.announceIntervalForUniformStepStrokes(this, numStrokes,\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 0.0),\r\n this._bcurve.knots.spanFractionToFraction(spanIndex, 1.0));\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Assess length and turn to determine a stroke count.\r\n * @param options stroke options structure.\r\n */\r\n public computeStrokeCountForOptions(options?: StrokeOptions): number {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n let numStroke = 0;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier)\r\n numStroke += bezier.computeStrokeCountForOptions(options);\r\n }\r\n return numStroke;\r\n }\r\n /**\r\n * Compute individual segment stroke counts. Attach in a StrokeCountMap.\r\n * @param options StrokeOptions that determine count\r\n * @param parentStrokeMap evolving parent map.\r\n * @alpha\r\n */\r\n public override computeAndAttachRecursiveStrokeCounts(options?: StrokeOptions, parentStrokeMap?: StrokeCountMap) {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n const myData = StrokeCountMap.createWithCurvePrimitiveAndOptionalParent(this, parentStrokeMap, []);\r\n\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier) {\r\n const segmentLength = workBezier.curveLength();\r\n const numStrokeOnSegment = workBezier.computeStrokeCountForOptions(options);\r\n myData.addToCountAndLength(numStrokeOnSegment, segmentLength);\r\n }\r\n }\r\n CurvePrimitive.installStrokeCountMap(this, myData, parentStrokeMap);\r\n }\r\n /** Append strokes to a linestring. */\r\n public emitStrokes(dest: LineString3d, options?: StrokeOptions): void {\r\n const workBezier = this.initializeWorkBezier();\r\n const numSpan = this.numSpan;\r\n for (let spanIndex = 0; spanIndex < numSpan; spanIndex++) {\r\n const bezier = this.getSaturatedBezierSpan3dH(spanIndex, workBezier);\r\n if (bezier)\r\n bezier.emitStrokes(dest, options);\r\n }\r\n }\r\n /**\r\n * Test knots, control points, and wrappable flag to see if all agree for a possible wrapping.\r\n * @returns the manner of closing. Se BSplineWrapMode for particulars of each mode.\r\n *\r\n */\r\n public get isClosable(): BSplineWrapMode {\r\n const mode = this._bcurve.knots.wrappable;\r\n if (mode === BSplineWrapMode.None)\r\n return BSplineWrapMode.None;\r\n if (!this._bcurve.knots.testClosable(mode))\r\n return BSplineWrapMode.None;\r\n if (!this._bcurve.testCloseablePolygon(mode))\r\n return BSplineWrapMode.None;\r\n return mode;\r\n }\r\n /**\r\n * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to this type.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3dOr3dH(spanIndex: number, prefer3dH: boolean, result?: BezierCurveBase): BezierCurveBase | undefined {\r\n if (prefer3dH)\r\n return this.getSaturatedBezierSpan3dH(spanIndex, result);\r\n return this.getSaturatedBezierSpan3d(spanIndex, result);\r\n }\r\n\r\n /**\r\n * Return a CurvePrimitive (which is a BezierCurve3d) for a specified span of this curve.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3d(spanIndex: number, result?: BezierCurveBase): BezierCurveBase | undefined {\r\n if (spanIndex < 0 || spanIndex >= this.numSpan)\r\n return undefined;\r\n\r\n const order = this.order;\r\n if (result === undefined || !(result instanceof BezierCurve3d) || result.order !== order)\r\n result = BezierCurve3d.createOrder(order);\r\n const bezier = result as BezierCurve3d;\r\n bezier.loadSpanPoles(this._bcurve.packedData, spanIndex);\r\n if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))\r\n return result;\r\n return undefined;\r\n }\r\n /**\r\n * Return a CurvePrimitive (which is a BezierCurve3dH) for a specified span of this curve.\r\n * @param spanIndex\r\n * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.\r\n */\r\n public getSaturatedBezierSpan3dH(spanIndex: number, result?: BezierCurveBase): BezierCurve3dH | undefined {\r\n if (spanIndex < 0 || spanIndex >= this.numSpan)\r\n return undefined;\r\n\r\n const order = this.order;\r\n if (result === undefined || !(result instanceof BezierCurve3dH) || result.order !== order)\r\n result = BezierCurve3dH.createOrder(order);\r\n const bezier = result as BezierCurve3dH;\r\n bezier.loadSpan3dPolesWithWeight(this._bcurve.packedData, spanIndex, 1.0);\r\n if (bezier.saturateInPlace(this._bcurve.knots, spanIndex))\r\n return bezier;\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Set the flag indicating the bspline might be suitable for having wrapped \"closed\" interpretation.\r\n */\r\n public override setWrappable(value: BSplineWrapMode) {\r\n this._bcurve.knots.wrappable = value;\r\n }\r\n /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)` */\r\n public dispatchToGeometryHandler(handler: GeometryHandler): any {\r\n return handler.handleBSplineCurve3d(this);\r\n }\r\n /**\r\n * Extend a range so in includes the range of this curve\r\n * * REMARK: this is based on the poles, not the exact curve. This is generally larger than the true curve range.\r\n * @param rangeToExtend\r\n * @param transform transform to apply to points as they are entered into the range.\r\n */\r\n public extendRange(rangeToExtend: Range3d, transform?: Transform): void {\r\n const buffer = this._bcurve.packedData;\r\n const n = buffer.length - 2;\r\n if (transform) {\r\n for (let i0 = 0; i0 < n; i0 += 3)\r\n rangeToExtend.extendTransformedXYZ(transform, buffer[i0], buffer[i0 + 1], buffer[i0 + 2]);\r\n } else {\r\n for (let i0 = 0; i0 < n; i0 += 3)\r\n rangeToExtend.extendXYZ(buffer[i0], buffer[i0 + 1], buffer[i0 + 2]);\r\n }\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -58,7 +58,7 @@ export declare class KnotVector {
|
|
|
58
58
|
/** Whether the bspline was created by adding poles into "closed" structure. This is used by serialize/deserialize to mark knotVector's that were converted from periodic style. */
|
|
59
59
|
get wrappable(): BSplineWrapMode;
|
|
60
60
|
set wrappable(value: BSplineWrapMode);
|
|
61
|
-
/** Return the number of bezier spans.
|
|
61
|
+
/** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */
|
|
62
62
|
get numSpans(): number;
|
|
63
63
|
/**
|
|
64
64
|
*
|
|
@@ -92,7 +92,7 @@ export declare class KnotVector {
|
|
|
92
92
|
*/
|
|
93
93
|
static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector;
|
|
94
94
|
/**
|
|
95
|
-
* Create knot vector with
|
|
95
|
+
* Create knot vector with wraparound knots at start and end, and uniform knots between.
|
|
96
96
|
* @param numInterval number of intervals in knot space. (NOT POLE COUNT)
|
|
97
97
|
* @param degree degree of polynomial
|
|
98
98
|
* @param a0 left knot value for active interval
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnotVector.d.ts","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH;;;;;;GAMG;AACH,oBAAY,eAAe;IACzB,gCAAgC;IAChC,IAAI,IAAI;IACR;;;OAGG;IACH,yBAAyB,IAAI;IAC7B;;;OAGG;IACH,mBAAmB,IAAI;CACxB;AACD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAU;IACrB,uCAAuC;IAChC,KAAK,EAAE,YAAY,CAAC;IAC3B,mEAAmE;IAC5D,MAAM,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,SAAS,CAAC,CAAkB;IACpC,0DAA0D;IAC1D,gBAAuB,aAAa,QAAU;IAC9C,+FAA+F;IAC/F,IAAW,QAAQ,WAA0B;IAC7C,gGAAgG;IAChG,IAAW,SAAS,WAA0B;IAC9C,mEAAmE;IACnE,IAAW,aAAa,WAA8B;IACtD,oEAAoE;IACpE,IAAW,cAAc,WAA8C;IACvE,mLAAmL;IACnL,IAAW,SAAS,IACQ,eAAe,CAD4D;IACvG,IAAW,SAAS,CAAC,KAAK,EAAE,eAAe,EAA6B;IACxE,
|
|
1
|
+
{"version":3,"file":"KnotVector.d.ts","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH;;;;;;GAMG;AACH,oBAAY,eAAe;IACzB,gCAAgC;IAChC,IAAI,IAAI;IACR;;;OAGG;IACH,yBAAyB,IAAI;IAC7B;;;OAGG;IACH,mBAAmB,IAAI;CACxB;AACD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,UAAU;IACrB,uCAAuC;IAChC,KAAK,EAAE,YAAY,CAAC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ialize/deserialize to mark knotVector's that were converted from periodic style. */
|
|
89
89
|
get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }
|
|
90
90
|
set wrappable(value) { this._wrapMode = value; }
|
|
91
|
-
/** Return the number of bezier spans.
|
|
91
|
+
/** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */
|
|
92
92
|
get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }
|
|
93
93
|
/** copy degree and knots to a new KnotVector. */
|
|
94
94
|
clone() { return new KnotVector(this.knots, this.degree, this.wrappable); }
|
|
@@ -179,7 +179,7 @@ class KnotVector {
|
|
|
179
179
|
return knots;
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
|
-
* Create knot vector with
|
|
182
|
+
* Create knot vector with wraparound knots at start and end, and uniform knots between.
|
|
183
183
|
* @param numInterval number of intervals in knot space. (NOT POLE COUNT)
|
|
184
184
|
* @param degree degree of polynomial
|
|
185
185
|
* @param a0 left knot value for active interval
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnotVector.js","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,8EAA8E;AAC9E,0CAAuC;AACvC,6DAAyD;AAEzD;;;;;;GAMG;AACH,IAAY,eAaX;AAbD,WAAY,eAAe;IACzB,gCAAgC;IAChC,qDAAQ,CAAA;IACR;;;OAGG;IACH,+FAA6B,CAAA;IAC7B;;;OAGG;IACH,mFAAuB,CAAA;AACzB,CAAC,EAbW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAa1B;AACD;;;;;;;;;;;;;;GAcG;AACH,MAAa,UAAU;IAwBrB;;;;;;OAMG;IACH,YAAoB,KAAuC,EAAE,MAAc,EAAE,QAA0B;QACrG,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,uGA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AAE,CAAC;QAC5B,IAAI,mBAAmB,EAAE;YACvB,IAAI,IAAI,EAAE;gBACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;aACtD;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5B;SACF;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,mBAAmB,EAAE;YACvB,IAAI,IAAI,EAAE;gBACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;aACrD;;gBACC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAhXH,gCAiXC;AAxWC,0DAA0D;AACnC,wBAAa,GAAG,MAAM,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty, no-console*/\r\nimport { Geometry } from \"../Geometry\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/**\r\n * Enumeration of the possible ways of converting a \"periodic\" knot vector to an open knot vector.\r\n * None (0) ==> no wrap possible\r\n * OpenByAddingControlPoints (1) ==> wrapped by adding poles\r\n * OpenByRemovingKnots (2) ==> wrapped by deleting extreme knots.\r\n * @public\r\n */\r\nexport enum BSplineWrapMode {\r\n /** No conversion to periodic */\r\n None = 0,\r\n /** Convert to periodic by removing control points. This is typical for closed bcurve constructed by control points with maximum continuity.\r\n * * Knots stay the same in open and periodic form.\r\n * * Periodic form omits {degree} control points.\r\n */\r\n OpenByAddingControlPoints = 1,\r\n /** Convert to periodic by adding special knots. This is typical of closed bcurve constructed as exact circular or elliptic arc\r\n * * 2 knots on each end are omitted in open form\r\n * * poles stay the same.\r\n */\r\n OpenByRemovingKnots = 2,\r\n}\r\n/**\r\n * Array of non-decreasing numbers acting as a knot array for bsplines.\r\n *\r\n * * Essential identity: numKnots = numPoles + order = numPoles + degree - 1\r\n * * Various bspline libraries have confusion over how many \"end knots\" are needed. \"Many\" libraries (including MicroStation)\r\n * incorrectly demand \"order\" knots at each end for clamping. But only \"order - 1\" are really needed.\r\n * * This class uses the \"order-1\" convention.\r\n * * This class provides queries to convert among spanIndex and knotIndex\r\n * * A span is a single interval of the knots.\r\n * * The left knot of span {k} is knot {k+degree-1}\r\n * * This class provides queries to convert among spanFraction, fraction of knot range, and knot\r\n * * core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Caller's need to\r\n * know their primary values (global knot, spanFraction).\r\n * @public\r\n */\r\nexport class KnotVector {\r\n /** The simple array of knot values. */\r\n public knots: Float64Array;\r\n /** Return the degree of basis functions defined in these knots. */\r\n public degree: number;\r\n private _knot0: number;\r\n private _knot1: number;\r\n\r\n private _wrapMode?: BSplineWrapMode;\r\n /** tolerance for considering two knots to be the same. */\r\n public static readonly knotTolerance = 1.0e-9;\r\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get leftKnot() { return this._knot0; }\r\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get rightKnot() { return this._knot1; }\r\n /** Return the index of the leftmost knot of the active interval */\r\n public get leftKnotIndex() { return this.degree - 1; }\r\n /** Return the index of the rightmost knot of the active interval */\r\n public get rightKnotIndex() { return this.knots.length - this.degree; }\r\n /** Whether the bspline was created by adding poles into \"closed\" structure. This is used by serialize/deserialize to mark knotVector's that were converted from periodic style. */\r\n public get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }\r\n public set wrappable(value: BSplineWrapMode) { this._wrapMode = value; }\r\n /** Return the number of bezier spans. Not that this includes zero-length spans if there are repeated knots. */\r\n public get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }\r\n /**\r\n *\r\n * * If knots is a number array or Float64Array, the those values become the local knot array.\r\n * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.\r\n * @param knots\r\n * @param degree\r\n */\r\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\r\n this.degree = degree;\r\n this._wrapMode = wrapMode;\r\n // default values to satisfy compiler -- real values hapn setupFixedValues or final else defers to user\r\n this._knot0 = 0.0;\r\n this._knot1 = 1.0;\r\n // satisfy the initialize checker ..\r\n if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.\r\n this.knots = new Float64Array(knots.length);\r\n this.setKnots(knots);\r\n this.setupFixedValues();\r\n } else if (knots instanceof Float64Array) {\r\n this.knots = knots.slice();\r\n this.setupFixedValues();\r\n } else { // caller is responsible for filling array separately ...\r\n this.knots = new Float64Array(knots);\r\n }\r\n }\r\n /** copy degree and knots to a new KnotVector. */\r\n public clone(): KnotVector { return new KnotVector(this.knots, this.degree, this.wrappable); }\r\n private setupFixedValues() {\r\n // These should be read-only . ..\r\n this._knot0 = this.knots[this.degree - 1];\r\n this._knot1 = this.knots[this.knots.length - this.degree];\r\n }\r\n /** Return the total knot distance from beginning to end. */\r\n public get knotLength01(): number { return this._knot1 - this._knot0; }\r\n /**\r\n * Returns true if all numeric values have wraparound conditions for \"closed\" knotVector with specified wrap mode\r\n * @param mode optional test mode. If undefined, use the this.wrappable.\r\n */\r\n public testClosable(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.wrappable;\r\n const leftKnotIndex = this.leftKnotIndex;\r\n const rightKnotIndex = this.rightKnotIndex;\r\n const period = this.rightKnot - this.leftKnot;\r\n const degree = this.degree;\r\n const indexDelta = rightKnotIndex - leftKnotIndex;\r\n // maximum continuity mode . . .\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n for (let k0 = leftKnotIndex - degree + 1; k0 < leftKnotIndex + degree - 1; k0++) {\r\n const k1 = k0 + indexDelta;\r\n if (!Geometry.isSameCoordinate(this.knots[k0] + period, this.knots[k1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n // arc mode ...\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // we expect {degree} replicated knots at each end . . .\r\n const numRepeated = degree - 1;\r\n const leftKnot = this.knots[leftKnotIndex];\r\n const rightKnot = this.knots[rightKnotIndex];\r\n for (let i = 0; i < numRepeated; i++) {\r\n if (!Geometry.isSameCoordinate(leftKnot, this.knots[leftKnotIndex - i - 1]))\r\n return false;\r\n if (!Geometry.isSameCoordinate(rightKnot, this.knots[rightKnotIndex + i + 1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n /** Test matching degree and knot values */\r\n public isAlmostEqual(other: KnotVector): boolean {\r\n if (this.degree !== other.degree) return false;\r\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\r\n }\r\n /** install knot values from an array, optionally ignoring first and last.\r\n */\r\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\r\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\r\n if (numAllocate !== this.knots.length)\r\n this.knots = new Float64Array(numAllocate);\r\n if (skipFirstAndLast) {\r\n for (let i = 1; i + 1 < knots.length; i++)\r\n this.knots[i - 1] = knots[i];\r\n\r\n } else {\r\n for (let i = 0; i < knots.length; i++)\r\n this.knots[i] = knots[i];\r\n }\r\n this.setupFixedValues();\r\n }\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numPoles Number of poles\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numPoles + degree - 1, degree);\r\n let k = 0;\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a0;\r\n const du = 1.0 / (numPoles - degree);\r\n for (let i = 1; i + degree < numPoles; i++)\r\n knots.knots[k++] = a0 + i * du * (a1 - a0);\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a1;\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numInterval number of intervals in knot space. (NOT POLE COUNT)\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\r\n const du = 1.0 / numInterval;\r\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {\r\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\r\n }\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n\r\n /**\r\n * Create knot vector with given knot values and degree.\r\n * @param knotArray knot values\r\n * @param degree degree of polynomial\r\n * @param skipFirstAndLast true to skip class overclamped end knots.\r\n */\r\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\r\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\r\n const knots = new KnotVector(numAllocate, degree);\r\n knots.setKnots(knotArray, skipFirstAndLast);\r\n return knots;\r\n }\r\n\r\n /**\r\n * Return the average of degree consecutive knots beginning at spanIndex.\r\n */\r\n public grevilleKnot(spanIndex: number): number {\r\n if (spanIndex < 0) return this.leftKnot;\r\n if (spanIndex > this.rightKnotIndex) return this.rightKnot;\r\n let sum = 0.0;\r\n for (let i = spanIndex; i < spanIndex + this.degree; i++)\r\n sum += this.knots[i];\r\n return sum / this.degree;\r\n }\r\n /** Return an array sized for a set of the basis function values. */\r\n public createBasisArray(): Float64Array { return new Float64Array(this.degree + 1); }\r\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\r\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\r\n const knot0 = this.knots[knotIndex0];\r\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\r\n }\r\n /** Convert localFraction within an indexed bezier span to a knot value. */\r\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\r\n }\r\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\r\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\r\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\r\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\r\n }\r\n /** Return fraction of active knot range to knot value. */\r\n public fractionToKnot(fraction: number): number {\r\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\r\n }\r\n /**\r\n * Evaluate basis functions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of basis values. ASSUMED PROPER LENGTH\r\n */\r\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array) {\r\n f[0] = 1.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n f[1] = (u - u0) / (u1 - u0);\r\n f[0] = 1.0 - f[1];\r\n if (this.degree < 2) return;\r\n\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n const fraction = (u - tLeft) / (tRight - tLeft);\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * (1.0 - fraction);\r\n f[step] = gCarry + g0;\r\n gCarry = g1;\r\n }\r\n f[depth + 1] = gCarry;\r\n }\r\n }\r\n\r\n /**\r\n * Evaluate basis fucntions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of basis values. ASSUMED PROPER LENGTH\r\n */\r\n public evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array) {\r\n f[0] = 1.0; df[0] = 0.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n // ah = 1/(u1-u0) is the derivative of fraction0\r\n // (-ah) is the derivative of fraction1.\r\n let ah = 1.0 / (u1 - u0);\r\n f[1] = (u - u0) * ah;\r\n f[0] = 1.0 - f[1];\r\n df[0] = -ah; df[1] = ah;\r\n if (ddf) { // first derivative started constant, second derivative started zero.\r\n ddf[0] = 0.0; ddf[1] = 0.0;\r\n }\r\n if (this.degree < 2) return;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n let dgCarry = 0.0;\r\n let ddgCarry = 0.0;\r\n // f, df, ddf, are each row vectors with product of `step` linear terms.\r\n // 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)\r\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\r\n // Hence fnew = f * V\r\n // dfnew = df * V + f * dV\r\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\r\n // but ddV is zero so\r\n // ddfnew = ddf * V + 2 * df * dV\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n ah = 1.0 / (tRight - tLeft);\r\n const fraction = (u - tLeft) * ah;\r\n const fraction1 = 1.0 - fraction;\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * fraction1;\r\n const dg1 = df[step] * fraction + f[step] * ah;\r\n const dg0 = df[step] * fraction1 - f[step] * ah;\r\n const dfSave = 2.0 * df[step] * ah;\r\n f[step] = gCarry + g0;\r\n df[step] = dgCarry + dg0;\r\n gCarry = g1;\r\n dgCarry = dg1;\r\n if (ddf) { // do the backward reference to df before rewriting df !!!\r\n const ddg1 = ddf[step] * fraction + dfSave;\r\n const ddg0 = ddf[step] * fraction1 - dfSave;\r\n ddf[step] = ddgCarry + ddg0;\r\n ddgCarry = ddg1;\r\n }\r\n }\r\n f[depth + 1] = gCarry;\r\n df[depth + 1] = dgCarry;\r\n if (ddf)\r\n ddf[depth + 1] = ddgCarry;\r\n }\r\n }\r\n /** Return the (highest) index of the knot less than or equal to u */\r\n public knotToLeftKnotIndex(u: number): number {\r\n // Anything to left is in the first span . .\r\n const firstLeftKnot = this.degree - 1;\r\n if (u < this.knots[firstLeftKnot + 1]) return firstLeftKnot;\r\n // Anything to right is in the last span ...\r\n const lastLeftKnot = this.knots.length - this.degree - 1;\r\n if (u >= this.knots.length - this.degree) return this.knots[lastLeftKnot];\r\n // ugh ... linear search ...\r\n for (let i = firstLeftKnot + 1; i < lastLeftKnot; i++)\r\n if (u < this.knots[i + 1]) return i; // testing against right side skips over multiple knot cases???\r\n return lastLeftKnot;\r\n }\r\n /**\r\n * Given a span index, return the index of the knot at its left.\r\n * @param spanIndex index of span\r\n */\r\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\r\n const d = this.degree;\r\n if (spanIndex <= 0.0) return d - 1;\r\n return Math.min(spanIndex + d - 1, this.knots.length - d);\r\n }\r\n /** Return the knot interval length of indexed bezier span. */\r\n public spanIndexToSpanLength(spanIndex: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k + 1] - this.knots[k];\r\n }\r\n /**\r\n * Given a span index, test if it is within range and has nonzero length.\r\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans\r\n * @param spanIndex index of span to test.\r\n */\r\n public isIndexOfRealSpan(spanIndex: number): boolean {\r\n if (spanIndex >= 0 && spanIndex < this.knots.length - this.degree)\r\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\r\n return false;\r\n }\r\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */\r\n public reflectKnots() {\r\n const a = this.leftKnot;\r\n const b = this.rightKnot;\r\n const numKnots = this.knots.length;\r\n for (let i = 0; i < numKnots; i++)\r\n this.knots[i] = a + (b - this.knots[i]);\r\n this.knots.reverse();\r\n }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] {\r\n const wrap = this.wrappable === BSplineWrapMode.OpenByAddingControlPoints && this.testClosable();\r\n const leftIndex = this.leftKnotIndex;\r\n const rightIndex = this.rightKnotIndex;\r\n const a0 = this.leftKnot;\r\n const a1 = this.rightKnot;\r\n const delta = a1 - a0;\r\n const degree = this.degree;\r\n const values: number[] = [];\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[rightIndex - degree] - delta);\r\n } else {\r\n values.push(this.knots[0]);\r\n }\r\n }\r\n for (const u of this.knots) values.push(u);\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[leftIndex + degree] + delta);\r\n } else\r\n values.push(values[values.length - 1]);\r\n }\r\n return values;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"KnotVector.js","sourceRoot":"","sources":["../../../src/bspline/KnotVector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,8EAA8E;AAC9E,0CAAuC;AACvC,6DAAyD;AAEzD;;;;;;GAMG;AACH,IAAY,eAaX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AS,KAAK,eAAe,CAAC,yBAAyB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACjG,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC;QACrC,MAAM,UAAU,GAAG,IAAI,CAAC,cAAc,CAAC;QACvC,MAAM,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAC1B,MAAM,KAAK,GAAG,EAAE,GAAG,EAAE,CAAC;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,mBAAmB,EAAE;YACvB,IAAI,IAAI,EAAE;gBACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;aACtD;iBAAM;gBACL,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5B;SACF;QACD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,mBAAmB,EAAE;YACvB,IAAI,IAAI,EAAE;gBACR,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;aACrD;;gBACC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;SAC1C;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;;AAhXH,gCAiXC;AAxWC,0DAA0D;AACnC,wBAAa,GAAG,MAAM,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Bspline\r\n */\r\n\r\n// import { Point2d } from \"../Geometry2d\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty, no-console*/\r\nimport { Geometry } from \"../Geometry\";\r\nimport { NumberArray } from \"../geometry3d/PointHelpers\";\r\n\r\n/**\r\n * Enumeration of the possible ways of converting a \"periodic\" knot vector to an open knot vector.\r\n * None (0) ==> no wrap possible\r\n * OpenByAddingControlPoints (1) ==> wrapped by adding poles\r\n * OpenByRemovingKnots (2) ==> wrapped by deleting extreme knots.\r\n * @public\r\n */\r\nexport enum BSplineWrapMode {\r\n /** No conversion to periodic */\r\n None = 0,\r\n /** Convert to periodic by removing control points. This is typical for closed bcurve constructed by control points with maximum continuity.\r\n * * Knots stay the same in open and periodic form.\r\n * * Periodic form omits {degree} control points.\r\n */\r\n OpenByAddingControlPoints = 1,\r\n /** Convert to periodic by adding special knots. This is typical of closed bcurve constructed as exact circular or elliptic arc\r\n * * 2 knots on each end are omitted in open form\r\n * * poles stay the same.\r\n */\r\n OpenByRemovingKnots = 2,\r\n}\r\n/**\r\n * Array of non-decreasing numbers acting as a knot array for bsplines.\r\n *\r\n * * Essential identity: numKnots = numPoles + order = numPoles + degree - 1\r\n * * Various bspline libraries have confusion over how many \"end knots\" are needed. \"Many\" libraries (including MicroStation)\r\n * incorrectly demand \"order\" knots at each end for clamping. But only \"order - 1\" are really needed.\r\n * * This class uses the \"order-1\" convention.\r\n * * This class provides queries to convert among spanIndex and knotIndex\r\n * * A span is a single interval of the knots.\r\n * * The left knot of span {k} is knot {k+degree-1}\r\n * * This class provides queries to convert among spanFraction, fraction of knot range, and knot\r\n * * core computations (evaluateBasisFunctions) have leftKnotIndex and global knot value as inputs. Caller's need to\r\n * know their primary values (global knot, spanFraction).\r\n * @public\r\n */\r\nexport class KnotVector {\r\n /** The simple array of knot values. */\r\n public knots: Float64Array;\r\n /** Return the degree of basis functions defined in these knots. */\r\n public degree: number;\r\n private _knot0: number;\r\n private _knot1: number;\r\n\r\n private _wrapMode?: BSplineWrapMode;\r\n /** tolerance for considering two knots to be the same. */\r\n public static readonly knotTolerance = 1.0e-9;\r\n /** Return the leftmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get leftKnot() { return this._knot0; }\r\n /** Return the rightmost knot value (of the active interval, ignoring unclamped leading knots)*/\r\n public get rightKnot() { return this._knot1; }\r\n /** Return the index of the leftmost knot of the active interval */\r\n public get leftKnotIndex() { return this.degree - 1; }\r\n /** Return the index of the rightmost knot of the active interval */\r\n public get rightKnotIndex() { return this.knots.length - this.degree; }\r\n /** Whether the bspline was created by adding poles into \"closed\" structure. This is used by serialize/deserialize to mark knotVector's that were converted from periodic style. */\r\n public get wrappable() { return this._wrapMode === undefined ? BSplineWrapMode.None : this._wrapMode; }\r\n public set wrappable(value: BSplineWrapMode) { this._wrapMode = value; }\r\n /** Return the number of bezier spans. Note that this includes zero-length spans if there are repeated knots. */\r\n public get numSpans() { return this.rightKnotIndex - this.leftKnotIndex; }\r\n /**\r\n *\r\n * * If knots is a number array or Float64Array, the those values become the local knot array.\r\n * * If knots is a simple number, the local knot array is allocated to that size but left as zeros.\r\n * @param knots\r\n * @param degree\r\n */\r\n private constructor(knots: number[] | Float64Array | number, degree: number, wrapMode?: BSplineWrapMode) {\r\n this.degree = degree;\r\n this._wrapMode = wrapMode;\r\n // default values to satisfy compiler -- real values hapn setupFixedValues or final else defers to user\r\n this._knot0 = 0.0;\r\n this._knot1 = 1.0;\r\n // satisfy the initialize checker ..\r\n if (Array.isArray(knots)) { // remark: This ctor is private. The callers (as of April 2019) do not use this path.\r\n this.knots = new Float64Array(knots.length);\r\n this.setKnots(knots);\r\n this.setupFixedValues();\r\n } else if (knots instanceof Float64Array) {\r\n this.knots = knots.slice();\r\n this.setupFixedValues();\r\n } else { // caller is responsible for filling array separately ...\r\n this.knots = new Float64Array(knots);\r\n }\r\n }\r\n /** copy degree and knots to a new KnotVector. */\r\n public clone(): KnotVector { return new KnotVector(this.knots, this.degree, this.wrappable); }\r\n private setupFixedValues() {\r\n // These should be read-only . ..\r\n this._knot0 = this.knots[this.degree - 1];\r\n this._knot1 = this.knots[this.knots.length - this.degree];\r\n }\r\n /** Return the total knot distance from beginning to end. */\r\n public get knotLength01(): number { return this._knot1 - this._knot0; }\r\n /**\r\n * Returns true if all numeric values have wraparound conditions for \"closed\" knotVector with specified wrap mode\r\n * @param mode optional test mode. If undefined, use the this.wrappable.\r\n */\r\n public testClosable(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.wrappable;\r\n const leftKnotIndex = this.leftKnotIndex;\r\n const rightKnotIndex = this.rightKnotIndex;\r\n const period = this.rightKnot - this.leftKnot;\r\n const degree = this.degree;\r\n const indexDelta = rightKnotIndex - leftKnotIndex;\r\n // maximum continuity mode . . .\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n for (let k0 = leftKnotIndex - degree + 1; k0 < leftKnotIndex + degree - 1; k0++) {\r\n const k1 = k0 + indexDelta;\r\n if (!Geometry.isSameCoordinate(this.knots[k0] + period, this.knots[k1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n // arc mode ...\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // we expect {degree} replicated knots at each end . . .\r\n const numRepeated = degree - 1;\r\n const leftKnot = this.knots[leftKnotIndex];\r\n const rightKnot = this.knots[rightKnotIndex];\r\n for (let i = 0; i < numRepeated; i++) {\r\n if (!Geometry.isSameCoordinate(leftKnot, this.knots[leftKnotIndex - i - 1]))\r\n return false;\r\n if (!Geometry.isSameCoordinate(rightKnot, this.knots[rightKnotIndex + i + 1]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n /** Test matching degree and knot values */\r\n public isAlmostEqual(other: KnotVector): boolean {\r\n if (this.degree !== other.degree) return false;\r\n return NumberArray.isAlmostEqual(this.knots, other.knots, KnotVector.knotTolerance);\r\n }\r\n /** install knot values from an array, optionally ignoring first and last.\r\n */\r\n public setKnots(knots: number[] | Float64Array, skipFirstAndLast?: boolean) {\r\n const numAllocate = skipFirstAndLast ? knots.length - 2 : knots.length;\r\n if (numAllocate !== this.knots.length)\r\n this.knots = new Float64Array(numAllocate);\r\n if (skipFirstAndLast) {\r\n for (let i = 1; i + 1 < knots.length; i++)\r\n this.knots[i - 1] = knots[i];\r\n\r\n } else {\r\n for (let i = 0; i < knots.length; i++)\r\n this.knots[i] = knots[i];\r\n }\r\n this.setupFixedValues();\r\n }\r\n /**\r\n * Create knot vector with {degree-1} replicated knots at start and end, and uniform knots between.\r\n * @param numPoles Number of poles\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformClamped(numPoles: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numPoles + degree - 1, degree);\r\n let k = 0;\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a0;\r\n const du = 1.0 / (numPoles - degree);\r\n for (let i = 1; i + degree < numPoles; i++)\r\n knots.knots[k++] = a0 + i * du * (a1 - a0);\r\n for (let m = 0; m < degree; m++)knots.knots[k++] = a1;\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n /**\r\n * Create knot vector with wraparound knots at start and end, and uniform knots between.\r\n * @param numInterval number of intervals in knot space. (NOT POLE COUNT)\r\n * @param degree degree of polynomial\r\n * @param a0 left knot value for active interval\r\n * @param a1 right knot value for active interval\r\n */\r\n public static createUniformWrapped(numInterval: number, degree: number, a0: number, a1: number): KnotVector {\r\n const knots = new KnotVector(numInterval + 2 * degree - 1, degree);\r\n const du = 1.0 / numInterval;\r\n for (let i = 1 - degree, k = 0; i < numInterval + degree; i++, k++) {\r\n knots.knots[k] = Geometry.interpolate(a0, i * du, a1);\r\n }\r\n knots.setupFixedValues();\r\n return knots;\r\n }\r\n\r\n /**\r\n * Create knot vector with given knot values and degree.\r\n * @param knotArray knot values\r\n * @param degree degree of polynomial\r\n * @param skipFirstAndLast true to skip class overclamped end knots.\r\n */\r\n public static create(knotArray: number[] | Float64Array, degree: number, skipFirstAndLast?: boolean): KnotVector {\r\n const numAllocate = skipFirstAndLast ? knotArray.length - 2 : knotArray.length;\r\n const knots = new KnotVector(numAllocate, degree);\r\n knots.setKnots(knotArray, skipFirstAndLast);\r\n return knots;\r\n }\r\n\r\n /**\r\n * Return the average of degree consecutive knots beginning at spanIndex.\r\n */\r\n public grevilleKnot(spanIndex: number): number {\r\n if (spanIndex < 0) return this.leftKnot;\r\n if (spanIndex > this.rightKnotIndex) return this.rightKnot;\r\n let sum = 0.0;\r\n for (let i = spanIndex; i < spanIndex + this.degree; i++)\r\n sum += this.knots[i];\r\n return sum / this.degree;\r\n }\r\n /** Return an array sized for a set of the basis function values. */\r\n public createBasisArray(): Float64Array { return new Float64Array(this.degree + 1); }\r\n /** Convert localFraction within the interval following an indexed knot to a knot value. */\r\n public baseKnotFractionToKnot(knotIndex0: number, localFraction: number): number {\r\n const knot0 = this.knots[knotIndex0];\r\n return knot0 + localFraction * (this.knots[knotIndex0 + 1] - knot0);\r\n }\r\n /** Convert localFraction within an indexed bezier span to a knot value. */\r\n public spanFractionToKnot(spanIndex: number, localFraction: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k] + localFraction * (this.knots[k + 1] - this.knots[k]);\r\n }\r\n /** Convert localFraction within an indexed bezier span to fraction of active knot range. */\r\n public spanFractionToFraction(spanIndex: number, localFraction: number): number {\r\n const knot = this.spanFractionToKnot(spanIndex, localFraction);\r\n return (knot - this.leftKnot) / (this.rightKnot - this.leftKnot);\r\n }\r\n /** Return fraction of active knot range to knot value. */\r\n public fractionToKnot(fraction: number): number {\r\n return Geometry.interpolate(this.knots[this.degree - 1], fraction, this.knots[this.knots.length - this.degree]);\r\n }\r\n /**\r\n * Evaluate basis functions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of basis values. ASSUMED PROPER LENGTH\r\n */\r\n public evaluateBasisFunctions(knotIndex0: number, u: number, f: Float64Array) {\r\n f[0] = 1.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n f[1] = (u - u0) / (u1 - u0);\r\n f[0] = 1.0 - f[1];\r\n if (this.degree < 2) return;\r\n\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n const fraction = (u - tLeft) / (tRight - tLeft);\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * (1.0 - fraction);\r\n f[step] = gCarry + g0;\r\n gCarry = g1;\r\n }\r\n f[depth + 1] = gCarry;\r\n }\r\n }\r\n\r\n /**\r\n * Evaluate basis fucntions f[] at knot value u.\r\n *\r\n * @param u knot value for evaluation\r\n * @param f array of basis values. ASSUMED PROPER LENGTH\r\n */\r\n public evaluateBasisFunctions1(knotIndex0: number, u: number, f: Float64Array, df: Float64Array, ddf?: Float64Array) {\r\n f[0] = 1.0; df[0] = 0.0;\r\n if (this.degree < 1) return;\r\n // direct compute for linear part ...\r\n const u0 = this.knots[knotIndex0];\r\n const u1 = this.knots[knotIndex0 + 1];\r\n // ah = 1/(u1-u0) is the derivative of fraction0\r\n // (-ah) is the derivative of fraction1.\r\n let ah = 1.0 / (u1 - u0);\r\n f[1] = (u - u0) * ah;\r\n f[0] = 1.0 - f[1];\r\n df[0] = -ah; df[1] = ah;\r\n if (ddf) { // first derivative started constant, second derivative started zero.\r\n ddf[0] = 0.0; ddf[1] = 0.0;\r\n }\r\n if (this.degree < 2) return;\r\n for (let depth = 1; depth < this.degree; depth++) {\r\n let kLeft = knotIndex0 - depth;\r\n let kRight = kLeft + depth + 1;\r\n let gCarry = 0.0;\r\n let dgCarry = 0.0;\r\n let ddgCarry = 0.0;\r\n // f, df, ddf, are each row vectors with product of `step` linear terms.\r\n // 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)\r\n // Each row of the derivative dV is two entries (0,0, -1/h, 1/h,0,0,0)\r\n // Hence fnew = f * V\r\n // dfnew = df * V + f * dV\r\n // ddfnew = ddf * V + df*dV + df * dV + f * ddV\r\n // but ddV is zero so\r\n // ddfnew = ddf * V + 2 * df * dV\r\n for (let step = 0; step <= depth; step++) {\r\n const tLeft = this.knots[kLeft++];\r\n const tRight = this.knots[kRight++];\r\n ah = 1.0 / (tRight - tLeft);\r\n const fraction = (u - tLeft) * ah;\r\n const fraction1 = 1.0 - fraction;\r\n const g1 = f[step] * fraction;\r\n const g0 = f[step] * fraction1;\r\n const dg1 = df[step] * fraction + f[step] * ah;\r\n const dg0 = df[step] * fraction1 - f[step] * ah;\r\n const dfSave = 2.0 * df[step] * ah;\r\n f[step] = gCarry + g0;\r\n df[step] = dgCarry + dg0;\r\n gCarry = g1;\r\n dgCarry = dg1;\r\n if (ddf) { // do the backward reference to df before rewriting df !!!\r\n const ddg1 = ddf[step] * fraction + dfSave;\r\n const ddg0 = ddf[step] * fraction1 - dfSave;\r\n ddf[step] = ddgCarry + ddg0;\r\n ddgCarry = ddg1;\r\n }\r\n }\r\n f[depth + 1] = gCarry;\r\n df[depth + 1] = dgCarry;\r\n if (ddf)\r\n ddf[depth + 1] = ddgCarry;\r\n }\r\n }\r\n /** Return the (highest) index of the knot less than or equal to u */\r\n public knotToLeftKnotIndex(u: number): number {\r\n // Anything to left is in the first span . .\r\n const firstLeftKnot = this.degree - 1;\r\n if (u < this.knots[firstLeftKnot + 1]) return firstLeftKnot;\r\n // Anything to right is in the last span ...\r\n const lastLeftKnot = this.knots.length - this.degree - 1;\r\n if (u >= this.knots.length - this.degree) return this.knots[lastLeftKnot];\r\n // ugh ... linear search ...\r\n for (let i = firstLeftKnot + 1; i < lastLeftKnot; i++)\r\n if (u < this.knots[i + 1]) return i; // testing against right side skips over multiple knot cases???\r\n return lastLeftKnot;\r\n }\r\n /**\r\n * Given a span index, return the index of the knot at its left.\r\n * @param spanIndex index of span\r\n */\r\n public spanIndexToLeftKnotIndex(spanIndex: number): number {\r\n const d = this.degree;\r\n if (spanIndex <= 0.0) return d - 1;\r\n return Math.min(spanIndex + d - 1, this.knots.length - d);\r\n }\r\n /** Return the knot interval length of indexed bezier span. */\r\n public spanIndexToSpanLength(spanIndex: number): number {\r\n const k = this.spanIndexToLeftKnotIndex(spanIndex);\r\n return this.knots[k + 1] - this.knots[k];\r\n }\r\n /**\r\n * Given a span index, test if it is within range and has nonzero length.\r\n * * note that a false return does not imply there are no more spans. This may be a double knot (zero length span) followed by more real spans\r\n * @param spanIndex index of span to test.\r\n */\r\n public isIndexOfRealSpan(spanIndex: number): boolean {\r\n if (spanIndex >= 0 && spanIndex < this.knots.length - this.degree)\r\n return !Geometry.isSmallMetricDistance(this.spanIndexToSpanLength(spanIndex));\r\n return false;\r\n }\r\n /** Reflect all knots so `leftKnot` and `rightKnot` are maintained but interval lengths reverse. */\r\n public reflectKnots() {\r\n const a = this.leftKnot;\r\n const b = this.rightKnot;\r\n const numKnots = this.knots.length;\r\n for (let i = 0; i < numKnots; i++)\r\n this.knots[i] = a + (b - this.knots[i]);\r\n this.knots.reverse();\r\n }\r\n /**\r\n * return a simple array form of the knots. optionally replicate the first and last\r\n * in classic over-clamped manner\r\n */\r\n public copyKnots(includeExtraEndKnot: boolean): number[] {\r\n const wrap = this.wrappable === BSplineWrapMode.OpenByAddingControlPoints && this.testClosable();\r\n const leftIndex = this.leftKnotIndex;\r\n const rightIndex = this.rightKnotIndex;\r\n const a0 = this.leftKnot;\r\n const a1 = this.rightKnot;\r\n const delta = a1 - a0;\r\n const degree = this.degree;\r\n const values: number[] = [];\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[rightIndex - degree] - delta);\r\n } else {\r\n values.push(this.knots[0]);\r\n }\r\n }\r\n for (const u of this.knots) values.push(u);\r\n if (includeExtraEndKnot) {\r\n if (wrap) {\r\n values.push(this.knots[leftIndex + degree] + delta);\r\n } else\r\n values.push(values[values.length - 1]);\r\n }\r\n return values;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FrameBuilder.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/FrameBuilder.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAa,eAAe,EAAY,MAAM,aAAa,CAAC;AAGnE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,QAAQ,CAAuB;IAEvC,OAAO,CAAC,6BAA6B;IAOrC,kDAAkD;IAC3C,KAAK;;IAEZ;;;;OAIG;IACI,iBAAiB,CAAC,eAAe,GAAE,OAAe,GAAG,SAAS,GAAG,SAAS;IAuBjF,kGAAkG;IAC3F,oBAAoB,CAAC,MAAM,CAAC,EAAE,QAAQ;IAK7C,8DAA8D;IAC9D,IAAW,SAAS,IAAI,OAAO,CAAuC;IACtE;OACG;IACI,gBAAgB,IAAI,MAAM;IASjC,8HAA8H;IACvH,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM;IAU5C,6BAA6B;IACtB,cAAc,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM;IA0B/C;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,GAAG;
|
|
1
|
+
{"version":3,"file":"FrameBuilder.d.ts","sourceRoot":"","sources":["../../../src/geometry3d/FrameBuilder.ts"],"names":[],"mapp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AG,SAAS,GAAG,SAAS;IASjF;;;;;;;;OAQG;WACW,kCAAkC,CAC9C,KAAK,EAAE,OAAO,EACd,WAAW,GAAE,eAA4D,EACzE,SAAS,GAAE,MAAU,EACrB,SAAS,GAAE,MAAU,EACrB,SAAS,GAAE,MAAU,EACrB,iBAAiB,GAAE,MAAY,GAAG,SAAS;CAgB9C"}
|
|
@@ -185,7 +185,7 @@ class FrameBuilder {
|
|
|
185
185
|
else if (data instanceof InterpolationCurve3d_1.InterpolationCurve3d) {
|
|
186
186
|
const point = Point3dVector3d_1.Point3d.create();
|
|
187
187
|
for (let i = 0; this.savedVectorCount() < 2; i++) {
|
|
188
|
-
if (i < data.options.fitPoints.length
|
|
188
|
+
if (i < data.options.fitPoints.length) {
|
|
189
189
|
point.setFrom(data.options.fitPoints[i]);
|
|
190
190
|
this.announcePoint(point);
|
|
191
191
|
}
|
|
@@ -193,7 +193,14 @@ class FrameBuilder {
|
|
|
193
193
|
break;
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
|
-
//
|
|
196
|
+
else { // unimplemented CurvePrimitive type
|
|
197
|
+
const frame = data.fractionToFrenetFrame(0.0);
|
|
198
|
+
if (undefined !== frame) {
|
|
199
|
+
this.announcePoint(frame.getOrigin());
|
|
200
|
+
this.announceVector(frame.matrix.getColumn(0));
|
|
201
|
+
this.announceVector(frame.matrix.getColumn(1));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
197
204
|
}
|
|
198
205
|
else if (data instanceof CurveCollection_1.CurveCollection) {
|
|
199
206
|
if (data.children)
|