Hello everyone,
I tried to load a vtp file in paraview and it looks like this:
The same I would like to get in vtk.js. My code looks like this:
const actor = vtkActor.newInstance()
const mapper = vtkMapper.newInstance()
actor.setMapper(mapper)
const reader = vtkXMLPolyDataReader.newInstance()
reader.parseAsArrayBuffer(data)
mapper.setInputConnection(reader.getOutputPort())
const source = reader.getOutputData()
source.getPointData().setActiveScalars('velocity [m/s]')
source.getPointData().setActiveVectors('velocity [m/s]')
const range = source
.getPointData()
.getArray('velocity [m/s]')
.getRange()
const ctfun = vtkColorTransferFunction.newInstance()
renderer.addActor(actor)
const presetResponse = await axios.get('/assets/json/organs/Nasal.json')
const presetData = presetResponse.data
const points = presetData[0].Points
const colorResponse = await axios.get( '/assets/json/luts/CoolToWarm.json')
const colorData = colorResponse.data
const colorRgbPoints = colorData[0].RGBPoints
const pp = stretchColorMap(colorRgbPoints, points)
ctfun.removeAllPoints()
ctfun.setRange(range[0], range[1])
for (let i = 0; i < pp.length; i += 4) {
const x = pp[i]
console.log(x)
const r = pp[i + 1]
const g = pp[i + 2]
const b = pp[i + 3]
ctfun.addRGBPoint(x, r, g, b)
}
mapper.setLookupTable(ctfun)
renderer.resetCameraClippingRange()
renderer.resetCamera()
renderWindow.render()
However, all I see is just blue color without any pattern:
With vti images this approach works well, the result is similar to paraview, but with polydata there are difficulties.
Why this is happening and what I might have missed?
Thanks in advance for your answers!