【问题标题】:How to cut polyhedron with a plane or bounding box?如何用平面或边界框切割多面体?
【发布时间】: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


【解决方案1】:

最简单的方法是使用文件CGAL/Polygon_mesh_processing/clip.h 中的函数未记录函数clip_to_bbox() 将平面转换为剪切bbox,并调用函数corefine() 将平面相交嵌入到网格中。如果要获取相交边缘,请将边缘约束映射传递给命名参数中的corefine()。

【讨论】:

  • 感谢您指向此标题。要在 bbox 中剪裁网格,使用起来很简单,也很有效。这是我使用的 sn-p:pastebin.com/r2EifyU8.
  • 如果您的目标是使用 bbox 或任意封闭流形网格进行剪裁,则 clip() 的过载会直接工作并记录在案。请注意,您至少应该使用CGAL::Exact_predicates_inexact_constructions_kernel 而不是CGAL::Simple_cartesian&lt;double&gt;。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-05
  • 1970-01-01
  • 1970-01-01
  • 2014-08-26
  • 2022-06-14
  • 2017-10-05
相关资源
最近更新 更多