[vtkusers] How can I save vtkOBJReader output?

David Doria daviddoria at gmail.com
Thu Dec 2 07:19:25 EST 2010


On Thu, Dec 2, 2010 at 4:50 AM, akbarjan bayiz <abayiz at yahoo.com> wrote:
> Hello, all!
> I am using the vtkOBJReader to read and render an .obj file, which works well. But, I also want to save its output, I mean those polydata generated by vtkOBJReader, into another single file. How can I do this? I want to save all the data in the right form, so that I can reach and render them later. I need an C++ example.
> By the way, I tried the "GetOutput" command, but it didn't work properly. I am new to VTK, and I really need an explicit, full example.
> Thank you very much in advance.
>
> Best regards,
> Abayiz

If you are looking to write an obj file, it is not possible with the
"off the shelf" VTK. I wrote a vtkOBJWriter which you can get here:

https://github.com/daviddoria/daviddoria-vtk/tree/VTK-vtkObjWriter

If you can live with a different type of file, here is an example of
how to write a ply file:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/WritePLY

Just replace the SphereSource in the example with your reader.

I'm not sure what you are doing, but I find it convenient to use the
VTK file formats so you can go back and forth between Paraview and VTK
easily. Here is an example of writing a vtk file:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/WriteVTP

David



More information about the vtkusers mailing list