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
#define CV_CORE_LIB_API
Definition: CVCoreLibWin.h:15
int points
math::float4 color
Eigen::Matrix3d R_
Definition: MinimumOBB.cpp:49
Eigen::Vector3d center_
Definition: MinimumOBB.cpp:51
Eigen::Vector3d extent_
Definition: MinimumOBB.cpp:50
A bounding box oriented along an arbitrary frame of reference.
Eigen::Vector3d color_
The color of the bounding box in RGB.
Eigen::Vector3d GetHalfExtent() const
Returns the half extent of the bounding box in its frame of reference.
Eigen::Vector3d extent_
The extent of the bounding box in its frame of reference.
const Eigen::Vector3d & GetExtent() const
OrientedBoundingBox()
Default constructor.
const Eigen::Vector3d & GetPosition() const
Eigen::Vector3d center_
The center point of the bounding box.
CCVector3 getCenter() const
Returns center.
OrientedBoundingBox(const Eigen::Vector3d &center, const Eigen::Matrix3d &R, const Eigen::Vector3d &extent)
Parameterized constructor.
const Eigen::Matrix3d & GetRotation() const
const Eigen::Vector3d & GetColor() const
Gets the bounding box color.
double GetMaxExtent() const
Returns the max extent of the bounding box in its frame of reference.
void SetColor(const Eigen::Vector3d &color)
Sets the bounding box color.
Definition: Eigen.h:103
Generic file read and write utility for python interface.