![]() |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
A bounding box oriented along an arbitrary frame of reference. More...
#include <BoundingVolume.h>
Public Member Functions | |
| OrientedBoundingBox (const core::Device &device=core::Device("CPU:0")) | |
| Construct an empty OrientedBoundingBox on the provided device. More... | |
| OrientedBoundingBox (const core::Tensor ¢er, const core::Tensor &rotation, const core::Tensor &extent) | |
| Construct an OrientedBoundingBox from center, rotation and extent. More... | |
| virtual | ~OrientedBoundingBox () override |
| core::Device | GetDevice () const override |
| Returns the device attribute of this OrientedBoundingBox. More... | |
| core::Dtype | GetDtype () const |
| Returns the data type attribute of this OrientedBoundingBox. More... | |
| OrientedBoundingBox | To (const core::Device &device, bool copy=false) const |
| OrientedBoundingBox | Clone () const |
| Returns copy of the OrientedBoundingBox on the same device. More... | |
| OrientedBoundingBox & | Clear () override |
| Clear all elements in the geometry. More... | |
| bool | IsEmpty () const override |
| Returns true iff the geometry is empty. More... | |
| void | SetCenter (const core::Tensor ¢er) |
| Set the center 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 | SetRotation (const core::Tensor &rotation) |
| Set the rotation matrix 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 | SetExtent (const core::Tensor &extent) |
| Set the extent 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. More... | |
| core::Tensor | GetMinBound () const |
| core::Tensor | GetMaxBound () const |
| core::Tensor | GetColor () const |
| core::Tensor | GetCenter () const |
| core::Tensor | GetRotation () const |
| core::Tensor | GetExtent () const |
| OrientedBoundingBox & | Translate (const core::Tensor &translation, bool relative=true) |
| Translate the oriented box by the given translation. If relative is true, the translation is added to the center of the box. If false, the center will be assigned to the translation. More... | |
| OrientedBoundingBox & | Rotate (const core::Tensor &rotation, const utility::optional< core::Tensor > ¢er=utility::nullopt) |
| Rotate the oriented box by the given rotation matrix. If the rotation matrix is not orthogonal, the rotation will no be applied. The rotation center will be the box center if it is not specified. More... | |
| OrientedBoundingBox & | Transform (const core::Tensor &transformation) |
| Transform the oriented box by the given transformation matrix. More... | |
| OrientedBoundingBox & | 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... | |
| 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::OrientedBoundingBox | ToLegacy () const |
| Convert to a legacy CloudViewer oriented box. More... | |
| AxisAlignedBoundingBox | GetAxisAlignedBoundingBox () const |
| Convert to an axis-aligned 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 OrientedBoundingBox | CreateFromAxisAlignedBoundingBox (const AxisAlignedBoundingBox &aabb) |
| static OrientedBoundingBox | FromLegacy (const cloudViewer::geometry::OrientedBoundingBox &box, const core::Dtype &dtype=core::Float32, const core::Device &device=core::Device("CPU:0")) |
| static OrientedBoundingBox | CreateFromPoints (const core::Tensor &points, bool robust=false, MethodOBBCreate method=MethodOBBCreate::MINIMAL_APPROX) |
Protected Attributes | |
| core::Device | device_ = core::Device("CPU:0") |
| core::Dtype | dtype_ = core::Float32 |
| core::Tensor | center_ |
| core::Tensor | rotation_ |
| core::Tensor | extent_ |
| core::Tensor | color_ |
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 oriented along an arbitrary frame of reference.
| cloudViewer::t::geometry::OrientedBoundingBox::OrientedBoundingBox | ( | const core::Device & | device = core::Device("CPU:0") | ) |
Construct an empty OrientedBoundingBox on the provided device.
Referenced by CreateFromPoints().
| cloudViewer::t::geometry::OrientedBoundingBox::OrientedBoundingBox | ( | const core::Tensor & | center, |
| const core::Tensor & | rotation, | ||
| const core::Tensor & | extent | ||
| ) |
Construct an OrientedBoundingBox from center, rotation and extent.
The OrientedBoundingBox will be created on the device of the given tensors, which must be on the same device and have the same data type.
| center | Center of the bounding box. Tensor of shape {3,}, and type float32 or float64. |
| rotation | Rotation matrix of the bounding box. Tensor of shape {3, 3}, and type float32 or float64. |
| extent | Extent of the bounding box. Tensor of shape {3,}, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtype, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, cloudViewer::core::Tensor::GetDevice(), cloudViewer::core::Tensor::GetDtype(), and rotation.
|
inlineoverridevirtual |
|
overridevirtual |
Clear all elements in the geometry.
Implements cloudViewer::t::geometry::Geometry.
References center_, color_, extent_, cloudViewer::core::Tensor::Eye(), GetDevice(), GetDtype(), cloudViewer::core::Tensor::Ones(), rotation_, and cloudViewer::core::Tensor::Zeros().
|
inline |
Returns copy of the OrientedBoundingBox on the same device.
References GetDevice(), and To().
|
static |
Create an oriented bounding box from the AxisAlignedBoundingBox.
| aabb | AxisAlignedBoundingBox object from which OrientedBoundingBox is created. |
References cloudViewer::core::Tensor::Eye(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetCenter(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetDevice(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetDtype(), and cloudViewer::t::geometry::AxisAlignedBoundingBox::GetExtent().
Referenced by cloudViewer::t::geometry::AxisAlignedBoundingBox::GetOrientedBoundingBox().
|
static |
Creates an oriented bounding box with various algorithms.
| points | A list of points with data type of float32 or float64 (N x 3 tensor, where N must be larger than 3). |
| robust | If set to true uses a more robust method which works in degenerate cases but introduces noise to the points coordinates. |
| method | This is one of PCA, MINIMAL_APPROX, MINIMAL_JYLANKI in the cloudViewer::t::geometry::MethodOBBCreate namespace.
|
References AssertTensorDtypes, AssertTensorShape, cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBJylanki(), ecvOrientedBBox::CreateFromPoints(), cloudViewer::core::Float32, cloudViewer::core::Float64, FromLegacy(), LogError, cloudViewer::t::geometry::MINIMAL_APPROX, cloudViewer::t::geometry::MINIMAL_JYLANKI, cloudViewer::utility::nullopt, OrientedBoundingBox(), cloudViewer::t::geometry::PCA, points, and cloudViewer::core::eigen_converter::TensorToEigenVector3dVector().
Referenced by cloudViewer::t::geometry::LineSet::GetOrientedBoundingBox(), cloudViewer::t::geometry::PointCloud::GetOrientedBoundingBox(), and cloudViewer::t::geometry::TriangleMesh::GetOrientedBoundingBox().
|
static |
Create an OrientedBoundingBox from a legacy CloudViewer oriented box.
| box | Legacy OrientedBoundingBox. |
| 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::OrientedBoundingBox::GetColor(), cloudViewer::OrientedBoundingBox::GetExtent(), cloudViewer::OrientedBoundingBox::GetPosition(), cloudViewer::OrientedBoundingBox::GetRotation(), LogError, SetColor(), cloudViewer::core::Tensor::To(), and cloudViewer::core::Dtype::ToString().
Referenced by CreateFromPoints().
| AxisAlignedBoundingBox cloudViewer::t::geometry::OrientedBoundingBox::GetAxisAlignedBoundingBox | ( | ) | const |
Convert to an axis-aligned box.
References cloudViewer::t::geometry::AxisAlignedBoundingBox::CreateFromPoints(), and GetBoxPoints().
| core::Tensor cloudViewer::t::geometry::OrientedBoundingBox::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.
/// ------- x /// /| /// / | /// / | z /// y /// 0 ------------------- 1 /// /| /| /// / | / | /// / | / | /// / | / | /// 2 ------------------- 7 | /// | |____________|____| 6 /// | /3 | / /// | / | / /// | / | / /// |/ |/ /// 5 ------------------- 4 ///
References cloudViewer::core::Tensor::Add(), cloudViewer::t::geometry::AxisAlignedBoundingBox::GetBoxPoints(), GetCenter(), GetExtent(), GetRotation(), and cloudViewer::core::Tensor::Matmul().
Referenced by GetAxisAlignedBoundingBox(), GetMaxBound(), and GetMinBound().
|
inline |
References center_.
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), GetBoxPoints(), and ToLegacy().
|
inline |
References color_.
Referenced by ToLegacy().
|
inlineoverridevirtual |
Returns the device attribute of this OrientedBoundingBox.
Implements cloudViewer::t::geometry::Geometry.
References device_.
Referenced by Clear(), Clone(), cloudViewer::t::geometry::PointCloud::Crop(), GetPointIndicesWithinBoundingBox(), Rotate(), Scale(), SetCenter(), SetColor(), SetExtent(), SetRotation(), To(), ToString(), Transform(), and Translate().
|
inline |
Returns the data type attribute of this OrientedBoundingBox.
References dtype_.
Referenced by Clear(), Rotate(), Scale(), SetCenter(), SetColor(), SetExtent(), SetRotation(), ToString(), Transform(), and Translate().
|
inline |
References extent_.
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), GetBoxPoints(), ToLegacy(), and Volume().
| core::Tensor cloudViewer::t::geometry::OrientedBoundingBox::GetMaxBound | ( | ) | const |
References GetBoxPoints(), and cloudViewer::core::Tensor::Max().
| core::Tensor cloudViewer::t::geometry::OrientedBoundingBox::GetMinBound | ( | ) | const |
References GetBoxPoints(), and cloudViewer::core::Tensor::Min().
| core::Tensor cloudViewer::t::geometry::OrientedBoundingBox::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, center_, extent_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), cloudViewer::t::geometry::kernel::pointcloud::GetPointMaskWithinOBB(), cloudViewer::utility::nullopt, points, rotation_, cloudViewer::core::Tensor::To(), and cloudViewer::core::Tensor::Zeros().
Referenced by cloudViewer::t::geometry::PointCloud::Crop().
|
inline |
References rotation_.
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), GetBoxPoints(), and ToLegacy().
|
inlineoverridevirtual |
Returns true iff the geometry is empty.
Implements cloudViewer::t::geometry::Geometry.
References Volume().
Referenced by cloudViewer::t::geometry::PointCloud::Crop().
| OrientedBoundingBox & cloudViewer::t::geometry::OrientedBoundingBox::Rotate | ( | const core::Tensor & | rotation, |
| const utility::optional< core::Tensor > & | center = utility::nullopt |
||
| ) |
Rotate the oriented box by the given rotation matrix. If the rotation matrix is not orthogonal, the rotation will no be applied. The rotation center will be the box center if it is not specified.
| rotation | Rotation matrix of shape {3, 3}, type float32 or float64, device same as the box. |
| center | Center of the rotation, default is null, which means use center of the box as rotation center. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, center_, e, cloudViewer::core::Tensor::Flatten(), cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), cloudViewer::utility::optional< T >::has_value(), LogWarning, cloudViewer::core::Tensor::Matmul(), rotation, rotation_, and cloudViewer::utility::optional< T >::value().
Referenced by cloudViewer::t::geometry::kernel::minimum_obb::ComputeMinimumOBBApprox(), and Transform().
| OrientedBoundingBox & cloudViewer::t::geometry::OrientedBoundingBox::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, center_, extent_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), cloudViewer::utility::optional< T >::has_value(), cloudViewer::core::Tensor::To(), and cloudViewer::utility::optional< T >::value().
| void cloudViewer::t::geometry::OrientedBoundingBox::SetCenter | ( | const core::Tensor & | center | ) |
Set the center of the box. If the data type of the given tensor differs from the data type of the box, an exception will be thrown.
| center | Tensor with {3,} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, center_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), and cloudViewer::core::Tensor::To().
Referenced by To().
| void cloudViewer::t::geometry::OrientedBoundingBox::SetColor | ( | const core::Tensor & | color | ) |
Set the color of the box.
| 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::OrientedBoundingBox::SetExtent | ( | const core::Tensor & | extent | ) |
Set the extent of the box. If the data type of the given tensor differs from the data type of the box, an exception will be thrown.
| extent | Tensor with {3,} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, extent_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), cloudViewer::core::Tensor::Item(), LogError, cloudViewer::core::Tensor::Min(), and cloudViewer::core::Tensor::To().
Referenced by To().
| void cloudViewer::t::geometry::OrientedBoundingBox::SetRotation | ( | const core::Tensor & | rotation | ) |
Set the rotation matrix of the box. If the data type of the given tensor differs from the data type of the box, an exception will be thrown.
| rotation | Tensor with {3, 3} shape, and type float32 or float64. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, e, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), LogWarning, rotation, and rotation_.
Referenced by To().
| OrientedBoundingBox cloudViewer::t::geometry::OrientedBoundingBox::To | ( | const core::Device & | device, |
| bool | copy = false |
||
| ) | const |
Transfer the OrientedBoundingBox to a specified device.
| device | The targeted device to convert to. |
| copy | If true, a new OrientedBoundingBox is always created; if false, the copy is avoided when the original OrientedBoundingBox is already on the targeted device. |
References center_, color_, copy, extent_, GetDevice(), rotation_, SetCenter(), SetColor(), SetExtent(), SetRotation(), and cloudViewer::core::Tensor::To().
| cloudViewer::geometry::OrientedBoundingBox cloudViewer::t::geometry::OrientedBoundingBox::ToLegacy | ( | ) | const |
Convert to a legacy CloudViewer oriented box.
References GetCenter(), GetColor(), GetExtent(), GetRotation(), cloudViewer::OrientedBoundingBox::SetColor(), cloudViewer::core::eigen_converter::TensorToEigenMatrixXd(), and cloudViewer::core::eigen_converter::TensorToEigenVector3dVector().
| std::string cloudViewer::t::geometry::OrientedBoundingBox::ToString | ( | ) | const |
Text description.
References format, GetDevice(), and GetDtype().
| OrientedBoundingBox & cloudViewer::t::geometry::OrientedBoundingBox::Transform | ( | const core::Tensor & | transformation | ) |
Transform the oriented box by the given transformation matrix.
| transformation | Transformation matrix of shape {4, 4}, type float32 or float64, device same as the box. |
References AssertTensorDevice, AssertTensorDtypes, AssertTensorShape, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), cloudViewer::core::TensorKey::Index(), Rotate(), cloudViewer::core::TensorKey::Slice(), cloudViewer::core::Tensor::To(), and Translate().
| OrientedBoundingBox & cloudViewer::t::geometry::OrientedBoundingBox::Translate | ( | const core::Tensor & | translation, |
| bool | relative = true |
||
| ) |
Translate the oriented box by the given translation. If relative is true, the translation is added to the center of the box. If false, the center will be assigned to the 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, center_, cloudViewer::core::Float32, cloudViewer::core::Float64, GetDevice(), GetDtype(), and cloudViewer::core::Tensor::To().
Referenced by Transform().
|
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(), and IsEmpty().
|
protected |
Referenced by Clear(), GetCenter(), GetPointIndicesWithinBoundingBox(), Rotate(), Scale(), SetCenter(), To(), and Translate().
|
protected |
Referenced by Clear(), GetColor(), SetColor(), and To().
|
protected |
Referenced by GetDevice().
|
protected |
Referenced by GetDtype().
|
protected |
Referenced by Clear(), GetExtent(), GetPointIndicesWithinBoundingBox(), Scale(), SetExtent(), and To().
|
protected |
Referenced by Clear(), GetPointIndicesWithinBoundingBox(), GetRotation(), Rotate(), SetRotation(), and To().