From 1b55f11f2895edfb6e3312de96644db30fa2b027 Mon Sep 17 00:00:00 2001 From: Nicola Loi <79461707+nicolaloi@users.noreply.github.com> Date: Fri, 17 May 2024 18:34:19 +0200 Subject: [PATCH] Fix segfault (infinite recursion) of PointCloud::DetectPlanarPatches if multiple points have same coordinates (#6794) --- CHANGELOG.md | 1 + .../PointCloudPlanarPatchDetection.cpp | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b68b0bdbd02..7d3b964d6d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ - Fix log error message for `probability` argument validation in `PointCloud::SegmentPlane` (PR #6622) - Fix macOS arm64 builds, add CI runner for macOS arm64 (PR #6695) - Fix KDTreeFlann possibly using a dangling pointer instead of internal storage and simplified its members (PR #6734) +- Fix segmentation fault (infinite recursion) of DetectPlanarPatches if multiple points have same coordinates (PR #6794) ## 0.13 diff --git a/cpp/open3d/geometry/PointCloudPlanarPatchDetection.cpp b/cpp/open3d/geometry/PointCloudPlanarPatchDetection.cpp index 16813bad75e..b76bc9f3fc4 100644 --- a/cpp/open3d/geometry/PointCloudPlanarPatchDetection.cpp +++ b/cpp/open3d/geometry/PointCloudPlanarPatchDetection.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -57,12 +58,18 @@ class BoundaryVolumeHierarchy { /// \brief Constructor for the root node of the octree. /// - /// \param point_cloud is the associated set of points being partitioned - BoundaryVolumeHierarchy(const PointCloud* point_cloud, - const Eigen::Vector3d& min_bound, - const Eigen::Vector3d& max_bound, - size_t min_points = 1, - double min_size = 0.0) + /// \param point_cloud is the associated set of points being partitioned. + /// \param min_bound is the minimum coordinate of the bounding volume. + /// \param max_bound is the maximum coordinate of the bounding volume. + /// \param min_points is the threshold number of points in a node to stop + /// partitioning it further. \param min_size is the threshold size of a node + /// to stop partitioning it further. + BoundaryVolumeHierarchy( + const PointCloud* point_cloud, + const Eigen::Vector3d& min_bound, + const Eigen::Vector3d& max_bound, + size_t min_points = 1, + double min_size = std::numeric_limits::epsilon()) : point_cloud_(point_cloud), min_points_(min_points), min_size_(min_size),