add the new API in the code

and adapt examples and tests consistently
This commit is contained in:
Jane Tournois 2020-04-03 06:52:25 +02:00
parent 3aae44f631
commit b9660603b9
8 changed files with 376 additions and 444 deletions

View File

@ -1,6 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_segment_traverser_3.h>
#include <CGAL/Triangulation_simplex_3.h>
#include <assert.h>
#include <iostream>
@ -19,10 +19,9 @@ typedef Kernel::Point_3 Point_3;
// Define the structure.
typedef CGAL::Delaunay_triangulation_3< Kernel > DT;
typedef DT::Cell_handle Cell_handle;
typedef CGAL::Triangulation_segment_simplex_iterator_3<DT> Simplex_traverser;
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
typedef CGAL::Triangulation_simplex_3<DT::Triangulation_data_structure> Simplex;
int main(int argc, char* argv[])
{
@ -52,7 +51,6 @@ int main(int argc, char* argv[])
time.start();
unsigned int nb_cells = 0, nb_facets = 0, nb_edges = 0, nb_vertex = 0;
unsigned int nb_collinear = 0;
for (int i = 0; i < nb_seg; ++i)
{
@ -69,45 +67,21 @@ int main(int argc, char* argv[])
<< "\n\t(" << p1
<< ")\n\t(" << p2 << ")" << std::endl;
#endif
Simplex_traverser st(dt, p1, p2);
Segment_simplex_iterator st = dt.segment_traverser_simplices_begin(p1, p2);
Segment_simplex_iterator stend = dt.segment_traverser_simplices_end(p1, p2);
// Count the number of finite cells traversed.
unsigned int inf = 0, fin = 0;
for (; st != st.end(); ++st)
for (; st != stend; ++st)
{
if( dt.is_infinite(st) )
++inf;
else
{
++fin;
if (st.is_facet()) ++nb_facets;
else if (st.is_edge()) ++nb_edges;
else if (st.is_vertex()) ++nb_vertex;
else if (st.is_cell()) ++nb_cells;
if (st.is_collinear()) ++nb_collinear;
#ifdef CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
if (st.is_facet())
std::cout << "facet " << std::endl;
else if (st.is_edge())
std::cout << "edge " << std::endl;
else if (st.is_vertex())
std::cout << "vertex " << std::endl;
else
{
CGAL_assertion(st.is_cell());
std::cout << "cell " << std::endl;
}
#endif
}
const Simplex s = st;
if (s.dimension() == 3) ++nb_cells;
else if (s.dimension() == 2) ++nb_facets;
else if (s.dimension() == 1) ++nb_edges;
else if (s.dimension() == 0) ++nb_vertex;
}
#ifdef CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
std::cout << "While traversing from " << st.source()
<< " to " << st.target() << std::endl;
std::cout << "\tinfinite cells : " << inf << std::endl;
std::cout << "\tfinite cells : " << fin << std::endl;
std::cout << "\tfacets : " << nb_facets << std::endl;
std::cout << "\tedges : " << nb_edges << std::endl;
std::cout << "\tvertices : " << nb_vertex << std::endl;
@ -123,7 +97,6 @@ int main(int argc, char* argv[])
std::cout << "\tnb facets : " << nb_facets << std::endl;
std::cout << "\tnb edges : " << nb_edges << std::endl;
std::cout << "\tnb vertices : " << nb_vertex << std::endl;
std::cout << "\tnb collinear : " << nb_collinear << std::endl;
return 0;
}

View File

@ -1,7 +1,6 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_segment_traverser_3.h>
#include <assert.h>
#include <iostream>
@ -13,7 +12,6 @@
#include <CGAL/Random.h>
#include <CGAL/Timer.h>
//#define CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
// Define the kernel.
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
@ -21,10 +19,8 @@ typedef Kernel::Point_3 Point_3;
// Define the structure.
typedef CGAL::Delaunay_triangulation_3< Kernel > DT;
typedef DT::Cell_handle Cell_handle;
typedef CGAL::Triangulation_segment_cell_iterator_3< DT > Cell_traverser;
typedef DT::Segment_cell_iterator Segment_cell_iterator;
int main(int argc, char* argv[])
{
@ -72,8 +68,6 @@ int main(int argc, char* argv[])
CGAL::Timer time;
time.start();
unsigned int nb_facets = 0, nb_edges = 0, nb_vertex = 0;
for (unsigned int i = 0; i < nb_seg; ++i)
{
// Construct a traverser.
@ -89,43 +83,21 @@ int main(int argc, char* argv[])
<< "\n\t(" << p1
<< ")\n\t(" << p2 << ")" << std::endl;
#endif
Cell_traverser ct(dt, p1, p2);
Segment_cell_iterator ct = dt.segment_traverser_cells_begin(p1, p2);
Segment_cell_iterator ctend = dt.segment_traverser_cells_begin(p1, p2);
// Count the number of finite cells traversed.
unsigned int inf = 0, fin = 0;
for( ; ct != ct.end(); ++ct )
for( ; ct !=ctend; ++ct )
{
if( dt.is_infinite(ct) )
++inf;
else
{
++fin;
DT::Locate_type lt;
int li, lj;
ct.entry(lt, li, lj);
switch (lt)
{
case DT::Locate_type::FACET:
++nb_facets;
break;
case DT::Locate_type::EDGE:
++nb_edges;
break;
case DT::Locate_type::VERTEX:
++nb_vertex;
break;
default:
/*when source is in a cell*/
CGAL_assertion(lt == DT::Locate_type::CELL);
}
}
}
#ifdef CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
std::cout << "While traversing from " << ct.source()
<< " to " << ct.target() << std::endl;
std::cout << "While traversing from " << p1 << " to " << p2 << std::endl;
std::cout << inf << " infinite and "
<< fin << " finite cells were visited." << std::endl;
std::cout << std::endl << std::endl;
@ -138,9 +110,6 @@ int main(int argc, char* argv[])
std::cout << "Traversing cells of triangulation with "
<< nb_seg << " segments took " << time.time() << " seconds."
<< std::endl;
std::cout << "\tnb facets : " << nb_facets << std::endl;
std::cout << "\tnb edges : " << nb_edges << std::endl;
std::cout << "\tnb vertices : " << nb_vertex << std::endl;
return 0;
}

View File

@ -43,6 +43,8 @@
#include <CGAL/spatial_sort.h>
#include <CGAL/Spatial_sort_traits_adapter_3.h>
#include <CGAL/Triangulation_segment_traverser_3.h>
#include <CGAL/iterator.h>
#include <CGAL/function_objects.h>
#include <CGAL/Iterator_project.h>
@ -524,6 +526,9 @@ public:
typedef Iterator_range<Finite_edges_iterator> Finite_edges;
typedef Iterator_range<Finite_facets_iterator> Finite_facets;
typedef Triangulation_segment_cell_iterator_3<Self> Segment_cell_iterator;
typedef Triangulation_segment_simplex_iterator_3<Self> Segment_simplex_iterator;
private:
// Auxiliary iterators for convenience
// do not use default template argument to please VC++
@ -2187,6 +2192,59 @@ public:
return _tds.incident_edges_threadsafe(v, edges, Finite_filter(this));
}
Segment_cell_iterator segment_traverser_cells_begin(Vertex_handle vs,
Vertex_handle vt) const
{
Segment_cell_iterator it(this, vs, vt);
return it;
}
Segment_cell_iterator segment_traverser_cells_end(Vertex_handle vs,
Vertex_handle vt) const
{
Segment_cell_iterator it(this, vs, vt);
return it.end();
}
Segment_cell_iterator segment_traverser_cells_begin(const Point& ps,
const Point& pt,
Cell_handle hint = Cell_handle()) const
{
Segment_cell_iterator it(this, ps, pt, hint);
return it;
}
Segment_cell_iterator segment_traverser_cells_end(const Point& ps,
const Point& pt,
Cell_handle hint = Cell_handle()) const
{
Segment_cell_iterator it(this, ps, pt, hint);
return it.end();
}
Segment_simplex_iterator segment_traverser_simplices_begin(Vertex_handle vs,
Vertex_handle vt) const
{
Segment_simplex_iterator it(this, vs, vt);
return it;
}
Segment_simplex_iterator segment_traverser_simplices_end(Vertex_handle vs,
Vertex_handle vt) const
{
Segment_simplex_iterator it(this, vs, vt);
return it.end();
}
Segment_simplex_iterator segment_traverser_simplices_begin(const Point& ps,
const Point& pt,
Cell_handle hint = Cell_handle()) const
{
Segment_simplex_iterator it(this, ps, pt, hint);
return it;
}
Segment_simplex_iterator segment_traverser_simplices_end(const Point& ps,
const Point& pt,
Cell_handle hint = Cell_handle()) const
{
Segment_simplex_iterator it(this, ps, pt, hint);
return it.end();
}
size_type degree(Vertex_handle v) const
{
return _tds.degree(v);

View File

@ -48,48 +48,6 @@
namespace CGAL {
/*
add the following to Triangulation_segment_traverser_3.h to get a superclass of the Incrementer visitor.
template < class Tr, class Inc >
class Test_super_SCI;
namespace internal {
template < class Tr >
struct Test_incrementer: public Incrementer<Tr> {
typedef Incrementer<Tr> Base;
typedef Test_incrementer<Tr> Self;
typedef Test_super_SCI<Tr,Self> SCI;
Test_incrementer() {}
void increment( SCI& sci ) {
++sci._superclass;
sci.increment();
}
}; // struct Test_incrementer
} // namespace internal
template < class Tr_, class Inc = internal::Test_incrementer<Tr_> >
class Test_super_SCI: public Triangulation_segment_cell_iterator_3<Tr_,Inc> {
typedef Tr_ Tr;
typedef Triangulation_segment_cell_iterator_3<Tr,Inc> SCI;
int _superclass;
friend internal::Test_incrementer<Tr>;
public:
Test_super_SCI( const Tr& tr, const Point& s, const Point& t, Cell_handle hint = Cell_handle() )
: SCI(tr,s,t,hint), _superclass(0) {}
};
*/
template < class Tr, class Inc >
class Triangulation_segment_cell_iterator_3;
@ -143,7 +101,8 @@ struct Incrementer {
* \sa `Forward_circulator_base`
*/
template < class Tr_, class Inc = internal::Incrementer<Tr_> >
class Triangulation_segment_cell_iterator_3 {
class Triangulation_segment_cell_iterator_3
{
typedef Tr_ Tr;
typedef typename Tr::Triangulation_data_structure Tds;
typedef typename Tr::Geom_traits Gt;
@ -192,7 +151,7 @@ protected:
// \internal \name Protected Attributes
// \{
// \internal The triangulation to traverse.
const Tr& _tr;
const Tr* _tr;
// \}
@ -218,7 +177,7 @@ public:
* \param t the target vertex. This vertex must be initialized and cannot be the infinite vertex.
* It cannot equal `s`.
*/
Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, Vertex_handle t );
Triangulation_segment_cell_iterator_3( const Tr* tr, Vertex_handle s, Vertex_handle t );
// constructs an iterator.
/* \param tr the triangulation to iterate though. This triangulation must have dimension > 0.
@ -226,7 +185,7 @@ public:
* \param t the target point. This point must be initialized and it cannot be be at the same location as `s`.
* If `tr` has dimension < 3, `t` must lie inside the affine hull of `tr`.
*/
Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, const Point& t );
Triangulation_segment_cell_iterator_3( const Tr* tr, Vertex_handle s, const Point& t );
// constructs an iterator.
/* \param tr the triangulation to iterate though. This triangulation must have dimension > 0.
@ -235,7 +194,7 @@ public:
* If `tr` has dimension < 3, `s` must lie inside the affine hull of `tr`.
* \param hint the starting point to search for `s`.
*/
Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, Vertex_handle t, Cell_handle hint = Cell_handle() );
Triangulation_segment_cell_iterator_3( const Tr* tr, const Point& s, Vertex_handle t, Cell_handle hint = Cell_handle() );
// constructs an iterator.
/* \param tr the triangulation to iterate though. This triangulation must have dimension > 0.
@ -245,7 +204,7 @@ public:
* If `tr` has dimension < 3, `t` must lie inside the affine hull of `tr`.
* \param hint the starting point to search for `s`.
*/
Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, const Point& t, Cell_handle hint = Cell_handle() );
Triangulation_segment_cell_iterator_3( const Tr* tr, const Point& s, const Point& t, Cell_handle hint = Cell_handle() );
// constructs an iterator.
/* \param tr the triangulation to iterate though. This triangulation must have dimension > 0.
@ -253,7 +212,7 @@ public:
* the affine hull of `tr`. `S` must not be degenerate, i.e. its source and target must not be equal.
* \param hint the starting point to search for `S`.
*/
Triangulation_segment_cell_iterator_3( const Tr& tr, const Segment& S, Cell_handle hint = Cell_handle() );
Triangulation_segment_cell_iterator_3( const Tr* tr, const Segment& S, Cell_handle hint = Cell_handle() );
// \}
#ifndef CGAL_TST_ASSUME_CORRECT_TYPES
@ -265,13 +224,13 @@ public:
private:
// private constructor that does not initialize the source and target.
Triangulation_segment_cell_iterator_3( const Tr& tr );
Triangulation_segment_cell_iterator_3( const Tr* tr );
public:
// \name Accessors
// \{
const Tr& triangulation() const { return _tr; }
const Tr* triangulation() const { return _tr; }
// gives the source point of the segment followed.
/* \return the source point.
@ -568,12 +527,11 @@ public:
typedef typename SCI::Triangulation::Facet Facet; //< defines the type of a facet in the triangulation.
typedef typename SCI::Locate_type Locate_type; //< defines the simplex type returned from location.
//typedef boost::variant<Vertex_handle, Edge, Facet, Cell_handle> Simplex_type; //types sorted by dimension
typedef CGAL::Triangulation_simplex_3<Tds> Simplex_type;
typedef CGAL::Triangulation_simplex_3<Tds> Simplex_3;
typedef Simplex_type value_type; //< defines the value type the iterator refers to.
typedef const Simplex_type& reference; //< defines the reference type of the iterator.
typedef const Simplex_type* pointer; //< defines the pointer type of the iterator.
typedef Simplex_3 value_type; //< defines the value type the iterator refers to.
typedef const Simplex_3& reference; //< defines the reference type of the iterator.
typedef const Simplex_3* pointer; //< defines the pointer type of the iterator.
typedef std::size_t size_type; //< defines the integral type that can hold the size of a sequence.
typedef std::ptrdiff_t difference_type; //< defines the signed integral type that can hold the distance between two iterators.
typedef std::forward_iterator_tag iterator_category; //< defines the iterator category.
@ -581,26 +539,26 @@ public:
private:
SCI _cell_iterator;
Simplex_type _curr_simplex;
Simplex_3 _curr_simplex;
public:
Triangulation_segment_simplex_iterator_3(const Tr& tr
Triangulation_segment_simplex_iterator_3(const Tr* tr
, Vertex_handle s, Vertex_handle t)
: _cell_iterator(tr, s, t)
{ set_curr_simplex_to_entry(); }
Triangulation_segment_simplex_iterator_3(const Tr& tr
Triangulation_segment_simplex_iterator_3(const Tr* tr
, Vertex_handle s, const Point& t)
: _cell_iterator(tr, s, t)
{ set_curr_simplex_to_entry(); }
Triangulation_segment_simplex_iterator_3(const Tr& tr
Triangulation_segment_simplex_iterator_3(const Tr* tr
, const Point& s, Vertex_handle t, Cell_handle hint = Cell_handle())
: _cell_iterator(tr, s, t, hint)
{ set_curr_simplex_to_entry(); }
Triangulation_segment_simplex_iterator_3(const Tr& tr
Triangulation_segment_simplex_iterator_3(const Tr* tr
, const Point& s, const Point& t, Cell_handle hint = Cell_handle())
: _cell_iterator(tr, s, t, hint)
{ set_curr_simplex_to_entry(); }
Triangulation_segment_simplex_iterator_3(const Tr& tr
Triangulation_segment_simplex_iterator_3(const Tr* tr
, const Segment& seg, Cell_handle hint = Cell_handle())
: _cell_iterator(tr, seg, hint)
{ set_curr_simplex_to_entry(); }
@ -619,7 +577,7 @@ public:
const Point& source() const { return _cell_iterator.source(); }
const Point& target() const { return _cell_iterator.target(); }
const Tr& triangulation() const { return _cell_iterator.triangulation(); }
const Tr* triangulation() const { return _cell_iterator.triangulation(); }
private:
Triangulation_segment_simplex_iterator_3
@ -665,7 +623,7 @@ private:
case Locate_type::OUTSIDE_CONVEX_HULL:
case Locate_type::OUTSIDE_AFFINE_HULL:
if (Cell_handle(_cell_iterator) == Cell_handle())
_curr_simplex = Simplex_type();
_curr_simplex = Simplex_3();
else
_curr_simplex = cell;
break;
@ -719,12 +677,12 @@ public:
{
if (_cell_iterator == _cell_iterator.end())
{
_curr_simplex = Simplex_type();
_curr_simplex = Simplex_3();
break;
}
//if the entry vertex is a vertex of current facet
int i;
if (triangulation().has_vertex(get_facet(), chnext->vertex(linext), i))
if (triangulation()->has_vertex(get_facet(), chnext->vertex(linext), i))
set_curr_simplex_to_entry();
else
_curr_simplex = ch;
@ -773,13 +731,13 @@ public:
case Locate_type::EDGE:
{
CGAL_assertion(_cell_iterator == _cell_iterator.end()
|| triangulation().is_infinite(chnext)
|| _curr_simplex != Simplex_type(Edge(chnext, linext, ljnext)));
|| triangulation()->is_infinite(chnext)
|| _curr_simplex != Simplex_3(Edge(chnext, linext, ljnext)));
if (_cell_iterator == _cell_iterator.end())
_curr_simplex = Simplex_type();
else if (triangulation().is_infinite(chnext)
&& _curr_simplex == Simplex_type(Edge(chnext, linext, ljnext)))
_curr_simplex = Simplex_3();
else if (triangulation()->is_infinite(chnext)
&& _curr_simplex == Simplex_3(Edge(chnext, linext, ljnext)))
_curr_simplex = chnext;
else
_curr_simplex = shared_facet(get_edge(), Edge(chnext, linext, ljnext));
@ -817,7 +775,7 @@ public:
{
CGAL_assertion(_cell_iterator == _cell_iterator.end()
|| get_vertex() != chnext->vertex(linext)
|| triangulation().is_infinite(chnext));
|| triangulation()->is_infinite(chnext));
if (_cell_iterator == _cell_iterator.end())
{
Cell_handle prev;
@ -843,13 +801,13 @@ public:
}
else
{
if (triangulation().is_infinite(chnext) && get_vertex() == chnext->vertex(linext))
if (triangulation()->is_infinite(chnext) && get_vertex() == chnext->vertex(linext))
_curr_simplex = chnext;
else
{
Cell_handle ec;
int ei, ej;
if (!triangulation().is_edge(get_vertex(), chnext->vertex(linext), ec, ei, ej))
if (!triangulation()->is_edge(get_vertex(), chnext->vertex(linext), ec, ei, ej))
CGAL_assertion(false);
_curr_simplex = Edge(ec, ei, ej);
}
@ -866,7 +824,7 @@ public:
default ://FACET
CGAL_assertion(ltnext == Locate_type::FACET);
if(chnext == Cell_handle())
_curr_simplex = Simplex_type();
_curr_simplex = Simplex_3();
else
_curr_simplex = shared_cell(Facet(chnext, linext), get_vertex());
};
@ -889,17 +847,17 @@ public:
// provides a dereference operator.
/* \return a pointer to the current cell.
*/
const Simplex_type* operator->() { return &_curr_simplex; }
const Simplex_3* operator->() { return &_curr_simplex; }
// provides an indirection operator.
/* \return the current cell.
*/
const Simplex_type& operator*() { return _curr_simplex; }
const Simplex_3& operator*() { return _curr_simplex; }
// provides a conversion operator.
/* \return a handle to the current cell.
/* \return the current simplex
*/
operator const Cell_handle() const { return Cell_handle(_cell_iterator); }
operator const Simplex_3() const { return _curr_simplex; }
bool is_vertex() const { return _curr_simplex.dimension() == 0; }
bool is_edge() const { return _curr_simplex.dimension() == 1; }
@ -911,7 +869,7 @@ public:
return _cell_iterator.cell();
}
const Simplex_type& get_simplex() const { return _curr_simplex; }
const Simplex_3& get_simplex() const { return _curr_simplex; }
Vertex_handle get_vertex() const
{
CGAL_assertion(is_vertex());
@ -1045,7 +1003,7 @@ private:
Vertex_handle nsv2 = (sv == v2a) ? v2b : v2a;
typename Tr::Facet_circulator circ
= triangulation().incident_facets(e1);
= triangulation()->incident_facets(e1);
typename Tr::Facet_circulator end = circ;
do
{
@ -1065,13 +1023,13 @@ private:
Facet shared_facet(const Edge& e, const Vertex_handle v) const
{
typename Tr::Facet_circulator circ
= triangulation().incident_facets(e);
= triangulation()->incident_facets(e);
typename Tr::Facet_circulator end = circ;
do
{
Facet f = *circ;
int i;
if (triangulation().has_vertex(f, v, i))
if (triangulation()->has_vertex(f, v, i))
return f;
} while (++circ != end);
@ -1083,7 +1041,7 @@ private:
Cell_handle shared_cell(const Edge& e, const Vertex_handle v) const
{
typename Tr::Cell_circulator circ
= triangulation().incident_cells(e);
= triangulation()->incident_cells(e);
typename Tr::Cell_circulator end = circ;
do
{
@ -1114,6 +1072,6 @@ private:
} // namespace CGAL
#include <CGAL/Triangulation_segment_traverser_3_impl.h>
#include <CGAL/internal/Triangulation_segment_traverser_3_impl.h>
#endif // CGAL_TRIANGULATION_SEGMENT_TRAVERSER_3_H

View File

@ -27,12 +27,12 @@ namespace CGAL {
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, Vertex_handle t )
Triangulation_segment_cell_iterator_3( const Tr* tr, Vertex_handle s, Vertex_handle t )
: _tr(tr) {
CGAL_triangulation_precondition( !_tr.is_infinite(s) );
CGAL_triangulation_precondition( !_tr.is_infinite(t) );
CGAL_triangulation_precondition( !_tr->is_infinite(s) );
CGAL_triangulation_precondition( !_tr->is_infinite(t) );
CGAL_triangulation_precondition( s->point() != t->point() );
CGAL_triangulation_precondition( _tr.dimension() >= 2 );
CGAL_triangulation_precondition( _tr->dimension() >= 2 );
_source = s->point();
_target = t->point();
@ -42,7 +42,7 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, Vertex_han
Cell_handle c = s->cell();
// If a vertex of an infinite cell, we start inside the convex hull.
int inf;
if( c->has_vertex( _tr.infinite_vertex(), inf ) )
if( c->has_vertex( _tr->infinite_vertex(), inf ) )
c = c->neighbor(inf);
_cur = Simplex( c, Tr::VERTEX, c->index(s), -1 );
@ -52,13 +52,13 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, Vertex_han
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, const Point& t )
Triangulation_segment_cell_iterator_3( const Tr* tr, Vertex_handle s, const Point& t )
: _tr(tr) {
CGAL_triangulation_precondition( !_tr.is_infinite(s) );
CGAL_triangulation_precondition( !_tr->is_infinite(s) );
CGAL_triangulation_precondition( s->point() != t );
CGAL_triangulation_precondition( _tr.dimension() >= 2 );
CGAL_triangulation_precondition( _tr.dimension() == 3 ||
orientation( *_tr.finite_facets_begin(), t ) == COPLANAR );
CGAL_triangulation_precondition( _tr->dimension() >= 2 );
CGAL_triangulation_precondition( _tr->dimension() == 3 ||
orientation( *_tr->finite_facets_begin(), t ) == COPLANAR );
_source = s->point();
_target = t;
@ -68,7 +68,7 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, const Poin
Cell_handle c = s->cell();
// If a vertex of an infinite cell, we start inside the convex hull.
int inf;
if( c->has_vertex( _tr.infinite_vertex(), inf ) )
if( c->has_vertex( _tr->infinite_vertex(), inf ) )
c = c->neighbor(inf);
_cur = Simplex( c, Tr::VERTEX, c->index(s), -1 );
@ -78,13 +78,13 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, Vertex_handle s, const Poin
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, Vertex_handle t, Cell_handle hint )
Triangulation_segment_cell_iterator_3( const Tr* tr, const Point& s, Vertex_handle t, Cell_handle hint )
: _tr(tr) {
CGAL_triangulation_precondition( !_tr.is_infinite(t) );
CGAL_triangulation_precondition( !_tr->is_infinite(t) );
CGAL_triangulation_precondition( s != t->point() );
CGAL_triangulation_precondition( _tr.dimension() >= 2 );
CGAL_triangulation_precondition( _tr.dimension() == 3 ||
orientation( *_tr.finite_facets_begin(), s ) == COPLANAR );
CGAL_triangulation_precondition( _tr->dimension() >= 2 );
CGAL_triangulation_precondition( _tr->dimension() == 3 ||
orientation( *_tr->finite_facets_begin(), s ) == COPLANAR );
_source = s;
_target = t->point();
@ -92,7 +92,7 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, Vertex_hand
_t_vertex = t;
using CGAL::cpp11::get;
get<0>(_cur) = _tr.locate( s, get<1>(_cur), get<2>(_cur), get<3>(_cur), hint );
get<0>(_cur) = _tr->locate( s, get<1>(_cur), get<2>(_cur), get<3>(_cur), hint );
CGAL_triangulation_postcondition( get<0>(_cur) != Cell_handle() );
@ -101,12 +101,12 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, Vertex_hand
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, const Point& t, Cell_handle hint )
Triangulation_segment_cell_iterator_3( const Tr* tr, const Point& s, const Point& t, Cell_handle hint )
: _tr(tr) {
CGAL_triangulation_precondition( s != t );
CGAL_triangulation_precondition( _tr.dimension() >= 2 );
CGAL_triangulation_precondition( _tr.dimension() == 3 ||
coplanar( *_tr.finite_facets_begin(), _target ) );
CGAL_triangulation_precondition( _tr->dimension() >= 2 );
CGAL_triangulation_precondition( _tr->dimension() == 3 ||
coplanar( *_tr->finite_facets_begin(), _target ) );
_source = s;
_target = t;
@ -114,7 +114,7 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, const Point
_t_vertex = Vertex_handle();
using CGAL::cpp11::get;
get<0>(_cur) = _tr.locate( s, get<1>(_cur), get<2>(_cur), get<3>(_cur), hint );
get<0>(_cur) = _tr->locate( s, get<1>(_cur), get<2>(_cur), get<3>(_cur), hint );
CGAL_triangulation_postcondition( get<0>(_cur) != Cell_handle() );
@ -123,12 +123,12 @@ Triangulation_segment_cell_iterator_3( const Tr& tr, const Point& s, const Point
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr, const Segment& s, Cell_handle hint )
Triangulation_segment_cell_iterator_3( const Tr* tr, const Segment& s, Cell_handle hint )
: Triangulation_segment_cell_iterator_3<Tr,Inc>( tr, s.source(), s.target(), hint ) {}
template < class Tr, class Inc >
Triangulation_segment_cell_iterator_3<Tr,Inc>::
Triangulation_segment_cell_iterator_3( const Tr& tr )
Triangulation_segment_cell_iterator_3( const Tr* tr )
: _tr(tr) {}
template < class Tr, class Inc >
@ -271,10 +271,10 @@ walk_to_next() {
// Walks to the next cell over a facet intersected by the line from source to target.
// This method is based on Triangulation_3::locate().
int inf;
switch( _tr.dimension() ) {
switch( _tr->dimension() ) {
case 3: {
// Infinite cells should be handled differently.
if( get<0>(_cur)->has_vertex( _tr.infinite_vertex(), inf ) )
if( get<0>(_cur)->has_vertex( _tr->infinite_vertex(), inf ) )
walk_to_next_3_inf( inf );
else
{
@ -285,13 +285,13 @@ walk_to_next() {
_cur = p.second;
} while (get<0>(_cur) != Cell_handle()//end
&& !get<0>(_cur)->has_vertex(_tr.infinite_vertex(), inf)
&& !get<0>(_cur)->has_vertex(_tr->infinite_vertex(), inf)
&& have_same_entry(backup, _cur));
}
break;
}
case 2: {
if( get<0>(_cur)->has_vertex( _tr.infinite_vertex(), inf ) )
if( get<0>(_cur)->has_vertex( _tr->infinite_vertex(), inf ) )
walk_to_next_2_inf( inf );
else
walk_to_next_2();
@ -299,17 +299,17 @@ walk_to_next() {
}
}
#ifdef CGAL_TRIANGULATION_3_TRAVERSER_CHECK_INTERSECTION
if(_tr.dimension() == 3)
if(_tr->dimension() == 3)
{
Cell_handle c = get<0>(_cur);
if (c != Cell_handle() && !_tr.is_infinite(c)) //hard to say anything in this case
if (c != Cell_handle() && !_tr->is_infinite(c)) //hard to say anything in this case
{
typename Tr::Segment seg(_source, _target);
bool intersects = false;
for (int i = 0; i < 4; ++i)
{
if (!_tr.is_infinite(c, i)
&& CGAL::do_intersect(_tr.triangle(c, i), seg))
if (!_tr->is_infinite(c, i)
&& CGAL::do_intersect(_tr->triangle(c, i), seg))
{
intersects = true;
break;
@ -343,7 +343,7 @@ have_same_entry(const Simplex& s1, const Simplex& s2) const
|| (v1a == v2b && v1b == v2a);
}
case Locate_type::FACET:
return triangulation().are_equal(Facet(get<0>(s1), get<2>(s1)),
return triangulation()->are_equal(Facet(get<0>(s1), get<2>(s1)),
Facet(get<0>(s2), get<2>(s2)));
default:
CGAL_assertion(false);
@ -373,11 +373,11 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
int j0 = Tr::vertex_triple_index(i, 0);
int j1 = Tr::vertex_triple_index(i, 1);
int j2 = Tr::vertex_triple_index(i, 2);
Orientation o0 = _tr.orientation(_source, *vert[i], *vert[j0], _target);
Orientation o0 = _tr->orientation(_source, *vert[i], *vert[j0], _target);
if (o0 == POSITIVE) {
Orientation o1 = _tr.orientation(_source, *vert[i], *vert[j1], _target);
Orientation o1 = _tr->orientation(_source, *vert[i], *vert[j1], _target);
if (o1 != POSITIVE) {
if (_tr.orientation(*vert[i], *vert[j0], *vert[j1], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j0], *vert[j1], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j2);
outside = j2;
if (o1 == ZERO) degenerate = 1; //EDGE i j1
@ -386,7 +386,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
inside = 1;
}
else {
if (_tr.orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j0);
outside = j0;
}
@ -395,9 +395,9 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
}
}
else if (o0 == ZERO) {
Orientation o1 = _tr.orientation(_source, *vert[i], *vert[j1], _target);
Orientation o1 = _tr->orientation(_source, *vert[i], *vert[j1], _target);
if (o1 == NEGATIVE) {
if (_tr.orientation(*vert[i], *vert[j0], *vert[j1], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j0], *vert[j1], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j2); //EDGE i j0
degenerate = 2;
outside = 44;
@ -406,7 +406,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
inside = 3;
}
else if (o1 == ZERO) {
if (_tr.orientation(*vert[i], *vert[j0], *vert[j2], _target) == POSITIVE)
if (_tr->orientation(*vert[i], *vert[j0], *vert[j2], _target) == POSITIVE)
inside = 55;
else
{
@ -416,7 +416,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
}
}
else {
if (_tr.orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j0);
outside = j0;
}
@ -425,9 +425,9 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
}
}
else {
Orientation o2 = _tr.orientation(_source, *vert[i], *vert[j2], _target);
Orientation o2 = _tr->orientation(_source, *vert[i], *vert[j2], _target);
if (o2 != NEGATIVE) {
if (_tr.orientation(*vert[i], *vert[j2], *vert[j0], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j2], *vert[j0], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j1);
outside = j1;
if (o2 == ZERO) degenerate = 4; // EDGE i j2
@ -436,7 +436,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
inside = 5;
}
else {
if (_tr.orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
if (_tr->orientation(*vert[i], *vert[j1], *vert[j2], _target) == POSITIVE) {
nnext = get<0>(cur)->neighbor(j0);
outside = j0;
}
@ -504,7 +504,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
vert[li] = &_target;
// Check if the target is on the opposite side of the supporting plane.
op[li] = _tr.orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
op[li] = _tr->orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
if( op[li] == POSITIVE )
pos += li;
if( op[li] != NEGATIVE ) {
@ -527,7 +527,7 @@ Triangulation_segment_cell_iterator_3<Tr,Inc>::walk_to_next_3(const Simplex& pre
if( !calc[oij] ) {
const Point* backup2 = vert[lj];
vert[lj] = &_source;
o[oij] = _tr.orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
o[oij] = _tr->orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
vert[lj] = backup2;
calc[oij] = true;
}
@ -663,7 +663,7 @@ template < class Tr, class Inc >
void Triangulation_segment_cell_iterator_3<Tr,Inc>::
walk_to_next_3_inf( int inf ) {
using CGAL::cpp11::get;
CGAL_triangulation_precondition( _tr.is_infinite( get<0>(_cur)->vertex(inf) ) );
CGAL_triangulation_precondition( _tr->is_infinite( get<0>(_cur)->vertex(inf) ) );
// If this cell was reached by traversal from a finite one, it must be the final cell.
Cell_handle fin = get<0>(_cur)->neighbor(inf);
@ -681,7 +681,7 @@ walk_to_next_3_inf( int inf ) {
Orientation o[4];
// Check if the target lies outside the convex hull.
if( _tr.orientation( *vert[0], *vert[1], *vert[2], *vert[3] ) == POSITIVE ) {
if( _tr->orientation( *vert[0], *vert[1], *vert[2], *vert[3] ) == POSITIVE ) {
// The target lies in an infinite cell.
// Note that we do not traverse to other infinite cells.
_prev = Simplex( get<0>(_cur), Tr::OUTSIDE_CONVEX_HULL, -1, -1 );
@ -690,7 +690,7 @@ walk_to_next_3_inf( int inf ) {
}
vert[inf] = &(_source);
CGAL_triangulation_assertion( _tr.orientation( *vert[0], *vert[1], *vert[2], *vert[3] ) == POSITIVE );
CGAL_triangulation_assertion( _tr->orientation( *vert[0], *vert[1], *vert[2], *vert[3] ) == POSITIVE );
int li = 0;
// Check if the line enters an adjacent infinite cell.
@ -711,7 +711,7 @@ walk_to_next_3_inf( int inf ) {
Point* backup = vert[li];
vert[li] = &(_target);
o[li] = _tr.orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
o[li] = _tr->orientation( *vert[0], *vert[1], *vert[2], *vert[3] );
if( o[li] != NEGATIVE ) {
vert[li] = backup;
@ -720,7 +720,7 @@ walk_to_next_3_inf( int inf ) {
// The target lies behind the plane through the source and two finite vertices.
// Traverse to the incident infinite cell.
CGAL_triangulation_assertion( _tr.is_infinite( next ) );
CGAL_triangulation_assertion( _tr->is_infinite( next ) );
_prev = Simplex( get<0>(_cur), Tr::FACET, li, -1 );
_cur = Simplex( next, Tr::FACET, next->index( get<0>(_prev) ), -1 );
return;
@ -784,17 +784,17 @@ walk_to_next_2()
switch( get<1>(_cur) ) {
case Tr::VERTEX: {
// First we try the incident edges.
Orientation ocw = CGAL::coplanar_orientation( *vert[get<2>(_cur)], *vert[_tr.cw(get<2>(_cur))], *vert[_tr.ccw(get<2>(_cur))], _target );
if( get<0>(_cur)->neighbor( _tr.ccw(get<2>(_cur)) ) != get<0>(_prev) && ocw == NEGATIVE) {
Cell_handle tmp = get<0>(_cur)->neighbor( _tr.ccw(get<2>(_cur)) );
Orientation ocw = CGAL::coplanar_orientation( *vert[get<2>(_cur)], *vert[_tr->cw(get<2>(_cur))], *vert[_tr->ccw(get<2>(_cur))], _target );
if( get<0>(_cur)->neighbor( _tr->ccw(get<2>(_cur)) ) != get<0>(_prev) && ocw == NEGATIVE) {
Cell_handle tmp = get<0>(_cur)->neighbor( _tr->ccw(get<2>(_cur)) );
_prev = _cur;
get<0>(_cur) = tmp;
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex(get<2>(_cur)) );
return;
}
Orientation occw = CGAL::coplanar_orientation( *vert[get<2>(_cur)], *vert[_tr.ccw(get<2>(_cur))], *vert[_tr.cw(get<2>(_cur))], _target );
if( get<0>(_cur)->neighbor( _tr.cw(get<2>(_cur)) ) != get<0>(_prev) && occw == NEGATIVE) {
Cell_handle tmp = get<0>(_cur)->neighbor( _tr.cw(get<2>(_cur)) );
Orientation occw = CGAL::coplanar_orientation( *vert[get<2>(_cur)], *vert[_tr->ccw(get<2>(_cur))], *vert[_tr->cw(get<2>(_cur))], _target );
if( get<0>(_cur)->neighbor( _tr->cw(get<2>(_cur)) ) != get<0>(_prev) && occw == NEGATIVE) {
Cell_handle tmp = get<0>(_cur)->neighbor( _tr->cw(get<2>(_cur)) );
_prev = _cur;
get<0>(_cur) = tmp;
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex(get<2>(_cur)) );
@ -802,7 +802,7 @@ walk_to_next_2()
}
// Then we try the opposite edge.
Orientation op = CGAL::coplanar_orientation( *vert[_tr.ccw(get<2>(_cur))], *vert[_tr.cw(get<2>(_cur))], *vert[get<2>(_cur)], _target );
Orientation op = CGAL::coplanar_orientation( *vert[_tr->ccw(get<2>(_cur))], *vert[_tr->cw(get<2>(_cur))], *vert[get<2>(_cur)], _target );
if( op == NEGATIVE) {
Cell_handle tmp = get<0>(_cur)->neighbor(get<2>(_cur));
get<0>(_prev) = get<0>(_cur);
@ -811,8 +811,8 @@ walk_to_next_2()
switch( ocw+occw ) {
case 2:
get<1>(_prev) = Tr::EDGE;
get<2>(_prev) = _tr.ccw( get<2>(_cur) );
get<3>(_prev) = _tr.cw( get<2>(_cur) );
get<2>(_prev) = _tr->ccw( get<2>(_cur) );
get<3>(_prev) = _tr->cw( get<2>(_cur) );
get<1>(_cur) = Tr::EDGE;
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( get<2>(_prev) ) );
get<3>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( get<3>(_prev) ) );
@ -820,8 +820,8 @@ walk_to_next_2()
case 1:
get<1>(_prev) = Tr::VERTEX;
get<1>(_cur) = Tr::VERTEX;
if( ocw == COLLINEAR ) get<2>(_prev) = _tr.cw( get<2>(_cur) );
else get<2>(_cur) = _tr.ccw( get<2>(_cur) );
if( ocw == COLLINEAR ) get<2>(_prev) = _tr->cw( get<2>(_cur) );
else get<2>(_cur) = _tr->ccw( get<2>(_cur) );
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( get<2>(_prev) ) );
return;
default:
@ -838,17 +838,17 @@ walk_to_next_2()
break;
case 2:
if( ocw == 0 )
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.ccw(get<2>(_cur)), -1 );
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->ccw(get<2>(_cur)), -1 );
else if( occw == 0 )
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.cw(get<2>(_cur)), -1 );
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->cw(get<2>(_cur)), -1 );
else
_prev = Simplex( get<0>(_cur), Tr::EDGE, get<2>(_cur), -1 );
break;
case 1:
if( ocw == 1 )
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.ccw(get<2>(_cur)), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->ccw(get<2>(_cur)), -1 );
else if( occw == 1 )
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.cw(get<2>(_cur)), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->cw(get<2>(_cur)), -1 );
else
_prev = Simplex( get<0>(_cur), Tr::VERTEX, get<2>(_cur), -1 );
break;
@ -973,37 +973,37 @@ walk_to_next_2()
Orientation o[3];
bool calc[3] = { false, false, false };
for( int j = 0; j != 3; ++j, li = _tr.ccw(li) ) {
for( int j = 0; j != 3; ++j, li = _tr->ccw(li) ) {
Cell_handle next = get<0>(_cur)->neighbor(li);
if( next == get<0>(_prev) )
continue;
// The target should lie on the other side of the edge.
Orientation op = CGAL::coplanar_orientation( *vert[_tr.ccw(li)], *vert[_tr.cw(li)], *vert[li], _target );
Orientation op = CGAL::coplanar_orientation( *vert[_tr->ccw(li)], *vert[_tr->cw(li)], *vert[li], _target );
if( op == POSITIVE )
continue;
// The target should lie inside the wedge.
if( !calc[_tr.ccw(li)] ) {
o[_tr.ccw(li)] = CGAL::coplanar_orientation( _source, *vert[_tr.ccw(li)], *vert[_tr.cw(li)], _target );
calc[_tr.ccw(li)] = true;
if( !calc[_tr->ccw(li)] ) {
o[_tr->ccw(li)] = CGAL::coplanar_orientation( _source, *vert[_tr->ccw(li)], *vert[_tr->cw(li)], _target );
calc[_tr->ccw(li)] = true;
}
if( o[_tr.ccw(li)] == NEGATIVE )
if( o[_tr->ccw(li)] == NEGATIVE )
continue;
else if( op == COLLINEAR && o[_tr.ccw(li)] == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.ccw(li), -1 );
else if( op == COLLINEAR && o[_tr->ccw(li)] == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->ccw(li), -1 );
get<0>(_cur) = Cell_handle();
return;
}
if( !calc[_tr.cw(li)] ) {
o[_tr.cw(li)] = CGAL::coplanar_orientation( _source, *vert[_tr.cw(li)], *vert[li], _target );
calc[_tr.cw(li)] = true;
if( !calc[_tr->cw(li)] ) {
o[_tr->cw(li)] = CGAL::coplanar_orientation( _source, *vert[_tr->cw(li)], *vert[li], _target );
calc[_tr->cw(li)] = true;
}
if( o[_tr.cw(li)] == POSITIVE )
if( o[_tr->cw(li)] == POSITIVE )
continue;
else if( op == COLLINEAR && o[_tr.cw(li)] == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.cw(li), -1 );
else if( op == COLLINEAR && o[_tr->cw(li)] == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->cw(li), -1 );
get<0>(_cur) = Cell_handle();
return;
}
@ -1011,20 +1011,20 @@ walk_to_next_2()
get<0>(_prev) = get<0>(_cur);
get<0>(_cur) = next;
switch( o[_tr.ccw(li)] + o[_tr.cw(li)] ) {
switch( o[_tr->ccw(li)] + o[_tr->cw(li)] ) {
case 2:
get<1>(_prev) = Tr::EDGE;
get<2>(_prev) = _tr.ccw(li);
get<3>(_prev) = _tr.cw(li);
get<2>(_prev) = _tr->ccw(li);
get<3>(_prev) = _tr->cw(li);
get<1>(_cur) = Tr::EDGE;
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( _tr.ccw(li) ) );
get<3>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( _tr.cw(li) ) );
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( _tr->ccw(li) ) );
get<3>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( _tr->cw(li) ) );
return;
case 1:
get<1>(_prev) = Tr::VERTEX;
get<1>(_cur) = Tr::VERTEX;
if( o[_tr.ccw(li)] == COLLINEAR ) get<2>(_prev) = _tr.ccw(li);
else get<2>(_prev) = _tr.cw(li);
if( o[_tr->ccw(li)] == COLLINEAR ) get<2>(_prev) = _tr->ccw(li);
else get<2>(_prev) = _tr->cw(li);
get<2>(_cur) = get<0>(_cur)->index( get<0>(_prev)->vertex( get<2>(_prev) ) );
return;
default:
@ -1047,8 +1047,8 @@ template < class Tr, class Inc >
void Triangulation_segment_cell_iterator_3<Tr,Inc>::
walk_to_next_2_inf( int inf ) {
using CGAL::cpp11::get;
CGAL_triangulation_precondition( _tr.is_infinite( get<0>(_cur)->vertex(3) ) );
CGAL_triangulation_precondition( _tr.is_infinite( get<0>(_cur)->vertex(inf) ) );
CGAL_triangulation_precondition( _tr->is_infinite( get<0>(_cur)->vertex(3) ) );
CGAL_triangulation_precondition( _tr->is_infinite( get<0>(_cur)->vertex(inf) ) );
// If this cell was reached by traversal from a finite one, it must be the final cell.
Cell_handle fin = get<0>(_cur)->neighbor(inf);
@ -1060,56 +1060,56 @@ walk_to_next_2_inf( int inf ) {
// Check the neighboring cells.
Orientation occw = CGAL::coplanar_orientation( _source,
get<0>(_cur)->vertex( _tr.ccw(inf))->point(),
get<0>(_cur)->vertex(_tr.cw(inf))->point(),
get<0>(_cur)->vertex( _tr->ccw(inf))->point(),
get<0>(_cur)->vertex(_tr->cw(inf))->point(),
_target );
if( occw == NEGATIVE ) {
Cell_handle tmp = get<0>(_cur)->neighbor(_tr.cw(inf));
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.ccw(inf), inf );
Cell_handle tmp = get<0>(_cur)->neighbor(_tr->cw(inf));
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->ccw(inf), inf );
_cur = Simplex( tmp, Tr::EDGE, tmp->index( get<0>(_prev)->vertex( get<2>(_prev) ) ), tmp->index( get<0>(_prev)->vertex( get<3>(_prev) ) ) );
return;
}
Orientation ocw = CGAL::coplanar_orientation( _source,
get<0>(_cur)->vertex( _tr.cw(inf))->point(),
get<0>(_cur)->vertex(_tr.ccw(inf))->point(),
get<0>(_cur)->vertex( _tr->cw(inf))->point(),
get<0>(_cur)->vertex(_tr->ccw(inf))->point(),
_target );
if( ocw == NEGATIVE ) {
Cell_handle tmp = get<0>(_cur)->neighbor(_tr.ccw(inf));
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.cw(inf), inf );
Cell_handle tmp = get<0>(_cur)->neighbor(_tr->ccw(inf));
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->cw(inf), inf );
_cur = Simplex( tmp, Tr::EDGE, tmp->index( get<0>(_prev)->vertex( get<2>(_prev) ) ), tmp->index( get<0>(_prev)->vertex( get<3>(_prev) ) ) );
return;
}
Orientation op = CGAL::coplanar_orientation(
get<0>(_cur)->vertex( _tr.ccw(inf) )->point(),
get<0>(_cur)->vertex( _tr.cw(inf) )->point(),
get<0>(_cur)->vertex( _tr->ccw(inf) )->point(),
get<0>(_cur)->vertex( _tr->cw(inf) )->point(),
_source, _target );
switch( op ) {
case NEGATIVE:
if( occw == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.ccw(inf), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->ccw(inf), -1 );
_cur = Simplex( fin, Tr::VERTEX, fin->index( get<0>(_prev)->vertex( get<2>(_prev) ) ), -1 );
return;
}
if( ocw == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.cw(inf), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->cw(inf), -1 );
_cur = Simplex( fin, Tr::VERTEX, fin->index( get<0>(_prev)->vertex( get<2>(_prev) ) ), -1 );
return;
}
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.ccw(inf), _tr.cw(inf) );
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->ccw(inf), _tr->cw(inf) );
_cur = Simplex( fin, Tr::EDGE, fin->index( get<0>(_prev)->vertex( get<2>(_prev) ) ), fin->index( get<0>(_prev)->vertex( get<3>(_prev) ) ) );
return;
case COLLINEAR:
if( occw == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.ccw(inf), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->ccw(inf), -1 );
get<0>(_cur) = Cell_handle();
return;
}
if( ocw == COLLINEAR ) {
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr.cw(inf), -1 );
_prev = Simplex( get<0>(_cur), Tr::VERTEX, _tr->cw(inf), -1 );
get<0>(_cur) = Cell_handle();
return;
}
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr.ccw(inf), _tr.cw(inf) );
_prev = Simplex( get<0>(_cur), Tr::EDGE, _tr->ccw(inf), _tr->cw(inf) );
get<0>(_cur) = Cell_handle();
return;
case POSITIVE:
@ -1125,7 +1125,7 @@ CGAL::Orientation
Triangulation_segment_cell_iterator_3<Tr, Inc>::orientation(
const Facet& f, const Point& p) const
{
return _tr.orientation(
return _tr->orientation(
f.first->vertex(Tr::vertex_triple_index(f.second, 0))->point(),
f.first->vertex(Tr::vertex_triple_index(f.second, 1))->point(),
f.first->vertex(Tr::vertex_triple_index(f.second, 2))->point(),

View File

@ -1,19 +1,11 @@
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_segment_traverser_3.h>
#include <assert.h>
#include <iostream>
#include <fstream>
#include <string>
#include <boost/foreach.hpp>
#include <CGAL/IO/read_xyz_points.h>
#include <CGAL/Random.h>
#include <CGAL/Timer.h>
//#define CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
// Define the kernel.
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
@ -21,10 +13,8 @@ typedef Kernel::Point_3 Point_3;
// Define the structure.
typedef CGAL::Delaunay_triangulation_3< Kernel > DT;
typedef DT::Cell_handle Cell_handle;
typedef CGAL::Triangulation_segment_cell_iterator_3< DT > Cell_traverser;
typedef DT::Segment_cell_iterator Segment_cell_iterator;
int main(int argc, char* argv[])
{
@ -42,72 +32,44 @@ int main(int argc, char* argv[])
{ 10, 10, 10 },
{ 10, -10, 10 },
};
std::vector<DT::Vertex_handle> vertices;
vertices.reserve(points.size());
DT dt;
for(auto p: points) vertices.push_back(dt.insert(p));
DT::Cell_handle c;
Cell_handle c;
assert( dt.is_valid() );
assert(dt.is_cell(vertices[0], vertices[2], vertices[3], vertices[4], c));
assert(dt.is_cell(vertices[1], vertices[2], vertices[3], vertices[4], c));
assert( dt.is_cell(vertices[0], vertices[2], vertices[3], vertices[4], c));
assert( dt.is_cell(vertices[1], vertices[2], vertices[3], vertices[4], c));
std::cerr << dt.number_of_finite_cells() << '\n';
Cell_traverser ct(dt, points[0], points[1]);
unsigned int nb_cells = 0, nb_facets = 0, nb_edges = 0, nb_vertex = 0;
Segment_cell_iterator ct = dt.segment_traverser_cells_begin(points[0], points[1]);
Segment_cell_iterator ctend = dt.segment_traverser_cells_end(points[0], points[1]);
// Count the number of finite cells traversed.
unsigned int nb_cells = 0, nb_facets = 0, nb_edges = 0, nb_vertex = 0;
// Count the number of finite cells traversed.
unsigned int inf = 0, fin = 0;
for( ; ct != ct.end(); ++ct )
while(ct != ctend)
{
std::cerr << "Cell ( ";
for(int i = 0; i < 4; ++i)
std::cerr << ct->vertex(i)->point() << " ";
std::cerr << " )\n";
if( dt.is_infinite(ct) )
++inf;
else
{
++fin;
DT::Locate_type lt;
int li, lj;
ct.entry(lt, li, lj);
switch (lt)
{
case DT::Locate_type::FACET:
++nb_facets;
break;
case DT::Locate_type::EDGE:
++nb_edges;
break;
case DT::Locate_type::VERTEX:
++nb_vertex;
break;
default:
/*when source is in a cell*/
++nb_cells;
CGAL_assertion(lt == DT::Locate_type::CELL);
}
}
++ct;
}
#ifdef CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
std::cout << "While traversing from " << ct.source()
<< " to " << ct.target() << std::endl;
std::cout << "While traversing from " << points[0]
<< " to " << points[1] << std::endl;
std::cout << inf << " infinite and "
<< fin << " finite cells were visited." << std::endl;
std::cout << std::endl << std::endl;
#endif
std::cout << "Triangulation has " << dt.number_of_vertices() << " vertices."
<< std::endl;
std::cout << "\tnb cells : " << nb_cells << std::endl;
std::cout << "\tnb facets : " << nb_facets << std::endl;
std::cout << "\tnb edges : " << nb_edges << std::endl;
std::cout << "\tnb vertices : " << nb_vertex << std::endl;
return 0;
}

View File

@ -12,25 +12,18 @@
#include <CGAL/Random.h>
#define CGAL_TRIANGULATION_3_VERBOSE_TRAVERSER_EXAMPLE
#define CGAL_T3_TEST_SIMPLEX_TRAVERSER
// Define the kernel.
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point_3;
// Define the structure.
typedef CGAL::Delaunay_triangulation_3< Kernel > DT;
typedef CGAL::Delaunay_triangulation_3<Kernel> DT;
typedef DT::Cell_handle Cell_handle;
#ifdef CGAL_T3_TEST_SIMPLEX_TRAVERSER
typedef CGAL::Triangulation_segment_simplex_iterator_3<DT> Traverser;
#else
typedef CGAL::Triangulation_segment_cell_iterator_3<DT> Traverser;
#endif
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
template <typename Big_tuple>
bool test(const DT dt, const Big_tuple& tuple);
bool test(const DT& dt, const Big_tuple& tuple);
int main(int, char* [])
{
@ -52,20 +45,20 @@ int main(int, char* [])
vertices.reserve(points.size());
DT dt;
for(auto p: points) vertices.push_back(dt.insert(p));
DT::Cell_handle c;
assert( dt.is_valid() );
Cell_handle c;
assert(dt.is_valid());
assert(dt.is_cell(vertices[0], vertices[2], vertices[3], vertices[4], c));
assert(dt.is_cell(vertices[1], vertices[2], vertices[3], vertices[4], c));
std::cerr << dt.number_of_finite_cells() << '\n';
const std::vector < std::tuple<Point_3, Point_3, std::array<unsigned, 4>>> queries = {
// {{-1, 0, 0}, { 1, 0, 0}, {0, 0, 1, 2}}, // CFC
// {{-1, 0, 0}, { 2, 0, 0}, {1, 0, 1, 2}}, // CFCV
// {{ 2, 0, 0}, {-1, 0, 0}, {1, 0, 1, 2}}, // reverse
// {{-2, 0, 0}, { 2, 0, 0}, {2, 0, 1, 2}}, // VCFCV
// {{ 2, 0, 0}, {-2, 0, 0}, {2, 0, 1, 2}}, // reverse case: VCFCV
// {{-3, 0, 0}, { 3, 0, 0}, {2, 0, 3, 2}}, // FVCFCVF
{{-1, 0, 0}, { 1, 0, 0}, {0, 0, 1, 2}}, // CFC
{{-1, 0, 0}, { 2, 0, 0}, {1, 0, 1, 2}}, // CFCV
{{ 2, 0, 0}, {-1, 0, 0}, {1, 0, 1, 2}}, // reverse
{{-2, 0, 0}, { 2, 0, 0}, {2, 0, 1, 2}}, // VCFCV
{{ 2, 0, 0}, {-2, 0, 0}, {2, 0, 1, 2}}, // reverse case: VCFCV
{{-3, 0, 0}, { 3, 0, 0}, {2, 0, 3, 2}}, // FVCFCVF
{{-2, 0, 0}, { 2, 2, -2}, {2, 1, 1, 0}}, // VEVF
{{ 2, 2, -2}, {-2, 0, 0}, {2, 1, 1, 0}}, // reverse case: FVEV
};
@ -78,7 +71,8 @@ int main(int, char* [])
}
template <typename Big_tuple>
bool test(const DT dt, const Big_tuple& tuple) {
bool test(const DT& dt, const Big_tuple& tuple)
{
bool result = true;
using std::get;
const auto& p1 = get<0>(tuple);
@ -87,15 +81,18 @@ bool test(const DT dt, const Big_tuple& tuple) {
std::cout << "\n#\n# Query segment: ( " << p1 << " , "
<< p2 << " )\n#\n";
Traverser st(dt, p1, p2);
Segment_simplex_iterator st = dt.segment_traverser_simplices_begin(p1, p2);
Segment_simplex_iterator stend = dt.segment_traverser_simplices_end(p1, p2);
unsigned int nb_cells = 0, nb_facets = 0, nb_edges = 0, nb_vertex = 0;
unsigned int nb_collinear = 0;
// Count the number of finite cells traversed.
unsigned int inf = 0, fin = 0;
for (; st != st.end(); ++st) {
if (Cell_handle(st) != Cell_handle() && dt.is_infinite(st))
for (; st != stend; ++st)
{
if (st->dimension() == 3
&& dt.is_infinite(Cell_handle(*st)))
++inf;
else {
++fin;

View File

@ -21,7 +21,6 @@
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_segment_traverser_3.h>
#include <assert.h>
#include <iostream>
@ -45,9 +44,7 @@ typedef DT::Vertex_handle Vertex_handle;
typedef DT::Cell_handle Cell_handle;
typedef DT::Edge Edge;
typedef DT::Facet Facet;
typedef CGAL::Triangulation_segment_simplex_iterator_3<DT> Simplex_traverser;
typedef DT::Segment_simplex_iterator Segment_simplex_iterator;
void test_vertex_edge_vertex(const DT& dt, const std::size_t& nb_tests)
{
@ -70,29 +67,36 @@ void test_vertex_edge_vertex(const DT& dt, const std::size_t& nb_tests)
<< " ** " << v2->point() <<")"
<< std::endl;
std::cout << "\t(";
Simplex_traverser st(dt, v1->point() - 2.*v, v2->point() + 3.*v);
for (; st != st.end(); ++st)
Segment_simplex_iterator st
= dt.segment_traverser_simplices_begin((v1->point() - 2.*v),
(v2->point() + 3.*v));
Segment_simplex_iterator stend
= dt.segment_traverser_simplices_end((v1->point() - 2. * v),
(v2->point() + 3. * v));
for (; st != stend; ++st)
{
std::cout << st.simplex_dimension();
if(Cell_handle(st) != Cell_handle() && dt.is_infinite(st))
std::cout << st->dimension();
if(st->dimension() == 3
&& Cell_handle(*st) != Cell_handle()
&& dt.is_infinite(Cell_handle(*st)))
std::cout << "i";
std::cout << " ";
if (st.is_vertex() && st.get_vertex() == v1)
if (st->dimension() == 0 && Vertex_handle(*st) == v1)
{
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_edge());
Edge e = st.get_edge();
std::cout << st->dimension() << " ";
assert(st->dimension() == 1);
Edge e(*st);
Vertex_handle ve1 = e.first->vertex(e.second);
Vertex_handle ve2 = e.first->vertex(e.third);
assert((ve1 == v1 && ve2 == v2)
|| (ve1 == v2 && ve2 == v1));
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_vertex());
assert(st.get_vertex() == v2);
std::cout << st->dimension() << " ";
assert(st->dimension() == 0);
assert(Vertex_handle(*st) == v2);
}
}
std::cout << ")" << std::endl;
@ -123,30 +127,35 @@ void test_edge_facet_edge(const DT& dt, const std::size_t& nb_tests)
std::cout << "TEST " << i << " (" << p1 << " ** " << p2 << ")"
<< std::endl;
std::cout << "\t(";
Simplex_traverser st(dt, p1 - 2.*v, p2 + 3.*v);
for (; st != st.end(); ++st)
Segment_simplex_iterator st
= dt.segment_traverser_simplices_begin((p1 - 2. * v), (p2 + 3. * v));
Segment_simplex_iterator stend
= dt.segment_traverser_simplices_end((p1 - 2. * v), (p2 + 3. * v));
for (; st != stend; ++st)
{
std::cout << st.simplex_dimension();
if (Cell_handle(st) != Cell_handle() && dt.is_infinite(st))
std::cout << st->dimension();
if (st->dimension() == 3
&& Cell_handle(*st) != Cell_handle()
&& dt.is_infinite(Cell_handle(*st)))
std::cout << "i";
std::cout << " ";
if (st.is_edge())
if (st->dimension() == 1)
{
Edge e = st.get_edge();
Edge e = *st;
Vertex_handle va = e.first->vertex(e.second);
Vertex_handle vb = e.first->vertex(e.third);
if ((va == v1 && vb == v2)
|| (va == v2 && vb == v1))
{
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_facet());
std::cout << st->dimension() << " ";
assert(st->dimension() == 2);
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_edge());
Edge e2 = st.get_edge();
std::cout << st->dimension() << " ";
assert(st->dimension() == 1);
Edge e2 = *st;
Vertex_handle va2 = e2.first->vertex(e2.second);
Vertex_handle vb2 = e2.first->vertex(e2.third);
assert(va == va2 || va == vb2 || vb == va2 || vb == vb2);
@ -181,37 +190,42 @@ void test_edge_facet_vertex(const DT& dt, const std::size_t& nb_tests)
std::cout << "TEST " << i << " (" << p1 << " ** " << p2 << ")"
<< std::endl;
std::cout << "\t(";
Simplex_traverser st(dt, p1 - 2.*v, p2 + 3.*v);
Simplex_traverser end = st.end();
for (; st != end; ++st)
Segment_simplex_iterator st
= dt.segment_traverser_simplices_begin((p1 - 2. * v), (p2 + 3. * v));
Segment_simplex_iterator stend
= dt.segment_traverser_simplices_end((p1 - 2. * v), (p2 + 3. * v));
for (; st != stend; ++st)
{
std::cout << st.simplex_dimension();
if (Cell_handle(st) != Cell_handle() && dt.is_infinite(st))
std::cout << st->dimension();
if (st->dimension() == 3 && dt.is_infinite(Cell_handle(*st)))
std::cout << "i";
std::cout << " ";
if (st.is_edge())
if (st->dimension() == 1)
{
Edge e = st.get_edge();
Edge e = *st;
Vertex_handle va = e.first->vertex(e.second);
Vertex_handle vb = e.first->vertex(e.third);
if ((va == v1 && vb == v2) || (va == v2 && vb == v1))
{
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_facet());
std::cout << st->dimension() << " ";
assert(st->dimension() == 2);
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_vertex());
assert(st.get_vertex() == v3);
std::cout << st->dimension() << " ";
assert(st->dimension() == 0);
assert(Vertex_handle(*st) == v3);
}
++st;
std::cout << st.simplex_dimension() << " ";
if (st == st.end())
std::cout << st->dimension() << " ";
if (st == stend)
break;
else if (dt.is_infinite(st)) std::cout << "i ";
assert(st.is_cell());
else if (st->dimension() == 3
&& Cell_handle(*st) != Cell_handle()
&& dt.is_infinite(Cell_handle(*st)))
std::cout << "i ";
assert(st->dimension() == 3);
}
}
std::cout << ")" << std::endl;
@ -243,26 +257,28 @@ void test_vertex_facet_edge(const DT& dt, const std::size_t& nb_tests)
std::cout << "TEST " << i << " (" << p1 << " ** " << p2 << ")"
<< std::endl;
std::cout << "\t(";
Simplex_traverser st(dt, p1 - 2.*v, p2 + 3.*v);
Simplex_traverser end = st.end();
for (; st != end; ++st)
Segment_simplex_iterator st = dt.segment_traverser_simplices_begin(p1 - 2.*v, p2 + 3.*v);
Segment_simplex_iterator stend = dt.segment_traverser_simplices_begin(p1 - 2. * v, p2 + 3. * v);
for (; st != stend; ++st)
{
std::cout << st.simplex_dimension();
if (Cell_handle(st) != Cell_handle() && dt.is_infinite(st))
std::cout << st->dimension();
if (st->dimension() == 3
&& Cell_handle(*st) != Cell_handle()
&& dt.is_infinite(Cell_handle(*st)))
std::cout << "i";
std::cout << " ";
if (st.is_vertex() && st.get_vertex() == v1)
if (st->dimension() == 0 && Vertex_handle(*st) == v1)
{
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_facet());
assert(st.get_facet() == facets[i]
|| st.get_facet() == dt.mirror_facet(facets[i]));
std::cout << st->dimension() << " ";
assert(st->dimension() == 2);
assert(Facet(*st) == facets[i]
|| Facet(*st) == dt.mirror_facet(facets[i]));
++st;
std::cout << st.simplex_dimension() << " ";
assert(st.is_edge());
Edge e = st.get_edge();
std::cout << st->dimension() << " ";
assert(st->dimension() == 1);
Edge e(*st);
Vertex_handle va = e.first->vertex(e.second);
Vertex_handle vb = e.first->vertex(e.third);
assert((va == v2 && vb == v3) || (va == v3 && vb == v2));
@ -294,28 +310,27 @@ void test_triangulation_on_a_grid()
//along a border of the cube
queries[4] = Segment_3(Point_3(0., 0., 0.), Point_3(11., 0., 5.));
BOOST_FOREACH(Segment_3 s, queries)
for(const Segment_3& s : queries)
{
std::cout << "Query segment : (" << s.source()
<< ") to (" << s.target() << ") [";
Simplex_traverser st(dt, s);
Segment_simplex_iterator st = dt.segment_traverser_simplices_begin(s.source(), s.target());
Segment_simplex_iterator stend = dt.segment_traverser_simplices_end(s.source(), s.target());
unsigned int inf = 0, fin = 0;
unsigned int nb_facets = 0, nb_edges = 0, nb_vertex = 0;
unsigned int nb_collinear = 0;
for (; st != st.end(); ++st)
{
std::cout << st.simplex_dimension() << " ";
std::cout << st->dimension() << " ";
std::cout.flush();
if (st.is_cell())
if (st->dimension() == 3)
{
if (dt.is_infinite(st)) ++inf;
if (dt.is_infinite(Cell_handle(*st))) ++inf;
else ++fin;
}
if (st.is_facet()) ++nb_facets;
else if (st.is_edge()) ++nb_edges;
else if (st.is_vertex()) ++nb_vertex;
if (st.is_collinear()) ++nb_collinear;
if (st->dimension() == 2) ++nb_facets;
else if (st->dimension() == 1) ++nb_edges;
else if (st->dimension() == 0) ++nb_vertex;
}
std::cout << "\b]" << std::endl;
@ -324,7 +339,6 @@ void test_triangulation_on_a_grid()
std::cout << "\tfacets : " << nb_facets << std::endl;
std::cout << "\tedges : " << nb_edges << std::endl;
std::cout << "\tvertices : " << nb_vertex << std::endl;
std::cout << "\tcollinear : " << nb_collinear << std::endl;
std::cout << std::endl;
}
}
@ -368,28 +382,29 @@ int main(int argc, char* argv[])
std::cout << "Traverser " << (i + 1)
<< "\n\t(" << p1
<< ")\n\t(" << p2 << ")" << std::endl;
Simplex_traverser st(dt, p1, p2);
Segment_simplex_iterator st = dt.segment_traverser_simplices_begin(p1, p2);
Segment_simplex_iterator stend = dt.segment_traverser_simplices_end(p1, p2);
// Count the number of finite cells traversed.
unsigned int inf = 0, fin = 0;
unsigned int nb_facets = 0, nb_edges = 0, nb_vertex = 0;
unsigned int nb_collinear = 0;
for (; st != st.end(); ++st)
for (; st != stend; ++st)
{
if (st.is_cell())
if (st->dimension() == 3)
{
if (Cell_handle(st) != Cell_handle() && dt.is_infinite(st)) ++inf;
else ++fin;
if (Cell_handle(*st) != Cell_handle()
&& dt.is_infinite(Cell_handle(*st)))
++inf;
else
++fin;
}
if (st.is_facet()) ++nb_facets;
else if (st.is_edge()) ++nb_edges;
else if (st.is_vertex()) ++nb_vertex;
if (st.is_collinear()) ++nb_collinear;
if (st->dimension() == 2) ++nb_facets;
else if (st->dimension() == 1) ++nb_edges;
else if (st->dimension() == 0) ++nb_vertex;
}
std::cout << "While traversing from " << st.source()
<< " to " << st.target() << std::endl;
std::cout << "While traversing from " << p1
<< " to " << p2 << std::endl;
std::cout << "\tinfinite cells : " << inf << std::endl;
std::cout << "\tfinite cells : " << fin << std::endl;
std::cout << "\tfacets : " << nb_facets << std::endl;