Skip to content

Commit

Permalink
Merge branch 'master' of github.com:isl-org/Open3D into khanduja/upgr…
Browse files Browse the repository at this point in the history
…ade_documentation_techstack
  • Loading branch information
ssheorey committed Nov 14, 2023
2 parents 6be9fed + 392fcb9 commit 93a0a5b
Show file tree
Hide file tree
Showing 21 changed files with 1,206 additions and 87 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
* Changed TriangleMesh to store materials in a list so they can be accessed by the material index (PR #5938)
* Support multi-threading in the RayCastingScene function to commit scene (PR #6051).
* Fix some bad triangle generation in TriangleMesh::SimplifyQuadricDecimation
* Fix printing of tensor in gpu and add validation check for bounds of axis-aligned bounding box (PR #6444)
* Fix printing of tensor in gpu and add validation check for bounds of axis-aligned bounding box (PR #6444)
* Python 3.11 support. bump pybind11 v2.6.2 -> v2.11.1
* Check for support of CUDA Memory Pools at runtime (#4679)
* Fix `toString`, `CreateFromPoints` methods and improve docs in `AxisAlignedBoundingBox`. 🐛📝
* Migrate Open3d documentation to furo theme ✨ (#6470)

## 0.13
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ the open-source community.
- GPU acceleration for core 3D operations
- Available in C++ and Python

Here's a brief overview of the different components of Open3D and how they fit
together to enable full end to end pipelines:

![Open3D_layers](https://github.com/isl-org/Open3D/assets/41028320/e9b8645a-a823-4d78-8310-e85207bbc3e4)

For more, please visit the [Open3D documentation](http://www.open3d.org/docs).

## Python quick start
Expand Down
31 changes: 31 additions & 0 deletions cpp/open3d/core/Dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,34 @@
open3d::utility::LogError("Unsupported data type."); \
} \
}()

#define DISPATCH_INT_DTYPE_PREFIX_TO_TEMPLATE(DTYPE, PREFIX, ...) \
[&] { \
if (DTYPE == open3d::core::Int8) { \
using scalar_##PREFIX##_t = int8_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::Int16) { \
using scalar_##PREFIX##_t = int16_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::Int32) { \
using scalar_##PREFIX##_t = int32_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::Int64) { \
using scalar_##PREFIX##_t = int64_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::UInt8) { \
using scalar_##PREFIX##_t = uint8_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::UInt16) { \
using scalar_##PREFIX##_t = uint16_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::UInt32) { \
using scalar_##PREFIX##_t = uint32_t; \
return __VA_ARGS__(); \
} else if (DTYPE == open3d::core::UInt64) { \
using scalar_##PREFIX##_t = uint64_t; \
return __VA_ARGS__(); \
} else { \
open3d::utility::LogError("Unsupported data type."); \
} \
}()
5 changes: 4 additions & 1 deletion cpp/open3d/geometry/BoundingVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ AxisAlignedBoundingBox& AxisAlignedBoundingBox::Scale(
AxisAlignedBoundingBox& AxisAlignedBoundingBox::Rotate(
const Eigen::Matrix3d& rotation, const Eigen::Vector3d& center) {
utility::LogError(
"A rotation of a AxisAlignedBoundingBox would not be axis aligned "
"A rotation of an AxisAlignedBoundingBox would not be axis-aligned "
"anymore, convert it to an OrientedBoundingBox first");
return *this;
}
Expand All @@ -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 {
Expand Down
9 changes: 8 additions & 1 deletion cpp/open3d/geometry/BoundingVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ class OrientedBoundingBox : public Geometry3D {

/// \class AxisAlignedBoundingBox
///
/// \brief A bounding box that is aligned along the coordinate axes.
/// \brief A bounding box that is aligned along the coordinate axes and defined
/// by the min_bound and max_bound.
///
/// The AxisAlignedBoundingBox uses the coordinate axes for bounding box
/// generation. This means that the bounding box is oriented along the
Expand Down Expand Up @@ -227,14 +228,20 @@ class AxisAlignedBoundingBox : public Geometry3D {
/// extents.
double GetMaxExtent() const { return (max_bound_ - min_bound_).maxCoeff(); }

/// Calculates the percentage position of the given x-coordinate within
/// the x-axis range of this AxisAlignedBoundingBox.
double GetXPercentage(double x) const {
return (x - min_bound_(0)) / (max_bound_(0) - min_bound_(0));
}

/// Calculates the percentage position of the given y-coordinate within
/// the y-axis range of this AxisAlignedBoundingBox.
double GetYPercentage(double y) const {
return (y - min_bound_(1)) / (max_bound_(1) - min_bound_(1));
}

/// Calculates the percentage position of the given z-coordinate within
/// the z-axis range of this AxisAlignedBoundingBox.
double GetZPercentage(double z) const {
return (z - min_bound_(2)) / (max_bound_(2) - min_bound_(2));
}
Expand Down
29 changes: 18 additions & 11 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 Expand Up @@ -80,7 +83,7 @@ void AxisAlignedBoundingBox::SetMinBound(const core::Tensor &min_bound) {
if (Volume() < 0) {
utility::LogWarning(
"Invalid axis-aligned bounding box. Please make sure all "
"the elements in min bound are smaller than min bound.");
"the elements in min bound are smaller than max bound.");
min_bound_ = tmp;
}
}
Expand Down Expand Up @@ -110,8 +113,8 @@ void AxisAlignedBoundingBox::SetColor(const core::Tensor &color) {
if (color.Max({0}).To(core::Float64).Item<double>() > 1.0 ||
color.Min({0}).To(core::Float64).Item<double>() < 0.0) {
utility::LogError(
"The color must be in the range [0, 1], but for range [{}, "
"{}].",
"The color must be in the range [0, 1], but found in range "
"[{}, {}].",
color.Min({0}).To(core::Float64).Item<double>(),
color.Max({0}).To(core::Float64).Item<double>());
}
Expand Down Expand Up @@ -220,16 +223,20 @@ core::Tensor AxisAlignedBoundingBox::GetPointIndicesWithinBoundingBox(
}

std::string AxisAlignedBoundingBox::ToString() const {
return fmt::format("AxisAlignedBoundingBox[{}, {}]", GetDtype().ToString(),
return fmt::format("AxisAlignedBoundingBox[{} - {}, {}, {}]",
GetMinBound().ToString(false),
GetMaxBound().ToString(false), GetDtype().ToString(),
GetDevice().ToString());
}

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});
Expand Down Expand Up @@ -385,8 +392,8 @@ void OrientedBoundingBox::SetColor(const core::Tensor &color) {
if (color.Max({0}).To(core::Float64).Item<double>() > 1.0 ||
color.Min({0}).To(core::Float64).Item<double>() < 0.0) {
utility::LogError(
"The color must be in the range [0, 1], but for range [{}, "
"{}].",
"The color must be in the range [0, 1], but found in range "
"[{}, {}].",
color.Min({0}).To(core::Float64).Item<double>(),
color.Max({0}).To(core::Float64).Item<double>());
}
Expand Down
29 changes: 21 additions & 8 deletions cpp/open3d/t/geometry/BoundingVolume.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ class AxisAlignedBoundingBox : public Geometry, public DrawableGeometry {
/// \param min_bound Tensor with {3,} shape, and type float32 or float64.
void SetMinBound(const core::Tensor &min_bound);

/// \brief Set the max boundof the box.
/// \brief Set the max bound of the box.
/// If the data type of the given tensor differs from the data type of the
/// box, an exception will be thrown.
///
/// If the max bound makes the box invalid, it will not be set to the box.
/// \param min_bound Tensor with {3,} shape, and type float32 or float64.
/// \param max_bound Tensor with {3,} shape, and type float32 or float64.
void SetMaxBound(const core::Tensor &max_bound);

/// \brief Set the color of the box.
Expand Down Expand Up @@ -156,25 +156,32 @@ class AxisAlignedBoundingBox : public Geometry, public DrawableGeometry {
/// Returns the half extent of the bounding box.
core::Tensor GetHalfExtent() const { return GetExtent() / 2; }

/// Returns the maximum extent, i.e. the maximum of X, Y and Z axis'
/// \brief Returns the maximum extent, i.e. the maximum of X, Y and Z axis'
/// extents.
double GetMaxExtent() const {
return GetExtent().Max({0}).To(core::Float64).Item<double>();
}

/// Calculates the percentage position of the given x-coordinate within
/// the x-axis range of this AxisAlignedBoundingBox.
double GetXPercentage(double x) const;

/// Calculates the percentage position of the given y-coordinate within
/// the y-axis range of this AxisAlignedBoundingBox.
double GetYPercentage(double y) const;

/// Calculates the percentage position of the given z-coordinate within
/// the z-axis range of this AxisAlignedBoundingBox.
double GetZPercentage(double z) const;

/// Returns the volume of the bounding box.
double Volume() const {
return GetExtent().Prod({0}).To(core::Float64).Item<double>();
}

/// Returns the eight points that define the bounding box. The Return tensor
/// has shape {8, 3} and data type same as the box.
/// \brief Returns the eight points that define the bounding box.
///
/// The Return tensor has shape {8, 3} and data type same as the box.
core::Tensor GetBoxPoints() const;

/// \brief Indices to points that are within the bounding box.
Expand Down Expand Up @@ -206,16 +213,21 @@ 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);

protected:
/// The device to use for the bounding box. The default is CPU:0.
core::Device device_ = core::Device("CPU:0");
/// The data type of the bounding box.
core::Dtype dtype_ = core::Float32;
/// The lower x, y, z bounds of the bounding box.
core::Tensor min_bound_;
/// The upper x, y, z bounds of the bounding box.
core::Tensor max_bound_;
/// The color of the bounding box in RGB. The default is white.
core::Tensor color_;
};

Expand Down Expand Up @@ -373,8 +385,9 @@ class OrientedBoundingBox : public Geometry, public DrawableGeometry {
return GetExtent().Prod({0}).To(core::Float64).Item<double>();
}

/// Returns the eight points that define the bounding box. The Return tensor
/// has shape {8, 3} and data type same as the box.
/// \brief Returns the eight points that define the bounding box.
///
/// The Return tensor has shape {8, 3} and data type same as the box.
///
/// \verbatim
/// ------- x
Expand Down
Loading

0 comments on commit 93a0a5b

Please sign in to comment.