22 #include <vtkErrorCode.h>
23 #include <vtkPolyDataReader.h>
24 #include <vtkPolyDataWriter.h>
25 #include <vtkSmartPointer.h>
26 #include <vtkXMLPolyDataReader.h>
27 #include <vtkXMLPolyDataWriter.h>
35 defaultOptions[
"Save as binary file"] =
false;
47 reader->SetFileName(fileName.c_str());
50 if (reader->GetOutput() != NULL)
52 output->SetVtkPolyData(reader->GetOutput());
56 mitkThrow() <<
"vtkPolyDataReader error: " << vtkErrorCode::GetStringFromErrorCode(reader->GetErrorCode());
59 std::vector<BaseData::Pointer> result;
60 result.push_back(output.GetPointer());
70 if (reader->IsFilePolyData())
72 if (std::strcmp(reader->GetHeader(),
"vtk output") == 0)
88 const unsigned int timesteps = input->
GetTimeGeometry()->CountTimeSteps();
89 for (
unsigned int t = 0; t < timesteps; ++t)
92 vtkSmartPointer<vtkPolyData> polyData = this->
GetPolyData(t, fileName);
94 writer->SetInputData(polyData);
97 writer->SetFileTypeToBinary();
101 writer->SetFileName(localFile.
GetFileName().c_str());
103 if (writer->Write() == 0 || writer->GetErrorCode() != 0)
105 mitkThrow() <<
"Error during surface writing"
106 << (writer->GetErrorCode() ?
107 std::string(
": ") + vtkErrorCode::GetStringFromErrorCode(writer->GetErrorCode()) :
113 MITK_WARN <<
"Writing multiple time-steps to output streams is not supported. "
114 <<
"Only the first time-step will be written";
Class for storing surfaces (vtkPolyData).
virtual std::vector< BaseData::Pointer > Read() override
Reads a path or stream and creates a list of BaseData objects.
virtual ConfidenceLevel GetReaderConfidenceLevel() const override
std::string GetFileName()
DataCollection - Class to facilitate loading/accessing structured data.
void ValidateOutputLocation() const
vtkSmartPointer< vtkPolyData > GetPolyData(unsigned int t, std::string &fileName)
std::map< std::string, us::Any > Options
Options for reading or writing data.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
std::string GetLocalFileName() const
Get a local file name for reading.
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
virtual const BaseData * GetInput() const override
Get the input data set via SetInput().
static const char * GetStaticNameOfClass()
virtual void Write() override
Write the base data to the specified location or output stream.
A local file representation for streams.
virtual std::ostream * GetOutputStream() const override
Get the output stream.
us::Any GetWriterOption(const std::string &name) const
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
virtual ConfidenceLevel GetReaderConfidenceLevel() const override
void SetDefaultWriterOptions(const Options &defaultOptions)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.