From e4306a0d3da8268bae3bb12124ccc8e290d7d097 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 16 Apr 2013 16:01:09 +0200 Subject: [PATCH] fixed -> unremovable; fixed is no longer used in Polyline_constrained_trioangulation --- .../Polyline_simplification_2.cpp | 2 +- .../Polyline_simplification_2_graphics_item.h | 22 +++++++-------- .../Polyline_simplification_2.txt | 25 ++++++++--------- .../Polyline_simplification_2/Vertex_base_2.h | 10 +++---- .../mark_vertices_unremovable.h | 2 +- .../CGAL/Polyline_simplification_2/simplify.h | 27 ++++++++++--------- .../CGAL/Polyline_constraint_hierarchy_2.h | 4 +-- 7 files changed, 44 insertions(+), 48 deletions(-) diff --git a/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp b/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp index b2a9bfe180f..9373806166d 100644 --- a/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp +++ b/Polyline_simplification_2/demo/Polyline_simplification_2/Polyline_simplification_2.cpp @@ -68,7 +68,7 @@ typedef K::Point_2 Point_2; typedef K::Segment_2 Segment_2; typedef K::Iso_rectangle_2 Iso_rectangle_2; -typedef CGAL::Polyline_simplification_2::Vertex_base_2<> Vb; +typedef CGAL::Polyline_simplification_2::Vertex_base_2 Vb; typedef CGAL::Constrained_triangulation_face_base_2 Fb; typedef CGAL::Triangulation_data_structure_2 TDS; typedef CGAL::Exact_predicates_tag Itag; diff --git a/Polyline_simplification_2/demo/Polyline_simplification_2/include/CGAL/Qt/Polyline_simplification_2_graphics_item.h b/Polyline_simplification_2/demo/Polyline_simplification_2/include/CGAL/Qt/Polyline_simplification_2_graphics_item.h index de2e4901daa..afdb139c285 100644 --- a/Polyline_simplification_2/demo/Polyline_simplification_2/include/CGAL/Qt/Polyline_simplification_2_graphics_item.h +++ b/Polyline_simplification_2/demo/Polyline_simplification_2/include/CGAL/Qt/Polyline_simplification_2_graphics_item.h @@ -66,8 +66,8 @@ public: constraints_pen = this->edgesPen(); constraints_pen.setColor(::Qt::red); - fixed_vertices_pen = this->verticesPen(); - fixed_vertices_pen.setColor(::Qt::blue); + unremovable_vertices_pen = this->verticesPen(); + unremovable_vertices_pen.setColor(::Qt::blue); } void operator()(typename PCT::Face_handle fh); @@ -82,14 +82,14 @@ public: constraints_pen = pen; } - const QPen& fixedVerticesPen() const + const QPen& unremovableVerticesPen() const { - return fixed_vertices_pen; + return unremovable_vertices_pen; } - void setFixedVerticesPen(const QPen& pen) + void setUnremovableVerticesPen(const QPen& pen) { - fixed_vertices_pen = pen; + unremovable_vertices_pen = pen; } bool visibleConstraints() const @@ -110,7 +110,7 @@ protected: virtual void paintVertex(typename PCT::Vertex_handle vh); QPen constraints_pen; - QPen fixed_vertices_pen; + QPen unremovable_vertices_pen; private: bool visible_constraints; @@ -170,8 +170,8 @@ PolylineSimplificationGraphicsItem::paintVertex( typename PCT::Vertex_handl { Converter convert; - // if ( vh->is_fixed() || vh->is_shared() ) { - // this->m_painter->setPen(this->fixedVerticesPen()); + // if ( vh->is_unremovable() || vh->is_shared() ) { + // this->m_painter->setPen(this->unremovableVerticesPen()); // } else { this->m_painter->setPen(this->verticesPen()); // } @@ -199,8 +199,8 @@ PolylineSimplificationGraphicsItem::paintVertices(QPainter *painter) it != this->t->vertices_in_constraint_end(*cit); it++){ QPointF point = matrix.map(convert((*it)->point())); - if ( (*it)->fixed ) - painter->setPen(this->fixedVerticesPen()); + if ( (*it)->unremovable() ) + painter->setPen(this->unremovableVerticesPen()); else painter->setPen(this->verticesPen()); diff --git a/Polyline_simplification_2/doc/Polyline_simplification_2/Polyline_simplification_2.txt b/Polyline_simplification_2/doc/Polyline_simplification_2/Polyline_simplification_2.txt index 8f315d5d9ca..f3efe4e05a0 100755 --- a/Polyline_simplification_2/doc/Polyline_simplification_2/Polyline_simplification_2.txt +++ b/Polyline_simplification_2/doc/Polyline_simplification_2/Polyline_simplification_2.txt @@ -153,18 +153,17 @@ the number of vertices. \subsection Subsection_PolylineSimplification_Simplifying_Several Simplifying Several Polylines In the second example we insert several polygons in a -`Polyline_constrained_triangulation_2`. Assuming that the polygons do not -intersect, we can take the default template parameters for the -`Constrained_Delaunay_triangulation_2`. - -Before calling `Polyline_simplification_2::simplify()` we mark some -polyline vertices as not removable. This package provides a -convenience function +`Polyline_constrained_triangulation_2`. As a vertex +type we have to use `CGAL::Polyline_simplification_2::Vertex_base` +as vertices may be marked as non-removable. The simplification +algorithm marks the first and last vertex of polyline constraints +as well as intersections. + +In the example we mark further polyline vertices as not removable. +This package provides a convenience function `Polyline_simplification_2::mark_vertices_unremovable()` that marks the vertices with smallest and largest `x` and `y` coordinates of each -polyline constraint as non-removable. The class -`Polyline_constrained_triangulation_2` offers functions to mark -individual polyline vertices as non removable. Finally, we iterate +polyline constraint as non-removable. Finally, we iterate over all vertices of all polyline constraints. \cgalExample{Polyline_simplification_2/simplify.cpp} @@ -180,7 +179,7 @@ During the simplification the cost functions need the original sequence of points. As explained in the introduction the `Polyline_constrained_triangulation_2` allows to remove vertices from a polyline constraint, and hence from the triangulation, while keeping -the point in the polyline constraint. This explains why there is a +the points in the polyline constraint. This explains why there is a `Vertex_in_constraint_iterator` and a `Point_in_constraint_iterator`. With the last argument of `Polyline_simplification_2::simplify()` set @@ -207,9 +206,7 @@ to check if an elementary simplification step can be performed. In our implementation we simplified this test even further. Fernando Cacciola made a first prototype implementation for -GeometryFactory, and Andreas Fabri developed the -`Polyline_constrained_triangulation_2` and the final version of this -package. +GeometryFactory. diff --git a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/Vertex_base_2.h b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/Vertex_base_2.h index 2eb7163a3ea..5cb1cd46863 100644 --- a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/Vertex_base_2.h +++ b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/Vertex_base_2.h @@ -44,19 +44,19 @@ public: template < typename TDS2 > struct Rebind_TDS { typedef typename Vb::template Rebind_TDS::Other Vb2; - typedef Vertex_base_2 Other; + typedef Vertex_base_2 Other; }; Vertex_base_2() - : Base(), m_fixed(false), m_cost(-1.0) + : Base(), m_unremovable(false), m_cost(-1.0) {} - bool m_fixed; + bool m_unremovable; FT m_cost; - bool& fixed() + bool& unremovable() { - return m_fixed; + return m_unremovable; } FT& cost() diff --git a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/mark_vertices_unremovable.h b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/mark_vertices_unremovable.h index db1bd59d8f7..72b35774783 100644 --- a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/mark_vertices_unremovable.h +++ b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/mark_vertices_unremovable.h @@ -48,7 +48,7 @@ mark_vertices_unremovable(CGAL::Polyline_constrained_triangulation_2& pct, 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; + l->unremovable() = r->unremovable() = t->unremovable() = b->unremovable() = true; } diff --git a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h index 3f10a49c3b0..24c5cbf9c5c 100644 --- a/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h +++ b/Polyline_simplification_2/include/CGAL/Polyline_simplification_2/simplify.h @@ -99,7 +99,7 @@ public: { std::cerr << pct_initial_number_of_vertices << std::endl; int m = initialize_indices(); - initialize_fixed(); + initialize_unremovable(); Compare_cost cc; Id_map idm; mpq = new MPQ(m, cc, idm); @@ -110,7 +110,7 @@ public: : pct(pct), cost(cost), stop(stop), pct_initial_number_of_vertices(pct.number_of_vertices()), number_of_unremovable_vertices(0) { int m = initialize_indices(cid); - initialize_fixed(); + initialize_unremovable(); Compare_cost cc; Id_map idm; mpq = new MPQ(m, cc, idm); @@ -124,27 +124,27 @@ public: delete mpq; } - void initialize_fixed() + void initialize_unremovable() { std::set vertices; Constraint_iterator cit = pct.constraints_begin(), e = pct.constraints_end(); for(; cit!=e; ++cit){ Constraint_id cid = *cit; Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid); - (*it)->fixed() = true; + (*it)->unremovable() = true; for(; it != pct.vertices_in_constraint_end(cid); ++it){ if(vertices.find(*it) != vertices.end()){ - (*it)->fixed() = true; + (*it)->unremovable() = true; } else { vertices.insert(*it); } } it = boost::prior(it); - (*it)->fixed() = true; + (*it)->unremovable() = true; } } - // For all polyline constraints we compute the cost of all non fixed and not removed vertices + // For all polyline constraints we compute the cost of all unremovable and not removed vertices int initialize_costs(Constraint_id cid) { @@ -152,7 +152,7 @@ public: for(Vertices_in_constraint_iterator it = pct.vertices_in_constraint_begin(cid); it != pct.vertices_in_constraint_end(cid); ++it){ - if(! (*it)->fixed()){ + if(! (*it)->unremovable()){ Vertices_in_constraint_iterator u = boost::prior(it); Vertices_in_constraint_iterator w = boost::next(it); @@ -185,7 +185,7 @@ public: is_removable(Vertices_in_constraint_iterator it) { typedef typename PCT::Geom_traits Geom_traits; - if((*it)->fixed()) { + if((*it)->unremovable()) { return false; } @@ -260,7 +260,7 @@ operator()() Vertices_in_constraint_iterator u = boost::prior(v), w = boost::next(v); pct.simplify(u,v,w); - if(! (*u)->fixed()){ + if(! (*u)->unremovable()){ Vertices_in_constraint_iterator uu = boost::prior(u); boost::optional dist = cost(pct, uu,u,w); if(! dist){ @@ -273,7 +273,7 @@ operator()() } } - if(! (*w)->fixed()){ + if(! (*w)->unremovable()){ Vertices_in_constraint_iterator ww = boost::next(w); boost::optional dist = cost(pct, u,w,ww); if(! dist){ @@ -316,8 +316,9 @@ template ::type K; - typedef Vertex_base_2< CGAL::Triangulation_vertex_base_2< K > > Vb; - typedef CGAL::Triangulation_data_structure_2 > TDS; + typedef Vertex_base_2< K > Vb; + typedef CGAL::Constrained_triangulation_face_base_2 Fb; + typedef CGAL::Triangulation_data_structure_2 TDS; typedef CGAL::Constrained_Delaunay_triangulation_2 CDT; typedef CGAL::Polyline_constrained_triangulation_2 PCT; typedef PCT::Constraint_id Constraint_id; diff --git a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h index 5692f5f24da..e29fd61c5d3 100644 --- a/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h +++ b/Triangulation_2/include/CGAL/Polyline_constraint_hierarchy_2.h @@ -538,7 +538,6 @@ void Polyline_constraint_hierarchy_2::simplify(Vertex_it uc, Vertex_it wc) { - // 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" ); @@ -930,8 +929,7 @@ add_Steiner(T va, T vb, T vc){ // insert vc in enclosing constraint pos = ctit->current(); ++pos; - pos = ctit->enclosing->insert(pos.base(), Node(vc));// fixed == true - //AF vc->fixed = true; + pos = ctit->enclosing->insert(pos.base(), Node(vc)); --pos; // set ctxt to the context of (vc,vb)