1919#include " itkPointFeature.h"
2020#include " itkPointSet.h"
2121#include " itkTestingMacros.h"
22+ #include " itkMesh.h"
23+ #include " itkVector.h"
24+ #include " itkMeshFileReader.h"
25+
26+
27+ namespace
28+ {
29+ constexpr unsigned int Dimension = 3 ;
30+ using CoordType = double ;
31+ using VectorType = itk::Vector<CoordType, Dimension>;
32+ using MeshType = itk::Mesh<CoordType, Dimension, itk::DefaultStaticMeshTraits<VectorType, Dimension>>;
33+ constexpr unsigned numDebugPoints = 10 ;
34+
35+ MeshType::Pointer
36+ ReadMesh (std::string filename)
37+ {
38+ using ReaderType = itk::MeshFileReader<MeshType>;
39+ ReaderType::Pointer reader = ReaderType::New ();
40+ reader->SetFileName (filename);
41+ reader->Update ();
42+ MeshType::Pointer output = reader->GetOutput ();
43+ output->DisconnectPipeline ();
44+ return output;
45+ }
46+
47+ int
48+ BasicTests ()
49+ {
50+ using PixelType = float ;
51+ using PointSetType = itk::PointSet<PixelType, Dimension>;
52+
53+ using FilterType = itk::PointFeature<PointSetType, PointSetType>;
54+ FilterType::Pointer filter = FilterType::New ();
55+
56+ ITK_EXERCISE_BASIC_OBJECT_METHODS (filter, PointFeature, MeshToMeshFilter);
57+
58+ std::cout << " Basic tests finished." << std::endl;
59+
60+ return EXIT_SUCCESS;
61+ }
62+ } // namespace
2263
2364int
2465itkPointFeatureTest (int argc, char * argv[])
@@ -27,21 +68,56 @@ itkPointFeatureTest(int argc, char * argv[])
2768 {
2869 std::cerr << " Missing parameters." << std::endl;
2970 std::cerr << " Usage: " << itkNameOfTestExecutableMacro (argv);
30- std::cerr << " outputImage " ;
71+ std::cerr << " inputMesh " ;
3172 std::cerr << std::endl;
32- return EXIT_FAILURE;
73+ std::cout << " Running basic tests only." << std::endl;
74+ return BasicTests ();
3375 }
34- const char * outputImageFileName = argv[1 ];
3576
36- constexpr unsigned int Dimension = 3 ;
37- using PixelType = float ;
38- using PointSetType = itk::PointSet<PixelType, Dimension>;
77+ MeshType::Pointer points = ReadMesh (argv[1 ]);
78+ MeshType::Pointer normals = ReadMesh (argv[1 ]);
3979
40- using FilterType = itk::PointFeature<PointSetType, PointSetType> ;
41- FilterType::Pointer filter = FilterType::New ();
80+ MeshType::PointsContainerPointer normal_points = normals-> GetPoints () ;
81+ MeshType::PointsContainerIterator p_it = normal_points-> Begin ();
4282
43- ITK_EXERCISE_BASIC_OBJECT_METHODS (filter, PointFeature, MeshToMeshFilter);
83+ MeshType::PointDataContainerPointer normal_normals = normals->GetPointData ();
84+ MeshType::PointDataContainerIterator d_it = normal_normals->Begin ();
85+
86+ // Print first 10 points and normals for sanity check and debugging
87+ std::cout << " Index * Point * Normal (up to first 10)" << std::endl;
88+ unsigned i = 0 ;
89+ while (p_it != normal_points->End ())
90+ {
91+ if (i < numDebugPoints) // debug
92+ {
93+ std::cout << p_it.Index () << " * " ;
94+ std::cout << p_it.Value () << " * " ;
95+ std::cout << d_it.Value () << std::endl;
96+ }
97+
98+ for (unsigned d = 0 ; d < Dimension; ++d)
99+ {
100+ p_it.Value ()[d] = d_it.Value ()[d];
101+ }
102+
103+ ++p_it;
104+ ++d_it;
105+ ++i;
106+ }
107+
108+ // Code specific for this test
109+ using FilterType = itk::PointFeature<MeshType, MeshType>;
110+ FilterType::Pointer fpfh = FilterType::New ();
111+ fpfh->ComputeFPFHFeature (points, normals, 2.4219912533797725 , 100 );
112+ auto result = fpfh->GetFpfhFeature ();
113+ auto resultSTL = result->CastToSTLConstContainer ();
114+ for (i = 0 ; i < numDebugPoints; ++i)
115+ {
116+ std::cout << " FPFH Feature for point " << i << " :" ;
117+ for (unsigned k = 0 ; k < 33 ; ++k)
118+ std::cout << ' ' << resultSTL[i * 33 + k];
119+ std::cout << std::endl;
120+ }
44121
45- std::cout << " Test finished." << std::endl;
46122 return EXIT_SUCCESS;
47123}
0 commit comments