[vtkusers] Problem with conversion from VRML into VTK file
Kristian Sons
kristian.sons at actor3d.com
Tue Nov 24 12:37:12 EST 2009
Dear RimAY,
the vtkVRMLImporter creates one vtkActor per VRML Shape node. So if yo
have many Shapes in your VRML scene you will have to iterate over the
scene, and you will get one PolyData per Shape.
If you intend to have one PolyData as result, you can use the
vtkAppendFilter to append the meshes. Please be aware that point/cell
attributes that are not available in all the polydata objects will be
discarded.
Another way would be to combine the geometry using a composite data
type. vtkMultiBlockData is a good candidate. Several filters support
this "new" kind of of data object. You can use the
vtkXMLMultiBlockDataWriter to serialize your data.
Hope that helps,
Kristian
RimAY schrieb:
> Dear All ,
>
> I try to convert a vrml file into vtk file, my problem is that i got only a
> part of the image in the vtk format.
> this is the code i used:
>
> target = vtkVRMLImporter()
> target.SetFileName("WRL path")
> target.Read()
>
> actors = vtkActorCollection()
> actors = target.GetRenderer().GetActors()
> actors.InitTraversal()
>
> pDataset = actors.GetNextActor().GetMapper().GetInput()
>
> geometryFilter = vtkGeometryFilter()
> geometryFilter.SetInput(pDataset)
>
> filter1 = vtkImageDataGeometryFilter()
> filter1.SetInput(pDataset)
>
> data = vtkPolyData()
> data = geometryFilter.GetOutput()
> data.Update()
>
>
> writer = vtkXMLPolyDataWriter()
> writer.SetFileName("vtk path")
> writer.SetInput(data)
> writer.Write()
>
> print "fichier crée"
>
> Any help will be very appreciated
>
> Best Regards
--
Kristian Sons
Actor3D - Agentur für interaktive 3D-Medien
Chiemgaustr 62
D-81549 München / Germany
tel +49-89-20327854
fax +49-89-20327853
mobile +49-151-50987608
mail kristian.sons at actor3d.com
web http://www.actor3d.com
More information about the vtkusers
mailing list