![](/img/trans.png)
[英]Slow building of a Symbian Qt Project in Qt Creator. Takes over 20 minutes
[英]Hole Filling methods takes over 20 minutes
当尝试用非常复杂的边界填充网格中的孔时,应用程序在孔填充调用中需要 20 分钟。
它可以是此处显示的任何调用。
我正在使用的代码是这样的:
int main()
{
std::ifstream input("V:/tobehealed2.off");
Triangle_mesh mesh;
input >> mesh;
//////////////
std::vector<std::vector<int>> indices(mesh.num_faces());
std::vector<Point_3> vertices(mesh.num_vertices());
int i = 0;
for (auto& p : mesh.points()) {
vertices[i++] = p;
}
i = 0;
for (auto& f : mesh.faces()) {
std::vector<int> triangle(3);
int j = 0;
for (auto v : mesh.vertices_around_face(mesh.halfedge(f))) {
triangle[j++] = v;
}
indices[i++] = triangle;
}
mesh.clear();
CGAL::Polygon_mesh_processing::repair_polygon_soup(vertices, indices);
CGAL::Polygon_mesh_processing::orient_polygon_soup(vertices, indices);
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(vertices, indices, mesh);
CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, 1);
bool hasHoles = true;
std::vector<face_descriptor> face_out;
std::vector<vertex_descriptor> vertex_out;
while (hasHoles) {
hasHoles = false;
for (auto& hh : mesh.halfedges()) {
if (mesh.is_border(hh)) {
hasHoles = true;
CGAL::Polygon_mesh_processing::triangulate_and_refine_hole(mesh, hh, std::back_inserter(face_out), std::back_inserter(vertex_out));
break;
}
}
face_out.clear();
vertex_out.clear();
}
CGAL::Polygon_mesh_processing::keep_largest_connected_components(mesh, 1);
CGAL::Polygon_mesh_processing::remove_isolated_vertices(mesh);
CGAL::Polygon_mesh_processing::remove_self_intersections(mesh);
CGAL::Surface_mesh_simplification::Count_stop_predicate<Triangle_mesh> stop(60000);
int r = CGAL::Surface_mesh_simplification::edge_collapse(mesh, stop);
mesh.collect_garbage();
std::ofstream out2("V:/healed.off");
out2 << mesh;
}
应用程序在调用triangulate_and_refine_hole
时需要 20 多分钟。
经过测试的 model 可在此处下载:
https://drive.google.com/file/d/1t2dwJBs5vNpg2jLOVprHEY-8tCHvCErK/view?usp=sharing
我的目标是能够事先检查 model 是否有一个如此复杂的孔,关闭它需要几分钟,所以我可以跳过填充孔的尝试。 此外,如果有办法在某个阈值时间后退出 function 调用,那就太好了。
model 的大小无关紧要。 如果我使用 3 倍大的网格,它可以在几秒钟内填充一个不那么复杂的孔。
此外,如果有办法在某个阈值时间后退出 function 调用,那就太好了。
始终有效的方法是在另一个线程中启动任务并监视该线程,并在一段时间后在必要时将其终止。
虽然真的不是一个很好的解决方案。 CGAL 仍然是一个维护的库,所以相当肯定你只是提供一些不正确的数据。 或者你确定它真的挂断了? 如果我没记错的话,36Mb 对于 model 来说是一个相当可靠的尺寸,而且孔修复是一项随着 model 复杂性而增长的任务。
编辑:嗯,如果你能负担得起在修理 model 之前等待 20 分钟,那么线程是通往 go 的方法。 它只会在后台运行。 如果你负担不起它需要这么长时间,那么它就不是那么容易了。 要么你找到一些明显更好的实现(不太可能),要么你必须做一些权衡。 要么简化 model,要么使用不太正确的孔修复(假设有一些启发式算法用于此任务)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.