diff --git a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/Gyroviz_point_3.h b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/Gyroviz_point_3.h index 6f1442d4ebf..707fc4e4cf1 100644 --- a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/Gyroviz_point_3.h +++ b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/Gyroviz_point_3.h @@ -22,7 +22,7 @@ #include -#include +#include #include @@ -54,7 +54,7 @@ public: typedef typename CGAL::Oriented_normal_3 Normal; ///< Model of OrientedNormal_3 concept. /// Iterator over cameras - typedef typename std::vector::const_iterator Camera_const_iterator; + typedef typename std::set::const_iterator Camera_const_iterator; // Public methods public: @@ -81,7 +81,7 @@ public: InputIterator first_camera, InputIterator beyond_camera) : Base(point, CGAL::NULL_VECTOR) { - std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras)); + list_of_cameras.insert(first_camera, beyond_camera); } template < class InputIterator > Gyroviz_point_3(const Point_3& point, @@ -89,7 +89,7 @@ public: InputIterator first_camera, InputIterator beyond_camera) : Base(point, normal) { - std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras)); + list_of_cameras.insert(first_camera, beyond_camera); } // Default copy constructor and operator =() are fine @@ -104,21 +104,30 @@ public: return ! (*this == that); } - // Get/set cameras + // Get cameras + Camera_const_iterator cameras_begin() const { return list_of_cameras.begin(); } + Camera_const_iterator cameras_end () const { return list_of_cameras.end(); } + + // Set cameras template < class InputIterator > void set_cameras(InputIterator first_camera, InputIterator beyond_camera) { list_of_cameras.clear(); - std::copy(first_camera, beyond_camera, std::back_inserter(list_of_cameras)); + list_of_cameras.insert(first_camera, beyond_camera); + } + + // Add cameras + template < class InputIterator > + void add_cameras(InputIterator first_camera, InputIterator beyond_camera) + { + list_of_cameras.insert(first_camera, beyond_camera); } - Camera_const_iterator cameras_begin() const { return list_of_cameras.begin(); } - Camera_const_iterator cameras_end () const { return list_of_cameras.end(); } // Data private: // List of cameras - std::vector list_of_cameras; + std::set list_of_cameras; }; diff --git a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/RedirectIOToConsole.h b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/RedirectIOToConsole.h similarity index 100% rename from Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/RedirectIOToConsole.h rename to Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/RedirectIOToConsole.h diff --git a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/enriched_polyhedron.h b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/enriched_polyhedron.h index 02d75a302f8..bc5dca10186 100644 --- a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/enriched_polyhedron.h +++ b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/enriched_polyhedron.h @@ -135,11 +135,29 @@ private: typedef CGAL::Polyhedron_3 Base; + // Auxiliary class to build a triangles iterator + template // Node is Facet + struct Project_triangle { + typedef Node argument_type; + typedef typename PolyhedronTraits_3::Triangle_3 Triangle; + typedef Triangle result_type; + typedef CGAL::Arity_tag<1> Arity; + typedef typename PolyhedronTraits_3::Point_3 Point; + + Triangle operator()(const Node& f) const { + Halfedge_const_handle he = f.halfedge(); + const Point& a = he->vertex()->point(); + const Point& b = he->next()->vertex()->point(); + const Point& c = he->next()->next()->vertex()->point(); + return Triangle(a,b,c); + } + }; + // Public types public: - typedef typename PolyhedronTraits_3::FT FT; - typedef typename PolyhedronTraits_3::Point_3 Point; + typedef typename PolyhedronTraits_3::FT FT; + typedef typename PolyhedronTraits_3::Point_3 Point; // Repeat Polyhedron_3 public types typedef typename Base::HalfedgeDS HalfedgeDS; @@ -165,6 +183,10 @@ public: typedef typename Base::Halfedge_around_vertex_circulator Halfedge_around_vertex_circulator; typedef typename Base::Halfedge_around_vertex_const_circulator Halfedge_around_vertex_const_circulator; + // Iterator over triangles + typedef CGAL::Iterator_project > + Triangle_const_iterator; + public : // Default constructor, copy constructor and operator =() are fine. @@ -177,6 +199,10 @@ public : Base::vertices_begin; Base::vertices_end; + // Get first/last iterators over triangles. + Triangle_const_iterator triangles_begin() const { return Triangle_const_iterator(facets_begin()); } + Triangle_const_iterator triangles_end() const { return Triangle_const_iterator(facets_end()); } + // Compute normals using mesh connectivity (per facet, then per vertex) void compute_normals_per_facet() { diff --git a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/surface_reconstruction_read_pwc.h b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/surface_reconstruction_read_pwc.h index ef89f6c5ffa..69896f827d1 100644 --- a/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/surface_reconstruction_read_pwc.h +++ b/Surface_reconstruction_3/demo/Surface_reconstruction_3/poisson/include/surface_reconstruction_read_pwc.h @@ -28,7 +28,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename, FILE *pFile = fopen(pFilename,"rt"); if(pFile == NULL) { - std::cerr << "Error: cannot open " << pFilename; + std::cerr << "Error: cannot open " << pFilename << std::endl; return false; } @@ -52,7 +52,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename, if ( (sscanf(pLine,"%s",signature) != 1) || (strcmp(signature, "CamOFF") != 0) ) { // if unsupported file format - std::cerr << "Incorrect file format line " << lineNumber << " of " << pFilename; + std::cerr << "Incorrect file format line " << lineNumber << " of " << pFilename << std::endl; return false; } } @@ -62,7 +62,7 @@ bool surface_reconstruction_read_pwc(const char* pFilename, { if (sscanf(pLine,"%ld %ld",&camCount,&pointsCount) != 2) { - std::cerr << "Error line " << lineNumber << " of " << pFilename; + std::cerr << "Error line " << lineNumber << " of " << pFilename << std::endl; return false; } } @@ -107,6 +107,10 @@ bool surface_reconstruction_read_pwc(const char* pFilename, list_of_cameras.begin(), list_of_cameras.end()); gyroviz_point_output++; } + else + { + //std::cerr << "Skip (" << position << ") line " << lineNumber << " of " << pFilename << std::endl; + } } // ...or skip comment line } diff --git a/Surface_reconstruction_3/include/CGAL/Point_with_normal_3.h b/Surface_reconstruction_3/include/CGAL/Point_with_normal_3.h index 98c98b93843..10d4dac7f0f 100644 --- a/Surface_reconstruction_3/include/CGAL/Point_with_normal_3.h +++ b/Surface_reconstruction_3/include/CGAL/Point_with_normal_3.h @@ -79,7 +79,7 @@ public: /// Compare positions bool operator==(const Point_with_normal_3& that) { - return Base::operator==(that); + return ((Base&)(*this) == (Base&)that); } bool operator!=(const Point_with_normal_3& that) { diff --git a/Surface_reconstruction_3/include/CGAL/merge_epsilon_nearest_points_3.h b/Surface_reconstruction_3/include/CGAL/merge_epsilon_nearest_points_3.h index d98f594afb0..34b9e45f8df 100644 --- a/Surface_reconstruction_3/include/CGAL/merge_epsilon_nearest_points_3.h +++ b/Surface_reconstruction_3/include/CGAL/merge_epsilon_nearest_points_3.h @@ -112,8 +112,8 @@ merge_epsilon_nearest_points_3( InputIterator first, ///< input points InputIterator beyond, OutputIterator output, ///< output points - const Kernel& /*kernel*/, - double epsilon) ///< tolerance value when comparing 3D points + double epsilon, ///< tolerance value when comparing 3D points + const Kernel& /*kernel*/) { typedef typename Kernel::Point_3 Point; @@ -123,7 +123,7 @@ merge_epsilon_nearest_points_3( CGAL_precondition(epsilon > 0); // Merge points which belong to the same cell of a grid of cell size = epsilon. - Epsilon_point_set_3 merged_points(epsilon); + Epsilon_point_set_3 merged_points(epsilon); merged_points.insert(first, beyond); // Copy merged points to output @@ -147,8 +147,9 @@ void merge_epsilon_nearest_points_3( ForwardIterator first, ///< input/output points ForwardIterator beyond, - const Kernel& /*kernel*/, - double epsilon) ///< tolerance value when comparing 3D points + double epsilon, ///< tolerance value when comparing 3D points + const Kernel& /*kernel*/) + { CGAL_precondition(false); // nyi } @@ -175,7 +176,7 @@ merge_epsilon_nearest_points_3( { typedef typename std::iterator_traits::value_type Value_type; typedef typename Kernel_traits::Kernel Kernel; - return merge_epsilon_nearest_points_3(first,beyond,output,Kernel(),epsilon); + return merge_epsilon_nearest_points_3(first,beyond,output,epsilon,Kernel()); } /// Merge points which belong to the same cell of a grid of cell size = epsilon. @@ -195,7 +196,7 @@ merge_epsilon_nearest_points_3( { typedef typename std::iterator_traits::value_type Value_type; typedef typename Kernel_traits::Kernel Kernel; - merge_epsilon_nearest_points_3(first,beyond,Kernel(),epsilon); + merge_epsilon_nearest_points_3(first,beyond,epsilon,Kernel()); }