CGAL / cgal

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

[KSP] Finalizing Partition Error [Help][CGAL 6.0.1] #8624

Open ThreeBoxWithCode opened 2 days ago

ThreeBoxWithCode commented 2 days ago

When I use KSP(Kinetic Shape Partition)[CGAL 6.0.1] to partition the space, the code ksp.partition(2) reports an error.

Issue Details

Details of the error are as follows:

--- FINALIZING PARTITION:
* getting volumes ...
CGAL error: precondition violation!
Expression : !collinear(o_prime,o,q)
File       : D:\Program_Files\CGAL-6.0.1\CGAL-6.0.1\include\CGAL/Polygon_mesh_processing/internal/Corefinement/predicates.h
Line       : 77
Explanation:
Refer to the bug-reporting instructions at https://www.cgal.org/bug_report.html
ERROR: constrained Delaunay triangulation failed

I found that in sorted_around_edge function, points o_prime, o, q were detected as collinear errors. I would like to ask how can I add constraints to the input_vertices and input_faces to avoid such errors?

I hope someone can give me some ideas. Thank you very much~

Source Code

using EPICK = CGAL::Exact_predicates_inexact_constructions_kernel;
using EPECK = CGAL::Exact_predicates_exact_constructions_kernel;

using Kernel = EPICK;
using FT = typename Kernel::FT;
using Point_3 = typename Kernel::Point_3;

using Surface_mesh = CGAL::Surface_mesh<Point_3>;
using KSP = CGAL::Kinetic_space_partition_3<EPICK>;
using Timer = CGAL::Real_timer;

std::vector<Point_3> input_vertices;
std::vector<std::vector<std::size_t> > input_faces;

try
    {
        KSP ksp(CGAL::parameters::verbose(true).debug(false));
        ksp.insert(input_vertices, input_faces);

        ksp.initialize(CGAL::parameters::bbox_dilation_ratio(1.1).reorient_bbox(false));

        ksp.partition(2);  // Error reported here!!

        ksp.getVolumes<EPICK>(output_vertices, output_faces, output_volume_centers);
    }
    catch (std::exception& e) {
        std::cerr << "\t--STOCKER: partition failed: " << e.what() << std::endl;
        return false;
    }
    catch (...) {
        return false;
    }

    if (output_faces.size() != output_volume_centers.size()) {
        return false;
    }

Environment

soesau commented 15 hours ago

I will look into it. Can you share the input data or a minimal set of polygons, so I can reproduce the error?

ThreeBoxWithCode commented 14 hours ago

I will look into it. Can you share the input data or a minimal set of polygons, so I can reproduce the error?

@soesau Thanks for your reply. I changed the data into.OFF format and put it in this link.

Here is an explanation of the data, I build polygons by assigning 2-D line segments with positive and negative height values, which I call fake polygons: Image