[vtkusers] doubt in conversion from VRML to VTK

nuno.jf nunofernandes7 at gmail.com
Mon Aug 29 12:10:23 EDT 2011


Dear Users,

I have a doubt regarding a piece of code that converts a VRML file,
containing geometric data, into a VTK (polydata) file. (link to the code:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/VRML)
The code is similar to this:

	imp = vtkVRMLImporter::New();
	imp -> SetFileName( fileName );
	imp -> Read();
	imp -> Update();
       
        vtkDataSet *pDataset;
	vtkActorCollection *actors = imp -> GetRenderer()->GetActors();
	actors -> InitTraversal();
	pDataset = actors -> GetNextActor()->GetMapper()->GetInput();

	vtkPolyData *polyData = vtkPolyData::SafeDownCast( pDataset );
	polyData -> Update();

My question is: Why do we need to first convert to vtkDataSet, instead of
directly converting to vtkPolyData, since vtkPolyData is a derived classe of
vtkDataSet? I don't know If I am being totally clear, but why not doing
this:

	imp = vtkVRMLImporter::New();
	imp -> SetFileName( fileName );
	imp -> Read();
	imp -> Update();
       
        vtkPolyData *pDataset::vtkPolyData::New();
	vtkActorCollection *actors = imp -> GetRenderer()->GetActors();
	actors -> InitTraversal();
	pDataset = actors -> GetNextActor()->GetMapper()->GetInput();
	pDataset->update();

Is this because there needs to be some specific way to convert the data to
vtkPolyData? If so, is this done by SafeDownCast()? I know that
SafeDownCast() converts a base-class pointer to a derive-class pointer and
verifies the inheritance. 
I am a little confused, so any help would be greatly appreciated.
Thank you,

Nuno 


--
View this message in context: http://vtk.1045678.n5.nabble.com/doubt-in-conversion-from-VRML-to-VTK-tp4746682p4746682.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list