如何通过删除"free faces"从非流形中提取底层 2-流形?
How to extract the underlying 2-manifold from a non-manifold by deleting "free faces"?
我正在尝试从非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()
(。
相关文章:
- 从包含m行的文件中提取n行,必要时(惰性地)重复该文件
- 如何从 std::atomic 中提取指针 T<T>?
- 为什么istream不支持右值提取
- 如何设置一个范围来提取我想要获得的信息
- 视觉工作室项目.提取源文件夹名称
- C++17 - 使用自定义分配器的节点提取/重新插入 - 适用于 clang++/libc++,但不适用于 libstd
- 从字符串中提取整数并形成一个数组
- C ++中的StringStream有助于使用向量从字符串中提取逗号分隔的整数,而不是空格分隔的整数,为什么?
- asn1c 不会从 asn.1 模块中提取八位字节字符串的默认值
- 从 std::vector<无符号字符>切片中提取 int?
- 在C++中使用重载提取运算符时出现问题
- 在 Qt(C++) 中使用 QProcess 解压缩 - 提取目录问题
- C++(.cpp文件和.h文件)拆分代码并添加一个函数,提取 - 这很容易吗?
- 无法从 std::string 中提取C++ Unicode 符号
- 如何从也包含C++字母的文本文件中提取某些数字?
- 如何从适合一定范围的数字中提取数字?
- C++从通用引用中提取实际类型
- 从运行服务的应用程序代码中提取窗口句柄
- 如何在字符串中找到字符,然后在C++中提取其余的字符串
- 如何通过删除"free faces"从非流形中提取底层 2-流形?