[vtkusers] Convert vtkActor to vtkPolyData

agatte agatakrason at gmail.com
Sun Mar 2 04:03:11 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 
II 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




--
View this message in context: http://vtk.1045678.n5.nabble.com/Convert-vtkActor-to-vtkPolyData-tp5726149.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list