Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | 1x 1499x 1499x 4497x 4231x 266x 1499x 1499x 15x 15x 45x 45x 1x 1499x 1499x 1499x 1499x 1x | import macro from 'vtk.js/Sources/macros';
import vtk from 'vtk.js/Sources/vtk';
import vtkDataSetAttributes from 'vtk.js/Sources/Common/DataModel/DataSetAttributes';
import Constants from 'vtk.js/Sources/Common/DataModel/DataSet/Constants';
// import vtkBoundingBox from '../BoundingBox';
// import * as vtkMath from '../../Core/Math';
//
// function getBounds(dataset) {
// if (dataset.bounds) {
// return dataset.bounds;
// }
// if (dataset.type && dataset[dataset.type]) {
// const ds = dataset[dataset.type];
// if (ds.bounds) {
// return ds.bounds;
// }
// if (ds.Points && ds.Points.bounds) {
// return ds.Points.bounds;
// }
// if (ds.Points && ds.Points.values) {
// const array = ds.Points.values;
// const bbox = [...vtkBoundingBox.INIT_BOUNDS];
// const size = array.length;
// const delta = ds.Points.numberOfComponents ? ds.Points.numberOfComponents : 3;
// for (let idx = 0; idx < size; idx += delta) {
// vtkBoundingBox.addPoint(bbox, array[idx * delta], array[(idx * delta) + 1], array[(idx * delta) + 2]);
// }
// ds.Points.bounds = bbox;
// return ds.Points.bounds;
// }
// }
// return vtkMath.createUninitializedBounds();
// }
// ----------------------------------------------------------------------------
// Global methods
// ----------------------------------------------------------------------------
const DATASET_FIELDS = ['pointData', 'cellData', 'fieldData'];
// ----------------------------------------------------------------------------
// vtkDataSet methods
// ----------------------------------------------------------------------------
function vtkDataSet(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkDataSet');
// Add dataset attributes
DATASET_FIELDS.forEach((fieldName) => {
if (!model[fieldName]) {
model[fieldName] = vtkDataSetAttributes.newInstance();
} else {
model[fieldName] = vtk(model[fieldName]);
}
});
const superShallowCopy = publicAPI.shallowCopy;
publicAPI.shallowCopy = (other, debug = false) => {
superShallowCopy(other, debug);
DATASET_FIELDS.forEach((fieldName) => {
model[fieldName] = vtkDataSetAttributes.newInstance();
model[fieldName].shallowCopy(other.getReferenceByName(fieldName));
});
};
}
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
// pointData: null,
// cellData: null,
// fieldData: null,
};
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
// Object methods
macro.obj(publicAPI, model);
macro.setGet(publicAPI, model, DATASET_FIELDS);
// Object specific methods
vtkDataSet(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = macro.newInstance(extend, 'vtkDataSet');
// ----------------------------------------------------------------------------
export default { newInstance, extend, ...Constants };
|