From e02796f8ac9bd81c8ef36d97c6b9d8d09339b1bb Mon Sep 17 00:00:00 2001 From: Pierre Alliez Date: Mon, 24 Mar 2008 12:05:27 +0000 Subject: [PATCH] Surface reconstruction: a bit of cleanup of normal estimation + comment --- .../CGAL/estimate_normals_jet_fitting_3.h | 6 ++--- .../include/CGAL/estimate_normals_pca_3.h | 5 ++-- .../include/CGAL/estimate_normals_poles_3.h | 3 +++ .../include/CGAL/k_nearest_neighbor.h | 2 +- .../normal_estimation_test.cpp | 24 ++++++++++++------- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/Surface_reconstruction_3/include/CGAL/estimate_normals_jet_fitting_3.h b/Surface_reconstruction_3/include/CGAL/estimate_normals_jet_fitting_3.h index 06a814a1690..e2392687940 100644 --- a/Surface_reconstruction_3/include/CGAL/estimate_normals_jet_fitting_3.h +++ b/Surface_reconstruction_3/include/CGAL/estimate_normals_jet_fitting_3.h @@ -30,7 +30,6 @@ CGAL_BEGIN_NAMESPACE - /// Estimate normal direction using linear least /// squares fitting of a plane on the K nearest neighbors. /// @@ -47,7 +46,7 @@ estimate_normal_jet_fitting_3(const typename Kernel::Point_3& query, ///< 3D poi const unsigned int K, const unsigned int degre_fitting = 2) { - // Basic geometric types + // basic geometric types typedef typename Kernel::Point_3 Point; typedef typename Kernel::Vector_3 Vector; typedef OrientedNormal_3 Oriented_normal; @@ -109,7 +108,7 @@ estimate_normals_jet_fitting_3(InputIterator first, ///< input points const unsigned int degre_fitting = 2) { // Hard-code the Normal type as back_insert_iterator value_type is wrong (VC++ 2003) - //typedef typename std::iterator_traits::value_type Normal; + // typedef typename std::iterator_traits::value_type Normal; typedef CGAL::Oriented_normal_3 Normal; // types for K-nearest neighbor search structure @@ -158,7 +157,6 @@ estimate_normals_jet_fitting_3(InputIterator first, ///< input points estimate_normals_jet_fitting_3(first,beyond,normals,K,Kernel(),degre_fitting); } - CGAL_END_NAMESPACE #endif // CGAL_ESTIMATE_NORMALS_JET_FITTING_3_H diff --git a/Surface_reconstruction_3/include/CGAL/estimate_normals_pca_3.h b/Surface_reconstruction_3/include/CGAL/estimate_normals_pca_3.h index c2504c477f7..568cdbf8faf 100644 --- a/Surface_reconstruction_3/include/CGAL/estimate_normals_pca_3.h +++ b/Surface_reconstruction_3/include/CGAL/estimate_normals_pca_3.h @@ -30,7 +30,6 @@ CGAL_BEGIN_NAMESPACE - /// Estimate normal direction using linear least /// squares fitting of a plane on the K nearest neighbors. /// @@ -46,7 +45,7 @@ estimate_normal_pca_3(const typename Kernel::Point_3& query, ///< 3D point whose Tree& tree, ///< KD-tree const unsigned int K) { - // Basic geometric types + // basic geometric types typedef typename Kernel::Point_3 Point; typedef typename Kernel::Plane_3 Plane; typedef typename Kernel::Vector_3 Vector; @@ -102,7 +101,7 @@ estimate_normals_pca_3(InputIterator first, ///< input points const Kernel& kernel) { // Hard-code the Normal type as back_insert_iterator value_type is wrong (VC++ 2003) - //typedef typename std::iterator_traits::value_type Normal; + // typedef typename std::iterator_traits::value_type Normal; typedef CGAL::Oriented_normal_3 Normal; // types for K-nearest neighbor search structure diff --git a/Surface_reconstruction_3/include/CGAL/estimate_normals_poles_3.h b/Surface_reconstruction_3/include/CGAL/estimate_normals_poles_3.h index c2aeb12bc64..2081e0b1a2d 100644 --- a/Surface_reconstruction_3/include/CGAL/estimate_normals_poles_3.h +++ b/Surface_reconstruction_3/include/CGAL/estimate_normals_poles_3.h @@ -31,6 +31,9 @@ CGAL_BEGIN_NAMESPACE // triangulation, use the parameter otherwise (careful, 8 vertices // are added in order to bound all Voronoi cells. The last parameter // specifies if these points should be removed. + +// Pierre: I would suggest not to use pointers - simply the user +// can call the function without any reference to a DT. template < typename InputIterator, typename OutputIterator, typename Kernel, diff --git a/Surface_reconstruction_3/include/CGAL/k_nearest_neighbor.h b/Surface_reconstruction_3/include/CGAL/k_nearest_neighbor.h index 5188b63b42c..e08569fe23f 100644 --- a/Surface_reconstruction_3/include/CGAL/k_nearest_neighbor.h +++ b/Surface_reconstruction_3/include/CGAL/k_nearest_neighbor.h @@ -89,7 +89,7 @@ struct Construct_coord_iterator { // We have put the glue layer in this file as well, that is a class that // allows to iterate over the Cartesian coordinates of the KVertex, and a // class to construct such an iterator for a KVertex. -//We next need a distance class +// We next need a distance class template struct Distance { diff --git a/Surface_reconstruction_3/test/Surface_reconstruction_3/normal_estimation_test.cpp b/Surface_reconstruction_3/test/Surface_reconstruction_3/normal_estimation_test.cpp index 7d398f88c1c..f209f421b1d 100644 --- a/Surface_reconstruction_3/test/Surface_reconstruction_3/normal_estimation_test.cpp +++ b/Surface_reconstruction_3/test/Surface_reconstruction_3/normal_estimation_test.cpp @@ -1,5 +1,3 @@ -// poisson_reconstruction_test.cpp - #include // include basic.h before testing #defines // CGAL @@ -19,48 +17,59 @@ #include // types -typedef CGAL::Simple_cartesian Kernel; +typedef CGAL::Simple_cartesian Kernel; typedef Kernel::FT FT; typedef Kernel::Point_3 Point; typedef Kernel::Vector_3 Vector; typedef CGAL::Oriented_normal_3 Normal; -// read point from .xyz file +// read point set from .xyz file bool read_point_set(char *input_filename, std::list& points) { + std::cerr << " Open " << input_filename << " for reading..."; + std::ifstream stream(input_filename); if(!stream.is_open()) + { + std::cerr << "failed" << std::endl; return false; + } + + // read point set Point point; while(!stream.fail()) { stream >> point; points.push_back(point); } + std::cerr << "ok (" << points.size() << " points)" << std::endl; return true; } void test_pca(std::list& points, const unsigned int k) { + std::cerr << " Estimate normals using KNN and point-based PCA..."; std::list normals; CGAL::estimate_normals_pca_3(points.begin(),points.end(),std::back_inserter(normals),k); + std::cerr << "ok" << std::endl; } void test_jet_fitting(std::list& points, const unsigned int k) { + std::cerr << " Estimate normals using KNN and jet fitting..."; std::list normals; CGAL::estimate_normals_jet_fitting_3(points.begin(),points.end(),std::back_inserter(normals),k); + std::cerr << "ok" << std::endl; } // main function int main(int argc, char * argv[]) { - std::cerr << "NORMAL ESTIMATION" << std::endl; - std::cerr << "Test the normal estimation methods" << std::endl; + std::cerr << "Normal estimation test" << std::endl; if(argc < 2) { @@ -77,10 +86,9 @@ int main(int argc, { test_pca(points,k); test_jet_fitting(points,k); - std::cerr << "OK" << std::endl; } else - std::cerr << "Unable to open file " << argv[i] << std::endl; + std::cerr << " Unable to open file " << argv[i] << std::endl; } return EXIT_SUCCESS; }