【发布时间】:2019-09-09 03:02:56
【问题描述】:
在多面体中,我如何获得与给定平面相交的任何边的句柄(目的是我可以用CGAL::polyhedron_cut_plane_3 进一步切割它)?
我目前有这个 sn-p 但它不起作用。我是根据 CGAL 文档和示例中的片段构建的:
typedef CGAL::Simple_cartesian<double> Kernel;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::AABB_face_graph_triangle_primitive<Polyhedron> Primitive;
typedef CGAL::AABB_traits<Kernel, Primitive> Traits;
Polyhedron poly = load_obj(argv[1]); // load from file using a helper
Kernel::Plane_3 plane(1, 0, 0, 0); // I am certain this plane intersects the given mesh
CGAL::AABB_tree<Traits> tree(faces(poly).first, faces(poly).second, poly);
auto intersection = tree.any_intersection(plane);
if (intersection) {
if (boost::get<Kernel::Segment_3>(&(intersection->first))) {
// SHOULD enter here and I can do things with intersection->second
} else {
// BUT it enters here
}
} else {
std::cout << "No intersection." << std::endl;
}
2019 年 9 月 9 日编辑:
我更改了原来的标题旧标题:如何获得平面多面体交叉点中某个边的句柄。使用CGAL/Polygon_mesh_processing/clip.h提供的方法,无需使用AABB_Tree寻找交点。
- 用一个平面剪辑,一条线就够了:
CGAL::Polygon_mesh_processing::clip(poly, plane); - 按照@sloriot 的建议,要在某个边界框内进行剪辑,有一个内部函数
CGAL::Polygon_mesh_processing::internal::clip_to_bbox。这里是an example。
【问题讨论】:
-
您必须调用 any_intersected_primitive() doc.cgal.org/latest/AABB_tree/… 而不是 any_intersection()
-
我确信可以通过这种方式完成,但由于我找到了一个更简单的替代方案,所以我不会花更多时间来解决这个问题。无论如何,谢谢。
标签: cgal