[vtkusers] extending VTK's XML file formats

David Gobbi david.gobbi at gmail.com
Tue Jan 10 12:03:30 EST 2012


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.

 - David


On Tue, Jan 10, 2012 at 9:49 AM, Tim Hutton <tim.hutton at gmail.com> wrote:
> On 10 January 2012 16:19, Matheus Viana <vianamp at gmail.com> wrote:
>> Hi Tim.
>>
>> Did you check this example?
>> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/IO/Testing/Tcl/TestXMLImageDataIO.tcl?root=VTK&content-type=text/plain
>>
>> Is that useful for you?
>
> Thanks Matheus, but unless I've missed something that example just
> uses the standard XML format, without adding anything. I need to add
> significant amounts of data (strings, values, etc.).
>
>>
>> Best,
>> Matheus Viana
>> Computational Physics
>> IFSC-USP
>>
>>
>> 2012/1/10 Tim Hutton <tim.hutton at gmail.com>
>>>
>>> What is the accepted way of extending VTK's XML file formats? I would
>>> like to be able to attach metadata to a vtkImageData file. Presumably
>>> the right approach involves subclassing vtkXMLImageDataWriter and
>>> vtkXMLImageDataReader but I'm not sure how to proceed. Is there an
>>> example somewhere?
>>>
>>> Thanks,
>>>
>>> Tim



More information about the vtkusers mailing list