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

Protected Member Functions

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

Protected Attributes

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

Friends

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

Detailed Description

Bbox2 is an axis aligned 2D bounding box.

Constructor & Destructor Documentation

◆ Bbox2()

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

Constructor.

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

Add a point.

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

Add points.

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

Add points.

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

Add points.

Extends the 2D bounding box if required.

Returns
true if the bounding box changes, false otherwise

◆ computeCenter()

Point2 Bbox2::computeCenter ( ) const

Compute the 2D midpoint.

◆ doIntersect()

bool Bbox2::doIntersect ( const Bbox2 other) const

Check intersection.

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

◆ doubleTheBox()

void Bbox2::doubleTheBox ( )

Double the box.

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

◆ get_maxX()

double Bbox2::get_maxX ( ) const
inline

Get maxX.

Returns
maxX

◆ get_maxY()

double Bbox2::get_maxY ( ) const
inline

Get maxY.

Returns
maxY

◆ get_minX()

double Bbox2::get_minX ( ) const
inline

Get minX.

Returns
minX

◆ get_minY()

double Bbox2::get_minY ( ) const
inline

Get minY.

Returns
minY

◆ getBounds()

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

Get bounds.

◆ getCorners()

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

Get corners.

Convenience function: Returns the 4 corners of the bounding box

◆ getMaxCoord()

double Bbox2::getMaxCoord ( ) const
inline

Get maximum coordinate.

Returns
the largest coordinate value, i.e. max(maxX,maxY)

◆ getMaxPoint()

Point2 Bbox2::getMaxPoint ( ) const
inline

Get the max point.

Returns
the 2D corner point with the maximum coordinates

◆ getMaxRange()

double Bbox2::getMaxRange ( ) const
inline

Get max range.

Returns
the largest range, i.e. max(getRangeX(),getRangeY())

◆ getMinCoord()

double Bbox2::getMinCoord ( ) const
inline

Get minimum coordinate.

Returns
the smallest coordinate value, i.e. min(minX,minY)

◆ getMinPoint()

Point2 Bbox2::getMinPoint ( ) const
inline

Get the min point.

Returns
the 2D corner point with the minimum coordinates

◆ getOffsetCorners()

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

Get offset corners.

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

Get x-range.

Returns
maxX-minX

◆ getRangeY()

double Bbox2::getRangeY ( ) const
inline

Get y-range.

Returns
maxY-minY

◆ inflateIfDegenerate()

void Bbox2::inflateIfDegenerate ( double  val)
inline

Inflate if Degenerate.

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

Point-in-Box Test.

Returns
true if minX <= p.x() <=maxX and minY <= p.y() <=maxY or false otherwise.

◆ isValid()

bool Bbox2::isValid ( ) const
inline

Check if the bounds are valid.

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)

Add a bounding box.

Extends the 2D bounding box if required.

Returns
the resulting bounding box

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