mirror of https://github.com/CGAL/cgal
Give the TDS the ability to store a more general Cell_data in cells,
than just an implicit access to a conflict_flag.
This commit is contained in:
parent
6736efcb80
commit
919321e300
|
|
@ -55,6 +55,8 @@ class of \ccc{Triangulation_data_structure_3::Cell}.}
|
|||
\ccTypedef{typedef TriangulationDataStructure_3::Vertex_handle Vertex_handle;}{}
|
||||
\ccGlue
|
||||
\ccTypedef{typedef TriangulationDataStructure_3::Cell_handle Cell_handle;}{}
|
||||
\ccGlue
|
||||
\ccTypedef{typedef TriangulationDataStructure_3::Cell_data TDS_data;}{}
|
||||
|
||||
\ccCreation
|
||||
\ccCreationVariable{c} %% choose variable name
|
||||
|
|
@ -138,6 +140,8 @@ When \ccc{verbose} is set to \ccc{true}, messages are printed to give
|
|||
a precise indication of the kind of invalidity encountered. \ccc{level}
|
||||
increases the level of testing.}
|
||||
|
||||
\begin{ccAdvanced}
|
||||
|
||||
\ccHeading{Various}
|
||||
|
||||
\ccMethod{void * for_compact_container() const;}{}
|
||||
|
|
@ -147,12 +151,14 @@ increases the level of testing.}
|
|||
because it uses \ccc{Compact_container} to store its cells. See the
|
||||
documentation of \ccc{Compact_container} for the exact requirements.}
|
||||
|
||||
\ccMethod{void set_in_conflict_flag(unsigned char f);}{}
|
||||
\ccMethod{TDS_data& tds_data();}{}
|
||||
\ccGlue
|
||||
\ccMethod{unsigned char get_in_conflict_flag() const;}{}
|
||||
{ These functions are used internally to mark cells with a flag. The user is
|
||||
\ccMethod{const TDS_data& tds_data() const;}{}
|
||||
{ These functions are used internally by the triangulation data structure. The user is
|
||||
not encouraged to use them directly as they may change in the future.}
|
||||
|
||||
\end{ccAdvanced}
|
||||
|
||||
\ccHeading{I/O}
|
||||
|
||||
\ccFunction{istream& operator>> (istream& is, TriangulationDSCellBase_3 & c);}
|
||||
|
|
|
|||
|
|
@ -253,14 +253,14 @@ public:
|
|||
// Reset the conflict flag on the boundary.
|
||||
for(typename std::vector<Facet>::iterator fit=facets.begin();
|
||||
fit != facets.end(); ++fit) {
|
||||
fit->first->neighbor(fit->second)->set_in_conflict_flag(0);
|
||||
fit->first->neighbor(fit->second)->tds_data().clear();
|
||||
*bfit++ = *fit;
|
||||
}
|
||||
|
||||
// Reset the conflict flag in the conflict cells.
|
||||
for(typename std::vector<Cell_handle>::iterator ccit=cells.begin();
|
||||
ccit != cells.end(); ++ccit) {
|
||||
(*ccit)->set_in_conflict_flag(0);
|
||||
(*ccit)->tds_data().clear();
|
||||
*cit++ = *ccit;
|
||||
}
|
||||
return make_triple(bfit, cit, ifit);
|
||||
|
|
|
|||
|
|
@ -207,14 +207,14 @@ public:
|
|||
// Reset the conflict flag on the boundary.
|
||||
for(typename std::vector<Facet>::iterator fit=facets.begin();
|
||||
fit != facets.end(); ++fit) {
|
||||
fit->first->neighbor(fit->second)->set_in_conflict_flag(0);
|
||||
fit->first->neighbor(fit->second)->tds_data().clear();
|
||||
*bfit++ = *fit;
|
||||
}
|
||||
|
||||
// Reset the conflict flag in the conflict cells.
|
||||
for(typename std::vector<Cell_handle>::iterator ccit=cells.begin();
|
||||
ccit != cells.end(); ++ccit) {
|
||||
(*ccit)->set_in_conflict_flag(0);
|
||||
(*ccit)->tds_data().clear();
|
||||
*cit++ = *ccit;
|
||||
}
|
||||
return make_triple(bfit, cit, ifit);
|
||||
|
|
|
|||
|
|
@ -674,11 +674,6 @@ public:
|
|||
protected:
|
||||
// - c is the current cell, which must be in conflict.
|
||||
// - tester is the function object that tests if a cell is in conflict.
|
||||
//
|
||||
// in_conflict_flag value :
|
||||
// 0 -> unknown
|
||||
// 1 -> in conflict
|
||||
// 2 -> not in conflict (== on boundary)
|
||||
template <
|
||||
class Conflict_test,
|
||||
class OutputIteratorBoundaryFacets,
|
||||
|
|
@ -697,7 +692,7 @@ protected:
|
|||
|
||||
std::stack<Cell_handle> cell_stack;
|
||||
cell_stack.push(d);
|
||||
d->set_in_conflict_flag(1);
|
||||
d->tds_data().mark_in_conflict();
|
||||
*it.second++ = d;
|
||||
|
||||
do {
|
||||
|
|
@ -706,22 +701,22 @@ protected:
|
|||
|
||||
for (int i=0; i<dimension()+1; ++i) {
|
||||
Cell_handle test = c->neighbor(i);
|
||||
if (test->get_in_conflict_flag() == 1) {
|
||||
if (test->tds_data().is_in_conflict()) {
|
||||
if (c < test)
|
||||
*it.third++ = Facet(c, i); // Internal facet.
|
||||
continue; // test was already in conflict.
|
||||
}
|
||||
if (test->get_in_conflict_flag() == 0) {
|
||||
if (test->tds_data().is_clear()) {
|
||||
if (tester(test)) {
|
||||
if (c < test)
|
||||
*it.third++ = Facet(c, i); // Internal facet.
|
||||
|
||||
cell_stack.push(test);
|
||||
test->set_in_conflict_flag(1);
|
||||
test->tds_data().mark_in_conflict();
|
||||
*it.second++ = test;
|
||||
continue;
|
||||
}
|
||||
test->set_in_conflict_flag(2); // test is on the boundary.
|
||||
test->tds_data().mark_on_boundary();
|
||||
}
|
||||
*it.first++ = Facet(c, i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,20 @@ public:
|
|||
typedef typename Vb::template Rebind_TDS<Tds>::Other Vertex;
|
||||
typedef typename Cb::template Rebind_TDS<Tds>::Other Cell;
|
||||
|
||||
class Cell_data {
|
||||
unsigned char conflict_state;
|
||||
public:
|
||||
Cell_data() : conflict_state(0) {}
|
||||
|
||||
void clear() { conflict_state = 0; }
|
||||
void mark_in_conflict() { conflict_state = 1; }
|
||||
void mark_on_boundary() { conflict_state = 2; }
|
||||
|
||||
bool is_clear() const { return conflict_state == 0; }
|
||||
bool is_in_conflict() const { return conflict_state == 1; }
|
||||
bool is_on_boundary() const { return conflict_state == 2; }
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
friend class Triangulation_ds_facet_iterator_3<Tds>;
|
||||
|
|
@ -396,7 +410,7 @@ public:
|
|||
Vertex_handle newv)
|
||||
{
|
||||
for (CellIt cit = cell_begin; cit != cell_end; ++cit)
|
||||
(*cit)->set_in_conflict_flag(1);
|
||||
(*cit)->tds_data().mark_in_conflict();
|
||||
|
||||
return _insert_in_hole(cell_begin, cell_end, begin, i, newv);
|
||||
}
|
||||
|
|
@ -587,7 +601,7 @@ private:
|
|||
|
||||
std::stack<Cell_handle> cell_stack;
|
||||
cell_stack.push(d);
|
||||
d->set_in_conflict_flag(1);
|
||||
d->tds_data().mark_in_conflict();
|
||||
*it.first++ = d;
|
||||
|
||||
do {
|
||||
|
|
@ -600,10 +614,10 @@ private:
|
|||
Cell_handle next = c->neighbor(i);
|
||||
if (c < next)
|
||||
*it.second++ = Facet(c, i); // Incident facet.
|
||||
if (next->get_in_conflict_flag() != 0)
|
||||
if (! next->tds_data().is_clear())
|
||||
continue;
|
||||
cell_stack.push(next);
|
||||
next->set_in_conflict_flag(1);
|
||||
next->tds_data().mark_in_conflict();
|
||||
*it.first++ = next;
|
||||
}
|
||||
} while(!cell_stack.empty());
|
||||
|
|
@ -619,21 +633,21 @@ private:
|
|||
{
|
||||
CGAL_triangulation_precondition(dimension() == 2);
|
||||
|
||||
// TODO : in 2D, there's no real need for conflict_flag, we could use
|
||||
// TODO : in 2D, there's no real need for tds_data, we could use
|
||||
// a smarter algorithm. We could use the 2D Face_circulator.
|
||||
// Should we just have this Face_circulator ?
|
||||
|
||||
// Flag values :
|
||||
// 1 : incident cell already visited
|
||||
// 0 : unknown
|
||||
c->set_in_conflict_flag(1);
|
||||
c->tds_data().mark_in_conflict();
|
||||
*cells++ = c;
|
||||
|
||||
for (int i=0; i<3; ++i) {
|
||||
if (c->vertex(i) == v)
|
||||
continue;
|
||||
Cell_handle next = c->neighbor(i);
|
||||
if (next->get_in_conflict_flag() != 0)
|
||||
if (! next->tds_data().is_clear())
|
||||
continue;
|
||||
incident_cells_2(v, next, cells);
|
||||
}
|
||||
|
|
@ -928,7 +942,7 @@ public:
|
|||
cit != tmp_cells.end();
|
||||
++cit)
|
||||
{
|
||||
(*cit)->set_in_conflict_flag(0);
|
||||
(*cit)->tds_data().clear();
|
||||
visit(*cit);
|
||||
}
|
||||
return visit.result();
|
||||
|
|
@ -1025,9 +1039,8 @@ create_star_3(const Vertex_handle& v, const Cell_handle& c, int li,
|
|||
int prev_ind2)
|
||||
{
|
||||
CGAL_triangulation_precondition( dimension() == 3);
|
||||
CGAL_triangulation_precondition( c->get_in_conflict_flag() == 1);
|
||||
CGAL_triangulation_precondition( c->neighbor(li)->get_in_conflict_flag()
|
||||
!= 1);
|
||||
CGAL_triangulation_precondition( c->tds_data().is_in_conflict() );
|
||||
CGAL_triangulation_precondition( ! c->neighbor(li)->tds_data().is_in_conflict() );
|
||||
|
||||
Cell_handle cnew = create_cell(c->vertex(0),
|
||||
c->vertex(1),
|
||||
|
|
@ -1050,7 +1063,7 @@ create_star_3(const Vertex_handle& v, const Cell_handle& c, int li,
|
|||
int zz = ii;
|
||||
Cell_handle n = cur->neighbor(zz);
|
||||
// turn around the oriented edge vj1 vj2
|
||||
while ( n->get_in_conflict_flag() == 1) {
|
||||
while ( n->tds_data().is_in_conflict() ) {
|
||||
CGAL_triangulation_assertion( n != c );
|
||||
cur = n;
|
||||
zz = next_around_edge(n->index(vj1), n->index(vj2));
|
||||
|
|
@ -1058,7 +1071,7 @@ create_star_3(const Vertex_handle& v, const Cell_handle& c, int li,
|
|||
}
|
||||
// Now n is outside region, cur is inside.
|
||||
|
||||
n->set_in_conflict_flag(0); // Reset the flag for boundary cells.
|
||||
n->tds_data().clear(); // Reset the flag for boundary cells.
|
||||
|
||||
int jj1 = n->index(vj1);
|
||||
int jj2 = n->index(vj2);
|
||||
|
|
@ -1098,12 +1111,12 @@ create_star_2(const Vertex_handle& v, const Cell_handle& c, int li )
|
|||
do {
|
||||
cur = bound;
|
||||
// turn around v2 until we reach the boundary of region
|
||||
while ( cur->neighbor(cw(i1))->get_in_conflict_flag() == 1 ) {
|
||||
while ( cur->neighbor(cw(i1))->tds_data().is_in_conflict() ) {
|
||||
// neighbor in conflict
|
||||
cur = cur->neighbor(cw(i1));
|
||||
i1 = cur->index( v1 );
|
||||
}
|
||||
cur->neighbor(cw(i1))->set_in_conflict_flag(0);
|
||||
cur->neighbor(cw(i1))->tds_data().clear();
|
||||
// here cur has an edge on the boundary of region
|
||||
cnew = create_face( v, v1, cur->vertex( ccw(i1) ) );
|
||||
set_adjacency(cnew, 0, cur->neighbor(cw(i1)),
|
||||
|
|
@ -2078,7 +2091,7 @@ insert_in_edge(const Cell_handle& c, int i, int j)
|
|||
do {
|
||||
Cell_handle cc = ccir;
|
||||
cells.push_back(cc);
|
||||
cc->set_in_conflict_flag(1);
|
||||
cc->tds_data().mark_in_conflict();
|
||||
++ccir;
|
||||
} while (c != ccir);
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
typedef typename TDS::Cell_handle Cell_handle;
|
||||
typedef typename TDS::Vertex Vertex;
|
||||
typedef typename TDS::Cell Cell;
|
||||
typedef typename TDS::Cell_data TDS_data;
|
||||
|
||||
template <typename TDS2>
|
||||
struct Rebind_TDS { typedef Triangulation_ds_cell_base_3<TDS2> Other; };
|
||||
|
|
@ -45,7 +46,6 @@ public:
|
|||
{
|
||||
set_vertices();
|
||||
set_neighbors();
|
||||
set_in_conflict_flag(0);
|
||||
}
|
||||
|
||||
Triangulation_ds_cell_base_3(const Vertex_handle& v0, const Vertex_handle& v1,
|
||||
|
|
@ -53,7 +53,6 @@ public:
|
|||
{
|
||||
set_vertices(v0, v1, v2, v3);
|
||||
set_neighbors();
|
||||
set_in_conflict_flag(0);
|
||||
}
|
||||
|
||||
Triangulation_ds_cell_base_3(const Vertex_handle& v0, const Vertex_handle& v1,
|
||||
|
|
@ -63,7 +62,6 @@ public:
|
|||
{
|
||||
set_vertices(v0, v1, v2, v3);
|
||||
set_neighbors(n0, n1, n2, n3);
|
||||
set_in_conflict_flag(0);
|
||||
}
|
||||
|
||||
// ACCESS FUNCTIONS
|
||||
|
|
@ -198,16 +196,15 @@ public:
|
|||
void * for_compact_container() const { return N[0].for_compact_container(); }
|
||||
void * & for_compact_container() { return N[0].for_compact_container(); }
|
||||
|
||||
// Conflict flag access functions.
|
||||
// This should become a property map or something at some point.
|
||||
void set_in_conflict_flag(unsigned char f) { _in_conflict_flag = f; }
|
||||
unsigned char get_in_conflict_flag() const { return _in_conflict_flag; }
|
||||
// TDS internal data access functions.
|
||||
TDS_data& tds_data() { return _tds_data; }
|
||||
const TDS_data& tds_data() const { return _tds_data; }
|
||||
|
||||
private:
|
||||
|
||||
Cell_handle N[4];
|
||||
Vertex_handle V[4];
|
||||
unsigned char _in_conflict_flag;
|
||||
TDS_data _tds_data;
|
||||
};
|
||||
|
||||
template < class TDS >
|
||||
|
|
|
|||
Loading…
Reference in New Issue