vtkWriter to memory

Occasionally I want to use a vtkWriter to write to memory instead of disk. The docs offer this teaser:

vtkWriter is an abstract class for mapper objects that write their data to disk (or into a communications port)

Is the ability to write to memory or a communications port something which must be implemented by the subclass, or is there a way to make any vtkWriter write to memory?

AFAIK, this is something each writer must implement as most operate on paths. Note that some writers handle formats that write directories of files rather than single files, so these are much harder to support (though vtkArchiver could be used to do this, useful subclasses are not generally available because they require an external dependency).

Hi @whophil

vtkDataWriter::WriteToOutputString lets you do that.


That works for some things, but if a class inherits from vtkWriter, such functionality is “orphaned”. AFAICT, the vast majority of the writer classes are in this bucket. So, you can probably get “VTK” format output in such a way, but not something like PLY or GeoJSON.

Agreed, only vtkDataWriter has this capabilities afaik.

Thanks for the answer and discussion!