13 #include "MeshFromTensorsCLP.h" 15 #include "vtkPolyDataWriter.h" 28 main (
int argc,
char const* argv[])
32 typedef double PixelType;
33 typedef itk::VectorImage<PixelType, 3> InputImageType;
42 InputImageType::Pointer inputImage;
46 std::vector<double> tensor;
48 InputImageType::PixelType pixel(tensor.size());
50 inputImage = itk::GenerateImageFromSingleVoxel<InputImageType>(pixel);
56 std::vector<double> tensor, tensor6d(6), tensor9d(9);
70 InputImageType::PixelType pixel(tensor6d.size());
72 inputImage = itk::GenerateImageFromSingleVoxel<InputImageType>(pixel);
76 MeshCreatorType::Pointer filter = MeshCreatorType::New();
78 filter->SetInput( inputImage );
80 typedef MeshCreatorType::ScalarImageType ScalarImageType;
81 ScalarImageType::Pointer scalarImage = ScalarImageType::New();
82 if (_ScalarImageFileArg.isSet())
85 filter->SetScalarImage(scalarImage);
88 if (_GlyphType ==
"LINE") { filter->SetShapeMode(MeshCreatorType::GLYPH_LINE); }
89 if (_GlyphType ==
"ARROW") { filter->SetShapeMode(MeshCreatorType::GLYPH_ARROW); }
90 if (_GlyphType ==
"DISK") { filter->SetShapeMode(MeshCreatorType::GLYPH_DISK); }
91 if (_GlyphType ==
"CYLINDER") { filter->SetShapeMode(MeshCreatorType::GLYPH_CYLINDER); }
92 if (_GlyphType ==
"CUBE") { filter->SetShapeMode(MeshCreatorType::GLYPH_CUBE); }
93 if (_GlyphType ==
"ELLIPSOID") { filter->SetShapeMode(MeshCreatorType::GLYPH_SPHERE); }
94 if (_GlyphType ==
"SUPERQUADRIC") { filter->SetShapeMode(MeshCreatorType::GLYPH_SUPERQUADRIC); }
96 if (_ColorScheme ==
"NONE") { filter->SetTensorColorScheme(MeshCreatorType::COLOR_NONE); }
97 if (_ColorScheme ==
"FA") { filter->SetTensorColorScheme(MeshCreatorType::COLOR_BY_FA); }
98 if (_ColorScheme ==
"MD") { filter->SetTensorColorScheme(MeshCreatorType::COLOR_BY_MD); }
99 if (_ColorScheme ==
"DIRECTION") { filter->SetTensorColorScheme(MeshCreatorType::COLOR_BY_DIRECTION); }
100 if (_ColorScheme ==
"IMAGE") { filter->SetTensorColorScheme(MeshCreatorType::COLOR_BY_IMAGE); }
102 filter->SetScale( _Scale );
103 filter->SetFlip(_Flip[0], _Flip[1], _Flip[2]);
104 filter->SetBoxView(_BoxView[0], _BoxView[1], _BoxView[2], _BoxView[3], _BoxView[4], _BoxView[5]);
105 filter->SetSliceView(_SliceView[0], _SliceView[1], _SliceView[2]);
110 filter->SetGlyphResolution(_GlyphResolution);
111 filter->SetDebug(_DebugArg.isSet());
113 std::cout <<
"Generating mesh ... " << std::flush;
117 std::cout << clock.GetMean() <<
"s elapsed" << std::endl;
119 MeshCreatorType::OutputMeshPolyDataType* mesh = filter->GetOutput();
121 if (_OutputFileArg.isSet())
130 if (_ColorScheme==
"DIRECTION")
133 vtk::VisualizePolyDataWithScalarRange(mesh, _ScalarRange, {0.0,1.0}, _Angle, _WindowSize, !_NoNormalArg.isSet(), !_NoLightingArg.isSet(), _Zoom, _PNGFile, _BackgroundColor);
138 vtk::VisualizePolyDataWithScalarRange(mesh, _ScalarRange, {0.6667,0.0}, _Angle, _WindowSize, !_NoNormalArg.isSet(), !_NoLightingArg.isSet(), _Zoom, _PNGFile, _BackgroundColor);
helper functions specifically used in dmritool
void VectorToVector(const T1 &v1, T2 &v2, const int N)
void ReadVectorImage(const std::string &filename, SmartPointer< VectorImage< PixelType, 3 > > &image, const std::string &printInfo="Reading Image:")
bool IsFileExist(const std::string &file)
bool ReadImage(const std::string &filename, SmartPointer< ImageType > &image, const std::string &printInfo="Reading Image:")
#define utlGlobalException(cond, expout)
Compute mesh from a tensor image.
void ReadVector(const std::string &vectorStr, std::vector< T > &vec, const char *cc=" ")
void PrintVector(const std::vector< T > &vec, const std::string &str="", const char *separate=" ", std::ostream &os=std::cout, bool showStats=true)
void ConvertTensor6DTo9D(const V1Type &v6d, V2Type &v9d, int v6dStoreWay)
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})
bool IsEndingWith(const std::string &fullString, const std::string &ending)
int SetVector(const char *s, std::vector< T > &vec, const int least_num=0, const char &c=',')
int main(int argc, char const *argv[])
Gnerate mesh from peaks.
void ConvertTensor9DTo6D(const V1Type &v9d, V2Type &v6d, int v6dStoreWay)
void WriteVtkPolyData(vtkPolyData *mesh, const std::string &filename)