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
This commit is contained in:
Sébastien Loriot 2017-09-07 15:57:45 +02:00
parent b750ca7f0f
commit c3833d0fb0
3 changed files with 16 additions and 40 deletions

View File

@ -55,10 +55,11 @@ of the vertex `vd`.
void vertex_node(vertex_descriptor vd, Point& pt); void vertex_node(vertex_descriptor vd, Point& pt);
/*! /*!
computes the subdivided points `ept` and `vpt` based on the neighborhood computes the subdivided points `ept1` and `ept2` based on the neighborhood
of the border halfedge `hd`. 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);
/// @} /// @}

View File

@ -581,6 +581,7 @@ void Sqrt3_1step(Poly& p, VertexPointMap vpm, Mask mask,
// halfedge corresponds to THE (there can only be one) border edge. // halfedge corresponds to THE (there can only be one) border edge.
std::vector<halfedge_descriptor> face_halfedge_border(num_f, std::vector<halfedge_descriptor> face_halfedge_border(num_f,
boost::graph_traits<Poly>::null_halfedge()); boost::graph_traits<Poly>::null_halfedge());
std::list<std::pair<vertex_descriptor, Point> > new_positions;
// compute the positions of new points // compute the positions of new points
std::size_t i = 0; 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)) { BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(halfedge(fd, p), p)) {
if(is_border(opposite(hd, p),p)) { if(is_border(opposite(hd, p),p)) {
face_halfedge_border[face_id] = hd; face_halfedge_border[face_id] = hd;
halfedge_descriptor bhd = opposite(hd, p); Point vpt;
mask.border_node(bhd, cpt[i], cpt[i+1]); mask.border_node(hd, cpt[i+1], cpt[i], vpt);
new_positions.push_back(std::make_pair(target(hd,p), vpt));
i += 2; i += 2;
// the border subdivision is only performed every second subdivision // 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 // smooth the position of existing vertices
std::list<std::pair<vertex_descriptor, Point> > new_positions;
BOOST_FOREACH(vertex_descriptor vd, vertices(p)){ BOOST_FOREACH(vertex_descriptor vd, vertices(p)){
Point pt; Point pt;
if(!is_border(vd, p)) { 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 // actually inserts the new positions in the vertex point property map
typename std::list<std::pair<vertex_descriptor, Point> >::iterator it = new_positions.begin(), typename std::list<std::pair<vertex_descriptor, Point> >::iterator it = new_positions.begin(),
end = new_positions.end(); end = new_positions.end();

View File

@ -585,11 +585,13 @@ public:
pt = CGAL::ORIGIN + cv; 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 <em>single</em> /// \attention Border subdivision only happens every second step of a <em>single</em>
/// successive \f$ \sqrt{3}\f$ subdivision (thus requiring a depth larger than 1). /// successive \f$ \sqrt{3}\f$ subdivision (thus requiring a depth larger than 1).
void border_node(halfedge_descriptor bhd, Point& ept, Point& vpt) { void border_node(halfedge_descriptor hd, Point& ept1, Point& ept2, Point& vpt) {
// this function takes a BORDER halfedge // this function takes the opposite of a BORDER halfedge
halfedge_descriptor bhd = opposite(hd, *(this->pmesh));
CGAL_precondition(is_border(bhd, *(this->pmesh))); CGAL_precondition(is_border(bhd, *(this->pmesh)));
vertex_descriptor prev_s = source(prev(bhd, *(this->pmesh)), *(this->pmesh)); vertex_descriptor prev_s = source(prev(bhd, *(this->pmesh)), *(this->pmesh));
Vector prev_sv = get(this->vpmap, prev_s) - CGAL::ORIGIN; 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; Vector next_tv = get(this->vpmap, next_t) - CGAL::ORIGIN;
const FT denom = 1./27.; const FT denom = 1./27.;
ept = CGAL::ORIGIN + denom * ( 10.*sv + 16.*tv + next_tv ); ept1 = CGAL::ORIGIN + denom * ( prev_sv + 16.*sv + 10.*tv );
vpt = 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 );
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 );
} }
}; };