[vtkusers] How to export vtk source objects created in programming way into files to load in ParaView etc

David Doria daviddoria at gmail.com
Thu Jan 2 14:10:34 EST 2014


On Thu, Jan 2, 2014 at 2:02 PM, Wei Wu <salad00 at gmail.com> wrote:

> Hi there,
>
> I learned how to create vtk source objects, such as cubes, disks etc, in a
> programming way. However every time I need to run my written program to
> display the objects. Do we have a method to export these already created
> objects into a vtk or vtu file, in order to load into software like
> ParaView to render them later on?
>
> I have tried to find the solution but unfortunately didn't get any clue.
> Your help will be appreciated greatly!
>
> Many thanks for your hint in advance!
>
> Best regards,
> Wei
>

Wei,

You can feed your data into any one of the classes that end in *Writer and
are compatible with the data type. For example, if you have a vtkPolyData
(which it sounds like you do), you can give it to a vtkXMLPolyDataWriter to
create a .vtp file. Here is an example:

http://www.vtk.org/Wiki/VTK/Examples/Cxx/IO/WriteVTP

And here are a few other examples:

http://www.vtk.org/Wiki/VTK/Examples/Cxx#Output_2

Good luck!

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140102/4c04b16c/attachment.htm>


More information about the vtkusers mailing list