From bf535be3c9daca0fa59680b28c4a0dfd477ea170 Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Wed, 8 Mar 2023 10:28:49 -0500 Subject: [PATCH 1/3] Allow TriangleModel meshes to be selected --- .../visualizer/O3DVisualizer.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp index 8e8b9e249bc..48773fa6e62 100644 --- a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp +++ b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp @@ -2026,12 +2026,30 @@ struct O3DVisualizer::Impl { void UpdateSelectableGeometry() { std::vector pickable; - pickable.reserve(objects_.size()); + // Count number of meshes stored in TriangleMeshModels + size_t model_mesh_count = 0; + size_t model_count = 0; + for (auto &o: objects_) { + if (!IsGeometryVisible(o)) { + continue; + } + if (o.model.get()) { + model_count++; + model_mesh_count += o.model.get()->meshes_.size(); + } + } + pickable.reserve(objects_.size()+model_mesh_count-model_count); for (auto &o : objects_) { if (!IsGeometryVisible(o)) { continue; } - pickable.emplace_back(o.name, o.geometry.get(), o.tgeometry.get()); + if (o.model.get()) { + for (auto &g : o.model->meshes_) { + pickable.emplace_back(o.name, g.mesh.get(), o.tgeometry.get()); + } + } else { + pickable.emplace_back(o.name, o.geometry.get(), o.tgeometry.get()); + } } selections_->SetSelectableGeometry(pickable); } From 2cbab03865e91a12bfbca7d4eabad2dce3f729ad Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Wed, 8 Mar 2023 10:29:49 -0500 Subject: [PATCH 2/3] Apply style fixes --- cpp/open3d/visualization/visualizer/O3DVisualizer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp index 48773fa6e62..9af7c2fb229 100644 --- a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp +++ b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp @@ -2029,7 +2029,7 @@ struct O3DVisualizer::Impl { // Count number of meshes stored in TriangleMeshModels size_t model_mesh_count = 0; size_t model_count = 0; - for (auto &o: objects_) { + for (auto &o : objects_) { if (!IsGeometryVisible(o)) { continue; } @@ -2038,17 +2038,19 @@ struct O3DVisualizer::Impl { model_mesh_count += o.model.get()->meshes_.size(); } } - pickable.reserve(objects_.size()+model_mesh_count-model_count); + pickable.reserve(objects_.size() + model_mesh_count - model_count); for (auto &o : objects_) { if (!IsGeometryVisible(o)) { continue; } if (o.model.get()) { for (auto &g : o.model->meshes_) { - pickable.emplace_back(o.name, g.mesh.get(), o.tgeometry.get()); + pickable.emplace_back(o.name, g.mesh.get(), + o.tgeometry.get()); } } else { - pickable.emplace_back(o.name, o.geometry.get(), o.tgeometry.get()); + pickable.emplace_back(o.name, o.geometry.get(), + o.tgeometry.get()); } } selections_->SetSelectableGeometry(pickable); From 75b5aa6c03281c624180f2bf9b1d1cf14a24e635 Mon Sep 17 00:00:00 2001 From: Rene Sepulveda Date: Wed, 8 Mar 2023 12:40:59 -0500 Subject: [PATCH 3/3] Use mesh name instead of object name --- cpp/open3d/visualization/visualizer/O3DVisualizer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp index 9af7c2fb229..5dc25714392 100644 --- a/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp +++ b/cpp/open3d/visualization/visualizer/O3DVisualizer.cpp @@ -2045,7 +2045,7 @@ struct O3DVisualizer::Impl { } if (o.model.get()) { for (auto &g : o.model->meshes_) { - pickable.emplace_back(o.name, g.mesh.get(), + pickable.emplace_back(g.mesh_name, g.mesh.get(), o.tgeometry.get()); } } else {