What I'm trying to achieve is to get the intersection between a line and a lot of polygons with holes β pin lines on the mask (a lot of polygons) β the result will be another line. Question in CGAL: Intersection between a segment and a polygon? suggests using Polygon with two dots to represent a string. Using CGAL samples, I came up with the following snippet. My intention was to calculate the part of the line that lies inside the rectangle using the intersection. However, the result has 4 points, and apparently it computes the intersection between the polygon and the half-plane defined by the line.
Can someone shed some light on this, please?
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; typedef Kernel::Point_2 Point_2; typedef CGAL::Polygon_2<Kernel> Polygon_2; typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2; typedef std::list<Polygon_with_holes_2> Pwh_list_2; int main() { Polygon_2 P;
source share