Skip to content

Commit

Permalink
Fix isl-org#6436 - add bound check for axis aligned bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
saurabheights committed Oct 22, 2023
1 parent eba27ef commit 7145f91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 16 additions & 0 deletions cpp/open3d/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,22 @@ OrientedBoundingBox AxisAlignedBoundingBox::GetMinimalOrientedBoundingBox(
return OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(*this);
}

AxisAlignedBoundingBox::AxisAlignedBoundingBox(const Eigen::Vector3d& min_bound,
const Eigen::Vector3d& max_bound)
: Geometry3D(Geometry::GeometryType::AxisAlignedBoundingBox),
min_bound_(min_bound),
max_bound_(max_bound),
color_(1, 1, 1) {
if ((max_bound_.array() < min_bound_.array()).any()) {
open3d::utility::LogWarning(
"max_bound {} of bounding box is smaller than min_bound {} in "
"one or more axis. Fix input values to remove this warning.",
max_bound_, min_bound_);
max_bound_ = max_bound.cwiseMax(min_bound);
min_bound_ = max_bound.cwiseMin(min_bound);
}
}

AxisAlignedBoundingBox& AxisAlignedBoundingBox::Transform(
const Eigen::Matrix4d& transformation) {
utility::LogError(
Expand Down
6 changes: 1 addition & 5 deletions cpp/open3d/geometry/BoundingVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,7 @@ class AxisAlignedBoundingBox : public Geometry3D {
/// \param min_bound Lower bounds of the bounding box for all axes.
/// \param max_bound Upper bounds of the bounding box for all axes.
AxisAlignedBoundingBox(const Eigen::Vector3d& min_bound,
const Eigen::Vector3d& max_bound)
: Geometry3D(Geometry::GeometryType::AxisAlignedBoundingBox),
min_bound_(min_bound),
max_bound_(max_bound),
color_(1, 1, 1) {}
const Eigen::Vector3d& max_bound);
~AxisAlignedBoundingBox() override {}

public:
Expand Down

0 comments on commit 7145f91

Please sign in to comment.