[vtkusers] Convert vtkActor to vtkPolyData
Cory Quammen
cory.quammen at kitware.com
Sun Mar 2 09:33:28 EST 2014
You are trying to downcast a vtkAlgorithm to a vtkPolyData, but
vtkPolyData does not descend from vtkAlgorithm, so it won't work.
Instead, try
refLower = vtkPolyData::SafeDownCast(actorLower->GetMapper()->GetInputAsDataSet())
Let us know how it goes.
Cory
On Sun, Mar 2, 2014 at 4:01 AM, Agata Krasoń <agatakrason at gmail.com> wrote:
> 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
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list