[vtkusers] Convert vtkActor to vtkPolyData

Agata Krasoń agatakrason at gmail.com
Sun Mar 2 04:01:49 EST 2014


Hi,

I need to convert vtkActor to vtkPolyData and save as stl file.

I followed ReverseAccess example from VTK wiki
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ReverseAccess
Unfortunately  it does not work in this case.

I am trying with following code :
I don't know exactly about SafeDownCast
It seems to be that I am doing something wrong in SafeDownCast  ..

.....
   actorLower = vtkSmartPointer<vtkActor>::New();
   actorUpper = vtkSmartPointer<vtkActor>::New();

*  vtkSmartPointer<vtkAlgorithm> algoSafeLower =
actorLower->GetMapper()->GetInputConnection(0, 0)->GetProducer();*
*   refLower = vtkPolyData::SafeDownCast(algoSafeLower));*

*vtkSmartPointer<vtkAlgorithm> algoSafeUpper =
actorUpper->GetMapper()->GetInputConnection(0, 0)->GetProducer();*
*   refUpper = vtkPolyData::SafeDownCast(algoSafeUpper);*

   safeAppendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
   safeAppendFilter->AddInput(refUpper);
   safeAppendFilter->AddInput(refLower);
   safeAppendFilter->Update();

   stlWriter = vtkSmartPointer<vtkSTLWriter>::New();
   stlWriter->SetFileName("output_file.stl");
   stlWriter->SetInputConnection(safeAppendFilter->GetOutputPort());
   stlWriter->Write();

I would appreciate for any help please.

agatte
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140302/12425c1e/attachment.html>


More information about the vtkusers mailing list