我有一组多边形,我想测试它和线段之间的交集。
我检查了手册,但找不到匹配的功能。
点、线、线段、三角形、平面之间确实存在交点。
并且多边形之间的交点也在那里。
我的问题是:
- 有这样的功能吗?
- 如果不是,是否意味着我需要将多边形分解成段并在这些段之间进行相交? (我不愿意这样做的原因是,我认为CGAL实际上可能会使用这种方式来进行多边形之间的相交。为什么没有这样的用于直线和多边形相交的函数?)或者还有其他更好的吗怎么办?
最简单的方法是创建一个 Polygon_set_2 对象,其中可能包含多个多边形。要测试外部多边形与该集合的交集,只需应用 do_intersect 方法即可。
例如:
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);
有关 Polygon_set_2 的更多信息:
- http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Boolean_set_operations_2_ref/Class_General_polygon_set_2.html http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Boolean_set_operations_2_ref/Class_General_polygon_set_2.html
- http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Boolean_set_operations_2_ref/Class_Polygon_set_2.html http://www.cgal.org/Manual/3.2/doc_html/cgal_manual/Boolean_set_operations_2_ref/Class_Polygon_set_2.html
我希望这是清楚的
基里尔
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)