diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h index f4eb6980549..bf369321af4 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polygon_mesh.h @@ -46,16 +46,21 @@ struct Tracer_polyhedron int i, int k, bool last = true) { - if(i + 1 == k) { return P[i+1]; } + if(i + 1 == k) + return P[i+1]; halfedge_descriptor h, g; - if(i+2 == k){ + if(i+2 == k) + { if(last) - { - h = P[i+1]; - Euler::fill_hole(h,pmesh); } + { + h = P[i + 1]; + Euler::fill_hole(h, pmesh); + } else - { h = Euler::add_face_to_border(prev(P[i+1],pmesh), P[i+2/*k*/], pmesh); } + { + h = Euler::add_face_to_border(prev(P[i + 1], pmesh), P[i + 2 /*k*/], pmesh); + } CGAL_assertion(face(h,pmesh) != boost::graph_traits::null_face()); *out++ = face(h,pmesh); @@ -68,12 +73,14 @@ struct Tracer_polyhedron g = operator()(lambda, la, k, false); if(last) - { - h = g; - Euler::fill_hole(g,pmesh); - } + { + h = g; + Euler::fill_hole(g, pmesh); + } else - { h = Euler::add_face_to_border(prev(h,pmesh), g, pmesh); } + { + h = Euler::add_face_to_border(prev(h, pmesh), g, pmesh); + } CGAL_assertion(face(h,pmesh) != boost::graph_traits::null_face()); *out++ = face(h,pmesh); @@ -106,28 +113,29 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, typedef std::map Vertex_map; typedef typename Vertex_map::iterator Vertex_map_it; - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG CGAL::Timer timer; timer.start(); - #endif +#endif - std::vector P, Q; + std::vector P, Q; std::vector P_edges; Vertex_map vertex_map; int id = 0; Hedge_around_face_circulator circ(border_halfedge,pmesh), done(circ); - do{ + do + { P.push_back(get(vpmap, target(*circ, pmesh))); Q.push_back(get(vpmap, target(next(opposite(next(*circ,pmesh),pmesh),pmesh),pmesh))); P_edges.push_back(*circ); - if(!vertex_map.insert(std::make_pair(target(*circ,pmesh), id++)).second) { - #ifndef CGAL_TEST_SUITE + if(!vertex_map.insert(std::make_pair(target(*circ,pmesh), id++)).second) + { +#ifndef CGAL_TEST_SUITE CGAL_warning_msg(false, "Returning no output. Non-manifold vertex is found on boundary!"); - #else +#else std::cerr << "W: Returning no output. Non-manifold vertex is found on boundary!\n"; - #endif - return std::make_pair(out, - CGAL::internal::Weight_min_max_dihedral_and_area::NOT_VALID()); +#endif + return std::make_pair(out, CGAL::internal::Weight_min_max_dihedral_and_area::NOT_VALID()); } } while (++circ != done); @@ -151,52 +159,52 @@ triangulate_hole_polygon_mesh(PolygonMesh& pmesh, if(v_it_neigh_it != vertex_map.end()) //other endpoint found in the map { int v_it_neigh_id = v_it_neigh_it->second; - if( v_it_neigh_id != v_it_prev && v_it_neigh_id != v_it_next ) - { //there is an edge incident to v_it, which is not next or previous + if(v_it_neigh_id != v_it_prev && v_it_neigh_id != v_it_next) + { + //there is an edge incident to v_it, which is not next or previous //from vertex_map (checked by comparing IDs) if(v_it_id < v_it_neigh_id) // to include each edge only once - { existing_edges.push_back(std::make_pair(v_it_id, v_it_neigh_id)); } + existing_edges.push_back(std::make_pair(v_it_id, v_it_neigh_id)); } } } while(++circ_vertex != done_vertex); } - //#define CGAL_USE_WEIGHT_INCOMPLETE - #ifdef CGAL_USE_WEIGHT_INCOMPLETE +//#define CGAL_USE_WEIGHT_INCOMPLETE +#ifdef CGAL_USE_WEIGHT_INCOMPLETE typedef CGAL::internal::Weight_calculator, CGAL::internal::Is_valid_existing_edges_and_degenerate_triangle> WC; - #else +#else typedef CGAL::internal::Weight_calculator WC; - #endif +#endif CGAL::internal::Is_valid_existing_edges_and_degenerate_triangle is_valid(existing_edges); // fill hole using polyline function, with custom tracer for PolygonMesh - Tracer_polyhedron - tracer(out, pmesh, P_edges); + Tracer_polyhedron tracer(out, pmesh, P_edges); #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_CDT2 - if(use_cdt && triangulate_hole_polyline_with_cdt(P, tracer, is_valid, k, max_squared_distance)) - { - return std::make_pair(tracer.out, CGAL::internal::Weight_min_max_dihedral_and_area(0,0)); - } + if(use_cdt && triangulate_hole_polyline_with_cdt(P, tracer, is_valid, k, max_squared_distance)) + return std::make_pair(tracer.out, CGAL::internal::Weight_min_max_dihedral_and_area(0,0)); #endif CGAL::internal::Weight_min_max_dihedral_and_area weight = - triangulate_hole_polyline(P, Q, tracer, WC(is_valid), - use_delaunay_triangulation, k) -#ifdef CGAL_USE_WEIGHT_INCOMPLETE - .weight // get actual weight in Weight_incomplete +#ifndef CGAL_USE_WEIGHT_INCOMPLETE + triangulate_hole_polyline(P, Q, tracer, WC(is_valid), use_delaunay_triangulation, k); +#else + // get actual weight in Weight_incomplete + triangulate_hole_polyline(P, Q, tracer, WC(is_valid), use_delaunay_triangulation, k).weight; #endif - ; - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG std::cerr << "Hole filling: " << timer.time() << " sc." << std::endl; timer.reset(); - #endif +#endif + return std::make_pair(tracer.out, weight); } -}// namespace internal -}// namespace Polygon_mesh_processing -}// namespace CGAL +} // namespace internal +} // namespace Polygon_mesh_processing +} // namespace CGAL + #endif //CGAL_HOLE_FILLING_TRIANGULATE_HOLE_POLYHEDRON_3_H diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h index 5eab37058cd..403494666ce 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/Hole_filling/Triangulate_hole_polyline.h @@ -1492,11 +1492,11 @@ triangulate_hole_polyline(const PointRange1& points, typedef Kernel K; typedef typename K::Point_3 Point_3; - #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 typedef CGAL::internal::Triangulate_hole_polyline_DT Fill_DT; - #else +#else CGAL_USE(use_delaunay_triangulation); - #endif +#endif typedef CGAL::internal::Triangulate_hole_polyline Fill; std::vector P(boost::begin(points), boost::end(points)); @@ -1510,20 +1510,19 @@ triangulate_hole_polyline(const PointRange1& points, } typename WeightCalculator::Weight w = - #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 +#ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 use_delaunay_triangulation ? Fill_DT().operator()(P,Q,tracer,WC) : - #endif +#endif Fill().operator()(P,Q,tracer,WC); #ifndef CGAL_HOLE_FILLING_DO_NOT_USE_DT3 - if (use_delaunay_triangulation - && w == WeightCalculator::Weight::NOT_VALID()) + if(use_delaunay_triangulation && w == WeightCalculator::Weight::NOT_VALID()) w = Fill().operator()(P, Q, tracer, WC); #endif - #ifdef CGAL_PMP_HOLE_FILLING_DEBUG +#ifdef CGAL_PMP_HOLE_FILLING_DEBUG std::cerr << w << std::endl; - #endif +#endif return w; }