Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BoundingBox Class Reference

A concrete object that provides the functionality for representing a bounding box geometric primitive and associated operations such as bounding box intersection. More...

#include <BoundingBox.hpp>

Public Member Functions

void setCoordinates (const double x, const double y, const double z, const double X, const double Y, const double Z)
 Sets the coordinates of this BoundingBox instance. More...
 
 BoundingBox ()
 Default Constructor. More...
 
 BoundingBox (const double x, const double y, const double z, const double X, const double Y, const double Z)
 Custom Constructor. More...
 
 ~BoundingBox ()
 Destructor. More...
 
double getMinX ()
 
double getMinY ()
 
double getMinZ ()
 
double getMaxX ()
 
double getMaxY ()
 
double getMaxZ ()
 
bool hasPoint (const double x, const double y, const double z)
 Determines if a point is inside the bounding box. More...
 

Static Public Member Functions

static BoundingBox intersection (BoundingBox &b1, BoundingBox &b2)
 Computes the bounding box intersection between bounding box b1,b2. More...
 
static size_t Size ()
 Same as BoundingBox::getBytesize( ) but does not require a BoundingBox instance to be allocated. More...
 

Protected Attributes

double max [3]
 
double min [3]
 

Detailed Description

A concrete object that provides the functionality for representing a bounding box geometric primitive and associated operations such as bounding box intersection.

Author
George Zagaris (gzaga.nosp@m.ris@.nosp@m.illin.nosp@m.ois..nosp@m.edu)
Date
1/30/2009

Definition at line 21 of file BoundingBox.hpp.

Constructor & Destructor Documentation

BoundingBox ( )
inline

Default Constructor.

Constructs a 1x1x1 cube

Definition at line 116 of file BoundingBox.hpp.

Referenced by intersection().

117  {
118  this ->min[ 0 ] = 0.0;
119  this ->min[ 1 ] = 0.0;
120  this ->min[ 2 ] = 0.0;
121  this ->max[ 0 ] = 1.0;
122  this ->max[ 1 ] = 1.0;
123  this ->max[ 2 ] = 1.0;
124  }

Here is the caller graph for this function:

BoundingBox ( const double  x,
const double  y,
const double  z,
const double  X,
const double  Y,
const double  Z 
)
inline

Custom Constructor.

Parameters
xmin x of the bounding box
ymin y of the bounding box
zmin z of the bounding box
Xmax x of the bounding box
Ymax y of the bounding box
Zmax z of the bounding box

Definition at line 135 of file BoundingBox.hpp.

137  {
138  this ->setCoordinates( x,y,z, X,Y,Z );
139  }
void int int REAL REAL * y
Definition: read.cpp:74
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
~BoundingBox ( )
inline

Destructor.

Definition at line 144 of file BoundingBox.hpp.

145  {
146 
147  }

Member Function Documentation

double getMaxX ( )
inline
Returns
x max x

Definition at line 167 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

167 { return this ->max[ 0 ]; };

Here is the caller graph for this function:

double getMaxY ( )
inline
Returns
y max y

Definition at line 172 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

172 { return this ->max[ 1 ]; };

Here is the caller graph for this function:

double getMaxZ ( )
inline
Returns
z max z

Definition at line 177 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

177 { return this ->max[ 2 ]; };

Here is the caller graph for this function:

double getMinX ( )
inline
Returns
x min x

Definition at line 152 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

152 { return this ->min[ 0 ]; };

Here is the caller graph for this function:

double getMinY ( )
inline
Returns
y min y

Definition at line 157 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

157 { return this ->min[ 1 ]; };

Here is the caller graph for this function:

double getMinZ ( )
inline
Returns
z min z

Definition at line 162 of file BoundingBox.hpp.

Referenced by hasPoint(), and intersection().

162 { return this ->min[ 2 ]; };

Here is the caller graph for this function:

bool hasPoint ( const double  x,
const double  y,
const double  z 
)
inline

Determines if a point is inside the bounding box.

Parameters
xthe x-coordinate of the point in query.
ythe y-coordinate of the point in query.
zthe z-coordinate of the point in query.
Returns
status true if the point (x,y,z) is inside this instance of bounding box, else false.

Definition at line 187 of file BoundingBox.hpp.

References Numerics::fpointequals(), getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), and getMinZ().

188  {
189 
190  return(
191  ( x > this ->getMinX( ) || Numerics::fpointequals( x, this ->getMinX( ) ) ) &&
192  ( x < this ->getMaxX( ) || Numerics::fpointequals( x, this ->getMaxX( ) ) ) &&
193  ( y > this ->getMinY( ) || Numerics::fpointequals( y, this ->getMinY( ) ) ) &&
194  ( y < this ->getMaxY( ) || Numerics::fpointequals( y, this ->getMaxY( ) ) ) &&
195  ( z > this ->getMinZ( ) || Numerics::fpointequals( z, this ->getMinZ( ) ) ) &&
196  ( z < this ->getMaxZ( ) || Numerics::fpointequals( z, this ->getMaxZ( ) ) )
197  );
198 
199  }
double getMinX()
double getMinZ()
void int int REAL REAL * y
Definition: read.cpp:74
double getMaxZ()
double getMinY()
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74
double getMaxY()
double getMaxX()
bool fpointequals(const double a, const double b, double TOL=1e-9)
Checks if two floating numbers are &quot;nearly&quot; equal.

