CGAL / cgal

The public CGAL repository, see the README below
https://github.com/CGAL/cgal#readme
Other
5k stars 1.39k forks source link

Assertion error when convex decomposing Nef_polyhedron #5703

Open szobov opened 3 years ago

szobov commented 3 years ago

Hi there, I was trying to run convex decomposition on the nef_polyhedron, but it's failed.

Issue Details

terminate called after throwing an instance of 'CGAL::Assertion_exception'
  what():  CGAL ERROR: assertion violation!
File: .../libigl/external/cgal/Installation/lib/cmake/CGAL/../../../../Convex_decomposition_3/include/CGAL/Convex_decomposition_3/Ray_hit_generator2.h
Line: 169
Explanation: ray should hit vertex, edge, or facet
Aborted (core dumped)

Source Code

#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Nef_3/SNC_indexed_items.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Polygon_mesh_processing/triangulate_faces.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/convex_decomposition_3.h>

#include <igl/copyleft/cgal/mesh_to_polyhedron.h>
#include <igl/read_triangle_mesh.h>

#include <Eigen/Dense>

typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;
typedef Kernel::Point_3 Point;
typedef CGAL::Nef_polyhedron_3<Kernel> Nef_polyhedron;
typedef Nef_polyhedron::Volume_const_iterator Volume_const_iterator;

int main(int argc, char *argv[])
{
    Eigen::MatrixXi face;
    Eigen::MatrixXd vert;
    igl::read_triangle_mesh("/tmp/broken_mesh1804289383.stl", vert, face);

    Polyhedron poly;
    igl::copyleft::cgal::mesh_to_polyhedron(vert, face, poly);
    Nef_polyhedron nef;
    nef = Nef_polyhedron(poly);

    CGAL::convex_decomposition_3(nef);

    return 0;
}

(I didn't compile it but seems to be valid) broken_mesh1804289383.stl.zip

Environment

If you need any other info, please ask. Thanks

lrineau commented 3 years ago

@sloriot @afabri Who is responsible for Nef_3, now?

lrineau commented 3 years ago

@szobov Thanks for your report. Do you have any way to verify if that bug still applies with CGAL-5.2 (the later public version), or with CGAL master? It seems you use an old version of CGAL shipped with libigl. Maybe that could be updated?

lrineau commented 3 years ago

The CMake code that downlods CGAL is here: https://github.com/libigl/libigl/blob/2ce04b54fc99e3b6643a6c699f4b5b9e950dd63b/cmake/LibiglDownloadExternal.cmake#L43-L48

That is actually a download of CGAL-4.12, that is three years old, and no longer supported.

szobov commented 3 years ago

@lrineau thanks for the reply!

@szobov Thanks for your report. Do you have any way to verify if that bug still applies with CGAL-5.2 (the later public version), or with CGAL master? It seems you use an old version of CGAL shipped with libigl. Maybe that could be updated?

I've checked out to https://github.com/CGAL/cgal/commit/c733c2a9874a9b47a03cbf2bfade32c0a2b51fee but the problem is still here. If you need any help, please ask. Cheers.

PS. I've also created a similar issue, but the errors themself seem to be different. https://github.com/CGAL/cgal/issues/5711