From e499208f5c159b39b6cc50f94476f706bc8e3a55 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 13 Nov 2017 15:27:07 +0100 Subject: [PATCH 01/32] add missing namespace --- Mesh_2/doc/Mesh_2/CGAL/lloyd_optimize_mesh_2.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Mesh_2/doc/Mesh_2/CGAL/lloyd_optimize_mesh_2.h b/Mesh_2/doc/Mesh_2/CGAL/lloyd_optimize_mesh_2.h index 329d0b12b5b..e9cbce4e5d5 100644 --- a/Mesh_2/doc/Mesh_2/CGAL/lloyd_optimize_mesh_2.h +++ b/Mesh_2/doc/Mesh_2/CGAL/lloyd_optimize_mesh_2.h @@ -101,13 +101,13 @@ lloyd_optimize_mesh_2(cdt, \endcode -\sa `Mesh_optimization_return_code` +\sa `CGAL::Mesh_optimization_return_code` \sa `CGAL::refine_Delaunay_mesh_2()` */ template -Mesh_optimization_return_code +CGAL::Mesh_optimization_return_code lloyd_optimize_mesh_2(CDT& cdt, double parameters::time_limit=0, std::size_t parameters::max_iteration_number=0, From e888bd46c17d7b5a4126102e275aad8bb8567e70 Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 13 Nov 2017 15:31:36 +0100 Subject: [PATCH 02/32] the convergence criterion does not need to check "is_in_domain" for incident faces anyway we do not compute the criterion for constrained vertices, nor for non-moving vertices --- Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h b/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h index 0e3636bde84..43d2f09438a 100644 --- a/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h +++ b/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h @@ -307,8 +307,7 @@ private: // Find the minimum value do { - if(face->is_in_domain()) - min_sqr = (std::min)(min_sqr, sq_circumradius(face)); + min_sqr = (std::min)(min_sqr, sq_circumradius(face)); face++; } while(face != end); From 029888f85cd7f9e5a08ceeb71745556e11a386b3 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 23 Nov 2017 15:50:26 +0000 Subject: [PATCH 03/32] Derecursify insert_constraint(Vhandle,Vhandle); Increment depth of propagating_flip() --- .../Constrained_Delaunay_triangulation_2.h | 4 +- .../CGAL/Constrained_triangulation_2.h | 72 ++++++++++--------- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h index 68bace7904d..38af351057b 100644 --- a/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_Delaunay_triangulation_2.h @@ -742,9 +742,9 @@ propagating_flip(Face_handle f,int i, int depth) Face_handle ni = f->neighbor(i); flip(f, i); // flip for constrained triangulations - propagating_flip(f,i); + propagating_flip(f,i, depth+1); i = ni->index(f->vertex(i)); - propagating_flip(ni,i); + propagating_flip(ni,i, depth+1); #endif } #else diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h index 6ce163f6537..aef4f476081 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_2.h @@ -649,45 +649,53 @@ insert_constraint(Vertex_handle vaa, Vertex_handle vbb) // if a vertex vc of t lies on segment ab // or if ab intersect some constrained edges { - CGAL_triangulation_precondition( vaa != vbb); - Vertex_handle vi; + std::stack > stack; + stack.push(std::make_pair(vaa,vbb)); - Face_handle fr; - int i; - if(includes_edge(vaa,vbb,vi,fr,i)) { - mark_constraint(fr,i); - if (vi != vbb) { - insert_constraint(vi,vbb); + while(! stack.empty()){ + boost::tie(vaa,vbb) = stack.top(); + stack.pop(); + CGAL_triangulation_precondition( vaa != vbb); + Vertex_handle vi; + + Face_handle fr; + int i; + if(includes_edge(vaa,vbb,vi,fr,i)) { + mark_constraint(fr,i); + if (vi != vbb) { + stack.push(std::make_pair(vi,vbb)); + } + continue; } - return; - } - List_faces intersected_faces; - List_edges conflict_boundary_ab, conflict_boundary_ba; + List_faces intersected_faces; + List_edges conflict_boundary_ab, conflict_boundary_ba; - bool intersection = find_intersected_faces( vaa, vbb, - intersected_faces, - conflict_boundary_ab, - conflict_boundary_ba, - vi); - if ( intersection) { - if (vi != vaa && vi != vbb) { - insert_constraint(vaa,vi); - insert_constraint(vi,vbb); - } - else insert_constraint(vaa,vbb); - return; - } + bool intersection = find_intersected_faces( vaa, vbb, + intersected_faces, + conflict_boundary_ab, + conflict_boundary_ba, + vi); + if ( intersection) { + if (vi != vaa && vi != vbb) { + stack.push(std::make_pair(vaa,vi)); + stack.push(std::make_pair(vi,vbb)); + } + else{ + stack.push(std::make_pair(vaa,vbb)); + } + continue; + } - //no intersection - triangulate_hole(intersected_faces, - conflict_boundary_ab, - conflict_boundary_ba); + //no intersection + triangulate_hole(intersected_faces, + conflict_boundary_ab, + conflict_boundary_ba); - if (vi != vbb) { - insert_constraint(vi,vbb); + if (vi != vbb) { + stack.push(std::make_pair(vi,vbb)); + } } - return; } From 62b9e59fa142dd037be50cb001de4d48b445607f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 28 Nov 2017 15:12:41 +0000 Subject: [PATCH 04/32] Derecursify in Constrained_triangulation_plus_2 --- .../CGAL/Constrained_triangulation_plus_2.h | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index e6eb522d219..01db6cde134 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -773,7 +773,14 @@ insert_subconstraint(Vertex_handle vaa, // insert the subconstraint [vaa vbb] // it will eventually be splitted into several subconstraints { - CGAL_triangulation_precondition( vaa != vbb); + std::stack > stack; + stack.push(std::make_pair(vaa,vbb)); + + while(! stack.empty()){ + boost::tie(vaa,vbb) = stack.top(); + stack.pop(); + CGAL_triangulation_precondition( vaa != vbb); + Vertex_handle vi; Face_handle fr; @@ -782,7 +789,7 @@ insert_subconstraint(Vertex_handle vaa, this->mark_constraint(fr,i); if (vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); - insert_subconstraint(vi,vbb, out); + stack.push(std::make_pair(vi,vbb)); } return; } @@ -800,10 +807,10 @@ insert_subconstraint(Vertex_handle vaa, if ( intersection) { if (vi != vaa && vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); - insert_subconstraint(vaa,vi, out); - insert_subconstraint(vi,vbb, out); + stack.push(std::make_pair(vaa,vi)); + stack.push(std::make_pair(vi,vbb)); } - else insert_subconstraint(vaa,vbb,out); + else stack.push(std::make_pair(vaa,vbb)); return; @@ -846,9 +853,9 @@ insert_subconstraint(Vertex_handle vaa, if (vi != vbb) { hierarchy.split_constraint(vaa,vbb,vi); - insert_subconstraint(vi,vbb, out); + stack.push(std::make_pair(vi,vbb)); + } } - return; } From 3572246411e36584dbdf08b5b6b04de7dcaec6df Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 29 Nov 2017 07:20:42 +0000 Subject: [PATCH 05/32] fix the derucursification --- .../include/CGAL/Constrained_triangulation_plus_2.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 01db6cde134..148a801637c 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -791,7 +791,7 @@ insert_subconstraint(Vertex_handle vaa, hierarchy.split_constraint(vaa,vbb,vi); stack.push(std::make_pair(vi,vbb)); } - return; + continue; } List_faces intersected_faces; @@ -812,8 +812,7 @@ insert_subconstraint(Vertex_handle vaa, } else stack.push(std::make_pair(vaa,vbb)); - - return; + continue; } From 9a9bfa78a19a35bbb614736394f1dba1f49c6444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 4 Dec 2017 14:57:45 +0100 Subject: [PATCH 06/32] use readable property map API --- Ridges_3/include/CGAL/Ridges.h | 84 ++++++++++++++++---------------- Ridges_3/include/CGAL/Umbilics.h | 14 +++--- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/Ridges_3/include/CGAL/Ridges.h b/Ridges_3/include/CGAL/Ridges.h index 1c46784ba3b..c886b17f305 100644 --- a/Ridges_3/include/CGAL/Ridges.h +++ b/Ridges_3/include/CGAL/Ridges.h @@ -501,7 +501,7 @@ facet_ridge_type(const face_descriptor f, halfedge_descriptor& he1, halfedge_des //check for regular facet //i.e. if there is a coherent orientation of ppal dir at the facet vertices - if ( d1[v1]*d1[v2] * d1[v1]*d1[v3] * d1[v2]*d1[v3] < 0 ) + if ( get(d1,v1)*get(d1,v2) * get(d1,v1)*get(d1,v3) * get(d1,v2)*get(d1,v3) < 0 ) return NO_RIDGE; //determine potential crest color @@ -510,11 +510,11 @@ facet_ridge_type(const face_descriptor f, halfedge_descriptor& he1, halfedge_des Ridge_type crest_color = NO_RIDGE; if (r_type == CREST_RIDGE) { - if ( CGAL::abs(k1[v1]+k1[v2]+k1[v3]) > CGAL::abs(k2[v1]+k2[v2]+k2[v3]) ) + if ( CGAL::abs(get(k1,v1)+get(k1,v2)+get(k1,v3)) > CGAL::abs(get(k2, v1)+get(k2,v2)+get(k2,v3)) ) crest_color = MAX_CREST_RIDGE; - if ( CGAL::abs(k1[v1]+k1[v2]+k1[v3]) < CGAL::abs(k2[v1]+k2[v2]+k2[v3]) ) + if ( CGAL::abs(get(k1,v1)+get(k1,v2)+get(k1,v3)) < CGAL::abs(get(k2,v1)+get(k2,v2)+get(k2,v3)) ) crest_color = MIN_CREST_RIDGE; - if ( CGAL::abs(k1[v1]+k1[v2]+k1[v3]) == CGAL::abs(k2[v1]+k2[v2]+k2[v3]) ) + if ( CGAL::abs(get(k1,v1)+get(k1,v2)+get(k1,v3)) == CGAL::abs(get(k2,v1)+get(k2,v2)+get(k2,v3)) ) return NO_RIDGE; } @@ -586,15 +586,15 @@ xing_on_edge(const halfedge_descriptor he, bool& is_crossed, Ridge_interrogation is_crossed = false; FT sign = 0; FT b_p, b_q; // extremalities at p and q for he: p->q - Vector_3 d_p = d1[target(opposite(he,P),P)], - d_q = d1[target(he,P)]; //ppal dir + Vector_3 d_p = get(d1,target(opposite(he,P),P)), + d_q = get(d1,target(he,P)); //ppal dir if ( color == MAX_RIDGE ) { - b_p = b0[target(opposite(he,P),P)]; - b_q = b0[target(he,P)]; + b_p = get(b0,target(opposite(he,P),P)); + b_q = get(b0,target(he,P)); } else { - b_p = b3[target(opposite(he,P),P)]; - b_q = b3[target(he,P)]; + b_p = get(b3,target(opposite(he,P),P)); + b_q = get(b3,target(he,P)); } if ( b_p == 0 && b_q == 0 ) return; if ( b_p == 0 && b_q !=0 ) sign = d_p*d_q * b_q; @@ -619,13 +619,13 @@ tag_as_elliptic_hyperbolic(const Ridge_interrogation_type color, FT coord1, coord2; if (color == MAX_RIDGE) { - coord1 = CGAL::abs(b0[v_q1]) / ( CGAL::abs(b0[v_p1]) + CGAL::abs(b0[v_q1]) ); - coord2 = CGAL::abs(b0[v_q2]) / ( CGAL::abs(b0[v_p2]) + CGAL::abs(b0[v_q2]) ); + coord1 = CGAL::abs(get(b0,v_q1)) / ( CGAL::abs(get(b0,v_p1)) + CGAL::abs(get(b0,v_q1)) ); + coord2 = CGAL::abs(get(b0,v_q2)) / ( CGAL::abs(get(b0,v_p2)) + CGAL::abs(get(b0,v_q2)) ); } else { - coord1 = CGAL::abs(b3[v_q1]) / ( CGAL::abs(b3[v_p1]) + CGAL::abs(b3[v_q1]) ); - coord2 = CGAL::abs(b3[v_q2]) / ( CGAL::abs(b3[v_p2]) + CGAL::abs(b3[v_q2]) ); + coord1 = CGAL::abs(get(b3,v_q1)) / ( CGAL::abs(get(b3,v_p1)) + CGAL::abs(get(b3,v_q1)) ); + coord2 = CGAL::abs(get(b3,v_q2)) / ( CGAL::abs(get(b3,v_p2)) + CGAL::abs(get(b3,v_q2)) ); } if ( tag_order == Ridge_order_3 ) { @@ -648,10 +648,10 @@ tag_as_elliptic_hyperbolic(const Ridge_interrogation_type color, // of Pi at the two crossing points FT sign_P; if (color == MAX_RIDGE) - sign_P = P1[v_p1]*coord1 + P1[v_q1]*(1-coord1) - + P1[v_p2]*coord2 + P1[v_q2]*(1-coord2); - else sign_P = P2[v_p1]*coord1 + P2[v_q1]*(1-coord1) - + P2[v_p2]*coord2 + P2[v_q2]*(1-coord2); + sign_P = get(P1,v_p1)*coord1 + get(P1,v_q1)*(1-coord1) + + get(P1,v_p2)*coord2 + get(P1,v_q2)*(1-coord2); + else sign_P = get(P2,v_p1)*coord1 + get(P2,v_q1)*(1-coord1) + + get(P2,v_p2)*coord2 + get(P2,v_q2)*(1-coord2); if ( sign_P < 0 ) return true; else return false; } @@ -671,20 +671,20 @@ b_sign_pointing_to_ridge(const vertex_descriptor v1, Vector_3 r = r2 - r1, dv1, dv2, dv3; FT bv1, bv2, bv3; if ( color == MAX_RIDGE ) { - bv1 = b0[v1]; - bv2 = b0[v2]; - bv3 = b0[v3]; - dv1 = d1[v1]; - dv2 = d1[v2]; - dv3 = d1[v3]; + bv1 = get(b0,v1); + bv2 = get(b0,v2); + bv3 = get(b0,v3); + dv1 = get(d1,v1); + dv2 = get(d1,v2); + dv3 = get(d1,v3); } else { - bv1 = b3[v1]; - bv2 = b3[v2]; - bv3 = b3[v3]; - dv1 = d2[v1]; - dv2 = d2[v2]; - dv3 = d2[v3]; + bv1 = get(b3,v1); + bv2 = get(b3,v2); + bv3 = get(b3,v3); + dv1 = get(d2,v1); + dv2 = get(d2,v2); + dv3 = get(d2,v3); } if ( r != CGAL::NULL_VECTOR ) r = r/CGAL::sqrt(r*r); FT sign1, sign2, sign3; @@ -734,8 +734,8 @@ addback(Ridge_line* ridge_line, const halfedge_descriptor he, FT k1x, k2x; //abs value of the ppal curvatures at the Xing point on he. FT k_second = 0; // abs value of the second derivative of the curvature // along the line of curvature - k1x = CGAL::abs(k1[v_p]) * coord + CGAL::abs(k1[v_q]) * (1-coord) ; - k2x = CGAL::abs(k2[v_p]) * coord + CGAL::abs(k2[v_q]) * (1-coord) ; + k1x = CGAL::abs(get(k1,v_p)) * coord + CGAL::abs(get(k1,v_q)) * (1-coord) ; + k2x = CGAL::abs(get(k2,v_p)) * coord + CGAL::abs(get(k2,v_q)) * (1-coord) ; if ( (ridge_line->line_type() == MAX_ELLIPTIC_RIDGE) || (ridge_line->line_type() == MAX_HYPERBOLIC_RIDGE) @@ -743,7 +743,7 @@ addback(Ridge_line* ridge_line, const halfedge_descriptor he, ridge_line->strength() += k1x * CGAL::sqrt(segment * segment); if (tag_order == Ridge_order_4) { if (k1x != k2x) - k_second =CGAL::abs(( CGAL::abs(P1[v_p]) * coord + CGAL::abs(P1[v_q]) * (1-coord) )/(k1x-k2x)); + k_second =CGAL::abs(( CGAL::abs(get(P1,v_p)) * coord + CGAL::abs(get(P1,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } if ( (ridge_line->line_type() == MIN_ELLIPTIC_RIDGE) @@ -752,7 +752,7 @@ addback(Ridge_line* ridge_line, const halfedge_descriptor he, ridge_line->strength() += k2x * CGAL::sqrt(segment * segment); if (tag_order == Ridge_order_4) { if (k1x != k2x) - k_second =CGAL::abs(( CGAL::abs(P2[v_p]) * coord + CGAL::abs(P2[v_q]) * (1-coord) )/(k1x-k2x)); + k_second =CGAL::abs(( CGAL::abs(get(P2,v_p)) * coord + CGAL::abs(get(P2,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } ridge_line->line()->push_back( Ridge_halfhedge(he, coord)); @@ -778,8 +778,8 @@ addfront(Ridge_line* ridge_line, FT k1x, k2x; //abs value of the ppal curvatures at the Xing point on he. FT k_second = 0.; // abs value of the second derivative of the curvature // along the line of curvature - k1x = CGAL::abs(k1[v_p]) * coord + CGAL::abs(k1[v_q]) * (1-coord) ; - k2x = CGAL::abs(k2[v_p]) * coord + CGAL::abs(k2[v_q]) * (1-coord) ; + k1x = CGAL::abs(get(k1,v_p)) * coord + CGAL::abs(get(k1,v_q)) * (1-coord) ; + k2x = CGAL::abs(get(k2,v_p)) * coord + CGAL::abs(get(k2,v_q)) * (1-coord) ; if ( (ridge_line->line_type() == MAX_ELLIPTIC_RIDGE) || (ridge_line->line_type() == MAX_HYPERBOLIC_RIDGE) @@ -787,7 +787,7 @@ addfront(Ridge_line* ridge_line, ridge_line->strength() += k1x * CGAL::sqrt(segment * segment); if (tag_order == Ridge_order_4) { if (k1x != k2x) - k_second =CGAL::abs(( CGAL::abs(P1[v_p]) * coord + CGAL::abs(P1[v_q]) * (1-coord) )/(k1x-k2x)); + k_second =CGAL::abs(( CGAL::abs(get(P1,v_p)) * coord + CGAL::abs(get(P1,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } if ( (ridge_line->line_type() == MIN_ELLIPTIC_RIDGE) @@ -796,7 +796,7 @@ addfront(Ridge_line* ridge_line, ridge_line->strength() += k2x * CGAL::sqrt(segment * segment); if (tag_order == Ridge_order_4) { if (k1x != k2x) - k_second =CGAL::abs(( CGAL::abs(P2[v_p]) * coord + CGAL::abs(P2[v_q]) * (1-coord) )/(k1x-k2x)); + k_second =CGAL::abs(( CGAL::abs(get(P2,v_p)) * coord + CGAL::abs(get(P2,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } ridge_line->line()->push_front( Ridge_halfhedge(he, coord)); @@ -814,14 +814,14 @@ bary_coord(const halfedge_descriptor he, const Ridge_type r_type) if ( (r_type == MAX_ELLIPTIC_RIDGE) || (r_type == MAX_HYPERBOLIC_RIDGE) || (r_type == MAX_CREST_RIDGE) ) { - b_p = b0[target(opposite(he,P),P)]; - b_q = b0[target(he,P)]; + b_p = get(b0,target(opposite(he,P),P)); + b_q = get(b0,target(he,P)); } if ( (r_type == MIN_ELLIPTIC_RIDGE) || (r_type == MIN_HYPERBOLIC_RIDGE) || (r_type == MIN_CREST_RIDGE) ) { - b_p = b3[target(opposite(he,P),P)]; - b_q = b3[target(he,P)]; + b_p = get(b3,target(opposite(he,P),P)); + b_q = get(b3,target(he,P)); } //denominator cannot be 0 since there is no crossing when both extremalities are 0 return CGAL::abs(b_q) / ( CGAL::abs(b_q) + CGAL::abs(b_p) ); diff --git a/Ridges_3/include/CGAL/Umbilics.h b/Ridges_3/include/CGAL/Umbilics.h index 8b87af0a2de..57ecfbf27be 100644 --- a/Ridges_3/include/CGAL/Umbilics.h +++ b/Ridges_3/include/CGAL/Umbilics.h @@ -193,7 +193,7 @@ compute(OutputIterator umbilics_it, FT size) boost::tie(itb,ite) = vertices(P); for (;itb != ite; itb++) { vertex_descriptor vh = *itb; - umbilicEstimatorVertex = cgal_abs(k1[vh]-k2[vh]); + umbilicEstimatorVertex = cgal_abs(get(k1,vh)-get(k2,vh)); //reset vector, list and bool vces.clear(); contour.clear(); @@ -217,7 +217,7 @@ compute(OutputIterator umbilics_it, FT size) itev = vces.end(); itbv++; for (; itbv != itev; itbv++) - { umbilicEstimatorNeigh = cgal_abs( k1[*itbv] - k2[*itbv] ); + { umbilicEstimatorNeigh = cgal_abs( get(k1,*itbv) - get(k2,*itbv) ); if ( umbilicEstimatorNeigh < umbilicEstimatorVertex ) {is_umbilic = false; break;} } @@ -244,14 +244,14 @@ compute_type(Umbilic& umb) itlast = --umb.contour_list().end(); v = target(*itb, P); - dir = d1[v]; - normal = CGAL::cross_product(d1[v], d2[v]); + dir = get(d1,v); + normal = CGAL::cross_product(get(d1,v), get(d2,v)); //sum angles along the contour do{ itb++; v = target(*itb, P); - dirnext = d1[v]; + dirnext = get(d1,v); cosinus = To_double(dir*dirnext); if (cosinus < 0) {dirnext = dirnext*(-1); cosinus *= -1;} if (cosinus>1) cosinus = 1; @@ -260,13 +260,13 @@ compute_type(Umbilic& umb) else angle = -acos(cosinus); angleSum += angle; dir = dirnext; - normal = CGAL::cross_product(d1[v], d2[v]); + normal = CGAL::cross_product(get(d1,v), get(d2,v)); } while (itb != (itlast)); //angle (v_last, v_0) v = target(*umb.contour_list().begin(), P); - dirnext = d1[v]; + dirnext = get(d1,v); cosinus = To_double(dir*dirnext); if (cosinus < 0) {dirnext = dirnext*(-1); cosinus *= -1;} if (cosinus>1) cosinus = 1; From 27de50e50b2b1ac6efecfd1582d30d25db423192 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 5 Dec 2017 14:37:49 +0100 Subject: [PATCH 07/32] fix misspelled typedef --- Ridges_3/doc/Ridges_3/CGAL/Ridges.h | 4 ++-- Ridges_3/include/CGAL/Ridges.h | 22 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Ridges_3/doc/Ridges_3/CGAL/Ridges.h b/Ridges_3/doc/Ridges_3/CGAL/Ridges.h index b08aa4753a7..e5bb07fc85d 100644 --- a/Ridges_3/doc/Ridges_3/CGAL/Ridges.h +++ b/Ridges_3/doc/Ridges_3/CGAL/Ridges.h @@ -226,7 +226,7 @@ typedef typename TriangleMesh::Traits::FT FT; A halfedge crossed by a ridge is paired with the barycentric coordinate of the crossing point. */ -typedef std::pair< halfedge_descriptor, FT> Ridge_halfhedge; +typedef std::pair< halfedge_descriptor, FT> Ridge_halfedge; /// @} @@ -261,7 +261,7 @@ FT sharpness() const; /*! */ -const std::list* line() const; +const std::list* line() const; /// @} diff --git a/Ridges_3/include/CGAL/Ridges.h b/Ridges_3/include/CGAL/Ridges.h index c886b17f305..db63c842596 100644 --- a/Ridges_3/include/CGAL/Ridges.h +++ b/Ridges_3/include/CGAL/Ridges.h @@ -68,7 +68,8 @@ public: typedef typename Kernel::FT FT; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef std::pair< halfedge_descriptor, FT> ridge_halfhedge; + typedef std::pair< halfedge_descriptor, FT> Ridge_halfedge; + typedef Ridge_halfedge ridge_halfhedge; //kept for backward compatibility Ridge_type line_type() const {return m_line_type;} Ridge_type& line_type() {return m_line_type;} @@ -79,8 +80,8 @@ public: const FT sharpness() const {return m_sharpness;} FT& sharpness() {return m_sharpness;} - const std::list* line() const { return &m_line;} - std::list* line() { return &m_line;} + const std::list* line() const { return &m_line;} + std::list* line() { return &m_line;} //constructor Ridge_line(const TriangleMesh& P); @@ -99,7 +100,7 @@ protected: //one of MAX_ELLIPTIC_RIDGE, MAX_HYPERBOLIC_RIDGE, MAX_CREST_RIDGE, //MIN_ELLIPTIC_RIDGE, MIN_HYPERBOLIC_RIDGE or MIN_CREST_RIDGE Ridge_type m_line_type; - std::list m_line; + std::list m_line; FT m_strength;// = integral of ppal curvature along the line FT m_sharpness;// = (integral of second derivative of curvature // along the line) multiplied by the squared of @@ -130,7 +131,7 @@ dump_4ogl(std::ostream& out_stream, << strength() << " " << sharpness() << " "; typedef typename boost::property_traits::value_type Point_3; - typename std::list::const_iterator + typename std::list::const_iterator iter = line()->begin(), ite = line()->end(); for (;iter!=ite;iter++){ @@ -155,7 +156,7 @@ dump_verbose(std::ostream& out_stream, VertexPointMap vpm) const << "Sharpness is : " << sharpness() << std::endl << "Polyline point coordinates are : " << std::endl; - typename std::list::const_iterator + typename std::list::const_iterator iter = line()->begin(), ite = line()->end(); for (;iter!=ite;iter++){ @@ -203,7 +204,8 @@ class Ridge_approximation CGAL_static_assertion((boost::is_same::value)); CGAL_static_assertion((boost::is_same::value)); - typedef std::pair< halfedge_descriptor, FT> Ridge_halfhedge; + typedef std::pair< halfedge_descriptor, FT> Ridge_halfedge; + typedef Ridge_halfedge Ridge_halfhedge; // kept for backward compatibility typedef CGAL::Ridge_line Ridge_line; Ridge_approximation(const TriangleMesh &P, @@ -711,7 +713,7 @@ init_ridge_line(Ridge_line* ridge_line, const Ridge_type r_type) { ridge_line->line_type() = r_type; - ridge_line->line()->push_back(Ridge_halfhedge(h1, bary_coord(h1,r_type))); + ridge_line->line()->push_back(Ridge_halfedge(h1, bary_coord(h1,r_type))); addback(ridge_line, h2, r_type); } @@ -755,7 +757,7 @@ addback(Ridge_line* ridge_line, const halfedge_descriptor he, k_second =CGAL::abs(( CGAL::abs(get(P2,v_p)) * coord + CGAL::abs(get(P2,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } - ridge_line->line()->push_back( Ridge_halfhedge(he, coord)); + ridge_line->line()->push_back( Ridge_halfedge(he, coord)); } @@ -799,7 +801,7 @@ addfront(Ridge_line* ridge_line, k_second =CGAL::abs(( CGAL::abs(get(P2,v_p)) * coord + CGAL::abs(get(P2,v_q)) * (1-coord) )/(k1x-k2x)); ridge_line->sharpness() += k_second * CGAL::sqrt(segment * segment) * squared_model_size; } } - ridge_line->line()->push_front( Ridge_halfhedge(he, coord)); + ridge_line->line()->push_front( Ridge_halfedge(he, coord)); } From a2075ef10e8e9ac2c3bcf5b83ee98d1b2ae3b2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 5 Dec 2017 15:47:49 +0100 Subject: [PATCH 08/32] typo --- Ridges_3/doc/Ridges_3/CGAL/Ridges.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Ridges_3/doc/Ridges_3/CGAL/Ridges.h b/Ridges_3/doc/Ridges_3/CGAL/Ridges.h index e5bb07fc85d..1c6cec82ad6 100644 --- a/Ridges_3/doc/Ridges_3/CGAL/Ridges.h +++ b/Ridges_3/doc/Ridges_3/CGAL/Ridges.h @@ -170,21 +170,21 @@ Ridge_approximation(const TriangleMesh &tm, Outputs ridges of types `MAX_ELLIPTIC_RIDGE` and `MAX_HYPERBOLIC_RIDGE`. \tparam OutputIterator an output iterator wìth value type `Ridge_line*`. */ -template OutputIterator compute_max_ridges(OutputIterator it, Rdge_order ord = Ridge_order_3); +template OutputIterator compute_max_ridges(OutputIterator it, Ridge_order ord = Ridge_order_3); /*! Outputs ridges of types `MIN_ELLIPTIC_RIDGE` and `MIN_HYPERBOLIC_RIDGE`. \tparam OutputIterator an output iterator with value type `Ridge_line*`. */ -template OutputIterator compute_min_ridges(OutputIterator it, Rdge_order ord = Ridge_order_3); +template OutputIterator compute_min_ridges(OutputIterator it, Ridge_order ord = Ridge_order_3); /*! Outputs ridges of types `MAX_CREST_RIDGE` and `MIN_CREST_RIDGE`. \tparam OutputIterator is an output iterator with value type `Ridge_line*`. */ -template OutputIterator compute_crest_ridges(OutputIterator it, Rdge_order ord = Ridge_order_3); +template OutputIterator compute_crest_ridges(OutputIterator it, Ridge_order ord = Ridge_order_3); /// @} From 9dd6684627109250d21683e5dc9b8f60372cd87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 6 Dec 2017 16:42:06 +0100 Subject: [PATCH 09/32] use only add_vertex function described in the concept --- .../Convex_hull_3/dual/halfspace_intersection_3.h | 9 ++++++--- .../halfspace_intersection_with_constructions_3.h | 13 ++++++++----- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h index 39b96552389..fa5e7007278 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_3.h @@ -66,8 +66,10 @@ namespace CGAL typedef typename Polyhedron_dual::Vertex_const_iterator Vertex_const_iterator; - // typedefs for primal + // typedef and type for primal typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typename boost::property_map::type vpm = + get(CGAL::vertex_point, primal); // Typedefs for intersection typedef typename Kernel::Plane_3 Plane_3; @@ -114,8 +116,9 @@ namespace CGAL origin.y() + pp->y(), origin.z() + pp->z()); - - primal_vertices[it] = add_vertex(ppp, primal); + vertex_descriptor vd = add_vertex(primal); + primal_vertices[it] = vd; + put(vpm, vd, ppp); } // Then, add facets to the primal polyhedron diff --git a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h index ac18a1e1556..cccd556b489 100644 --- a/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h +++ b/Convex_hull_3/include/CGAL/Convex_hull_3/dual/halfspace_intersection_with_constructions_3.h @@ -55,22 +55,25 @@ namespace CGAL typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typename boost::property_map::const_type vpmap = get(CGAL::vertex_point, primal); + typename boost::property_map::const_type vpm_primal = get(CGAL::vertex_point, primal); + typename boost::property_map::type vpm_dual = get(CGAL::vertex_point, dual); // compute coordinates of extreme vertices in the dual polyhedron // from primal faces boost::unordered_map extreme_points; BOOST_FOREACH (face_descriptor fd , faces( primal)){ halfedge_descriptor h = halfedge(fd,primal); - Plane_3 p (get(vpmap, target(h, primal)), - get(vpmap, target(next(h, primal), primal)), - get(vpmap, target(next(next(h, primal), primal), primal))); + Plane_3 p (get(vpm_primal, target(h, primal)), + get(vpm_primal, target(next(h, primal), primal)), + get(vpm_primal, target(next(next(h, primal), primal), primal))); // translate extreme vertex Point_3 extreme_p = CGAL::ORIGIN + p.orthogonal_vector () / (-p.d()); Point_3 translated_extreme_p(extreme_p.x() + origin.x(), extreme_p.y() + origin.y(), extreme_p.z() + origin.z()); - extreme_points[fd] = add_vertex(translated_extreme_p,dual); + vertex_descriptor vd = add_vertex(dual); + extreme_points[fd] = vd; + put(vpm_dual, vd, translated_extreme_p); } // build faces From f191e6114a29a72f4bff0fa6e5d87729a3cc912c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 6 Dec 2017 17:46:24 +0100 Subject: [PATCH 10/32] fix named parameter functions --- .../Polygon_mesh_processing/internal/parameters_interface.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h index 908f19269d4..92d00507c6a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/internal/parameters_interface.h @@ -31,9 +31,9 @@ CGAL_add_named_parameter(protect_constraints_t, protect_constraints, protect_con CGAL_add_named_parameter(relax_constraints_t, relax_constraints, relax_constraints) CGAL_add_named_parameter(vertex_is_constrained_t, vertex_is_constrained, vertex_is_constrained_map) CGAL_add_named_parameter(face_patch_t, face_patch, face_patch_map) -CGAL_add_named_parameter(random_uniform_sampling_t, random_uniform_sampling, random_uniform_sampling) -CGAL_add_named_parameter(grid_sampling_t, grid_sampling, grid_sampling) -CGAL_add_named_parameter(monte_carlo_sampling_t, monte_carlo_sampling, monte_carlo_sampling) +CGAL_add_named_parameter(random_uniform_sampling_t, random_uniform_sampling, use_random_uniform_sampling) +CGAL_add_named_parameter(grid_sampling_t, grid_sampling, use_grid_sampling) +CGAL_add_named_parameter(monte_carlo_sampling_t, monte_carlo_sampling, use_monte_carlo_sampling) CGAL_add_named_parameter(do_sample_edges_t, do_sample_edges, do_sample_edges) CGAL_add_named_parameter(do_sample_vertices_t, do_sample_vertices, do_sample_vertices) CGAL_add_named_parameter(do_sample_faces_t, do_sample_faces, do_sample_faces) From ef3c8a638eef736e38f179630c1a89c9e884ec87 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 7 Dec 2017 08:18:45 +0000 Subject: [PATCH 11/32] fix indentation --- .../CGAL/Constrained_triangulation_plus_2.h | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h index 148a801637c..d2594b4d940 100644 --- a/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h +++ b/Triangulation_2/include/CGAL/Constrained_triangulation_plus_2.h @@ -781,79 +781,79 @@ insert_subconstraint(Vertex_handle vaa, stack.pop(); CGAL_triangulation_precondition( vaa != vbb); - Vertex_handle vi; + Vertex_handle vi; - Face_handle fr; - int i; - if(this->includes_edge(vaa,vbb,vi,fr,i)) { - this->mark_constraint(fr,i); - if (vi != vbb) { - hierarchy.split_constraint(vaa,vbb,vi); - stack.push(std::make_pair(vi,vbb)); + Face_handle fr; + int i; + if(this->includes_edge(vaa,vbb,vi,fr,i)) { + this->mark_constraint(fr,i); + if (vi != vbb) { + hierarchy.split_constraint(vaa,vbb,vi); + stack.push(std::make_pair(vi,vbb)); + } + continue; } - continue; - } - List_faces intersected_faces; - List_edges conflict_boundary_ab, conflict_boundary_ba; + List_faces intersected_faces; + List_edges conflict_boundary_ab, conflict_boundary_ba; - bool intersection = this->find_intersected_faces( - vaa, vbb, - intersected_faces, - conflict_boundary_ab, - conflict_boundary_ba, - vi); + bool intersection = this->find_intersected_faces( + vaa, vbb, + intersected_faces, + conflict_boundary_ab, + conflict_boundary_ba, + vi); - if ( intersection) { - if (vi != vaa && vi != vbb) { - hierarchy.split_constraint(vaa,vbb,vi); - stack.push(std::make_pair(vaa,vi)); - stack.push(std::make_pair(vi,vbb)); - } - else stack.push(std::make_pair(vaa,vbb)); + if ( intersection) { + if (vi != vaa && vi != vbb) { + hierarchy.split_constraint(vaa,vbb,vi); + stack.push(std::make_pair(vaa,vi)); + stack.push(std::make_pair(vi,vbb)); + } + else stack.push(std::make_pair(vaa,vbb)); - continue; - } + continue; + } - //no intersection + //no intersection - List_edges edges(conflict_boundary_ab); - std::copy(conflict_boundary_ba.begin(), conflict_boundary_ba.end(), std::back_inserter(edges)); + List_edges edges(conflict_boundary_ab); + std::copy(conflict_boundary_ba.begin(), conflict_boundary_ba.end(), std::back_inserter(edges)); - // edges may contain mirror edges. They no longer exist after triangulate_hole - // so we have to remove them before calling get_bounded_faces - if(! edges.empty()){ + // edges may contain mirror edges. They no longer exist after triangulate_hole + // so we have to remove them before calling get_bounded_faces + if(! edges.empty()){ #if defined(BOOST_MSVC) && (BOOST_VERSION == 105500) - std::set faces(intersected_faces.begin(), intersected_faces.end()); + std::set faces(intersected_faces.begin(), intersected_faces.end()); #else - boost::container::flat_set faces(intersected_faces.begin(), intersected_faces.end()); + boost::container::flat_set faces(intersected_faces.begin(), intersected_faces.end()); #endif - typename List_edges::iterator it2; - for(typename List_edges::iterator it = edges.begin(); it!= edges.end();){ - if(faces.find(it->first) != faces.end()){ - typename List_edges::iterator it2 = it; - ++it; - edges.erase(it2); - }else { - ++it; + typename List_edges::iterator it2; + for(typename List_edges::iterator it = edges.begin(); it!= edges.end();){ + if(faces.find(it->first) != faces.end()){ + typename List_edges::iterator it2 = it; + ++it; + edges.erase(it2); + }else { + ++it; + } } } - } - this->triangulate_hole(intersected_faces, - conflict_boundary_ab, - conflict_boundary_ba); + this->triangulate_hole(intersected_faces, + conflict_boundary_ab, + conflict_boundary_ba); - this->get_bounded_faces(edges.begin(), - edges.end(), - out); + this->get_bounded_faces(edges.begin(), + edges.end(), + out); - if (vi != vbb) { - hierarchy.split_constraint(vaa,vbb,vi); - stack.push(std::make_pair(vi,vbb)); - } + if (vi != vbb) { + hierarchy.split_constraint(vaa,vbb,vi); + stack.push(std::make_pair(vi,vbb)); + } } } From 68cf051563d25c7842eda5a96f5f7c796c15ea9f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 7 Dec 2017 10:07:16 +0100 Subject: [PATCH 12/32] Fix It requires `CGAL::exact(FT)` from ``. Fixes #2654. --- .../include/CGAL/Polygon_mesh_processing/measure.h | 4 ++++ .../test/Polygon_mesh_processing/measures_test.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h index e6765511f28..6793a77d5ab 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/measure.h @@ -34,6 +34,10 @@ #include #include +#include // needed for CGAL::exact(FT)/CGAL::exact(Lazy_exact_nt) + +#include + #ifdef DOXYGEN_RUNNING #define CGAL_PMP_NP_TEMPLATE_PARAMETERS NamedParameters #define CGAL_PMP_NP_CLASS NamedParameters diff --git a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp index 5d37a3bb56e..022c86cd1e0 100644 --- a/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp +++ b/Polygon_mesh_processing/test/Polygon_mesh_processing/measures_test.cpp @@ -1,10 +1,10 @@ +#include #include #include #include #include -#include #include #include From 9a7f07cd1d06827d2b30cb0eaa0b31b39025a784 Mon Sep 17 00:00:00 2001 From: Simon Giraudot Date: Fri, 8 Dec 2017 10:06:36 +0100 Subject: [PATCH 13/32] Reinitialize properties of Point_set_3 --- Point_set_3/include/CGAL/Point_set_3.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Point_set_3/include/CGAL/Point_set_3.h b/Point_set_3/include/CGAL/Point_set_3.h index c03bbf0ffdb..b07ac3662ba 100644 --- a/Point_set_3/include/CGAL/Point_set_3.h +++ b/Point_set_3/include/CGAL/Point_set_3.h @@ -412,7 +412,9 @@ public: else { -- m_nb_removed; - return m_indices.end() - m_nb_removed - 1; + iterator out = m_indices.end() - m_nb_removed - 1; + m_base.reset(*out); + return out; } } From 082d9005da96ce43c4089607a01c819da76b48b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 8 Dec 2017 14:45:54 +0100 Subject: [PATCH 14/32] use reference type of the pmap --- Point_set_processing_3/include/CGAL/estimate_scale.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Point_set_processing_3/include/CGAL/estimate_scale.h b/Point_set_processing_3/include/CGAL/estimate_scale.h index ef428e7494f..61eefc3f5b7 100644 --- a/Point_set_processing_3/include/CGAL/estimate_scale.h +++ b/Point_set_processing_3/include/CGAL/estimate_scale.h @@ -70,7 +70,8 @@ class Quick_multiscale_approximate_knn_distance::reference + operator() (const ValueType& v) const { return get(point_pmap, v); } }; std::size_t m_cluster_size; @@ -226,7 +227,8 @@ class Quick_multiscale_approximate_knn_distance::reference + operator() (const ValueType& v) const { return get(point_pmap, v); } }; template @@ -242,7 +244,8 @@ class Quick_multiscale_approximate_knn_distance::reference + p2 = get(ppmap.point_pmap, i); return value_type (p2.x(), p2.y(), 0.); } @@ -367,7 +370,8 @@ public: FT nb = 0.; std::size_t index = 0; - const typename Kernel::Point_2& pquery = get(point_pmap, *query); + typename boost::property_traits::reference + pquery = get(point_pmap, *query); for (std::size_t t = 0; t < m_point_sets.size(); ++ t) { std::size_t size = ((t == m_point_sets.size() - 1) From e58abaf3e73aa51489f869e6543da2ec606520c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 10:54:23 +0100 Subject: [PATCH 15/32] readd the invariant on the concept doc it was only on the summary page and is important --- BGL/doc/BGL/Concepts/HalfedgeGraph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BGL/doc/BGL/Concepts/HalfedgeGraph.h b/BGL/doc/BGL/Concepts/HalfedgeGraph.h index 2bfb1136b88..4cd60ea98f0 100644 --- a/BGL/doc/BGL/Concepts/HalfedgeGraph.h +++ b/BGL/doc/BGL/Concepts/HalfedgeGraph.h @@ -27,7 +27,7 @@ A model of `HalfedgeGraph` must have the interior property `vertex_point` attach class HalfedgeGraph {}; /*! \relates HalfedgeGraph -returns the edge corresponding to halfedges `h` and `opposite(h,g)`. +returns the edge corresponding to halfedges `h` and `opposite(h,g)`, with the following invariant `halfedge(edge(h,g),g)==h`. */ template boost::graph_traits::edge_descriptor From 751c424aa04f8c07e1ba6ed1488ccb326a37e52e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 11:00:05 +0100 Subject: [PATCH 16/32] make no assumption of the point map type --- .../CGAL/Subdivision_method_3/subdivision_masks_3.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h index f2d7028fabf..c0adb335253 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h @@ -92,6 +92,8 @@ public: typedef typename Base::FT FT; typedef typename Base::Point Point; typedef typename Base::Vector Vector; + + typedef typename boost::property_traits::reference Point_ref; #endif public: @@ -116,8 +118,8 @@ public: } void edge_node(halfedge_descriptor edge, Point& pt) { - const Point& p1 = get(this->vpmap, target(edge, *(this->pmesh))); - const Point& p2 = get(this->vpmap, source(edge, *(this->pmesh))); + const Point_ref p1 = get(this->vpmap, target(edge, *(this->pmesh))); + const Point_ref p2 = get(this->vpmap, source(edge, *(this->pmesh))); pt = Point((p1[0]+p2[0])/2, (p1[1]+p2[1])/2, (p1[2]+p2[2])/2); } @@ -172,6 +174,8 @@ public: typedef typename Base::FT FT; typedef typename Base::Point Point; typedef typename Base::Vector Vector; + + typedef typename boost::property_traits::reference Point_ref; #endif public: @@ -212,7 +216,7 @@ public: typename boost::graph_traits::degree_size_type n = degree(vertex, *(this->pmesh)); FT Q[] = {0.0, 0.0, 0.0}, R[] = {0.0, 0.0, 0.0}; - Point& S = get(this->vpmap,vertex); + const Point_ref S = get(this->vpmap,vertex); Point q; for (unsigned int i = 0; i < n; i++, ++vcir) { From c89abd7d72eeb1d7011ad00421856a8dde45e475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 12:17:35 +0100 Subject: [PATCH 17/32] fix conversion warnings --- .../internal/subdivision_hosts_impl_3.h | 34 +++++++++---------- .../subdivision_masks_3.h | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index db34693beba..1db48935e0d 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -89,7 +89,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { std::vector v_onborder(num_vertex); face_iterator fitr = faces(p).first; - for (size_t i = 0; i < num_facet; i++, ++fitr) + for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) mask.face_node(*fitr, face_point_buffer[i]); @@ -111,7 +111,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } vertex_iterator vitr = vertices(p).first; - for (size_t i = 0; i < num_vertex; i++, ++vitr) + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) if (!v_onborder[v_index[*vitr]]) mask.vertex_node(*vitr, vertex_point_buffer[i]); // Build the connectivity using insert_vertex() and insert_edge() @@ -123,7 +123,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // the new inserted vertex of step 3 // Step 1. edge_iterator eitr = edges(p).first; - for (size_t i = 0; i < num_edge; i++, ++eitr) { + for (typename boost::graph_traits::edges_size_type i = 0; i < num_edge; i++, ++eitr) { vertex_descriptor vh = insert_vertex(p, halfedge(*eitr,p)); put(vpm, vh, edge_point_buffer[i]); } @@ -131,7 +131,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // TODO: the topoloy modification can be done by a template function // and that gives the user a chance to create new topological masks. - for (size_t i = 0; i < num_facet; i++, ++fitr) { + for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) { // Step 2. Halfedge_around_facet_circulator hcir_begin(halfedge(*fitr,p),p); Halfedge_around_facet_circulator hcir = hcir_begin; @@ -161,7 +161,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // Update the geometry data of the newly inserted vertices by the // vertices buffer vitr = vertices(p).first; - for (size_t i = 0; i < num_vertex; i++, ++vitr) + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) put(vpm, *vitr, vertex_point_buffer[i]); // CGAL_postcondition(p.is_valid()); @@ -223,7 +223,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } } vertex_iterator vitr = vertices(p).first; - for (size_t i = 0; i < num_vertex; i++, ++vitr) + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) if (!v_onborder[i]) mask.vertex_node(*vitr, vertex_point_buffer[i]); // Build the connectivity using insert_vertex() and insert_edge() @@ -235,12 +235,12 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // the new inserted vertex of step 3 // Step 1. edge_iterator eitr = edges(p).first; - for (size_t i = 0; i < num_edge; i++, ++eitr) { + for (typename boost::graph_traits::edges_size_type i = 0; i < num_edge; i++, ++eitr) { vertex_descriptor vh = insert_vertex(p, halfedge(*eitr,p)); put(vpm,vh, edge_point_buffer[i]); } face_iterator fitr = faces(p).first; - for (size_t i = 0; i < num_facet; i++, ++fitr) { + for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) { // Step 2. Halfedge_around_face_circulator hcir_begin(halfedge(*fitr,p),p); Halfedge_around_face_circulator hcir = hcir_begin; @@ -261,7 +261,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // Update the geometry data of the newly inserted vertices by the // vertices buffer vitr = vertices(p).first; - for (size_t i = 0; i < num_vertex; i++, ++vitr) + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) put(vpm, *vitr, vertex_point_buffer[i]); // CGAL_postcondition(p.is_valid()); @@ -312,13 +312,13 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { // Build the connectivity using insert_vertex() and insert_edge() pi = 0; - for (size_t i = 0; i < num_v; ++i) { + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v; ++i) { vertex_descriptor vh = *vitr; ++vitr; Halfedge_around_target_circulator vcir(vh,p); - size_t vn = degree(vh,p); - for (size_t j = 0; j < vn; ++j) { + typename boost::graph_traits::degree_size_type vn = degree(vh,p); + for (typename boost::graph_traits::degree_size_type j = 0; j < vn; ++j) { halfedge_descriptor e = *vcir; ++vcir; if (! is_border(e,p)) { @@ -328,7 +328,7 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { } vcir = Halfedge_around_target_circulator(vh,p); - for (size_t j = 0; j < vn; ++j) { + for (typename boost::graph_traits::vertices_size_type j = 0; j < vn; ++j) { if (! is_border(*vcir,p)) { halfedge_descriptor e1 = prev(*vcir, p); ++vcir; @@ -343,7 +343,7 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { } edge_iterator eitr = edges(p).first; - for (size_t i = 0; i < num_e; ++i) { + for (typename boost::graph_traits::edges_size_type i = 0; i < num_e; ++i) { halfedge_descriptor eh = halfedge(*eitr,p); ++eitr; if (! is_border(edge(eh,p),p)) { @@ -378,7 +378,7 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { } vitr = vertices(p).first; - for (size_t i = 0; i < num_v-num_be; ++i) { + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v-num_be; ++i) { vertex_descriptor vh = *vitr; ++vitr; Euler::remove_center_vertex(halfedge(vh,p),p); @@ -624,7 +624,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, // insert the new subdividing points face_iterator b,e; boost::tie(b,e) = faces(p); - for(std::size_t i=0, cpt_id=0; i < num_f; ++i, ++b){ + for(typename boost::graph_traits::faces_size_type i=0, cpt_id=0; i < num_f; ++i, ++b){ face_descriptor fd = *b; halfedge_descriptor hd = face_halfedge_border[i]; if(refine_border && hd != boost::graph_traits::null_halfedge()) { @@ -650,7 +650,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, // flip the old edges (except the border edges) edge_iterator eitr = edges(p).first; - for (size_t i = 0; i < num_e; ++i) { + for (typename boost::graph_traits::edges_size_type i = 0; i < num_e; ++i) { halfedge_descriptor e = halfedge(*eitr,p); ++eitr; // move to next edge before flip since flip destroys current edge if (! is_border(edge(e,p),p)) { diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h index c0adb335253..7dc4ebaba5b 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h @@ -219,7 +219,7 @@ public: const Point_ref S = get(this->vpmap,vertex); Point q; - for (unsigned int i = 0; i < n; i++, ++vcir) { + for (typename boost::graph_traits::degree_size_type i = 0; i < n; i++, ++vcir) { const Point& p2 = get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); R[0] += (S[0] + p2[0]) / 2; R[1] += (S[1] + p2[1]) / 2; From 25491714badf0144b35324ebe81eb9641cfedad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 13:21:37 +0100 Subject: [PATCH 18/32] using named parameters as documented --- .../examples/Subdivision_method_3/CatmullClark_subdivision.cpp | 3 ++- .../examples/Subdivision_method_3/Customized_subdivision.cpp | 3 ++- .../examples/Subdivision_method_3/DooSabin_subdivision.cpp | 3 ++- .../examples/Subdivision_method_3/Loop_subdivision.cpp | 3 ++- .../examples/Subdivision_method_3/Sqrt3_subdivision.cpp | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Subdivision_method_3/examples/Subdivision_method_3/CatmullClark_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/CatmullClark_subdivision.cpp index b0cc8a9138c..cfaf8938158 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/CatmullClark_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/CatmullClark_subdivision.cpp @@ -16,6 +16,7 @@ typedef CGAL::Surface_mesh PolygonMesh; using namespace std; using namespace CGAL; +namespace params = CGAL::Polygon_mesh_processing::parameters; int main(int argc, char** argv) { if (argc > 4) { @@ -40,7 +41,7 @@ int main(int argc, char** argv) { Timer t; t.start(); - Subdivision_method_3::CatmullClark_subdivision(pmesh, d); + Subdivision_method_3::CatmullClark_subdivision(pmesh, params::number_of_iterations(d)); std::cerr << "Done (" << t.time() << " s)" << std::endl; std::ofstream out(out_file); diff --git a/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp index 5dbdaf8e198..40c3fde25c8 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp @@ -16,6 +16,7 @@ typedef CGAL::Simple_cartesian Kernel; typedef CGAL::Surface_mesh PolygonMesh; using namespace std; using namespace CGAL; +namespace params = CGAL::Polygon_mesh_processing::parameters; // ====================================================================== template @@ -109,7 +110,7 @@ int main(int argc, char **argv) { Timer t; t.start(); - Subdivision_method_3::PTQ(pmesh, WLoop_mask_3(pmesh), d); + Subdivision_method_3::PTQ(pmesh, WLoop_mask_3(pmesh), params::number_of_iterations(d)); std::cerr << "Done (" << t.time() << " s)" << std::endl; std::ofstream out(out_file); diff --git a/Subdivision_method_3/examples/Subdivision_method_3/DooSabin_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/DooSabin_subdivision.cpp index 72cbe53e6f1..016bf1f8d33 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/DooSabin_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/DooSabin_subdivision.cpp @@ -18,6 +18,7 @@ typedef CGAL::Polyhedron_3 PolygonMesh; using namespace std; using namespace CGAL; +namespace params = CGAL::Polygon_mesh_processing::parameters; int main(int argc, char **argv) { if (argc > 4) { @@ -42,7 +43,7 @@ int main(int argc, char **argv) { Timer t; t.start(); - Subdivision_method_3::DooSabin_subdivision(pmesh, d); + Subdivision_method_3::DooSabin_subdivision(pmesh, params::number_of_iterations(d)); std::cerr << "Done (" << t.time() << " s)" << std::endl; std::ofstream out(out_file); diff --git a/Subdivision_method_3/examples/Subdivision_method_3/Loop_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/Loop_subdivision.cpp index 88526ed999a..8298450fdda 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/Loop_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/Loop_subdivision.cpp @@ -16,6 +16,7 @@ typedef CGAL::Surface_mesh PolygonMesh; using namespace std; using namespace CGAL; +namespace params = CGAL::Polygon_mesh_processing::parameters; int main(int argc, char **argv) { if (argc > 4) { @@ -40,7 +41,7 @@ int main(int argc, char **argv) { Timer t; t.start(); - Subdivision_method_3::Loop_subdivision(pmesh,d); + Subdivision_method_3::Loop_subdivision(pmesh, params::number_of_iterations(d)); std::cerr << "Done (" << t.time() << " s)" << std::endl; std::ofstream out(out_file); diff --git a/Subdivision_method_3/examples/Subdivision_method_3/Sqrt3_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/Sqrt3_subdivision.cpp index cec6f63b4e5..447ae6e1671 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/Sqrt3_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/Sqrt3_subdivision.cpp @@ -16,6 +16,7 @@ typedef CGAL::Surface_mesh PolygonMesh; using namespace std; using namespace CGAL; +namespace params = CGAL::Polygon_mesh_processing::parameters; int main(int argc, char **argv) { if (argc > 4) { @@ -40,7 +41,7 @@ int main(int argc, char **argv) { Timer t; t.start(); - Subdivision_method_3::Sqrt3_subdivision(pmesh,d); + Subdivision_method_3::Sqrt3_subdivision(pmesh, params::number_of_iterations(d)); std::cerr << "Done (" << t.time() << " s)" << std::endl; std::ofstream out(out_file); From 5291ebc58baf714830bd545d47ec01b28f640c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 13:26:32 +0100 Subject: [PATCH 19/32] workaround conversion warning --- .../Surface_mesh_shortest_path/Surface_mesh_shortest_path.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h index 924511cc47b..60f3170024b 100644 --- a/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h +++ b/Surface_mesh_shortest_path/include/CGAL/Surface_mesh_shortest_path/Surface_mesh_shortest_path.h @@ -1268,7 +1268,7 @@ private: propagateRight = rightSide; } - if (node->level() <= num_faces(m_graph)) + if (node->level() <= static_cast(num_faces(m_graph))) { if (propagateLeft) { From c751a461ff8657bb2e3911af35d2c203668c8180 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 17:51:24 +0100 Subject: [PATCH 20/32] copy descriptors as we are looping over them while modifying the mesh done for all but DQQ --- .../internal/subdivision_hosts_impl_3.h | 134 +++++++++--------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index 1db48935e0d..6b26176615e 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -53,13 +53,19 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - - typedef typename boost::graph_traits::vertex_iterator vertex_iterator; - typedef typename boost::graph_traits::edge_iterator edge_iterator; - typedef typename boost::graph_traits::face_iterator face_iterator; + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef Halfedge_around_face_circulator Halfedge_around_facet_circulator; + //First back up initial vertices/faces/edges + std::vector p_vertices(vertices(p).first, vertices(p).second); + std::vector p_faces(faces(p).first, faces(p).second); + std::vector p_edges(edges(p).first, edges(p).second); + + std::size_t num_v = p_vertices.size(); + std::size_t num_e = p_edges.size(); + std::size_t num_f = p_faces.size(); + // Build a new vertices buffer has the following structure // // 0 1 ... e_begin ... f_begin ... (end_of_buffer) @@ -68,34 +74,29 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // f_begin ... (end) : store the positions of the face-vertices // The index of the vertices buffer should 1-1 map to the distance // of the corresponding iterator to the begin of the iterator. - typename boost::graph_traits::vertices_size_type num_vertex = num_vertices(p); - typename boost::graph_traits::halfedges_size_type num_edge = num_halfedges(p)/2; - typename boost::graph_traits::faces_size_type num_facet = num_faces(p); // We need to reserve the memory to prevent reallocation. - reserve(p,num_vertex+num_edge+num_facet, 4*2*num_edge, 4*num_edge/2); + reserve(p,num_v+num_e+num_f, 4*2*num_e, 4*num_e/2); typedef typename boost::property_traits::value_type Point; - Point* vertex_point_buffer = new Point[num_vertex + num_edge + num_facet]; - Point* edge_point_buffer = vertex_point_buffer + num_vertex; - Point* face_point_buffer = edge_point_buffer + num_edge; + Point* vertex_point_buffer = new Point[num_v + num_e + num_f]; + Point* edge_point_buffer = vertex_point_buffer + num_v; + Point* face_point_buffer = edge_point_buffer + num_e; int i=0; boost::unordered_map v_index; - BOOST_FOREACH(vertex_descriptor vh, vertices(p)){ + BOOST_FOREACH(vertex_descriptor vh, p_vertices){ v_index[vh]= i++; } - std::vector v_onborder(num_vertex); - face_iterator fitr = faces(p).first; - for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) + std::vector v_onborder(num_v); + typename std::vector::iterator fitr=p_faces.begin(); + for (std::size_t i = 0; i < num_f; i++, ++fitr) mask.face_node(*fitr, face_point_buffer[i]); - - { std::size_t i = 0; - BOOST_FOREACH(edge_descriptor ed, edges(p)){ + BOOST_FOREACH(edge_descriptor ed, p_edges){ if(is_border(ed,p)){ halfedge_descriptor h=halfedge(ed,p); if (is_border(h,p)) h=opposite(h,p); @@ -110,8 +111,8 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } } - vertex_iterator vitr = vertices(p).first; - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) + typename std::vector::iterator vitr = p_vertices.begin(); + for (std::size_t i = 0; i < num_v; i++, ++vitr) if (!v_onborder[v_index[*vitr]]) mask.vertex_node(*vitr, vertex_point_buffer[i]); // Build the connectivity using insert_vertex() and insert_edge() @@ -122,16 +123,16 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // 4. insert_edge() between all other new inserted vertices of step 1 and // the new inserted vertex of step 3 // Step 1. - edge_iterator eitr = edges(p).first; - for (typename boost::graph_traits::edges_size_type i = 0; i < num_edge; i++, ++eitr) { + typename std::vector::iterator eitr = p_edges.begin(); + for (std::size_t i = 0; i < num_e; i++, ++eitr) { vertex_descriptor vh = insert_vertex(p, halfedge(*eitr,p)); put(vpm, vh, edge_point_buffer[i]); } - fitr = faces(p).first; // TODO: the topoloy modification can be done by a template function // and that gives the user a chance to create new topological masks. - for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) { + fitr = p_faces.begin(); + for (std::size_t i = 0; i < num_f; i++, ++fitr) { // Step 2. Halfedge_around_facet_circulator hcir_begin(halfedge(*fitr,p),p); Halfedge_around_facet_circulator hcir = hcir_begin; @@ -160,8 +161,8 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // Update the geometry data of the newly inserted vertices by the // vertices buffer - vitr = vertices(p).first; - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) + vitr = p_vertices.begin(); + for (std::size_t i = 0; i < num_v; i++, ++vitr) put(vpm, *vitr, vertex_point_buffer[i]); // CGAL_postcondition(p.is_valid()); @@ -174,15 +175,21 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; - - typedef typename boost::graph_traits::vertex_iterator vertex_iterator; - typedef typename boost::graph_traits::edge_iterator edge_iterator; - typedef typename boost::graph_traits::face_iterator face_iterator; + typedef typename boost::graph_traits::face_descriptor face_descriptor; typedef Halfedge_around_face_circulator Halfedge_around_face_circulator; typedef typename boost::property_traits::value_type Point; + //First back up initial vertices/faces/edges + std::vector p_vertices(vertices(p).first, vertices(p).second); + std::vector p_faces(faces(p).first, faces(p).second); + std::vector p_edges(edges(p).first, edges(p).second); + + std::size_t num_v = p_vertices.size(); + std::size_t num_e = p_edges.size(); + std::size_t num_f = p_faces.size(); + // Build a new vertices buffer has the following structure // // 0 1 ... e_begin ... f_begin ... (end_of_buffer) @@ -190,26 +197,23 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // e_begin ... (end) : store the positions of the edge-vertices // The index of the vertices buffer should 1-1 map to the distance // of the corresponding iterator to the begin of the iterator. - typename boost::graph_traits::vertices_size_type num_vertex = num_vertices(p); - typename boost::graph_traits::halfedges_size_type num_edge = num_halfedges(p)/2; - typename boost::graph_traits::faces_size_type num_facet = num_faces(p); // We need to reserve the memory to prevent reallocation. - reserve(p,num_vertex+num_edge, 2*2*num_edge, 4*num_edge/2); + reserve(p,num_v + num_e, 2*2*num_e, 4*num_e/2); - Point* vertex_point_buffer = new Point[num_vertex + num_edge]; - Point* edge_point_buffer = vertex_point_buffer + num_vertex; + Point* vertex_point_buffer = new Point[num_v + num_e]; + Point* edge_point_buffer = vertex_point_buffer + num_v; int i=0; boost::unordered_map v_index; - BOOST_FOREACH(vertex_descriptor vh, vertices(p)){ + BOOST_FOREACH(vertex_descriptor vh, p_vertices){ v_index[vh]= i++; } - std::vector v_onborder(num_vertex); + std::vector v_onborder(num_v); { std::size_t i = 0; - BOOST_FOREACH(edge_descriptor ed, edges(p)){ + BOOST_FOREACH(edge_descriptor ed, p_edges){ if(! is_border(ed,p)){ mask.edge_node(halfedge(ed,p), edge_point_buffer[i]); } else{ @@ -222,8 +226,8 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { ++i; } } - vertex_iterator vitr = vertices(p).first; - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) + typename std::vector::iterator vitr = p_vertices.begin(); + for (std::size_t i = 0; i < num_v; i++, ++vitr) if (!v_onborder[i]) mask.vertex_node(*vitr, vertex_point_buffer[i]); // Build the connectivity using insert_vertex() and insert_edge() @@ -234,13 +238,14 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // 4. insert_edge() between all other new inserted vertices of step 1 and // the new inserted vertex of step 3 // Step 1. - edge_iterator eitr = edges(p).first; - for (typename boost::graph_traits::edges_size_type i = 0; i < num_edge; i++, ++eitr) { - vertex_descriptor vh = insert_vertex(p, halfedge(*eitr,p)); + typename std::vector::iterator eit = p_edges.begin(); + for (std::size_t i = 0; i < num_e; i++, ++eit) { + vertex_descriptor vh = insert_vertex(p, halfedge(*eit,p)); put(vpm,vh, edge_point_buffer[i]); } - face_iterator fitr = faces(p).first; - for (typename boost::graph_traits::faces_size_type i = 0; i < num_facet; i++, ++fitr) { + + typename std::vector::iterator fitr = p_faces.begin(); + for (std::size_t i = 0; i < num_f; i++, ++fitr) { // Step 2. Halfedge_around_face_circulator hcir_begin(halfedge(*fitr,p),p); Halfedge_around_face_circulator hcir = hcir_begin; @@ -260,8 +265,8 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // Update the geometry data of the newly inserted vertices by the // vertices buffer - vitr = vertices(p).first; - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_vertex; i++, ++vitr) + vitr = p_vertices.begin(); + for (std::size_t i = 0; i < num_v; i++, ++vitr) put(vpm, *vitr, vertex_point_buffer[i]); // CGAL_postcondition(p.is_valid()); @@ -555,19 +560,21 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, typedef typename boost::graph_traits::edge_descriptor edge_descriptor; typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::edge_iterator edge_iterator; - typedef typename boost::graph_traits::face_iterator face_iterator; - typedef typename boost::property_traits::value_type Point; - typename boost::graph_traits::vertices_size_type num_v = num_vertices(p); - typename boost::graph_traits::halfedges_size_type num_e = num_halfedges(p)/2; - typename boost::graph_traits::faces_size_type num_f = num_faces(p); + //First back up initial vertices/faces/edges + std::vector p_vertices(vertices(p).first, vertices(p).second); + std::vector p_faces(faces(p).first, faces(p).second); + std::vector p_edges(edges(p).first, edges(p).second); + + std::size_t num_v = p_vertices.size(); + std::size_t num_e = p_edges.size(); + std::size_t num_f = p_faces.size(); // reserve enough size for the new points - typename boost::graph_traits::faces_size_type new_pts_size = num_f; + std::size_t new_pts_size = num_f; if(refine_border) { - BOOST_FOREACH(edge_descriptor ed, edges(p)){ + BOOST_FOREACH(edge_descriptor ed, p_edges){ if(is_border(ed, p)) ++new_pts_size; } @@ -586,7 +593,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, // compute the positions of new points std::size_t i = 0; std::size_t face_id = 0; - BOOST_FOREACH (face_descriptor fd, faces(p)) { + BOOST_FOREACH (face_descriptor fd, p_faces) { //ASSERTION_MSG(circulator_size(fitr->facet_begin())==3, "(ERROR) Non-triangle facet!"); if(refine_border) { BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(halfedge(fd, p), p)) { @@ -613,7 +620,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, } // smooth the position of existing vertices - BOOST_FOREACH(vertex_descriptor vd, vertices(p)){ + BOOST_FOREACH(vertex_descriptor vd, p_vertices){ Point pt; if(!is_border(vd, p)) { mask.vertex_node(vd, pt); @@ -622,10 +629,9 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, } // insert the new subdividing points - face_iterator b,e; - boost::tie(b,e) = faces(p); - for(typename boost::graph_traits::faces_size_type i=0, cpt_id=0; i < num_f; ++i, ++b){ - face_descriptor fd = *b; + typename std::vector::iterator fit=p_faces.begin(); + for(std::size_t i=0, cpt_id=0; i < num_f; ++i, ++fit){ + face_descriptor fd = *fit; halfedge_descriptor hd = face_halfedge_border[i]; if(refine_border && hd != boost::graph_traits::null_halfedge()) { halfedge_descriptor hd_next = next(hd, p); @@ -649,8 +655,8 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, } // flip the old edges (except the border edges) - edge_iterator eitr = edges(p).first; - for (typename boost::graph_traits::edges_size_type i = 0; i < num_e; ++i) { + typename std::vector::iterator eitr = p_edges.begin(); + for (std::size_t i = 0; i < num_e; ++i) { halfedge_descriptor e = halfedge(*eitr,p); ++eitr; // move to next edge before flip since flip destroys current edge if (! is_border(edge(e,p),p)) { From d8bba16568fe984de73c6858405d7fdc5f82f3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 11 Dec 2017 18:03:36 +0100 Subject: [PATCH 21/32] update user manual to also used named parameters --- .../Subdivision_method_3.txt | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt index 39d503841f4..901621151d0 100644 --- a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt +++ b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt @@ -127,12 +127,12 @@ There is only one line deserving a detailed explanation: \code{.cpp} -Subdivision_method_3::CatmullClark_subdivision(pmesh, d); +Subdivision_method_3::CatmullClark_subdivision(pmesh, params::number_of_iterations(d)); \endcode `Subdivision_method_3` specifies the namespace of the -subdivision functions. `CatmullClark_subdivision(P, d)` computes the +subdivision functions. `CatmullClark_subdivision(P, params::number_of_iterations(d))` computes the Catmull-Clark subdivision surface of the polygon mesh `pmesh` after `d` iterations of the refinements. The polygon mesh `pmesh` is passed by reference, and is modified (i.e.\ subdivided) by the @@ -188,7 +188,7 @@ three components of the Catmull-Clark subdivision method. \code{.cpp} template -void PQQ(PolygonMesh& p, Mask mask, int depth) +void PQQ(PolygonMesh& p, Mask mask, NamedParameters np) \endcode @@ -203,8 +203,7 @@ new points by cooperating with the `mask`. To implement Catmull-Clark subdivision, `Mask`, the geometry policy, has to realize the geometry masks of Catmull-Clark subdivision. -The parameter `depth` specifies the iterations of the refinement -on the control mesh. +The number of iterations as well as the vertex point map can be specified using the named parameter `np`. To implement the geometry masks, we need to know how a refinement host communicates with its geometry masks. @@ -305,7 +304,7 @@ call `PQQ()` with the Catmull-Clark masks that we have just defined. \code{.cpp} -PQQ(pmesh, CatmullClark_mask_3(pmesh), depth); +PQQ(pmesh, CatmullClark_mask_3(pmesh), params::number_of_iterations(depth)); \endcode @@ -335,16 +334,16 @@ and \f$ \sqrt{3}\f$ subdivision. namespace Subdivision_method_3 { template -void PQQ(PolygonMesh& pmesh, Mask mask, int step); +void PQQ(PolygonMesh& pmesh, Mask mask, NamedParameters np); template -void PTQ(PolygonMesh& pmesh, Mask mask, int step); +void PTQ(PolygonMesh& pmesh, Mask mask, NamedParameters np); template -void DQQ(PolygonMesh& pmesh, Mask mask, int step) +void DQQ(PolygonMesh& pmesh, Mask mask, NamedParameters np) template -void Sqrt3(PolygonMesh& pmesh, Mask mask, int step) +void Sqrt3(PolygonMesh& pmesh, Mask mask, NamedParameters np) } \endcode @@ -533,24 +532,24 @@ based on that kernel. \code{.cpp} namespace Subdivision_method_3 { - template - void CatmullClark_subdivision(PolygonMesh& pmesh, int step = 1) { - PQQ(pmesh, CatmullClark_mask_3(pmesh), step); + template + void CatmullClark_subdivision(PolygonMesh& pmesh, NamedParameters np) { + PQQ(pmesh, CatmullClark_mask_3(pmesh), np); } - template - void Loop_subdivision(PolygonMesh& pmesh, int step = 1) { - PTQ(pmesh, Loop_mask_3(pmesh) , step); + template + void Loop_subdivision(PolygonMesh& pmesh, NamedParameters np) { + PTQ(pmesh, Loop_mask_3(pmesh) , np); } - template - void DooSabin_subdivision(PolygonMesh& pmesh, int step = 1) { - DQQ(pmesh, DooSabin_mask_3(pmesh), step); + template + void DooSabin_subdivision(PolygonMesh& pmesh, NamedParameters np) { + DQQ(pmesh, DooSabin_mask_3(pmesh), np); } - template - void Sqrt3_subdivision(PolygonMesh& pmesh, int step = 1) { - Sqrt3(pmesh, Sqrt3_mask_3(pmesh), step); + template + void Sqrt3_subdivision(PolygonMesh& pmesh, NamedParameters np) { + Sqrt3(pmesh, Sqrt3_mask_3(pmesh), np); } } From 9aa82afc2a9925d96dea123e1661032f9e388656 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 11:17:14 +0100 Subject: [PATCH 22/32] copy descriptors as we are looping over them while modifying the mesh for DQQ --- .../internal/subdivision_hosts_impl_3.h | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index 6b26176615e..9ae118452be 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -280,19 +280,23 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; + typedef typename boost::graph_traits::face_descriptor face_descriptor; - typedef typename boost::graph_traits::vertex_iterator vertex_iterator; - typedef typename boost::graph_traits::edge_iterator edge_iterator; typedef typename boost::property_traits::value_type Point; - typename boost::graph_traits::vertices_size_type num_v = num_vertices(p); - typename boost::graph_traits::halfedges_size_type num_e = num_halfedges(p)/2; - typename boost::graph_traits::faces_size_type num_f = num_faces(p); + //First back up initial vertices/faces/edges + std::vector p_vertices(vertices(p).first, vertices(p).second); + std::vector p_faces(faces(p).first, faces(p).second); + std::vector p_edges(edges(p).first, edges(p).second); + + std::size_t num_v = p_vertices.size(); + std::size_t num_e = p_edges.size(); + std::size_t num_f = p_faces.size(); std::vector border_halfedges; size_t num_be = 0 ; - BOOST_FOREACH(edge_descriptor ed, edges(p)){ + BOOST_FOREACH(edge_descriptor ed, p_edges){ if(is_border(ed,p)){ ++num_be; border_halfedges.push_back(halfedge(ed,p)); @@ -301,10 +305,8 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { Point* point_buffer = new Point[num_e*2]; // Build the point_buffer - vertex_iterator vitr, vitr_end; - boost::tie(vitr,vitr_end) = vertices(p); int pi = 0; - BOOST_FOREACH(vertex_descriptor vd, vertices(p)){ + BOOST_FOREACH(vertex_descriptor vd, p_vertices){ BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_target(vd,p)){ if (! is_border(hd,p)){ mask.corner_node(hd, point_buffer[pi++]); @@ -317,7 +319,8 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { // Build the connectivity using insert_vertex() and insert_edge() pi = 0; - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v; ++i) { + typename std::vector::iterator vitr=p_vertices.begin(); + for (std::size_t i = 0; i < num_v; ++i) { vertex_descriptor vh = *vitr; ++vitr; @@ -347,7 +350,7 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { } } - edge_iterator eitr = edges(p).first; + typename std::vector::iterator eitr = p_edges.begin(); for (typename boost::graph_traits::edges_size_type i = 0; i < num_e; ++i) { halfedge_descriptor eh = halfedge(*eitr,p); ++eitr; @@ -382,7 +385,7 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { Euler::remove_face(ehe,p); } - vitr = vertices(p).first; + vitr = p_vertices.begin(); for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v-num_be; ++i) { vertex_descriptor vh = *vitr; ++vitr; From 68a7fbbe3ad7c49edd242eb886f2d304839bc0b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 11:20:17 +0100 Subject: [PATCH 23/32] use only one implementation for DQQ this is possible now as all the descriptors are first copied into internal vectors --- .../internal/subdivision_hosts_impl_3.h | 158 +----------------- 1 file changed, 1 insertion(+), 157 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index 9ae118452be..cc3934b1492 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -32,11 +32,8 @@ #include #include -#include #include -#include #include -#include #include #include @@ -276,7 +273,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // ====================================================================== template -void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { +void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; typedef typename boost::graph_traits::edge_descriptor edge_descriptor; @@ -395,159 +392,6 @@ void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_false) { delete []point_buffer; } -template -void DQQ_1step_impl(Poly& p, VertexPointMap vpm, Mask mask, CGAL::Tag_true) { - typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; - typedef typename boost::graph_traits::halfedge_descriptor halfedge_descriptor; - typedef typename boost::graph_traits::face_descriptor face_descriptor; - - typedef typename boost::property_traits::value_type Point; - - // Note that for types like 'Surface_mesh', num_vertices() and other similar functions - // return the TOTAL number of elements, which may include removed vertices. - typename boost::graph_traits::vertices_size_type num_v = num_vertices(p); - typename boost::graph_traits::edges_size_type num_e = num_edges(p); - typename boost::graph_traits::faces_size_type num_f = num_faces(p); - - // Move `p` into `moved_p`, and build the subdivided mesh from scratch in `p`. - // This is done to make the algorithm work with CGAL::Surface_mesh, - // even though CGAL::Surface_mesh does not insert elements at the end (due to removed elements). - // The DooSabin subdivision of a mesh is a completely different mesh so there - // is no additional cost to rebuild from scratch (but there is a bit from - // using `copy_face_graph`). - Poly moved_p; - reserve(moved_p,num_v, num_e, num_f); - - // We must use copy_face_graph rather than an assignement operator because - // we need the correspondence between vertex_descriptors - boost::unordered_map v2v(num_v); - CGAL::copy_face_graph(p, moved_p, std::inserter(v2v, v2v.end())); - - VertexPointMap moved_vpm = get(vertex_point, moved_p); - - // Move the position information to the internal property map of moved_p - typename boost::unordered_map::iterator it = v2v.begin(), - end = v2v.end(); - for(; it!=end; ++it) { - put(moved_vpm, it->second, get(vpm, it->first)); - } - - // Temporarily change the members of the mask to `moved_p` - mask.pmesh = &moved_p; - mask.vpm = moved_vpm; - - clear(p); - reserve(p,num_v+num_e+num_f, 2*num_e, (2+4+2)*num_e); - - // Correspondence between halfedges of the original mesh and some of the - // halfedges in the subdivided mesh. Since we have halfedge_index_t, - // we can simply use a vector! - // Note: need to make sure the halfedge index map is initialized - // @fixme this overwrites previous initilizations... - helpers::init_halfedge_indices(const_cast(moved_p), - get(boost::halfedge_index, moved_p)); - std::vector old_to_new(2 * num_e); - Property_map_binder::type, - typename Pointer_property_map::type> - hmap = bind_property_maps(get(boost::halfedge_index, moved_p), - make_property_map(old_to_new)); - - // Build new n-faces - BOOST_FOREACH(face_descriptor fd, faces(moved_p)) { - halfedge_descriptor hd = halfedge(fd, moved_p); - std::list vertices_of_new_face; - - // Keep the first outside; it will be used to build the correspondence - // between old and new halfedges - Point first_pt; - mask.corner_node(hd, first_pt); - vertex_descriptor first_v = add_vertex(p); - put(vpm, first_v, first_pt); - vertices_of_new_face.push_back(first_v); - - // Loop normally and add the rest of the vertices - halfedge_descriptor done = hd; - hd = next(hd, moved_p); - while(hd != done) { - Point pt; - mask.corner_node(hd, pt); - vertex_descriptor v = add_vertex(p); - put(vpm, v, pt); - vertices_of_new_face.push_back(v); - hd = next(hd, moved_p); - } - - face_descriptor new_face = Euler::add_face(vertices_of_new_face, p); - - // Find the starting halfedge in the new face that corresponds to halfedge(fd, p) - halfedge_descriptor nf_hd = halfedge(new_face, p); - while(target(nf_hd, p) != first_v) { - nf_hd = next(nf_hd, p); - } - - // Build the correspondence between old and new halfedges - hd = halfedge(fd, moved_p); - done = nf_hd; - do { - put(hmap, hd, nf_hd); - hd = next(hd, moved_p); - nf_hd = next(nf_hd, p); - } while (nf_hd != done); - } - - // Build new edge-faces - BOOST_FOREACH(halfedge_descriptor hd, halfedges(moved_p)) { - if(is_border(hd, moved_p)) - continue; - - halfedge_descriptor hd_opp = opposite(hd, moved_p); - if(is_border(hd_opp, moved_p)) - continue; - - if(hd > hd_opp) - continue; - - halfedge_descriptor new_hd = opposite(get(hmap, hd), p); - halfedge_descriptor new_hd_opp = opposite(get(hmap, hd_opp), p); - - boost::array v = {{source(new_hd, p), - target(new_hd, p), - source(new_hd_opp, p), - target(new_hd_opp, p)}}; - - Euler::add_face(v, p); - } - - // Build new vertex-faces - BOOST_FOREACH(vertex_descriptor vd, vertices(moved_p)) { - if(is_border(vd, moved_p)) - continue; - - halfedge_descriptor hd = halfedge(vd, moved_p); - halfedge_descriptor new_hd = opposite(get(hmap, hd), p); - halfedge_descriptor new_face_hd = opposite(prev(new_hd, p), p), done = new_face_hd; - std::list vertices_of_new_faces; - do { - vertices_of_new_faces.push_back(source(new_face_hd, p)); - new_face_hd = next(new_face_hd, p); - } while(new_face_hd != done); - - Euler::add_face(vertices_of_new_faces, p); - } - - // Reset the members of the mask - mask.pmesh = &p; - mask.vpm = vpm; -} - -template -void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { - // Check if halfedges are index-based, which allows to use vectors instead of maps - DQQ_1step_impl(p, vpm, mask, - boost::graph_has_property()); -// CGAL_postcondition(p.is_valid()); -} - // ====================================================================== template void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, From 471d996e335aad6b95090c90d582459da75ff70b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 11:24:01 +0100 Subject: [PATCH 24/32] remove paragraph no longer relevant --- .../doc/Subdivision_method_3/Subdivision_method_3.txt | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt index 901621151d0..1b0934c5d86 100644 --- a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt +++ b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt @@ -150,12 +150,6 @@ in the internal container are sequentially ordered (e.g. This implies that the iterators traverse the primitives in the order of their creations/insertions. -\attention The four subdivision techniques have been made to work with -`Surface_mesh` despite `Surface_mesh` not necessarily inserting new elements at -the end of its containers (see Section \ref sectionSurfaceMesh_properties of the -`Surface_mesh`). However, it is required that the `Surface_mesh` passed as input -is garbage-free, which can be achieved by first calling `Surface_mesh::collect_garbage()`. - Section \ref secRefHost gives detailed explanations on this two restrictions. From 2a90e40211d8ab73317d9ffa1eb2ca73304adc1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 14:26:35 +0100 Subject: [PATCH 25/32] add missing template parameters --- .../doc/Subdivision_method_3/Subdivision_method_3.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt index 1b0934c5d86..eb8b5397acc 100644 --- a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt +++ b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt @@ -181,7 +181,7 @@ three components of the Catmull-Clark subdivision method. \code{.cpp} -template +template void PQQ(PolygonMesh& p, Mask mask, NamedParameters np) \endcode @@ -327,16 +327,16 @@ and \f$ \sqrt{3}\f$ subdivision. \code{.cpp} namespace Subdivision_method_3 { -template +template void PQQ(PolygonMesh& pmesh, Mask mask, NamedParameters np); -template +template void PTQ(PolygonMesh& pmesh, Mask mask, NamedParameters np); -template +template void DQQ(PolygonMesh& pmesh, Mask mask, NamedParameters np) -template +template void Sqrt3(PolygonMesh& pmesh, Mask mask, NamedParameters np) } From eac197b2cb3fdd14b3fb166ada7e103dac016d29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 14:30:28 +0100 Subject: [PATCH 26/32] fix type --- .../include/CGAL/Subdivision_method_3/subdivision_masks_3.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h index 7dc4ebaba5b..2ae091c8a57 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h @@ -577,12 +577,12 @@ public: /// computes the \f$ \sqrt{3}\f$ vertex-point `pt` of the vertex `vd`. void vertex_node(vertex_descriptor vertex, Point& pt) { Halfedge_around_target_circulator vcir(vertex, *(this->pmesh)); - const size_t n = degree(vertex, *(this->pmesh)); + const typename boost::graph_traits::degree_size_type n = degree(vertex, *(this->pmesh)); const FT a = (FT) ((4.0-2.0*std::cos(2.0*CGAL_PI/(double)n))/9.0); Vector cv = ((FT)(1.0-a)) * (get(this->vpmap, vertex) - CGAL::ORIGIN); - for (size_t i = 1; i <= n; ++i, --vcir) { + for (typename boost::graph_traits::degree_size_type i = 1; i <= n; ++i, --vcir) { cv = cv + (a/FT(n))*(get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh)))-CGAL::ORIGIN); } From 6342f9a732de0da46a4aca46dd0cddcdd738d1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 14:41:41 +0100 Subject: [PATCH 27/32] fix remaining point reference --- .../Subdivision_method_3.txt | 18 ++++---- .../Customized_subdivision.cpp | 23 +++++----- .../subdivision_masks_3.h | 46 ++++++++++--------- .../test_Subdivision_method_3.cpp | 2 +- 4 files changed, 46 insertions(+), 43 deletions(-) diff --git a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt index eb8b5397acc..48a87621908 100644 --- a/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt +++ b/Subdivision_method_3/doc/Subdivision_method_3/Subdivision_method_3.txt @@ -251,8 +251,8 @@ class CatmullClark_mask_3 { }; void edge_node(halfedge_descriptor edge, Point_3& pt) { - Point_3& p1 = get(vpm,target(edge, pmesh)); - Point_3& p2 = get(vpm,source(edge, pmesh)); + Point_3 p1 = get(vpm,target(edge, pmesh)); + Point_3 p2 = get(vpm,source(edge, pmesh)); Point_3 f1, f2; face_node(face(edge,pmesh), f1); face_node(face(opposite(edge,pmesh),pmesh), f2); @@ -266,11 +266,11 @@ class CatmullClark_mask_3 { typename boost::graph_traits::degree_size_type n = degree(vertex,pmesh); FT Q[] = {0.0, 0.0, 0.0}, R[] = {0.0, 0.0, 0.0}; - Point_3& S = get(vpm,vertex); + Point_3 S = get(vpm,vertex); Point_3 q; for (int i = 0; i < n; i++, ++vcir) { - Point_3& p2 = get(vpm, target(opposite(*vcir,pmesh),pmesh)); + Point_3 p2 = get(vpm, target(opposite(*vcir,pmesh),pmesh)); R[0] += (S[0]+p2[0])/2; R[1] += (S[1]+p2[1])/2; R[2] += (S[2]+p2[2])/2; @@ -454,15 +454,15 @@ is listed below, where `ept` returns the new point splitting \code{.cpp} void border_node(halfedge_descriptor edge, Point_3& ept, Point_3& vpt) { - Point_3& ep1 = get(vpm, target(edge, pmesh)); - Point_3& ep2 = get(vpm, target(opposite(edge, pmesh), pmesh)); + Point_3 ep1 = get(vpm, target(edge, pmesh)); + Point_3 ep2 = get(vpm, target(opposite(edge, pmesh), pmesh)); ept = Point_3((ep1[0]+ep2[0])/2, (ep1[1]+ep2[1])/2, (ep1[2]+ep2[2])/2); Halfedge_around_target_circulator vcir(edge, pmesh); - Point_3& vp1 = get(vpm,target(opposite(*vcir, pmesh ), pmesh)); - Point_3& vp0 = get(vpm, target(*vcir, pmesh)); + Point_3 vp1 = get(vpm,target(opposite(*vcir, pmesh ), pmesh)); + Point_3 vp0 = get(vpm, target(*vcir, pmesh)); --vcir; - Point_3& vp_1 = get(vpm, target(opposite(*vcir, pmesh), pmesh)); + Point_3 vp_1 = get(vpm, target(opposite(*vcir, pmesh), pmesh)); vpt = Point_3((vp_1[0] + 6*vp0[0] + vp1[0])/8, (vp_1[1] + 6*vp0[1] + vp1[1])/8, (vp_1[2] + 6*vp0[2] + vp1[2])/8 ); diff --git a/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp b/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp index 40c3fde25c8..dc93f81bc89 100644 --- a/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp +++ b/Subdivision_method_3/examples/Subdivision_method_3/Customized_subdivision.cpp @@ -28,6 +28,7 @@ class WLoop_mask_3 { typedef typename boost::property_map::type Vertex_pmap; typedef typename boost::property_traits::value_type Point; + typedef typename boost::property_traits::reference Point_ref; PolygonMesh& pmesh; Vertex_pmap vpm; @@ -38,10 +39,10 @@ public: {} void edge_node(halfedge_descriptor hd, Point& pt) { - Point& p1 = get(vpm, target(hd,pmesh)); - Point& p2 = get(vpm, target(opposite(hd,pmesh),pmesh)); - Point& f1 = get(vpm, target(next(hd,pmesh),pmesh)); - Point& f2 = get(vpm, target(next(opposite(hd,pmesh),pmesh),pmesh)); + Point_ref p1 = get(vpm, target(hd,pmesh)); + Point_ref p2 = get(vpm, target(opposite(hd,pmesh),pmesh)); + Point_ref f1 = get(vpm, target(next(hd,pmesh),pmesh)); + Point_ref f2 = get(vpm, target(next(opposite(hd,pmesh),pmesh),pmesh)); pt = Point((3*(p1[0]+p2[0])+f1[0]+f2[0])/8, (3*(p1[1]+p2[1])+f1[1]+f2[1])/8, @@ -49,12 +50,12 @@ public: } void vertex_node(vertex_descriptor vd, Point& pt) { double R[] = {0.0, 0.0, 0.0}; - Point& S = get(vpm,vd); + Point_ref S = get(vpm,vd); std::size_t n = 0; BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_target(vd, pmesh)){ ++n; - Point& p = get(vpm, target(opposite(hd,pmesh),pmesh)); + Point_ref p = get(vpm, target(opposite(hd,pmesh),pmesh)); R[0] += p[0]; R[1] += p[1]; R[2] += p[2]; } @@ -72,15 +73,15 @@ public: } void border_node(halfedge_descriptor hd, Point& ept, Point& vpt) { - Point& ep1 = get(vpm, target(hd,pmesh)); - Point& ep2 = get(vpm, target(opposite(hd,pmesh),pmesh)); + Point_ref ep1 = get(vpm, target(hd,pmesh)); + Point_ref ep2 = get(vpm, target(opposite(hd,pmesh),pmesh)); ept = Point((ep1[0]+ep2[0])/2, (ep1[1]+ep2[1])/2, (ep1[2]+ep2[2])/2); Halfedge_around_target_circulator vcir(hd,pmesh); - Point& vp1 = get(vpm, target(opposite(*vcir,pmesh),pmesh)); - Point& vp0 = get(vpm, target(*vcir,pmesh)); + Point_ref vp1 = get(vpm, target(opposite(*vcir,pmesh),pmesh)); + Point_ref vp0 = get(vpm, target(*vcir,pmesh)); --vcir; - Point& vp_1 = get(vpm,target(opposite(*vcir,pmesh),pmesh)); + Point_ref vp_1 = get(vpm,target(opposite(*vcir,pmesh),pmesh)); vpt = Point((vp_1[0] + 6*vp0[0] + vp1[0])/8, (vp_1[1] + 6*vp0[1] + vp1[1])/8, (vp_1[2] + 6*vp0[2] + vp1[2])/8 ); diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h index 2ae091c8a57..a10bf7415a4 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/subdivision_masks_3.h @@ -118,8 +118,8 @@ public: } void edge_node(halfedge_descriptor edge, Point& pt) { - const Point_ref p1 = get(this->vpmap, target(edge, *(this->pmesh))); - const Point_ref p2 = get(this->vpmap, source(edge, *(this->pmesh))); + Point_ref p1 = get(this->vpmap, target(edge, *(this->pmesh))); + Point_ref p2 = get(this->vpmap, source(edge, *(this->pmesh))); pt = Point((p1[0]+p2[0])/2, (p1[1]+p2[1])/2, (p1[2]+p2[2])/2); } @@ -200,8 +200,8 @@ public: /// computes the Catmull-Clark edge-point `pt` of the edge `edge`. void edge_node(halfedge_descriptor edge, Point& pt) { - const Point& p1 = get(this->vpmap,target(edge, *(this->pmesh))); - const Point& p2 = get(this->vpmap,source(edge, *(this->pmesh))); + Point_ref p1 = get(this->vpmap,target(edge, *(this->pmesh))); + Point_ref p2 = get(this->vpmap,source(edge, *(this->pmesh))); Point f1, f2; this->face_node(face(edge, *(this->pmesh)), f1); this->face_node(face(opposite(edge, *(this->pmesh)), *(this->pmesh)), f2); @@ -216,11 +216,11 @@ public: typename boost::graph_traits::degree_size_type n = degree(vertex, *(this->pmesh)); FT Q[] = {0.0, 0.0, 0.0}, R[] = {0.0, 0.0, 0.0}; - const Point_ref S = get(this->vpmap,vertex); + Point_ref S = get(this->vpmap,vertex); Point q; for (typename boost::graph_traits::degree_size_type i = 0; i < n; i++, ++vcir) { - const Point& p2 = get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); + Point_ref p2 = get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); R[0] += (S[0] + p2[0]) / 2; R[1] += (S[1] + p2[1]) / 2; R[2] += (S[2] + p2[2]) / 2; @@ -240,15 +240,15 @@ public: /// computes the Catmull-Clark edge-point `ept` and the Catmull-Clark /// vertex-point `vpt` of the border edge `edge`. void border_node(halfedge_descriptor edge, Point& ept, Point& vpt) { - const Point& ep1 = get(this->vpmap,target(edge, *(this->pmesh))); - const Point& ep2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); + Point_ref ep1 = get(this->vpmap,target(edge, *(this->pmesh))); + Point_ref ep2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); ept = Point((ep1[0]+ep2[0])/2, (ep1[1]+ep2[1])/2, (ep1[2]+ep2[2])/2); Halfedge_around_target_circulator vcir(edge, *(this->pmesh)); - const Point& vp1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); - const Point& vp0 = get(this->vpmap, target(*vcir, *(this->pmesh))); + Point_ref vp1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); + Point_ref vp0 = get(this->vpmap, target(*vcir, *(this->pmesh))); --vcir; - const Point& vp_1 = get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); + Point_ref vp_1 = get(this->vpmap, target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); vpt = Point((vp_1[0] + 6*vp0[0] + vp1[0])/8, (vp_1[1] + 6*vp0[1] + vp1[1])/8, (vp_1[2] + 6*vp0[2] + vp1[2])/8 ); @@ -299,6 +299,7 @@ public: typedef typename Base::FT FT; typedef typename Base::Point Point; typedef typename Base::Vector Vector; + typedef typename boost::property_traits::reference Point_ref; #endif typedef Halfedge_around_face_circulator Halfedge_around_facet_circulator; @@ -326,10 +327,10 @@ public: /// computes the Loop edge-point `pt` of the edge `edge`. void edge_node(halfedge_descriptor edge, Point& pt) { - const Point& p1 = get(this->vpmap,target(edge, *(this->pmesh))); - const Point& p2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); - const Point& f1 = get(this->vpmap,target(next(edge, *(this->pmesh)), *(this->pmesh))); - const Point& f2 = get(this->vpmap,target(next(opposite(edge, *(this->pmesh)), *(this->pmesh)), *(this->pmesh))); + Point_ref p1 = get(this->vpmap,target(edge, *(this->pmesh))); + Point_ref p2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); + Point_ref f1 = get(this->vpmap,target(next(edge, *(this->pmesh)), *(this->pmesh))); + Point_ref f2 = get(this->vpmap,target(next(opposite(edge, *(this->pmesh)), *(this->pmesh)), *(this->pmesh))); pt = Point((3*(p1[0]+p2[0])+f1[0]+f2[0])/8, (3*(p1[1]+p2[1])+f1[1]+f2[1])/8, @@ -342,10 +343,10 @@ public: size_t n = circulator_size(vcir); FT R[] = {0.0, 0.0, 0.0}; - const Point& S = get(this->vpmap,vertex); + Point_ref S = get(this->vpmap,vertex); for (size_t i = 0; i < n; i++, ++vcir) { - const Point& p = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); + Point_ref p = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); R[0] += p[0]; R[1] += p[1]; R[2] += p[2]; } if (n == 6) { @@ -364,15 +365,15 @@ public: /// computes the Loop edge-point `ept` and the Loop vertex-point `vpt` of the border edge `edge`. void border_node(halfedge_descriptor edge, Point& ept, Point& vpt) { - const Point& ep1 = get(this->vpmap,target(edge, *(this->pmesh))); - const Point& ep2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); + Point_ref ep1 = get(this->vpmap,target(edge, *(this->pmesh))); + Point_ref ep2 = get(this->vpmap,target(opposite(edge, *(this->pmesh)), *(this->pmesh))); ept = Point((ep1[0]+ep2[0])/2, (ep1[1]+ep2[1])/2, (ep1[2]+ep2[2])/2); Halfedge_around_vertex_circulator vcir(edge, *(this->pmesh)); - const Point& vp1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh) ), *(this->pmesh))); - const Point& vp0 = get(this->vpmap,target(*vcir, *(this->pmesh))); + Point_ref vp1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh) ), *(this->pmesh))); + Point_ref vp0 = get(this->vpmap,target(*vcir, *(this->pmesh))); --vcir; - const Point& vp_1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); + Point_ref vp_1 = get(this->vpmap,target(opposite(*vcir, *(this->pmesh)), *(this->pmesh))); vpt = Point((vp_1[0] + 6*vp0[0] + vp1[0])/8, (vp_1[1] + 6*vp0[1] + vp1[1])/8, (vp_1[2] + 6*vp0[2] + vp1[2])/8 ); @@ -460,6 +461,7 @@ public: typedef typename Base::FT FT; typedef typename Base::Point Point; typedef typename Base::Vector Vector; + typedef typename boost::property_traits::reference Point_ref; #endif public: diff --git a/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp b/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp index b0b18514ded..9250848883a 100644 --- a/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp +++ b/Subdivision_method_3/test/Subdivision_method_3/test_Subdivision_method_3.cpp @@ -338,7 +338,7 @@ void test_Subdivision_surface_3_SM_NP() { // some arbitrary new coordinates (different from the internal vpm) BOOST_FOREACH(vertex_descriptor vd, vertices(P)) { - const Point& pt = get(vpm, vd); + boost::property_traits::reference pt = get(vpm, vd); Vector v = pt - Point(0., 0., -3.); put(apm, vd, pt + 0.5*v); } From f7569e661318b102887782d21cb9a690745b3fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 12 Dec 2017 17:11:18 +0100 Subject: [PATCH 28/32] make no assumption on the position of border vertices --- .../internal/subdivision_hosts_impl_3.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index cc3934b1492..5a836298e87 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -303,12 +303,17 @@ void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // Build the point_buffer int pi = 0; + int vi=0; + std::vector is_border_vertex(num_v, false); BOOST_FOREACH(vertex_descriptor vd, p_vertices){ BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_target(vd,p)){ if (! is_border(hd,p)){ mask.corner_node(hd, point_buffer[pi++]); } + else + is_border_vertex[vi]=true; } + ++vi; } // Reserve to avoid rellocations during insertions @@ -365,7 +370,7 @@ void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } } - // After this point, the original border edges are in front! + BOOST_FOREACH(halfedge_descriptor eeh, border_halfedges){ halfedge_descriptor eh = eeh; if (is_border(eh,p)){ @@ -383,10 +388,11 @@ void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } vitr = p_vertices.begin(); - for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v-num_be; ++i) { + for (typename boost::graph_traits::vertices_size_type i = 0; i < num_v; ++i) { vertex_descriptor vh = *vitr; ++vitr; - Euler::remove_center_vertex(halfedge(vh,p),p); + if (!is_border_vertex[i]) + Euler::remove_center_vertex(halfedge(vh,p),p); } delete []point_buffer; From 8def8ba0f4dda2ebfa617d31727f7d393102744c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 13 Dec 2017 10:09:06 +0100 Subject: [PATCH 29/32] remove unused variable --- .../Subdivision_method_3/internal/subdivision_hosts_impl_3.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index 5a836298e87..8ef063e44a3 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -292,10 +292,8 @@ void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { std::size_t num_f = p_faces.size(); std::vector border_halfedges; - size_t num_be = 0 ; BOOST_FOREACH(edge_descriptor ed, p_edges){ if(is_border(ed,p)){ - ++num_be; border_halfedges.push_back(halfedge(ed,p)); } } From c2ae22d2d14aaffe3170d1da98a5e34b465845d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 14 Dec 2017 10:31:18 +0100 Subject: [PATCH 30/32] fix conversion warnings --- .../internal/subdivision_hosts_impl_3.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h index 8ef063e44a3..f0fdc5dc867 100644 --- a/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h +++ b/Subdivision_method_3/include/CGAL/Subdivision_method_3/internal/subdivision_hosts_impl_3.h @@ -45,6 +45,16 @@ namespace Subdivision_method_3 { namespace internal { +template +void call_reserve(PolygonMesh& pm, std::size_t v, std::size_t e, std::size_t f) +{ + typedef boost::graph_traits GT; + reserve(pm, + static_cast(v), + static_cast(e), + static_cast(f)); +} + template void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; @@ -73,7 +83,7 @@ void PQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // of the corresponding iterator to the begin of the iterator. // We need to reserve the memory to prevent reallocation. - reserve(p,num_v+num_e+num_f, 4*2*num_e, 4*num_e/2); + call_reserve(p,num_v+num_e+num_f, 4*2*num_e, 4*num_e/2); typedef typename boost::property_traits::value_type Point; @@ -196,7 +206,7 @@ void PTQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { // of the corresponding iterator to the begin of the iterator. // We need to reserve the memory to prevent reallocation. - reserve(p,num_v + num_e, 2*2*num_e, 4*num_e/2); + call_reserve(p,num_v + num_e, 2*2*num_e, 4*num_e/2); Point* vertex_point_buffer = new Point[num_v + num_e]; Point* edge_point_buffer = vertex_point_buffer + num_v; @@ -315,7 +325,7 @@ void DQQ_1step(Poly& p, VertexPointMap vpm, Mask mask) { } // Reserve to avoid rellocations during insertions - reserve(p,num_v+num_e+num_f, 2*num_e, (2+4+2)*num_e); + call_reserve(p,num_v+num_e+num_f, 2*num_e, (2+4+2)*num_e); // Build the connectivity using insert_vertex() and insert_edge() pi = 0; @@ -433,7 +443,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, Point* cpt = new Point[new_pts_size]; // size of the subdivided mesh - reserve(p,num_v + new_pts_size, (num_e + 2*num_f + new_pts_size)*2, 3*num_f); + call_reserve(p,num_v + new_pts_size, (num_e + 2*num_f + new_pts_size)*2, 3*num_f); // keep in memory whether a face is incident to the border and, if so, which // halfedge corresponds to THE (there can only be one) border edge. From c55d75ede896f3dce1849ed41ee918681d22d06f Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Fri, 15 Dec 2017 10:24:11 +0100 Subject: [PATCH 31/32] sq_circumradius cannot be computed on an infinite facet there was no need to check if a face is in domain, but we still need to check whether it is infinite --- Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h b/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h index 43d2f09438a..f7a6fd309e4 100644 --- a/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h +++ b/Mesh_2/include/CGAL/Mesh_2/Mesh_global_optimizer_2.h @@ -307,7 +307,8 @@ private: // Find the minimum value do { - min_sqr = (std::min)(min_sqr, sq_circumradius(face)); + if (!cdt_.is_infinite(face)) + min_sqr = (std::min)(min_sqr, sq_circumradius(face)); face++; } while(face != end); From 22d5a5b884ee64c265e702b85e7aaacac6dffff9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 15 Dec 2017 10:45:25 +0100 Subject: [PATCH 32/32] Fix Convex_hull_3 quickhull, with coplanar point `CGAL::convex_hull_3` documents that the output is a triangulation polyhedron. That is true... but for coplanar input points! In case of coplanar input point, the output before this patch was a polyhedron with a single polygonal face. The patch triangulates the face using a pivot point and Euler operations. --- Convex_hull_3/include/CGAL/convex_hull_3.h | 17 +++++++++++++++-- .../test/Convex_hull_3/quickhull_test_3.cpp | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Convex_hull_3/include/CGAL/convex_hull_3.h b/Convex_hull_3/include/CGAL/convex_hull_3.h index 7eb685447d7..5e4c96b774a 100644 --- a/Convex_hull_3/include/CGAL/convex_hull_3.h +++ b/Convex_hull_3/include/CGAL/convex_hull_3.h @@ -315,13 +315,26 @@ void coplanar_3_hull(InputIterator first, InputIterator beyond, typename boost::property_map::type vpm = get(CGAL::vertex_point, P); - std::vector::vertex_descriptor> vertices; + typedef boost::graph_traits Graph_traits; + typedef typename Graph_traits::vertex_descriptor vertex_descriptor; + typedef typename Graph_traits::halfedge_descriptor halfedge_descriptor; + typedef typename Graph_traits::face_descriptor face_descriptor; + std::vector vertices; vertices.reserve(CH_2.size()); BOOST_FOREACH(const Point_3& p, CH_2){ vertices.push_back(add_vertex(P)); put(vpm, vertices.back(),p); } - Euler::add_face(vertices, P); + face_descriptor f = Euler::add_face(vertices, P); + + // Then triangulate that face + const halfedge_descriptor he = halfedge(f, P); + halfedge_descriptor other_he = next(next(he, P), P); + for(std::size_t i = 3, end = vertices.size(); i < end; ++i) { + const halfedge_descriptor next_he = next(other_he, P); + Euler::split_face(other_he, he, P); + other_he = next_he; + } } diff --git a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp index c5c4f22a255..61756f28d79 100644 --- a/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp +++ b/Convex_hull_3/test/Convex_hull_3/quickhull_test_3.cpp @@ -106,6 +106,22 @@ void test_small_hull() polyhedron2.size_of_facets() == 6 ); } +void test_coplanar_hull() +{ + std::vector points; + points.push_back(Point_3(0,0,0)); + points.push_back(Point_3(1,0,0)); + points.push_back(Point_3(0,1,0)); + points.push_back(Point_3(1,1,0)); + points.push_back(Point_3(1.5,0.5,0)); + points.push_back(Point_3(0.5,1.1,0)); + Polyhedron_3 polyhedron; + CGAL::convex_hull_3(points.begin(), points.end(), polyhedron, Traits()); + assert( polyhedron.is_valid() ); + assert( polyhedron.size_of_facets() == 4 ); + assert( polyhedron.is_pure_triangle() ); +} + int main() { @@ -115,6 +131,8 @@ int main() test_tetrahedron_convexity(); std::cerr << "Testing small hull" << std::endl; test_small_hull(); + std::cerr << "Testing coplanar hull" << std::endl; + test_coplanar_hull(); std::cerr << "Testing 500 random points" << std::endl; std::vector points;