ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvOrientedBBox.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 "CV_db.h"
12 #include "ecvColorTypes.h"
13 #include "ecvDrawableObject.h"
14 #include "ecvHObject.h"
15 
16 // CV_CORE_LIB
17 #include <OrientedBoundingBox.h>
18 
19 #ifdef USE_EIGEN
20 #endif // USE_EIGEN
21 #include <Eigen/Core>
22 
24 
27 class ccGLMatrix;
28 class ccGLMatrixd;
30  public ccHObject {
31 public:
34  : cloudViewer::OrientedBoundingBox(), ccHObject("ecvOrientedBBox") {}
35 
42  ecvOrientedBBox(const Eigen::Vector3d& center,
43  const Eigen::Matrix3d& R,
44  const Eigen::Vector3d& extent,
45  const std::string& name = "ecvOrientedBBox")
46  : cloudViewer::OrientedBoundingBox(center, R, extent),
47  ccHObject(name.c_str()) {}
48 
49  ~ecvOrientedBBox() override {}
50 
51  // inherited methods (ccHObject)
52  virtual bool isSerializable() const override { return true; }
54  virtual CV_CLASS_ENUM getClassID() const override {
56  }
57  // Returns the entity's own bounding-box
58  virtual ccBBox getOwnBB(bool withGLFeatures = false) override;
59 
60  // Inherited from ccHObject - override to avoid hiding base class method
61  void draw(CC_DRAW_CONTEXT& context) override;
62 
64 
68 
69  inline virtual bool IsEmpty() const override { return volume() <= 0; }
70  virtual Eigen::Vector3d GetMinBound() const override;
71  virtual Eigen::Vector3d GetMaxBound() const override;
72  virtual Eigen::Vector3d GetCenter() const override;
73 
74  virtual ccBBox GetAxisAlignedBoundingBox() const override;
75  virtual ecvOrientedBBox GetOrientedBoundingBox() const override;
76 
78  const Eigen::Matrix4d& transformation) override;
79  virtual ecvOrientedBBox& Translate(const Eigen::Vector3d& translation,
80  bool relative = true) override;
81  virtual ecvOrientedBBox& Scale(const double scale,
82  const Eigen::Vector3d& center) override;
83  virtual ecvOrientedBBox& Rotate(const Eigen::Matrix3d& R,
84  const Eigen::Vector3d& center) override;
85 
90 
97  const std::vector<Eigen::Vector3d>& points);
99  const std::vector<CCVector3>& points);
100 
102  const ccBBox& aabox);
103 };
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
#define CV_DB_LIB_API
Definition: CV_db.h:15
std::string name
int points
Bounding box structure.
Definition: ecvBBox.h:25
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
A bounding box oriented along an arbitrary frame of reference.
double volume() const
Returns the volume of the bounding box.
RGB color structure.
Definition: ecvColorTypes.h:49
virtual ccBBox GetAxisAlignedBoundingBox() const override
Returns an axis-aligned bounding box of the geometry.
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
virtual bool IsEmpty() const override
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
virtual ecvOrientedBBox & Scale(const double scale, const Eigen::Vector3d &center) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
~ecvOrientedBBox() override
virtual bool isSerializable() const override
Returns whether object is serializable of not.
virtual ecvOrientedBBox & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
virtual CV_CLASS_ENUM getClassID() const override
Returns unique class ID.
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
const ecvOrientedBBox operator*(const ccGLMatrix &mat)
Applies transformation to the bounding box.
static ecvOrientedBBox CreateFromPoints(const std::vector< Eigen::Vector3d > &points)
static ecvOrientedBBox CreateFromAxisAlignedBoundingBox(const ccBBox &aabox)
const ecvOrientedBBox operator*(const ccGLMatrixd &mat)
Applies transformation to the bounding box.
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
ecvOrientedBBox()
Default constructor.
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
void draw(CC_DRAW_CONTEXT &context, const ecvColor::Rgb &col)
Draws oriented bounding box (OpenGL)
virtual ccBBox getOwnBB(bool withGLFeatures=false) override
Returns the entity's own bounding-box.
static ecvOrientedBBox CreateFromPoints(const std::vector< CCVector3 > &points)
virtual ecvOrientedBBox & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
ecvOrientedBBox(const Eigen::Vector3d &center, const Eigen::Matrix3d &R, const Eigen::Vector3d &extent, const std::string &name="ecvOrientedBBox")
Parameterized constructor.
virtual ecvOrientedBBox & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
ImGuiContext * context
Definition: Window.cpp:76
@ ORIENTED_BBOX
Definition: CVTypes.h:155
::ecvOrientedBBox OrientedBoundingBox
Generic file read and write utility for python interface.
Display context.