![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound. More...
#include <BoundingVolume.h>
Public Member Functions | |
| AxisAlignedBoundingBox (const core::Device &device=core::Device("CPU:0")) | |
| Construct an empty AxisAlignedBoundingBox on the provided device. More... | |
| AxisAlignedBoundingBox (const core::Tensor &min_bound, const core::Tensor &max_bound) | |
| Construct an AxisAlignedBoundingBox from min/max bound. More... | |
| virtual | ~AxisAlignedBoundingBox () override |
| core::Device | GetDevice () const override |
| Returns the device attribute of this AxisAlignedBoundingBox. More... | |
| core::Dtype | GetDtype () const |
| Returns the data type attribute of this AxisAlignedBoundingBox. More... | |
| AxisAlignedBoundingBox | To (const core::Device &device, bool copy=false) const |
| Transfer the AxisAlignedBoundingBox to a specified device. More... | |
| AxisAlignedBoundingBox | Clone () const |
| Returns copy of the AxisAlignedBoundingBox on the same device. More... | |
| AxisAlignedBoundingBox & | Clear () override |
| Clear all elements in the geometry. More... | |
| bool | IsEmpty () const override |
| Returns true iff the geometry is empty. More... | |
| void | SetMinBound (const core::Tensor &min_bound) |
| Set the min 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. More... | |
| void | SetMaxBound (const core::Tensor &max_bound) |
| 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. More... | |
| void | SetColor (const core::Tensor &color) |
| Set the color of the box. If the data type of the given tensor differs from the data type of the box, an exception will be thrown. More... | |
| core::Tensor | GetMinBound () const |
| core::Tensor | GetMaxBound () const |
| core::Tensor | GetColor () const |
| core::Tensor | GetCenter () const |
| AxisAlignedBoundingBox & | Translate (const core::Tensor &translation, bool relative=true) |
| Translate the axis-aligned box by the given translation. More... | |
| AxisAlignedBoundingBox & | Scale (double scale, const utility::optional< core::Tensor > ¢er=utility::nullopt) |
Scale the axis-aligned box. If is the min_bound and is the max_bound of the axis aligned bounding box, and and are the provided scaling factor and center respectively, then the new min_bound and max_bound are given by and . The scaling center will be the box center if it is not specified. More... | |
| AxisAlignedBoundingBox & | operator+= (const AxisAlignedBoundingBox &other) |
| Add operation for axis-aligned bounding box. The device of other box must be the same as the device of the current box. More... | |
| core::Tensor | GetExtent () const |
| Get the extent/length of the bounding box in x, y, and z dimension. More... | |
| core::Tensor | GetHalfExtent () const |
| Returns the half extent of the bounding box. More... | |
| double | GetMaxExtent () const |
| Returns the maximum extent, i.e. the maximum of X, Y and Z axis' extents. More... | |
| double | GetXPercentage (double x) const |
| double | GetYPercentage (double y) const |
| double | GetZPercentage (double z) const |
| double | Volume () const |
| Returns the volume of the bounding box. More... | |
| core::Tensor | GetBoxPoints () const |
| Returns the eight points that define the bounding box. More... | |
| core::Tensor | GetPointIndicesWithinBoundingBox (const core::Tensor &points) const |
| Indices to points that are within the bounding box. More... | |
| std::string | ToString () const |
| Text description. More... | |
| cloudViewer::geometry::AxisAlignedBoundingBox | ToLegacy () const |
| Convert to a legacy CloudViewer axis-aligned box. More... | |
| OrientedBoundingBox | GetOrientedBoundingBox () const |
| Convert to an oriented box. More... | |
Public Member Functions inherited from cloudViewer::t::geometry::Geometry | |
| virtual | ~Geometry () |
| GeometryType | GetGeometryType () const |
| Returns one of registered geometry types. More... | |
| int | Dimension () const |
| Returns whether the geometry is 2D or 3D. More... | |
| std::string | GetName () const |
| void | SetName (const std::string &name) |
Public Member Functions inherited from cloudViewer::core::IsDevice | |
| IsDevice ()=default | |
| virtual | ~IsDevice ()=default |
| bool | IsCPU () const |
| bool | IsCUDA () const |
| bool | IsSYCL () const |
Public Member Functions inherited from cloudViewer::t::geometry::DrawableGeometry | |
| DrawableGeometry () | |
| ~DrawableGeometry () | |
| bool | HasMaterial () const |
| Check if a material has been applied to this Geometry with SetMaterial. More... | |
| visualization::rendering::Material & | GetMaterial () |
| Get material associated with this Geometry. More... | |
| const visualization::rendering::Material & | GetMaterial () const |
| Get const reference to material associated with this Geometry. More... | |
| void | SetMaterial (const visualization::rendering::Material &material) |
| Set the material properties associate with this Geometry. More... | |
Static Public Member Functions | |
| static AxisAlignedBoundingBox | FromLegacy (const cloudViewer::geometry::AxisAlignedBoundingBox &box, const core::Dtype &dtype=core::Float32, const core::Device &device=core::Device("CPU:0")) |
| static AxisAlignedBoundingBox | CreateFromPoints (const core::Tensor &points) |
Protected Attributes | |
| core::Device | device_ = core::Device("CPU:0") |
| The device to use for the bounding box. The default is CPU:0. More... | |
| core::Dtype | dtype_ = core::Float32 |
| The data type of the bounding box. More... | |
| core::Tensor | min_bound_ |
| The lower x, y, z bounds of the bounding box. More... | |
| core::Tensor | max_bound_ |
| The upper x, y, z bounds of the bounding box. More... | |
| core::Tensor | color_ |
| The color of the bounding box in RGB. The default is white. More... | |
Additional Inherited Members | |
Public Types inherited from cloudViewer::t::geometry::Geometry | |
| enum | GeometryType { GeometryType::Unspecified = 0, GeometryType::PointCloud = 1, GeometryType::VoxelGrid = 2, GeometryType::Octree = 3, GeometryType::LineSet = 4, GeometryType::MeshBase = 5, GeometryType::TriangleMesh = 6, GeometryType::HalfEdgeTriangleMesh = 7, GeometryType::Image = 8, GeometryType::RGBDImage = 9, GeometryType::TetraMesh = 10, GeometryType::OrientedBoundingBox = 11, GeometryType::AxisAlignedBoundingBox = 12 } |
| Specifies possible geometry types. More... | |
Protected Member Functions inherited from cloudViewer::t::geometry::Geometry | |
| Geometry (GeometryType type, int dimension) | |
| Parameterized Constructor. More... | |
A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.
| cloudViewer::t::geometry::AxisAlignedBoundingBox::AxisAlignedBoundingBox | ( | const core::Device & | device = core::Device("CPU:0") | ) |
Construct an empty AxisAlignedBoundingBox on the provided device.
Referenced by CreateFromPoints().
| cloudViewer::t::geometry::AxisAlignedBoundingBox::AxisAlignedBoundingBox | ( | const core::Tensor & | min_bound, |
| const core::Tensor & | max_bound | ||
| ) |
Construct an AxisAlignedBoundingBox from min/max bound.
The AxisAlignedBoundingBox will be created on the device of the given bound tensor, which must be on the same device and have the same data type.
| min_bound | Lower bounds of the bounding box for all axes. Tensor of shape {3,}, and type float32 or float64. |
| max_bound | Upper bounds of the bounding box for all axes. Tensor of shape {3,}, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtype, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::core::Tensor::GetDevice(), and cloudViewer::core::Tensor::GetDtype().
|
inlineoverridevirtual |
|
overridevirtual |
Clear all elements in the geometry.
Implements cloudViewer::t::geometry::Geometry.
References color_, GetDevice(), GetDtype(), max_bound_, min_bound_, cloudViewer::core::Tensor::Ones(), and cloudViewer::core::Tensor::Zeros().
|
inline |
Returns copy of the AxisAlignedBoundingBox on the same device.
References GetDevice(), and To().
|
static |
Creates the axis-aligned box that encloses the set of points.
| points | A list of points with data type of float32 or float64 (N x 3 tensor). |
References AssertTensorDtypes, AssertTensorShape, AxisAlignedBoundingBox(), cloudViewer::core::Float32, cloudViewer::core::Float64, LogWarning, cloudViewer::utility::nullopt, and points.
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), cloudViewer::t::geometry::LineSet::GetAxisAlignedBoundingBox(), cloudViewer::t::geometry::OrientedBoundingBox::GetAxisAlignedBoundingBox(), cloudViewer::t::geometry::PointCloud::GetAxisAlignedBoundingBox(), and cloudViewer::t::geometry::TriangleMesh::GetAxisAlignedBoundingBox().
|
static |
Create an AxisAlignedBoundingBox from a legacy CloudViewer axis-aligned box.
| box | Legacy AxisAlignedBoundingBox. |
| dtype | The data type of the box for min_bound, max_bound and color. The default is float32. |
| device | The device of the box. The default is CPU:0. |
References cloudViewer::core::eigen_converter::EigenMatrixToTensor(), cloudViewer::core::Tensor::Flatten(), cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::BoundingBoxTpl< T >::GetColor(), LogError, cloudViewer::BoundingBoxTpl< T >::maxCorner(), cloudViewer::BoundingBoxTpl< T >::minCorner(), SetColor(), To(), cloudViewer::core::Tensor::To(), cloudViewer::core::Dtype::ToString(), Tuple3Tpl< Type >::x, Tuple3Tpl< Type >::y, and Tuple3Tpl< Type >::z.
| core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetBoxPoints | ( | ) | const |
Returns the eight points that define the bounding box.
The Return tensor has shape {8, 3} and data type same as the box.
References cloudViewer::core::Concatenate(), cloudViewer::core::Tensor::Eye(), GetDevice(), GetDtype(), GetExtent(), max_bound_, min_bound_, cloudViewer::core::Tensor::Mul(), and cloudViewer::core::Tensor::Reshape().
Referenced by cloudViewer::t::geometry::OrientedBoundingBox::GetBoxPoints().
|
inline |
References max_bound_, and min_bound_.
Referenced by cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(), and Scale().
|
inline |
References color_.
Referenced by ToLegacy().
|
inlineoverridevirtual |
Returns the device attribute of this AxisAlignedBoundingBox.
Implements cloudViewer::t::geometry::Geometry.
References device_.
Referenced by Clear(), Clone(), cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(), cloudViewer::t::geometry::PointCloud::Crop(), GetBoxPoints(), GetPointIndicesWithinBoundingBox(), Scale(), SetColor(), SetMaxBound(), SetMinBound(), To(), ToString(), and Translate().
|
inline |
Returns the data type attribute of this AxisAlignedBoundingBox.
References dtype_.
Referenced by Clear(), cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(), GetBoxPoints(), operator+=(), Scale(), SetColor(), SetMaxBound(), SetMinBound(), ToString(), and Translate().
|
inline |
Get the extent/length of the bounding box in x, y, and z dimension.
References max_bound_, and min_bound_.
Referenced by cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(), GetBoxPoints(), GetHalfExtent(), GetMaxExtent(), and Volume().
|
inline |
|
inline |
References max_bound_.
Referenced by operator+=(), ToLegacy(), and ToString().
|
inline |
Returns the maximum extent, i.e. the maximum of X, Y and Z axis' extents.
References cloudViewer::core::Float64, GetExtent(), cloudViewer::core::Tensor::Max(), and To().
|
inline |
References min_bound_.
Referenced by operator+=(), ToLegacy(), and ToString().
| OrientedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::GetOrientedBoundingBox | ( | ) | const |
Convert to an oriented box.
References cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox().
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), and cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki().
| core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetPointIndicesWithinBoundingBox | ( | const core::Tensor & | points | ) | const |
Indices to points that are within the bounding box.
| points | Tensor with {N, 3} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Bool, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinAABB(), max_bound_, min_bound_, cloudViewer::utility::nullopt, points, cloudViewer::core::Tensor::To(), and cloudViewer::core::Tensor::Zeros().
Referenced by cloudViewer::t::geometry::PointCloud::Crop().
| double cloudViewer::t::geometry::AxisAlignedBoundingBox::GetXPercentage | ( | double | x | ) | const |
Calculates the percentage position of the given x-coordinate within the x-axis range of this AxisAlignedBoundingBox.
References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, cloudViewer::core::Tensor::To(), and x.
| double cloudViewer::t::geometry::AxisAlignedBoundingBox::GetYPercentage | ( | double | y | ) | const |
Calculates the percentage position of the given y-coordinate within the y-axis range of this AxisAlignedBoundingBox.
References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, cloudViewer::core::Tensor::To(), and y.
| double cloudViewer::t::geometry::AxisAlignedBoundingBox::GetZPercentage | ( | double | z | ) | const |
Calculates the percentage position of the given z-coordinate within the z-axis range of this AxisAlignedBoundingBox.
References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, cloudViewer::core::Tensor::To(), and z.
|
inlineoverridevirtual |
Returns true iff the geometry is empty.
Implements cloudViewer::t::geometry::Geometry.
References Volume().
Referenced by cloudViewer::t::geometry::PointCloud::Crop(), and operator+=().
| AxisAlignedBoundingBox & cloudViewer::t::geometry::AxisAlignedBoundingBox::operator+= | ( | const AxisAlignedBoundingBox & | other | ) |
Add operation for axis-aligned bounding box. The device of other box must be the same as the device of the current box.
References GetDtype(), GetMaxBound(), GetMinBound(), IsEmpty(), LogError, max_bound_, cloudViewer::core::Maximum(), min_bound_, cloudViewer::core::Minimum(), cloudViewer::core::Dtype::ToString(), and ToString().
| AxisAlignedBoundingBox & cloudViewer::t::geometry::AxisAlignedBoundingBox::Scale | ( | double | scale, |
| const utility::optional< core::Tensor > & | center = utility::nullopt |
||
| ) |
Scale the axis-aligned box. If
is the min_bound and
is the max_bound of the axis aligned bounding box, and
and
are the provided scaling factor and center respectively, then the new min_bound and max_bound are given by
and
. The scaling center will be the box center if it is not specified.
| scale | The scale parameter. |
| center | Center used for the scaling operation. Tensor of shape {3,}, type float32 or float64, device same as the box. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, GetCenter(), GetDevice(), GetDtype(), cloudViewer::utility::optional< T >::has_value(), max_bound_, min_bound_, cloudViewer::core::Tensor::To(), and cloudViewer::utility::optional< T >::value().
| void cloudViewer::t::geometry::AxisAlignedBoundingBox::SetColor | ( | const core::Tensor & | color | ) |
Set the color of the box. If the data type of the given tensor differs from the data type of the box, an exception will be thrown.
| color | Tensor with {3,} shape, and type float32 or float64, with values in range [0.0, 1.0]. |
References AssertTensorDevice, AssertTensorShape, color, color_, cloudViewer::core::Float64, GetDevice(), GetDtype(), and LogError.
Referenced by FromLegacy(), and To().
| void cloudViewer::t::geometry::AxisAlignedBoundingBox::SetMaxBound | ( | const core::Tensor & | max_bound | ) |
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.
| max_bound | Tensor with {3,} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Tensor::Clone(), cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), LogWarning, max_bound_, cloudViewer::core::Tensor::To(), and Volume().
Referenced by To().
| void cloudViewer::t::geometry::AxisAlignedBoundingBox::SetMinBound | ( | const core::Tensor & | min_bound | ) |
Set the min 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 min bound makes the box invalid, it will not be set to the box.
| min_bound | Tensor with {3,} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Tensor::Clone(), cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), LogWarning, min_bound_, cloudViewer::core::Tensor::To(), and Volume().
Referenced by To().
| AxisAlignedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::To | ( | const core::Device & | device, |
| bool | copy = false |
||
| ) | const |
Transfer the AxisAlignedBoundingBox to a specified device.
| device | The targeted device to convert to. |
| copy | If true, a new AxisAlignedBoundingBox is always created; If false, the copy is avoided when the original AxisAlignedBoundingBox is already on the targeted device. |
References color_, copy, GetDevice(), max_bound_, min_bound_, SetColor(), SetMaxBound(), SetMinBound(), and cloudViewer::core::Tensor::To().
Referenced by Clone(), FromLegacy(), GetMaxExtent(), and Volume().
| cloudViewer::geometry::AxisAlignedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::ToLegacy | ( | ) | const |
Convert to a legacy CloudViewer axis-aligned box.
References e, GetColor(), GetMaxBound(), GetMinBound(), cloudViewer::BoundingBoxTpl< T >::maxCorner(), cloudViewer::BoundingBoxTpl< T >::minCorner(), cloudViewer::BoundingBoxTpl< T >::SetColor(), and cloudViewer::core::eigen_converter::TensorToEigenVector3dVector().
| std::string cloudViewer::t::geometry::AxisAlignedBoundingBox::ToString | ( | ) | const |
Text description.
References format, GetDevice(), GetDtype(), GetMaxBound(), and GetMinBound().
Referenced by operator+=().
| AxisAlignedBoundingBox & cloudViewer::t::geometry::AxisAlignedBoundingBox::Translate | ( | const core::Tensor & | translation, |
| bool | relative = true |
||
| ) |
Translate the axis-aligned box by the given translation.
If relative is true, the translation is applied to the current min and max bound. If relative is false, the translation is applied to make the box's center at the given translation.
| translation | Translation tensor of shape (3,), type float32 or float64, device same as the box. |
| relative | Whether to perform relative translation. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), GetHalfExtent(), max_bound_, min_bound_, and cloudViewer::core::Tensor::To().
|
inline |
Returns the volume of the bounding box.
References cloudViewer::core::Float64, GetExtent(), cloudViewer::core::Tensor::Prod(), and To().
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), IsEmpty(), SetMaxBound(), and SetMinBound().
|
protected |
The color of the bounding box in RGB. The default is white.
Referenced by Clear(), GetColor(), SetColor(), and To().
|
protected |
The device to use for the bounding box. The default is CPU:0.
Referenced by GetDevice().
|
protected |
The data type of the bounding box.
Referenced by GetDtype().
|
protected |
The upper x, y, z bounds of the bounding box.
Referenced by Clear(), GetBoxPoints(), GetCenter(), GetExtent(), GetMaxBound(), GetPointIndicesWithinBoundingBox(), GetXPercentage(), GetYPercentage(), GetZPercentage(), operator+=(), Scale(), SetMaxBound(), To(), and Translate().
|
protected |
The lower x, y, z bounds of the bounding box.
Referenced by Clear(), GetBoxPoints(), GetCenter(), GetExtent(), GetMinBound(), GetPointIndicesWithinBoundingBox(), GetXPercentage(), GetYPercentage(), GetZPercentage(), operator+=(), Scale(), SetMinBound(), To(), and Translate().