r70387, r70573, r70574 from Mesh_3-experimental-GF

Add incident_cells_3(Vertex_handle, std::vector<Cell_handle>)

This function avoids the construction of two additional std::vectors.
The performance gain is between 30% (g++) and 50% (VC++)
for points on surfaces as well as for points filling space.

We at the same time change the implementation of the function
incident_cells(Vertex_handle, OutputIterator).
In order to save one additional std::vector,
the cells are reported in bfs and not in dfs order
This commit is contained in:
Jane Tournois 2012-07-31 14:44:45 +00:00
parent 7d169b85f8
commit abc1515741
1 changed files with 76 additions and 0 deletions

View File

@ -652,7 +652,33 @@ private:
return it;
}
void just_incident_cells_3(Vertex_handle v,
std::vector<Cell_handle>& cells) const
{
CGAL_triangulation_precondition(dimension() == 3);
Cell_handle d = v->cell();
cells.push_back(d);
d->tds_data().mark_in_conflict();
int head=0;
int tail=1;
do {
Cell_handle c = cells[head];
for (int i=0; i<4; ++i) {
if (c->vertex(i) == v)
continue;
Cell_handle next = c->neighbor(i);
if (! next->tds_data().is_clear())
continue;
cells.push_back(next);
++tail;
next->tds_data().mark_in_conflict();
}
++head;
} while(head != tail);
}
template <class OutputIterator>
void
@ -842,8 +868,13 @@ public:
OutputIterator
incident_cells(Vertex_handle v, OutputIterator cells, Filter f = Filter()) const
{
#ifdef CGAL_JUST_INCIDENT_CELLS
return visit_just_incident_cells<Cell_extractor<OutputIterator, Filter>,
OutputIterator>(v, cells, f);
#else
return visit_incident_cells<Cell_extractor<OutputIterator, Filter>,
OutputIterator>(v, cells, f);
#endif
}
template <class OutputIterator>
@ -853,6 +884,20 @@ public:
return incident_cells<False_filter>(v, cells);
}
// This version only works for vectors and only in 3D
void incident_cells_3(Vertex_handle v,
std::vector<Cell_handle>& cells) const
{
just_incident_cells_3(v, cells);
typename std::vector<Cell_handle>::iterator cit,end;
for(cit = cells.begin(), end = cells.end();
cit != end;
++cit)
{
(*cit)->tds_data().clear();
}
}
template <class Filter, class OutputIterator>
OutputIterator
incident_facets(Vertex_handle v, OutputIterator facets, Filter f = Filter()) const
@ -978,6 +1023,37 @@ public:
return visit.result();
}
template <class Visitor, class OutputIterator, class Filter>
OutputIterator
visit_just_incident_cells(Vertex_handle v, OutputIterator output, Filter f) const
{
CGAL_triangulation_precondition( v != Vertex_handle() );
CGAL_triangulation_expensive_precondition( is_vertex(v) );
if ( dimension() < 2 )
return output;
Visitor visit(v, output, this, f);
std::vector<Cell_handle> tmp_cells;
tmp_cells.reserve(64);
if ( dimension() == 3 )
just_incident_cells_3(v, tmp_cells);
else
incident_cells_2(v, v->cell(), std::back_inserter(tmp_cells));
typename std::vector<Cell_handle>::iterator cit;
for(cit = tmp_cells.begin();
cit != tmp_cells.end();
++cit)
{
(*cit)->tds_data().clear();
visit(*cit);
}
return visit.result();
}
size_type degree(Vertex_handle v) const;
// CHECKING