ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
OrientedBoundingBox.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "BoundingBox.h"
12 #include "CVGeom.h"
13 #include "Eigen.h"
14 
15 namespace cloudViewer {
23 public:
28  : center_(0, 0, 0),
29  R_(Eigen::Matrix3d::Identity()),
30  extent_(0, 0, 0),
31  color_(0, 0, 0) {}
38  OrientedBoundingBox(const Eigen::Vector3d& center,
39  const Eigen::Matrix3d& R,
40  const Eigen::Vector3d& extent)
41  : center_(center), R_(R), extent_(extent), color_(0, 0, 0) {}
42  virtual ~OrientedBoundingBox() {}
43 
44 public:
45  OrientedBoundingBox& Clear();
46 
49  inline const Eigen::Vector3d& GetExtent() const { return extent_; }
50 
52  inline CCVector3 getCenter() const { return center_; }
53 
55  Eigen::Vector3d GetHalfExtent() const { return GetExtent() * 0.5; }
56 
58  inline double GetMaxExtent() const { return extent_.maxCoeff(); }
59 
61  inline void SetColor(const Eigen::Vector3d& color) { color_ = color; }
63  inline const Eigen::Vector3d& GetColor() const { return color_; }
64 
65  inline const Eigen::Matrix3d& GetRotation() const { return R_; }
66 
67  inline const Eigen::Vector3d& GetPosition() const { return center_; }
68 
70  double volume() const;
71 
92  std::vector<Eigen::Vector3d> GetBoxPoints() const;
93 
95  std::vector<size_t> GetPointIndicesWithinBoundingBox(
96  const std::vector<Eigen::Vector3d>& points) const;
97 
98  std::vector<size_t> GetPointIndicesWithinBoundingBox(
99  const std::vector<CCVector3>& points) const;
100 
105  static OrientedBoundingBox CreateFromAxisAlignedBoundingBox(
106  const BoundingBox& aabox);
107 
108 public:
110  Eigen::Vector3d center_;
113  Eigen::Matrix3d R_;
115  Eigen::Vector3d extent_;
117  Eigen::Vector3d color_;
118 };
119 
120 } // namespace cloudViewer
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
Eigen
Definition: Eigen.h:103
Eigen.h
R_
Eigen::Matrix3d R_
Definition: MinimumOBB.cpp:49
cloudViewer::OrientedBoundingBox::R_
Eigen::Matrix3d R_
Definition: OrientedBoundingBox.h:113
cloudViewer::OrientedBoundingBox::GetMaxExtent
double GetMaxExtent() const
Returns the max extent of the bounding box in its frame of reference.
Definition: OrientedBoundingBox.h:58
color
math::float4 color
Definition: LineSetBuffers.cpp:46
cloudViewer::OrientedBoundingBox
A bounding box oriented along an arbitrary frame of reference.
Definition: OrientedBoundingBox.h:22
cloudViewer::OrientedBoundingBox::GetColor
const Eigen::Vector3d & GetColor() const
Gets the bounding box color.
Definition: OrientedBoundingBox.h:63
Vector3Tpl< PointCoordinateType >
extent_
Eigen::Vector3d extent_
Definition: MinimumOBB.cpp:50
cloudViewer::OrientedBoundingBox::GetPosition
const Eigen::Vector3d & GetPosition() const
Definition: OrientedBoundingBox.h:67
CVGeom.h
cloudViewer::OrientedBoundingBox::SetColor
void SetColor(const Eigen::Vector3d &color)
Sets the bounding box color.
Definition: OrientedBoundingBox.h:61
cloudViewer::OrientedBoundingBox::color_
Eigen::Vector3d color_
The color of the bounding box in RGB.
Definition: OrientedBoundingBox.h:117
points
int points
Definition: FileIOFactory.cpp:144
cloudViewer::OrientedBoundingBox::OrientedBoundingBox
OrientedBoundingBox(const Eigen::Vector3d &center, const Eigen::Matrix3d &R, const Eigen::Vector3d &extent)
Parameterized constructor.
Definition: OrientedBoundingBox.h:38
center_
Eigen::Vector3d center_
Definition: MinimumOBB.cpp:51
cloudViewer::OrientedBoundingBox::GetRotation
const Eigen::Matrix3d & GetRotation() const
Definition: OrientedBoundingBox.h:65
cloudViewer::OrientedBoundingBox::~OrientedBoundingBox
virtual ~OrientedBoundingBox()
Definition: OrientedBoundingBox.h:42
cloudViewer::OrientedBoundingBox::extent_
Eigen::Vector3d extent_
The extent of the bounding box in its frame of reference.
Definition: OrientedBoundingBox.h:115
cloudViewer::BoundingBoxTpl< PointCoordinateType >
cloudViewer::OrientedBoundingBox::getCenter
CCVector3 getCenter() const
Returns center.
Definition: OrientedBoundingBox.h:52
cloudViewer::OrientedBoundingBox::center_
Eigen::Vector3d center_
The center point of the bounding box.
Definition: OrientedBoundingBox.h:110
cloudViewer::OrientedBoundingBox::GetHalfExtent
Eigen::Vector3d GetHalfExtent() const
Returns the half extent of the bounding box in its frame of reference.
Definition: OrientedBoundingBox.h:55
cloudViewer::OrientedBoundingBox::OrientedBoundingBox
OrientedBoundingBox()
Default constructor.
Definition: OrientedBoundingBox.h:27
cloudViewer::OrientedBoundingBox::GetExtent
const Eigen::Vector3d & GetExtent() const
Definition: OrientedBoundingBox.h:49
CV_CORE_LIB_API
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
BoundingBox.h