Extracted cross-section from vtkCutter cannot be displayed

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Extracted cross-section from vtkCutter cannot be displayed

ochampao
Hi vtkUsers,

I am trying to extract the cross-section of a sphere (vtkSphereSource)
displayed in one render window, and display its cross-section in another
render window, however, I am unable to make this work. I am trying to
achieve this using a vtkCutter to extract the cross-section of
vtkSphereSource.

I have adapted the SideBySideRenderWindowsQt example from the wiki to
demonstrate the problem. The full compileable code is attached.

Here are some details of the problem:

In the example, I have two views: 1) left "2D" view and 2) right "3D" view.
The 2D view has a callback for picking points via the ALT+LeftMouseButton
key combination. When the user picks a point on the 2D view, the
addPickedPoint() method is called, which renders a sphere on the 3D view and
then uses a vtkCutter to extract the cross-section of the sphere so that it
is displayed at the position of the picked point on the 2D view. The
attached code implements this behaviour, however, only the sphere appears on
the 3D view. Its cross-section, extracted using a vtkCutter instance is not
displayed on the 2D view. My initial thought was that the vtkImageStack on
the 2D view is "hiding" the cross-section actor, but after removing the
vtkImageStack the actor is still not displayed.

Have you got any ideas on how to fix this?

Any help will be much appreciated.

Thanks,
Panos.



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Extracted cross-section from vtkCutter cannot be displayed

ochampao
My attachment did not get uploaded. Here is another attempt to upload it.

SideBySideRenderWindowsQt.zip
<http://vtk.1045678.n5.nabble.com/file/t341857/SideBySideRenderWindowsQt.zip>  



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Extracted cross-section from vtkCutter cannot be displayed

ochampao
Here is the method which adds the sphere on the right view and then cuts the
cross-section to be displayed on the left view.

void addPickedPoint(const double x, const double y, const double z)
{
        // sphere source
        vtkNew<vtkSphereSource> sphereSource;
        sphereSource->SetCenter(x, y, z);
        sphereSource->SetRadius(1.0);
        sphereSource->SetThetaResolution(50);
        sphereSource->SetPhiResolution(50);

        // sphere polygonal mapper
        vtkNew<vtkPolyDataMapper> sphereMapper;
        sphereMapper->SetInputConnection(sphereSource->GetOutputPort());

        // actor for displaying sphere in 3D
        vtkNew<vtkActor> sphereActor;
        sphereActor->SetMapper(sphereMapper);
        sphereActor->GetProperty()->SetDiffuseColor(1, 0, 0);
        sphereActor->GetProperty()->SetOpacity(0.7);

        // setup cut plane for extracting cross-sections of polygonal models.
        // Cutplane is the plane defined by the focal point and the view plane
        // normal of the Left View.
        vtkNew<vtkPlane> cutPlane;
        cutPlane->SetOrigin(
                this->leftRenderer->GetActiveCamera()->GetFocalPoint());
        cutPlane->SetNormal(
                this->leftRenderer->GetActiveCamera()->GetViewPlaneNormal());

        // setup cutter and attach cutplane
        vtkNew<vtkCutter> cutter;
        cutter->SetCutFunction(cutPlane);
        cutter->SetInputConnection(sphereSource->GetOutputPort());
        cutter->Update();

        // crossection mapper
        vtkNew<vtkPolyDataMapper> cutterMapper;
        cutterMapper->SetInputConnection(cutter->GetOutputPort());

        // actor for displaying the extracted cross-section from the sphere
        vtkNew<vtkActor> cutterActor;
        cutterActor->SetMapper(cutterMapper);
        cutterActor->GetProperty()->SetDiffuseColor(0.2, .49, 1);
        cutterActor->GetProperty()->SetColor(1.0, 0.55, 0.2);
        cutterActor->GetProperty()->SetLineWidth(1.0f);
        cutterActor->GetProperty()->SetOpacity(1.0);
       
        // add all actors to the Renderers
        this->leftRenderer->AddActor(cutterActor);
        this->rightRenderer->AddActor(sphereActor);

        // reset camera
        this->leftRenderer->ResetCamera();
        this->rightRenderer->ResetCamera();

        // render views
        this->leftRenderer->GetRenderWindow()->Render();
        this->rightRenderer->GetRenderWindow()->Render();
}



--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: Extracted cross-section from vtkCutter cannot be displayed

ochampao
After lots of searching in VTK users mailing list, I came across this post:

http://vtk.1045678.n5.nabble.com/black-contour-instead-of-colors-after-vtkcutter-td5738068.html
<http://vtk.1045678.n5.nabble.com/black-contour-instead-of-colors-after-vtkcutter-td5738068.html>  

which helped me solve the issues. Essentially, the actors were placed on the
view but they were not visible. To mitigate this I have added the following
two lines of code:

cutterActor->GetProperty()->LightingOff();
cutterActor->GetProperty()->SetAmbient(1.0);

This solved the problem.

Thanks,
P.





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
https://public.kitware.com/mailman/listinfo/vtkusers