@itwin/core-geometry 4.3.0-dev.13 → 4.3.0-dev.14

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.
Files changed (149) hide show
  1. package/lib/cjs/bspline/BSpline1dNd.d.ts +12 -2
  2. package/lib/cjs/bspline/BSpline1dNd.d.ts.map +1 -1
  3. package/lib/cjs/bspline/BSpline1dNd.js +27 -17
  4. package/lib/cjs/bspline/BSpline1dNd.js.map +1 -1
  5. package/lib/cjs/bspline/BSplineCurve.d.ts +30 -16
  6. package/lib/cjs/bspline/BSplineCurve.d.ts.map +1 -1
  7. package/lib/cjs/bspline/BSplineCurve.js +68 -44
  8. package/lib/cjs/bspline/BSplineCurve.js.map +1 -1
  9. package/lib/cjs/bspline/BSplineCurve3dH.d.ts +27 -20
  10. package/lib/cjs/bspline/BSplineCurve3dH.d.ts.map +1 -1
  11. package/lib/cjs/bspline/BSplineCurve3dH.js +136 -87
  12. package/lib/cjs/bspline/BSplineCurve3dH.js.map +1 -1
  13. package/lib/cjs/bspline/BSplineSurface.d.ts +138 -74
  14. package/lib/cjs/bspline/BSplineSurface.d.ts.map +1 -1
  15. package/lib/cjs/bspline/BSplineSurface.js +242 -119
  16. package/lib/cjs/bspline/BSplineSurface.js.map +1 -1
  17. package/lib/cjs/bspline/Bezier1dNd.d.ts +18 -4
  18. package/lib/cjs/bspline/Bezier1dNd.d.ts.map +1 -1
  19. package/lib/cjs/bspline/Bezier1dNd.js +19 -5
  20. package/lib/cjs/bspline/Bezier1dNd.js.map +1 -1
  21. package/lib/cjs/bspline/BezierCurve3dH.d.ts.map +1 -1
  22. package/lib/cjs/bspline/BezierCurve3dH.js +2 -1
  23. package/lib/cjs/bspline/BezierCurve3dH.js.map +1 -1
  24. package/lib/cjs/bspline/KnotVector.d.ts +30 -33
  25. package/lib/cjs/bspline/KnotVector.d.ts.map +1 -1
  26. package/lib/cjs/bspline/KnotVector.js +76 -69
  27. package/lib/cjs/bspline/KnotVector.js.map +1 -1
  28. package/lib/cjs/geometry3d/Matrix3d.d.ts +20 -13
  29. package/lib/cjs/geometry3d/Matrix3d.d.ts.map +1 -1
  30. package/lib/cjs/geometry3d/Matrix3d.js +28 -21
  31. package/lib/cjs/geometry3d/Matrix3d.js.map +1 -1
  32. package/lib/cjs/geometry3d/Point3dVector3d.d.ts +3 -2
  33. package/lib/cjs/geometry3d/Point3dVector3d.d.ts.map +1 -1
  34. package/lib/cjs/geometry3d/Point3dVector3d.js +6 -5
  35. package/lib/cjs/geometry3d/Point3dVector3d.js.map +1 -1
  36. package/lib/cjs/geometry3d/PointHelpers.d.ts +58 -20
  37. package/lib/cjs/geometry3d/PointHelpers.d.ts.map +1 -1
  38. package/lib/cjs/geometry3d/PointHelpers.js +213 -62
  39. package/lib/cjs/geometry3d/PointHelpers.js.map +1 -1
  40. package/lib/cjs/geometry3d/Transform.d.ts +2 -3
  41. package/lib/cjs/geometry3d/Transform.d.ts.map +1 -1
  42. package/lib/cjs/geometry3d/Transform.js +2 -3
  43. package/lib/cjs/geometry3d/Transform.js.map +1 -1
  44. package/lib/cjs/geometry4d/Point4d.d.ts +13 -0
  45. package/lib/cjs/geometry4d/Point4d.d.ts.map +1 -1
  46. package/lib/cjs/geometry4d/Point4d.js +21 -0
  47. package/lib/cjs/geometry4d/Point4d.js.map +1 -1
  48. package/lib/cjs/numerics/BezierPolynomials.d.ts +88 -64
  49. package/lib/cjs/numerics/BezierPolynomials.d.ts.map +1 -1
  50. package/lib/cjs/numerics/BezierPolynomials.js +92 -73
  51. package/lib/cjs/numerics/BezierPolynomials.js.map +1 -1
  52. package/lib/cjs/numerics/PascalCoefficients.d.ts +8 -12
  53. package/lib/cjs/numerics/PascalCoefficients.d.ts.map +1 -1
  54. package/lib/cjs/numerics/PascalCoefficients.js +10 -12
  55. package/lib/cjs/numerics/PascalCoefficients.js.map +1 -1
  56. package/lib/cjs/serialization/BGFBReader.d.ts +10 -10
  57. package/lib/cjs/serialization/BGFBReader.d.ts.map +1 -1
  58. package/lib/cjs/serialization/BGFBReader.js +69 -42
  59. package/lib/cjs/serialization/BGFBReader.js.map +1 -1
  60. package/lib/cjs/serialization/BGFBWriter.d.ts +8 -8
  61. package/lib/cjs/serialization/BGFBWriter.d.ts.map +1 -1
  62. package/lib/cjs/serialization/BGFBWriter.js +80 -55
  63. package/lib/cjs/serialization/BGFBWriter.js.map +1 -1
  64. package/lib/cjs/serialization/GeometrySamples.d.ts.map +1 -1
  65. package/lib/cjs/serialization/GeometrySamples.js +6 -8
  66. package/lib/cjs/serialization/GeometrySamples.js.map +1 -1
  67. package/lib/cjs/serialization/IModelJsonSchema.d.ts +6 -14
  68. package/lib/cjs/serialization/IModelJsonSchema.d.ts.map +1 -1
  69. package/lib/cjs/serialization/IModelJsonSchema.js +84 -262
  70. package/lib/cjs/serialization/IModelJsonSchema.js.map +1 -1
  71. package/lib/cjs/serialization/SerializationHelpers.d.ts +109 -0
  72. package/lib/cjs/serialization/SerializationHelpers.d.ts.map +1 -0
  73. package/lib/cjs/serialization/SerializationHelpers.js +591 -0
  74. package/lib/cjs/serialization/SerializationHelpers.js.map +1 -0
  75. package/lib/esm/bspline/BSpline1dNd.d.ts +12 -2
  76. package/lib/esm/bspline/BSpline1dNd.d.ts.map +1 -1
  77. package/lib/esm/bspline/BSpline1dNd.js +27 -17
  78. package/lib/esm/bspline/BSpline1dNd.js.map +1 -1
  79. package/lib/esm/bspline/BSplineCurve.d.ts +30 -16
  80. package/lib/esm/bspline/BSplineCurve.d.ts.map +1 -1
  81. package/lib/esm/bspline/BSplineCurve.js +68 -44
  82. package/lib/esm/bspline/BSplineCurve.js.map +1 -1
  83. package/lib/esm/bspline/BSplineCurve3dH.d.ts +27 -20
  84. package/lib/esm/bspline/BSplineCurve3dH.d.ts.map +1 -1
  85. package/lib/esm/bspline/BSplineCurve3dH.js +137 -88
  86. package/lib/esm/bspline/BSplineCurve3dH.js.map +1 -1
  87. package/lib/esm/bspline/BSplineSurface.d.ts +138 -74
  88. package/lib/esm/bspline/BSplineSurface.d.ts.map +1 -1
  89. package/lib/esm/bspline/BSplineSurface.js +242 -119
  90. package/lib/esm/bspline/BSplineSurface.js.map +1 -1
  91. package/lib/esm/bspline/Bezier1dNd.d.ts +18 -4
  92. package/lib/esm/bspline/Bezier1dNd.d.ts.map +1 -1
  93. package/lib/esm/bspline/Bezier1dNd.js +19 -5
  94. package/lib/esm/bspline/Bezier1dNd.js.map +1 -1
  95. package/lib/esm/bspline/BezierCurve3dH.d.ts.map +1 -1
  96. package/lib/esm/bspline/BezierCurve3dH.js +2 -1
  97. package/lib/esm/bspline/BezierCurve3dH.js.map +1 -1
  98. package/lib/esm/bspline/KnotVector.d.ts +30 -33
  99. package/lib/esm/bspline/KnotVector.d.ts.map +1 -1
  100. package/lib/esm/bspline/KnotVector.js +76 -69
  101. package/lib/esm/bspline/KnotVector.js.map +1 -1
  102. package/lib/esm/geometry3d/Matrix3d.d.ts +20 -13
  103. package/lib/esm/geometry3d/Matrix3d.d.ts.map +1 -1
  104. package/lib/esm/geometry3d/Matrix3d.js +28 -21
  105. package/lib/esm/geometry3d/Matrix3d.js.map +1 -1
  106. package/lib/esm/geometry3d/Point3dVector3d.d.ts +3 -2
  107. package/lib/esm/geometry3d/Point3dVector3d.d.ts.map +1 -1
  108. package/lib/esm/geometry3d/Point3dVector3d.js +6 -5
  109. package/lib/esm/geometry3d/Point3dVector3d.js.map +1 -1
  110. package/lib/esm/geometry3d/PointHelpers.d.ts +58 -20
  111. package/lib/esm/geometry3d/PointHelpers.d.ts.map +1 -1
  112. package/lib/esm/geometry3d/PointHelpers.js +213 -62
  113. package/lib/esm/geometry3d/PointHelpers.js.map +1 -1
  114. package/lib/esm/geometry3d/Transform.d.ts +2 -3
  115. package/lib/esm/geometry3d/Transform.d.ts.map +1 -1
  116. package/lib/esm/geometry3d/Transform.js +2 -3
  117. package/lib/esm/geometry3d/Transform.js.map +1 -1
  118. package/lib/esm/geometry4d/Point4d.d.ts +13 -0
  119. package/lib/esm/geometry4d/Point4d.d.ts.map +1 -1
  120. package/lib/esm/geometry4d/Point4d.js +21 -0
  121. package/lib/esm/geometry4d/Point4d.js.map +1 -1
  122. package/lib/esm/numerics/BezierPolynomials.d.ts +88 -64
  123. package/lib/esm/numerics/BezierPolynomials.d.ts.map +1 -1
  124. package/lib/esm/numerics/BezierPolynomials.js +92 -73
  125. package/lib/esm/numerics/BezierPolynomials.js.map +1 -1
  126. package/lib/esm/numerics/PascalCoefficients.d.ts +8 -12
  127. package/lib/esm/numerics/PascalCoefficients.d.ts.map +1 -1
  128. package/lib/esm/numerics/PascalCoefficients.js +10 -12
  129. package/lib/esm/numerics/PascalCoefficients.js.map +1 -1
  130. package/lib/esm/serialization/BGFBReader.d.ts +10 -10
  131. package/lib/esm/serialization/BGFBReader.d.ts.map +1 -1
  132. package/lib/esm/serialization/BGFBReader.js +69 -42
  133. package/lib/esm/serialization/BGFBReader.js.map +1 -1
  134. package/lib/esm/serialization/BGFBWriter.d.ts +8 -8
  135. package/lib/esm/serialization/BGFBWriter.d.ts.map +1 -1
  136. package/lib/esm/serialization/BGFBWriter.js +80 -55
  137. package/lib/esm/serialization/BGFBWriter.js.map +1 -1
  138. package/lib/esm/serialization/GeometrySamples.d.ts.map +1 -1
  139. package/lib/esm/serialization/GeometrySamples.js +7 -9
  140. package/lib/esm/serialization/GeometrySamples.js.map +1 -1
  141. package/lib/esm/serialization/IModelJsonSchema.d.ts +6 -14
  142. package/lib/esm/serialization/IModelJsonSchema.d.ts.map +1 -1
  143. package/lib/esm/serialization/IModelJsonSchema.js +85 -263
  144. package/lib/esm/serialization/IModelJsonSchema.js.map +1 -1
  145. package/lib/esm/serialization/SerializationHelpers.d.ts +109 -0
  146. package/lib/esm/serialization/SerializationHelpers.d.ts.map +1 -0
  147. package/lib/esm/serialization/SerializationHelpers.js +588 -0
  148. package/lib/esm/serialization/SerializationHelpers.js.map +1 -0
  149. package/package.json +3 -3
