Я немного озадачен жизненным циклом дескрипторов вершин CGAL в триангуляции Делоне.Мне не ясно, когда дескрипторы признаны недействительными.
В моем приложении мне часто приходилось перемещать одну точку, и я надеялся, что смогу сделать это, не сделав недействительной структуру, содержащую дескрипторы вершин.(в документации упоминается, что итераторы признаны недействительными)
Например:
- Если триангуляция перестроена, будут ли аннулированы старые маркеры?
- Если вершина удаляется, что происходит с висящим маркером этой вершины?
В этом примере вершина в триангуляции перемещается так, чтобы она дублировалась, что привело к удалению вершины.
//https://doc.cgal.org/latest/Triangulation_2/index.html#title42
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_2.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay;
typedef Delaunay::Point Point;
int main()
{
Delaunay T;
auto handle0 = T.insert(Point(0, 0));
auto handle1 = T.insert(Point(1, 0));
auto handle2 = T.insert(Point(1, 1));
std::cout << "Beginning" << std::endl;
for (auto v = T.all_vertices_begin(); v != T.all_vertices_end(); ++v)
{
std::cout << *v << std::endl;
}
T.move(handle2, Point(0, 0));
std::cout << "Move to invalid will remove the vertex (expected)" << std::endl;
for (auto v = T.all_vertices_begin(); v != T.all_vertices_end(); ++v)
{
std::cout << *v << std::endl;
}
std::cout << "Where does this handle point to?" << std::endl;
T.move(handle2, Point(1, 1));
std::cout << "Vertices" << std::endl;
for (auto v = T.all_vertices_begin(); v != T.all_vertices_end(); ++v)
{
std::cout << *v << std::endl;
}
return 0;
}
выход
Beginning
-9.25596e+61 -9.25596e+61
0 0
1 0
1 1
Move to invalid will remove the vertex (expected)
-9.25596e+61 -9.25596e+61
0 0
1 0
Where does this handle point to?
Vertices
-9.25596e+61 -9.25596e+61
0 0
1 0