Medical Imaging Interaction Toolkit  2018.4.99-389bf124
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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
16 
18 
19 #include <itksys/SystemTools.hxx>
20 
21 
22 MITK_REGISTER_SERIALIZER(MAPRegistrationWrapperSerializer)
23 
24 
26 {
27 }
28 
29 
31 {
32 }
33 
34 
36 {
37  const mitk::MAPRegistrationWrapper* wrapper = dynamic_cast<const mitk::MAPRegistrationWrapper*>( m_Data.GetPointer() );
38  if (wrapper == nullptr)
39  {
40  MITK_ERROR << " Object at " << (const void*) this->m_Data
41  << " is not an mitk::MAPRegistrationWrapper. Cannot serialize as MAPRegistrationWrapper for MatchPoint registration objects.";
42  return "";
43  }
44 
45  std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
46  filename += "_";
47  filename += m_FilenameHint;
48  filename += ".mapr";
49 
50  std::string fullname(m_WorkingDirectory);
51  fullname += "/";
52  fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
53 
54  try
55  {
57  writer.SetOutputLocation(fullname);
58  writer.AbstractFileWriter::SetInput( dynamic_cast<const mitk::MAPRegistrationWrapper*>( wrapper ) );
59  writer.Write();
60  }
61  catch (std::exception& e)
62  {
63  MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data
64  << " to "
65  << fullname
66  << ": "
67  << e.what();
68  return "";
69  }
70  return filename;
71 }
#define MITK_REGISTER_SERIALIZER(classname)
#define MITK_ERROR
Definition: mitkLogMacros.h:20
std::string GetUniqueFilenameInWorkingDirectory()
DataCollection - Class to facilitate loading/accessing structured data.
std::string Serialize() override
Serializes given BaseData object.
MAPRegistrationWrapper Wrapper class to allow the handling of MatchPoint registration objects as mitk...
BaseData::ConstPointer m_Data
Serializes mitk::MAPRegistrationWrapper for mitk::SceneIO.
void SetOutputLocation(const std::string &location) override
Set the output location.
void Write() override
Write the base data to the specified location or output stream.