@kitware/vtk.js 21.5.0 → 21.5.1
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.
|
@@ -221,23 +221,32 @@ function vtkColorTransferFunction(publicAPI, model) {
|
|
|
221
221
|
|
|
222
222
|
publicAPI.setNodes = function (nodes) {
|
|
223
223
|
if (model.nodes !== nodes) {
|
|
224
|
+
var before = JSON.stringify(model.nodes);
|
|
224
225
|
model.nodes = nodes;
|
|
225
|
-
|
|
226
|
+
var after = JSON.stringify(model.nodes);
|
|
227
|
+
return publicAPI.sortAndUpdateRange() || before !== after;
|
|
226
228
|
}
|
|
229
|
+
|
|
230
|
+
return false;
|
|
227
231
|
}; //----------------------------------------------------------------------------
|
|
228
232
|
// Sort the vector in increasing order, then fill in
|
|
229
233
|
// the Range
|
|
230
234
|
|
|
231
235
|
|
|
232
236
|
publicAPI.sortAndUpdateRange = function () {
|
|
237
|
+
var before = JSON.stringify(model.nodes);
|
|
233
238
|
model.nodes.sort(function (a, b) {
|
|
234
239
|
return a.x - b.x;
|
|
235
240
|
});
|
|
241
|
+
var after = JSON.stringify(model.nodes);
|
|
236
242
|
var modifiedInvoked = publicAPI.updateRange(); // If range is updated, Modified() has been called, don't call it again.
|
|
237
243
|
|
|
238
|
-
if (!modifiedInvoked) {
|
|
244
|
+
if (!modifiedInvoked && before !== after) {
|
|
239
245
|
publicAPI.modified();
|
|
246
|
+
return true;
|
|
240
247
|
}
|
|
248
|
+
|
|
249
|
+
return modifiedInvoked;
|
|
241
250
|
}; //----------------------------------------------------------------------------
|
|
242
251
|
|
|
243
252
|
|
|
@@ -102,12 +102,29 @@ function bindArrays(arraysToBind) {
|
|
|
102
102
|
|
|
103
103
|
function createNewArrayHandler(instance, arrayMetadata, arraysToBind) {
|
|
104
104
|
return function (values) {
|
|
105
|
+
var regMethod = arrayMetadata.registration ? arrayMetadata.registration : 'addArray';
|
|
106
|
+
var location = arrayMetadata.location ? instance.getReferenceByName(arrayMetadata.location) : instance; // Try to prevent unncessary modified
|
|
107
|
+
|
|
108
|
+
var previousArray = null;
|
|
109
|
+
|
|
110
|
+
if (arrayMetadata.location) {
|
|
111
|
+
previousArray = instance.getReferenceByName(arrayMetadata.location).getArray(arrayMetadata.name);
|
|
112
|
+
} else {
|
|
113
|
+
previousArray = instance["get".concat(regMethod.substring(3))]();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (previousArray) {
|
|
117
|
+
if (previousArray.getData() !== values) {
|
|
118
|
+
arraysToBind.push([previousArray.setData, [values, arrayMetadata.numberOfComponents]]);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return previousArray;
|
|
122
|
+
}
|
|
123
|
+
|
|
105
124
|
var vtkClass = arrayMetadata.vtkClass ? arrayMetadata.vtkClass : 'vtkDataArray';
|
|
106
125
|
var array = DATA_ARRAY_MAPPER[vtkClass].newInstance(_objectSpread(_objectSpread({}, arrayMetadata), {}, {
|
|
107
126
|
values: values
|
|
108
127
|
}));
|
|
109
|
-
var regMethod = arrayMetadata.registration ? arrayMetadata.registration : 'addArray';
|
|
110
|
-
var location = arrayMetadata.location ? instance.getReferenceByName(arrayMetadata.location) : instance;
|
|
111
128
|
arraysToBind.push([location[regMethod], [array]]);
|
|
112
129
|
return array;
|
|
113
130
|
};
|
|
@@ -273,6 +290,11 @@ function genericUpdater(instance, state, context) {
|
|
|
273
290
|
context.start(); // -> start(arraysToBind)
|
|
274
291
|
|
|
275
292
|
dependencies.push(Promise.all(promises).then(function () {
|
|
293
|
+
// Since some arrays are getting updated, we should modify our dataset
|
|
294
|
+
if (arraysToBind.length) {
|
|
295
|
+
instance.modified();
|
|
296
|
+
}
|
|
297
|
+
|
|
276
298
|
bindArrays(arraysToBind);
|
|
277
299
|
return true;
|
|
278
300
|
}).catch(function (error) {
|
|
@@ -429,8 +451,6 @@ function colorTransferFunctionUpdater(instance, state, context) {
|
|
|
429
451
|
instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
|
|
430
452
|
nodes: nodes
|
|
431
453
|
}), true);
|
|
432
|
-
instance.sortAndUpdateRange();
|
|
433
|
-
instance.modified();
|
|
434
454
|
context.end(); // -> end(colorTransferFunctionUpdater)
|
|
435
455
|
}
|
|
436
456
|
|
|
@@ -454,12 +474,30 @@ function piecewiseFunctionUpdater(instance, state, context) {
|
|
|
454
474
|
instance.set(_objectSpread(_objectSpread({}, state.properties), {}, {
|
|
455
475
|
nodes: nodes
|
|
456
476
|
}), true);
|
|
457
|
-
instance.sortAndUpdateRange();
|
|
458
|
-
|
|
477
|
+
instance.sortAndUpdateRange(); // instance.modified();
|
|
478
|
+
|
|
459
479
|
context.end(); // -> end(piecewiseFunctionUpdater)
|
|
460
480
|
} // ----------------------------------------------------------------------------
|
|
461
481
|
|
|
462
482
|
|
|
483
|
+
function removeUnavailableArrays(fields, availableNames) {
|
|
484
|
+
var namesToDelete = [];
|
|
485
|
+
var size = fields.getNumberOfArrays();
|
|
486
|
+
|
|
487
|
+
for (var i = 0; i < size; i++) {
|
|
488
|
+
var array = fields.getArray(i);
|
|
489
|
+
var name = array.getName();
|
|
490
|
+
|
|
491
|
+
if (!availableNames.has(name)) {
|
|
492
|
+
namesToDelete.push(name);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
for (var _i = 0; _i < namesToDelete.length; _i++) {
|
|
497
|
+
fields.removeArray(namesToDelete[_i]);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
463
501
|
function createDataSetUpdate() {
|
|
464
502
|
var piecesToFetch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
465
503
|
return function (instance, state, context) {
|
|
@@ -489,8 +527,18 @@ function createDataSetUpdate() {
|
|
|
489
527
|
|
|
490
528
|
delete state.properties.fields; // Reset any pre-existing fields array
|
|
491
529
|
|
|
492
|
-
|
|
493
|
-
|
|
530
|
+
var arrayToKeep = {
|
|
531
|
+
pointData: new Set(),
|
|
532
|
+
cellData: new Set(),
|
|
533
|
+
fieldData: new Set()
|
|
534
|
+
};
|
|
535
|
+
fieldsArrays.forEach(function (_ref5) {
|
|
536
|
+
var location = _ref5.location,
|
|
537
|
+
name = _ref5.name;
|
|
538
|
+
arrayToKeep[location].add(name);
|
|
539
|
+
});
|
|
540
|
+
removeUnavailableArrays(instance.getPointData(), arrayToKeep.pointData);
|
|
541
|
+
removeUnavailableArrays(instance.getCellData(), arrayToKeep.cellData); // Generic handling
|
|
494
542
|
|
|
495
543
|
var res = genericUpdater(instance, state, context); // Finish what we started
|
|
496
544
|
|
package/macros.js
CHANGED