Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes and docs improvement of AABB tensor class #6486

Merged
Prev Previous commit
Next Next commit
Correct points length check when creating AABB from points.
saurabheights committed Nov 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 722f2906a47b66cffeca397ef15498fcc4284c85
3 changes: 3 additions & 0 deletions cpp/open3d/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
@@ -330,6 +330,9 @@ AxisAlignedBoundingBox AxisAlignedBoundingBox::CreateFromPoints(
const std::vector<Eigen::Vector3d>& points) {
AxisAlignedBoundingBox box;
if (points.empty()) {
utility::LogWarning(
"The number of points is 0 when creating axis-aligned bounding "
"box.");
box.min_bound_ = Eigen::Vector3d(0.0, 0.0, 0.0);
box.max_bound_ = Eigen::Vector3d(0.0, 0.0, 0.0);
} else {
6 changes: 4 additions & 2 deletions cpp/open3d/t/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
@@ -231,8 +231,10 @@ AxisAlignedBoundingBox AxisAlignedBoundingBox::CreateFromPoints(
const core::Tensor &points) {
core::AssertTensorShape(points, {utility::nullopt, 3});
core::AssertTensorDtypes(points, {core::Float32, core::Float64});
if (points.GetLength() <= 3) {
utility::LogWarning("The points number is less than 3.");
if (points.GetLength() <= 0) {
utility::LogWarning(
"The number of points is 0 when creating axis-aligned bounding "
"box.");
return AxisAlignedBoundingBox(points.GetDevice());
} else {
const core::Tensor min_bound = points.Min({0});
2 changes: 1 addition & 1 deletion cpp/open3d/t/geometry/BoundingVolume.h
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ class AxisAlignedBoundingBox : public Geometry, public DrawableGeometry {

/// Creates the axis-aligned box that encloses the set of points.
/// \param points A list of points with data type of float32 or float64 (N x
/// 3 tensor, where N must be larger than 3).
/// 3 tensor).
/// \return AxisAlignedBoundingBox with same data type and device as input
/// points.
static AxisAlignedBoundingBox CreateFromPoints(const core::Tensor &points);
2 changes: 1 addition & 1 deletion cpp/pybind/t/geometry/boundingvolume.cpp
Original file line number Diff line number Diff line change
@@ -197,7 +197,7 @@ The scaling center will be the box center if it is not specified.)",
m, "AxisAlignedBoundingBox", "create_from_points",
{{"points",
"A list of points with data type of float32 or float64 (N x 3 "
"tensor, where N must be larger than 3)."}});
"tensor)."}});

py::class_<OrientedBoundingBox, PyGeometry<OrientedBoundingBox>,
std::shared_ptr<OrientedBoundingBox>, Geometry, DrawableGeometry>