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
mitkConnectomicsNetworkSerializer.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 
20 
21 #include <itksys/SystemTools.hxx>
22 
23 
24 MITK_REGISTER_SERIALIZER(ConnectomicsNetworkSerializer)
25 
26 
28 {
29 }
30 
31 
33 {
34 }
35 
36 
38 {
39  const ConnectomicsNetwork* conNet = dynamic_cast<const ConnectomicsNetwork*>( m_Data.GetPointer() );
40  if (conNet == NULL)
41  {
42  MITK_ERROR << " Object at " << (const void*) this->m_Data
43  << " is not an mitk::ConnectomicsNetwork. Cannot serialize as ConnectomicsNetwork.";
44  return "";
45  }
46 
47  std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
48  filename += "_";
49  filename += m_FilenameHint;
50  filename += ".cnf";
51 
52  std::string fullname(m_WorkingDirectory);
53  fullname += "/";
54  fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
55 
56  try
57  {
59  writer.SetOutputLocation(fullname);
60  writer.SetInput(const_cast<ConnectomicsNetwork*>(conNet));
61  writer.Write();
62  }
63  catch (std::exception& e)
64  {
65  MITK_ERROR << " Error serializing object at " << (const void*) this->m_Data
66  << " to "
67  << fullname
68  << ": "
69  << e.what();
70  return "";
71  }
72  return filename;
73 }
74 
#define MITK_REGISTER_SERIALIZER(classname)
virtual void SetInput(const BaseData *data) override
Set the input data for writing.
#define MITK_ERROR
Definition: mitkLogMacros.h:24
DataCollection - Class to facilitate loading/accessing structured data.
virtual void Write() override
Write the base data to the specified location or output stream.
static const std::string filename
Serializes mitk::ConnectomicsNetwork for mitk::SceneIO.
virtual void SetOutputLocation(const std::string &location) override
Set the output location.
Connectomics Network Class.
virtual std::string Serialize() override
Serializes given BaseData object.