[vtkusers] Serialization of vtk objects from an XML string
    Bryn Lloyd 
    lloyd at itis.ethz.ch
       
    Wed Mar 21 12:42:03 EDT 2012
    
    
  
Hi
I found an example (post by Xiaoping Chen) of how to serialize a 
vtkDataSet (e.g. vtkPolyData), using the XML writers.
http://public.kitware.com/pipermail/vtkusers/2011-August/118157.html
However, I could not figure out how to implement the corresponding reader.
Bryn
Here is the example for the writer:
#include <ostream>
#include <vtkXMLImageDataWriter.h>
#include <vtkOutputStream.h>
#include <vtkObjectFactory.h>
class vtkXMLImageDataStreamWriter : public vtkXMLImageDataWriter
{
public:
     static vtkXMLImageDataStreamWriter* New();
     virtual void SetUserStream(std::ostream& output_stream)
     {
         this->Stream = &output_stream;
         this->Stream->precision(11);
         this->DataStream->SetStream(this->Stream);
     }
protected:
     vtkXMLImageDataStreamWriter() {}
     ~vtkXMLImageDataStreamWriter() {}
     virtual int WriteInternal()
     {
         (*this->Stream).imbue(vtkstd::locale::classic());
         return this->WriteData();
     }
};
vtkStandardNewMacro(vtkXMLImageDataStreamWriter);
    
    
More information about the vtkusers
mailing list