| 32 | } |
| 33 | |
| 34 | vtkSmartPointer<vtkPolyData> SurfaceVtkIO::GetPolyData(unsigned int t, std::string &fileName) |
| 35 | { |
| 36 | const auto *input = dynamic_cast<const Surface *>(this->GetInput()); |
| 37 | |
| 38 | vtkSmartPointer<vtkTransformPolyDataFilter> transformPolyData = vtkSmartPointer<vtkTransformPolyDataFilter>::New(); |
| 39 | |
| 40 | // surfaces do not have to exist in all timesteps; therefor, only write valid surfaces |
| 41 | if (input->GetVtkPolyData(t) == nullptr) |
| 42 | return vtkSmartPointer<vtkPolyData>(); |
| 43 | |
| 44 | std::string baseName = this->GetOutputLocation(); |
| 45 | std::string extension = Utf8Util::Utf8ToLocal8Bit(itksys::SystemTools::GetFilenameExtension(Utf8Util::Local8BitToUtf8(baseName))); |
| 46 | if (!extension.empty()) |
| 47 | { |
| 48 | baseName = baseName.substr(0, baseName.size() - extension.size()); |
| 49 | } |
| 50 | |
| 51 | std::ostringstream ss; |
| 52 | ss.imbue(::std::locale::classic()); |
| 53 | |
| 54 | BaseGeometry *geometry = input->GetGeometry(t); |
| 55 | if (input->GetTimeGeometry()->IsValidTimeStep(t)) |
| 56 | { |
| 57 | if (input->GetTimeGeometry()->CountTimeSteps() > 1) |
| 58 | { |
| 59 | const TimeBounds &timebounds = input->GetTimeGeometry()->GetTimeBounds(t); |
| 60 | ss << baseName << "_S" << std::setprecision(0) << timebounds[0] << "_E" << std::setprecision(0) << timebounds[1] |
| 61 | << "_T" << t << extension; |
| 62 | } |
| 63 | else |
| 64 | { |
| 65 | // use the original file name |
| 66 | ss << this->GetOutputLocation(); |
| 67 | } |
| 68 | } |
| 69 | else |
| 70 | { |
| 71 | MITK_WARN << "Error on write: TimeGeometry invalid of surface " << fileName << "."; |
| 72 | return vtkSmartPointer<vtkPolyData>(); |
| 73 | } |
| 74 | |
| 75 | fileName = ss.str(); |
| 76 | |
| 77 | transformPolyData->SetInputData(input->GetVtkPolyData(t)); |
| 78 | transformPolyData->SetTransform(geometry->GetVtkTransform()); |
| 79 | transformPolyData->UpdateWholeExtent(); |
| 80 | |
| 81 | vtkSmartPointer<vtkPolyData> polyData = transformPolyData->GetOutput(); |
| 82 | return polyData; |
| 83 | } |
| 84 | |
| 85 | IFileIO::ConfidenceLevel SurfaceVtkIO::GetWriterConfidenceLevel() const |
| 86 | { |
no test coverage detected