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
mitkFiberBundleSerializer.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 
18 #include "mitkFiberBundle.h"
20 
21 #include <itksys/SystemTools.hxx>
22 #include <mitkIOUtil.h>
23 
24 
25 MITK_REGISTER_SERIALIZER(FiberBundleSerializer)
26 
27 
29 {
30 }
31 
32 
34 {
35 }
36 
37 
39 {
40  const FiberBundle* fb = dynamic_cast<const FiberBundle*>( m_Data.GetPointer() );
41  if (fb == NULL)
42  {
43  MITK_ERROR << " Object at " << (const void*) this->m_Data
44  << " is not an mitk::FiberBundle. Cannot serialize as FiberBundle.";
45  return "";
46  }
47 
48  std::string filename( this->GetUniqueFilenameInWorkingDirectory() );
49  filename += "_";
50  filename += m_FilenameHint;
51  filename += ".fib";
52 
53  std::string fullname(m_WorkingDirectory);
54  fullname += "/";
55  fullname += itksys::SystemTools::ConvertToOutputPath(filename.c_str());
56 
57  try
58  {
59  mitk::IOUtil::Save(const_cast<FiberBundle*>(fb),fullname);
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 }
72 
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.
static const std::string filename
Base Class for Fiber Bundles;.
virtual std::string Serialize() override
Serializes given BaseData object.
Serializes mitk::Surface for mitk::SceneIO.