Currently, I want to display vtkVolume
and vtkPolyData
in a render. But, the part of vtkPolyData
, which is covered by vtkVolume
, is black. Like the following figure:
The line outside of vtkVolume
is red, which is what I expected. But the part covered by vtkVolume
is black.
My code is:
import vtkmodules.all as vtk
reader = vtk.vtkDICOMImageReader()
reader.SetDirectoryName('./data')
reader.Update()
image = reader.GetOutput()
image.SetOrigin(0, 0, 0)
image.SetDirectionMatrix([1, 0, 0, 0, 1, 0, 0, 0, 1])
print(image.GetBounds())
line = vtk.vtkLineSource()
line.SetPoint1(0, 0, 0)
line.SetPoint2(200, 200, 200)
line.Update()
polyMapper = vtk.vtkPolyDataMapper()
polyMapper.SetInputData(line.GetOutput())
polyActor = vtk.vtkActor()
polyActor.SetMapper(polyMapper)
polyActor.GetProperty().SetColor(255, 0, 0)
polyActor.GetProperty().SetLineWidth(5)
volume = vtk.vtkVolume()
vMapper = vtk.vtkGPUVolumeRayCastMapper()
vMapper.SetBlendModeToMaximumIntensity()
vMapper.SetInputData(image)
volume.SetMapper(vMapper)
render = vtk.vtkRenderer()
render.AddActor(volume)
render.AddActor(polyActor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()
How can I turn the line covered by vtkVolume
to red?