Я передаю точку, чтобы получить триангуляцию и выплюнуть данные ячейки.Но значение плюнуть обратно неверно, так как данные ячейки нарушают принцип триангуляции.
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K> Delaunay;
std::vector<K::Point_3> points;
std::map<Delaunay::Vertex_handle, int> index_of_vertex;
points.push_back(K::Point_3(-400.0, 0.0, 0.0));
points.push_back(K::Point_3(200, 400.0, 0.0));
points.push_back(K::Point_3(200, -400.0, 0.0));
points.push_back(K::Point_3(0.0, 0.0, 600.0));
points.push_back(K::Point_3(0.0, 0.0, -600.0));
//And here I push the vector to Delaunay
Delaunay dt(points.begin(), points.end());
// Keep track of vertex used
for (Delaunay::Finite_vertices_iterator it = t.finite_vertices_begin(); it != dt.finite_vertices_end(); ++it, ++j)
{
index_of_vertex[it.base()] = j;
}
// Iterate though and extract vertex and index in cell.
for (Delaunay::Finite_cells_iterator itCell = it.finite_cells_begin(), itend = dt.finite_cells_end(); itCell != itend; itCell++)
{
vector<double> verts;
vector<int> indx;
int ind0 = index_of_vertex[itCell->vertex(0)];
int ind1 = index_of_vertex[itCell->vertex(1)];
int ind2 = index_of_vertex[itCell->vertex(2)];
int ind3 = index_of_vertex[itCell->vertex(3)];
K::Point_3 v0 = points[ind0];
K::Point_3 v1 = points[ind1];
K::Point_3 v2 = points[ind2];
K::Point_3 v3 = points[ind3];
// Store the vertex
verts.push_back(CGAL::to_double(v0.x()));
...
verts.push_back(CGAL::to_double(v3.z()));
// extract the index
int ind00 = Delaunay::vertex_triple_index(0, 0);
...
int ind32 = Delaunay::vertex_triple_index(3, 2);
// Store the index
indx.push_back(ind00);
...
indx.push_back(ind32);
}
// ---- Ожидаем ---- Как вы видите там.У меня есть 5 баллов (-400,0, 0,0, 0,0), (200, 400,0, 0,0), (200, -400,0, 0,0), (0,0, 0,0, 600,0), (0,0, 0,0, -600,0).Так что, если он выплюнет правильно, я, скорее всего, буду две ячейки с вершиной с индексами (0, 1,2,3) и (0,1,2,4).
// ----- Результат ---- Но кое-как он разделен неправильно (0, 1, 2, 3) и (0,1,3,4).Если я уменьшу z от 3 и 4 до 300 и -300, я выплюну 3 ячейки.(0, 1, 2, 3), (4, 0, 2, 3) и (1, 4, 2, 3).
// ------ update 1 .----
Поэтому я меняю способ извлечения вершины.Я конвертирую непосредственно из itCell-> vertext-> point () и получаю вершины, которые я считаю правильными.Но это все еще дает мне много клеток, которые пересекаются с другими клетками.Я думал, что набор должен быть уникальным и не пересекаться с другой клеткой.