@@ -58,8 +58,11 @@ export declare class BSpline1dNd {
58
58
  static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined;
59
59
  /** Map a span index and local fraction to knot value. */
60
60
  spanFractionToKnot(span: number, localFraction: number): number;
61
- /** Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span. */
62
- evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array): void;
61
+ /**
62
+ * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.
63
+ * @returns true if and only if output arrays are sufficiently sized
64
+ */
65
+ evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array): boolean;
63
66
  /**
64
67
  * * Evaluate the basis functions at spanIndex and fraction.
65
68
  * * Evaluations are stored in the preallocated `this.basisBuffer`
@@ -90,8 +93,15 @@ export declare class BSpline1dNd {
90
93
  * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
91
94
  * to act as a normal bspline.
92
95
  * @returns true if `degree` leading and trailing polygon blocks match
96
+ * @deprecated in 4.x. Use testClosablePolygon instead.
93
97
  */
94
98
  testCloseablePolygon(mode?: BSplineWrapMode): boolean;
99
+ /**
100
+ * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
101
+ * to act as a normal bspline.
102
+ * @returns true if `degree` leading and trailing polygon blocks match
103
+ */
104
+ testClosablePolygon(mode?: BSplineWrapMode): boolean;
95
105
  /** Insert knot and resulting pole into the instance, optionally multiple times.
96
106
  * @param knot the knot to be inserted (may already exist in the KnotVector)
97
107
  * @param totalMultiplicity the total multiplicity of the knot on return
@@ -1 +1 @@
1
- {"version":3,"file":"BSpline1dNd.d.ts","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE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AC,SAAS,EAAE,MAAM;IAS9C,wHAAwH;IACjH,qBAAqB,CAAC,SAAS,EAAE,MAAM;IAS9C,4HAA4H;IACrH,qBAAqB,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,GAAE,MAAU;IAgBjE;;OAEG;IACI,cAAc,IAAI,IAAI;IAgB7B;;;;;OAKG;IACI,oBAAoB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO;IAG5D;;;;OAIG;IACI,mBAAmB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO;IAqB3D;;;OAGG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,GAAG,OAAO;CA2DjE"}
@@ -64,7 +64,10 @@ class BSpline1dNd {
64
64
  spanFractionToKnot(span, localFraction) {
65
65
  return this.knots.spanFractionToKnot(span, localFraction);
66
66
  }
67
- /** Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span. */
67
+ /**
68
+ * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.
69
+ * @returns true if and only if output arrays are sufficiently sized
70
+ */
68
71
  evaluateBasisFunctionsInSpan(spanIndex, spanFraction, f, df, ddf) {
69
72
  if (spanIndex < 0)
70
73
  spanIndex = 0;
@@ -167,28 +170,35 @@ class BSpline1dNd {
167
170
  * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
168
171
  * to act as a normal bspline.
169
172
  * @returns true if `degree` leading and trailing polygon blocks match
173
+ * @deprecated in 4.x. Use testClosablePolygon instead.
170
174
  */
171
175
  testCloseablePolygon(mode) {
176
+ return this.testClosablePolygon(mode);
177
+ }
178
+ /**
179
+ * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon which has been expanded
180
+ * to act as a normal bspline.
181
+ * @returns true if `degree` leading and trailing polygon blocks match
182
+ */
183
+ testClosablePolygon(mode) {
172
184
  if (mode === undefined)
173
185
  mode = this.knots.wrappable;
174
- const degree = this.degree;
186
+ let numPolesToTest = 0;
187
+ if (mode === KnotVector_1.BSplineWrapMode.OpenByAddingControlPoints)
188
+ numPolesToTest = this.degree;
189
+ else if (mode === KnotVector_1.BSplineWrapMode.OpenByRemovingKnots)
190
+ numPolesToTest = 1;
191
+ else
192
+ return false;
193
+ // check for wraparound poles
175
194
  const blockSize = this.poleLength;
176
- const indexDelta = (this.numPoles - this.degree) * blockSize;
177
- const data = this.packedData;
178
- if (mode === KnotVector_1.BSplineWrapMode.OpenByAddingControlPoints) {
179
- // expect {degree} matched points.
180
- const numValuesToTest = degree * blockSize;
181
- for (let i0 = 0; i0 < numValuesToTest; i0++) {
182
- if (!Geometry_1.Geometry.isSameCoordinate(data[i0], data[i0 + indexDelta]))
183
- return false;
184
- }
185
- return true;
195
+ const indexDelta = (this.numPoles - numPolesToTest) * blockSize;
196
+ const numValuesToTest = numPolesToTest * blockSize;
197
+ for (let i0 = 0; i0 < numValuesToTest; i0++) {
198
+ if (!Geometry_1.Geometry.isSameCoordinate(this.packedData[i0], this.packedData[i0 + indexDelta]))
199
+ return false;
186
200
  }
187
- if (mode === KnotVector_1.BSplineWrapMode.OpenByRemovingKnots) {
188
- // no pole conditions are applied.
189
- return true;
190
- }
191
- return false;
201
+ return true;
192
202
  }
193
203
  /** Insert knot and resulting pole into the instance, optionally multiple times.
194
204
  * @param knot the knot to be inserted (may already exist in the KnotVector)
@@ -1 +1 @@
1
- {"version":3,"file":"BSpline1dNd.js","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,0CAAuC;AACvC,mEAAmE;AACnE,mEAAwD;AACxD,6CAA2D;AAE3D;;;;;GAKG;AACH,MAAa,WAAW;IAOtB,gEAAgE;IAChE,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACzD,+FAA+F;IAC/F,IAAW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AC;YACrC,KAAK,MAAM,CAAC,IAAI,OAAO;gBACrB,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,6BAA6B;YAE5D,0EAA0E;YAC1E,QAAQ,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;YACjE,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;YAE/B,EAAE,SAAS,CAAC;YACZ,EAAE,aAAa,CAAC;YAChB,EAAE,aAAa,CAAC;SACjB;QACD,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9PD,kCA8PC","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 { Geometry } from \"../Geometry\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/** Bspline knots and poles for 1d-to-Nd.\r\n * * The \"pole\" (aka control point) of this class is a block of `poleLength` numbers.\r\n * * Derived classes (not this class) assign meaning such as x,y,z,w.\r\n * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w\r\n * @public\r\n */\r\nexport class BSpline1dNd {\r\n /** knots of the bspline */\r\n public knots: KnotVector;\r\n /** poles, packed in blocks of `poleLength` doubles. */\r\n public packedData: Float64Array;\r\n /** (property accessor) Return the number of numeric values per pole. */\r\n public poleLength: number;\r\n /** (property accessor) Return the degree of the polynomials. */\r\n public get degree(): number { return this.knots.degree; }\r\n /** (property accessor) Return the number of order (one more than degree) of the polynomials */\r\n public get order(): number { return this.knots.degree + 1; }\r\n /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/\r\n public get numSpan(): number { return this.numPoles - this.knots.degree; }\r\n /** (property accessor) Return the number of poles*/\r\n public get numPoles(): number { return this.packedData.length / this.poleLength; }\r\n /** copy 3 values of pole `i` into a point.\r\n * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.\r\n */\r\n public getPoint3dPole(i: number, result?: Point3d): Point3d | undefined { return Point3d.createFromPacked(this.packedData, i, result); }\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer1: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer2: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer1: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer2: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n\r\n /**\r\n * initialize arrays for given spline dimensions.\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n protected constructor(numPoles: number, poleLength: number, order: number, knots: KnotVector) {\r\n this.knots = knots;\r\n this.packedData = new Float64Array(numPoles * poleLength);\r\n this.poleLength = poleLength;\r\n this.basisBuffer = new Float64Array(order);\r\n this.poleBuffer = new Float64Array(poleLength);\r\n this.basisBuffer1 = new Float64Array(order);\r\n this.basisBuffer2 = new Float64Array(order);\r\n this.poleBuffer1 = new Float64Array(poleLength);\r\n this.poleBuffer2 = new Float64Array(poleLength);\r\n }\r\n\r\n /**\r\n * create a 1Bspline1dNd`\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n public static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined {\r\n return new BSpline1dNd(numPoles, poleLength, order, knots);\r\n }\r\n /** Map a span index and local fraction to knot value. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this.knots.spanFractionToKnot(span, localFraction);\r\n }\r\n\r\n /** Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span. */\r\n public evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array) {\r\n if (spanIndex < 0) spanIndex = 0;\r\n if (spanIndex >= this.numSpan) spanIndex = this.numSpan - 1;\r\n const knotIndex0 = spanIndex + this.degree - 1;\r\n const globalKnot = this.knots.baseKnotFractionToKnot(knotIndex0, spanFraction);\r\n return df ?\r\n this.knots.evaluateBasisFunctions1(knotIndex0, globalKnot, f, df, ddf) :\r\n this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);\r\n }\r\n /**\r\n * * Evaluate the basis functions at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer`\r\n * */\r\n public evaluateBuffersInSpan(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n }\r\n /**\r\n * * Evaluate the basis functions and one derivative at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`\r\n * */\r\n public evaluateBuffersInSpan1(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n this.sumPoleBuffer1ForSpan(spanIndex);\r\n }\r\n /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */\r\n public sumPoleBufferForSpan(spanIndex: number) {\r\n this.poleBuffer.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer) {\r\n for (let j = 0; j < this.poleLength; j++) { this.poleBuffer[j] += f * this.packedData[k++]; }\r\n }\r\n }\r\n /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */\r\n public sumPoleBuffer1ForSpan(spanIndex: number) {\r\n this.poleBuffer1.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer1) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer1[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */\r\n public sumPoleBuffer2ForSpan(spanIndex: number) {\r\n this.poleBuffer2.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer2) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer2[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */\r\n public evaluateBuffersAtKnot(u: number, numDerivative: number = 0) {\r\n const knotIndex0 = this.knots.knotToLeftKnotIndex(u);\r\n if (numDerivative < 1) {\r\n this.knots.evaluateBasisFunctions(knotIndex0, u, this.basisBuffer);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n } else if (numDerivative === 1) {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n } else {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1, this.basisBuffer2);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);\r\n }\r\n }\r\n /**\r\n * Reverse the (blocked) poles (in `this.packedData` in place.\r\n */\r\n public reverseInPlace(): void {\r\n // reverse poles in blocks ...\r\n const b = this.poleLength;\r\n const data = this.packedData;\r\n for (let i0 = 0, j0 = b * (this.numPoles - 1);\r\n i0 < j0;\r\n i0 += b, j0 -= b) {\r\n let t = 0;\r\n for (let i = 0; i < b; i++) {\r\n t = data[i0 + i];\r\n data[i0 + i] = data[j0 + i];\r\n data[j0 + i] = t;\r\n }\r\n }\r\n this.knots.reflectKnots();\r\n }\r\n /**\r\n * Test if the leading and trailing polygon coordinates are replicated in the manner of a \"closed\" bspline polygon which has been expanded\r\n * to act as a normal bspline.\r\n * @returns true if `degree` leading and trailing polygon blocks match\r\n */\r\n public testCloseablePolygon(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.knots.wrappable;\r\n const degree = this.degree;\r\n const blockSize = this.poleLength;\r\n const indexDelta = (this.numPoles - this.degree) * blockSize;\r\n const data = this.packedData;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints) {\r\n // expect {degree} matched points.\r\n const numValuesToTest = degree * blockSize;\r\n for (let i0 = 0; i0 < numValuesToTest; i0++) {\r\n if (!Geometry.isSameCoordinate(data[i0], data[i0 + indexDelta]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n if (mode === BSplineWrapMode.OpenByRemovingKnots) {\r\n // no pole conditions are applied.\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /** Insert knot and resulting pole into the instance, optionally multiple times.\r\n * @param knot the knot to be inserted (may already exist in the KnotVector)\r\n * @param totalMultiplicity the total multiplicity of the knot on return\r\n */\r\n public addKnot(knot: number, totalMultiplicity: number): boolean {\r\n if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)\r\n return false; // invalid input\r\n let iLeftKnot = this.knots.knotToLeftKnotIndex(knot);\r\n\r\n // snap input if too close to an existing knot\r\n if (Math.abs(knot - this.knots.knots[iLeftKnot]) < KnotVector.knotTolerance) {\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of bracket\r\n } else if (Math.abs(knot - this.knots.knots[iLeftKnot + 1]) < KnotVector.knotTolerance) {\r\n iLeftKnot += this.knots.getKnotMultiplicityAtIndex(iLeftKnot + 1);\r\n if (iLeftKnot > this.knots.rightKnotIndex)\r\n return true; // nothing to do\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of next bracket\r\n }\r\n const numKnotsToAdd = Math.min(totalMultiplicity, this.degree) - this.knots.getKnotMultiplicity(knot);\r\n if (numKnotsToAdd <= 0)\r\n return true; // nothing to do\r\n\r\n // working arrays and pole buffer\r\n let currKnotCount = this.knots.knots.length;\r\n const newKnots = new Float64Array(currKnotCount + numKnotsToAdd);\r\n for (let i = 0; i < currKnotCount; ++i)\r\n newKnots[i] = this.knots.knots[i];\r\n let currPoleCount = this.numPoles;\r\n const newPackedData = new Float64Array(this.packedData.length + (numKnotsToAdd * this.poleLength));\r\n for (let i = 0; i < this.packedData.length; ++i)\r\n newPackedData[i] = this.packedData[i];\r\n const dataBuf = new Float64Array(this.degree * this.poleLength); // holds degree poles\r\n\r\n // each iteration adds one knot and one pole to the working arrays (cf. Farin 4e)\r\n for (let iter = 0; iter < numKnotsToAdd; ++iter) {\r\n // fill the buffer with new poles obtained from control polygon corner cutting\r\n let iBuf = 0;\r\n const iStart = iLeftKnot - this.degree + 2;\r\n for (let i = iStart; i < iStart + this.degree; ++i) {\r\n const fraction = (knot - newKnots[i - 1]) / (newKnots[i + this.degree - 1] - newKnots[i - 1]);\r\n for (let j = i * this.poleLength; j < (i + 1) * this.poleLength; ++j) {\r\n dataBuf[iBuf++] = Geometry.interpolate(newPackedData[j - this.poleLength], fraction, newPackedData[j]);\r\n }\r\n }\r\n\r\n // overwrite degree-1 poles with degree new poles, shifting tail to the right by one\r\n newPackedData.copyWithin((iStart + this.degree) * this.poleLength, (iStart + this.degree - 1) * this.poleLength, currPoleCount * this.poleLength);\r\n let iData = iStart * this.poleLength;\r\n for (const d of dataBuf)\r\n newPackedData[iData++] = d; // overwrite degree new poles\r\n\r\n // add the knot to newKnots in position, shifting tail to the right by one\r\n newKnots.copyWithin(iLeftKnot + 2, iLeftKnot + 1, currKnotCount);\r\n newKnots[iLeftKnot + 1] = knot;\r\n\r\n ++iLeftKnot;\r\n ++currKnotCount;\r\n ++currPoleCount;\r\n }\r\n this.knots.setKnotsCapture(newKnots);\r\n this.packedData = newPackedData;\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"BSpline1dNd.js","sourceRoot":"","sources":["../../../src/bspline/BSpline1dNd.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2CAA2C;AAC3C,0CAAuC;AACvC,mEAAmE;AACnE,mEAAwD;AACxD,6CAA2D;AAE3D;;;;;GAKG;AACH,MAAa,WAAW;IAOtB,gEAAgE;IAChE,IAAW,MAAM,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,C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AAU,EAAE,aAAa,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;YAClJ,IAAI,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC;YACrC,KAAK,MAAM,CAAC,IAAI,OAAO;gBACrB,aAAa,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAE,6BAA6B;YAE5D,0EAA0E;YAC1E,QAAQ,CAAC,UAAU,CAAC,SAAS,GAAG,CAAC,EAAE,SAAS,GAAG,CAAC,EAAE,aAAa,CAAC,CAAC;YACjE,QAAQ,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;YAE/B,EAAE,SAAS,CAAC;YACZ,EAAE,aAAa,CAAC;YAChB,EAAE,aAAa,CAAC;SACjB;QACD,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAtQD,kCAsQC","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 { Geometry } from \"../Geometry\";\r\n/* eslint-disable @typescript-eslint/naming-convention, no-empty */\r\nimport { Point3d } from \"../geometry3d/Point3dVector3d\";\r\nimport { BSplineWrapMode, KnotVector } from \"./KnotVector\";\r\n\r\n/** Bspline knots and poles for 1d-to-Nd.\r\n * * The \"pole\" (aka control point) of this class is a block of `poleLength` numbers.\r\n * * Derived classes (not this class) assign meaning such as x,y,z,w.\r\n * * for instance, an instance of this class with `poleLength===3` does not know if its poles are x,y,z or weighted 2D x,y,w\r\n * @public\r\n */\r\nexport class BSpline1dNd {\r\n /** knots of the bspline */\r\n public knots: KnotVector;\r\n /** poles, packed in blocks of `poleLength` doubles. */\r\n public packedData: Float64Array;\r\n /** (property accessor) Return the number of numeric values per pole. */\r\n public poleLength: number;\r\n /** (property accessor) Return the degree of the polynomials. */\r\n public get degree(): number { return this.knots.degree; }\r\n /** (property accessor) Return the number of order (one more than degree) of the polynomials */\r\n public get order(): number { return this.knots.degree + 1; }\r\n /** (property accessor) Return the number of bezier spans (including null spans at multiple knots)*/\r\n public get numSpan(): number { return this.numPoles - this.knots.degree; }\r\n /** (property accessor) Return the number of poles*/\r\n public get numPoles(): number { return this.packedData.length / this.poleLength; }\r\n /** copy 3 values of pole `i` into a point.\r\n * * The calling class is responsible for knowing if this is an appropriate access to the blocked data.\r\n */\r\n public getPoint3dPole(i: number, result?: Point3d): Point3d | undefined { return Point3d.createFromPacked(this.packedData, i, result); }\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer1: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `order`) used as temporary in evaluations */\r\n public basisBuffer2: Float64Array; // one set of basis function values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer1: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n /** preallocated array (length === `poleLength`) used as temporary in evaluations */\r\n public poleBuffer2: Float64Array; // one set of target values. ALLOCATED BY CTOR FOR FREQUENT REUSE\r\n\r\n /**\r\n * initialize arrays for given spline dimensions.\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n protected constructor(numPoles: number, poleLength: number, order: number, knots: KnotVector) {\r\n this.knots = knots;\r\n this.packedData = new Float64Array(numPoles * poleLength);\r\n this.poleLength = poleLength;\r\n this.basisBuffer = new Float64Array(order);\r\n this.poleBuffer = new Float64Array(poleLength);\r\n this.basisBuffer1 = new Float64Array(order);\r\n this.basisBuffer2 = new Float64Array(order);\r\n this.poleBuffer1 = new Float64Array(poleLength);\r\n this.poleBuffer2 = new Float64Array(poleLength);\r\n }\r\n\r\n /**\r\n * create a 1Bspline1dNd`\r\n * @param numPoles number of poles\r\n * @param poleLength number of coordinates per pole (e.g.. 3 for 3D unweighted, 4 for 3d weighted, 2 for 2d unweighted, 3 for 2d weighted)\r\n * @param order number of poles in support for a section of the bspline\r\n * @param knots KnotVector. This is captured, not cloned.\r\n */\r\n public static create(numPoles: number, poleLength: number, order: number, knots: KnotVector): BSpline1dNd | undefined {\r\n return new BSpline1dNd(numPoles, poleLength, order, knots);\r\n }\r\n /** Map a span index and local fraction to knot value. */\r\n public spanFractionToKnot(span: number, localFraction: number): number {\r\n return this.knots.spanFractionToKnot(span, localFraction);\r\n }\r\n\r\n /**\r\n * Evaluate the `order` basis functions (and optionally one or two derivatives) at a given fractional position within indexed span.\r\n * @returns true if and only if output arrays are sufficiently sized\r\n */\r\n public evaluateBasisFunctionsInSpan(spanIndex: number, spanFraction: number, f: Float64Array, df?: Float64Array, ddf?: Float64Array): boolean {\r\n if (spanIndex < 0) spanIndex = 0;\r\n if (spanIndex >= this.numSpan) spanIndex = this.numSpan - 1;\r\n const knotIndex0 = spanIndex + this.degree - 1;\r\n const globalKnot = this.knots.baseKnotFractionToKnot(knotIndex0, spanFraction);\r\n return df ?\r\n this.knots.evaluateBasisFunctions1(knotIndex0, globalKnot, f, df, ddf) :\r\n this.knots.evaluateBasisFunctions(knotIndex0, globalKnot, f);\r\n }\r\n /**\r\n * * Evaluate the basis functions at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer`\r\n * */\r\n public evaluateBuffersInSpan(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n }\r\n /**\r\n * * Evaluate the basis functions and one derivative at spanIndex and fraction.\r\n * * Evaluations are stored in the preallocated `this.basisBuffer`\r\n * * Immediately do the summations of the basis values times the respective control points\r\n * * Summations are stored in the preallocated `this.poleBuffer` and `this.poleBuffer1`\r\n * */\r\n public evaluateBuffersInSpan1(spanIndex: number, spanFraction: number) {\r\n this.evaluateBasisFunctionsInSpan(spanIndex, spanFraction, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(spanIndex);\r\n this.sumPoleBuffer1ForSpan(spanIndex);\r\n }\r\n /** sum poles in `poleBuffer` at span `spanIndex` by the weights in the `basisBuffer` */\r\n public sumPoleBufferForSpan(spanIndex: number) {\r\n this.poleBuffer.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer) {\r\n for (let j = 0; j < this.poleLength; j++) { this.poleBuffer[j] += f * this.packedData[k++]; }\r\n }\r\n }\r\n /** sum poles in `poleBuffer1` at span `spanIndex` by the weights in the `basisBuffer1`, i.e. form first derivatives */\r\n public sumPoleBuffer1ForSpan(spanIndex: number) {\r\n this.poleBuffer1.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer1) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer1[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** sum poles in `poleBuffer2` at span `spanIndex` by the weights in the `basisBuffer2`, i.e. form second derivatives */\r\n public sumPoleBuffer2ForSpan(spanIndex: number) {\r\n this.poleBuffer2.fill(0);\r\n let k = spanIndex * this.poleLength;\r\n for (const f of this.basisBuffer2) {\r\n for (let j = 0; j < this.poleLength; j++) {\r\n this.poleBuffer2[j] += f * this.packedData[k++];\r\n }\r\n }\r\n }\r\n /** Evaluate the function values and 1 or 2 derivatives into `this.poleBuffer`, `this.poleBuffer1` and `this.poleBuffer2` */\r\n public evaluateBuffersAtKnot(u: number, numDerivative: number = 0) {\r\n const knotIndex0 = this.knots.knotToLeftKnotIndex(u);\r\n if (numDerivative < 1) {\r\n this.knots.evaluateBasisFunctions(knotIndex0, u, this.basisBuffer);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n } else if (numDerivative === 1) {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n } else {\r\n this.knots.evaluateBasisFunctions1(knotIndex0, u, this.basisBuffer, this.basisBuffer1, this.basisBuffer2);\r\n this.sumPoleBufferForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer1ForSpan(knotIndex0 - this.degree + 1);\r\n this.sumPoleBuffer2ForSpan(knotIndex0 - this.degree + 1);\r\n }\r\n }\r\n /**\r\n * Reverse the (blocked) poles (in `this.packedData` in place.\r\n */\r\n public reverseInPlace(): void {\r\n // reverse poles in blocks ...\r\n const b = this.poleLength;\r\n const data = this.packedData;\r\n for (let i0 = 0, j0 = b * (this.numPoles - 1);\r\n i0 < j0;\r\n i0 += b, j0 -= b) {\r\n let t = 0;\r\n for (let i = 0; i < b; i++) {\r\n t = data[i0 + i];\r\n data[i0 + i] = data[j0 + i];\r\n data[j0 + i] = t;\r\n }\r\n }\r\n this.knots.reflectKnots();\r\n }\r\n /**\r\n * Test if the leading and trailing polygon coordinates are replicated in the manner of a \"closed\" bspline polygon which has been expanded\r\n * to act as a normal bspline.\r\n * @returns true if `degree` leading and trailing polygon blocks match\r\n * @deprecated in 4.x. Use testClosablePolygon instead.\r\n */\r\n public testCloseablePolygon(mode?: BSplineWrapMode): boolean {\r\n return this.testClosablePolygon(mode);\r\n }\r\n /**\r\n * Test if the leading and trailing polygon coordinates are replicated in the manner of a \"closed\" bspline polygon which has been expanded\r\n * to act as a normal bspline.\r\n * @returns true if `degree` leading and trailing polygon blocks match\r\n */\r\n public testClosablePolygon(mode?: BSplineWrapMode): boolean {\r\n if (mode === undefined)\r\n mode = this.knots.wrappable;\r\n let numPolesToTest = 0;\r\n if (mode === BSplineWrapMode.OpenByAddingControlPoints)\r\n numPolesToTest = this.degree;\r\n else if (mode === BSplineWrapMode.OpenByRemovingKnots)\r\n numPolesToTest = 1;\r\n else\r\n return false;\r\n // check for wraparound poles\r\n const blockSize = this.poleLength;\r\n const indexDelta = (this.numPoles - numPolesToTest) * blockSize;\r\n const numValuesToTest = numPolesToTest * blockSize;\r\n for (let i0 = 0; i0 < numValuesToTest; i0++) {\r\n if (!Geometry.isSameCoordinate(this.packedData[i0], this.packedData[i0 + indexDelta]))\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Insert knot and resulting pole into the instance, optionally multiple times.\r\n * @param knot the knot to be inserted (may already exist in the KnotVector)\r\n * @param totalMultiplicity the total multiplicity of the knot on return\r\n */\r\n public addKnot(knot: number, totalMultiplicity: number): boolean {\r\n if (knot < this.knots.leftKnot || knot > this.knots.rightKnot)\r\n return false; // invalid input\r\n let iLeftKnot = this.knots.knotToLeftKnotIndex(knot);\r\n\r\n // snap input if too close to an existing knot\r\n if (Math.abs(knot - this.knots.knots[iLeftKnot]) < KnotVector.knotTolerance) {\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of bracket\r\n } else if (Math.abs(knot - this.knots.knots[iLeftKnot + 1]) < KnotVector.knotTolerance) {\r\n iLeftKnot += this.knots.getKnotMultiplicityAtIndex(iLeftKnot + 1);\r\n if (iLeftKnot > this.knots.rightKnotIndex)\r\n return true; // nothing to do\r\n knot = this.knots.knots[iLeftKnot]; // snap to left knot of next bracket\r\n }\r\n const numKnotsToAdd = Math.min(totalMultiplicity, this.degree) - this.knots.getKnotMultiplicity(knot);\r\n if (numKnotsToAdd <= 0)\r\n return true; // nothing to do\r\n\r\n // working arrays and pole buffer\r\n let currKnotCount = this.knots.knots.length;\r\n const newKnots = new Float64Array(currKnotCount + numKnotsToAdd);\r\n for (let i = 0; i < currKnotCount; ++i)\r\n newKnots[i] = this.knots.knots[i];\r\n let currPoleCount = this.numPoles;\r\n const newPackedData = new Float64Array(this.packedData.length + (numKnotsToAdd * this.poleLength));\r\n for (let i = 0; i < this.packedData.length; ++i)\r\n newPackedData[i] = this.packedData[i];\r\n const dataBuf = new Float64Array(this.degree * this.poleLength); // holds degree poles\r\n\r\n // each iteration adds one knot and one pole to the working arrays (cf. Farin 4e)\r\n for (let iter = 0; iter < numKnotsToAdd; ++iter) {\r\n // fill the buffer with new poles obtained from control polygon corner cutting\r\n let iBuf = 0;\r\n const iStart = iLeftKnot - this.degree + 2;\r\n for (let i = iStart; i < iStart + this.degree; ++i) {\r\n const fraction = (knot - newKnots[i - 1]) / (newKnots[i + this.degree - 1] - newKnots[i - 1]);\r\n for (let j = i * this.poleLength; j < (i + 1) * this.poleLength; ++j) {\r\n dataBuf[iBuf++] = Geometry.interpolate(newPackedData[j - this.poleLength], fraction, newPackedData[j]);\r\n }\r\n }\r\n\r\n // overwrite degree-1 poles with degree new poles, shifting tail to the right by one\r\n newPackedData.copyWithin((iStart + this.degree) * this.poleLength, (iStart + this.degree - 1) * this.poleLength, currPoleCount * this.poleLength);\r\n let iData = iStart * this.poleLength;\r\n for (const d of dataBuf)\r\n newPackedData[iData++] = d; // overwrite degree new poles\r\n\r\n // add the knot to newKnots in position, shifting tail to the right by one\r\n newKnots.copyWithin(iLeftKnot + 2, iLeftKnot + 1, currKnotCount);\r\n newKnots[iLeftKnot + 1] = knot;\r\n\r\n ++iLeftKnot;\r\n ++currKnotCount;\r\n ++currPoleCount;\r\n }\r\n this.knots.setKnotsCapture(newKnots);\r\n this.packedData = newPackedData;\r\n return true;\r\n }\r\n}\r\n"]}
@@ -85,15 +85,29 @@ export declare abstract class BSplineCurve3dBase extends CurvePrimitive {
85
85
  get numSpan(): number;
86
86
  /** Return the number of poles */
87
87
  get numPoles(): number;
88
+ /** Return live reference to the packed control point coordinates of the curve. */
89
+ get polesRef(): Float64Array;
90
+ /** Return live reference to the knots of the curve. */
91
+ get knotsRef(): Float64Array;
92
+ /** Number of components per pole.
93
+ * * 3 for conventional (x,y,z) curve
94
+ * * 4 for weighted (wx,wy,wz,w) curve
95
+ */
96
+ get poleDimension(): number;
88
97
  /**
89
- * return a simple array form of the knots. optionally replicate the first and last
90
- * in classic over-clamped manner
91
- */
98
+ * return a simple array form of the knots. optionally replicate the first and last
99
+ * in classic over-clamped manner
100
+ */
92
101
  copyKnots(includeExtraEndKnot: boolean): number[];
93
- /**
94
- * Set the flag indicating the bspline might be suitable for having wrapped "closed" interpretation.
95
- */
102
+ /** Get the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
103
+ getWrappable(): BSplineWrapMode;
104
+ /** Set the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
96
105
  setWrappable(value: BSplineWrapMode): void;
106
+ /**
107
+ * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
108
+ * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
109
+ */
110
+ get isClosableCurve(): BSplineWrapMode;
97
111
  /** Evaluate at a position given by fractional position within a span. */
98
112
  abstract evaluatePointInSpan(spanIndex: number, spanFraction: number, result?: Point3d): Point3d;
99
113
  /** Evaluate at a position given by fractional position within a span. */
@@ -237,12 +251,17 @@ export declare class BSplineCurve3d extends BSplineCurve3dBase {
237
251
  * @param options collection of points and end conditions.
238
252
  */
239
253
  static createFromAkimaCurve3dOptions(options: AkimaCurve3dOptions): BSplineCurve3d | undefined;
240
- /** Create a bspline with given knots.
241
- * * Only two knot count conditions are recognized; all others return undefined:
254
+ /**
255
+ * Create a bspline with given knots.
256
+ * * The poles have several variants:
257
+ * * Float64Array(3 * numPoles) in blocks of [x,y,z]
258
+ * * Point3d[]
259
+ * * number[][], with inner dimension 3
260
+ * * Two count conditions are recognized:
242
261
  * * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots of classic clamping.
243
262
  * * If poleArray.length + order === knotArray.length + 2, the knots are in modern form.
244
263
  */
245
- static create(poleArray: Float64Array | Point3d[], knotArray: Float64Array | number[], order: number): BSplineCurve3d | undefined;
264
+ static create(poleArray: Float64Array | Point3d[] | number[][], knotArray: Float64Array | number[], order: number): BSplineCurve3d | undefined;
246
265
  /** Return a deep clone */
247
266
  clone(): BSplineCurve3d;
248
267
  /** Evaluate at a position given by fractional position within a span. */
@@ -280,9 +299,8 @@ export declare class BSplineCurve3d extends BSplineCurve3dBase {
280
299
  /** Append strokes to a linestring. */
281
300
  emitStrokes(dest: LineString3d, options?: StrokeOptions): void;
282
301
  /**
283
- * Test knots, control points, and wrappable flag to see if all agree for a possible wrapping.
284
- * @returns the manner of closing. Se BSplineWrapMode for particulars of each mode.
285
- *
302
+ * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
303
+ * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
286
304
  */
287
305
  get isClosable(): BSplineWrapMode;
288
306
  /**
@@ -303,10 +321,6 @@ export declare class BSplineCurve3d extends BSplineCurve3dBase {
303
321
  * @param result optional reusable curve. This will only be reused if it is a BezierCurve3d with matching order.
304
322
  */
305
323
  getSaturatedBezierSpan3dH(spanIndex: number, result?: BezierCurveBase): BezierCurve3dH | undefined;
306
- /**
307
- * Set the flag indicating the bspline might be suitable for having wrapped "closed" interpretation.
308
- */
309
- setWrappable(value: BSplineWrapMode): void;
310
324
  /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)` */
311
325
  dispatchToGeometryHandler(handler: GeometryHandler): any;
312
326
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"BSplineCurve.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C,EAAE,aAAa,GAAG,IAAI;IAwBjF;;;OAGG;IACI,4BAA4B,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,MAAM;IAWpE;;;;;OAKG;IACa,qCAAqC,CAAC,OAAO,CAAC,EAAE,aAAa,EAAE,eAAe,CAAC,EAAE,cAAc;IAe/G,sCAAsC;IAC/B,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI;IASrE;;;OAGG;IACF,IAAW,UAAU,IAAI,eAAe,CAExC;IACD;;;;OAIG;IACI,6BAA6B,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,eAAe,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,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"}
@@ -91,17 +91,42 @@ class BSplineCurve3dBase extends CurvePrimitive_1.CurvePrimitive {
91
91
  get numSpan() { return this._bcurve.numSpan; }
92
92
  /** Return the number of poles */
93
93
  get numPoles() { return this._bcurve.numPoles; }
94
+ /** Return live reference to the packed control point coordinates of the curve. */
95
+ get polesRef() { return this._bcurve.packedData; }
96
+ /** Return live reference to the knots of the curve. */
97
+ get knotsRef() { return this._bcurve.knots.knots; }
98
+ /** Number of components per pole.
99
+ * * 3 for conventional (x,y,z) curve
100
+ * * 4 for weighted (wx,wy,wz,w) curve
101
+ */
102
+ get poleDimension() { return this._bcurve.poleLength; }
94
103
  /**
95
- * return a simple array form of the knots. optionally replicate the first and last
96
- * in classic over-clamped manner
97
- */
104
+ * return a simple array form of the knots. optionally replicate the first and last
105
+ * in classic over-clamped manner
106
+ */
98
107
  copyKnots(includeExtraEndKnot) { return this._bcurve.knots.copyKnots(includeExtraEndKnot); }
99
- /**
100
- * Set the flag indicating the bspline might be suitable for having wrapped "closed" interpretation.
101
- */
108
+ /** Get the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
109
+ getWrappable() {
110
+ return this._bcurve.knots.wrappable;
111
+ }
112
+ /** Set the flag indicating the curve might be suitable for having wrapped "closed" interpretation. */
102
113
  setWrappable(value) {
103
114
  this._bcurve.knots.wrappable = value;
104
115
  }
116
+ /**
117
+ * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
118
+ * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
119
+ */
120
+ get isClosableCurve() {
121
+ const mode = this._bcurve.knots.wrappable;
122
+ if (mode === KnotVector_1.BSplineWrapMode.None)
123
+ return KnotVector_1.BSplineWrapMode.None;
124
+ if (!this._bcurve.knots.testClosable(mode))
125
+ return KnotVector_1.BSplineWrapMode.None;
126
+ if (!this._bcurve.testClosablePolygon(mode))
127
+ return KnotVector_1.BSplineWrapMode.None;
128
+ return mode;
129
+ }
105
130
  /** Evaluate the curve point at `fraction` */
106
131
  fractionToPoint(fraction, result) {
107
132
  return this.knotToPoint(this._bcurve.knots.fractionToKnot(fraction), result);
@@ -390,6 +415,8 @@ class BSplineCurve3d extends BSplineCurve3dBase {
390
415
  if (order < 2)
391
416
  return undefined;
392
417
  let numPoles = poles instanceof Float64Array ? poles.length / 3 : poles.length;
418
+ if (numPoles < 2)
419
+ return undefined;
393
420
  const startPoint = Point3dVector3d_1.Point3d.createZero();
394
421
  const endPoint = Point3dVector3d_1.Point3d.createZero();
395
422
  let hasClosurePoint = false;
@@ -399,8 +426,8 @@ class BSplineCurve3d extends BSplineCurve3dBase {
399
426
  endPoint.set(poles[3 * numPoles - 3], poles[3 * numPoles - 2], poles[3 * numPoles - 1]);
400
427
  }
401
428
  else if (poles instanceof GrowableXYZArray_1.GrowableXYZArray) {
402
- startPoint.set(poles.float64Data()[0], poles.float64Data()[1], poles.float64Data()[2]);
403
- endPoint.set(poles.float64Data()[3 * numPoles - 3], poles.float64Data()[3 * numPoles - 2], poles.float64Data()[3 * numPoles - 1]);
429
+ poles.getPoint3dAtUncheckedPointIndex(0, startPoint);
430
+ poles.getPoint3dAtUncheckedPointIndex(numPoles - 1, endPoint);
404
431
  }
405
432
  else {
406
433
  startPoint.setFromPoint3d(poles[0]);
@@ -418,15 +445,18 @@ class BSplineCurve3d extends BSplineCurve3dBase {
418
445
  // append degree wraparound poles
419
446
  const curve = new BSplineCurve3d(numPoles + degree, order, knots);
420
447
  if (poles instanceof Float64Array) {
421
- for (let i = 0; i < 3 * numPoles; i++)
422
- curve._bcurve.packedData[i] = poles[i];
423
- for (let i = 0; i < 3 * degree; i++)
424
- curve._bcurve.packedData[3 * numPoles + i] = poles[i];
448
+ let i = 0;
449
+ for (let j = 0; j < 3 * numPoles; j++)
450
+ curve._bcurve.packedData[i++] = poles[j];
451
+ for (let j = 0; j < 3 * degree; j++)
452
+ curve._bcurve.packedData[i++] = poles[j];
425
453
  }
426
454
  else if (poles instanceof GrowableXYZArray_1.GrowableXYZArray) {
427
- curve._bcurve.packedData = poles.float64Data().slice(0, 3 * numPoles);
428
- for (let i = 0; i < 3 * degree; i++)
429
- curve._bcurve.packedData[3 * numPoles + i] = poles.float64Data()[i];
455
+ let i = 0;
456
+ for (let j = 0; j < 3 * numPoles; j++)
457
+ curve._bcurve.packedData[i++] = poles.float64Data()[j];
458
+ for (let j = 0; j < 3 * degree; j++)
459
+ curve._bcurve.packedData[i++] = poles.float64Data()[j];
430
460
  }
431
461
  else {
432
462
  let i = 0;
@@ -457,8 +487,13 @@ class BSplineCurve3d extends BSplineCurve3dBase {
457
487
  static createFromAkimaCurve3dOptions(options) {
458
488
  return BSplineCurveOps_1.BSplineCurveOps.createThroughPoints(options.fitPoints, 4); // temporary
459
489
  }
460
- /** Create a bspline with given knots.
461
- * * Only two knot count conditions are recognized; all others return undefined:
490
+ /**
491
+ * Create a bspline with given knots.
492
+ * * The poles have several variants:
493
+ * * Float64Array(3 * numPoles) in blocks of [x,y,z]
494
+ * * Point3d[]
495
+ * * number[][], with inner dimension 3
496
+ * * Two count conditions are recognized:
462
497
  * * If poleArray.length + order === knotArray.length, the first and last are assumed to be the extraneous knots of classic clamping.
463
498
  * * If poleArray.length + order === knotArray.length + 2, the knots are in modern form.
464
499
  */
@@ -466,18 +501,13 @@ class BSplineCurve3d extends BSplineCurve3dBase {
466
501
  if (order < 2)
467
502
  return undefined;
468
503
  let numPoles = poleArray.length;
469
- if (poleArray instanceof Float64Array) {
470
- numPoles /= 3; // blocked as xyz
471
- }
504
+ if (poleArray instanceof Float64Array)
505
+ numPoles = Math.floor(numPoles / 3); // blocked as xyz
472
506
  if (numPoles < order)
473
507
  return undefined;
474
508
  const numKnots = knotArray.length;
475
- let skipFirstAndLast;
476
- if (numPoles + order === numKnots)
477
- skipFirstAndLast = true; // classic (first/last knots extraneous)
478
- else if (numPoles + order === numKnots + 2)
479
- skipFirstAndLast = false; // modern
480
- else
509
+ const skipFirstAndLast = (numPoles + order === numKnots); // classic over-clamped input knots
510
+ if (!skipFirstAndLast && numPoles + order !== numKnots + 2) // modern knots
481
511
  return undefined;
482
512
  const knots = KnotVector_1.KnotVector.create(knotArray, order - 1, skipFirstAndLast);
483
513
  const curve = new BSplineCurve3d(numPoles, order, knots);
@@ -486,13 +516,21 @@ class BSplineCurve3d extends BSplineCurve3dBase {
486
516
  for (const coordinate of poleArray)
487
517
  curve._bcurve.packedData[i++] = coordinate;
488
518
  }
489
- else {
519
+ else if (poleArray[0] instanceof Point3dVector3d_1.Point3d) {
490
520
  for (const p of poleArray) {
491
521
  curve._bcurve.packedData[i++] = p.x;
492
522
  curve._bcurve.packedData[i++] = p.y;
493
523
  curve._bcurve.packedData[i++] = p.z;
494
524
  }
495
525
  }
526
+ else if (Array.isArray(poleArray[0]) && poleArray[0].length === 3) {
527
+ for (const point of poleArray)
528
+ for (const coord of point)
529
+ curve._bcurve.packedData[i++] = coord;
530
+ }
531
+ else {
532
+ return undefined; // unexpected poleArray type
533
+ }
496
534
  return curve;
497
535
  }
498
536
  /** Return a deep clone */
@@ -612,19 +650,11 @@ class BSplineCurve3d extends BSplineCurve3dBase {
612
650
  }
613
651
  }
614
652
  /**
615
- * Test knots, control points, and wrappable flag to see if all agree for a possible wrapping.
616
- * @returns the manner of closing. Se BSplineWrapMode for particulars of each mode.
617
- *
653
+ * Test knots and control points to determine if it is possible to close (aka "wrap") the curve.
654
+ * @returns the manner in which it is possible to close the curve. See `BSplineWrapMode` for particulars of each mode.
618
655
  */
619
656
  get isClosable() {
620
- const mode = this._bcurve.knots.wrappable;
621
- if (mode === KnotVector_1.BSplineWrapMode.None)
622
- return KnotVector_1.BSplineWrapMode.None;
623
- if (!this._bcurve.knots.testClosable(mode))
624
- return KnotVector_1.BSplineWrapMode.None;
625
- if (!this._bcurve.testCloseablePolygon(mode))
626
- return KnotVector_1.BSplineWrapMode.None;
627
- return mode;
657
+ return this.isClosableCurve;
628
658
  }
629
659
  /**
630
660
  * Return a BezierCurveBase for this curve. The concrete return type may be BezierCurve3d or BezierCurve3dH according to this type.
@@ -670,12 +700,6 @@ class BSplineCurve3d extends BSplineCurve3dBase {
670
700
  return bezier;
671
701
  return undefined;
672
702
  }
673
- /**
674
- * Set the flag indicating the bspline might be suitable for having wrapped "closed" interpretation.
675
- */
676
- setWrappable(value) {
677
- this._bcurve.knots.wrappable = value;
678
- }
679
703
  /** Second step of double dispatch: call `handler.handleBSplineCurve3d(this)` */
680
704
  dispatchToGeometryHandler(handler) {
681
705
  return handler.handleBSplineCurve3d(this);