Here is the call graph for this function:

static BoundingBox intersection ( BoundingBox b1,
BoundingBox b2 
)
inlinestatic

Computes the bounding box intersection between bounding box b1,b2.

Parameters
b1the bounding box instance to intersect with bounding box b2.
b2the bounding box instance to intersect with bounding box b1.
Returns
c the bounding box intersection of b1,b2.

Definition at line 36 of file BoundingBox.hpp.

References BoundingBox(), getMaxX(), getMaxY(), getMaxZ(), getMinX(), getMinY(), getMinZ(), max, and min.

37  {
38  double min[3]; double max[3];
39 
40  std::vector< double > xaxis; xaxis.resize( 4 );
41  std::vector< double > yaxis; yaxis.resize( 4 );
42  std::vector< double > zaxis; zaxis.resize( 4 );
43 
44  xaxis[ 0 ] = b1.getMinX( );
45  xaxis[ 1 ] = b1.getMaxX( );
46  xaxis[ 2 ] = b2.getMinX( );
47  xaxis[ 3 ] = b2.getMaxX( );
48 
49  yaxis[ 0 ] = b1.getMinY( );
50  yaxis[ 1 ] = b1.getMaxY( );
51  yaxis[ 2 ] = b2.getMinY( );
52  yaxis[ 3 ] = b2.getMaxY( );
53 
54  zaxis[ 0 ] = b1.getMinZ( );
55  zaxis[ 1 ] = b1.getMaxZ( );
56  zaxis[ 2 ] = b2.getMinZ( );
57  zaxis[ 3 ] = b2.getMaxZ( );
58 
59  std::sort( xaxis.begin( ), xaxis.end( ) );
60  std::sort( yaxis.begin( ), yaxis.end( ) );
61  std::sort( zaxis.begin( ), zaxis.end( ) );
62 
63 
64  min[ 0 ] = xaxis[ 1 ];
65  max[ 0 ] = xaxis[ 2 ];
66 
67  min[ 1 ] = yaxis[ 1 ];
68  max[ 1 ] = yaxis[ 2 ];
69 
70  min[ 2 ] = zaxis[ 1 ];
71  max[ 2 ] = zaxis[ 2 ];
72 
73  xaxis.clear( );
74  yaxis.clear( );
75  zaxis.clear( );
76 
77  return ( BoundingBox( min[ 0 ], min[ 1 ], min[ 2 ],
78  max[ 0 ], max[ 1 ], max[ 2 ] ) );
79 
80  }
double getMinX()
double getMinZ()
double getMaxZ()
double getMinY()
BoundingBox()
Default Constructor.
double min[3]
Definition: BoundingBox.hpp:25
double getMaxY()
double getMaxX()
double max[3]
Definition: BoundingBox.hpp:24

Here is the call graph for this function:

void setCoordinates ( const double  x,
const double  y,
const double  z,
const double  X,
const double  Y,
const double  Z 
)
inline

Sets the coordinates of this BoundingBox instance.

Parameters
xmin x of the bounding box
ymin y of the bounding box
zmin z of the bounding box
Xmax x of the bounding box
Ymax y of the bounding box
Zmax z of the bounding box

Definition at line 101 of file BoundingBox.hpp.

References x, y, and z.

Referenced by ComSwitch::parseValuesFromArguments().

104  {
105  this ->min[ 0 ] = x;
106  this ->min[ 1 ] = y;
107  this ->min[ 2 ] = z;
108  this ->max[ 0 ] = X;
109  this ->max[ 1 ] = Y;
110  this ->max[ 2 ] = Z;
111  };
void int int REAL REAL * y
Definition: read.cpp:74
void int int int REAL REAL REAL * z
Definition: write.cpp:76
void int int REAL * x
Definition: read.cpp:74

Here is the caller graph for this function:

static size_t Size ( )
inlinestatic

Same as BoundingBox::getBytesize( ) but does not require a BoundingBox instance to be allocated.

Returns
The size of a BoundingBox instance.

Definition at line 87 of file BoundingBox.hpp.

88  {
89  return( 6*sizeof( double ) );
90  }

Member Data Documentation

double max[3]
protected

Definition at line 24 of file BoundingBox.hpp.

Referenced by intersection().

double min[3]
protected

Definition at line 25 of file BoundingBox.hpp.

Referenced by intersection().


The documentation for this class was generated from the following file: