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 };
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
ecvOrientedBBox::ecvOrientedBBox
ecvOrientedBBox()
Default constructor.
Definition: ecvOrientedBBox.h:33
CV_TYPES::ORIENTED_BBOX
@ ORIENTED_BBOX
Definition: CVTypes.h:155
ecvColorTypes.h
ecvOrientedBBox::isSerializable
virtual bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvOrientedBBox.h:52
ccGLMatrixd
Double version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:56
ccBBox
Bounding box structure.
Definition: ecvBBox.h:25
ccHObject::GetCenter
virtual Eigen::Vector3d GetCenter() const
Returns the center of the geometry coordinates.
Definition: ecvHObject.h:150
operator*
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
ccHObject::Rotate
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
ecvOrientedBBox::~ecvOrientedBBox
~ecvOrientedBBox() override
Definition: ecvOrientedBBox.h:49
cloudViewer::OrientedBoundingBox
A bounding box oriented along an arbitrary frame of reference.
Definition: OrientedBoundingBox.h:22
CV_CLASS_ENUM
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
context
ImGuiContext * context
Definition: Window.cpp:76
cloudViewer::OrientedBoundingBox::volume
double volume() const
Returns the volume of the bounding box.
Definition: OrientedBoundingBox.cpp:30
ccHObject::GetOrientedBoundingBox
virtual ecvOrientedBBox GetOrientedBoundingBox() const
Definition: ecvHObject.cpp:449
ecvOrientedBBox::IsEmpty
virtual bool IsEmpty() const override
Definition: ecvOrientedBBox.h:69
ccHObject::GetMaxBound
virtual Eigen::Vector3d GetMaxBound() const
Returns max bounds for geometry coordinates.
Definition: ecvHObject.h:147
ccHObject::Transform
virtual ccHObject & Transform(const Eigen::Matrix4d &transformation)
Apply transformation (4x4 matrix) to the geometry coordinates.
Definition: ecvHObject.h:157
points
int points
Definition: FileIOFactory.cpp:144
ecvDrawableObject.h
CV_db.h
ccHObject::draw
void draw(CC_DRAW_CONTEXT &context) override
Draws entity and its children.
Definition: ecvHObject.cpp:1438
ccGLMatrix
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
ccHObject::GetAxisAlignedBoundingBox
virtual ccBBox GetAxisAlignedBoundingBox() const
Returns an axis-aligned bounding box of the geometry.
Definition: ecvHObject.cpp:447
ecvColor::RgbTpl
RGB color structure.
Definition: ecvColorTypes.h:49
ccHObject::GetMinBound
virtual Eigen::Vector3d GetMinBound() const
Returns min bounds for geometry coordinates.
Definition: ecvHObject.h:144
ecvOrientedBBox
Definition: ecvOrientedBBox.h:29
ccHObject
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
ccHObject::getOwnBB
virtual ccBBox getOwnBB(bool withGLFeatures=false)
Returns the entity's own bounding-box.
Definition: ecvHObject.cpp:757
CV_DB_LIB_API
#define CV_DB_LIB_API
Definition: CV_db.h:15
ccGLDrawContext
Display context.
Definition: ecvDrawContext.h:365
ecvOrientedBBox::getClassID
virtual CV_CLASS_ENUM getClassID() const override
Returns unique class ID.
Definition: ecvOrientedBBox.h:54
cloudViewer::geometry::OrientedBoundingBox
::ecvOrientedBBox OrientedBoundingBox
Definition: BoundingVolume.h:22
ccHObject::Translate
virtual ccHObject & Translate(const Eigen::Vector3d &translation, bool relative=true)
Apply translation to the geometry coordinates.
Definition: ecvHObject.h:165
ccHObject::Scale
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
OrientedBoundingBox.h
ecvOrientedBBox::ecvOrientedBBox
ecvOrientedBBox(const Eigen::Vector3d &center, const Eigen::Matrix3d &R, const Eigen::Vector3d &extent, const std::string &name="ecvOrientedBBox")
Parameterized constructor.
Definition: ecvOrientedBBox.h:42
ecvHObject.h
cloudViewer::OrientedBoundingBox::CreateFromAxisAlignedBoundingBox
static OrientedBoundingBox CreateFromAxisAlignedBoundingBox(const BoundingBox &aabox)
Definition: OrientedBoundingBox.cpp:74
name
std::string name
Definition: FileIOFactory.cpp:129