Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix alpha shape reconstruction if alpha too small for point scale #6998

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,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
Loading