23 #include <vtkErrorCode.h>
24 #include <vtkImageData.h>
25 #include <vtkSmartPointer.h>
26 #include <vtkXMLImageDataReader.h>
27 #include <vtkXMLImageDataWriter.h>
31 class VtkXMLImageDataReader :
public ::vtkXMLImageDataReader
34 static VtkXMLImageDataReader *
New() {
return new VtkXMLImageDataReader(); }
35 vtkTypeMacro(VtkXMLImageDataReader, vtkXMLImageDataReader)
37 void SetStream(
std::istream *is)
41 std::istream *GetStream()
const {
return this->Stream; }
44 class VtkXMLImageDataWriter :
public ::vtkXMLImageDataWriter
47 static VtkXMLImageDataWriter *
New() {
return new VtkXMLImageDataWriter(); }
48 vtkTypeMacro(VtkXMLImageDataWriter, vtkXMLImageDataWriter)
50 void SetStream(
std::ostream *os)
54 std::ostream *GetStream()
const {
return this->Stream; }
76 if (reader->GetOutput() != NULL)
79 output->Initialize(reader->GetOutput());
80 output->SetVolume(reader->GetOutput()->GetScalarPointer());
81 std::vector<BaseData::Pointer> result;
82 result.push_back(output.GetPointer());
87 mitkThrow() <<
"vtkXMLImageDataReader error: " << vtkErrorCode::GetStringFromErrorCode(reader->GetErrorCode());
99 if (xmlReader->CanReadFile(this->GetInputLocation().c_str()) != 0)
127 writer->SetInputData(const_cast<vtkImageData *>(vtkReadAccessor.GetVtkImageData()));
129 if (writer->Write() == 0 || writer->GetErrorCode() != 0)
131 mitkThrow() <<
"vtkXMLImageDataWriter error: " << vtkErrorCode::GetStringFromErrorCode(writer->GetErrorCode());
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
virtual vtkImageData * GetVtkImageData(int t=0, int n=0)
Get a volume at a specific time t of channel n as a vtkImageData.
virtual ConfidenceLevel GetReaderConfidenceLevel() const override
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().
Image class for storing images.
static const char * GetStaticNameOfClass()
virtual ConfidenceLevel GetWriterConfidenceLevel() const override
virtual void Write() override
Write the base data to the specified location or output stream.
ImageVtkReadAccessor class provides any image read access which is required by Vtk methods...
virtual std::ostream * GetOutputStream() const override
Get the output stream.
virtual std::string GetOutputLocation() const override
Get the current output location.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
virtual ConfidenceLevel GetWriterConfidenceLevel() const override
virtual std::vector< BaseData::Pointer > Read() override
Reads a path or stream and creates a list of BaseData objects.
virtual std::string GetInputLocation() const override
Get the current input location.
unsigned int GetDimension() const
Get dimension of the image.
Abstract class for implementing a reader and writer.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.