Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assert triggered by calling CGAL::Polygon_mesh_processing::corefine_and_compute_difference #4704

Closed
xiaowen64 opened this issue May 6, 2020 · 2 comments

Comments

@xiaowen64
Copy link

xiaowen64 commented May 6, 2020

Please use the following template to help us solving your issue.

Issue Details

calling CGAL::Polygon_mesh_processing::corefine_and_compute_difference on two innocent-looking Surface_mesh triggered an assert deep in the stack. head of the stack:

#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007fffff135859 in __GI_abort () at abort.c:79
#2 0x00007fffff51e951 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3 0x00007fffff52a47c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4 0x00007fffff52a4e7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5 0x00007fffff52a799 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x000000000800f803 in CGAL::assertion_fail (expr=0x818d65b "oxz_pqr != COLLINEAR",
file=0x818d630 "/usr/include/CGAL/predicates/kernel_ftC3.h", line=188, msg=0x817c08c "")
at /usr/include/CGAL/assertions_impl.h:170
#7 0x0000000008100445 in CGAL::coplanar_orientationC3<CGAL::Interval_nt > (px=..., py=..., pz=..., qx=..., qy=..., qz=...,
rx=..., ry=..., rz=..., sx=..., sy=..., sz=...) at /usr/include/CGAL/predicates/kernel_ftC3.h:188
#8 0x00000000080e80de in CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesian<CGAL::Interval_nt > >::operator() (this=0x7ffffffecab7, p=..., q=..., r=..., s=...) at /usr/include/CGAL/Cartesian/function_objects.h:3667
#9 0x00000000080cf955 in CGAL::Filtered_predicate<CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesianCGAL::Mpzf >, CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesian<CGAL::Interval_nt > >, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesianCGAL::Mpzf, CGAL::NT_converter<double, CGAL::Mpzf> >, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesian<CGAL::Interval_nt >, CGAL::NT_converter<double, CGAL::Interval_nt > >, true>::operator()<CGAL::Point_3CGAL::Epick, CGAL::Point_3CGAL::Epick, CGAL::Point_3CGAL::Epick, CGAL::Point_3CGAL::Epick > (this=0x7ffffffecab2) at /usr/include/CGAL/Filtered_predicate.h:98
#10 0x00000000080b1632 in CGAL::Static_filtered_predicate<CGAL::Simple_cartesian<CGAL::Interval_nt >, CGAL::Filtered_predicate<CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesian<boost::multiprecision::number<boost::multiprecision::backends::gmp_rational, (boost::multiprecision::expression_template_option)1> > >, CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesian<CGAL::Interval_nt > >, CGAL::Exact_converter<CGAL::Epeck, CGAL::Simple_cartesian<boost::multiprecision::number<boost::multiprecision::backends::gmp_rational, (boost::multiprecision::expression_template_option)1> > >, CGAL::Approx_converter<CGAL::Epeck, CGAL::Simple_cartesian<CGAL::Interval_nt > >, true>, CGAL::Filtered_predicate<CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesianCGAL::Mpzf >, CGAL::CartesianKernelFunctors::Coplanar_orientation_3<CGAL::Simple_cartesian<CGAL::Interval_nt > >, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesianCGAL::Mpzf, CGAL::NT_converter<double, CGAL::Mpzf> >, CGAL::Cartesian_converter<CGAL::Type_equality_wrapper<CGAL::Cartesian_base_no_ref_count<double, CGAL::Epick>, CGAL::Epick>, CGAL::Simple_cartesian<CGAL::Interval_nt >, CGAL::NT_converter<double, CGAL::Interval_nt > >, true> >::operator()<CGAL::Point_3CGAL::Epeck, CGAL::Point_3CGAL::Epeck, CGAL::Point_3CGAL::Epeck, CGAL::Point_3CGAL::Epeck > (this=0x7ffffffecaae, a1=..., a2=..., a3=...,
a4=...) at /usr/include/CGAL/Static_filtered_predicate.h:151
#11 0x000000000808e8ed in CGAL::Polygon_mesh_processing::Corefinement::Intersect_coplanar_faces_3<CGAL::Surface_mesh<CGAL::Point_3<CGAL::Simple_cartesian > >, CGAL::Surface_mesh<CGAL::Point_3<CGAL::Simple_cartesian > >::Property_map<CGAL::SM_Vertex_index, CGAL::Point_3<CGAL::Simple_cartesian > > >::get_orientation_and_update_info_2 (this=0x7ffffffecc80, h2=...,
ipt=...) at /usr/include/CGAL/Polygon_mesh_processing/internal/Corefinement/intersection_of_coplanar_triangles_3.h:204

Source Code

#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>

typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Surface_mesh<Kernel::Point_3> Mesh;

int main()
{
    Mesh cube;
    Mesh solid;

    std::ifstream in("cube.off");
    in >> cube;
    in.close();

    in.open("solid.off");
    in >> solid;
    in.close();

    bool valid_difference = CGAL::Polygon_mesh_processing::corefine_and_compute_difference(cube, solid, cube);

    if (valid_difference) {
        std::ofstream out("result.ply");
        CGAL::write_ply(out, cube);
        out.close();
    } else {
        std::cerr << "Error" << std::endl;
    }

    return 0;
}

Environment

  • Operating system (Windows/Mac/Linux, 32/64 bits):

    Ubuntu 20.04 via WSL on Win10 64 bit pro.

  • Compiler:

    gcc 9.3.0

  • Release or debug mode:

    Both debug and RelWithDebInfo modes

  • Specific flags used (if any):

  • CGAL version:

    5.0.2

  • Boost version:

    1.72

  • Other libraries versions if used (Eigen, TBB, etc.):

@xiaowen64
Copy link
Author

xiaowen64 commented May 6, 2020

tmp.zip

the two off files in the zip

@sloriot
Copy link
Member

sloriot commented May 6, 2020

  • Do not use a kernel without exact predicates. Kernel should be something like CGAL::Exact_predicates_inexact_constructions_kernel. See this entry for more details.
  • solid.off has some self-intersections due to a degenerate face (that can be removed successfully with the undocumented function CGAL::Polygon_mesh_processing::remove_degenerate_faces() defined in CGAL/Polygon_mesh_processing/repair.h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants