mirror of https://github.com/CGAL/cgal
Propagated that change up through the hierarchy. (*it)-> syntax for
Vertex_it still feels a little bit awkward but is the best we can get.
This commit is contained in:
parent
918a6084ab
commit
c72b426896
|
|
@ -35,11 +35,11 @@ int main( )
|
|||
cit != pct.constraints_end();
|
||||
++cit) {
|
||||
std::cout << "simplified polyline" << std::endl;
|
||||
for(Vertices_in_constraint_iterator vit =
|
||||
pct.vertices_in_constraint_begin(*cit);
|
||||
vit != pct.vertices_in_constraint_end(*cit);
|
||||
for(Points_in_constraint_iterator vit =
|
||||
pct.points_in_constraint_begin(*cit);
|
||||
vit != pct.points_in_constraint_end(*cit);
|
||||
++vit)
|
||||
std::cout << vit->point() << std::endl;
|
||||
std::cout << *vit << std::endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ public:
|
|||
Compute_squared_distance compute_squared_distance = pct.geom_traits().compute_squared_distance_2_object() ;
|
||||
Construct_segment construct_segment = pct.geom_traits().construct_segment_2_object() ;
|
||||
|
||||
Point const& lP = p->point;
|
||||
Point const& lR = r->point;
|
||||
Point const& lP = (*p)->point();
|
||||
Point const& lR = (*r)->point();
|
||||
|
||||
Segment lP_R = construct_segment(lP, lR) ;
|
||||
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
++p;
|
||||
|
||||
for ( ;p != r; ++p )
|
||||
d1 = (std::max)(d1, compute_squared_distance( lP_R, p->point ) ) ;
|
||||
d1 = (std::max)(d1, compute_squared_distance( lP_R, (*p)->point() ) ) ;
|
||||
|
||||
return d1 ;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,12 +40,12 @@ mark_vertices_unremovable(CGAL::Polyline_constrained_triangulation_2<Tr>& pct,
|
|||
for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid);
|
||||
it != pct.vertices_in_constraint_end(cid);
|
||||
it++){
|
||||
if(it->point.x() < l->point().x()) l = *it;
|
||||
if(it->point.x() > r->point().x()) r = *it;
|
||||
if(it->point.y() < b->point().y()) b = *it;
|
||||
if(it->point.y() > t->point().y()) t = *it;
|
||||
}
|
||||
l->fixed = r->fixed = t->fixed = b->fixed = true;
|
||||
if((*it)->point().x() < l->point().x()) l = *it;
|
||||
if((*it)->point().x() > r->point().x()) r = *it;
|
||||
if((*it)->point().y() < b->point().y()) b = *it;
|
||||
if((*it)->point().y() > t->point().y()) t = *it;
|
||||
}
|
||||
l->fixed = r->fixed = t->fixed = b->fixed = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public:
|
|||
bool operator() ( Vertices_in_constraint_iterator const& x,
|
||||
Vertices_in_constraint_iterator const& y ) const
|
||||
{
|
||||
return x->vertex->cost < y->vertex->cost;
|
||||
return (*x)->cost < (*y)->cost;
|
||||
}
|
||||
} ;
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ public:
|
|||
typedef value_type reference;
|
||||
typedef Vertices_in_constraint_iterator key_type;
|
||||
|
||||
reference operator[] ( key_type const& x ) const { return x->id ; }
|
||||
reference operator[] ( key_type const& x ) const { return x.base()->id ; }
|
||||
} ;
|
||||
|
||||
typedef CGAL::Modifiable_priority_queue<Vertices_in_constraint_iterator,Compare_cost,Id_map> MPQ ;
|
||||
|
|
@ -129,17 +129,17 @@ public:
|
|||
for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid);
|
||||
it != pct.vertices_in_constraint_end(cid);
|
||||
++it){
|
||||
if(! it->vertex->fixed){
|
||||
if(! (*it)->fixed){
|
||||
Vertices_in_constraint_iterator u = boost::prior(it);
|
||||
Vertices_in_constraint_iterator w = boost::next(it);
|
||||
|
||||
boost::optional<double> dist = cost(pct, u, it, w);
|
||||
if(dist){
|
||||
it->vertex->cost = *dist;
|
||||
(*it)->cost = *dist;
|
||||
(*mpq).push(it);
|
||||
++n;
|
||||
} else {
|
||||
it->vertex->cost = (std::numeric_limits<double>::max)();
|
||||
(*it)->cost = (std::numeric_limits<double>::max)();
|
||||
std::cerr << "could not compute a cost" << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -162,15 +162,15 @@ public:
|
|||
is_removable(Vertices_in_constraint_iterator it)
|
||||
{
|
||||
typedef typename PCT::Geom_traits Geom_traits;
|
||||
if(it->vertex->fixed) {
|
||||
if((*it)->fixed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vertex_handle vh = it->vertex;
|
||||
Vertex_handle vh = *it;
|
||||
Vertices_in_constraint_iterator u = boost::prior(it);
|
||||
Vertex_handle uh = u->vertex;
|
||||
Vertex_handle uh = *u;
|
||||
Vertices_in_constraint_iterator w = boost::next(it);
|
||||
Vertex_handle wh = w->vertex;
|
||||
Vertex_handle wh = *w;
|
||||
|
||||
typename Geom_traits::Orientation_2 orientation_2 = pct.geom_traits().orientation_2_object();
|
||||
CGAL::Orientation o = orientation_2(uh->point(), vh->point(), wh->point());
|
||||
|
|
@ -206,7 +206,7 @@ public:
|
|||
for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid);
|
||||
it != pct.vertices_in_constraint_end(cid);
|
||||
++it){
|
||||
it->id = id++;
|
||||
it.base()->id = id++;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
@ -230,33 +230,33 @@ operator()()
|
|||
}
|
||||
Vertices_in_constraint_iterator v = (*mpq).top();
|
||||
(*mpq).pop();
|
||||
if(stop(pct, v, v->vertex->cost, pct_initial_number_of_vertices, pct.number_of_vertices())){
|
||||
if(stop(pct, v, (*v)->cost, pct_initial_number_of_vertices, pct.number_of_vertices())){
|
||||
return false;
|
||||
}
|
||||
if(is_removable(v)){
|
||||
Vertices_in_constraint_iterator u = boost::prior(v), w = boost::next(v);
|
||||
pct.simplify(u,v,w, keep_points);
|
||||
|
||||
if(! u->vertex->fixed){
|
||||
if(! (*u)->fixed){
|
||||
Vertices_in_constraint_iterator uu = boost::prior(u);
|
||||
boost::optional<double> dist = cost(pct, uu,u,w);
|
||||
if(! dist){
|
||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
||||
} else {
|
||||
u->vertex->cost = *dist;
|
||||
(*u)->cost = *dist;
|
||||
if((*mpq).contains(u)){
|
||||
(*mpq).update(u, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(! w->vertex->fixed){
|
||||
if(! (*w)->fixed){
|
||||
Vertices_in_constraint_iterator ww = boost::next(w);
|
||||
boost::optional<double> dist = cost(pct, u,w,ww);
|
||||
if(! dist){
|
||||
std::cerr << "undefined cost not handled yet" << std::endl;
|
||||
} else {
|
||||
w->vertex->cost = *dist;
|
||||
(*w)->cost = *dist;
|
||||
if((*mpq).contains(w)){
|
||||
(*mpq).update(w, true);
|
||||
}
|
||||
|
|
@ -304,11 +304,8 @@ template <class PolygonTraits_2, class Container, class CostFunction, class Stop
|
|||
while(simplifier()){}
|
||||
|
||||
CGAL::Polygon_2<PolygonTraits_2,Container> result;
|
||||
for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid);
|
||||
it != pct.vertices_in_constraint_end(cid);
|
||||
it++) {
|
||||
result.push_back(it->point);
|
||||
}
|
||||
std::copy(pct.points_in_constraint_begin(cid),
|
||||
pct.points_in_constraint_end(cid), std::back_inserter(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -573,11 +573,11 @@ public:
|
|||
{
|
||||
hierarchy.simplify(u,v,w);
|
||||
|
||||
Triangulation::remove_incident_constraints(v->vertex);
|
||||
Triangulation::remove_incident_constraints(*v);
|
||||
|
||||
Triangulation::remove(v->vertex);
|
||||
Triangulation::remove(*v);
|
||||
|
||||
Triangulation::insert_constraint(u->vertex,w->vertex);
|
||||
Triangulation::insert_constraint(*u, *w);
|
||||
}
|
||||
|
||||
void remove_points_from_constraint(Constraint_id cid)
|
||||
|
|
@ -585,7 +585,7 @@ public:
|
|||
hierarchy.remove_points_from_constraint(cid);
|
||||
}
|
||||
|
||||
void remove_points_from_constraints()
|
||||
void remove_points_from_constraints()
|
||||
{
|
||||
hierarchy.remove_points_from_constraints();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,10 +73,10 @@ public:
|
|||
{
|
||||
public:
|
||||
Point_it() : Vertex_it::iterator_adaptor_() {}
|
||||
Point_it(typename Vertex_list::all_iterator it) : Vertex_it::iterator_adaptor_(it) {}
|
||||
Point_it(typename Vertex_list::all_iterator it) : Point_it::iterator_adaptor_(it) {}
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
Vertex_handle dereference() const { return this->base()->point(); }
|
||||
Point& dereference() const { return this->base()->point(); }
|
||||
};
|
||||
|
||||
// only nodes with a vertex_handle that is still in the triangulation
|
||||
|
|
@ -91,6 +91,7 @@ public:
|
|||
public:
|
||||
Vertex_it() : Vertex_it::iterator_adaptor_() {}
|
||||
Vertex_it(typename Vertex_list::skip_iterator it) : Vertex_it::iterator_adaptor_(it) {}
|
||||
operator Point_it() const { return Point_it(this->base()); }
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
Vertex_handle dereference() const { return this->base()->vertex(); }
|
||||
|
|
@ -146,8 +147,15 @@ public:
|
|||
bool vertices_in_constraint(Constraint hc,
|
||||
Vertex_it& v_first,
|
||||
Vertex_it& v_past) const;
|
||||
Vertex_it vertices_in_constraint_begin(Constraint_id) const;
|
||||
Vertex_it vertices_in_constraint_end(Constraint_id) const;
|
||||
Vertex_it vertices_in_constraint_begin(Constraint_id cid) const
|
||||
{ return cid->skip_begin(); }
|
||||
Vertex_it vertices_in_constraint_end(Constraint_id cid) const
|
||||
{ return cid->skip_end(); }
|
||||
|
||||
Point_it points_in_constraint_begin(Constraint_id cid) const
|
||||
{ return cid->all_begin(); }
|
||||
Point_it points_in_constraint_end(Constraint_id cid) const
|
||||
{ return cid->all_end(); }
|
||||
|
||||
bool enclosing_constraint(Edge he, Constraint& hc) const;
|
||||
bool enclosing_constraint(T vaa, T vbb, T& va, T& vb) const;
|
||||
|
|
@ -413,22 +421,6 @@ contexts_end(T va, T vb)
|
|||
return last;
|
||||
}
|
||||
|
||||
template <class T, class Data>
|
||||
typename Polyline_constraint_hierarchy_2<T,Data>::Vertex_it
|
||||
Polyline_constraint_hierarchy_2<T,Data>::
|
||||
vertices_in_constraint_begin(Constraint_id cid) const
|
||||
{
|
||||
return cid->skip_begin();
|
||||
}
|
||||
|
||||
template <class T, class Data>
|
||||
typename Polyline_constraint_hierarchy_2<T,Data>::Vertex_it
|
||||
Polyline_constraint_hierarchy_2<T,Data>::
|
||||
vertices_in_constraint_end(Constraint_id cid) const
|
||||
{
|
||||
return cid->skip_end();
|
||||
}
|
||||
|
||||
template <class T, class Data>
|
||||
void
|
||||
Polyline_constraint_hierarchy_2<T,Data>::
|
||||
|
|
@ -529,13 +521,13 @@ void Polyline_constraint_hierarchy_2<T,Data>::simplify(Vertex_it uc,
|
|||
Vertex_it wc)
|
||||
|
||||
{
|
||||
CGAL_assertion(vc->vertex->fixed != true);
|
||||
Vertex_handle u = uc->vertex, v = vc->vertex, w = wc->vertex;
|
||||
CGAL_assertion((*vc)->fixed != true);
|
||||
Vertex_handle u = *uc, v = *vc, w = *wc;
|
||||
typename Sc_to_c_map::iterator uv_sc_iter = sc_to_c_map.find(make_edge(u, v));
|
||||
CGAL_assertion_msg( uv_sc_iter != sc_to_c_map.end(), "not a subconstraint" );
|
||||
Context_list* uv_hcl = uv_sc_iter->second;
|
||||
CGAL_assertion_msg(uv_hcl->size() == 1, "more than one constraint passing through the subconstraint" );
|
||||
if((uv_hcl->front().current())->vertex != u) {
|
||||
if(*(uv_hcl->front().current()) != u) {
|
||||
std::swap(u,w);
|
||||
uv_sc_iter = sc_to_c_map.find(make_edge(u, v));
|
||||
CGAL_assertion_msg( uv_sc_iter != sc_to_c_map.end(), "not a subconstraint" );
|
||||
|
|
@ -550,7 +542,7 @@ void Polyline_constraint_hierarchy_2<T,Data>::simplify(Vertex_it uc,
|
|||
Vertex_list* vertex_list = uv_hcl->front().id();
|
||||
CGAL_assertion_msg(vertex_list == vw_hcl->front().id(), "subconstraints from different polyline constraints" );
|
||||
// Remove the list item which points to v
|
||||
vertex_list->skip(vc);
|
||||
vertex_list->skip(vc.base());
|
||||
|
||||
// Remove the entries for [u,v] and [v,w]
|
||||
sc_to_c_map.erase(uv_sc_iter);
|
||||
|
|
@ -566,9 +558,10 @@ int
|
|||
Polyline_constraint_hierarchy_2<T,Data>::remove_points_from_constraint(Constraint_id cid)
|
||||
{
|
||||
int n=0;
|
||||
for(Point_it it = cid->all_begin(); it != cid->all_end(); ++it) {
|
||||
if(cid->is_skipped(it)) {
|
||||
it = cid->erase(it);
|
||||
for(Point_it it = points_in_constraint_begin(cid);
|
||||
it != points_in_constraint_end(cid); ++it) {
|
||||
if(cid->is_skipped(it.base())) {
|
||||
it = cid->erase(it.base());
|
||||
++n;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue