@kitware/vtk.js 25.4.0 → 25.7.0

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 (98) hide show
  1. package/Common/Core/CellArray.d.ts +20 -8
  2. package/Common/Core/CellArray.js +25 -6
  3. package/Common/Core/DataArray.d.ts +159 -15
  4. package/Common/Core/DataArray.js +181 -26
  5. package/Common/Core/Math/index.js +1 -1
  6. package/Common/Core/Math.js +1 -1
  7. package/Common/Core/Points.d.ts +6 -5
  8. package/Common/Core/Points.js +8 -4
  9. package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
  10. package/Common/DataModel/AbstractPointLocator.js +40 -0
  11. package/Common/DataModel/DataSetAttributes/FieldData.d.ts +33 -22
  12. package/Common/DataModel/DataSetAttributes/FieldData.js +91 -9
  13. package/Common/DataModel/DataSetAttributes.d.ts +44 -0
  14. package/Common/DataModel/DataSetAttributes.js +11 -0
  15. package/Common/DataModel/IncrementalOctreeNode.d.ts +282 -0
  16. package/Common/DataModel/IncrementalOctreeNode.js +621 -0
  17. package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
  18. package/Common/DataModel/IncrementalOctreePointLocator.js +342 -0
  19. package/Common/DataModel/Line.js +1 -1
  20. package/Common/DataModel/Locator.d.ts +43 -0
  21. package/Common/DataModel/Locator.js +37 -0
  22. package/Common/DataModel/Plane.js +1 -1
  23. package/Common/DataModel/Polygon/Constants.js +12 -0
  24. package/Common/DataModel/Polygon.d.ts +38 -4
  25. package/Common/DataModel/Polygon.js +210 -6
  26. package/Common/DataModel/Quad/Constants.js +9 -0
  27. package/Common/DataModel/Quad.d.ts +91 -0
  28. package/Common/DataModel/Quad.js +235 -0
  29. package/Common/DataModel/Triangle.d.ts +106 -81
  30. package/Common/DataModel/Triangle.js +1 -1
  31. package/Common/Transform/LandmarkTransform.js +1 -1
  32. package/Filters/Core/PolyDataNormals.js +1 -1
  33. package/Filters/General/ClipClosedSurface/Constants.js +10 -0
  34. package/Filters/General/ClipClosedSurface/ccsEdgeLocator.js +40 -0
  35. package/Filters/General/ClipClosedSurface.d.ts +95 -0
  36. package/Filters/General/ClipClosedSurface.js +970 -0
  37. package/Filters/General/ContourTriangulator/Constants.js +6 -0
  38. package/Filters/General/ContourTriangulator/helper.js +1951 -0
  39. package/Filters/General/ContourTriangulator.d.ts +122 -0
  40. package/Filters/General/ContourTriangulator.js +200 -0
  41. package/Filters/General/ImageMarchingCubes.js +1 -1
  42. package/Filters/General/MoleculeToRepresentation.js +1 -1
  43. package/Filters/General/OBBTree.js +1 -1
  44. package/Filters/General/TubeFilter.js +1 -1
  45. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  46. package/Filters/Sources/PlaneSource.js +1 -1
  47. package/Filters/Texture/TextureMapToPlane.js +1 -1
  48. package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +4 -8
  49. package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +6 -14
  50. package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +60 -57
  51. package/IO/Core/ZipMultiDataSetReader.js +19 -29
  52. package/IO/Core/ZipMultiDataSetWriter.js +7 -23
  53. package/IO/Misc/SkyboxReader.js +67 -75
  54. package/IO/XML/XMLReader.js +2 -2
  55. package/IO/XML/XMLWriter.js +2 -2
  56. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  57. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
  58. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
  59. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  60. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  61. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  62. package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
  63. package/Interaction/Style/InteractorStyleTrackballCamera.js +16 -0
  64. package/Proxy/Core/View2DProxy.js +1 -1
  65. package/Rendering/Core/Actor2D.d.ts +12 -6
  66. package/Rendering/Core/Camera.js +1 -1
  67. package/Rendering/Core/CellPicker.js +3 -2
  68. package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
  69. package/Rendering/Core/Light.js +1 -1
  70. package/Rendering/Core/Picker.js +1 -1
  71. package/Rendering/Core/Property2D.d.ts +1 -1
  72. package/Rendering/Core/VolumeProperty.d.ts +4 -4
  73. package/Rendering/Core/VolumeProperty.js +1 -1
  74. package/Rendering/OpenGL/PolyDataMapper.js +1 -1
  75. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +65 -0
  76. package/Rendering/OpenGL/RenderWindow.js +3 -1
  77. package/Rendering/WebGPU/BufferManager.js +1 -1
  78. package/Rendering/WebGPU/ForwardPass.js +93 -15
  79. package/Rendering/WebGPU/OpaquePass.js +1 -1
  80. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  81. package/Rendering/WebGPU/RenderEncoder.js +9 -5
  82. package/Rendering/WebGPU/RenderWindow.js +15 -13
  83. package/Rendering/WebGPU/TextureView.js +15 -2
  84. package/Rendering/WebGPU/VolumePass.js +1 -1
  85. package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
  86. package/Widgets/Manipulators/LineManipulator.js +1 -1
  87. package/Widgets/Manipulators/TrackballManipulator.js +1 -1
  88. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  89. package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
  90. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  91. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  92. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  93. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  94. package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
  95. package/index.d.ts +8 -0
  96. package/index.js +0 -2
  97. package/package.json +3 -4
  98. package/ThirdParty/index.js +0 -9
