libMesh::MeshTools::BoundingBox Class Reference

#include <mesh_tools.h>

Inheritance diagram for libMesh::MeshTools::BoundingBox:

Public Member Functions

 BoundingBox (const Point &new_min, const Point &new_max)
 
 BoundingBox (const std::pair< Point, Point > &bbox)
 
 BoundingBox ()
 
void invalidate ()
 
const Pointmin () const
 
Pointmin ()
 
const Pointmax () const
 
Pointmax ()
 
BoundingBoxexpand ()
 
bool intersect (const BoundingBox &) const
 
bool contains_point (const Point &) const
 

Detailed Description

Defines a Cartesian bounding box by the two corner extremum.

Definition at line 67 of file mesh_tools.h.

Constructor & Destructor Documentation

libMesh::MeshTools::BoundingBox::BoundingBox ( const Point new_min,
const Point new_max 
)
inline

Definition at line 71 of file mesh_tools.h.

71  :
72  std::pair<Point, Point>(new_min, new_max)
73  {}
libMesh::MeshTools::BoundingBox::BoundingBox ( const std::pair< Point, Point > &  bbox)
inline

Definition at line 75 of file mesh_tools.h.

75  :
76  std::pair<Point, Point> (bbox)
77  {}
libMesh::MeshTools::BoundingBox::BoundingBox ( )
inline

Default constructor sets invalid bounds.

Definition at line 82 of file mesh_tools.h.

References invalidate().

83  {
84  this->invalidate();
85  }

Member Function Documentation

bool libMesh::MeshTools::BoundingBox::contains_point ( const Point p) const

Definition at line 284 of file mesh_tools.C.

References libMesh::is_between(), and libMesh::Real.

285 {
286  // Make local variables first to make thiings more clear in a moment
287  Real my_min_x = this->first(0);
288  Real my_max_x = this->second(0);
289  bool x_int = is_between(my_min_x, p(0), my_max_x);
290 
291  bool intersection_true = x_int;
292 
293 #if LIBMESH_DIM > 1
294  Real my_min_y = this->first(1);
295  Real my_max_y = this->second(1);
296  bool y_int = is_between(my_min_y, p(1), my_max_y);
297 
298  intersection_true = intersection_true && y_int;
299 #endif
300 
301 
302 #if LIBMESH_DIM > 2
303  Real my_min_z = this->first(2);
304  Real my_max_z = this->second(2);
305  bool z_int = is_between(my_min_z, p(2), my_max_z);
306 
307  intersection_true = intersection_true && z_int;
308 #endif
309 
310  return intersection_true;
311 }
BoundingBox& libMesh::MeshTools::BoundingBox::expand ( )
inline

Definition at line 108 of file mesh_tools.h.

109  { return *this; }
bool libMesh::MeshTools::BoundingBox::intersect ( const BoundingBox other_box) const

Definition at line 244 of file mesh_tools.C.

References libMesh::is_between(), and libMesh::Real.

245 {
246  // Make local variables first to make thiings more clear in a moment
247  const Real& my_min_x = this->first(0);
248  const Real& my_max_x = this->second(0);
249  const Real& other_min_x = other_box.first(0);
250  const Real& other_max_x = other_box.second(0);
251 
252  const bool x_int = is_between(my_min_x, other_min_x, my_max_x) || is_between(my_min_x, other_max_x, my_max_x) ||
253  is_between(other_min_x, my_min_x, other_max_x) || is_between(other_min_x, my_max_x, other_max_x);
254 
255  bool intersection_true = x_int;
256 
257 #if LIBMESH_DIM > 1
258  const Real& my_min_y = this->first(1);
259  const Real& my_max_y = this->second(1);
260  const Real& other_min_y = other_box.first(1);
261  const Real& other_max_y = other_box.second(1);
262 
263  const bool y_int = is_between(my_min_y, other_min_y, my_max_y) || is_between(my_min_y, other_max_y, my_max_y) ||
264  is_between(other_min_y, my_min_y, other_max_y) || is_between(other_min_y, my_max_y, other_max_y);
265 
266  intersection_true = intersection_true && y_int;
267 #endif
268 
269 #if LIBMESH_DIM > 2
270  const Real& my_min_z = this->first(2);
271  const Real& my_max_z = this->second(2);
272  const Real& other_min_z = other_box.first(2);
273  const Real& other_max_z = other_box.second(2);
274 
275  const bool z_int = is_between(my_min_z, other_min_z, my_max_z) || is_between(my_min_z, other_max_z, my_max_z) ||
276  is_between(other_min_z, my_min_z, other_max_z) || is_between(other_min_z, my_max_z, other_max_z);
277 
278  intersection_true = intersection_true && z_int;
279 #endif
280 
281  return intersection_true;
282 }
void libMesh::MeshTools::BoundingBox::invalidate ( )
inline

Definition at line 87 of file mesh_tools.h.

References std::max().

Referenced by BoundingBox().

88  {
89  for (unsigned int i=0; i<LIBMESH_DIM; i++)
90  {
91  this->first(i) = std::numeric_limits<Real>::max();
92  this->second(i) = -std::numeric_limits<Real>::max();
93  }
94  }
const Point& libMesh::MeshTools::BoundingBox::max ( ) const
inline

Definition at line 102 of file mesh_tools.h.

103  { return this->second; }
Point& libMesh::MeshTools::BoundingBox::max ( )
inline

Definition at line 105 of file mesh_tools.h.

106  { return this->second; }
const Point& libMesh::MeshTools::BoundingBox::min ( ) const
inline

Definition at line 96 of file mesh_tools.h.

97  { return this->first; }
Point& libMesh::MeshTools::BoundingBox::min ( )
inline

Definition at line 99 of file mesh_tools.h.

100  { return this->first; }

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

Site Created By: libMesh Developers
Last modified: February 07 2014 16:58:02 UTC

Hosted By:
SourceForge.net Logo