Any way to insert comments in a file created by vtkXMLImageDataWriter

In 3D Slicer, we use field data to store additional metadata with meshes. You can read/write using existing VTK API. Search for “fielddata” in this file to see examples for reading/writing.