DMRITool  v0.1.1-139-g860d86b4
Diffusion MRI Tool
MeshFromTracts.cxx
Go to the documentation of this file.
1 
12 #include "MeshFromTractsCLP.h"
13 
14 #include "vtkPolyDataWriter.h"
15 
17 
18 #include "utl.h"
19 #include "utlVTK.h"
20 
21 #include "itkFiberTractsReader.h"
23 #include "vtkPolyDataViewer.h"
24 
28  int
29 main (int argc, char const* argv[])
30 {
31  PARSE_ARGS;
32 
33  itk::TimeProbe clock;
34 
35  utlGlobalException(_Flip.size()!=3, "need 3 parameters in --flip");
36 
38  reader->SetFileName(_InputFile);
39  reader->Update();
40 
41  auto fibers = reader->GetOutput();
42 
43  // fibers->Print(std::cout<<"fibers=\n");
44 
45  typedef itk::MeshFromFiberTractsFilter MeshCreatorType;
46  MeshCreatorType::Pointer filter = MeshCreatorType::New();
47 
48  if (_ColorScheme == "DIRECTION") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_POINT_DIRECTION); }
49  if (_ColorScheme == "MEAN_DIRECTION") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_MEAN_DIRECTION); }
50  if (_ColorScheme == "END_POINTS") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_ENDPOINTS_DIRECTION); }
51  if (_ColorScheme == "FIXED") { filter->SetColorScheme(MeshCreatorType::COLOR_FIXED); }
52  if (_ColorScheme == "IMAGE") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_IMAGE); }
53  if (_ColorScheme == "SCALARS") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_SCALARS); }
54  if (_ColorScheme == "PROPERTY") { filter->SetColorScheme(MeshCreatorType::COLOR_BY_PROPERTY); }
55 
56  filter->SetFiberTracts( fibers );
57  filter->SetColor(_ColorFiber[0], _ColorFiber[1], _ColorFiber[2]);
58  filter->SetFlip(_Flip[0], _Flip[1], _Flip[2]);
59  if (_TubeRadiusArg.isSet())
60  {
61  filter->SetShapeMode(MeshCreatorType::GLYPH_TUBE);
62  filter->SetTubeRadius(_TubeRadius);
63  }
64  else
65  filter->SetShapeMode(MeshCreatorType::GLYPH_LINE);
66 
67  filter->SetDebug(_DebugArg.isSet());
68 
69  std::cout << "Generating mesh ... " << std::flush;
70  clock.Start();
71  filter->Update();
72  clock.Stop();
73  std::cout << clock.GetMean() << "s elapsed" << std::endl;
74 
75 
76 
77  vtkPolyData* mesh = filter->GetOutput();
78 
79  if (_OutputFileArg.isSet())
80  {
81  utl::WriteVtkPolyData(mesh, _OutputFile);
82  }
83  else
84  {
85  utlGlobalException(_WindowSize.size()!=2, "wrong window size");
86  utlGlobalException(_Angle.size()!=2, "wrong angle size");
87  vtk::VisualizePolyDataWithScalarRange(mesh, _ScalarRange, {0.6667,0.0}, _Angle, _WindowSize, !_NoNormalArg.isSet(), true, _Zoom, _PNGFile);
88  }
89 }
SmartPointer< Self > Pointer
helper functions specifically used in dmritool
Created "06-08-2017.
Created "06-06-2017.
Created "08-23-2017.
static Pointer New()
#define utlGlobalException(cond, expout)
Definition: utlCoreMacro.h:372
Created "08-23-2017.
void VisualizePolyDataWithScalarRange(const std::vector< vtkPolyData * > &meshes, const std::vector< double > &opacity, const std::vector< double > &scalarRange={-1.0,-1.0}, const std::vector< double > &hueRange={0.6667, 0.0}, const std::vector< double > &angle={0.0, 0.0}, const std::vector< int > &windowSize={600, 600}, const bool useNormal=true, const bool lighting=true, const double zoom=1.0, const std::string &pngfile="", const std::vector< double > &bgColor={0, 0, 0})
int main(int argc, char const *argv[])
Gnerate mesh from peaks.
void WriteVtkPolyData(vtkPolyData *mesh, const std::string &filename)
Definition: utlVTK.h:45