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 
67  void draw(CC_DRAW_CONTEXT& context, const ecvColor::Rgb& col);
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 
77  virtual ecvOrientedBBox& Transform(
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 
87  const ecvOrientedBBox operator*(const ccGLMatrix& mat);
89  const ecvOrientedBBox operator*(const ccGLMatrixd& mat);
90 
96  static ecvOrientedBBox CreateFromPoints(
97  const std::vector<Eigen::Vector3d>& points);
98  static ecvOrientedBBox CreateFromPoints(
99  const std::vector<CCVector3>& points);
100 
102  const ccBBox& aabox);
103 };
Vector3Tpl< float > operator*(float s, const Vector3Tpl< float > &v)
Multiplication of a 3D vector by a scalar (front) operator (float version)
Definition: CVGeom.h:789
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
virtual ecvOrientedBBox GetOrientedBoundingBox() const
Definition: ecvHObject.cpp:449
virtual ccHObject & Scale(const double s, const Eigen::Vector3d &center)
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
Definition: ecvHObject.h:176
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
virtual Eigen::Vector3d GetCenter() const
Returns the center of the geometry coordinates.
Definition: ecvHObject.h:150
virtual ccHObject & Translate(const Eigen::Vector3d &translation, bool relative=true)
Apply translation to the geometry coordinates.
Definition: ecvHObject.h:165
virtual ccHObject & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center)
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
Definition: ecvHObject.h:186
virtual Eigen::Vector3d GetMaxBound() const
Returns max bounds for geometry coordinates.
Definition: ecvHObject.h:147
virtual Eigen::Vector3d GetMinBound() const
Returns min bounds for geometry coordinates.
Definition: ecvHObject.h:144
virtual ccHObject & Transform(const Eigen::Matrix4d &transformation)
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: ecvHObject.h:157
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
Definition: ecvHObject.cpp:757
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
Definition: ecvHObject.cpp:447
A bounding box oriented along an arbitrary frame of reference.
static OrientedBoundingBox CreateFromAxisAlignedBoundingBox(const BoundingBox &aabox)
double volume() const
Returns the volume of the bounding box.
RGB color structure.
Definition: ecvColorTypes.h:49
virtual bool IsEmpty() const override
~ecvOrientedBBox() override
virtual bool isSerializable() const override
Returns whether object is serializable of not.
virtual CV_CLASS_ENUM getClassID() const override
Returns unique class ID.
ecvOrientedBBox()
Default constructor.
ecvOrientedBBox(const Eigen::Vector3d &center, const Eigen::Matrix3d &R, const Eigen::Vector3d &extent, const std::string &name="ecvOrientedBBox")
Parameterized constructor.
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.