mirror of https://github.com/CGAL/cgal
reintegrate '^/branches/features/Triangulation_2_UseTraitsInHierarchy-GF'
This commit is contained in:
commit
96319a1365
|
|
@ -209,6 +209,7 @@ the following has been changed since CGAL-4.0:</p>
|
||||||
<h3>2D and 3D Geometry Kernel </h3>
|
<h3>2D and 3D Geometry Kernel </h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fix a bug in the <code>Segment_3-Triangle_3</code> intersection function in the case the segment is collinear with a triangle edge.</li>
|
<li>Fix a bug in the <code>Segment_3-Triangle_3</code> intersection function in the case the segment is collinear with a triangle edge.</li>
|
||||||
|
<li>Fix a bug in the <code>Projection_traits_.._3</code>class in the case a segment was parallel to the x-axis.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3>Algebraic Kernel</h3>
|
<h3>Algebraic Kernel</h3>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,25 @@
|
||||||
|
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
|
// Comparison functor that compares two Vertex_handle.
|
||||||
|
// Used as 'Compare' functor for the constraint hierarchy.
|
||||||
|
template < class Tr >
|
||||||
|
class Ctp2_vertex_handle_less_xy {
|
||||||
|
const Tr* tr_p;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Ctp2_vertex_handle_less_xy(const Tr* tr_p) : tr_p(tr_p) {}
|
||||||
|
|
||||||
|
typedef typename Tr::Vertex_handle Vertex_handle;
|
||||||
|
|
||||||
|
bool operator()(const Vertex_handle& va,
|
||||||
|
const Vertex_handle& vb) const
|
||||||
|
{
|
||||||
|
return tr_p->compare_xy(va->point(), vb->point()) == SMALLER;
|
||||||
|
}
|
||||||
|
}; // end class template Ctp2_vertex_handle_less_xy
|
||||||
|
|
||||||
|
|
||||||
// Tr the base triangulation class
|
// Tr the base triangulation class
|
||||||
// Tr has to be Constrained or Constrained_Delaunay
|
// Tr has to be Constrained or Constrained_Delaunay
|
||||||
|
|
||||||
|
|
@ -58,8 +77,11 @@ public:
|
||||||
typedef typename Triangulation::List_vertices List_vertices;
|
typedef typename Triangulation::List_vertices List_vertices;
|
||||||
typedef typename Triangulation::List_constraints List_constraints;
|
typedef typename Triangulation::List_constraints List_constraints;
|
||||||
|
|
||||||
typedef Constraint_hierarchy_2<Vertex_handle, bool> Constraint_hierarchy;
|
typedef Ctp2_vertex_handle_less_xy<Self> Vh_less_xy;
|
||||||
typedef Tag_true Constraint_hierarchy_tag;
|
typedef Constraint_hierarchy_2<Vertex_handle,
|
||||||
|
Vh_less_xy,
|
||||||
|
bool> Constraint_hierarchy;
|
||||||
|
typedef Tag_true Constraint_hierarchy_tag;
|
||||||
|
|
||||||
// for user interface with the constraint hierarchy
|
// for user interface with the constraint hierarchy
|
||||||
typedef typename Constraint_hierarchy::H_vertex_it
|
typedef typename Constraint_hierarchy::H_vertex_it
|
||||||
|
|
@ -88,10 +110,14 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Constrained_triangulation_plus_2(const Geom_traits& gt=Geom_traits())
|
Constrained_triangulation_plus_2(const Geom_traits& gt=Geom_traits())
|
||||||
: Triangulation(gt) { }
|
: Triangulation(gt)
|
||||||
|
, hierarchy(Vh_less_xy(this))
|
||||||
|
{ }
|
||||||
|
|
||||||
Constrained_triangulation_plus_2(const Self& ctp)
|
Constrained_triangulation_plus_2(const Self& ctp)
|
||||||
: Triangulation() { copy_triangulation(ctp);}
|
: Triangulation()
|
||||||
|
, hierarchy(Vh_less_xy(this))
|
||||||
|
{ copy_triangulation(ctp);}
|
||||||
|
|
||||||
virtual ~Constrained_triangulation_plus_2() {}
|
virtual ~Constrained_triangulation_plus_2() {}
|
||||||
|
|
||||||
|
|
@ -100,6 +126,7 @@ public:
|
||||||
Constrained_triangulation_plus_2(List_constraints& lc,
|
Constrained_triangulation_plus_2(List_constraints& lc,
|
||||||
const Geom_traits& gt=Geom_traits())
|
const Geom_traits& gt=Geom_traits())
|
||||||
: Triangulation(gt)
|
: Triangulation(gt)
|
||||||
|
, hierarchy(Vh_less_xy(this))
|
||||||
{
|
{
|
||||||
typename List_constraints::iterator lcit=lc.begin();
|
typename List_constraints::iterator lcit=lc.begin();
|
||||||
for( ;lcit != lc.end(); lcit++) {
|
for( ;lcit != lc.end(); lcit++) {
|
||||||
|
|
@ -113,6 +140,7 @@ public:
|
||||||
InputIterator last,
|
InputIterator last,
|
||||||
const Geom_traits& gt=Geom_traits() )
|
const Geom_traits& gt=Geom_traits() )
|
||||||
: Triangulation(gt)
|
: Triangulation(gt)
|
||||||
|
, hierarchy(Vh_less_xy(this))
|
||||||
{
|
{
|
||||||
while( first != last){
|
while( first != last){
|
||||||
insert_constraint((*first).first, (*first).second);
|
insert_constraint((*first).first, (*first).second);
|
||||||
|
|
|
||||||
|
|
@ -31,26 +31,34 @@
|
||||||
namespace CGAL {
|
namespace CGAL {
|
||||||
|
|
||||||
// T is expected to be Vertex_handle
|
// T is expected to be Vertex_handle
|
||||||
|
// Compare is a comparison operator for type T
|
||||||
// Data is intended to store info on a Vertex
|
// Data is intended to store info on a Vertex
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
class Constraint_hierarchy_2
|
class Constraint_hierarchy_2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<T, T> H_edge;
|
typedef std::pair<T, T> H_edge;
|
||||||
typedef T H_vertex;
|
typedef T H_vertex;
|
||||||
typedef Constraint_hierarchy_2<T,Data> Hierarchy;
|
typedef Constraint_hierarchy_2<T,
|
||||||
|
Compare,
|
||||||
|
Data> Hierarchy;
|
||||||
typedef std::pair<T, T> H_constraint;
|
typedef std::pair<T, T> H_constraint;
|
||||||
typedef std::list<T> H_vertex_list;
|
typedef std::list<T> H_vertex_list;
|
||||||
typedef std::list<H_constraint> H_constraint_list;
|
typedef std::list<H_constraint> H_constraint_list;
|
||||||
typedef typename std::list<T>::iterator H_vertex_it;
|
typedef typename std::list<T>::iterator H_vertex_it;
|
||||||
typedef typename std::list<H_constraint>::iterator H_constraint_it;
|
typedef typename std::list<H_constraint>::iterator H_constraint_it;
|
||||||
|
|
||||||
struct Pair_compare {
|
class Pair_compare {
|
||||||
|
Compare comp;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Pair_compare(const Compare& comp) : comp(comp) {}
|
||||||
|
|
||||||
bool operator()(const H_edge& e1, const H_edge& e2) const {
|
bool operator()(const H_edge& e1, const H_edge& e2) const {
|
||||||
if(e1.first->point() < e2.first->point()) {
|
if(comp(e1.first, e2.first)) {
|
||||||
return true;
|
return true;
|
||||||
} else if(e1.first->point() == e2.first->point() &&
|
} else if((! comp(e2.first, e1.first)) && // !less(e1,e2) && !less(e2,e1) == equal
|
||||||
e1.second->point() < e2.second->point()) {
|
comp(e1.second, e2.second)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -59,7 +67,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class H_context {
|
class H_context {
|
||||||
friend class Constraint_hierarchy_2<T,Data>;
|
friend class Constraint_hierarchy_2<T,Compare,Data>;
|
||||||
private:
|
private:
|
||||||
H_vertex_list* enclosing;
|
H_vertex_list* enclosing;
|
||||||
H_vertex_it pos;
|
H_vertex_it pos;
|
||||||
|
|
@ -85,6 +93,7 @@ public:
|
||||||
typedef std::pair<H_edge, H_context_list*> H_sc_value;
|
typedef std::pair<H_edge, H_context_list*> H_sc_value;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Compare comp;
|
||||||
// data for the 1d hierarchy
|
// data for the 1d hierarchy
|
||||||
H_c_to_sc_map c_to_sc_map;
|
H_c_to_sc_map c_to_sc_map;
|
||||||
H_sc_to_c_map sc_to_c_map;
|
H_sc_to_c_map sc_to_c_map;
|
||||||
|
|
@ -92,7 +101,11 @@ private:
|
||||||
H_vertex_map vertex_map;
|
H_vertex_map vertex_map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Constraint_hierarchy_2() { }
|
Constraint_hierarchy_2(const Compare& comp_ = Compare())
|
||||||
|
: comp(comp_)
|
||||||
|
, c_to_sc_map(Pair_compare(comp))
|
||||||
|
, sc_to_c_map(Pair_compare(comp))
|
||||||
|
{ }
|
||||||
Constraint_hierarchy_2(const Constraint_hierarchy_2& ch);
|
Constraint_hierarchy_2(const Constraint_hierarchy_2& ch);
|
||||||
~Constraint_hierarchy_2(){ clear();}
|
~Constraint_hierarchy_2(){ clear();}
|
||||||
void clear();
|
void clear();
|
||||||
|
|
@ -162,24 +175,27 @@ public:
|
||||||
void print() const;
|
void print() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
Constraint_hierarchy_2(const Constraint_hierarchy_2& ch)
|
Constraint_hierarchy_2(const Constraint_hierarchy_2& ch)
|
||||||
|
: comp(ch.comp)
|
||||||
|
, c_to_sc_map(Pair_compare(comp))
|
||||||
|
, sc_to_c_map(Pair_compare(comp))
|
||||||
{
|
{
|
||||||
copy(ch);
|
copy(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
Constraint_hierarchy_2<T,Data>&
|
Constraint_hierarchy_2<T,Compare,Data>&
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
operator=(const Constraint_hierarchy_2& ch){
|
operator=(const Constraint_hierarchy_2& ch){
|
||||||
copy(ch);
|
copy(ch);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
copy(const Constraint_hierarchy_2& ch1)
|
copy(const Constraint_hierarchy_2& ch1)
|
||||||
{
|
{
|
||||||
// create a identity transfer vertex map
|
// create a identity transfer vertex map
|
||||||
|
|
@ -194,9 +210,9 @@ copy(const Constraint_hierarchy_2& ch1)
|
||||||
copy(ch1, vmap);
|
copy(ch1, vmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
copy(const Constraint_hierarchy_2& ch1, std::map<T,T>& vmap)
|
copy(const Constraint_hierarchy_2& ch1, std::map<T,T>& vmap)
|
||||||
// copy with a tranfer vertex map
|
// copy with a tranfer vertex map
|
||||||
{
|
{
|
||||||
|
|
@ -245,9 +261,9 @@ copy(const Constraint_hierarchy_2& ch1, std::map<T,T>& vmap)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
swap(Constraint_hierarchy_2& ch)
|
swap(Constraint_hierarchy_2& ch)
|
||||||
{
|
{
|
||||||
c_to_sc_map.swap(ch.c_to_sc_map);
|
c_to_sc_map.swap(ch.c_to_sc_map);
|
||||||
|
|
@ -255,31 +271,31 @@ swap(Constraint_hierarchy_2& ch)
|
||||||
vertex_map.swap(ch.vertex_map);
|
vertex_map.swap(ch.vertex_map);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
is_constrained_vertex(T v) const
|
is_constrained_vertex(T v) const
|
||||||
{
|
{
|
||||||
return( vertex_map.find(v) != vertex_map.end() );
|
return( vertex_map.find(v) != vertex_map.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
is_constrained_edge(T va, T vb) const
|
is_constrained_edge(T va, T vb) const
|
||||||
{
|
{
|
||||||
return( c_to_sc_map.find(make_edge(va, vb)) != c_to_sc_map.end() );
|
return( c_to_sc_map.find(make_edge(va, vb)) != c_to_sc_map.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
is_subconstrained_edge(T va, T vb) const
|
is_subconstrained_edge(T va, T vb) const
|
||||||
{
|
{
|
||||||
return( sc_to_c_map.find(make_edge(va, vb)) != sc_to_c_map.end() );
|
return( sc_to_c_map.find(make_edge(va, vb)) != sc_to_c_map.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
vertices_in_constraint(H_constraint hc,
|
vertices_in_constraint(H_constraint hc,
|
||||||
H_vertex_it& v_first,
|
H_vertex_it& v_first,
|
||||||
H_vertex_it& v_past ) const
|
H_vertex_it& v_past ) const
|
||||||
|
|
@ -291,8 +307,8 @@ vertices_in_constraint(H_constraint hc,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
enclosing_constraint(H_edge he, H_constraint& hc) const
|
enclosing_constraint(H_edge he, H_constraint& hc) const
|
||||||
{
|
{
|
||||||
H_context_iterator hcit, past;
|
H_context_iterator hcit, past;
|
||||||
|
|
@ -303,8 +319,8 @@ enclosing_constraint(H_edge he, H_constraint& hc) const
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
enclosing_constraint(T vaa, T vbb, T& va, T& vb) const
|
enclosing_constraint(T vaa, T vbb, T& va, T& vb) const
|
||||||
{
|
{
|
||||||
H_context_iterator hcit, past;
|
H_context_iterator hcit, past;
|
||||||
|
|
@ -315,8 +331,8 @@ enclosing_constraint(T vaa, T vbb, T& va, T& vb) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
enclosing_constraints(T vaa, T vbb , H_constraint_list& hcl) const
|
enclosing_constraints(T vaa, T vbb , H_constraint_list& hcl) const
|
||||||
{
|
{
|
||||||
H_context_iterator hcit, past;
|
H_context_iterator hcit, past;
|
||||||
|
|
@ -328,9 +344,9 @@ enclosing_constraints(T vaa, T vbb , H_constraint_list& hcl) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_context
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_context
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
context(T va, T vb)
|
context(T va, T vb)
|
||||||
{
|
{
|
||||||
H_context_iterator hcit, past;
|
H_context_iterator hcit, past;
|
||||||
|
|
@ -338,9 +354,9 @@ context(T va, T vb)
|
||||||
return *hcit;
|
return *hcit;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
std::size_t
|
std::size_t
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
number_of_enclosing_constraints(T va, T vb)
|
number_of_enclosing_constraints(T va, T vb)
|
||||||
{
|
{
|
||||||
H_context_list* hcl = get_contexts(va, vb);
|
H_context_list* hcl = get_contexts(va, vb);
|
||||||
|
|
@ -348,9 +364,9 @@ number_of_enclosing_constraints(T va, T vb)
|
||||||
return hcl->size();
|
return hcl->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_context_iterator
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_context_iterator
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
contexts_begin(T va, T vb)
|
contexts_begin(T va, T vb)
|
||||||
{
|
{
|
||||||
H_context_iterator first, last;
|
H_context_iterator first, last;
|
||||||
|
|
@ -358,9 +374,9 @@ contexts_begin(T va, T vb)
|
||||||
return first;
|
return first;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_context_iterator
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_context_iterator
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
contexts_end(T va, T vb)
|
contexts_end(T va, T vb)
|
||||||
{
|
{
|
||||||
H_context_iterator first, last;
|
H_context_iterator first, last;
|
||||||
|
|
@ -368,9 +384,9 @@ contexts_end(T va, T vb)
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_vertex_it
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_vertex_it
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
vertices_in_constraint_begin(T va, T vb)
|
vertices_in_constraint_begin(T va, T vb)
|
||||||
{
|
{
|
||||||
H_c_iterator cit = c_to_sc_map.find(make_edge(va,vb));
|
H_c_iterator cit = c_to_sc_map.find(make_edge(va,vb));
|
||||||
|
|
@ -378,9 +394,9 @@ vertices_in_constraint_begin(T va, T vb)
|
||||||
return cit->second->begin();
|
return cit->second->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_vertex_it
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_vertex_it
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
vertices_in_constraint_end(T va, T vb)
|
vertices_in_constraint_end(T va, T vb)
|
||||||
{
|
{
|
||||||
H_c_iterator cit = c_to_sc_map.find(make_edge(va,vb));
|
H_c_iterator cit = c_to_sc_map.find(make_edge(va,vb));
|
||||||
|
|
@ -393,8 +409,8 @@ vertices_in_constraint_end(T va, T vb)
|
||||||
when a constraint is inserted,
|
when a constraint is inserted,
|
||||||
it is, at first, both a constraint and a subconstraint
|
it is, at first, both a constraint and a subconstraint
|
||||||
*/
|
*/
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
insert_constraint(T va, T vb){
|
insert_constraint(T va, T vb){
|
||||||
H_edge he = make_edge(va, vb);
|
H_edge he = make_edge(va, vb);
|
||||||
H_vertex_list* children = new H_vertex_list;
|
H_vertex_list* children = new H_vertex_list;
|
||||||
|
|
@ -427,9 +443,9 @@ insert_constraint(T va, T vb){
|
||||||
return false; //duplicate constraint - no insertion
|
return false; //duplicate constraint - no insertion
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
remove_constraint(T va, T vb){
|
remove_constraint(T va, T vb){
|
||||||
H_edge he = make_edge(va, vb);
|
H_edge he = make_edge(va, vb);
|
||||||
typename H_c_to_sc_map::iterator c_to_sc_it = c_to_sc_map.find(he);
|
typename H_c_to_sc_map::iterator c_to_sc_it = c_to_sc_map.find(he);
|
||||||
|
|
@ -464,38 +480,38 @@ remove_constraint(T va, T vb){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
constrain_vertex(T v, Data data){
|
constrain_vertex(T v, Data data){
|
||||||
vertex_map.insert(std::make_pair(v,data));
|
vertex_map.insert(std::make_pair(v,data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
unconstrain_vertex(T v){
|
unconstrain_vertex(T v){
|
||||||
vertex_map.erase(v);
|
vertex_map.erase(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
Data Constraint_hierarchy_2<T,Data>::
|
Data Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
get_data(T v){
|
get_data(T v){
|
||||||
CGAL_precondition( is_constrained_vertex(v) );
|
CGAL_precondition( is_constrained_vertex(v) );
|
||||||
return (*vertex_map.find(v)).second;
|
return (*vertex_map.find(v)).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
set_data(T v, Data data){
|
set_data(T v, Data data){
|
||||||
vertex_map.erase(v);
|
vertex_map.erase(v);
|
||||||
vertex_map.insert(std::make_pair(v,data));
|
vertex_map.insert(std::make_pair(v,data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
clear()
|
clear()
|
||||||
{
|
{
|
||||||
H_c_iterator cit;
|
H_c_iterator cit;
|
||||||
|
|
@ -516,8 +532,8 @@ clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
bool Constraint_hierarchy_2<T,Data>::
|
bool Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
next_along_sc(T va, T vb, T& w) const
|
next_along_sc(T va, T vb, T& w) const
|
||||||
{
|
{
|
||||||
// find the next vertex after vb along any enclosing constrained
|
// find the next vertex after vb along any enclosing constrained
|
||||||
|
|
@ -545,8 +561,8 @@ next_along_sc(T va, T vb, T& w) const
|
||||||
Attention, le point v DOIT etre un point de Steiner,
|
Attention, le point v DOIT etre un point de Steiner,
|
||||||
et les segments va,v et v,vb sont des sous contraintes.
|
et les segments va,v et v,vb sont des sous contraintes.
|
||||||
*/
|
*/
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
remove_Steiner(T v, T va, T vb)
|
remove_Steiner(T v, T va, T vb)
|
||||||
{
|
{
|
||||||
// remove a Steiner point
|
// remove a Steiner point
|
||||||
|
|
@ -577,16 +593,16 @@ remove_Steiner(T v, T va, T vb)
|
||||||
same as add_Steiner
|
same as add_Steiner
|
||||||
precondition : va,vb est une souscontrainte.
|
precondition : va,vb est une souscontrainte.
|
||||||
*/
|
*/
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void Constraint_hierarchy_2<T,Data>::
|
void Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
split_constraint(T va, T vb, T vc){
|
split_constraint(T va, T vb, T vc){
|
||||||
add_Steiner(va, vb, vc);
|
add_Steiner(va, vb, vc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
add_Steiner(T va, T vb, T vc){
|
add_Steiner(T va, T vb, T vc){
|
||||||
H_context_list* hcl = get_contexts(va, vb);
|
H_context_list* hcl = get_contexts(va, vb);
|
||||||
CGAL_triangulation_assertion(hcl != NULL);
|
CGAL_triangulation_assertion(hcl != NULL);
|
||||||
|
|
@ -635,19 +651,19 @@ add_Steiner(T va, T vb, T vc){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
inline
|
inline
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_edge
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_edge
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
make_edge(T va, T vb) const
|
make_edge(T va, T vb) const
|
||||||
{
|
{
|
||||||
return (va->point()<vb->point()) ? H_edge(va,vb) : H_edge(vb,va);
|
return comp(va, vb) ? H_edge(va,vb) : H_edge(vb,va);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
inline
|
inline
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_context_list*
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_context_list*
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
get_contexts(T va, T vb) const
|
get_contexts(T va, T vb) const
|
||||||
{
|
{
|
||||||
H_sc_iterator sc_iter = sc_to_c_map.find(make_edge(va,vb));
|
H_sc_iterator sc_iter = sc_to_c_map.find(make_edge(va,vb));
|
||||||
|
|
@ -656,10 +672,10 @@ get_contexts(T va, T vb) const
|
||||||
return (*sc_iter).second;
|
return (*sc_iter).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
get_contexts(T va, T vb,
|
get_contexts(T va, T vb,
|
||||||
H_context_iterator& ctxt,
|
H_context_iterator& ctxt,
|
||||||
H_context_iterator& past) const
|
H_context_iterator& past) const
|
||||||
|
|
@ -674,19 +690,19 @@ get_contexts(T va, T vb,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
inline
|
inline
|
||||||
typename Constraint_hierarchy_2<T,Data>::H_vertex_it
|
typename Constraint_hierarchy_2<T,Compare,Data>::H_vertex_it
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
get_pos(T va, T vb) const
|
get_pos(T va, T vb) const
|
||||||
//return pos in the first context
|
//return pos in the first context
|
||||||
{
|
{
|
||||||
return (*sc_to_c_map.find(make_edge(va,vb))).second->begin().pos;
|
return (*sc_to_c_map.find(make_edge(va,vb))).second->begin().pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
oriented_end(T va, T vb, T& vc) const
|
oriented_end(T va, T vb, T& vc) const
|
||||||
{
|
{
|
||||||
H_context_iterator ctxt, past;
|
H_context_iterator ctxt, past;
|
||||||
|
|
@ -698,9 +714,9 @@ oriented_end(T va, T vb, T& vc) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class T, class Data>
|
template <class T, class Compare, class Data>
|
||||||
void
|
void
|
||||||
Constraint_hierarchy_2<T,Data>::
|
Constraint_hierarchy_2<T,Compare,Data>::
|
||||||
print() const
|
print() const
|
||||||
{
|
{
|
||||||
H_c_iterator hcit;
|
H_c_iterator hcit;
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,18 @@
|
||||||
#include <CGAL/Constraint_hierarchy_2.h>
|
#include <CGAL/Constraint_hierarchy_2.h>
|
||||||
|
|
||||||
class Vertex {
|
struct Less
|
||||||
int i;
|
{
|
||||||
public:
|
bool operator()(int i, int j) const
|
||||||
int point() const {
|
{
|
||||||
return i;
|
return i < j;
|
||||||
}
|
|
||||||
Vertex(const int i) {
|
|
||||||
this->i = i;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Vertex* Vh;
|
typedef int Vh;
|
||||||
typedef bool Data;
|
typedef bool Data;
|
||||||
typedef CGAL::Constraint_hierarchy_2<Vh, Data> Hierarchy;
|
typedef CGAL::Constraint_hierarchy_2<Vh,
|
||||||
|
Less,
|
||||||
|
Data> Hierarchy;
|
||||||
typedef Hierarchy::H_constraint H_constraint;
|
typedef Hierarchy::H_constraint H_constraint;
|
||||||
typedef Hierarchy::H_vertex H_vertex;
|
typedef Hierarchy::H_vertex H_vertex;
|
||||||
typedef Hierarchy::H_vertex_it H_vertex_it;
|
typedef Hierarchy::H_vertex_it H_vertex_it;
|
||||||
|
|
@ -29,7 +28,7 @@ void
|
||||||
_test_cls_hierarchy_2()
|
_test_cls_hierarchy_2()
|
||||||
{
|
{
|
||||||
Vh v[10];
|
Vh v[10];
|
||||||
for(int i=0; i <10; i++) { v[i] = new Vertex(i);}
|
for(int i=0; i <10; i++) { v[i] = i;}
|
||||||
|
|
||||||
Hierarchy h;
|
Hierarchy h;
|
||||||
h.insert_constraint(v[1],v[2]);
|
h.insert_constraint(v[1],v[2]);
|
||||||
|
|
@ -135,8 +134,6 @@ _test_cls_hierarchy_2()
|
||||||
h.remove_constraint(v[3],v[4]);
|
h.remove_constraint(v[3],v[4]);
|
||||||
// h.print();
|
// h.print();
|
||||||
|
|
||||||
for(int i=0; i <10; i++) { delete v[i];}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
|
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||||
|
#include <CGAL/Constrained_triangulation_plus_2.h>
|
||||||
|
#include <CGAL/Projection_traits_xy_3.h>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel EIK;
|
||||||
|
typedef CGAL::Projection_traits_xy_3<EIK> K;
|
||||||
|
typedef CGAL::Triangulation_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;
|
||||||
|
typedef CGAL::Constrained_Delaunay_triangulation_2<K, TDS, Itag> CDTi;
|
||||||
|
typedef CGAL::Constrained_triangulation_plus_2<CDTi> CDT;
|
||||||
|
|
||||||
|
typedef CDT::Point Point;
|
||||||
|
typedef CDT::Vertex_handle Vertex_handle;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
CDT cdt;
|
||||||
|
|
||||||
|
std::vector<std::pair<Vertex_handle, Vertex_handle> > constraints;
|
||||||
|
std::vector<std::pair<Point,Point> > segments;
|
||||||
|
|
||||||
|
segments.push_back(std::make_pair(Point(212.69651243, 168.58113131, 0),
|
||||||
|
Point(212.69487813, 169.35340097, 0)));
|
||||||
|
segments.push_back(std::make_pair(Point( 211.49303932, 161.00812931, 0),
|
||||||
|
Point(211.49303932, 172.95244391, 0)));
|
||||||
|
segments.push_back(std::make_pair(Point( 210.13500000, 169.20200000, 0),
|
||||||
|
Point(232.65300000, 167.91200000, 0)));
|
||||||
|
segments.push_back(std::make_pair(Point( 210.13500000, 169.20200000, 0),
|
||||||
|
Point(232.69100000, 189.32500000, 0)));
|
||||||
|
|
||||||
|
Point p, q;
|
||||||
|
for(unsigned int i=0;i< segments.size(); i++){
|
||||||
|
p = segments[i].first;
|
||||||
|
q = segments[i].second;
|
||||||
|
Vertex_handle v = cdt.insert(p);
|
||||||
|
Vertex_handle w = cdt.insert(q);
|
||||||
|
constraints.push_back(std::make_pair(v,w));
|
||||||
|
}
|
||||||
|
for(unsigned int i=0; i < constraints.size(); ++i){
|
||||||
|
std::cerr << i << std::endl;
|
||||||
|
cdt.insert_constraint(constraints[i].first, constraints[i].second);
|
||||||
|
}
|
||||||
|
std::cerr << "done" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue