From c3833d0fb0e12fd734c4223fe664f5a7f0caf5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 7 Sep 2017 15:57:45 +0200 Subject: [PATCH] update border_node for Sqrt3 only one function that computes the coordinates of the interior points and the update of the target vertex. We also make the function consistant with other masks by requesting a non boundary halfedge --- .../Concepts/Sqrt3Mask_3.h | 7 ++--- .../internal/subdivision_hosts_impl_3.h | 22 +++------------ .../subdivision_masks_3.h | 27 ++++++------------- 3 files changed, 16 insertions(+), 40 deletions(-) diff --git a/Subdivision_method_3/doc/Subdivision_method_3/Concepts/Sqrt3Mask_3.h b/Subdivision_method_3/doc/Subdivision_method_3/Concepts/Sqrt3Mask_3.h index 7f41d4512c6..677bfa0a717 100644 --- a/Subdivision_method_3/doc/Subdivision_method_3/Concepts/Sqrt3Mask_3.h +++ b/Subdivision_method_3/doc/Subdivision_method_3/Concepts/Sqrt3Mask_3.h @@ -55,10 +55,11 @@ of the vertex `vd`. void vertex_node(vertex_descriptor vd, Point& pt); /*! -computes the subdivided points `ept` and `vpt` based on the neighborhood -of the border halfedge `hd`. +computes the subdivided points `ept1` and `ept2` based on the neighborhood +of the halfedge `hd` (which opposite is on the border), as well as the updated +position `vpt` of its target vertex. Along `hd`, `ept1` is before `ept2`. */ -void border_node(halfedge_descriptor hd, Point& ept, Point& vpt); +void border_node(halfedge_descriptor hd, Point& ept1, Point& ept2, Point& vpt); /// @} 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 08e886e939b..6167dba55c9 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 @@ -581,6 +581,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, // halfedge corresponds to THE (there can only be one) border edge. std::vector face_halfedge_border(num_f, boost::graph_traits::null_halfedge()); + std::list > new_positions; // compute the positions of new points std::size_t i = 0; @@ -591,8 +592,9 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(halfedge(fd, p), p)) { if(is_border(opposite(hd, p),p)) { face_halfedge_border[face_id] = hd; - halfedge_descriptor bhd = opposite(hd, p); - mask.border_node(bhd, cpt[i], cpt[i+1]); + Point vpt; + mask.border_node(hd, cpt[i+1], cpt[i], vpt); + new_positions.push_back(std::make_pair(target(hd,p), vpt)); i += 2; // the border subdivision is only performed every second subdivision @@ -611,7 +613,6 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, } // smooth the position of existing vertices - std::list > new_positions; BOOST_FOREACH(vertex_descriptor vd, vertices(p)){ Point pt; if(!is_border(vd, p)) { @@ -640,21 +641,6 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask, } } - if(refine_border) { - // collect the new positions for border vertices - BOOST_FOREACH(halfedge_descriptor hd, halfedges(p)) { - // switch to the border halfedge - hd = opposite(hd, p); - if(!is_border(hd, p)) - continue; - - Point pt; - mask.border_node(hd, pt); - vertex_descriptor vd = target(hd, p); - new_positions.push_back(std::make_pair(vd, pt)); - } - } - // actually inserts the new positions in the vertex point property map typename std::list >::iterator it = new_positions.begin(), end = new_positions.end(); 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 5ceb2588b01..322539f5d43 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 @@ -585,11 +585,13 @@ public: pt = CGAL::ORIGIN + cv; } - /// computes the \f$ \sqrt{3}\f$ edge-points `ept` and `vpt` of the halfedge `hd`. + /// computes the \f$ \sqrt{3}\f$ edge-points `ept1` and `ept2` of the halfedge `hd`, + /// as well as the updated point for its target vertex. /// \attention Border subdivision only happens every second step of a single /// successive \f$ \sqrt{3}\f$ subdivision (thus requiring a depth larger than 1). - void border_node(halfedge_descriptor bhd, Point& ept, Point& vpt) { - // this function takes a BORDER halfedge + void border_node(halfedge_descriptor hd, Point& ept1, Point& ept2, Point& vpt) { + // this function takes the opposite of a BORDER halfedge + halfedge_descriptor bhd = opposite(hd, *(this->pmesh)); CGAL_precondition(is_border(bhd, *(this->pmesh))); vertex_descriptor prev_s = source(prev(bhd, *(this->pmesh)), *(this->pmesh)); Vector prev_sv = get(this->vpmap, prev_s) - CGAL::ORIGIN; @@ -604,22 +606,9 @@ public: Vector next_tv = get(this->vpmap, next_t) - CGAL::ORIGIN; const FT denom = 1./27.; - ept = CGAL::ORIGIN + denom * ( 10.*sv + 16.*tv + next_tv ); - vpt = CGAL::ORIGIN + denom * ( prev_sv + 16.*sv + 10.*tv ); - } - - void border_node(halfedge_descriptor bhd, Point& pt) { - // this function takes a BORDER halfedge - CGAL_precondition(is_border(bhd, *(this->pmesh))); - - vertex_descriptor s = source(bhd, *(this->pmesh)); - Vector sv = get(this->vpmap, s) - CGAL::ORIGIN; - vertex_descriptor c = target(bhd, *(this->pmesh)); - Vector cv = get(this->vpmap, c) - CGAL::ORIGIN; - vertex_descriptor n = target(next(bhd, *(this->pmesh)), *(this->pmesh)); - Vector nv = get(this->vpmap, n) - CGAL::ORIGIN; - - pt = CGAL::ORIGIN + 1./27. * ( 4*sv + 19*cv + 4*nv ); + ept1 = CGAL::ORIGIN + denom * ( prev_sv + 16.*sv + 10.*tv ); + ept2 = CGAL::ORIGIN + denom * ( 10.*sv + 16.*tv + next_tv ); + vpt = CGAL::ORIGIN + 1./27. * ( 4*prev_sv + 19*sv + 4*tv ); } };