mirror of https://github.com/CGAL/cgal
added Triangulation_data_structure_using_list_2
This commit is contained in:
parent
a44a0a379a
commit
59fc9f2ec7
File diff suppressed because it is too large
Load Diff
|
|
@ -978,7 +978,7 @@ copy_tds(const Tds &tds, const Vertex* v)
|
|||
//the class Geom_traits is required to have a pertinent operator=
|
||||
_dimension = tds.dimension();
|
||||
|
||||
if(tds.number_of_vertices() == 0){return static_cast<Vertex*>(NULL);}
|
||||
//if(tds.number_of_vertices() == 0){return static_cast<Vertex*>(NULL);}
|
||||
|
||||
std::map< const void*, void*, std::less<const void*> > V;
|
||||
std::map< const void*, void*, std::less<const void*> > F;
|
||||
|
|
@ -991,6 +991,8 @@ copy_tds(const Tds &tds, const Vertex* v)
|
|||
it != tds.vertices_end(); ++it) {
|
||||
V[&(*it)] = new Vertex( it->point() );
|
||||
}
|
||||
V[0] = 0 ; //to cope with lower dimensional cases when creating faces
|
||||
|
||||
//set infinite_vertex
|
||||
v_inf = static_cast<Vertex*>(V[v]);
|
||||
set_infinite_vertex(v_inf);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,233 @@
|
|||
// ======================================================================
|
||||
//
|
||||
// Copyright (c) 1997 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : Triangulation/include/CGAL/Triangulation_dsul_face_2.h
|
||||
// source : $RCSfile$
|
||||
// revision : $Revision$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Mariette Yvinec
|
||||
//
|
||||
// coordinator : Mariette Yvinec <Mariette Yvinec@sophia.inria.fr>
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef CGAL_TRIANGULATION_DSUL_FACE_2_H
|
||||
#define CGAL_TRIANGULATION_DSUL_FACE_2_H
|
||||
|
||||
#include <CGAL/Triangulation_short_names_2.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template <class Vb, class Fb >
|
||||
class Triangulation_dsul_vertex_2 ;
|
||||
|
||||
|
||||
template < class Vb, class Fb >
|
||||
class Triangulation_dsul_face_2
|
||||
: public Fb
|
||||
{
|
||||
public:
|
||||
typedef Triangulation_dsul_vertex_2<Vb,Fb> Vertex;
|
||||
typedef Triangulation_dsul_face_2<Vb,Fb> Face;
|
||||
|
||||
private:
|
||||
Face* _previous;
|
||||
Face* _next;
|
||||
|
||||
public :
|
||||
// creators
|
||||
Triangulation_dsul_face_2()
|
||||
: Fb(), _previous(this), _next(this)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_face_2(Vertex* v0, Vertex* v1, Vertex* v2)
|
||||
: Fb(v0,v1,v2)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_face_2(Vertex* v0, Vertex* v1, Vertex* v2,
|
||||
Face* n0, Face* n1, Face* n2)
|
||||
: Fb(v0,v1,v2,n0,n1,n2)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_face_2( const Face & f)
|
||||
: Fb(f)
|
||||
{}
|
||||
|
||||
//setting
|
||||
void set_vertex(int i, Vertex* v) { Fb::set_vertex(i,v);}
|
||||
void set_neighbor(int i, Face* n) { Fb::set_neighbor(i,n);}
|
||||
void set_vertices() { Fb::set_vertices();}
|
||||
void set_neighbors() { Fb::set_neighbors();}
|
||||
void set_vertices(Vertex* v0, Vertex* v1, Vertex* v2);
|
||||
void set_neighbors(Face* n0, Face* n1, Face* n2);
|
||||
//void reorient(); inherited from Face_base
|
||||
|
||||
//Vertex Access Member Functions
|
||||
Vertex* vertex(int i) const;
|
||||
Vertex* mirror_vertex(int i) const;
|
||||
bool has_vertex(const Vertex* v) const;
|
||||
bool has_vertex(const Vertex* v, int& i) const;
|
||||
int index(const Vertex* v) const;
|
||||
|
||||
// Neighbors Access Functions
|
||||
Face* neighbor(int i) const;
|
||||
bool has_neighbor(const Face* n) const;
|
||||
bool has_neighbor(const Face* n, int& i) const;
|
||||
int index(const Face* n) const;
|
||||
int mirror_index(int i) const;
|
||||
|
||||
//Miscelleanous
|
||||
bool is_valid(bool verbose = false, int level = 0) const;
|
||||
|
||||
//Handling the list of faces
|
||||
Face* previous() const {return _previous;}
|
||||
Face* next() const {return _next;}
|
||||
void set_previous(Face* f) {_previous = f;};
|
||||
void set_next(Face* f) {_next = f;};
|
||||
};
|
||||
|
||||
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline void
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
set_vertices(Vertex* v0, Vertex* v1, Vertex* v2)
|
||||
{
|
||||
Fb::set_vertices(v0,v1,v2);
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline void
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
set_neighbors(Face* n0, Face* n1, Face* n2)
|
||||
{
|
||||
Fb::set_neighbors(n0,n1,n2);
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline
|
||||
Triangulation_dsul_vertex_2<Vb,Fb> *
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
vertex(int i) const
|
||||
{
|
||||
return( (Vertex*) (Fb::vertex(i)));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline
|
||||
Triangulation_dsul_vertex_2<Vb,Fb> *
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
mirror_vertex(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition ( neighbor(i) != NULL);
|
||||
return neighbor(i)->vertex(neighbor(i)->index(this));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline int
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
mirror_index(int i) const
|
||||
{
|
||||
CGAL_triangulation_precondition (neighbor(i) != NULL);
|
||||
return neighbor(i)->index(this);
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline bool
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
has_vertex(const Vertex* v) const
|
||||
{
|
||||
return (Fb::has_vertex(v));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline bool
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
has_vertex(const Vertex* v, int& i) const
|
||||
{
|
||||
return (Fb::has_vertex(v,i));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline int
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
index(const Vertex* v) const
|
||||
{
|
||||
return(Fb::vertex_index(v));
|
||||
}
|
||||
|
||||
// Neighbors Access Functions
|
||||
template < class Vb, class Fb >
|
||||
inline
|
||||
Triangulation_dsul_face_2<Vb,Fb>*
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
neighbor(int i) const
|
||||
{
|
||||
return ((Face*) Fb::neighbor(i));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline bool
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
has_neighbor(const Face* n) const
|
||||
{
|
||||
return (Fb::has_neighbor(n));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline bool
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
has_neighbor(const Face* n, int& i) const
|
||||
{
|
||||
return (Fb::has_neighbor(n,i));
|
||||
}
|
||||
|
||||
template < class Vb, class Fb >
|
||||
inline int
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
index(const Face* n) const
|
||||
{
|
||||
return(Fb::face_index(n));
|
||||
}
|
||||
|
||||
//Miscelleanous
|
||||
template < class Vb, class Fb >
|
||||
bool
|
||||
Triangulation_dsul_face_2<Vb,Fb>::
|
||||
is_valid(bool verbose, int level) const
|
||||
{
|
||||
bool result = Fb::is_valid(verbose, level);
|
||||
for(int i = 0; i <= dimension(); i++) {
|
||||
Face* n = neighbor(i);
|
||||
int in = n->index(this);
|
||||
result = result && ( this == n->neighbor(in) );
|
||||
switch(dimension()) {
|
||||
case 0 :
|
||||
break;
|
||||
case 1 :
|
||||
result = result && in == 1-i;
|
||||
result = result && ( this->vertex(1-i) == n->vertex(1-in));
|
||||
break;
|
||||
case 2 :
|
||||
result = result && ( this->vertex(cw(i)) == n->vertex(ccw(in)))
|
||||
&& ( this->vertex(ccw(i)) == n->vertex(cw(in)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif //CGAL_TRIANGULATION_DSUL_FACE_2_H
|
||||
|
|
@ -0,0 +1,659 @@
|
|||
// ======================================================================
|
||||
//
|
||||
// Copyright (c) 1997 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------
|
||||
//
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : include/CGAL/Triangulation_ds_iterators_2.h
|
||||
// package : Triangulation
|
||||
// source : $RCSfile$
|
||||
// revision : $Revision$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Mariette Yvinec
|
||||
//
|
||||
// coordinator : Mariette Yvinec <Mariette Yvinec@sophia.inria.fr>
|
||||
//
|
||||
// ======================================================================
|
||||
|
||||
#ifndef CGAL_TRIANGULATION_DSUL_ITERATORS_2_H
|
||||
#define CGAL_TRIANGULATION_DSUL_ITERATORS_2_H
|
||||
|
||||
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#include <CGAL/triangulation_assertions.h>
|
||||
#include <CGAL/Triangulation_short_names_2.h>
|
||||
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
// The iterator_base visits all the full dimensional faces
|
||||
// of the Tds
|
||||
// whatever may be the dimension of the Tds
|
||||
|
||||
template <class Tds>
|
||||
class Triangulation_dsul_iterator_base_2
|
||||
{
|
||||
public:
|
||||
typedef typename Tds::Face value_type;
|
||||
typedef typename Tds::Face * pointer;
|
||||
typedef typename Tds::Face & reference;
|
||||
typedef std::size_t size_type;
|
||||
typedef std::ptrdiff_t difference_type;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
|
||||
typedef Triangulation_dsul_iterator_base_2<Tds> Iterator_base;
|
||||
typedef typename Tds::Face Face;
|
||||
|
||||
Triangulation_dsul_iterator_base_2()
|
||||
: _tds(NULL), pos(NULL)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_iterator_base_2(const Tds* tds)
|
||||
: _tds(tds), pos(tds->dummy().next())
|
||||
{}
|
||||
|
||||
Triangulation_dsul_iterator_base_2(const Tds* tds, int)
|
||||
: _tds(tds), pos(tds->past_end())
|
||||
{}
|
||||
|
||||
Triangulation_dsul_iterator_base_2(const Tds* tds, const Face* f)
|
||||
: _tds(tds), pos(f)
|
||||
{}
|
||||
|
||||
protected:
|
||||
const Tds* _tds;
|
||||
const Face* pos;
|
||||
|
||||
void increment() {pos=pos->next();}
|
||||
void decrement() {pos=pos->previous();}
|
||||
|
||||
public:
|
||||
Iterator_base& operator=(const Iterator_base& fi);
|
||||
bool operator==(const Iterator_base& fi) const;
|
||||
bool operator!=(const Iterator_base& fi) const;
|
||||
|
||||
Iterator_base& operator++();
|
||||
Iterator_base& operator--();
|
||||
Iterator_base operator++(int);
|
||||
Iterator_base operator--(int);
|
||||
|
||||
Face& operator*() const
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL && pos != _tds->past_end());
|
||||
return const_cast<Face&>(*pos);
|
||||
}
|
||||
|
||||
Face* operator->() const
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL);
|
||||
return const_cast<Face*>(pos);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
// The following iterator visit the 2-faces
|
||||
|
||||
template<class Tds>
|
||||
class Triangulation_dsul_face_iterator_2
|
||||
: public Triangulation_dsul_iterator_base_2<Tds>
|
||||
{
|
||||
public:
|
||||
typedef Triangulation_dsul_iterator_base_2<Tds> Iterator_base;
|
||||
typedef Triangulation_dsul_face_iterator_2<Tds> Face_iterator;
|
||||
|
||||
Triangulation_dsul_face_iterator_2() : Iterator_base() {}
|
||||
|
||||
Triangulation_dsul_face_iterator_2(const Tds * tds) : Iterator_base(tds)
|
||||
{
|
||||
if (tds->dimension() <2) pos= tds->past_end();
|
||||
}
|
||||
|
||||
Triangulation_dsul_face_iterator_2(const Tds* tds, int i)
|
||||
: Iterator_base(tds,i)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_face_iterator_2(const Face_iterator& fi)
|
||||
: Iterator_base(fi._tds, fi.pos)
|
||||
{}
|
||||
|
||||
Face_iterator& operator=(const Face_iterator& fi);
|
||||
|
||||
Face_iterator& operator++();
|
||||
Face_iterator& operator--();
|
||||
Face_iterator operator++(int);
|
||||
Face_iterator operator--(int);
|
||||
|
||||
};
|
||||
|
||||
|
||||
template < class Tds>
|
||||
class Triangulation_dsul_vertex_iterator_2
|
||||
: public Triangulation_dsul_iterator_base_2<Tds>
|
||||
{
|
||||
public:
|
||||
typedef typename Tds::Vertex Vertex;
|
||||
|
||||
typedef Vertex value_type;
|
||||
typedef Vertex * pointer;
|
||||
typedef Vertex & reference;
|
||||
|
||||
typedef Triangulation_dsul_iterator_base_2<Tds> Iterator_base;
|
||||
typedef Triangulation_dsul_vertex_iterator_2<Tds> Vertex_iterator;
|
||||
|
||||
private :
|
||||
int index;
|
||||
|
||||
public:
|
||||
Triangulation_dsul_vertex_iterator_2()
|
||||
: Iterator_base(), index(0)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_vertex_iterator_2(const Tds* tds);
|
||||
|
||||
Triangulation_dsul_vertex_iterator_2(const Tds* tds, int i)
|
||||
: Iterator_base(tds,i), index(0)
|
||||
{}
|
||||
|
||||
Vertex_iterator& operator++();
|
||||
Vertex_iterator& operator--();
|
||||
Vertex_iterator operator++(int);
|
||||
Vertex_iterator operator--(int);
|
||||
bool operator==(const Vertex_iterator& fi) const;
|
||||
bool operator!=(const Vertex_iterator& fi) const;
|
||||
|
||||
Vertex& operator*() const
|
||||
{
|
||||
CGAL_triangulation_assertion( pos != NULL && pos != _tds->past_end());
|
||||
return *(pos->vertex(index));
|
||||
}
|
||||
|
||||
Vertex* operator->() const
|
||||
{
|
||||
CGAL_triangulation_assertion( pos != NULL && pos != _tds->past_end());
|
||||
return pos->vertex(index);
|
||||
}
|
||||
|
||||
private:
|
||||
void increment();
|
||||
void decrement() ;
|
||||
bool associated_vertex();
|
||||
|
||||
};
|
||||
|
||||
|
||||
template <class Tds>
|
||||
class Triangulation_dsul_edge_iterator_2
|
||||
: public Triangulation_dsul_iterator_base_2<Tds>
|
||||
{
|
||||
public:
|
||||
typedef typename Tds::Edge Edge;
|
||||
|
||||
typedef Edge value_type;
|
||||
typedef Edge * pointer;
|
||||
typedef Edge & reference;
|
||||
|
||||
typedef Triangulation_dsul_iterator_base_2<Tds> Iterator_base;
|
||||
typedef Triangulation_dsul_edge_iterator_2<Tds> Edge_iterator;
|
||||
|
||||
private:
|
||||
int index;
|
||||
|
||||
public:
|
||||
Triangulation_dsul_edge_iterator_2()
|
||||
: Iterator_base(),index(0)
|
||||
{}
|
||||
|
||||
Triangulation_dsul_edge_iterator_2(const Tds * tds);
|
||||
|
||||
|
||||
Triangulation_dsul_edge_iterator_2(const Tds* tds, int i)
|
||||
: Iterator_base(tds,i),index(0)
|
||||
{
|
||||
if (_tds->dimension() == 1) {index = 2;}
|
||||
}
|
||||
|
||||
bool operator==(const Edge_iterator& fi) const ;
|
||||
bool operator!=(const Edge_iterator& fi) const {return !(*this== fi);}
|
||||
Edge_iterator& operator++();
|
||||
Edge_iterator& operator--();
|
||||
Edge_iterator operator++(int);
|
||||
Edge_iterator operator--(int);
|
||||
|
||||
Edge operator*() const
|
||||
{return std::make_pair(const_cast<Face*>(pos), index);}
|
||||
|
||||
private:
|
||||
void increment();
|
||||
void decrement();
|
||||
bool associated_edge();
|
||||
};
|
||||
|
||||
|
||||
// Iterator base implementation
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_iterator_base_2<Tds>&
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator=(const Iterator_base& fi)
|
||||
{
|
||||
pos = fi.pos;
|
||||
_tds = fi._tds;
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline bool
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator==(const Iterator_base& fi) const
|
||||
{
|
||||
return ((pos == fi.pos )&&(_tds==fi._tds));
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline bool
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator!=(const Iterator_base& fi) const
|
||||
{
|
||||
return !(*this == fi);
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds>&
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator++()
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL && pos != _tds->past_end());
|
||||
increment();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds>&
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator--()
|
||||
{
|
||||
CGAL_triangulation_precondition( pos != NULL && pos != _tds->dummy().next());
|
||||
decrement();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator++(int)
|
||||
{
|
||||
Iterator_base tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds>
|
||||
Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
operator--(int)
|
||||
{
|
||||
Iterator_base tmp(*this);
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// template<class Tds>
|
||||
// inline
|
||||
// typename Tds::Face&
|
||||
// Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
// operator*() const
|
||||
// {
|
||||
// CGAL_triangulation_precondition(pos != NULL);
|
||||
// return const_cast<Face&>(*pos);
|
||||
// }
|
||||
|
||||
// template<class Tds>
|
||||
// inline
|
||||
// typename Tds::Face*
|
||||
// Triangulation_dsul_iterator_base_2<Tds> ::
|
||||
// operator->() const
|
||||
// {
|
||||
// CGAL_triangulation_precondition(pos != NULL);
|
||||
// return const_cast<Face*>(pos);
|
||||
// }
|
||||
|
||||
// Face iterator implementation
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_face_iterator_2<Tds>&
|
||||
Triangulation_dsul_face_iterator_2<Tds>::
|
||||
operator=(const Face_iterator& fi)
|
||||
{
|
||||
Iterator_base::operator=(fi);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_face_iterator_2<Tds>&
|
||||
Triangulation_dsul_face_iterator_2<Tds>::
|
||||
operator++()
|
||||
{
|
||||
Iterator_base::operator++();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_face_iterator_2<Tds>&
|
||||
Triangulation_dsul_face_iterator_2<Tds>::
|
||||
operator--()
|
||||
{
|
||||
Iterator_base::operator--();
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_face_iterator_2<Tds>
|
||||
Triangulation_dsul_face_iterator_2<Tds>::
|
||||
operator++(int)
|
||||
{
|
||||
Face_iterator tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline
|
||||
Triangulation_dsul_face_iterator_2<Tds>
|
||||
Triangulation_dsul_face_iterator_2<Tds>::
|
||||
operator--(int)
|
||||
{
|
||||
Face_iterator tmp(*this);
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
// Vertex iterator implementation
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
Triangulation_dsul_vertex_iterator_2(const Tds * tds)
|
||||
: Iterator_base(tds), index(0)
|
||||
{
|
||||
while ( pos!= tds->past_end() && !associated_vertex()){
|
||||
increment();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
void
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
increment()
|
||||
{
|
||||
if (_tds->dimension()== -1) {// there is only one vertex
|
||||
CGAL_triangulation_assertion(pos == _tds->past_end()->next() && index==0);
|
||||
pos = _tds->past_end();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( index==_tds->dimension()) {Iterator_base::increment(); index = 0;}
|
||||
else { index +=1; }
|
||||
return;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
void
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
decrement()
|
||||
{
|
||||
if (_tds->dimension()== -1) {// there is only one vertex
|
||||
CGAL_triangulation_assertion(pos == _tds->past_end() && index==0);
|
||||
pos = pos->next();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
Iterator_base::decrement();
|
||||
index = _tds->dimension();
|
||||
}
|
||||
else {index -= 1;}
|
||||
return;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline bool
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
associated_vertex()
|
||||
{
|
||||
return ( pos->vertex(index)->face() == pos ); // marche en toute dimension
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds>&
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator++()
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL && pos != _tds->past_end());
|
||||
do increment();
|
||||
while (pos != _tds->past_end() && !associated_vertex());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds>&
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator--()
|
||||
{
|
||||
CGAL_triangulation_assertion(pos != NULL && *this != Vertex_iterator(_tds));
|
||||
do decrement();
|
||||
while ( pos != _tds->past_end() && !associated_vertex());
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator++(int)
|
||||
{
|
||||
Vertex_iterator tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds>
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator--(int)
|
||||
{
|
||||
Vertex_iterator tmp(*this);
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
bool
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator==(const Vertex_iterator& fi) const
|
||||
{
|
||||
if (pos==NULL || pos==_tds->past_end())
|
||||
return (pos==fi.pos) && (_tds==fi._tds) ;
|
||||
return (pos==fi.pos) && (_tds==fi._tds) && (index == fi.index);
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
inline bool
|
||||
Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
operator!=(const Vertex_iterator& fi) const
|
||||
{
|
||||
return !(*this == fi);
|
||||
}
|
||||
|
||||
// template<class Tds>
|
||||
// inline
|
||||
// typename Tds::Vertex&
|
||||
// Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
// operator*() const
|
||||
// {
|
||||
// CGAL_triangulation_assertion( pos != NULL);
|
||||
// if (pos == (Face*)1) {// only one vertex;
|
||||
// return *(_tds->infinite_vertex());
|
||||
// }
|
||||
// return *(pos->vertex(index));
|
||||
// }
|
||||
|
||||
// template<class Tds>
|
||||
// inline
|
||||
// typename Tds::Vertex*
|
||||
// Triangulation_dsul_vertex_iterator_2<Tds> ::
|
||||
// operator->() const
|
||||
// {
|
||||
// CGAL_triangulation_assertion( pos != NULL);
|
||||
// if (pos == (Face*)1) {// only one vertex;
|
||||
// return _tds->infinite_vertex();
|
||||
// }
|
||||
// return pos->vertex(index);
|
||||
// }
|
||||
|
||||
|
||||
// Edge iterator implementation
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
Triangulation_dsul_edge_iterator_2(const Tds * tds)
|
||||
: Iterator_base(tds), index(0)
|
||||
{
|
||||
if (_tds->dimension()<= 0) {
|
||||
pos = _tds->past_end(); // there is no edge
|
||||
return;
|
||||
}
|
||||
if (_tds->dimension() == 1) index = 2;
|
||||
while ( pos != _tds->past_end() && !associated_edge() ) increment();
|
||||
}
|
||||
|
||||
|
||||
template<class Tds>
|
||||
bool
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
operator==(const Edge_iterator& fi) const
|
||||
{
|
||||
if (pos==NULL || pos==_tds->past_end())
|
||||
return (pos==fi.pos) && (_tds==fi._tds) ;
|
||||
return (pos==fi.pos) && (_tds==fi._tds) && (index == fi.index);
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
void
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
increment()
|
||||
{
|
||||
CGAL_triangulation_precondition(_tds->dimension() >= 1);
|
||||
if (_tds->dimension() == 1) {Iterator_base::increment();}
|
||||
else {
|
||||
if (index == 2) {
|
||||
Iterator_base::increment();
|
||||
index = 0;
|
||||
}
|
||||
else{
|
||||
index +=1;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
void
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
decrement()
|
||||
{
|
||||
CGAL_triangulation_precondition(_tds->dimension() >= 1);
|
||||
if (_tds->dimension() == 1) {Iterator_base::decrement();}
|
||||
else {
|
||||
if (index == 0) {
|
||||
Iterator_base::decrement();
|
||||
index = 2;
|
||||
}
|
||||
else {index -= 1;}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
bool
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
associated_edge()
|
||||
{
|
||||
if (_tds->dimension() == 1) {return true;}
|
||||
return std::less<const Face*>()(pos, pos->neighbor(index));
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds>&
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
operator++()
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL && pos != _tds->past_end());
|
||||
do increment();
|
||||
while( pos != _tds->past_end() && !associated_edge());
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds>&
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
operator--()
|
||||
{
|
||||
CGAL_triangulation_precondition(pos != NULL && *this != Edge_iterator(_tds));
|
||||
do decrement();
|
||||
while ( !associated_edge() && *this != Edge_iterator(_tds) );
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
operator++(int)
|
||||
{
|
||||
Edge_iterator tmp(*this);
|
||||
++(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds>
|
||||
Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
operator--(int)
|
||||
{
|
||||
Edge_iterator tmp(*this);
|
||||
--(*this);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
// template<class Tds>
|
||||
// typename Tds::Edge
|
||||
// Triangulation_dsul_edge_iterator_2<Tds> ::
|
||||
// operator*() const
|
||||
// {
|
||||
// return std::make_pair(const_cast<Face*>(pos), index);
|
||||
// }
|
||||
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif //CGAL_TRIANGULATION_DSUL_ITERATORS_2_H
|
||||
|
||||
|
|
@ -0,0 +1,118 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// file : Triangulation/include/CGAL/Triangulation_dsul_vertex_2.h
|
||||
// source : $RCSfile$
|
||||
// revision : $Revision$
|
||||
// revision_date : $Date$
|
||||
// author(s) : Mariette Yvinec
|
||||
//
|
||||
// coordinator : Mariette Yvinec < Mariette Yvinec@sophia.inria.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifndef CGAL_TRIANGULATION_DSUL_VERTEX_2_H
|
||||
#define CGAL_TRIANGULATION_DSUL_VERTEX_2_H
|
||||
|
||||
#include <utility>
|
||||
#include <CGAL/Triangulation_short_names_2.h>
|
||||
#include <CGAL/Triangulation_utils_2.h>
|
||||
#include <CGAL/Triangulation_ds_circulators_2.h>
|
||||
|
||||
CGAL_BEGIN_NAMESPACE
|
||||
|
||||
template < class Vb, class Fb >
|
||||
class Triangulation_dsul_face_2;
|
||||
|
||||
template <class Vb, class Fb >
|
||||
class Triangulation_dsul_vertex_2
|
||||
: public Vb,
|
||||
public Triangulation_cw_ccw_2
|
||||
{
|
||||
public:
|
||||
typedef typename Vb::Point Point;
|
||||
typedef Triangulation_dsul_vertex_2<Vb,Fb> Vertex;
|
||||
typedef Triangulation_dsul_face_2<Vb,Fb> Face;
|
||||
typedef std::pair< Face*,int> Edge;
|
||||
typedef Triangulation_ds_face_circulator_2<Vertex,Face> Face_circulator;
|
||||
typedef Triangulation_ds_vertex_circulator_2<Vertex,Face>
|
||||
Vertex_circulator;
|
||||
typedef Triangulation_ds_edge_circulator_2<Vertex,Face> Edge_circulator;
|
||||
|
||||
//CREATORS
|
||||
Triangulation_dsul_vertex_2() : Vb() {}
|
||||
Triangulation_dsul_vertex_2(const Point & p) : Vb(p) {}
|
||||
Triangulation_dsul_vertex_2(const Point & p, Face * f) : Vb(p, f ) {}
|
||||
|
||||
//SETTING
|
||||
void set_face(Face* f) { Vb::set_face(f); }
|
||||
|
||||
//ACCESS
|
||||
Face* face() const {return ( (Face *) (Vb::face()) );}
|
||||
int degree() const ;
|
||||
|
||||
inline Vertex_circulator incident_vertices() const
|
||||
{return Vertex_circulator(this);}
|
||||
|
||||
inline Vertex_circulator incident_vertices(const Face* f) const
|
||||
{return Vertex_circulator(this,f);}
|
||||
|
||||
inline Face_circulator incident_faces() const
|
||||
{ return Face_circulator(this);}
|
||||
|
||||
inline Face_circulator incident_faces(const Face* f) const
|
||||
{ return Face_circulator(this, f);}
|
||||
|
||||
inline Edge_circulator incident_edges() const
|
||||
{ return Edge_circulator(this);}
|
||||
|
||||
inline Edge_circulator incident_edges(const Face* f) const
|
||||
{ return Edge_circulator(this, f);}
|
||||
|
||||
bool is_valid(bool verbose = false, int level = 0) const;
|
||||
|
||||
};
|
||||
|
||||
template <class Vb, class Fb >
|
||||
int
|
||||
Triangulation_dsul_vertex_2 <Vb,Fb> ::
|
||||
degree() const
|
||||
{
|
||||
int count = 0;
|
||||
Vertex_circulator vc = incident_vertices(), done(vc);
|
||||
if ( ! vc. is_empty()) {
|
||||
do {
|
||||
count += 1;
|
||||
} while (++vc != done);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class Vb, class Fb >
|
||||
bool
|
||||
Triangulation_dsul_vertex_2<Vb,Fb> ::
|
||||
is_valid(bool verbose, int level) const
|
||||
{
|
||||
bool result = Vb::is_valid(verbose, level);
|
||||
CGAL_triangulation_assertion(result);
|
||||
if (face() != NULL) { // face==NULL if dim <0
|
||||
result = result && face()->has_vertex(this);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif //CGAL_TRIANGULATION_DSUL_VERTEX_2_H
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
//Define shorter names to please linker (g++/egcs)
|
||||
|
||||
#define Triangulation_default_data_structure_2 Tdds
|
||||
#define Triangulation_data_structure_using_list_2 Tdsul
|
||||
#define Triangulation_vertex_base_2 Tvb
|
||||
#define Triangulation_face_base_2 Tfb
|
||||
#define Triangulation_euclidean_traits_2 Et2
|
||||
|
|
@ -39,9 +40,11 @@
|
|||
|
||||
#define Triangulation_ds_vertex_2 Tdsv
|
||||
#define Triangulation_ds_face_2 Tdsf
|
||||
#define Triangulation_dsul_vertex_2 Tdsulv
|
||||
#define Triangulation_dsul_face_2 Tdsulf
|
||||
#define Triangulation_vertex_2 Tv
|
||||
#define Triangulation_face_2 Tf
|
||||
#define Triangulation_vertex_handle_2 Tvh
|
||||
#define Triangulation_vertex_handle_2 Tvh
|
||||
#define Triangulation_face_handle_2 Tfh
|
||||
#define Triangulation_vertex_iterator_2 Tvi
|
||||
#define Triangulation_face_iterator_2 Tfi
|
||||
|
|
|
|||
Loading…
Reference in New Issue