mirror of https://github.com/CGAL/cgal
Surface reconstruction: a bit of cleanup of normal estimation + comment
This commit is contained in:
parent
c6307bb753
commit
e02796f8ac
|
|
@ -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<OutputIterator>::value_type Normal;
|
||||
// typedef typename std::iterator_traits<OutputIterator>::value_type Normal;
|
||||
typedef CGAL::Oriented_normal_3<Kernel> 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
|
||||
|
|
|
|||
|
|
@ -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<OutputIterator>::value_type Normal;
|
||||
// typedef typename std::iterator_traits<OutputIterator>::value_type Normal;
|
||||
typedef CGAL::Oriented_normal_3<Kernel> Normal;
|
||||
|
||||
// types for K-nearest neighbor search structure
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 <class Vertex_handle>
|
||||
struct Distance {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
// poisson_reconstruction_test.cpp
|
||||
|
||||
#include <CGAL/basic.h> // include basic.h before testing #defines
|
||||
|
||||
// CGAL
|
||||
|
|
@ -19,48 +17,59 @@
|
|||
#include <iterator>
|
||||
|
||||
// types
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef CGAL::Simple_cartesian<float> Kernel;
|
||||
typedef Kernel::FT FT;
|
||||
typedef Kernel::Point_3 Point;
|
||||
typedef Kernel::Vector_3 Vector;
|
||||
typedef CGAL::Oriented_normal_3<Kernel> Normal;
|
||||
|
||||
// read point from .xyz file
|
||||
// read point set from .xyz file
|
||||
bool read_point_set(char *input_filename,
|
||||
std::list<Point>& 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<Point>& points,
|
||||
const unsigned int k)
|
||||
{
|
||||
std::cerr << " Estimate normals using KNN and point-based PCA...";
|
||||
std::list<Normal> 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<Point>& points,
|
||||
const unsigned int k)
|
||||
{
|
||||
std::cerr << " Estimate normals using KNN and jet fitting...";
|
||||
std::list<Normal> 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue