0

I use vtkResliceImageViewer to display MPR, set vtkResliceImageViewer().SetResliceModeToAxisAligned, why my crosshair is very virtual and invisible, it will be covered by the image

enter image description here

here is my code

class Viewer():
    def __init__(self) -> None:
        self.riw = [vtk.vtkResliceImageViewer(), vtk.vtkResliceImageViewer(), vtk.vtkResliceImageViewer()]
        self.planeWidget = [vtk.vtkImagePlaneWidget(),vtk.vtkImagePlaneWidget(),vtk.vtkImagePlaneWidget()]


    def init_viewer(self, dcm_folder):
        reader = vtk.vtkDICOMImageReader()
        reader.SetDirectoryName(dcm_folder)
        reader.Update()
        dimension = reader.GetOutput().GetDimensions()
        for i in range(3):
            # make them all share the same reslice cursor object.
            rep = vtk.vtkResliceCursorLineRepresentation.SafeDownCast(
                self.riw[i].GetResliceCursorWidget().GetRepresentation())
            self.riw[i].SetResliceCursor(self.riw[i].GetResliceCursor())

            rep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal(i)

            self.riw[i].SetInputData(reader.GetOutput())
            self.riw[i].SetSliceOrientation(i)
            self.riw[i].SetResliceModeToAxisAligned()

        picker = vtk.vtkCellPicker()
        picker.SetTolerance(0.005)

        ipwProp = vtk.vtkProperty()
        ren = vtk.vtkRenderer()

        iren = self.ui.view_v.GetRenderWindow().GetInteractor()

        for i in range(3):
            self.planeWidget[i] = vtk.vtkImagePlaneWidget()
            self.planeWidget[i].SetInteractor(iren)
            self.planeWidget[i].SetPicker(picker)
            self.planeWidget[i].RestrictPlaneToVolumeOn()
            color = [0, 0, 0]
            color[i] = 1
            self.planeWidget[i].GetPlaneProperty().SetColor(color)

            self.riw[i].GetRenderer().SetBackground(color)

            self.planeWidget[i].SetTexturePlaneProperty(ipwProp)
            self.planeWidget[i].TextureInterpolateOff()
            self.planeWidget[i].SetResliceInterpolateToLinear()
            self.planeWidget[i].SetInputConnection(reader.GetOutputPort())
            self.planeWidget[i].SetPlaneOrientation(i)
            self.planeWidget[i].SetSliceIndex(dimension[i]//2)
            self.planeWidget[i].DisplayTextOn()
            self.planeWidget[i].SetDefaultRenderer(ren)
            self.planeWidget[i].SetWindowLevel(1358, -27)
            self.planeWidget[i].On()
            self.planeWidget[i].InteractionOn()
Albert Einstein
  • 7,472
  • 8
  • 36
  • 71
Drink
  • 1
  • 2

1 Answers1

-1

You should set the representation of centerline. just like:

vtkResliceCursorLineRepresentation* rep = vtkResliceCursorLineRepresentation::SafeDownCast(
                riw[i]->GetResliceCursorWidget()->GetRepresentation());
            rep->GetResliceCursorActor()->GetCenterlineProperty(0)->SetRepresentationToWireframe();
            rep->GetResliceCursorActor()->GetCenterlineProperty(1)->SetRepresentationToWireframe();
            rep->GetResliceCursorActor()->GetCenterlineProperty(2)->SetRepresentationToWireframe();
Albert Einstein
  • 7,472
  • 8
  • 36
  • 71