Here’s my code.:
test () {
axios.get(‘src/views/modules/generator/demo01.dcm’, {
responseType: ‘arraybuffer’
}).then(response => {
const dicomData = this.parseDICOM(response.data)
this.render3DModel(dicomData)
}).catch(error => {
console.error(error)
})
},
parseDICOM (arrayBuffer) {
const byteArray = new Uint8Array(arrayBuffer)
const dataSet = DICOMParser.parseDicom(byteArray)
return dataSet
},
render3DModel (dicomData){
const container = document.getElementById('vtk-container')
const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
container: container,
background: [0, 0, 0]
})
const imageData = vtkImageData.newInstance()
imageData.setDimensions(512, 512, 512)
imageData.setSpacing(1, 1, 1)
const dataArray = vtkDataArray.newInstance({
numberOfComponents: 1,
values: dicomData,
name: 'DICOM_PixelData',
})
imageData.getPointData().setScalars(dataArray)
const volumeMapper = vtkVolumeMapper.newInstance()
volumeMapper.setInputData(imageData)
const volume = vtkVolume.newInstance()
volume.setMapper(volumeMapper)
fullScreenRenderer.getRenderer().addVolume(volume)
fullScreenRenderer.getRenderWindow().render()
},
I’m a rookie. Please help me.