mirror of https://github.com/CGAL/cgal
use BGL free functions
This commit is contained in:
parent
4b18039316
commit
ba9c3678a6
|
|
@ -40,7 +40,7 @@ public:
|
||||||
typedef typename boost::graph_traits<TriangularPolyhedralSurface>::vertex_descriptor Vertex_const_handle;
|
typedef typename boost::graph_traits<TriangularPolyhedralSurface>::vertex_descriptor Vertex_const_handle;
|
||||||
typedef typename boost::graph_traits<TriangularPolyhedralSurface>::halfedge_descriptor Halfedge_const_handle;
|
typedef typename boost::graph_traits<TriangularPolyhedralSurface>::halfedge_descriptor Halfedge_const_handle;
|
||||||
|
|
||||||
T_Gate(const Vertex_const_handle v, const Halfedge_const_handle he);
|
T_Gate(FT d, const Halfedge_const_handle he);
|
||||||
FT& d() { return m_d;}
|
FT& d() { return m_d;}
|
||||||
const FT d() const { return m_d;}
|
const FT d() const { return m_d;}
|
||||||
const Halfedge_const_handle he() { return m_he;}
|
const Halfedge_const_handle he() { return m_he;}
|
||||||
|
|
@ -52,22 +52,10 @@ private:
|
||||||
|
|
||||||
//////////////IMPLEMENTATION//////////////////////////
|
//////////////IMPLEMENTATION//////////////////////////
|
||||||
template < class TriangularPolyhedralSurface >
|
template < class TriangularPolyhedralSurface >
|
||||||
T_Gate<TriangularPolyhedralSurface>::T_Gate(const Vertex_const_handle v,
|
T_Gate<TriangularPolyhedralSurface>::T_Gate(FT d,
|
||||||
const Halfedge_const_handle he)
|
const Halfedge_const_handle he)
|
||||||
: m_he(he)
|
: m_d(d), m_he(he)
|
||||||
{
|
{}
|
||||||
Point_3 p0 = v->point(),
|
|
||||||
p1 = he->vertex()->point(),
|
|
||||||
p2 = he->next()->vertex()->point(),
|
|
||||||
p3 = he->prev()->vertex()->point();
|
|
||||||
Vector_3 p0p1 = p0 - p1,
|
|
||||||
p0p2 = p0 - p2,
|
|
||||||
p0p3 = p0 - p3;
|
|
||||||
FT d1 = p0p1*p0p1,
|
|
||||||
d2 = p0p2*p0p2,
|
|
||||||
d3 = p0p3*p0p3;
|
|
||||||
m_d = CGAL::sqrt( (std::max)( (std::max)(d1,d2), d3) );
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// functor for priority queue
|
// functor for priority queue
|
||||||
|
|
@ -88,7 +76,8 @@ struct compare_gates
|
||||||
//class Gate and the functor compare_gates for the definition of a
|
//class Gate and the functor compare_gates for the definition of a
|
||||||
//priority queue
|
//priority queue
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
template < class TriangularPolyhedralSurface > class T_PolyhedralSurf_neighbors
|
template < class TriangularPolyhedralSurface >
|
||||||
|
class T_PolyhedralSurf_neighbors
|
||||||
{
|
{
|
||||||
const TriangularPolyhedralSurface& P;
|
const TriangularPolyhedralSurface& P;
|
||||||
public:
|
public:
|
||||||
|
|
@ -123,6 +112,24 @@ public:
|
||||||
//vertex tags is_visited are set to false
|
//vertex tags is_visited are set to false
|
||||||
void reset_is_visited_map(std::vector<Vertex_const_handle> &vces);
|
void reset_is_visited_map(std::vector<Vertex_const_handle> &vces);
|
||||||
|
|
||||||
|
|
||||||
|
Gate make_gate(const Vertex_const_handle v,
|
||||||
|
const Halfedge_const_handle he)
|
||||||
|
{
|
||||||
|
Point_3 p0 = v->point(),
|
||||||
|
p1 = target(he,P)->point(),
|
||||||
|
p2 = target(next(he,P),P)->point(),
|
||||||
|
p3 = target(prev(he,P),P)->point();
|
||||||
|
Vector_3 p0p1 = p0 - p1,
|
||||||
|
p0p2 = p0 - p2,
|
||||||
|
p0p3 = p0 - p3;
|
||||||
|
FT d1 = p0p1*p0p1,
|
||||||
|
d2 = p0p2*p0p2,
|
||||||
|
d3 = p0p3*p0p3;
|
||||||
|
FT d = CGAL::sqrt( (std::max)( (std::max)(d1,d2), d3) );
|
||||||
|
return Gate(d,he);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//tag to visit vertices
|
//tag to visit vertices
|
||||||
struct Vertex_cmp{//comparison is wrt vertex addresses
|
struct Vertex_cmp{//comparison is wrt vertex addresses
|
||||||
|
|
@ -157,11 +164,11 @@ compute_one_ring(const Vertex_const_handle v,
|
||||||
Halfedge_around_vertex_const_circulator he_circ(halfedge(v,P),P),
|
Halfedge_around_vertex_const_circulator he_circ(halfedge(v,P),P),
|
||||||
he_end = he_circ;
|
he_end = he_circ;
|
||||||
do {
|
do {
|
||||||
if ( (*he_circ)->is_border() )//then he and he->next follow the contour CW
|
if ( is_border(*he_circ,P) )//then he and he->next follow the contour CW
|
||||||
{contour.push_back(*he_circ);
|
{contour.push_back(*he_circ);
|
||||||
contour.push_back((*he_circ)->next());}
|
contour.push_back(next(*he_circ,P));}
|
||||||
else contour.push_back((*he_circ)->prev()->opposite());//not border, he->prev->opp on contour CW
|
else contour.push_back(opposite(prev(*he_circ,P),P));//not border, he->prev->opp on contour CW
|
||||||
vertex_neigh.push_back((*he_circ)->opposite()->vertex());
|
vertex_neigh.push_back(target(opposite(*he_circ,P),P));
|
||||||
he_circ++;
|
he_circ++;
|
||||||
} while (he_circ != he_end);
|
} while (he_circ != he_end);
|
||||||
|
|
||||||
|
|
@ -203,7 +210,7 @@ compute_neighbors(const Vertex_const_handle v,
|
||||||
typename std::list<Halfedge_const_handle>::const_iterator itb = contour.begin(),
|
typename std::list<Halfedge_const_handle>::const_iterator itb = contour.begin(),
|
||||||
ite = contour.end();
|
ite = contour.end();
|
||||||
for (; itb != ite; itb++) {
|
for (; itb != ite; itb++) {
|
||||||
if (!( (*itb)->is_border() )) GatePQ.push(Gate(v, *itb));
|
if (!( is_border(*itb,P) )) GatePQ.push(make_gate(v, *itb));
|
||||||
}
|
}
|
||||||
// init d_current
|
// init d_current
|
||||||
Gate firstGate = GatePQ.top();
|
Gate firstGate = GatePQ.top();
|
||||||
|
|
@ -245,40 +252,40 @@ compute_neighbors(const Vertex_const_handle v,
|
||||||
if ( he->next() == *pos_next )
|
if ( he->next() == *pos_next )
|
||||||
{ // case 2a
|
{ // case 2a
|
||||||
//contour
|
//contour
|
||||||
he1 = he->prev()->opposite();
|
he1 = opposite(prev(he,P),P);
|
||||||
contour.insert(pos_he, he1);
|
contour.insert(pos_he, he1);
|
||||||
contour.erase(pos_he);
|
contour.erase(pos_he);
|
||||||
contour.erase(pos_next);
|
contour.erase(pos_next);
|
||||||
//GatePQ
|
//GatePQ
|
||||||
if ( !(he1->is_border()) ) GatePQ.push(Gate(v, he1));
|
if ( !is_border(he1,P) ) GatePQ.push(make_gate(v, he1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if ( he->prev() == *pos_prev )
|
else if ( prev(he,P) == *pos_prev )
|
||||||
{ // case 2b
|
{ // case 2b
|
||||||
//contour
|
//contour
|
||||||
he1 = he->next()->opposite();
|
he1 = opposite(next(he,P),P);
|
||||||
contour.insert(pos_prev, he1);
|
contour.insert(pos_prev, he1);
|
||||||
contour.erase(pos_prev);
|
contour.erase(pos_prev);
|
||||||
contour.erase(pos_he);
|
contour.erase(pos_he);
|
||||||
//GatePQ
|
//GatePQ
|
||||||
if ( !(he1->is_border()) ) GatePQ.push(Gate(v, he1));
|
if ( ! is_border(he1,P) ) GatePQ.push(make_gate(v, he1));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
v1 = he->next()->vertex();
|
v1 = target(next(he,P),P);
|
||||||
if ( !is_visited_map.find(v1)->second )
|
if ( !is_visited_map.find(v1)->second )
|
||||||
{ // case 1
|
{ // case 1
|
||||||
//vertex
|
//vertex
|
||||||
is_visited_map.find(v1)->second = true;
|
is_visited_map.find(v1)->second = true;
|
||||||
vertex_neigh.push_back(v1);
|
vertex_neigh.push_back(v1);
|
||||||
//contour
|
//contour
|
||||||
he1 = he->prev()->opposite();
|
he1 = opposite(prev(he,P),P);
|
||||||
he2 = he->next()->opposite();
|
he2 = opposite(next(he,P),P);
|
||||||
contour.insert(pos_he, he1);
|
contour.insert(pos_he, he1);
|
||||||
contour.insert(pos_he, he2);
|
contour.insert(pos_he, he2);
|
||||||
contour.erase(pos_he);
|
contour.erase(pos_he);
|
||||||
//GatePQ
|
//GatePQ
|
||||||
if ( !(he1->is_border()) ) GatePQ.push(Gate(v, he1));
|
if ( ! is_border(he1,P) ) GatePQ.push(make_gate(v, he1));
|
||||||
if ( !(he2->is_border()) ) GatePQ.push(Gate(v, he2));
|
if ( ! is_border(he2,P) ) GatePQ.push(make_gate(v, he2));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//else do nothing (keep the he on the contour, and continue) to
|
//else do nothing (keep the he on the contour, and continue) to
|
||||||
|
|
|
||||||
|
|
@ -430,7 +430,7 @@ template < class TriangulatedSurfaceMesh,
|
||||||
*ridge_lines_it++ = cur_ridge_line;
|
*ridge_lines_it++ = cur_ridge_line;
|
||||||
|
|
||||||
//next triangle adjacent to h1 (push_front)
|
//next triangle adjacent to h1 (push_front)
|
||||||
if ( !(h1->is_border_edge()) )
|
if ( ! is_border_edge(h1,P) )
|
||||||
{
|
{
|
||||||
f = face(opposite(h1,P),P);
|
f = face(opposite(h1,P),P);
|
||||||
curhe = h1;
|
curhe = h1;
|
||||||
|
|
@ -442,8 +442,7 @@ template < class TriangulatedSurfaceMesh,
|
||||||
if (curhe->opposite() == curhe1) curhe = curhe2;
|
if (curhe->opposite() == curhe1) curhe = curhe2;
|
||||||
else curhe = curhe1;//curhe stays at the ridge extremity
|
else curhe = curhe1;//curhe stays at the ridge extremity
|
||||||
addfront(cur_ridge_line, curhe, cur_ridge_type);
|
addfront(cur_ridge_line, curhe, cur_ridge_type);
|
||||||
if ( !(curhe->is_border_edge()) ) f =
|
if ( ! is_border_edge(curhe,P) ) f = face(opposite(curhe,P),P);
|
||||||
curhe->opposite()->facet();
|
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
//exit from the while if
|
//exit from the while if
|
||||||
|
|
@ -453,9 +452,9 @@ template < class TriangulatedSurfaceMesh,
|
||||||
}
|
}
|
||||||
|
|
||||||
//next triangle adjacent to h2 (push_back)
|
//next triangle adjacent to h2 (push_back)
|
||||||
if ( !(h2->is_border_edge()) )
|
if ( ! is_border_edge(h2,P) )
|
||||||
{
|
{
|
||||||
f = h2->opposite()->facet();
|
f = face(opposite(h2,P),P);
|
||||||
curhe = h2;
|
curhe = h2;
|
||||||
while (cur_ridge_type ==
|
while (cur_ridge_type ==
|
||||||
facet_ridge_type(f,curhe1,curhe2,r_type))
|
facet_ridge_type(f,curhe1,curhe2,r_type))
|
||||||
|
|
@ -463,11 +462,10 @@ template < class TriangulatedSurfaceMesh,
|
||||||
//follow the ridge from curhe
|
//follow the ridge from curhe
|
||||||
if (is_visited_map.find(f)->second) break;
|
if (is_visited_map.find(f)->second) break;
|
||||||
is_visited_map.find(f)->second = true;
|
is_visited_map.find(f)->second = true;
|
||||||
if (curhe->opposite() == curhe1) curhe = curhe2;
|
if (opposite(curhe,P) == curhe1) curhe = curhe2;
|
||||||
else curhe = curhe1;
|
else curhe = curhe1;
|
||||||
addback(cur_ridge_line, curhe, cur_ridge_type);
|
addback(cur_ridge_line, curhe, cur_ridge_type);
|
||||||
if ( !(curhe->is_border_edge()) ) f =
|
if ( ! is_border_edge(curhe,P) ) f = face(opposite(curhe,P),P);
|
||||||
curhe->opposite()->facet();
|
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -485,11 +483,11 @@ facet_ridge_type(const Facet_const_handle f, halfedge_descriptor& he1, halfedge_
|
||||||
//polyhedral data
|
//polyhedral data
|
||||||
//we have v1--h1-->v2--h2-->v3--h3-->v1
|
//we have v1--h1-->v2--h2-->v3--h3-->v1
|
||||||
const halfedge_descriptor h1 = halfedge(f,P);
|
const halfedge_descriptor h1 = halfedge(f,P);
|
||||||
const vertex_descriptor v2 = h1->vertex();
|
const vertex_descriptor v2 = target(h1,P);
|
||||||
const halfedge_descriptor h2 = h1->next();
|
const halfedge_descriptor h2 = next(h1,P);
|
||||||
const vertex_descriptor v3 = h2->vertex();
|
const vertex_descriptor v3 = target(h2,P);
|
||||||
const halfedge_descriptor h3 = h2->next();
|
const halfedge_descriptor h3 = next(h2,P);
|
||||||
const vertex_descriptor v1 = h3->vertex();
|
const vertex_descriptor v1 = target(h3,P);
|
||||||
|
|
||||||
//check for regular facet
|
//check for regular facet
|
||||||
//i.e. if there is a coherent orientation of ppal dir at the facet vertices
|
//i.e. if there is a coherent orientation of ppal dir at the facet vertices
|
||||||
|
|
@ -576,15 +574,15 @@ xing_on_edge(const halfedge_descriptor he, bool& is_crossed, Ridge_interrogation
|
||||||
is_crossed = false;
|
is_crossed = false;
|
||||||
FT sign = 0;
|
FT sign = 0;
|
||||||
FT b_p, b_q; // extremalities at p and q for he: p->q
|
FT b_p, b_q; // extremalities at p and q for he: p->q
|
||||||
Vector_3 d_p = d1[he->opposite()->vertex()],
|
Vector_3 d_p = d1[target(opposite(he,P),P)],
|
||||||
d_q = d1[he->vertex()]; //ppal dir
|
d_q = d1[target(he,P)]; //ppal dir
|
||||||
if ( color == MAX_RIDGE ) {
|
if ( color == MAX_RIDGE ) {
|
||||||
b_p = b0[he->opposite()->vertex()];
|
b_p = b0[target(opposite(he,P),P)];
|
||||||
b_q = b0[he->vertex()];
|
b_q = b0[target(he,P)];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
b_p = b3[he->opposite()->vertex()];
|
b_p = b3[target(opposite(he,P),P)];
|
||||||
b_q = b3[he->vertex()];
|
b_q = b3[target(he,P)];
|
||||||
}
|
}
|
||||||
if ( b_p == 0 && b_q == 0 ) return;
|
if ( b_p == 0 && b_q == 0 ) return;
|
||||||
if ( b_p == 0 && b_q !=0 ) sign = d_p*d_q * b_q;
|
if ( b_p == 0 && b_q !=0 ) sign = d_p*d_q * b_q;
|
||||||
|
|
@ -601,8 +599,8 @@ bool Ridge_approximation< TriangulatedSurfaceMesh, Vertex2FTPropertyMap , Vertex
|
||||||
const halfedge_descriptor he1,
|
const halfedge_descriptor he1,
|
||||||
const halfedge_descriptor he2)
|
const halfedge_descriptor he2)
|
||||||
{
|
{
|
||||||
const vertex_descriptor v_p1 = he1->opposite()->vertex(), v_q1 = he1->vertex(),
|
const vertex_descriptor v_p1 = target(opposite(he1,P),P), v_q1 = target(he1,P),
|
||||||
v_p2 = he2->opposite()->vertex(), v_q2 = he2->vertex(); // hei: pi->qi
|
v_p2 = target(opposite(he2,P),P), v_q2 = target(he2,P); // hei: pi->qi
|
||||||
|
|
||||||
FT coord1, coord2;
|
FT coord1, coord2;
|
||||||
if (color == MAX_RIDGE)
|
if (color == MAX_RIDGE)
|
||||||
|
|
@ -711,8 +709,8 @@ addback(Ridge_line* ridge_line, const halfedge_descriptor he,
|
||||||
halfedge_descriptor he_cur = ( --(ridge_line->line()->end()) )->first;
|
halfedge_descriptor he_cur = ( --(ridge_line->line()->end()) )->first;
|
||||||
FT coord_cur = ( --(ridge_line->line()->end()) )->second;//bary_coord(he_cur);
|
FT coord_cur = ( --(ridge_line->line()->end()) )->second;//bary_coord(he_cur);
|
||||||
FT coord = bary_coord(he,r_type);
|
FT coord = bary_coord(he,r_type);
|
||||||
vertex_descriptor v_p = he->opposite()->vertex(), v_q = he->vertex(),
|
vertex_descriptor v_p = target(opposite(he,P),P), v_q = target(he,P),
|
||||||
v_p_cur = he_cur->opposite()->vertex(), v_q_cur = he_cur->vertex(); // he: p->q
|
v_p_cur = target(opposite(he_cur,P),P), v_q_cur = target(he_cur,P); // he: p->q
|
||||||
Vector_3 segment = CGAL::barycenter(v_p->point(), coord, v_q->point()) -
|
Vector_3 segment = CGAL::barycenter(v_p->point(), coord, v_q->point()) -
|
||||||
CGAL::barycenter(v_p_cur->point(), coord_cur, v_q_cur->point());
|
CGAL::barycenter(v_p_cur->point(), coord_cur, v_q_cur->point());
|
||||||
|
|
||||||
|
|
@ -754,8 +752,8 @@ addfront(Ridge_line* ridge_line,
|
||||||
halfedge_descriptor he_cur = ( ridge_line->line()->begin() )->first;
|
halfedge_descriptor he_cur = ( ridge_line->line()->begin() )->first;
|
||||||
FT coord_cur = ( ridge_line->line()->begin() )->second;
|
FT coord_cur = ( ridge_line->line()->begin() )->second;
|
||||||
FT coord = bary_coord(he,r_type);
|
FT coord = bary_coord(he,r_type);
|
||||||
vertex_descriptor v_p = he->opposite()->vertex(), v_q = he->vertex(),
|
vertex_descriptor v_p = target(opposite(he,P),P), v_q = target(he,P),
|
||||||
v_p_cur = he_cur->opposite()->vertex(), v_q_cur = he_cur->vertex(); // he: p->q
|
v_p_cur = target(opposite(he_cur,P),P), v_q_cur = target(he_cur,P); // he: p->q
|
||||||
Vector_3 segment = CGAL::barycenter(v_p->point(), coord, v_q->point()) -
|
Vector_3 segment = CGAL::barycenter(v_p->point(), coord, v_q->point()) -
|
||||||
CGAL::barycenter(v_p_cur->point(), coord_cur, v_q_cur->point());
|
CGAL::barycenter(v_p_cur->point(), coord_cur, v_q_cur->point());
|
||||||
|
|
||||||
|
|
@ -797,14 +795,14 @@ bary_coord(const halfedge_descriptor he, const Ridge_type r_type)
|
||||||
if ( (r_type == MAX_ELLIPTIC_RIDGE)
|
if ( (r_type == MAX_ELLIPTIC_RIDGE)
|
||||||
|| (r_type == MAX_HYPERBOLIC_RIDGE)
|
|| (r_type == MAX_HYPERBOLIC_RIDGE)
|
||||||
|| (r_type == MAX_CREST_RIDGE) ) {
|
|| (r_type == MAX_CREST_RIDGE) ) {
|
||||||
b_p = b0[he->opposite()->vertex()];
|
b_p = b0[target(opposite(he,P),P)];
|
||||||
b_q = b0[he->vertex()];
|
b_q = b0[target(he,P)];
|
||||||
}
|
}
|
||||||
if ( (r_type == MIN_ELLIPTIC_RIDGE)
|
if ( (r_type == MIN_ELLIPTIC_RIDGE)
|
||||||
|| (r_type == MIN_HYPERBOLIC_RIDGE)
|
|| (r_type == MIN_HYPERBOLIC_RIDGE)
|
||||||
|| (r_type == MIN_CREST_RIDGE) ) {
|
|| (r_type == MIN_CREST_RIDGE) ) {
|
||||||
b_p = b3[he->opposite()->vertex()];
|
b_p = b3[target(opposite(he,P),P)];
|
||||||
b_q = b3[he->vertex()];
|
b_q = b3[target(he,P)];
|
||||||
}
|
}
|
||||||
//denominator cannot be 0 since there is no crossing when both extremalities are 0
|
//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) );
|
return CGAL::abs(b_q) / ( CGAL::abs(b_q) + CGAL::abs(b_p) );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue