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
mitkPointSetSerializer.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 
17 #include "mitkPointSetSerializer.h"
18 #include "mitkIOUtil.h"
19 
20 MITK_REGISTER_SERIALIZER(PointSetSerializer)
21 
23 {
24 }
25 
27 {
28 }
29 
31 {
32  const PointSet *ps = dynamic_cast<const PointSet *>(m_Data.GetPointer());
33  if (ps == NULL)
34  {
35  MITK_ERROR << " Object at " << (const void *)this->m_Data
36  << " is not an mitk::PointSet. Cannot serialize as pointset.";
37  return "";
38  }
39 
40  std::string filename(this->GetUniqueFilenameInWorkingDirectory());
41  filename += "_";
42  filename += m_FilenameHint;
43  filename += ".mps";
44 
45  std::string fullname(m_WorkingDirectory);
46  fullname += IOUtil::GetDirectorySeparator();
47  fullname += filename;
48 
49  try
50  {
51  IOUtil::Save(ps, fullname);
52  }
53  catch (std::exception &e)
54  {
55  MITK_ERROR << " Error serializing object at " << (const void *)this->m_Data << " to " << fullname << ": "
56  << e.what();
57  return "";
58  }
59  return filename;
60 }
static void Save(const mitk::BaseData *data, const std::string &path)
Save a mitk::BaseData instance.
Definition: mitkIOUtil.cpp:824
static char GetDirectorySeparator()
Definition: mitkIOUtil.cpp:363
#define MITK_REGISTER_SERIALIZER(classname)
virtual std::string Serialize() override
Serializes given BaseData object.
#define MITK_ERROR
Definition: mitkLogMacros.h:24
Serializes mitk::Surface for mitk::SceneIO.
DataCollection - Class to facilitate loading/accessing structured data.
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:79
static const std::string filename