Search code examples
c++infinite-looptriangulationcgaldelaunay

Infinite loop during CGAL::Delaunay_triangulation_3


I am using the CGAL library for triangulating a 3D point-cloud. Some times the application works fine, but most of the time it gets stuck. It enters an infinite loop while inserting a new 3D point in the triangulation. This problem I get only on Windows, on Linux it works fine always. I am using CGAL 4.6 x64 with the kernel Exact_predicates_inexact_constructions_kernel with Visual Studio 2012/2015 on Windows 8.1 x64, and GCC on Ubuntu 14.04 x64.

Any suggestions on how to fix this problem on the Windows build?

UPDATE: Follow this link to find the minimal code to reproduce the problem and a sample data-set: https://drive.google.com/file/d/0B8bb0qT4PvT8V2hqUEt0RUstLTg The problem seems to be in the optimized procedure of searching the nearest point and inserting a new point (the two pieces of code decided before compilation are equivalent, but the second is optimized in two ways: use only one locate() instead of two and do not allocate/use a std::vector for each point).


Solution

  • I think the bug is in your struct adjacent_vertex_back_inserter_t The operator= should be as follows:

        inline void operator=(const vertex_handle_t& w) {
          assert(! delaunay.is_infinite(v))
            if ( !delaunay.is_infinite(w) && (delaunay.geom_traits().compare_distance_3_object()(p, w->point(), v->point()) == CGAL::SMALLER)){
              v = w;
          }