CGAL / cgal

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

PMP: CGAL::Polygon_mesh_processing::experimental::remove_self_intersections() abnormal result #8089

Open AstroJoke opened 3 months ago

AstroJoke commented 3 months ago

I get a strange case which generated from my toy code, cascading boolean diff. And this mesh will calculate abnormal result.

To illustrate clearly, I exchange the order of the template.

Source Code

int main(int argc, char** argv)
{
    constexpr int iArgcNum_repair = 2;
if (iArgcNum_repair == argc)
    {
        Surface_mesh_epeck sm;
        Surface_mesh_epeck preProcess1;

        std::string strInputA(argv[1]);
        std::ifstream ifInputA(strInputA);
        bool bFile1Suc = CGAL::IO::read_OFF(ifInputA, sm);

        if (bFile1Suc)
        {
            std::vector<Halfedge_descriptor_epeck> border_cycles;

            CGAL::Polygon_mesh_processing::extract_boundary_cycles(sm, std::back_inserter(border_cycles));
            for (Halfedge_descriptor_epeck h : border_cycles)
            {
                std::vector<Face_descriptor_epeck> patch_facets;
                CGAL::Polygon_mesh_processing::triangulate_hole(sm, h, std::back_inserter(patch_facets));
            }
            sm.collect_garbage();

            CGAL::Polygon_mesh_processing::stitch_borders(sm);
            sm.collect_garbage();

            auto temp = CGAL::Polygon_mesh_processing::experimental::remove_self_intersections(sm);
            sm.collect_garbage();

            return 0;
        }
        else
        {
            return 1; // cannot read the file
        }
    }
}

Issue Details

(and all the file are attched) The input_mesh.off is the mesh I input the code, and the path is strInputA.

if I not revise any code, it will output the mesh which named remove_self_intersections.obj

If I comment out the following code

            auto temp = CGAL::Polygon_mesh_processing::experimental::remove_self_intersections(sm);
            sm.collect_garbage();

it will output the mesh which named no_remove_self_intersections.obj

meshes.zip

But when i use MeshLab, it shows that no_remove_self_intersections.obj have not the self-intersection face, which shows as follow, and the CGAL::Polygon_mesh_processing::experimental::remove_self_intersections(sm); are treat the mesh with wrong result.

44SAQ91{5_N2U__ZUN6U0$Y

Environment

AstroJoke commented 3 months ago

it seems that i miss some code, there are some code before main

using Epeck = CGAL::Exact_predicates_exact_constructions_kernel;

using Nef_polyhedron_epeck = CGAL::Nef_polyhedron_3<Epeck>;

using Surface_mesh_epeck = CGAL::Surface_mesh<Epeck::Point_3>;

using Affine_transformation_3_epeck = CGAL::Aff_transformation_3<Epeck>;
using FT_epeck = Epeck::FT;
using Halfedge_descriptor_epeck = boost::graph_traits<Surface_mesh_epeck>::halfedge_descriptor;
using Face_descriptor_epeck = boost::graph_traits<Surface_mesh_epeck>::face_descriptor;
using Vertex_descriptor_epeck = Surface_mesh_epeck::Vertex_index;