16 #include "MeshFromSHCoefficientsCLP.h" 18 #include "vtkPolyDataWriter.h" 28 main(
int argc,
char *argv[])
40 typedef double PixelType;
41 typedef itk::VectorImage<PixelType, 3> InputImageType;
43 InputImageType::Pointer inputImage;
46 std::vector<double> shReadVec, shVec;
47 if (_ZonalSHArg.isSet())
50 int shRank = (shReadVec.size()-1)*2;
52 std::fill(shVec.begin(), shVec.end(), 0.0);
53 for (
int l = 0; l <= shRank; l=l+2 )
64 InputImageType::PixelType pixel(shVec.size());
66 inputImage = itk::GenerateImageFromSingleVoxel<InputImageType>(pixel);
73 if ( !_MaxOrderArg.isSet() )
77 unsigned numberOfBasisFunctions = (_MaxOrder + 1) * (_MaxOrder + 2) / 2;
78 itkAssertOrThrowMacro(numberOfBasisFunctions <=inputImage->GetNumberOfComponentsPerPixel(),
"MaxOrder too large. numberOfBasisFunctions="<< numberOfBasisFunctions
79 <<
", inputImage->GetNumberOfComponentsPerPixel()="<<inputImage->GetNumberOfComponentsPerPixel());
83 MeshCreatorType::Pointer filter = MeshCreatorType::New();
84 filter->SetScale( _Scale );
87 if (_Normalization==
"MIN_MAX") filter->SetNormalization( MeshCreatorType::MIN_MAX );
88 if (_Normalization==
"UNIT_MAX") filter->SetNormalization( MeshCreatorType::UNIT_MAX );
89 if (_Normalization==
"UNIT_INTEGRAL") filter->SetNormalization( MeshCreatorType::UNIT_INTEGRAL );
92 filter->SetRemoveNegativeValues(_RemoveNegativeValuesArg.isSet());
93 filter->SetStretch(!_NoStretchArg.isSet());
94 filter->SetMaxOrder( _MaxOrder );
95 filter->SetInput( inputImage );
97 filter->SetFlip(_Flip[0], _Flip[1], _Flip[2]);
98 filter->SetBoxView(_BoxView[0], _BoxView[1], _BoxView[2], _BoxView[3], _BoxView[4], _BoxView[5]);
99 filter->SetSliceView(_SliceView[0], _SliceView[1], _SliceView[2]);
101 if (_BasicShape ==
"TETRAHEDRON") { filter->SetBasicShape(MeshCreatorType::SphereTessellatorType::TETRAHEDRON); }
102 if (_BasicShape ==
"OCTAHEDRON") { filter->SetBasicShape(MeshCreatorType::SphereTessellatorType::OCTAHEDRON); }
103 if (_BasicShape ==
"ICOSAHEDRON") { filter->SetBasicShape(MeshCreatorType::SphereTessellatorType::ICOSAHEDRON); }
104 filter->SetTessellationOrder(_TessellationOrder);
106 if (_ColorScheme ==
"DIRECTION") { filter->SetColorScheme(MeshCreatorType::DIRECTION); }
107 if (_ColorScheme ==
"MAGNITUDE") { filter->SetColorScheme(MeshCreatorType::MAGNITUDE); }
110 if (_ShowProgressArg.isSet())
111 filter->AddObserver( itk::ProgressEvent(), observer );
112 if (_SingleThreadArg.isSet())
113 filter->SetNumberOfThreads(1);
114 filter->SetDebug(_DebugArg.isSet());
116 std::cout <<
"Generating mesh ... " << std::flush;
120 std::cout << clock.GetMean() <<
"s elapsed" << std::endl;
122 MeshCreatorType::OutputMeshPolyDataType* mesh = filter->GetOutput();
124 if (_OutputFileArg.isSet())
133 vtk::VisualizePolyData(mesh, _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)
int GetIndexSHj(const int l, const int m)
Compute mesh from SH coefficients.
void ReadVectorImage(const std::string &filename, SmartPointer< VectorImage< PixelType, 3 > > &image, const std::string &printInfo="Reading Image:")
int DimToRankSH(const int dimm)
SmartPointer< Self > Pointer
#define utlGlobalException(cond, expout)
int RankToDimSH(const int shRank)
void VisualizePolyData(vtkPolyData *mesh, 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})
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)
bool IsEndingWith(const std::string &fullString, const std::string &ending)
int main(int argc, char *argv[])
void WriteVtkPolyData(vtkPolyData *mesh, const std::string &filename)