All files / Sources/Common/DataModel/PointSet index.js

95.23% Statements 20/21
50% Branches 2/4
83.33% Functions 5/6
94.73% Lines 18/19

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                              1130x     1130x 1000x   130x     1130x   1130x   1130x       1130x 1130x 14x 14x 14x               1x             1130x     1130x 1130x     1130x         1x          
import vtk from 'vtk.js/Sources/vtk';
import macro from 'vtk.js/Sources/macros';
import vtkDataSet from 'vtk.js/Sources/Common/DataModel/DataSet';
import vtkPoints from 'vtk.js/Sources/Common/Core/Points';
 
// ----------------------------------------------------------------------------
// 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 = () => {
    publicAPI.getBounds();
  };
 
  const superShallowCopy = publicAPI.shallowCopy;
  publicAPI.shallowCopy = (other, debug = false) => {
    superShallowCopy(other, debug);
    model.points = vtkPoints.newInstance();
    model.points.shallowCopy(other.getPoints());
  };
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
 
const DEFAULT_VALUES = {
  // points: null,
};
 
// ----------------------------------------------------------------------------
 
export 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);
}
 
// ----------------------------------------------------------------------------
 
export const newInstance = macro.newInstance(extend, 'vtkPointSet');
 
// ----------------------------------------------------------------------------
 
export default { newInstance, extend };