From a590c7774e1afef91e943950942f551b47ba76b8 Mon Sep 17 00:00:00 2001 From: "Kang, Hsin-Yi" Date: Wed, 27 Dec 2023 07:15:25 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20the=20triggering=20in=20PickPointsInterac?= =?UTF-8?q?tor=20when=20there=20are=20linesets=20pr=E2=80=A6=20(#6499)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix the triggering in PickPointsInteractor when there are linesets presents * Adds handling of LineSet that is similar to Mesh and PointCloud in SetPickableGeometry() --------- Co-authored-by: Ewing Kang Co-authored-by: Sameer Sheorey --- CHANGELOG.md | 1 + .../gui/PickPointsInteractor.cpp | 21 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4b7530142f..220b0ed4131 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ - Add Doppler ICP in tensor registration pipeline (PR #5237) - Rename master branch to main. - Support in memory loading of XYZ files +- Fix geometry picker Error when LineSet objects are presented (PR #6499) ## 0.13 diff --git a/cpp/open3d/visualization/gui/PickPointsInteractor.cpp b/cpp/open3d/visualization/gui/PickPointsInteractor.cpp index 8910c64f264..45ca7c44c1e 100644 --- a/cpp/open3d/visualization/gui/PickPointsInteractor.cpp +++ b/cpp/open3d/visualization/gui/PickPointsInteractor.cpp @@ -11,8 +11,10 @@ #include #include "open3d/geometry/Image.h" +#include "open3d/geometry/LineSet.h" #include "open3d/geometry/PointCloud.h" #include "open3d/geometry/TriangleMesh.h" +#include "open3d/t/geometry/LineSet.h" #include "open3d/t/geometry/PointCloud.h" #include "open3d/t/geometry/TriangleMesh.h" #include "open3d/utility/Logging.h" @@ -161,15 +163,27 @@ void PickPointsInteractor::SetPickableGeometry( auto mesh = dynamic_cast(pg.geometry); auto tmesh = dynamic_cast(pg.tgeometry); + auto lineset = dynamic_cast(pg.geometry); + auto tlineset = + dynamic_cast(pg.tgeometry); if (cloud) { points_.insert(points_.end(), cloud->points_.begin(), cloud->points_.end()); } else if (mesh) { points_.insert(points_.end(), mesh->vertices_.begin(), mesh->vertices_.end()); - } else if (tcloud || tmesh) { - const auto &tpoints = (tcloud ? tcloud->GetPointPositions() - : tmesh->GetVertexPositions()); + } else if (lineset) { + points_.insert(points_.end(), lineset->points_.begin(), + lineset->points_.end()); + } else if (tcloud || tmesh || tlineset) { + core::Tensor tpoints; + if (tcloud) { + tpoints = tcloud->GetPointPositions(); + } else if (tmesh) { + tpoints = tmesh->GetVertexPositions(); + } else if (tlineset) { + tpoints = tlineset->GetPointPositions(); + } const size_t n = tpoints.NumElements(); float *pts = (float *)tpoints.GetDataPtr(); points_.reserve(points_.size() + n); @@ -203,6 +217,7 @@ void PickPointsInteractor::SetPickableGeometry( // picking_scene_->AddGeometry(pg.name, tmesh, mat); } } + // TODO what about Lineset selection? } // add safety but invalid obj lookup_->Add("", points_.size());