Overture  Version 25
BoundingBox.h
Go to the documentation of this file.
1 #ifndef BOUNDING_BOX_H
2 #define BOUNDING_BOX_H "BoundingBox.h"
3 
4 #include "GenericDataBase.h"
5 #include "wdhdefs.h"
6 #include "aString.H" // Livermore aString Library
7 // include "tlist.h"
8 
9 class ListOfBoundingBox; // forward declaration
10 
11 // This class defines a bounding box for a portion of a grid. This
12 // bounding box is normally put into a binary tree so it has
13 // pointers to a parent and two children.
14 //
15 // domain : is index space, domain bounds are int's
16 // range : is cartesian space, range bounds are real's
17 
19 {
20 public:
24 
25 
26  BoundingBox( const int domainDimension=3, const int rangeDimension=3 );
27  ~BoundingBox();
28 
29  inline int& domainBound(int side,int axis) { return domain[side][axis]; }
30  inline real& rangeBound(int side,int axis) { return range[side][axis]; }
31 
32  inline int domainBound(int side,int axis) const { return domain[side][axis]; }
33  inline real rangeBound(int side,int axis) const { return range[side][axis]; }
34 
35  // return the domain bounds
37  RealArray getRangeBound() const;
38 
39  int setDomainBound( const IntegerArray & db);
40  int setRangeBound( const RealArray & rb);
41 
42  int domainBoundEquals(const BoundingBox & b);
43  int rangeBoundEquals(const BoundingBox & b);
44 
45  inline bool isDefined() const {return defined;}
46  // It is up to the application to specify when the box is defined. The box is
47  // not defined when initially created.
48  void setIsDefined() {defined=TRUE;}
49 
50  void setDimensions( const int domainDimension=3, const int rangeDimension=3 );
51  void addChildren();
52  void deleteChildren();
53  void display( const aString & comment=nullString ) const;
54 
55  // does this box intersect another (in the range space).
56  bool intersects( const BoundingBox & box ) const;
57 
58  private:
59  int domainDimension;
60  int rangeDimension;
61 
62 
63  int defined; // true if domainBound and rangeBound have been assigned
64  int domain[2][3];
65  real range[2][3];
66 };
67 
68 
69 //
70 // This class holds a simple LIFO stack of bounding boxes.
71 //
73 {
74  public:
76 
78 
79  void push( BoundingBox & bb );
80 
81  BoundingBox& pop();
82 
83  int isEmpty() const;
84 
85  private:
86  int bottom,top;
87  ListOfBoundingBox *stack;
88 
89 };
90 
91 
92 #endif