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 92 93 94 | 3x 3x 2x 2x 6x 2x 6x 2x 9x 2x 2x 2x 2x 2x 12x 2x 2x 2x 2x 1x 3x 3x 3x 1x | import vtkXMLReader from 'vtk.js/Sources/IO/XML/XMLReader';
import macro from 'vtk.js/Sources/macros';
import vtkImageData from 'vtk.js/Sources/Common/DataModel/ImageData';
// ----------------------------------------------------------------------------
// vtkXMLImageDataReader methods
// ----------------------------------------------------------------------------
function vtkXMLImageDataReader(publicAPI, model) {
// Set our className
model.classHierarchy.push('vtkXMLImageDataReader');
publicAPI.parseXML = (rootElem, type, compressor, byteOrder, headerType) => {
const imageDataElem = rootElem.getElementsByTagName(model.dataType)[0];
const origin = imageDataElem
.getAttribute('Origin')
.split(' ')
.map((t) => Number(t));
const spacing = imageDataElem
.getAttribute('Spacing')
.split(' ')
.map((t) => Number(t));
const direction = imageDataElem
.getAttribute('Direction')
?.split(' ')
.map((t) => Number(t));
const pieces = imageDataElem.getElementsByTagName('Piece');
const nbPieces = pieces.length;
for (let outputIndex = 0; outputIndex < nbPieces; outputIndex++) {
// Create image data
const piece = pieces[outputIndex];
const extent = piece
.getAttribute('Extent')
.split(' ')
.map((t) => Number(t));
const imageData = vtkImageData.newInstance({
origin,
spacing,
direction,
extent,
});
// Fill data
vtkXMLReader.processFieldData(
imageData.getNumberOfPoints(),
piece.getElementsByTagName('PointData')[0],
imageData.getPointData(),
compressor,
byteOrder,
headerType,
model.binaryBuffer
);
vtkXMLReader.processFieldData(
imageData.getNumberOfCells(),
piece.getElementsByTagName('CellData')[0],
imageData.getCellData(),
compressor,
byteOrder,
headerType,
model.binaryBuffer
);
// Add new output
model.output[outputIndex] = imageData;
}
};
}
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
dataType: 'ImageData',
};
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
vtkXMLReader.extend(publicAPI, model, initialValues);
vtkXMLImageDataReader(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = macro.newInstance(extend, 'vtkXMLImageDataReader');
// ----------------------------------------------------------------------------
export default { newInstance, extend };
|