| 26 | } |
| 27 | |
| 28 | std::string mitk::ContourModelSetSerializer::Serialize() |
| 29 | { |
| 30 | const auto *contourSet = dynamic_cast<const ContourModelSet *>(m_Data.GetPointer()); |
| 31 | if (!contourSet) |
| 32 | { |
| 33 | MITK_ERROR << " Object at " << (const void *)this->m_Data |
| 34 | << " is not an mitk::ContourModelSet. Cannot serialize as contour model set."; |
| 35 | return ""; |
| 36 | } |
| 37 | |
| 38 | std::string filename(this->GetUniqueFilenameInWorkingDirectory()); |
| 39 | filename += "_"; |
| 40 | filename += m_FilenameHint; |
| 41 | filename += ".cnt_set"; |
| 42 | |
| 43 | std::string fullname(m_WorkingDirectory); |
| 44 | fullname += "/"; |
| 45 | fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str()); |
| 46 | |
| 47 | try |
| 48 | { |
| 49 | ContourModelSetWriter writer; |
| 50 | writer.SetOutputLocation(fullname); |
| 51 | writer.SetInput(contourSet); |
| 52 | writer.Write(); |
| 53 | } |
| 54 | catch ( const std::exception &e ) |
| 55 | { |
| 56 | MITK_ERROR << " Error serializing object at " << (const void *)this->m_Data << " to " << fullname << ": " |
| 57 | << e.what(); |
| 58 | return ""; |
| 59 | } |
| 60 | |
| 61 | return filename; |
| 62 | } |
nothing calls this directly
no test coverage detected