mirror of https://github.com/CGAL/cgal
reimplement TDS_3::is_edge (speed-up by a factor 7)
This commit is contained in:
parent
9194bb0bca
commit
70c73237e7
|
|
@ -2057,28 +2057,67 @@ is_edge(Vertex_handle u, Vertex_handle v,
|
||||||
Cell_handle &c, int &i, int &j) const
|
Cell_handle &c, int &i, int &j) const
|
||||||
// returns false when dimension <1 or when indices wrong
|
// returns false when dimension <1 or when indices wrong
|
||||||
{
|
{
|
||||||
CGAL_expensive_precondition( is_vertex(u) && is_vertex(v) );
|
CGAL_expensive_precondition(is_vertex(u) && is_vertex(v));
|
||||||
|
|
||||||
if (u==v)
|
if(u == v)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool result = false;
|
if(dimension() == 3) {
|
||||||
|
auto d = u->cell();
|
||||||
|
boost::container::small_vector<Cell_handle, 128> cells;
|
||||||
|
cells.emplace_back(d);
|
||||||
|
d->tds_data().mark_in_conflict();
|
||||||
|
|
||||||
incident_cells(u, boost::make_function_output_iterator([&](Cell_handle ch) {
|
auto cleanup_tds_data = make_scope_exit([&] {
|
||||||
if(ch->has_vertex(v, j)) {
|
for(auto c : cells) {
|
||||||
c = ch;
|
c->tds_data().clear();
|
||||||
i = c->index(u);
|
}
|
||||||
result = true;
|
});
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
return result;
|
int head = 0;
|
||||||
|
int tail = 1;
|
||||||
|
do {
|
||||||
|
Cell_handle ch = cells[head];
|
||||||
|
|
||||||
|
for(j = 0; j < 4; ++j) { // use parameter j on purpose
|
||||||
|
if(ch->vertex(j) == v) {
|
||||||
|
c = ch;
|
||||||
|
i = ch->index(u);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if(ch->vertex(j) == u)
|
||||||
|
continue;
|
||||||
|
Cell_handle next = ch->neighbor(j);
|
||||||
|
if(!next->tds_data().is_clear())
|
||||||
|
continue;
|
||||||
|
cells.emplace_back(next);
|
||||||
|
++tail;
|
||||||
|
next->tds_data().mark_in_conflict();
|
||||||
|
}
|
||||||
|
++head;
|
||||||
|
} while(head != tail);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool edge_found = false;
|
||||||
|
// try {
|
||||||
|
incident_cells_threadsafe(u, boost::make_function_output_iterator([&](Cell_handle ch) {
|
||||||
|
if(ch->has_vertex(v, j)) {
|
||||||
|
c = ch;
|
||||||
|
i = c->index(u);
|
||||||
|
// throw true;
|
||||||
|
edge_found = true;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
// } catch(bool b) {
|
||||||
|
// result = b;
|
||||||
|
// }
|
||||||
|
|
||||||
|
return edge_found;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Vb, class Cb, class Ct>
|
template <class Vb, class Cb, class Ct>
|
||||||
bool
|
bool Triangulation_data_structure_3<Vb, Cb, Ct>::is_edge(Vertex_handle u, Vertex_handle v) const
|
||||||
Triangulation_data_structure_3<Vb,Cb,Ct>::
|
|
||||||
is_edge(Vertex_handle u, Vertex_handle v) const
|
|
||||||
{
|
{
|
||||||
Cell_handle c;
|
Cell_handle c;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue