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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | 1x 13x 13x 13x 6x 6x 6x 6x 6x 6x 6x 13x 31x 13x 13x 13x 13x 1x 13x 13x 13x 13x 13x 13x 1x | import macro from 'vtk.js/Sources/macros'; import vtkCubeSource from 'vtk.js/Sources/Filters/Sources/CubeSource'; const { vtkErrorMacro } = macro; // ---------------------------------------------------------------------------- // vtkImageDataOutlineFilter methods // ---------------------------------------------------------------------------- function vtkImageDataOutlineFilter(publicAPI, model) { // Set our className model.classHierarchy.push('vtkImageDataOutlineFilter'); // Capture "parentClass" api for internal use const superClass = { ...publicAPI }; publicAPI.requestData = (inData, outData) => { // implement requestData const input = inData[0]; Iif (!input || !input.isA('vtkImageData')) { vtkErrorMacro('Invalid or missing input'); return; } // First create a cube polydata in the index-space of the image. // The benefit of using `getSpatialExtent` call is that it automatically // takes care of 0.5 voxel padding as required by an vtkImageData representation. const spatialExt = input.getSpatialExtent(); Iif (!spatialExt) { vtkErrorMacro('Unable to fetch spatial extents of input image.'); return; } model._cubeSource.setBounds(spatialExt); // Then apply index-to-world transform to the cube to create the outline. model._cubeSource.setMatrix(input.getIndexToWorld()); outData[0] = model._cubeSource.getOutputData(); }; publicAPI.getMTime = () => Math.max(superClass.getMTime(), model._cubeSource.getMTime()); // Forward calls for [set/get]Generate[Faces/Lines] functions to cubeSource: publicAPI.setGenerateFaces = model._cubeSource.setGenerateFaces; publicAPI.setGenerateLines = model._cubeSource.setGenerateLines; publicAPI.getGenerateFaces = model._cubeSource.getGenerateFaces; publicAPI.getGenerateLines = model._cubeSource.getGenerateLines; } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = {}; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Make this a VTK object macro.obj(publicAPI, model); // Also make it an algorithm with one input and one output macro.algo(publicAPI, model, 1, 1); // Internal persistent objects model._cubeSource = vtkCubeSource.newInstance(); macro.moveToProtected(publicAPI, model, ['cubeSource', 'tmpOut']); // Object specific methods vtkImageDataOutlineFilter(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance( extend, 'vtkImageDataOutlineFilter' ); // ---------------------------------------------------------------------------- export default { newInstance, extend }; |