DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
itkFiberTractsWriter.h
Go to the documentation of this file.
1 
12 #ifndef __itkFiberTractsWriter_h
13 #define __itkFiberTractsWriter_h
14 
15 #include <itkLightProcessObject.h>
16 
17 #include "itkFiberTracts.h"
18 #include "utlCoreMacro.h"
19 
20 namespace itk
21 {
22 
23 class ITK_EXPORT FiberTractsWriter : public LightProcessObject
24 {
25 public:
28  typedef LightProcessObject Superclass;
29  typedef SmartPointer<Self> Pointer;
30 
32  itkNewMacro(Self);
33 
35  itkTypeMacro(FiberTractsWriter, LightProcessObject);
36 
43 
44  itkSetGetMacro(FileName, std::string);
45  itkSetGetMacro(FiberTracts, FiberTractsPointer);
46 
48  virtual void Update();
49 
50  void WriteTractsTRK();
51 
52  void WriteTractsTCK();
53 
54  // void WriteTractsVTK();
55 
56 protected:
59 
60  void PrintSelf(std::ostream& os, Indent indent) const ITK_OVERRIDE
61  {
62  Superclass::PrintSelf(os, indent);
63  PrintVar(true, os<< indent, m_FileName);
64  m_FiberTracts->Print(os, indent);
65  }
66 
67  std::string m_FileName;
68 
69  FiberTractsPointer m_FiberTracts = FiberTractsType::New();
70 
71 
72 private:
73  FiberTractsWriter(const Self&); //purposely not implemented
74  void operator=(const Self&); //purposely not implemented
75 
76 };
77 
78 inline bool
79 SaveFibers ( const SmartPointer<FiberTracts<double> >& fibers, const std::string& filename, const std::string& printInfo="Writing fibers:" )
80 {
82  writer->SetFileName(filename);
83  writer->SetFiberTracts(fibers);
84  try
85  {
86  if (utl::IsLogNormal())
87  std::cout << printInfo << " " << filename << std::endl;
88  writer->Update();
89  }
90  catch (itk::ExceptionObject & err)
91  {
92  std::cout << "ExceptionObject caught !" << std::endl;
93  std::cout << err << std::endl;
94  return false;
95  }
96  return true;
97 }
98 
99 }
100 
101 #ifndef ITK_MANUAL_INSTANTIATION
102 #include "itkFiberTractsWriter.hxx"
103 #endif
104 
105 
106 #endif
FiberType::Pointer FiberPointer
TractType::VertexType VertexType
Definition: itkFiber.h:44
bool SaveFibers(const SmartPointer< FiberTracts< double > > &fibers, const std::string &filename, const std::string &printInfo="Writing fibers:")
void PrintSelf(std::ostream &os, Indent indent) const ITK_OVERRIDE
static Pointer New()
#define ITK_OVERRIDE
Definition: utlITKMacro.h:46
bool IsLogNormal(const int level=utl::LogLevel)
Definition: utlCoreMacro.h:209
#define PrintVar(cond, os,...)
Definition: utlCoreMacro.h:242
std::vector< ValueType > STDVectorType
Definition: itkFiber.h:46
#define itkSetGetMacro(name, type)
Definition: utlITKMacro.h:134
FiberTractsType::FiberType FiberType
FiberTractsType::Pointer FiberTractsPointer
Created "07-22-2017.
macros for utlCore
FiberType::VertexType VertexType
SmartPointer< Self > Pointer
SmartPointer< Self > Pointer
LightProcessObject Superclass
FiberTracts< double > FiberTractsType
Created "07-23-2017.
FiberTractsType::FiberPointer FiberPointer
FiberType::STDVectorType STDVectorType