DataSet

vtkDataSet is an abstract class that specifies an interface for dataset
objects. vtkDataSet also provides methods to provide informations about
the data, such as center, bounding box, and representative length.

In vtk a dataset consists of a structure (geometry and topology) and
attribute data. The structure is defined implicitly or explicitly as
a collection of cells. The geometry of the structure is contained in
point coordinates plus the cell interpolation functions. The topology
of the dataset structure is defined by cell types and how the cells
share their defining points.

Attribute data in vtk is either point data (data at points) or cell data
(data at cells). Typically filters operate on point data, but some may
operate on cell data, both cell and point data, either one, or none.

newInstance()

Construct a new vtkDataSet with some initial content.

api TBD

Source

Constants.js
// Specify how data arrays can be used by data objects
export const FieldDataTypes = {
UNIFORM: 0, // data that does not vary over points/cells/etc.
DATA_OBJECT_FIELD: 0, // to match VTK

COORDINATE: 1, // data that specifies the location of each point
POINT_DATA: 1, // to match VTK

POINT: 2, // data defined at each point, but that does not specify the point location
POINT_FIELD_DATA: 2, // to match VTK

CELL: 3, // data defined at each cell, but that does not specify the cell
CELL_FIELD_DATA: 3, // to match VTK

VERTEX: 4, // data defined at each graph vertex, but that does not specify the graph vertex
VERTEX_FIELD_DATA: 4, // to match VTK

EDGE: 5, // data defined at each graph edge, but that does not specify the graph edge
EDGE_FIELD_DATA: 5, // to match VTK

ROW: 6, // data specifying a table row
ROW_DATA: 6, // to match VTK
};

export const FieldAssociations = {
FIELD_ASSOCIATION_POINTS: 0,
FIELD_ASSOCIATION_CELLS: 1,
FIELD_ASSOCIATION_NONE: 2,
FIELD_ASSOCIATION_POINTS_THEN_CELLS: 3,
FIELD_ASSOCIATION_VERTICES: 4,
FIELD_ASSOCIATION_EDGES: 5,
FIELD_ASSOCIATION_ROWS: 6,
NUMBER_OF_ASSOCIATIONS: 7,
};

export default {
FieldDataTypes,
FieldAssociations,
};
index.js
import macro from 'vtk.js/Sources/macro';
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.newInstance();
// const size = array.length;
// const delta = ds.Points.numberOfComponents ? ds.Points.numberOfComponents : 3;
// for (let idx = 0; idx < size; idx += delta) {
// bbox.addPoint(array[idx * delta], array[(idx * delta) + 1], array[(idx * delta) + 2]);
// }
// ds.Points.bounds = bbox.getBounds();
// 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 Object.assign({ newInstance, extend }, Constants);