Fade2D Documentation pages v1.85
Delaunay Features
Bbox2 Class Reference

Bbox2 is an axis aligned 2D bounding box. More...

#include <Bbox2.h>

Public Member Functions

 Bbox2 (GeomTest *pGeomTest_=NULL)
 Constructor. More...
 
bool add (const Point2 &p)
 Add a point. More...
 
bool add (size_t numPoints, double *coordinates)
 Add points. More...
 
bool add (std::vector< Point2 * >::const_iterator start_it, std::vector< Point2 * >::const_iterator end_it)
 Add points. More...
 
bool add (std::vector< Point2 >::const_iterator start_it, std::vector< Point2 >::const_iterator end_it)
 Add points. More...
 
Point2 computeCenter () const
 Compute the 2D midpoint. More...
 
bool doIntersect (const Bbox2 &other) const
 Check intersection. More...
 
void doubleTheBox ()
 Double the box. More...
 
void enlargeRanges (double factor)
 
double get_maxX () const
 Get maxX. More...
 
double get_maxY () const
 Get maxY. More...
 
double get_minX () const
 Get minX. More...
 
double get_minY () const
 Get minY. More...
 
void getBounds (double &minX_, double &maxX_, double &minY_, double &maxY_) const
 Get bounds. More...
 
void getCorners (std::vector< Point2 > &vBoxCorners) const
 Get corners. More...
 
double getMaxCoord () const
 Get maximum coordinate. More...
 
Point2 getMaxPoint () const
 Get the max point. More...
 
double getMaxRange () const
 Get max range. More...
 
double getMinCoord () const
 Get minimum coordinate. More...
 
Point2 getMinPoint () const
 Get the min point. More...
 
void getOffsetCorners (double offset, std::vector< Point2 > &vBoxCorners) const
 Get offset corners. More...
 
double getRangeX () const
 Get x-range. More...
 
double getRangeY () const
 Get y-range. More...
 
void inflateIfDegenerate (double val)
 Inflate if Degenerate. More...
 
bool isInBox (const Point2 &p) const
 Point-in-Box Test. More...
 
bool isValid () const
 Check if the bounds are valid. More...
 
Bbox2 operator+ (const Bbox2 &b)
 Add a bounding box. More...
 
void setMaxX (double val)
 Set maxX.
 
void setMaxY (double val)
 Set maxY.
 
void setMinX (double val)
 Set minX.
 
void setMinY (double val)
 Set minY.
 

Protected Member Functions

void treatPointForInvalidBox (const Point2 &p)
 
void treatPointForValidBox (const Point2 &p)
 

Protected Attributes

bool bValid
 
double maxX
 
double maxY
 
double minX
 
double minY
 
GeomTest * pGeomTest
 

Friends

std::ostream & operator<< (std::ostream &stream, Bbox2 &pC)
 

Detailed Description

Constructor & Destructor Documentation

◆ Bbox2()

Bbox2::Bbox2 ( GeomTest *  pGeomTest_ = NULL)
inlineexplicit

Minimum bounds are initialized to DBL_MAX. Maximum bounds are initialized to -DBL_MAX. Box is not valid yet

Member Function Documentation

◆ add() [1/4]

bool Bbox2::add ( const Point2 p)
inline

Extends the 2D bounding box if required.

Returns
true if the bounding box changes, false otherwise

◆ add() [2/4]

bool Bbox2::add ( size_t  numPoints,
double *  coordinates 
)
inline

Extends the 2D bounding box if required.

Returns
true if the bounding box changes, false otherwise

◆ add() [3/4]

bool Bbox2::add ( std::vector< Point2 * >::const_iterator  start_it,
std::vector< Point2 * >::const_iterator  end_it 
)
inline

Extends the 2D bounding box if required.

Returns
true if the bounding box changes, false otherwise

◆ add() [4/4]

bool Bbox2::add ( std::vector< Point2 >::const_iterator  start_it,
std::vector< Point2 >::const_iterator  end_it 
)
inline

Extends the 2D bounding box if required.

Returns
true if the bounding box changes, false otherwise

◆ computeCenter()

Point2 Bbox2::computeCenter ( ) const

◆ doIntersect()

bool Bbox2::doIntersect ( const Bbox2 other) const

Two valid bounding boxes intersect if they share at least one point in the XY plane.

◆ doubleTheBox()

void Bbox2::doubleTheBox ( )

Changes the bounds such that the box grows in each direction by half the previous range

◆ get_maxX()

double Bbox2::get_maxX ( ) const
inline
Returns
maxX

◆ get_maxY()

double Bbox2::get_maxY ( ) const
inline
Returns
maxY

◆ get_minX()

double Bbox2::get_minX ( ) const
inline
Returns
minX

◆ get_minY()

double Bbox2::get_minY ( ) const
inline
Returns
minY

◆ getBounds()

void Bbox2::getBounds ( double &  minX_,
double &  maxX_,
double &  minY_,
double &  maxY_ 
) const

◆ getCorners()

void Bbox2::getCorners ( std::vector< Point2 > &  vBoxCorners) const

Convenience function: Returns the 4 corners of the bounding box

◆ getMaxCoord()

double Bbox2::getMaxCoord ( ) const
inline
Returns
the largest coordinate value, i.e. max(maxX,maxY)

◆ getMaxPoint()

Point2 Bbox2::getMaxPoint ( ) const
inline
Returns
the 2D corner point with the maximum coordinates

◆ getMaxRange()

double Bbox2::getMaxRange ( ) const
inline
Returns
the largest range, i.e. max(getRangeX(),getRangeY())

◆ getMinCoord()

double Bbox2::getMinCoord ( ) const
inline
Returns
the smallest coordinate value, i.e. min(minX,minY)

◆ getMinPoint()

Point2 Bbox2::getMinPoint ( ) const
inline
Returns
the 2D corner point with the minimum coordinates

◆ getOffsetCorners()

void Bbox2::getOffsetCorners ( double  offset,
std::vector< Point2 > &  vBoxCorners 
) const

Convenience function: Returns the 4 corners of an enlarged box. The box es enlarged by offset in each direction

◆ getRangeX()

double Bbox2::getRangeX ( ) const
inline
Returns
maxX-minX

◆ getRangeY()

double Bbox2::getRangeY ( ) const
inline
Returns
maxY-minY

◆ inflateIfDegenerate()

void Bbox2::inflateIfDegenerate ( double  val)
inline

When only one point has been added to Bbox2 or when all points have the same x- and/or y- coordinates then Bbox2 is degenerate. This is a valid state but sometimes undesireable. The present method inflates the Bbox2 by adding /p val to maxX and/or maxY.

◆ isInBox()

bool Bbox2::isInBox ( const Point2 p) const
Returns
true if minX <= p.x() <=maxX and minY <= p.y() <=maxY or false otherwise.

◆ isValid()

bool Bbox2::isValid ( ) const
inline

The bounds are valid when at least one point has been added or when set-methods have been used to set minX<=maxX and minY<=maxY

◆ operator+()

Bbox2 Bbox2::operator+ ( const Bbox2 b)

Extends the 2D bounding box if required.

Returns
the resulting bounding box

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