Cut polyData with ImagePlaneWidget

Hello,

I am using 3 orthogonal ImagePlaneWidgets that are tied to 3 ResliceImageViewers to show each plane. Similar to the FourPaneViewer example.

There are also a few sphere actors in the imagePlaneWidgets’ space.

What I would like to happen, is that when a imagePlaneWidget intersects one or more of the actors, the outline of the actor is also displayed in the slice that is shown in the corresponding ResliceImageViewers.

Following some of the advice here;
http://vtk.1045678.n5.nabble.com/vtkImagePlaneWidget-offset-from-cut-plane-td3423927.html

The things I have tried include;

  1. Passing the imagePlaneWidget to the cutter, by setting the cutter’s input data to the planeWidget[0]->ResliceOutput() …
    ** although I think I haven’t implemented this correctly. How should I pass the imagePlane directly to the cutter?

  2. imagePlaneWidget->GetPlanePropery() :
    With this I can modify the planeWidget properties, and am able to set an outline (as shown in the code below). However, I can’t seem to find a property that outlines the actor intersection with the plane.

  3. Using imagePlaneWidget->GetPolyData()
    With this method I can visualize the reslice but there is no sphere outline. I did not implement any
    tube filter, as discussed in the link above.

Any help is greatly appreciated.

Thanks,
Ryan

indent preformatted text by 4 spaces
vtkSmartPointer<vtkSphereSource> sphereSource = vtkSmartPointer<vtkSphereSource>::New();
// sphereSource->SetCenter(0.0 + (5*i), 0.0, 0.0);
sphereSource->SetRadius(5);

auto sphereMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
sphereMapper->SetInputConnection(sphereSource->GetOutputPort());

auto plane = vtkSmartPointer<vtkPlane>::New();
// plane->SetOrigin(imageData->GetOrigin());
plane->SetOrigin(0, 0, 0);
plane->SetNormal(1, 0, 0);

    // Method 1 : Using Cutter
    //
auto cutter = vtkSmartPointer<vtkCutter>::New();
cutter->SetCutFunction(plane);
cutter->SetInputConnection(sphereSource->GetOutputPort());
// cutter->SetInputData(planeWidget[0]->GetResliceOutput());
cutter->Update();

auto cutterMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
cutterMapper->SetInputConnection(cutter->GetOutputPort());

auto planeActor = vtkSmartPointer<vtkActor>::New();
planeActor->SetPosition(imageData->GetOrigin());
planeActor->GetProperty()->SetColor(1, 0, 0);
planeActor->GetProperty()->SetLineWidth(10);
planeActor->SetMapper( cutterMapper );
planeActor->GetProperty()->SetOpacity(0.5);
planeActor->GetProperty()->SetAmbient(1);
planeActor->GetProperty()->SetSpecularColor(1,1,0);
planeActor->GetProperty()->SetDiffuseColor(1, 1, 0);
planeActor->GetProperty()->SetDiffuse(0.8);
planeActor->GetProperty()->SetSpecular(0.3);
planeActor->GetProperty()->SetSpecularPower(20);
planeActor->GetProperty()->SetRepresentationToSurface();
planeActor->GetProperty()->EdgeVisibilityOn();

auto targetActor = vtkSmartPointer<vtkActor>::New();
targetActor->SetPosition(imageData->GetOrigin());
targetActor->GetProperty()->SetColor(0, 1, 1);
targetActor->GetProperty()->SetOpacity( 0.5);
targetActor->SetMapper( sphereMapper );
targetActor->VisibilityOn();

    // Method 2 : Get Plane Property and Modify 
    ///
auto planeProp = vtkSmartPointer<vtkProperty>::New();
planeProp = planeWidget[0]->GetPlaneProperty();
planeProp->SetRenderLinesAsTubes(1);
planeProp->RenderLinesAsTubesOn();
planeProp->SetLineWidth(10);
planeProp->SetEdgeVisibility(1);
planeProp->EdgeVisibilityOn();
planeProp->SetRepresentationToSurface();
planeProp->SetEdgeColor(0, 1, 1);
planeWidget[0]->SetPlaneProperty(planeProp);
// planeWidget[0]->PlaneOutlineActor->GetProperty()->SetColor(0,1,1);	

    // Method 3: GetPolyData() 
    //
auto polyData = vtkSmartPointer<vtkPolyData>::New();
planeWidget[0]->GetPolyData( polyData );

auto pMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
pMapper->SetInputData(polyData);	

auto        imageActor = vtkSmartPointer<vtkActor>::New();
// auto imageActorMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
// imageActor->GetMapper()->SetInputData(planeWidget[0]->GetResliceOutput());
imageActor->SetMapper(pMapper);	

testRenderer->AddActor(planeActor);
testRenderer->AddActor(targetActor);
testRenderer->AddActor(originActor);
testRenderer->AddActor(imageActor);