@@ -1,13 +1,12 @@
1
1
  import { TypedArray } from './../../types';
2
- import vtkDataArray from './DataArray';
2
+ import vtkDataArray, { IDataArrayInitialValues } from './DataArray';
3
3
 
4
4
 
5
5
  /**
6
- *
6
+ * The inital values of a vtkCellArray.
7
7
  */
8
- export interface ICellArrayInitialValues {
8
+ export interface ICellArrayInitialValues extends IDataArrayInitialValues {
9
9
  empty?: boolean;
10
- numberOfComponents?: number;
11
10
  }
12
11
 
13
12
  export interface vtkCellArray extends vtkDataArray {
@@ -19,22 +18,35 @@ export interface vtkCellArray extends vtkDataArray {
19
18
  getNumberOfCells(recompute?: boolean): number;
20
19
 
21
20
  /**
22
- *
21
+ * Get the sizes of the cells in this array.
23
22
  * @param {Boolean} [recompute] Recompute the cell sizes.
24
23
  */
25
24
  getCellSizes(recompute?: boolean): any;
26
25
 
27
26
  /**
28
- *
29
- * @param {TypedArray} typedArray The typedArray value.
27
+ * Set the data of this array.
28
+ * @param {TypedArray} typedArray The Array value.
30
29
  */
31
30
  setData(typedArray: TypedArray): void;
32
31
 
33
32
  /**
34
- * Returns the point indexes at the given location as a subarray.
33
+ * Returns the point indices at the given location as a subarray.
35
34
  * @param loc
36
35
  */
37
36
  getCell(loc: any): void;
37
+
38
+ /**
39
+ * Reset the cell array by setting the number of cells to 0.
40
+ * NOTE: This won't touch the actual memory of the underlying typedArray.
41
+ */
42
+ initialize(): void;
43
+
44
+ /**
45
+ * Insert a cell to this array in the next available slot.
46
+ * @param {Number[]} cellPointIds The list of point ids (NOT prefixed with the number of points)
47
+ * @returns {Number} Idx of where the cell was inserted
48
+ */
49
+ insertNextCell(cellPointIds: number[]): number;
38
50
  }
39
51
 
40
52
  /**
@@ -1,4 +1,5 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
3
  import macro from '../../macros.js';
3
4
  import vtkDataArray from './DataArray.js';
4
5
  import { VtkDataTypes } from './DataArray/Constants.js';
@@ -54,7 +55,7 @@ function vtkCellArray(publicAPI, model) {
54
55
  if (model.cellSizes) {
55
56
  model.numberOfCells = model.cellSizes.length;
56
57
  } else {
57
- model.numberOfCells = getNumberOfCells(model.values);
58
+ model.numberOfCells = getNumberOfCells(publicAPI.getData());
58
59
  }
59
60
 
60
61
  return model.numberOfCells;
@@ -65,7 +66,7 @@ function vtkCellArray(publicAPI, model) {
65
66
  return model.cellSizes;
66
67
  }
67
68
 
68
- model.cellSizes = extractCellSizes(model.values);
69
+ model.cellSizes = extractCellSizes(publicAPI.getData());
69
70
  return model.cellSizes;
70
71
  };
71
72
 
@@ -76,16 +77,34 @@ function vtkCellArray(publicAPI, model) {
76
77
  model.numberOfCells = undefined;
77
78
  model.cellSizes = undefined;
78
79
  };
79
- /**
80
- * Returns the point indexes at the given location as a subarray.
81
- */
82
-
83
80
 
84
81
  publicAPI.getCell = function (loc) {
85
82
  var cellLoc = loc;
86
83
  var numberOfPoints = model.values[cellLoc++];
87
84
  return model.values.subarray(cellLoc, cellLoc + numberOfPoints);
88
85
  };
86
+
87
+ var superInitialize = publicAPI.initialize;
88
+
89
+ publicAPI.initialize = function () {
90
+ superInitialize(); // Set to undefined to ensure insertNextCell works correctly
91
+
92
+ model.numberOfCells = undefined;
93
+ model.cellSizes = undefined;
94
+ };
95
+
96
+ publicAPI.insertNextCell = function (cellPointIds) {
97
+ var cellId = publicAPI.getNumberOfCells();
98
+ publicAPI.insertNextTuples([cellPointIds.length].concat(_toConsumableArray(cellPointIds))); // By computing the number of cells earlier, we made sure that numberOfCells is defined
99
+
100
+ ++model.numberOfCells;
101
+
102
+ if (model.cellSizes != null) {
103
+ model.cellSizes.push(cellPointIds.length);
104
+ }
105
+
106
+ return cellId;
107
+ };
89
108
  } // ----------------------------------------------------------------------------
90
109
  // Object factory
91
110
  // ----------------------------------------------------------------------------
@@ -1,5 +1,5 @@
1
1
  import { vtkObject, vtkRange } from './../../interfaces';
2
- import { TypedArray } from './../../types';
2
+ import { float, int, Nullable, TypedArray } from './../../types';
3
3
 
4
4
 
5
5
  /**
@@ -22,6 +22,19 @@ interface vtkRangeHelper {
22
22
  getRange(): vtkRange;
23
23
  }
24
24
 
25
+ /**
26
+ * The inital values of a vtkDataArray.
27
+ */
28
+ export interface IDataArrayInitialValues {
29
+ dataType?: string;
30
+ empty?: boolean;
31
+ name?: string;
32
+ numberOfComponents?: number;
33
+ rangeTuple?: [number, number];
34
+ size?: number;
35
+ values?: Array<number>|TypedArray;
36
+ }
37
+
25
38
  export interface vtkDataArray extends vtkObject {
26
39
 
27
40
  /**
@@ -64,56 +77,151 @@ export interface vtkDataArray extends vtkObject {
64
77
  setRange(rangeValue: vtkRange, componentIndex: number): [number, number];
65
78
 
66
79
  /**
80
+ * Set the given tuple at the given index.
81
+ * @param {Number} idx
82
+ * @param {Array<Number>|TypedArray} tuple
83
+ */
84
+ setTuple(idx: number, tuple: Array<number>|TypedArray): void;
85
+
86
+ /**
87
+ * Set the given tuples starting at the given index.
88
+ * @param {Number} idx
89
+ * @param {Array<Number>|TypedArray} tuples
90
+ */
91
+ setTuples(idx: number, tuples: Array<number>|TypedArray): void;
92
+
93
+ /**
94
+ * Get the tuple at the given index.
95
+ *
96
+ * The recommended use is the following:
97
+ * `const x = [];`
98
+ * `dataArray.getTuple(idx, x);`
99
+ * instead of:
100
+ * `const x = dataArray.getTuple(idx);`
67
101
  *
68
102
  * @param {Number} idx
69
- * @param {Number[]} tuple
103
+ * @param {Array<Number>} [tupleToFill] (default [])
104
+ * @returns {Array<Number>}
105
+ */
106
+ getTuple(idx: number, tupleToFill?: Array<number>): Array<number>;
107
+
108
+ /**
109
+ * Get the tuples between fromId (inclusive) and toId (exclusive).
110
+ *
111
+ * If fromId or toId is negative, it refers to a tuple index from the
112
+ * end of the underlying typedArray.
113
+ * If the range between fromId and toId is invalid, getTuples returns
114
+ * null.
115
+ *
116
+ * NOTE: Any changes to the returned TypedArray will result in changes to
117
+ * this DataArray's underlying TypedArray.
118
+ *
119
+ * @param {Number} [fromId] (default: 0)
120
+ * @param {Number} [toId] (default: publicAPI.getNumberOfTuples())
121
+ * @returns {Nullable<TypedArray>}
70
122
  */
71
- setTuple(idx: number, tuple: number[]): void;
123
+ getTuples(fromId?: number, toId?: number): Nullable<TypedArray>;
72
124
 
73
125
  /**
126
+ * Insert the given tuple at the given index.
127
+ * NOTE: May resize the data values array. "Safe" version of setTuple.
128
+ *
129
+ * A typical usage is when `vtkDataArray` is initialized with
130
+ * `initialValues = { size: 0, values: new Uint8Array(1000) }`, where
131
+ * an empty but pre-allocated array with 1'000 components is created.
132
+ * The component values can then be inserted with `insertTuple()` or
133
+ * `insertNextTuple()` without requiring new memory allocation until
134
+ * the size of 1'000 is exceeded (e.g. after inserting the 250th
135
+ * 4-component tuple).
136
+ *
137
+ * `insertTuple` increases the number of tuples (`getNumberOfTuples()`).
138
+ *
139
+ * @see insertNextTuple
140
+ * @see getNumberOfTuples
74
141
  *
75
142
  * @param {Number} idx
76
- * @param {Number[]} [tupleToFill] (default [])
143
+ * @param {Array<Number>|TypedArray} tuple
144
+ * @returns {Number} Index of the inserted tuple
77
145
  */
78
- getTuple(idx: number, tupleToFill?: number[]): number[];
146
+ insertTuple(idx: number, tuple: Array<number>|TypedArray): number;
147
+
148
+ /**
149
+ * Insert tuples starting at the given idx.
150
+ *
151
+ * @param {Number} idx
152
+ * @param {Array<Number>|TypedArray} tuples Flat array of tuples to insert
153
+ * @returns The index of the last inserted tuple
154
+ */
155
+ insertTuples(idx: number, tuples: Array<number>|TypedArray): number;
156
+
157
+ /**
158
+ * Insert the given tuple at the next available slot and return the index of the insertion.
159
+ * NOTE: May resize the data values array. "Safe" version of setTuple.
160
+ *
161
+ * @see insertTuple
162
+ *
163
+ * @param {Array<Number>|TypedArray} tuple
164
+ * @returns {Number} Index of the inserted tuple.
165
+ */
166
+ insertNextTuple(tuple: Array<number>|TypedArray): number;
167
+
168
+ /**
169
+ * Convenience function to insert an array of tuples with insertNextTuple.
170
+ * NOTE: tuples.length must be a multiple of `getNumberOfComponents`.
171
+ * @param {Array<Number>|TypedArray} tuples
172
+ * @returns The index of the last inserted tuple
173
+ */
174
+ insertNextTuples(tuples: Array<number>|TypedArray): number;
79
175
 
80
176
  /**
81
177
  *
82
178
  * @param {Number} [idx] (default: 1)
179
+ * @returns {Number}
83
180
  */
84
181
  getTupleLocation(idx?: number): number;
85
182
 
86
183
  /**
87
184
  * Get the dimension (n) of the components.
185
+ * @returns {Number}
88
186
  */
89
187
  getNumberOfComponents(): number;
90
188
 
91
189
  /**
92
- * Get the total number of values in the array.
190
+ * Get the actual number of values in the array, which is equal to `getNumberOfTuples() * getNumberOfComponents()`.
191
+ * @returns {Number}
93
192
  */
94
193
  getNumberOfValues(): number;
95
194
 
96
195
  /**
97
- * Get the number of complete tuples (a component group) in the array.
196
+ * Get the actual number of complete tuples (a component group) in the array.
197
+ * @returns {Number}
98
198
  */
99
199
  getNumberOfTuples(): number;
100
200
 
101
201
  /**
102
- *
202
+ * Get the data type of this array as a string.
203
+ * @returns {String}
103
204
  */
104
205
  getDataType(): string;
105
206
 
106
207
  /**
107
- *
208
+ * Return a clone of this array.
209
+ * @returns {vtkDataArray}
108
210
  */
109
211
  newClone(): vtkDataArray;
110
212
 
111
213
  /**
112
- *
214
+ * Get the name of the array.
215
+ * @returns {String}
113
216
  */
114
217
  getName(): string;
115
218
 
116
219
  /**
220
+ * Set the data of this array.
221
+ * Optionally pass ´numberOfComponents´ to overwrite this dataArray's
222
+ * numberOfComponents.
223
+ * If this dataArray's numberOfComponents doesn't divide the given array's
224
+ * length, this dataArray's numberOfComponents is set to 1.
117
225
  *
118
226
  * @param {TypedArray} typedArray
119
227
  * @param {Number} [numberOfComponents]
@@ -121,14 +229,50 @@ export interface vtkDataArray extends vtkObject {
121
229
  setData(typedArray: TypedArray, numberOfComponents?: number): void;
122
230
 
123
231
  /**
124
- *
232
+ * Get the state of this array.
233
+ * @returns {object}
125
234
  */
126
235
  getState(): object;
127
236
 
237
+ /**
238
+ * Deep copy of another vtkDataArray into this one.
239
+ * @param {vtkDataArray} other
240
+ */
241
+ deepCopy(other: vtkDataArray): void;
242
+
243
+ /**
244
+ * Interpolate between the tuples retrieved from source1
245
+ * and source2 with the resp. indices and set the
246
+ * resulting tuple to the idx of this DataArray.
247
+ *
248
+ * @param {int} idx,
249
+ * @param {vtkDataArray} source1,
250
+ * @param {int} source1Idx,
251
+ * @param {vtkDataArray} source2,
252
+ * @param {int} source2Idx,
253
+ * @param {float} t
254
+ */
255
+ interpolateTuple(
256
+ idx: int,
257
+ source1: vtkDataArray,
258
+ source1Idx: int,
259
+ source2: vtkDataArray,
260
+ source2Idx: int,
261
+ t: float
262
+ ): void;
263
+
264
+ /**
265
+ * Reset this array.
266
+ * NOTE: This won't touch the actual memory of the underlying typedArray.
267
+ */
268
+ initialize(): void;
269
+
128
270
  // --- via macro --
129
271
 
130
272
  /**
131
- *
273
+ * Set the name of this array.
274
+ * @param {String} name
275
+ * @returns {Boolean}
132
276
  */
133
277
  setName(name: string): boolean;
134
278
 
@@ -199,9 +343,9 @@ export function getMaxNorm(dataArray: vtkDataArray): number
199
343
  *
200
344
  * @param publicAPI object on which methods will be bounds (public)
201
345
  * @param model object on which data structure will be bounds (protected)
202
- * @param {object} [initialValues] (default: {})
346
+ * @param {object} [initialValues] (default: {}) Must pass a number > 0 for `size` except if `empty: true` is also passed or a non-empty typed array for `values`.
203
347
  */
204
- export function extend(publicAPI: object, model: object, initialValues?: object): void;
348
+ export function extend(publicAPI: object, model: object, initialValues?: IDataArrayInitialValues): void;
205
349
 
206
350
  // ----------------------------------------------------------------------------
207
351
 
@@ -252,7 +396,7 @@ export declare const vtkDataArray: {
252
396
  // static
253
397
  computeRange: typeof computeRange,
254
398
  createRangeHelper: typeof createRangeHelper,
255
- fastComputeRange: typeof fastComputeRange,
399
+ fastComputeRange: typeof fastComputeRange,
256
400
  getDataType: typeof getDataType,
257
401
  getMaxNorm: typeof getMaxNorm,
258
402
  // constants
@@ -1,11 +1,12 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import Constants from './DataArray/Constants.js';
3
- import { newInstance as newInstance$1, newTypedArray, newTypedArrayFrom, obj, set } from '../../macros.js';
3
+ import { newInstance as newInstance$1, newTypedArray, newTypedArrayFrom, obj, set, vtkErrorMacro as vtkErrorMacro$1 } from '../../macros.js';
4
4
  import { n as norm } from './Math/index.js';
5
5
 
6
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7
7
 
8
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
+ var vtkErrorMacro = vtkErrorMacro$1;
9
10
  var DefaultDataType = Constants.DefaultDataType;
10
11
  var TUPLE_HOLDER = []; // ----------------------------------------------------------------------------
11
12
  // Global methods
@@ -164,6 +165,44 @@ function vtkDataArray(publicAPI, model) {
164
165
  model.ranges = null;
165
166
  publicAPI.modified();
166
167
  }
168
+ /**
169
+ * Resize model.values and copy the old values to the new array.
170
+ * @param {Number} requestedNumTuples Final expected number of tuples; must be >= 0
171
+ * @returns {Boolean} True if a resize occured, false otherwise
172
+ */
173
+
174
+
175
+ function resize(requestedNumTuples) {
176
+ if (requestedNumTuples < 0) {
177
+ return false;
178
+ }
179
+
180
+ var numComps = publicAPI.getNumberOfComponents();
181
+ var curNumTuples = model.values.length / (numComps > 0 ? numComps : 1);
182
+
183
+ if (requestedNumTuples === curNumTuples) {
184
+ return true;
185
+ }
186
+
187
+ if (requestedNumTuples > curNumTuples) {
188
+ // Requested size is bigger than current size. Allocate enough
189
+ // memory to fit the requested size and be more than double the
190
+ // currently allocated memory.
191
+ var oldValues = model.values;
192
+ model.values = newTypedArray(model.dataType, (requestedNumTuples + curNumTuples) * numComps);
193
+ model.values.set(oldValues);
194
+ return true;
195
+ } // Requested size is smaller than current size
196
+
197
+
198
+ model.size = requestedNumTuples * numComps;
199
+ dataChange();
200
+ return true;
201
+ }
202
+
203
+ publicAPI.initialize = function () {
204
+ resize(0);
205
+ };
167
206
 
168
207
  publicAPI.getElementComponentSize = function () {
169
208
  return model.values.BYTES_PER_ELEMENT;
@@ -190,8 +229,20 @@ function vtkDataArray(publicAPI, model) {
190
229
  }
191
230
  };
192
231
 
232
+ publicAPI.getValue = function (valueIdx) {
233
+ var idx = valueIdx / model.numberOfComponents;
234
+ var comp = valueIdx % model.numberOfComponents;
235
+ return publicAPI.getComponent(idx, comp);
236
+ };
237
+
238
+ publicAPI.setValue = function (valueIdx, value) {
239
+ var idx = valueIdx / model.numberOfComponents;
240
+ var comp = valueIdx % model.numberOfComponents;
241
+ publicAPI.setComponent(idx, comp, value);
242
+ };
243
+
193
244
  publicAPI.getData = function () {
194
- return model.values;
245
+ return model.size === model.values.length ? model.values : model.values.subarray(0, model.size);
195
246
  };
196
247
 
197
248
  publicAPI.getRange = function () {
@@ -212,7 +263,7 @@ function vtkDataArray(publicAPI, model) {
212
263
  } // Need to compute ranges...
213
264
 
214
265
 
215
- range = computeRange(model.values, componentIndex, model.numberOfComponents);
266
+ range = computeRange(publicAPI.getData(), componentIndex, model.numberOfComponents);
216
267
  model.ranges[rangeIdx] = range;
217
268
  model.rangeTuple[0] = range.min;
218
269
  model.rangeTuple[1] = range.max;
@@ -242,6 +293,47 @@ function vtkDataArray(publicAPI, model) {
242
293
  }
243
294
  };
244
295
 
296
+ publicAPI.setTuples = function (idx, tuples) {
297
+ var i = idx * model.numberOfComponents;
298
+ var last = Math.min(tuples.length, model.size - i);
299
+
300
+ for (var j = 0; j < last;) {
301
+ model.values[i++] = tuples[j++];
302
+ }
303
+ };
304
+
305
+ publicAPI.insertTuple = function (idx, tuple) {
306
+ if (model.size <= idx * model.numberOfComponents) {
307
+ model.size = (idx + 1) * model.numberOfComponents;
308
+ resize(idx + 1);
309
+ }
310
+
311
+ publicAPI.setTuple(idx, tuple);
312
+ return idx;
313
+ };
314
+
315
+ publicAPI.insertTuples = function (idx, tuples) {
316
+ var end = idx + tuples.length / model.numberOfComponents;
317
+
318
+ if (model.size < end * model.numberOfComponents) {
319
+ model.size = end * model.numberOfComponents;
320
+ resize(end);
321
+ }
322
+
323
+ publicAPI.setTuples(idx, tuples);
324
+ return end;
325
+ };
326
+
327
+ publicAPI.insertNextTuple = function (tuple) {
328
+ var idx = model.size / model.numberOfComponents;
329
+ return publicAPI.insertTuple(idx, tuple);
330
+ };
331
+
332
+ publicAPI.insertNextTuples = function (tuples) {
333
+ var idx = model.size / model.numberOfComponents;
334
+ return publicAPI.insertTuples(idx, tuples);
335
+ };
336
+
245
337
  publicAPI.getTuple = function (idx) {
246
338
  var tupleToFill = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TUPLE_HOLDER;
247
339
  var numberOfComponents = model.numberOfComponents || 1;
@@ -253,29 +345,40 @@ function vtkDataArray(publicAPI, model) {
253
345
  var offset = idx * numberOfComponents; // Check most common component sizes first
254
346
  // to avoid doing a for loop if possible
255
347
 
256
- if (numberOfComponents === 1) {
257
- tupleToFill[0] = model.values[offset];
258
- } else if (numberOfComponents === 2) {
259
- tupleToFill[0] = model.values[offset];
260
- tupleToFill[1] = model.values[offset + 1];
261
- } else if (numberOfComponents === 3) {
262
- tupleToFill[0] = model.values[offset];
263
- tupleToFill[1] = model.values[offset + 1];
264
- tupleToFill[2] = model.values[offset + 2];
265
- } else if (numberOfComponents === 4) {
266
- tupleToFill[0] = model.values[offset];
267
- tupleToFill[1] = model.values[offset + 1];
268
- tupleToFill[2] = model.values[offset + 2];
269
- tupleToFill[3] = model.values[offset + 3];
270
- } else {
271
- for (var i = 0; i < numberOfComponents; i++) {
272
- tupleToFill[i] = model.values[offset + i];
273
- }
348
+ switch (numberOfComponents) {
349
+ case 4:
350
+ tupleToFill[3] = model.values[offset + 3];
351
+ // eslint-disable-next-line no-fallthrough
352
+
353
+ case 3:
354
+ tupleToFill[2] = model.values[offset + 2];
355
+ // eslint-disable-next-line no-fallthrough
356
+
357
+ case 2:
358
+ tupleToFill[1] = model.values[offset + 1];
359
+ // eslint-disable-next-line no-fallthrough
360
+
361
+ case 1:
362
+ tupleToFill[0] = model.values[offset];
363
+ break;
364
+
365
+ default:
366
+ for (var i = 0; i < numberOfComponents; i++) {
367
+ tupleToFill[i] = model.values[offset + i];
368
+ }
369
+
274
370
  }
275
371
 
276
372
  return tupleToFill;
277
373
  };
278
374
 
375
+ publicAPI.getTuples = function (fromId, toId) {
376
+ var from = (fromId !== null && fromId !== void 0 ? fromId : 0) * model.numberOfComponents;
377
+ var to = (toId !== null && toId !== void 0 ? toId : publicAPI.getNumberOfTuples()) * model.numberOfComponents;
378
+ var arr = publicAPI.getData().subarray(from, to);
379
+ return arr.length > 0 ? arr : null;
380
+ };
381
+
279
382
  publicAPI.getTupleLocation = function () {
280
383
  var idx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
281
384
  return idx * model.numberOfComponents;
@@ -286,11 +389,11 @@ function vtkDataArray(publicAPI, model) {
286
389
  };
287
390
 
288
391
  publicAPI.getNumberOfValues = function () {
289
- return model.values.length;
392
+ return model.size;
290
393
  };
291
394
 
292
395
  publicAPI.getNumberOfTuples = function () {
293
- return model.values.length / model.numberOfComponents;
396
+ return model.size / model.numberOfComponents;
294
397
  };
295
398
 
296
399
  publicAPI.getDataType = function () {
@@ -366,17 +469,66 @@ function vtkDataArray(publicAPI, model) {
366
469
 
367
470
  return sortedObj;
368
471
  };
472
+
473
+ publicAPI.deepCopy = function (other) {
474
+ publicAPI.shallowCopy(other);
475
+ publicAPI.setData(other.getData().slice());
476
+ };
477
+
478
+ publicAPI.interpolateTuple = function (idx, source1, source1Idx, source2, source2Idx, t) {
479
+ var numberOfComponents = model.numberOfComponents || 1;
480
+
481
+ if (numberOfComponents !== source1.getNumberOfComponents() || numberOfComponents !== source2.getNumberOfComponents()) {
482
+ vtkErrorMacro('numberOfComponents must match');
483
+ }
484
+
485
+ var tuple1 = [];
486
+ var tuple2 = [];
487
+ var out = [];
488
+ out.length = numberOfComponents;
489
+ source1.getTuple(source1Idx, tuple1);
490
+ source2.getTuple(source2Idx, tuple2); // Check most common component sizes first
491
+ // to avoid doing a for loop if possible
492
+
493
+ switch (numberOfComponents) {
494
+ case 4:
495
+ out[3] = tuple1[3] + (tuple2[3] - tuple1[3]) * t;
496
+ // eslint-disable-next-line no-fallthrough
497
+
498
+ case 3:
499
+ out[2] = tuple1[2] + (tuple2[2] - tuple1[2]) * t;
500
+ // eslint-disable-next-line no-fallthrough
501
+
502
+ case 2:
503
+ out[1] = tuple1[1] + (tuple2[1] - tuple1[1]) * t;
504
+ // eslint-disable-next-line no-fallthrough
505
+
506
+ case 1:
507
+ out[0] = tuple1[0] + (tuple2[0] - tuple1[0]) * t;
508
+ break;
509
+
510
+ default:
511
+ for (var i = 0; i < numberOfComponents; i++) {
512
+ out[i] = tuple1[i] + (tuple2[i] - tuple1[i]) * t;
513
+ }
514
+
515
+ }
516
+
517
+ return publicAPI.insertTuple(idx, out);
518
+ };
369
519
  } // ----------------------------------------------------------------------------
370
520
  // Object factory
371
521
  // ----------------------------------------------------------------------------
522
+ // size: The current size of the dataArray.
523
+ // NOTE: The underlying typed array may be larger than 'size'.
372
524
 
373
525
 
374
526
  var DEFAULT_VALUES = {
375
527
  name: '',
376
528
  numberOfComponents: 1,
377
- size: 0,
378
529
  dataType: DefaultDataType,
379
- rangeTuple: [0, 0] // values: null,
530
+ rangeTuple: [0, 0] // size: undefined,
531
+ // values: null,
380
532
  // ranges: null,
381
533
 
382
534
  }; // ----------------------------------------------------------------------------
@@ -396,7 +548,10 @@ function extend(publicAPI, model) {
396
548
  }
397
549
 
398
550
  if (model.values) {
399
- model.size = model.values.length;
551
+ var _model$size;
552
+
553
+ // Takes the size if provided (can be lower than `model.values`) otherwise the actual length of `values`.
554
+ model.size = (_model$size = model.size) !== null && _model$size !== void 0 ? _model$size : model.values.length;
400
555
  model.dataType = getDataType(model.values);
401
556
  } // Object methods
402
557
 
@@ -2347,4 +2347,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2347
2347
  'default': vtkMath
2348
2348
  });
2349
2349
 
2350
- export { ceilLog2 as $, rowsToMat3 as A, degreesFromRadians as B, areEquals as C, clampValue as D, arrayRange as E, getMajorAxisIndex as F, isInf as G, rgb2hsv as H, rgb2lab as I, lab2rgb as J, floor as K, round as L, normalize2D as M, nearestPowerOfTwo as N, createUninitializedBounds as O, multiply3x3_vect3 as P, areBoundsInitialized as Q, isPowerOfTwo as R, angleBetweenVectors as S, signedAngleBetweenVectors as T, createArray as U, Pi as V, ceil as W, min as X, max as Y, arrayMin as Z, arrayMax as _, areMatricesEqual as a, factorial as a0, binomial as a1, beginCombination as a2, nextCombination as a3, randomSeed as a4, getSeed as a5, gaussian as a6, multiplyScalar2D as a7, multiplyAccumulate2D as a8, outer as a9, luFactorLinearSystem as aA, luSolveLinearSystem as aB, invertMatrix as aC, estimateMatrixCondition as aD, solveHomogeneousLeastSquares as aE, solveLeastSquares as aF, hex2float as aG, lab2xyz as aH, xyz2lab as aI, xyz2rgb as aJ, rgb2xyz as aK, clampAndNormalizeValue as aL, getScalarTypeFittingRange as aM, getAdjustedScalarRange as aN, extentIsWithinOtherExtent as aO, boundsIsWithinOtherBounds as aP, pointIsWithinBounds as aQ, solve3PointCircle as aR, inf as aS, negInf as aT, isFinite as aU, isNaN as aV, floatToHex2 as aW, floatRGB2HexCode as aX, float2CssRGBA as aY, projectVector as aa, dot2D as ab, projectVector2D as ac, gaussianAmplitude as ad, gaussianWeight as ae, outer2D as af, norm2D as ag, rowsToMat4 as ah, columnsToMat4 as ai, columnsToMat3 as aj, LUFactor3x3 as ak, LUSolve3x3 as al, linearSolve3x3 as am, multiply3x3_mat3 as an, multiplyMatrix as ao, transpose3x3 as ap, invert3x3 as aq, identity3x3 as ar, identity as as, quaternionToMatrix3x3 as at, roundNumber as au, matrix3x3ToQuaternion as av, multiplyQuaternion as aw, orthogonalize3x3 as ax, diagonalize3x3 as ay, singularValueDecomposition3x3 as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, subtract as s, vtkMath as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
2350
+ export { ceilLog2 as $, rowsToMat3 as A, degreesFromRadians as B, areEquals as C, clampValue as D, arrayRange as E, getMajorAxisIndex as F, isInf as G, rgb2hsv as H, rgb2lab as I, lab2rgb as J, floor as K, round as L, normalize2D as M, nearestPowerOfTwo as N, createUninitializedBounds as O, multiply3x3_vect3 as P, areBoundsInitialized as Q, isPowerOfTwo as R, angleBetweenVectors as S, signedAngleBetweenVectors as T, createArray as U, Pi as V, ceil as W, min as X, max as Y, arrayMin as Z, arrayMax as _, areMatricesEqual as a, factorial as a0, binomial as a1, beginCombination as a2, nextCombination as a3, randomSeed as a4, getSeed as a5, gaussian as a6, multiplyScalar2D as a7, multiplyAccumulate2D as a8, outer as a9, luFactorLinearSystem as aA, luSolveLinearSystem as aB, invertMatrix as aC, estimateMatrixCondition as aD, solveHomogeneousLeastSquares as aE, solveLeastSquares as aF, hex2float as aG, lab2xyz as aH, xyz2lab as aI, xyz2rgb as aJ, rgb2xyz as aK, clampAndNormalizeValue as aL, getScalarTypeFittingRange as aM, getAdjustedScalarRange as aN, extentIsWithinOtherExtent as aO, boundsIsWithinOtherBounds as aP, pointIsWithinBounds as aQ, solve3PointCircle as aR, inf as aS, negInf as aT, isFinite as aU, isNaN as aV, floatToHex2 as aW, floatRGB2HexCode as aX, float2CssRGBA as aY, projectVector as aa, dot2D as ab, projectVector2D as ac, gaussianAmplitude as ad, gaussianWeight as ae, outer2D as af, norm2D as ag, rowsToMat4 as ah, columnsToMat4 as ai, columnsToMat3 as aj, LUFactor3x3 as ak, LUSolve3x3 as al, linearSolve3x3 as am, multiply3x3_mat3 as an, multiplyMatrix as ao, transpose3x3 as ap, invert3x3 as aq, identity3x3 as ar, identity as as, quaternionToMatrix3x3 as at, roundNumber as au, matrix3x3ToQuaternion as av, multiplyQuaternion as aw, orthogonalize3x3 as ax, diagonalize3x3 as ay, singularValueDecomposition3x3 as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, vtkMath as g, hsv2rgb as h, isNan as i, solveLinearSystem as j, cross as k, add as l, normalize as m, norm as n, multiplyAccumulate as o, determinant2x2 as p, jacobiN as q, radiansFromDegrees as r, subtract as s, perpendiculars as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };