22 #include <vtkErrorCode.h>
23 #include <vtkSmartPointer.h>
24 #include <vtkXMLPolyDataReader.h>
25 #include <vtkXMLPolyDataWriter.h>
29 class VtkXMLPolyDataReader :
public ::vtkXMLPolyDataReader
32 static VtkXMLPolyDataReader *
New() {
return new VtkXMLPolyDataReader(); }
33 vtkTypeMacro(VtkXMLPolyDataReader, vtkXMLPolyDataReader)
35 void SetStream(
std::istream *is)
39 std::istream *GetStream()
const {
return this->Stream; }
42 class VtkXMLPolyDataWriter :
public ::vtkXMLPolyDataWriter
45 static VtkXMLPolyDataWriter *
New() {
return new VtkXMLPolyDataWriter(); }
46 vtkTypeMacro(VtkXMLPolyDataWriter, vtkXMLPolyDataWriter)
48 void SetStream(
std::ostream *os)
52 std::ostream *GetStream()
const {
return this->Stream; }
76 if (reader->GetOutput() != NULL)
78 output->SetVtkPolyData(reader->GetOutput());
82 mitkThrow() <<
"vtkXMLPolyDataReader error: " << vtkErrorCode::GetStringFromErrorCode(reader->GetErrorCode());
85 std::vector<BaseData::Pointer> result;
86 result.push_back(output.GetPointer());
98 if (xmlReader->CanReadFile(this->GetInputLocation().c_str()) != 0)
115 const unsigned int timesteps = input->
GetTimeGeometry()->CountTimeSteps();
116 for (
unsigned int t = 0; t < timesteps; ++t)
118 std::string fileName;
119 vtkSmartPointer<vtkPolyData> polyData = this->
GetPolyData(t, fileName);
120 if (polyData.Get() == NULL)
122 mitkThrow() <<
"Cannot write empty surface";
126 writer->SetInputData(polyData);
132 MITK_WARN <<
"Writing multiple time-steps to output streams is not supported. "
133 <<
"Only the first time-step will be written";
139 writer->SetFileName(fileName.c_str());
142 if (writer->Write() == 0 || writer->GetErrorCode() != 0)
144 mitkThrow() <<
"Error during surface writing"
145 << (writer->GetErrorCode() ?
146 std::string(
": ") + vtkErrorCode::GetStringFromErrorCode(writer->GetErrorCode()) :
virtual std::vector< BaseData::Pointer > Read() override
Reads a path or stream and creates a list of BaseData objects.
Class for storing surfaces (vtkPolyData).
virtual ConfidenceLevel GetReaderConfidenceLevel() const override
virtual std::istream * GetInputStream() const override
Get the input stream.
DataCollection - Class to facilitate loading/accessing structured data.
void ValidateOutputLocation() const
vtkSmartPointer< vtkPolyData > GetPolyData(unsigned int t, std::string &fileName)
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
virtual void Write() override
Write the base data to the specified location or output stream.
virtual const BaseData * GetInput() const override
Get the input data set via SetInput().
static const char * GetStaticNameOfClass()
virtual std::ostream * GetOutputStream() const override
Get the output stream.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
virtual std::string GetInputLocation() const override
Get the current input location.
virtual ConfidenceLevel GetReaderConfidenceLevel() const override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.