Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
mitkPlanarFigureCompositeSerializer.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
21 
22 #include <itksys/SystemTools.hxx>
23 #include <mitkIOUtil.h>
24 
25 
26 MITK_REGISTER_SERIALIZER(PlanarFigureCompositeSerializer)
27 
28 
30 {
31 }
32 
33 
35 {
36 }
37 
38 
40 {
41  const PlanarFigureComposite* fb = dynamic_cast<const PlanarFigureComposite*>( m_Data.GetPointer() );
42  if (fb == NULL)
43  {
44  MITK_ERROR << " Object at " << (const void*) this->m_Data
45  << " is not an mitk::PlanarFigureComposite. Cannot serialize as PlanarFigureComposite.";
46  return "";
47  }
48 
49  std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
50  filename += "_";
51  filename += m_FilenameHint;
52  filename += ".pfc";
53 
54  std::string fullname(m_WorkingDirectory);
55  fullname += "/";
56  fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
57 
58  try
59  {
60  mitk::IOUtil::Save(fb,fullname);
61  }
62  catch (std::exception& e)
63  {
64  MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data
65  << " to "
66  << fullname
67  << ": "
68  << e.what();
69  return "";
70  }
71  return filename;
72 }
73 
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
Definition: mitkIOUtil.cpp:824
#define MITK_REGISTER_SERIALIZER(classname)
#define MITK_ERROR
Definition: mitkLogMacros.h:24
DataCollection - Class to facilitate loading/accessing structured data.
virtual std::string Serialize() override
Serializes given BaseData object.
static const std::string filename
Serializes mitk::Surface for mitk::SceneIO.