[vtkusers] extending VTK's XML file formats
Tim Hutton
tim.hutton at gmail.com
Tue Jan 10 12:44:49 EST 2012
On 10 January 2012 17:03, David Gobbi <david.gobbi at gmail.com> wrote:
> Hi Tim,
>
> If you can fit your metadata into a collection of VTK arrays (i.e.
> vtkDataArray, vtkStringArray, vtkVariantArray etc) then you can attach
> the metadata to the vtkImageData via SetFieldData.
>
> In VTK, "the FieldData" is a collection of named arrays that you can
> attach to any vtkDataObject and use for any purpose. Several years
> back I wrote a program that even converted all of DICOM metadata into
> arrays so that I could attach it to my images and write it out to VTK
> files (this was back before VTK XML existed).
>
> By using this trick, you wouldn't have to change the XML
> readers/writers at all, you would just need to write code to place the
> metadata into a vtkFieldData object and write code to get it out
> again.
Thanks David. This too would work. The problem now is that the data
file looks something like this:
<?xml version="1.0"?>
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
<ImageData WholeExtent="0 127 0 63 0 0" Origin="0 0 0" Spacing="1 1 1">
<FieldData>
<Array type="String" Name="param_names" NumberOfTuples="4" format="ascii">
68 95 97 0 68 95 98 0 107 0 70 0
</Array>
<DataArray type="Float32" Name="params" NumberOfTuples="4"
format="ascii" RangeMin="0.20000000298" RangeMax="0.5">
0.20000000298 0.30000001192 0.40000000596 0.5
</DataArray>
</FieldData>
<Piece Extent="0 127 0 63 0 0">
<PointData Scalars="Scalars_">
... etc. ...
Instead of something like what I would prefer (see below) - I would
like to keep the XML as readable as possible, for hand-editing.
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian"
compressor="vtkZLibDataCompressor">
<sim_details>
<description>blah blah blah</description>
<param name="D_a">0.082</param>
<param name="D_b">0.041</param>
<param name="k">0.06</param>
<param name="F">0.035</param>
</sim_details>
<ImageData WholeExtent="0 127 0 63 0 0" Origin="0 0 0" Spacing="1 1 1">
<Piece Extent="0 127 0 63 0 0">
<PointData Scalars="Scalars_">
... etc. ...
I think subclassing the XML I/O classes for this is the best solution,
but I'm having trouble working out how to do it.
--
Tim Hutton - http://www.sq3.org.uk - http://profiles.google.com/tim.hutton/
More information about the vtkusers
mailing list