0

Does anyone know how I can process a triangle mesh to allow conversion into a HalfEdgeTriangleMesh. I am trying to use the get_boundaries in HalfEdge to detect edges, which is not an included function in TriangleMesh

The last line gives the error.

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)
Alberto MQ
  • 373
  • 2
  • 16
  • Have you perhaps found a way around this? I'm facing the same issue, and none of the open3d built-in methods seem to help – Teo Cherici Apr 24 '20 at 10:33
  • @TeoCherici I decided to use get_non_manifold_edges instead – Alberto MQ Apr 24 '20 at 16:28
  • Thank you for your reply. Do you mean that you got better results by using `get_non_manifold_edges` and then manually removing them from the object? – Teo Cherici Apr 28 '20 at 08:35
  • What are you trying to do exactly? – Alberto MQ Apr 28 '20 at 17:10
  • I'm trying to generate a HalfEdgeTriangleMesh from a TriangleMesh, so that I can extract the boundary edges. Unfortunately, some of my meshes seem to have irregularities and non-manifold edges that cause the conversion to fail. – Teo Cherici May 04 '20 at 08:58
  • So I just kept it as a triangle mesh and ran get_non_manifold_edges setting allow_boundary_edges to false – Alberto MQ May 04 '20 at 14:42

1 Answers1

1

In Open3d,if you want to create HalfEdge from triangle mesh,please make sure your mesh is manifold and without singular vertex.In the case of a vertex has more than one output halfedge,runtime error will occur.In the newest version of Open3d,this bug has not been repaired.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 just like red arrows vertices.In these vertices,error will occur. If you want to find boundary,please try Openmesh or Libigl.Both Openmesh and Libigl have python version.

xiterson
  • 26
  • 1
  • 3