Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkFiberBundleTrackVisReader.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 <vtkPolyData.h>
20 #include <vtkDataReader.h>
21 #include <vtkPolyDataReader.h>
22 #include <vtkMatrix4x4.h>
23 #include <vtkPolyLine.h>
24 #include <vtkCellArray.h>
25 #include <vtkDataArray.h>
26 #include <vtkFloatArray.h>
27 #include <vtkCellData.h>
28 #include <vtkPointData.h>
29 #include <itksys/SystemTools.hxx>
30 #include <tinyxml.h>
31 #include <vtkCleanPolyData.h>
32 #include <mitkTrackvis.h>
33 #include <mitkCustomMimeType.h>
35 
36 
38  : mitk::AbstractFileReader( mitk::DiffusionIOMimeTypes::FIBERBUNDLE_TRK_MIMETYPE_NAME(), "TrackVis Fiber Bundle Reader" )
39 {
40  m_ServiceReg = this->RegisterService();
41 }
42 
44  :mitk::AbstractFileReader(other)
45 {
46 }
47 
49 {
50  return new FiberBundleTrackVisReader(*this);
51 }
52 
53 std::vector<itk::SmartPointer<mitk::BaseData> > mitk::FiberBundleTrackVisReader::Read()
54 {
55 
56  std::vector<itk::SmartPointer<mitk::BaseData> > result;
57  try
58  {
59  const std::string& locale = "C";
60  const std::string& currLocale = setlocale( LC_ALL, NULL );
61  setlocale(LC_ALL, locale.c_str());
62 
63  std::string filename = this->GetInputLocation();
64 
65  std::string ext = itksys::SystemTools::GetFilenameLastExtension(filename);
66  ext = itksys::SystemTools::LowerCase(ext);
67 
68  if (ext==".trk")
69  {
71  TrackVisFiberReader reader;
72  reader.open(this->GetInputLocation().c_str());
73  reader.read(image.GetPointer());
74  result.push_back(image.GetPointer());
75  return result;
76  }
77 
78  setlocale(LC_ALL, currLocale.c_str());
79  MITK_INFO << "Fiber bundle read";
80  }
81  catch(...)
82  {
83  throw;
84  }
85  return result;
86 }
#define MITK_INFO
Definition: mitkLogMacros.h:22
short open(string m_Filename)
DataCollection - Class to facilitate loading/accessing structured data.
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
static const std::string filename
virtual std::vector< itk::SmartPointer< BaseData > > Read() override
Reads a path or stream and creates a list of BaseData objects.
short read(mitk::FiberBundle *fib)
Base class for creating mitk::BaseData objects from files or streams.
virtual FiberBundleTrackVisReader * Clone() const override
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.