Reputation: 1969
I have a set of polygons and I want to test intersection between it and a segment. I checked the manual but I cannot find a matching function. The intersection between points, lines, segments, triangles, planes do exist. And the intersection between polygons are also there. My question is:
Upvotes: 7
Views: 4782
Reputation: 196
The easiest method is to create a Polygon_set_2 object which may contain several polygons. To test an intersection of an external polygon with this set you simply apply the do_intersect method.
For example:
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 on polygon_set_2:
I hope it's clear, Kiril
Upvotes: 7