| 71 | } |
| 72 | |
| 73 | void ImageVtkLegacyIO::Write() |
| 74 | { |
| 75 | ValidateOutputLocation(); |
| 76 | |
| 77 | const auto *input = dynamic_cast<const Image *>(this->GetInput()); |
| 78 | |
| 79 | vtkSmartPointer<vtkStructuredPointsWriter> writer = vtkSmartPointer<vtkStructuredPointsWriter>::New(); |
| 80 | |
| 81 | // The legacy vtk image writer cannot write to streams |
| 82 | LocalFile localFile(this); |
| 83 | writer->SetFileName(localFile.GetFileName().c_str()); |
| 84 | |
| 85 | if (us::any_cast<bool>(GetWriterOption("Save as binary file"))) |
| 86 | { |
| 87 | writer->SetFileTypeToBinary(); |
| 88 | } |
| 89 | |
| 90 | ImageVtkReadAccessor vtkReadAccessor(Image::ConstPointer(input), nullptr, input->GetVtkImageData()); |
| 91 | writer->SetInputData(const_cast<vtkImageData *>(vtkReadAccessor.GetVtkImageData())); |
| 92 | |
| 93 | if (writer->Write() == 0 || writer->GetErrorCode() != 0) |
| 94 | { |
| 95 | mitkThrow() << "vtkStructuredPointesWriter error: " |
| 96 | << vtkErrorCode::GetStringFromErrorCode(writer->GetErrorCode()); |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | IFileIO::ConfidenceLevel ImageVtkLegacyIO::GetWriterConfidenceLevel() const |
| 101 | { |
nothing calls this directly
no test coverage detected