UNPKG

@kitware/vtk.js

Version:

Visualization Toolkit for the Web

63 lines (53 loc) 2.16 kB
import { m as macro } from '../../macros2.js'; import vtkAbstractMapper from './AbstractMapper.js'; import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js'; // ---------------------------------------------------------------------------- // vtkAbstractMapper methods // ---------------------------------------------------------------------------- function vtkAbstractMapper3D(publicAPI, model) { publicAPI.computeBounds = () => { macro.vtkErrorMacro(`vtkAbstractMapper3D.computeBounds - NOT IMPLEMENTED`); }; const superGetBounds = publicAPI.getBounds; publicAPI.getBounds = () => { publicAPI.computeBounds(); return superGetBounds(); }; const superGetBoundsByReference = publicAPI.getBoundsByReference; publicAPI.getBoundsByReference = () => { publicAPI.computeBounds(); return superGetBoundsByReference(); }; publicAPI.getCenter = () => { const bounds = publicAPI.getBoundsByReference(); model.center = vtkBoundingBox.isValid(bounds) ? vtkBoundingBox.getCenter(bounds) : null; return model.center?.slice(); }; publicAPI.getLength = () => { const bounds = publicAPI.getBoundsByReference(); return vtkBoundingBox.getDiagonalLength(bounds); }; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const defaultValues = initialValues => ({ bounds: [...vtkBoundingBox.INIT_BOUNDS], center: [0, 0, 0], viewSpecificProperties: {}, ...initialValues }); // ---------------------------------------------------------------------------- function extend(publicAPI, model, initialValues = {}) { Object.assign(model, defaultValues(initialValues)); // Inheritance vtkAbstractMapper.extend(publicAPI, model, initialValues); macro.setGet(publicAPI, model, ['viewSpecificProperties']); macro.getArray(publicAPI, model, ['bounds'], 6); vtkAbstractMapper3D(publicAPI, model); } // ---------------------------------------------------------------------------- var vtkAbstractMapper3D$1 = { extend }; export { vtkAbstractMapper3D$1 as default, extend };