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

Method Serialize

Modules/SceneSerialization/src/mitkImageSerializer.cpp:28–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28std::string mitk::ImageSerializer::Serialize()
29{
30 const auto *image = dynamic_cast<const Image *>(m_Data.GetPointer());
31 if (!image)
32 {
33 MITK_ERROR << " Object at " << (const void *)this->m_Data << " is not an mitk::Image. Cannot serialize as image.";
34 return "";
35 }
36
37 std::string filename(this->GetUniqueFilenameInWorkingDirectory());
38 std::cout << "creating file " << filename << " in " << m_WorkingDirectory << std::endl;
39 filename += "_";
40 filename += m_FilenameHint;
41
42 std::string fullname(m_WorkingDirectory);
43 fullname += Poco::Path::separator();
44 fullname += filename + ".nrrd";
45
46 try
47 {
48 IOUtil::Save(image, fullname);
49 }
50 catch (std::exception &e)
51 {
52 MITK_ERROR << " Error serializing object at " << (const void *)this->m_Data << " to " << fullname << ": "
53 << e.what();
54 return "";
55 }
56 return Poco::Path(fullname).getFileName();
57}

Callers 2

SaveBaseDataMethod · 0.45
SavePropertyListMethod · 0.45

Calls 4

PathClass · 0.85
GetPointerMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected