fixed -> unremovable; fixed is no longer used in Polyline_constrained_trioangulation

This commit is contained in:
Andreas Fabri 2013-04-16 16:01:09 +02:00
parent 94567d8745
commit e4306a0d3d
7 changed files with 44 additions and 48 deletions

View File

@ -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<K> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;

View File

@ -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<PCT>::paintVertex( typename PCT::Vertex_handl
{
Converter<Geom_traits> 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<PCT>::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());

View File

@ -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.

View File

@ -44,19 +44,19 @@ public:
template < typename TDS2 >
struct Rebind_TDS {
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
typedef Vertex_base_2<Vb2> Other;
typedef Vertex_base_2<K,Vb2> 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()

View File

@ -48,7 +48,7 @@ mark_vertices_unremovable(CGAL::Polyline_constrained_triangulation_2<Tr>& 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;
}

View File

@ -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<Vertex_handle> 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<double> 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<double> dist = cost(pct, u,w,ww);
if(! dist){
@ -316,8 +316,9 @@ template <class PolygonTraits_2, class Container, class CostFunction, class Stop
{
typedef PolygonTraits_2::Point_2 Point_2;
typedef CGAL::Kernel_traits<Point_2>::type K;
typedef Vertex_base_2< CGAL::Triangulation_vertex_base_2< K > > Vb;
typedef CGAL::Triangulation_data_structure_2<Vb, CGAL::Constrained_triangulation_face_base_2<K> > TDS;
typedef Vertex_base_2< K > Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, CGAL::Exact_predicates_tag> CDT;
typedef CGAL::Polyline_constrained_triangulation_2<CDT> PCT;
typedef PCT::Constraint_id Constraint_id;

View File

@ -538,7 +538,6 @@ void Polyline_constraint_hierarchy_2<T,Data>::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)