Open3D 错误 ComputeHalfEdges 失败。重复的半边
Open3D ERROR ComputeHalfEdges failed. Duplicated half-edges
有谁知道如何处理三角形网格以允许转换为 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)
在 Open3d 中,如果你想从三角形网格创建半边,请确保你的网格是流形的并且没有奇异 vertex.In 如果一个顶点有多个输出半边,运行时错误将 occur.In最新版Open3d,此bug未修复Open3d Link
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;
}
singular vertices
就像红色箭头 vertices.In 这些顶点一样,会发生错误。
如果你想找到边界,请尝试 Openmesh or Libigl。Openmesh 和 Libigl 都有 python 版本。
有谁知道如何处理三角形网格以允许转换为 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)
在 Open3d 中,如果你想从三角形网格创建半边,请确保你的网格是流形的并且没有奇异 vertex.In 如果一个顶点有多个输出半边,运行时错误将 occur.In最新版Open3d,此bug未修复Open3d Link
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;
}
singular vertices 就像红色箭头 vertices.In 这些顶点一样,会发生错误。 如果你想找到边界,请尝试 Openmesh or Libigl。Openmesh 和 Libigl 都有 python 版本。