2

I'm using points to create planes, and then taking the intersection to form polyhedra, and using those polyhedra to construct nef polyhedra. Out of my roughly 2500 polyhedra, one seems to cause a segfault.

Here's a replication with the same input:

#include <iostream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Convex_hull_3/dual/halfspace_intersection_3.h>
#include <CGAL/Nef_polyhedron_3.h>

typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef K::Plane_3 Plane_3;
typedef K::Point_3 Point_3;
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
typedef CGAL::Nef_polyhedron_3<K> Nef_polyhedron;

int main()
{

    Plane_3 planes[5];


    planes[0] = Plane_3(Point_3(-1024, 1192, -80),
                        Point_3(-1024, 1192, -88),
                        Point_3(-1152, 1216, -88));

    planes[1] = Plane_3(Point_3(-1152, 1216, -88),
                        Point_3(-1152, 1200, -88),
                        Point_3(-1152, 1200, -80));

    planes[2] = Plane_3(Point_3(-1024, 1192, -88),
                        Point_3(-1152, 1200, -88),
                        Point_3(-1152, 1216, -88));

    planes[3] = Plane_3(Point_3(-1024, 1192, -80),
                        Point_3(-1152, 1200, -80),
                        Point_3(-1024, 1192, -88));

    planes[4] = Plane_3(Point_3(-1152, 1216, -88),
                        Point_3(-1152, 1200, -80),
                        Point_3(-1024, 1192, -80));


    CGAL::halfspace_intersection_3(std::begin(planes), std::end(planes), P);
    assert(P.is_closed());

    for (Polyhedron_3::Point_iterator pIt = P.points_begin(); pIt != P.points_end(); ++pIt)
    {
        std::cout << *pIt << std::endl;
    }

    std::cout << '\n';

    Nef_polyhedron newNef(P);
}
user3747260
  • 465
  • 1
  • 5
  • 14
  • I gave it a try and the halfspace intersection code throw an assertion saying that no interior points could be found. It might be that your set of planes is not closed. Did you checked that? Side remark: Since you are using exact constructions, you can switch to `halfspace_intersection_with_constructions_3` that should be faster. – sloriot Oct 19 '16 at 07:41
  • I reversed the point order in the post, which hopefully will help with the intersection. I forgot I had to do that in my original code, but for some reason the intersection for this test case worked for me without the points reversed. Is there a function to test if the planes are closed before computing the intersection, or do I need to make my own? – user3747260 Oct 19 '16 at 08:31
  • I guess the test to find a point inside the intersection of half-space can also be used for that purpose. Look for "problem when determing a point inside the intersection" in the header file. I think it might make more sense that the code throw an exception if an interior point cannot be found. Could you fill an [issue](https://github.com/CGAL/cgal/issues) to request that change? If you have time, a pull-request is also welcome ;) – sloriot Oct 19 '16 at 12:21

0 Answers0