Skip to content

Commit

Permalink
Warn if alpha shape reconstruction has alpha too small for point scal…
Browse files Browse the repository at this point in the history
…e and results in empty mesh (#6998)
  • Loading branch information
rxba authored Oct 13, 2024
1 parent 1263be4 commit 1a98853
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- Fix projection of point cloud to Depth/RGBD image if no position attribute is provided (PR #6880)
- Support lowercase types when reading PCD files (PR #6930)
- Fix visualization/draw ICP example and add warnings (PR #6933)
- Fix alpha shape reconstruction if alpha too small for point scale (PR #6998)

## 0.13

Expand Down
53 changes: 31 additions & 22 deletions cpp/open3d/geometry/SurfaceReconstructionAlphaShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,37 @@ std::shared_ptr<TriangleMesh> TriangleMesh::CreateFromPointCloudAlphaShape(
"[CreateFromPointCloudAlphaShape] done remove duplicate triangles "
"and unreferenced vertices");

auto tmesh = t::geometry::TriangleMesh::FromLegacy(*mesh);

// use new object tmesh2 here even if some arrays share memory with tmesh.
// We don't want to replace the blobs in tmesh.
auto tmesh2 = t::geometry::vtkutils::ComputeNormals(
tmesh, /*vertex_normals=*/true, /*face_normals=*/false,
/*consistency=*/true, /*auto_orient_normals=*/true,
/*splitting=*/false);

mesh->vertices_ = core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexPositions());
mesh->triangles_ = core::eigen_converter::TensorToEigenVector3iVector(
tmesh2.GetTriangleIndices());
if (mesh->HasVertexColors()) {
mesh->vertex_colors_ =
core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexColors());
}
if (mesh->HasVertexNormals()) {
mesh->vertex_normals_ =
core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexNormals());
if (mesh->vertices_.size() > 0) {
auto tmesh = t::geometry::TriangleMesh::FromLegacy(*mesh);

// use new object tmesh2 here even if some arrays share memory with
// tmesh. We don't want to replace the blobs in tmesh.
auto tmesh2 = t::geometry::vtkutils::ComputeNormals(
tmesh, /*vertex_normals=*/true, /*face_normals=*/false,
/*consistency=*/true, /*auto_orient_normals=*/true,
/*splitting=*/false);

mesh->vertices_ = core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexPositions());
mesh->triangles_ = core::eigen_converter::TensorToEigenVector3iVector(
tmesh2.GetTriangleIndices());
if (mesh->HasVertexColors()) {
mesh->vertex_colors_ =
core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexColors());
}
if (mesh->HasVertexNormals()) {
mesh->vertex_normals_ =
core::eigen_converter::TensorToEigenVector3dVector(
tmesh2.GetVertexNormals());
}
} else {
utility::LogWarning(
fmt::format("[CreateFromPointCloudAlphaShape] alpha shape "
"reconstruction resulted in empty mesh. Alpha "
"value ({}) could be too small.",
alpha)
.c_str());
}

return mesh;
Expand Down

0 comments on commit 1a98853

Please sign in to comment.