[vtk-developers] XML readers/writers with user streams

Goodwin Lawlor goodwin.lawlor at ucd.ie
Fri Jun 29 07:28:51 EDT 2007


Hi,

Reading through vtkXMLWriter/vtkXMLReader its looks like they were coded
to allow the reading and writing of datasets to/from a user stream
instead of to/from disk.

Was there any method to do this envisioned originally?

Below is what I've got working at the moment - is there a better way?

A new class vtkStringStream is a wrapper around std::stringstream just
like vtkOutputStream wraps std::ostream. It has an additional method
Get/SetString  for use with tcl,python etc. C++ can use Get/SetStream

vtkXMLReader/vtkXMLWriter has new methods Get/SetStringStream

(Tcl eg)

vtkConeSource cone

vtkStringStream ss

vtkXMLWriter writer
  writer SetInputConnection [cone GetOutputPort]
  writer SetStringStream ss
  writer Write

set cone_file [ss GetString]

This is useful with Tcl's "virtual file system"...

Thanks,

Goodwin



More information about the vtk-developers mailing list