mirror of https://github.com/CGAL/cgal
Faster insert for iterator ranges in Triangulation_hierarchy_2.
This commit is contained in:
parent
8342dfe408
commit
3feac5dc4c
|
|
@ -97,20 +97,39 @@ public:
|
||||||
|
|
||||||
template < class InputIterator >
|
template < class InputIterator >
|
||||||
int insert(InputIterator first, InputIterator last)
|
int insert(InputIterator first, InputIterator last)
|
||||||
{
|
{
|
||||||
int n = this->number_of_vertices();
|
int n = this->number_of_vertices();
|
||||||
|
|
||||||
std::vector<Point> points CGAL_make_vector(first, last);
|
std::vector<Point> points CGAL_make_vector(first, last);
|
||||||
std::random_shuffle (points.begin(), points.end());
|
std::random_shuffle (points.begin(), points.end());
|
||||||
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
CGAL::spatial_sort (points.begin(), points.end(), geom_traits());
|
||||||
|
|
||||||
Face_handle hint;
|
// hints[i] is the face of the previously inserted point in level i.
|
||||||
|
// Thanks to spatial sort, they are better hints than what the hierarchy
|
||||||
|
// would give us.
|
||||||
|
Face_handle hints[Triangulation_hierarchy_2__maxlevel];
|
||||||
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
for (typename std::vector<Point>::const_iterator p = points.begin(), end = points.end();
|
||||||
p != end; ++p)
|
p != end; ++p)
|
||||||
hint = insert (*p, hint)->face();
|
{
|
||||||
|
int vertex_level = random_level();
|
||||||
|
|
||||||
|
Vertex_handle v = hierarchy[0]->insert (*p, hints[0]);
|
||||||
|
hints[0] = v->face();
|
||||||
|
|
||||||
|
Vertex_handle prev = v;
|
||||||
|
|
||||||
|
for (int level = 1; level <= vertex_level; ++level) {
|
||||||
|
v = hierarchy[level]->insert (*p, hints[level]);
|
||||||
|
hints[level] = v->face();
|
||||||
|
|
||||||
|
v->set_down (prev);
|
||||||
|
prev->set_up (v);
|
||||||
|
prev = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this->number_of_vertices() - n;
|
return this->number_of_vertices() - n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove_degree_3(Vertex_handle v);
|
void remove_degree_3(Vertex_handle v);
|
||||||
void remove_first(Vertex_handle v);
|
void remove_first(Vertex_handle v);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue