MCPcopy Create free account
hub / github.com/MITK/MITK / Serialize

Method Serialize

Modules/ContourModel/src/IO/mitkContourModelSetSerializer.cpp:28–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28std::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}

Callers

nothing calls this directly

Calls 6

GetPointerMethod · 0.80
SetOutputLocationMethod · 0.80
whatMethod · 0.80
SetInputMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected