diff --git a/cpp/open3d/geometry/BoundingVolume.cpp b/cpp/open3d/geometry/BoundingVolume.cpp index 1bac823f5247..efe4667cca3f 100644 --- a/cpp/open3d/geometry/BoundingVolume.cpp +++ b/cpp/open3d/geometry/BoundingVolume.cpp @@ -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( diff --git a/cpp/open3d/geometry/BoundingVolume.h b/cpp/open3d/geometry/BoundingVolume.h index e808b232612e..76cdca5977de 100644 --- a/cpp/open3d/geometry/BoundingVolume.h +++ b/cpp/open3d/geometry/BoundingVolume.h @@ -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: