如何通过删除"free faces"从非流形中提取底层 2-流形?

How to extract the underlying 2-manifold from a non-manifold by deleting "free faces"?

本文关键字:提取 流形 非流形 删除 何通过 free faces      更新时间:2023-10-16

我正在尝试从非manifold网格中提取基础的2个manifold(闭合表面(。我想通过删除"自由面"来实现CGAL。。除非没有脸部边界边缘,否则我想继续删除它们。例如,如果我有一个2个速度和鳍片结构,我想通过删除鳍片的所有面来获得2-Sphere。<<<<<<<<<<<<<<<<<<<<<<<<

在CGAL中,我一直在半边上进行迭代,如果我得到了一个半边缘的IS_BORDER,我将删除面部事件(更精确地使用make_hole(h((,将其删除到半边缘。当没有可能的删除时,我一直在迭代。

typedef CGAL::Exact_predicates_inexact_constructions_kernel I;
typedef CGAL::Polyhedron_3<I> Polyhedron;
Polyhedron mesh;
//
int in_this_iter = 0;
    do {
        in_this_iter = 0;
        for (auto h = mesh.halfedges_begin(); h != mesh.halfedges_end(); h++) {
            //cout << e->is_border() << endl;
            if (h->opposite()->is_border() && !h->is_border()) {
                mesh.make_hole(h);
                /*CGAL::Euler::remove_face(h,mesh);
                *gives trouble*/
                in_this_iter++;
            }
            else if (h->is_border() && !h->opposite()->is_border()) {
                mesh.make_hole(h->opposite());
                in_this_iter++;
            }
        }
        //mesh.normalize_border();
        count = count + in_this_iter;
        std::cout << "Face Deleted in this iter: " << in_this_iter<<endl;
    } while (in_this_iter != 0);
    std::cout << "Face Deleted: " << count<<endl;

我正在测试的结构是:

OFF
7 8 0
0.0 0.0 0.0
1.0 0.0 0.0
2.0 0.0 0.0
0.0 1.0 0.0
1.0 1.0 0.0
2.0 1.0 0.0
0.0 0.0 1.0
3 0 1 3
3 3 1 4
3 1 4 2
3 2 4 5
3 1 2 4
3 3 1 6
3 3 4 6
3 1 4 6

我的算法不会删除任何自由面。但是,理想的一个应该捕获四面体的四个面孔删除其他面。P.S:感谢您的帮助!如果我不遵循礼节,请原谅我,因为这是我的第一篇文章。

您不应修改循环的结构,因为结果可能是出乎意料的。相反,您可以简单地做类似的事情:

Find all faces that have an halfedge on the border
Put them in a stack
while(stack not empty)
  take the face 'f' top of the stack
  if('f' is already tagged)
    continue
  else
    tag 'f' as "to_be_removed"
    add all neighboring faces that are not already tagged to the stack
done
Remove all faces that were tagged "to_be_removed"

请注意,这大致是CGAL :: PMP :: Connected_components函数正在做的:它们以组为组的所有面孔,以使一组的面孔都可以通过从一个脸到另一个面孔互相到达。因此,您还可以做的是使用这些CGAL::PMP::connected_components函数在连接的组件中标记面部,然后丢弃不形成封闭网格的连接组件。您可以在以下功能中找到灵感,其目标是在独立的连接组件中拆分给定的结构。这将是您代码的第一步;然后,您的第二步是要查看网格是否关闭(CGAL::is_closed()(。