В настоящее время я сталкиваюсь с ошибкой при использовании триангуляции Делоне библиотеки CGAL.Я вычисляю триангуляцию следующим образом
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point;
typedef CGAL::Delaunay_triangulation_2<Kernel> DelaunayTriangulation;
auto triangulation = DelaunayTriangulation();
triangulation.insert(points.begin(),points.end());
, где points
- данный вектор Point
с.Я запускаю код в нескольких случаях, и большую часть времени триангуляция вычисляется правильно.Однако иногда (я не могу воспроизвести это для определенного случая), триангуляция дает мне только часть ожидаемых лиц.Я реализовал следующие вспомогательные функции
auto face_count = [](DelaunayTriangulation &triangulation)
{
std::size_t face_count = 0;
for (auto it = triangulation.finite_faces_begin(); it < triangulation.finite_faces_end(); it++) {
face_count ++;
}
return face_count;
};
auto is_correct = [&convex_hull_size, &face_count, &points](DelaunayTriangulation &triangulation)
{
return face_count(triangulation) != 2*points.size() - convex_hull_size - 2;
};
для подсчета количества граней вычисленной триангуляции.В некоторых случаях можно пересчитать триангуляцию по тем же точкам, которые дают правильное количество треугольников.В других случаях, однако, я продолжаю получать ноль треугольников, которые действительно раздражают.
У меня вопрос, если кто-то сталкивался с подобными ошибками при использовании CGAL, и у меня есть идея, как я могу его отладить.Предоставить минимальный рабочий пример сложно из-за процесса чтения экземпляра.
РЕДАКТИРОВАТЬ:
Для ясности: следующий код
do
{
triangulation = DelaunayTriangulation();
triangulation.insert(points.begin(),points.end());
std::cout << "Calculated triangulation with " << face_count(triangulation) << " faces the correct amount is " << 2*points.size() - convex_hull_size - 2 << std::endl;
} while(is_correct(triangulation));
производитследующий вывод:
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 11 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 0 faces the correct amount is 60
Calculated triangulation with 60 faces the correct amount is 60
для некоторых экземпляров (но не всегда).В других случаях я неоднократно получаю 0 граней, и цикл while не прерывается.