ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::t::geometry::AxisAlignedBoundingBox Class Reference

A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound. More...

#include <BoundingVolume.h>

Inheritance diagram for cloudViewer::t::geometry::AxisAlignedBoundingBox:
Collaboration diagram for cloudViewer::t::geometry::AxisAlignedBoundingBox:

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...
 
AxisAlignedBoundingBoxClear () 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
 
AxisAlignedBoundingBoxTranslate (const core::Tensor &translation, bool relative=true)
 Translate the axis-aligned box by the given translation. More...
 
AxisAlignedBoundingBoxScale (double scale, const utility::optional< core::Tensor > &center=utility::nullopt)
 Scale the axis-aligned box. If $mi$ is the min_bound and $ma$ is the max_bound of the axis aligned bounding box, and $s$ and $c$ are the provided scaling factor and center respectively, then the new min_bound and max_bound are given by $mi = c + s (mi - c)$ and $ma = c + s (ma - c)$. The scaling center will be the box center if it is not specified. More...
 
AxisAlignedBoundingBoxoperator+= (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::MaterialGetMaterial ()
 Get material associated with this Geometry. More...
 
const visualization::rendering::MaterialGetMaterial () 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 class  GeometryType {
  Unspecified = 0 , PointCloud = 1 , VoxelGrid = 2 , Octree = 3 ,
  LineSet = 4 , MeshBase = 5 , TriangleMesh = 6 , HalfEdgeTriangleMesh = 7 ,
  Image = 8 , RGBDImage = 9 , TetraMesh = 10 , OrientedBoundingBox = 11 ,
  AxisAlignedBoundingBox = 12
}
 Specifies possible geometry types. More...
 
- Protected Member Functions inherited from cloudViewer::t::geometry::Geometry
 Geometry (GeometryType type, int dimension)
 Parameterized Constructor. More...
 

Detailed Description

A bounding box that is aligned along the coordinate axes and defined by the min_bound and max_bound.

Definition at line 47 of file BoundingVolume.h.

Constructor & Destructor Documentation

◆ AxisAlignedBoundingBox() [1/2]

cloudViewer::t::geometry::AxisAlignedBoundingBox::AxisAlignedBoundingBox ( const core::Device device = core::Device("CPU:0"))

Construct an empty AxisAlignedBoundingBox on the provided device.

Definition at line 19 of file BoundingVolume.cpp.

Referenced by CreateFromPoints().

◆ AxisAlignedBoundingBox() [2/2]

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.

Parameters
min_boundLower bounds of the bounding box for all axes. Tensor of shape {3,}, and type float32 or float64.
max_boundUpper bounds of the bounding box for all axes. Tensor of shape {3,}, and type float32 or float64.

Definition at line 27 of file BoundingVolume.cpp.

References AssertTensorDevice, AssertTensorDtype, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::core::Tensor::GetDevice(), and cloudViewer::core::Tensor::GetDtype().

◆ ~AxisAlignedBoundingBox()

virtual cloudViewer::t::geometry::AxisAlignedBoundingBox::~AxisAlignedBoundingBox ( )
inlineoverridevirtual

Definition at line 64 of file BoundingVolume.h.

Member Function Documentation

◆ Clear()

AxisAlignedBoundingBox & cloudViewer::t::geometry::AxisAlignedBoundingBox::Clear ( )
overridevirtual

◆ Clone()

AxisAlignedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::Clone ( ) const
inline

Returns copy of the AxisAlignedBoundingBox on the same device.

Definition at line 81 of file BoundingVolume.h.

References GetDevice(), and To().

Referenced by cloudViewer::t::geometry::pybind_boundingvolume().

◆ CreateFromPoints()

◆ FromLegacy()

AxisAlignedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::FromLegacy ( const cloudViewer::geometry::AxisAlignedBoundingBox box,
const core::Dtype dtype = core::Float32,
const core::Device device = core::Device("CPU:0") 
)
static

◆ GetBoxPoints()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetBoxPoints ( ) const

◆ GetCenter()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetCenter ( ) const
inline

◆ GetColor()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetColor ( ) const
inline

Definition at line 118 of file BoundingVolume.h.

References color_.

Referenced by cloudViewer::t::geometry::pybind_boundingvolume(), and ToLegacy().

◆ GetDevice()

core::Device cloudViewer::t::geometry::AxisAlignedBoundingBox::GetDevice ( ) const
inlineoverridevirtual

◆ GetDtype()

core::Dtype cloudViewer::t::geometry::AxisAlignedBoundingBox::GetDtype ( ) const
inline

◆ GetExtent()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetExtent ( ) const
inline

Get the extent/length of the bounding box in x, y, and z dimension.

Definition at line 155 of file BoundingVolume.h.

References max_bound_, and min_bound_.

Referenced by cloudViewer::t::geometry::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox(), GetBoxPoints(), GetHalfExtent(), GetMaxExtent(), cloudViewer::t::geometry::pybind_boundingvolume(), and Volume().

◆ GetHalfExtent()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetHalfExtent ( ) const
inline

Returns the half extent of the bounding box.

Definition at line 158 of file BoundingVolume.h.

References GetExtent().

Referenced by cloudViewer::t::geometry::pybind_boundingvolume(), and Translate().

◆ GetMaxBound()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetMaxBound ( ) const
inline

◆ GetMaxExtent()

double cloudViewer::t::geometry::AxisAlignedBoundingBox::GetMaxExtent ( ) const
inline

Returns the maximum extent, i.e. the maximum of X, Y and Z axis' extents.

Definition at line 162 of file BoundingVolume.h.

References cloudViewer::core::Float64, GetExtent(), cloudViewer::core::Tensor::Max(), and To().

Referenced by cloudViewer::t::geometry::pybind_boundingvolume().

◆ GetMinBound()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetMinBound ( ) const
inline

◆ GetOrientedBoundingBox()

◆ GetPointIndicesWithinBoundingBox()

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::GetPointIndicesWithinBoundingBox ( const core::Tensor points) const

◆ GetXPercentage()

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.

Definition at line 181 of file BoundingVolume.cpp.

References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, and cloudViewer::core::Tensor::To().

◆ GetYPercentage()

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.

Definition at line 187 of file BoundingVolume.cpp.

References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, and cloudViewer::core::Tensor::To().

◆ GetZPercentage()

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.

Definition at line 193 of file BoundingVolume.cpp.

References cloudViewer::core::Float64, cloudViewer::core::Tensor::Item(), max_bound_, min_bound_, and cloudViewer::core::Tensor::To().

◆ IsEmpty()

bool cloudViewer::t::geometry::AxisAlignedBoundingBox::IsEmpty ( ) const
inlineoverridevirtual

Returns true iff the geometry is empty.

Implements cloudViewer::t::geometry::Geometry.

Definition at line 87 of file BoundingVolume.h.

References Volume().

Referenced by cloudViewer::t::geometry::PointCloud::Crop(), and operator+=().

◆ 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.

Definition at line 162 of file BoundingVolume.cpp.

References GetDtype(), GetMaxBound(), GetMinBound(), IsEmpty(), LogError, max_bound_, cloudViewer::core::Maximum(), min_bound_, cloudViewer::core::Minimum(), cloudViewer::core::Dtype::ToString(), and ToString().

◆ Scale()

AxisAlignedBoundingBox & cloudViewer::t::geometry::AxisAlignedBoundingBox::Scale ( double  scale,
const utility::optional< core::Tensor > &  center = utility::nullopt 
)

Scale the axis-aligned box. If $mi$ is the min_bound and $ma$ is the max_bound of the axis aligned bounding box, and $s$ and $c$ are the provided scaling factor and center respectively, then the new min_bound and max_bound are given by $mi = c + s (mi - c)$ and $ma = c + s (ma - c)$. The scaling center will be the box center if it is not specified.

Parameters
scaleThe scale parameter.
centerCenter used for the scaling operation. Tensor of shape {3,}, type float32 or float64, device same as the box.

Definition at line 144 of file BoundingVolume.cpp.

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().

Referenced by cloudViewer::t::geometry::pybind_boundingvolume().

◆ SetColor()

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.

Parameters
colorTensor with {3,} shape, and type float32 or float64, with values in range [0.0, 1.0].

Definition at line 110 of file BoundingVolume.cpp.

References AssertTensorDevice, AssertTensorShape, color, color_, cloudViewer::core::Float64, GetDevice(), GetDtype(), and LogError.

Referenced by FromLegacy(), cloudViewer::t::geometry::pybind_boundingvolume(), and To().

◆ SetMaxBound()

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.

Parameters
max_boundTensor with {3,} shape, and type float32 or float64.

Definition at line 92 of file BoundingVolume.cpp.

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 cloudViewer::t::geometry::pybind_boundingvolume(), and To().

◆ SetMinBound()

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.

Parameters
min_boundTensor with {3,} shape, and type float32 or float64.

Definition at line 74 of file BoundingVolume.cpp.

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 cloudViewer::t::geometry::pybind_boundingvolume(), and To().

◆ To()

AxisAlignedBoundingBox cloudViewer::t::geometry::AxisAlignedBoundingBox::To ( const core::Device device,
bool  copy = false 
) const

Transfer the AxisAlignedBoundingBox to a specified device.

Parameters
deviceThe targeted device to convert to.
copyIf true, a new AxisAlignedBoundingBox is always created; If false, the copy is avoided when the original AxisAlignedBoundingBox is already on the targeted device.

Definition at line 55 of file BoundingVolume.cpp.

References color_, copy, GetDevice(), max_bound_, min_bound_, SetColor(), SetMaxBound(), SetMinBound(), and cloudViewer::core::Tensor::To().

Referenced by Clone(), FromLegacy(), GetMaxExtent(), cloudViewer::t::geometry::pybind_boundingvolume(), and Volume().

◆ ToLegacy()

◆ ToString()

std::string cloudViewer::t::geometry::AxisAlignedBoundingBox::ToString ( ) const

Text description.

Definition at line 226 of file BoundingVolume.cpp.

References format, GetDevice(), GetDtype(), GetMaxBound(), and GetMinBound().

Referenced by operator+=().

◆ Translate()

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.

Parameters
translationTranslation tensor of shape (3,), type float32 or float64, device same as the box.
relativeWhether to perform relative translation.

Definition at line 126 of file BoundingVolume.cpp.

References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), GetHalfExtent(), max_bound_, min_bound_, and cloudViewer::core::Tensor::To().

Referenced by cloudViewer::t::geometry::pybind_boundingvolume().

◆ Volume()

double cloudViewer::t::geometry::AxisAlignedBoundingBox::Volume ( ) const
inline

Member Data Documentation

◆ color_

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::color_
protected

The color of the bounding box in RGB. The default is white.

Definition at line 232 of file BoundingVolume.h.

Referenced by Clear(), GetColor(), SetColor(), and To().

◆ device_

core::Device cloudViewer::t::geometry::AxisAlignedBoundingBox::device_ = core::Device("CPU:0")
protected

The device to use for the bounding box. The default is CPU:0.

Definition at line 224 of file BoundingVolume.h.

Referenced by GetDevice().

◆ dtype_

core::Dtype cloudViewer::t::geometry::AxisAlignedBoundingBox::dtype_ = core::Float32
protected

The data type of the bounding box.

Definition at line 226 of file BoundingVolume.h.

Referenced by GetDtype().

◆ max_bound_

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::max_bound_
protected

◆ min_bound_

core::Tensor cloudViewer::t::geometry::AxisAlignedBoundingBox::min_bound_
protected

The documentation for this class was generated from the following files: