Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMAPRegistrationWrapperSerializer.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 
20 
22 
23 #include <itksys/SystemTools.hxx>
24 
25 
26 MITK_REGISTER_SERIALIZER(MAPRegistrationWrapperSerializer)
27 
28 
30 {
31 }
32 
33 
35 {
36 }
37 
38 
40 {
41  const mitk::MAPRegistrationWrapper* wrapper = dynamic_cast<const mitk::MAPRegistrationWrapper*>( m_Data.GetPointer() );
42  if (wrapper == NULL)
43  {
44  MITK_ERROR << " Object at " << (const void*) this->m_Data
45  << " is not an mitk::MAPRegistrationWrapper. Cannot serialize as MAPRegistrationWrapper for MatchPoint registration objects.";
46  return "";
47  }
48 
49  std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
50  filename += "_";
51  filename += m_FilenameHint;
52  filename += ".mapr";
53 
54  std::string fullname(m_WorkingDirectory);
55  fullname += "/";
56  fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
57 
58  try
59  {
61  writer.SetOutputLocation(fullname);
62  writer.AbstractFileWriter::SetInput( const_cast<mitk::MAPRegistrationWrapper*>( wrapper ) );
63  writer.Write();
64  }
65  catch (std::exception& e)
66  {
67  MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data
68  << " to "
69  << fullname
70  << ": "
71  << e.what();
72  return "";
73  }
74  return filename;
75 }
#define MITK_REGISTER_SERIALIZER(classname)
virtual void Write()
Write the base data to the specified location or output stream.
#define MITK_ERROR
Definition: mitkLogMacros.h:24
virtual std::string Serialize()
Serializes given BaseData object.
DataCollection - Class to facilitate loading/accessing structured data.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
Serializes mitk::MAPRegistrationWrapper for mitk::SceneIO.
static const std::string filename
virtual void SetOutputLocation(const std::string &location) override
Set the output location.