Skip to content

Commit

Permalink
Change invalid values of min_bound and max_bound as done in legacy, r…
Browse files Browse the repository at this point in the history
…elated pr isl-org#6444
  • Loading branch information
saurabheights committed Nov 13, 2023
1 parent 6167131 commit 7cf1c57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions cpp/open3d/t/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ AxisAlignedBoundingBox::AxisAlignedBoundingBox(const core::Tensor &min_bound,

// Check if the bounding box is valid.
if (Volume() < 0) {
utility::LogError(
"Invalid axis-aligned bounding box. Please make sure all "
"the elements in max bound are larger than min bound.");
utility::LogWarning(
"max_bound {} of bounding box is smaller than min_bound {} in "
"one or more axes. Fix input values to remove this warning.",
max_bound_.ToString(false), min_bound_.ToString(false));
max_bound_ = open3d::core::Maximum(min_bound, max_bound);
min_bound_ = open3d::core::Minimum(min_bound, max_bound);
}
}

Expand Down
9 changes: 5 additions & 4 deletions cpp/tests/t/geometry/AxisAlignedBoundingBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ TEST_P(AxisAlignedBoundingBoxPermuteDevices, Constructor) {
core::Tensor min_bound = core::Tensor::Init<float>({-1, -1, -1}, device);
core::Tensor max_bound = core::Tensor::Init<float>({1, 1, 1}, device);

// Attempt to construct with invalid min/max bound.
EXPECT_THROW(t::geometry::AxisAlignedBoundingBox(max_bound, min_bound),
std::runtime_error);

t::geometry::AxisAlignedBoundingBox aabb(min_bound, max_bound);

// Public members.
Expand All @@ -76,6 +72,11 @@ TEST_P(AxisAlignedBoundingBoxPermuteDevices, Constructor) {
core::Tensor::Init<float>({1, 1, 1}, device)));

EXPECT_EQ(aabb.GetDevice(), device);

// Attempt to construct with invalid min/max bound should create a valid
// bounding box with a warning.
t::geometry::AxisAlignedBoundingBox aabb_invalid(max_bound, min_bound);
EXPECT_TRUE(aabb_invalid.GetBoxPoints().AllClose(aabb.GetBoxPoints()));
}

TEST_P(AxisAlignedBoundingBoxPermuteDevicePairs, CopyDevice) {
Expand Down

0 comments on commit 7cf1c57

Please sign in to comment.