CGAL / cgal

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

How to convert my double type data to exact type? Not related to CGAL::Cartesian_converter. #8133

Open ChenKe404 opened 2 months ago

ChenKe404 commented 2 months ago

Issue Details

I have some polygons that use the double number type, and I need to use these polygons for precise boolean operations and relational judgments. However, if I directly use the kernel CGAL::Exact_predicates_exact_constructions_kernel or Simple_cartesian<double>, the results are usually incorrect.

So I want to first convert these polygons to precise number types before performing calculations. I plan to use a tolerance value, and if the distance between two points is less than the tolerance value, then they are considered equal. Similarly, if a point's distance to a line segment is less than the tolerance value, then the point is considered to be on the line segment.

I have read https://doc.cgal.org/latest/Number_types/index.html, then I tried specializing CGAL::compare and CGAL::bounded_side_2 or use CGAL::Cartesian_converter, but they did not achieve my goal. I also tried writing my own conversion algorithm, but it was too complex for me.

In short, my goal is to read polygon data of type double from an external source (whether it's text or binary), then convert it to CGAL::Polygon or CGAL::Polygon_with_holes, and finally perform boolean operations or relational judgments.

Source Code

no

Environment