V-ART
boundingbox.h
Go to the documentation of this file.
1 
5 #ifndef VART_BOUNDINGBOX_H
6 #define VART_BOUNDINGBOX_H
7 
8 #include "vart/point4d.h"
9 #include "vart/color.h"
10 #include <GL/glut.h>
11 #include <iostream>
12 
17 namespace VART {
18  class Transform;
23  class BoundingBox {
25  // FixMe: Perhaps this will cause trouble on an application with no console...
26  friend std::ostream& operator<<(std::ostream& output, const BoundingBox& box);
27  public:
29  BoundingBox();
30  BoundingBox(double minX, double minY, double minZ,
31  double maxX, double maxY, double maxZ);
32  BoundingBox(const BoundingBox& box);
33 
34  BoundingBox& operator=(const BoundingBox& box);
35  void ProcessCenter();
36 
39  void ApplyTransform(const Transform& trans);
40 
41  double GetGreaterX() const;
42  double GetGreaterY() const;
43  double GetGreaterZ() const;
44 
46  double GetGreaterEdge() const;
48  double GetSmallerEdge() const;
50  double GetEdgeX() const { return greaterX-smallerX; }
52  double GetEdgeY() const { return greaterY-smallerY; }
54  double GetEdgeZ() const { return greaterZ-smallerZ; }
55 
56  void SetGreaterX(double v);
57  void SetGreaterY(double v);
58  void SetGreaterZ(double v);
59 
60  double GetSmallerX() const;
61  double GetSmallerY() const;
62  double GetSmallerZ() const;
63 
64  void SetSmallerX(double v);
65  void SetSmallerY(double v);
66  void SetSmallerZ(double v);
67 
68  void SetBoundingBox(double minX, double minY, double minZ,
69  double maxX, double maxY, double maxZ);
70 
71  const Point4D& GetCenter() const;
72 
74  void ConditionalUpdate(double x, double y, double z);
76  void ConditionalUpdate(const Point4D& point);
77 
79  void MergeWith(const BoundingBox& box);
81  bool DrawInstanceOGL() const;
83  void SetVisibility(const bool value) { visible = value; };
85  void ToggleVisibility();
87  bool testAABBAABB(BoundingBox &b);
89  bool testPoint( VART::Point4D p );
91  bool visible;
93  void SetColor(const Color& value) { color = value; }
95  void CopyGeometryFrom(const BoundingBox& box);
97  void CutBBox( const BoundingBox& box );
98  private:
99  double greaterX, greaterY, greaterZ;
100  double smallerX, smallerY, smallerZ;
101  Point4D center;
102  Color color;
103  }; // end class declaration
104 } // end namespace
105 #endif // VART_BOUNDINGBOX_H
bool DrawInstanceOGL() const
Draws a bounding box.
BoundingBox()
Creates an uninitialized bounding box.
Definition: boundingbox.cpp:10
Points and vectors using homogeneous coordinates.
Definition: point4d.h:22
bool visible
Indicates wether the bounding box is visible.
Definition: boundingbox.h:91
void CutBBox(const BoundingBox &box)
Test against other bounding box and update itself if its outside the given bbox.
void SetBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ)
void ConditionalUpdate(double x, double y, double z)
Updates the bounding box if any given coordinate is outside it.
void CopyGeometryFrom(const BoundingBox &box)
Copies geometry data from other bounding box.
Definition: boundingbox.cpp:53
void MergeWith(const BoundingBox &box)
Merges a bounding with another, expanding it.
RGBA color representation.
Definition: color.h:24
Axis aligned bounding box.
Definition: boundingbox.h:23
BoundingBox & operator=(const BoundingBox &box)
Definition: boundingbox.cpp:40
void SetColor(const Color &value)
Sets the bounding box color.
Definition: boundingbox.h:93
double GetGreaterZ() const
Definition: boundingbox.cpp:93
double GetSmallerX() const
bool testPoint(VART::Point4D p)
Test if a point is included in the bbox.
Geometric transformations.
Definition: transform.h:24
double GetEdgeY() const
Returns the length of the Y edge.
Definition: boundingbox.h:52
double GetEdgeZ() const
Returns the length of the Z edge.
Definition: boundingbox.h:54
double GetSmallerY() const
void SetGreaterY(double v)
double GetGreaterY() const
Definition: boundingbox.cpp:89
Header file for V-ART class "Color".
void ToggleVisibility()
Toggles the visibility.
double GetSmallerEdge() const
Returns the length of the smaller edge.
void SetSmallerZ(double v)
void SetGreaterX(double v)
Definition: boundingbox.cpp:97
void SetVisibility(const bool value)
Sets the bounding box visibility.
Definition: boundingbox.h:83
double GetEdgeX() const
Returns the length of the X edge.
Definition: boundingbox.h:50
const Point4D & GetCenter() const
void ApplyTransform(const Transform &trans)
Applies transformation to a BoundingBox.
Definition: boundingbox.cpp:70
double GetGreaterEdge() const
Returns the length of the greater edge.
Header file for V-ART class "Point4D".
bool testAABBAABB(BoundingBox &b)
Test intersection among AABBs.
friend std::ostream & operator<<(std::ostream &output, const BoundingBox &box)
Output operator.
void SetSmallerX(double v)
void SetSmallerY(double v)
double GetGreaterX() const
Definition: boundingbox.cpp:85
void SetGreaterZ(double v)
double GetSmallerZ() const