CGAL: intersection between segment and polygon?

I have a set of polygons, and I want to check the intersection between it and the segment. I checked the manual but cannot find a suitable function. There is an intersection between points, lines, segments, triangles, planes. And the intersection between the polygons is also there. My question is:

  • Is there such a function?
  • If not, does this mean that I need to split the polygons into segments and make an intersection between these segments? (The reason I'm reluctant to do this, I thought that CGAL could actually use this method to intersect polygons. Why is there no such function to intersect a line and a polygon?) Or are there any other improvements to the way to do this?
+6
source share
1 answer

The easiest way is to create a Polygon_set_2 object that can contain multiple polygons. To check the intersection of the outer polygon with this set, you simply use the do_intersect method.

For instance:

typedef CGAL::Polygon_set_2<Kernel, std::vector<Kernel::Point_2>> Polygon_set_2; Polygon_set_2 ps; Polygon_2 poly; Polygon_2 line; // line is a polygon defined by 2 points ps.insert(poly); bool intersect = ps.do_intersect(line); 

More details about polygon_set_2:

Hope this is clear, Cyril

+7
source

Source: https://habr.com/ru/post/891837/


All Articles