Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkPlanarFigureCompositeReader.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 <itkMetaDataObject.h>
19 #include <itksys/SystemTools.hxx>
20 #include <tinyxml.h>
21 #include <vtkCleanPolyData.h>
22 #include <mitkTrackvis.h>
23 #include <mitkCustomMimeType.h>
25 #include <boost/property_tree/ptree.hpp>
26 #define RAPIDXML_NO_EXCEPTIONS
27 #include <boost/property_tree/xml_parser.hpp>
28 #include <boost/foreach.hpp>
29 #include <boost/lexical_cast.hpp>
31 
32 
34  : mitk::AbstractFileReader( mitk::DiffusionIOMimeTypes::PLANARFIGURECOMPOSITE_MIMETYPE(), "Planar Figure Composite Reader" )
35 {
36  m_ServiceReg = this->RegisterService();
37 }
38 
40  :mitk::AbstractFileReader(other)
41 {
42 }
43 
45 {
46  return new PlanarFigureCompositeReader(*this);
47 }
48 
49 
50 std::vector<itk::SmartPointer<mitk::BaseData> > mitk::PlanarFigureCompositeReader::Read()
51 {
52 
53  std::vector<itk::SmartPointer<mitk::BaseData> > result;
54  try
55  {
56  const std::string& locale = "C";
57  const std::string& currLocale = setlocale( LC_ALL, NULL );
58  setlocale(LC_ALL, locale.c_str());
59 
60  std::string filename = this->GetInputLocation();
61 
62  std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename);
63  ext = itksys::SystemTools::LowerCase(ext);
64 
65  boost::property_tree::ptree tree;
66  boost::property_tree::xml_parser::read_xml(filename, tree);
67  int comptype = tree.get<int>("comptype");
68 
70  switch(comptype)
71  {
72  case 0:
73  pfc->setOperationType(mitk::PlanarFigureComposite::AND);
74  MITK_INFO << "loading AND composition";
75  break;
76  case 1:
77  pfc->setOperationType(mitk::PlanarFigureComposite::OR);
78  MITK_INFO << "loading OR composition";
79  break;
80  case 2:
81  pfc->setOperationType(mitk::PlanarFigureComposite::NOT);
82  MITK_INFO << "loading NOT composition";
83  break;
84  default:
85  MITK_ERROR << filename << " contains no valid composition type!";
86  }
87 
88  std::vector<itk::SmartPointer<mitk::BaseData> > result;
89  result.push_back(pfc.GetPointer());
90 
91  setlocale(LC_ALL, currLocale.c_str());
92 
93  return result;
94  }
95  catch(...)
96  {
97  throw;
98  }
99  return result;
100 }
#define MITK_INFO
Definition: mitkLogMacros.h:22
#define MITK_ERROR
Definition: mitkLogMacros.h:24
DataCollection - Class to facilitate loading/accessing structured data.
virtual PlanarFigureCompositeReader * Clone() const override
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static const std::string filename
Base class for creating mitk::BaseData objects from files or streams.
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.