All files / Sources/Rendering/Core/AbstractMapper3D index.js

75% Statements 12/16
33.33% Branches 1/3
66.66% Functions 4/6
73.33% Lines 11/15

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                    861x         861x 5x 5x     5x     861x                   861x                   861x   861x   861x   861x            
import macro from 'vtk.js/Sources/macros';
import vtkAbstractMapper from 'vtk.js/Sources/Rendering/Core/AbstractMapper';
import vtkBoundingBox from 'vtk.js/Sources/Common/DataModel/BoundingBox';
import { createUninitializedBounds } from 'vtk.js/Sources/Common/Core/Math';
 
// ----------------------------------------------------------------------------
// vtkAbstractMapper methods
// ----------------------------------------------------------------------------
 
function vtkAbstractMapper3D(publicAPI, model) {
  publicAPI.getBounds = () => {
    macro.vtkErrorMacro(`vtkAbstractMapper3D.getBounds - NOT IMPLEMENTED`);
    return createUninitializedBounds();
  };
 
  publicAPI.getCenter = () => {
    const bounds = publicAPI.getBounds();
    model.center = vtkBoundingBox.isValid(bounds)
      ? vtkBoundingBox.getCenter(bounds)
      : null;
    return model.center?.slice();
  };
 
  publicAPI.getLength = () => {
    const bounds = publicAPI.getBounds();
    return vtkBoundingBox.getDiagonalLength(bounds);
  };
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
 
const defaultValues = (initialValues) => ({
  bounds: [...vtkBoundingBox.INIT_BOUNDS],
  center: [0, 0, 0],
  viewSpecificProperties: {},
  ...initialValues,
});
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, defaultValues(initialValues));
  // Inheritance
  vtkAbstractMapper.extend(publicAPI, model, initialValues);
 
  macro.setGet(publicAPI, model, ['viewSpecificProperties']);
 
  vtkAbstractMapper3D(publicAPI, model);
}
 
// ----------------------------------------------------------------------------
 
export default { extend };