Choreonoid  1.8
BoundingBox.h
Go to the documentation of this file.
1 
6 #ifndef CNOID_UTIL_BOUNDING_BOX_H
7 #define CNOID_UTIL_BOUNDING_BOX_H
8 
9 #include "EigenTypes.h"
10 #include <iosfwd>
11 #include "exportdecl.h"
12 
13 namespace cnoid {
14 
15 class BoundingBoxf;
16 
17 class CNOID_EXPORT BoundingBox
18 {
19 public:
20  BoundingBox();
21  BoundingBox(const Vector3& min, const Vector3& max);
22  BoundingBox(const BoundingBox& org);
23  BoundingBox(const BoundingBoxf& org);
24 
25  bool operator==(const BoundingBox& rhs) const {
26  return (min_ == rhs.min_) && (max_ == rhs.max_);
27  }
28  bool operator!=(const BoundingBox& rhs) const {
29  return !operator==(rhs);
30  }
31 
32  void set(const Vector3& min, const Vector3& max);
33  void clear();
34 
35  bool empty() const { return empty_; }
36  explicit operator bool() const { return !empty_; }
37  const Vector3& min() const { return min_; }
38  const Vector3& max() const { return max_; }
39  Vector3 center() const;
40  Vector3 size() const;
41  double boundingSphereRadius() const;
42 
43  void expandBy(const BoundingBox& bbox);
44  void expandBy(double x, double y, double z);
45  void expandBy(const Vector3& v){ expandBy(v.x(), v.y(), v.z()); }
46 
47  void transform(const Affine3& T);
48  void scale(double s);
49 
50 private:
51  Vector3 min_;
52  Vector3 max_;
53  bool empty_;
54 };
55 
56 CNOID_EXPORT std::ostream& operator<<(std::ostream& os, const BoundingBox& bb);
57 
61 class CNOID_EXPORT BoundingBoxf
62 {
63 public:
64  BoundingBoxf();
65  BoundingBoxf(const Vector3f& min, const Vector3f& max);
66  BoundingBoxf(const BoundingBoxf& org);
67  BoundingBoxf(const BoundingBox& org);
68 
69  bool operator==(const BoundingBoxf& rhs) const {
70  return (min_ == rhs.min_) && (max_ == rhs.max_);
71  }
72  bool operator!=(const BoundingBoxf& rhs) const {
73  return !operator==(rhs);
74  }
75 
76  void set(const Vector3f& min, const Vector3f& max);
77  void clear();
78 
79  bool empty() const { return empty_; }
80  explicit operator bool() const { return !empty_; }
81  const Vector3f& min() const { return min_; }
82  const Vector3f& max() const { return max_; }
83  Vector3f center() const;
84  Vector3f size() const;
85  float boundingSphereRadius() const;
86 
87  void expandBy(const BoundingBoxf& bbox);
88  void expandBy(const BoundingBox& bbox);
89  void expandBy(float x, float y, float z);
90  void expandBy(const Vector3f& v){ expandBy(v.x(), v.y(), v.z()); }
91 
92  void transform(const Affine3f& T);
93  void scale(float f);
94 
95 private:
96  bool empty_;
97  Vector3f min_;
98  Vector3f max_;
99 };
100 
101 CNOID_EXPORT std::ostream& operator<<(std::ostream& os, const BoundingBoxf& bb);
102 
103 }
104 
105 #endif
cnoid::BoundingBoxf::operator!=
bool operator!=(const BoundingBoxf &rhs) const
Definition: BoundingBox.h:72
cnoid::BoundingBox::min
const Vector3 & min() const
Definition: BoundingBox.h:37
cnoid::Vector3
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
cnoid::BoundingBoxf::expandBy
void expandBy(const Vector3f &v)
Definition: BoundingBox.h:90
cnoid::BoundingBoxf
Definition: BoundingBox.h:61
cnoid::operator<<
CNOID_EXPORT std::ostream & operator<<(std::ostream &os, const BoundingBox &bb)
Definition: BoundingBox.cpp:160
cnoid::BoundingBoxf::empty
bool empty() const
Definition: BoundingBox.h:79
cnoid::BoundingBox::max
const Vector3 & max() const
Definition: BoundingBox.h:38
cnoid::BoundingBox::empty
bool empty() const
Definition: BoundingBox.h:35
cnoid::BoundingBox::operator!=
bool operator!=(const BoundingBox &rhs) const
Definition: BoundingBox.h:28
cnoid
Definition: AbstractSceneLoader.h:11
cnoid::operator==
bool operator==(ref_ptr< T > const &a, ref_ptr< U > const &b)
Definition: Referenced.h:211
cnoid::BoundingBoxf::min
const Vector3f & min() const
Definition: BoundingBox.h:81
EigenTypes.h
cnoid::BoundingBoxf::max
const Vector3f & max() const
Definition: BoundingBox.h:82
cnoid::BoundingBox::operator==
bool operator==(const BoundingBox &rhs) const
Definition: BoundingBox.h:25
cnoid::BoundingBoxf::operator==
bool operator==(const BoundingBoxf &rhs) const
Definition: BoundingBox.h:69
cnoid::BoundingBox::expandBy
void expandBy(const Vector3 &v)
Definition: BoundingBox.h:45
cnoid::Affine3
Eigen::Affine3d Affine3
Definition: EigenTypes.h:62
cnoid::BoundingBox
Definition: BoundingBox.h:17