19 #include <vtkErrorCode.h> 20 #include <vtkSmartPointer.h> 21 #include <vtkStructuredPoints.h> 22 #include <vtkStructuredPointsReader.h> 23 #include <vtkStructuredPointsWriter.h> 31 defaultOptions[
"Save as binary file"] =
false;
40 vtkSmartPointer<vtkStructuredPointsReader> reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
41 reader->SetFileName(fileName.c_str());
44 if (reader->GetOutput() !=
nullptr)
47 output->Initialize(reader->GetOutput());
48 output->SetVolume(reader->GetOutput()->GetScalarPointer());
49 std::vector<BaseData::Pointer> result;
50 result.push_back(output.GetPointer());
55 mitkThrow() <<
"vtkStructuredPointsReader error: " 56 << vtkErrorCode::GetStringFromErrorCode(reader->GetErrorCode());
64 vtkSmartPointer<vtkStructuredPointsReader> reader = vtkSmartPointer<vtkStructuredPointsReader>::New();
66 if (reader->IsFileStructuredPoints())
77 const auto *input =
dynamic_cast<const Image *
>(this->
GetInput());
79 vtkSmartPointer<vtkStructuredPointsWriter> writer = vtkSmartPointer<vtkStructuredPointsWriter>::New();
83 writer->SetFileName(localFile.
GetFileName().c_str());
87 writer->SetFileTypeToBinary();
91 writer->SetInputData(const_cast<vtkImageData *>(vtkReadAccessor.GetVtkImageData()));
93 if (writer->Write() == 0 || writer->GetErrorCode() != 0)
95 mitkThrow() <<
"vtkStructuredPointesWriter error: " 96 << vtkErrorCode::GetStringFromErrorCode(writer->GetErrorCode());
104 const auto *input =
static_cast<const Image *
>(this->
GetInput());
105 if (input->GetDimension() == 3)
107 else if (input->GetDimension() < 3)
ConfidenceLevel GetReaderConfidenceLevel() const override
std::string GetFileName()
DataCollection - Class to facilitate loading/accessing structured data.
std::map< std::string, us::Any > Options
Options for reading or writing data.
us::Any GetWriterOption(const std::string &name) const
std::string GetLocalFileName() const
Get a local file name for reading.
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
std::pair< us::ServiceRegistration< IFileReader >, us::ServiceRegistration< IFileWriter > > RegisterService(us::ModuleContext *context=us::GetModuleContext())
const BaseData * GetInput() const override
Get the input data set via SetInput().
Image class for storing images.
A local file representation for streams.
void ValidateOutputLocation() const
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...
ConfidenceLevel GetReaderConfidenceLevel() const override
ConfidenceLevel GetWriterConfidenceLevel() const override
ConfidenceLevel GetWriterConfidenceLevel() const override
Abstract class for implementing a reader and writer.
void SetDefaultWriterOptions(const Options &defaultOptions)
std::vector< BaseData::Pointer > Read() override
Reads a path or stream and creates a list of BaseData objects.