[vtkusers] How to save multiple (polydata) objects together with their props into one single file?

Andras Lasso lasso at queensu.ca
Mon Feb 26 12:16:50 EST 2018


You can also insert your meshes into a vtkMultiBlockDataSet and use vtkXMLMultiBlockDataWriter/vtkXMLMultiBlockDataReader. The advantage compared to 3DS/OBJ/VRML exporters that all polydata point/cell arrays are preserved and you can optionally also store metadata for the whole dataset or for each block. Actor properties (such as color, opacity) are not written to the file, unless you store them in the polydata object.

See example of how this is used in 3D Slicer for storing segmentation consisting of potentially overlapping segments.

-          Reading: https://github.com/Slicer/Slicer/blob/f5128eae6aebfbce9bc4fb1a3a5804e545452d57/Libs/MRML/Core/vtkMRMLSegmentationStorageNode.cxx#L756-L930

-          Writing: https://github.com/Slicer/Slicer/blob/f5128eae6aebfbce9bc4fb1a3a5804e545452d57/Libs/MRML/Core/vtkMRMLSegmentationStorageNode.cxx#L1140-L1282

Andras

From: vtkusers [mailto:vtkusers-bounces at vtk.org] On Behalf Of David Gobbi
Sent: Monday, February 26, 2018 12:07 PM
To: normanius <juch at zhaw.ch>
Cc: VTK Users <vtkusers at vtk.org>
Subject: Re: [vtkusers] How to save multiple (polydata) objects together with their props into one single file?

On Mon, Feb 26, 2018 at 9:57 AM, normanius <juch at zhaw.ch<mailto:juch at zhaw.ch>> wrote:


Do I have to define my own "file format", or does something like this
already exist in vtk?

VTK can use a few different file formats for scenes.  I doubt that all features of each file format are supported, but if your basic requirement is just to save multiple polydata in a file, these should work for you:

https://www.vtk.org/doc/nightly/html/classvtkImporter.html<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.vtk.org%2Fdoc%2Fnightly%2Fhtml%2FclassvtkImporter.html&data=02%7C01%7Classo%40queensu.ca%7Ca885defcd1df443e6d3a08d57d3b5f87%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636552616310776728&sdata=0tyeRnSEIsbm5%2FtSleCeFjgkN6vnYpfodXLP5lptLEc%3D&reserved=0>
https://www.vtk.org/doc/nightly/html/classvtkExporter.html<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.vtk.org%2Fdoc%2Fnightly%2Fhtml%2FclassvtkExporter.html&data=02%7C01%7Classo%40queensu.ca%7Ca885defcd1df443e6d3a08d57d3b5f87%7Cd61ecb3b38b142d582c4efb2838b925c%7C1%7C0%7C636552616310776728&sdata=XNS8SmNQncJyJJMoWlAOAprx%2FxEeRxCtNfwLFqCSJZU%3D&reserved=0>

I don't think VTK has a native file format for this, but I could be wrong.

Cheers,
 - David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180226/0a0051f5/attachment.html>


More information about the vtkusers mailing list