0

有谁知道我如何处理三角形网格以允许转换为 HalfEdgeTriangleMesh。我正在尝试使用 HalfEdge 中的 get_boundaries 来检测边缘,这不是 TriangleMesh 中包含的函数

最后一行给出了错误。

mesh = mesh.remove_duplicated_triangles()
mesh = mesh.remove_degenerate_triangles()
mesh = mesh.remove_duplicated_vertices()
mesh = mesh.remove_non_manifold_edges()
mesh = mesh.remove_unreferenced_vertices()
half_edge_mesh = o3d.geometry.HalfEdgeTriangleMesh.create_from_triangle_mesh(mesh)
4

1 回答 1

1

在 Open3d 中,如果你想从三角形网格创建 HalfEdge,请确保你的网格是流形的并且没有奇异顶点。如果一个顶点有多个输出半边,则会出现运行时错误。在最新版本的 Open3d 中,此错误尚未修复。Open3d 链接

    for (size_t triangle_index = 0;
     triangle_index < mesh_cpy->triangles_.size(); triangle_index++) {
    const Eigen::Vector3i &triangle = mesh_cpy->triangles_[triangle_index];
    size_t num_half_edges = het_mesh->half_edges_.size();

    size_t he_0_index = num_half_edges;
    size_t he_1_index = num_half_edges + 1;
    size_t he_2_index = num_half_edges + 2;
    HalfEdge he_0(Eigen::Vector2i(triangle(0), triangle(1)),
                  int(triangle_index), int(he_1_index), -1);
    HalfEdge he_1(Eigen::Vector2i(triangle(1), triangle(2)),
                  int(triangle_index), int(he_2_index), -1);
    HalfEdge he_2(Eigen::Vector2i(triangle(2), triangle(0)),
                  int(triangle_index), int(he_0_index), -1);

    if (vertex_indices_to_half_edge_index.find(he_0.vertex_indices_) !=
                vertex_indices_to_half_edge_index.end() ||
        vertex_indices_to_half_edge_index.find(he_1.vertex_indices_) !=
                vertex_indices_to_half_edge_index.end() ||
        vertex_indices_to_half_edge_index.find(he_2.vertex_indices_) !=
                vertex_indices_to_half_edge_index.end()) {
        utility::LogError(
                "ComputeHalfEdges failed. Duplicated half-edges.");//Throw a runtime error.
    }

    het_mesh->half_edges_.push_back(he_0);
    het_mesh->half_edges_.push_back(he_1);
    het_mesh->half_edges_.push_back(he_2);
    vertex_indices_to_half_edge_index[he_0.vertex_indices_] = he_0_index;
    vertex_indices_to_half_edge_index[he_1.vertex_indices_] = he_1_index;
    vertex_indices_to_half_edge_index[he_2.vertex_indices_] = he_2_index;
}

奇异顶点 就像红色箭头顶点一样。在这些顶点中,会发生错误。如果你想找到边界,请尝试OpenmeshLibigl。Openmesh和 Libigl 都有 python 版本。

于 2020-12-18T05:54:40.203 回答