UNPKG

@kitware/vtk.js

Version:

Visualization Toolkit for the Web

80 lines (64 loc) 2.49 kB
import vtk from '../../vtk.js'; import { m as macro } from '../../macros2.js'; import vtkDataSet from './DataSet.js'; import vtkPoints from '../Core/Points.js'; // ---------------------------------------------------------------------------- // Global methods // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // vtkPointSet methods // ---------------------------------------------------------------------------- function vtkPointSet(publicAPI, model) { // Set our className model.classHierarchy.push('vtkPointSet'); // Create empty points if (!model.points) { model.points = vtkPoints.newInstance(); } else { model.points = vtk(model.points); } publicAPI.getNumberOfPoints = () => model.points.getNumberOfPoints(); publicAPI.getBounds = () => model.points?.getBounds(); publicAPI.computeBounds = () => { model.points?.computeBounds(); }; const superShallowCopy = publicAPI.shallowCopy; publicAPI.shallowCopy = (other, debug = false) => { superShallowCopy(other, debug); model.points = vtkPoints.newInstance(); model.points.shallowCopy(other.getPoints()); }; const superGetMTime = publicAPI.getMTime; publicAPI.getMTime = () => { const mTime = superGetMTime(); return Math.max(mTime, model.points?.getMTime() ?? mTime); }; const superInitialize = publicAPI.initialize; publicAPI.initialize = () => { model.points?.initialize(); return superInitialize(); }; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { // points: null, }; // ---------------------------------------------------------------------------- function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance vtkDataSet.extend(publicAPI, model, initialValues); macro.setGet(publicAPI, model, ['points']); // Object specific methods vtkPointSet(publicAPI, model); } // ---------------------------------------------------------------------------- const newInstance = macro.newInstance(extend, 'vtkPointSet'); // ---------------------------------------------------------------------------- var vtkPointSet$1 = { newInstance, extend }; export { vtkPointSet$1 as default, extend, newInstance };