Fade2D Documentation pages v2.16.7
Delaunay Features
GEOM_FADE2D::Bbox2 Class Reference

A 2D axis-aligned bounding box. More...

#include <Bbox2.h>

Public Member Functions

 Bbox2 (GeomTest *pGeomTest_=NULL)
 Default constructor. More...
 
bool add (const Bbox2 &other)
 Adds another bounding box to this one. More...
 
bool add (const Point2 &p)
 Adds a single point to the bounding box. More...
 
bool add (size_t numPoints, double *coordinates)
 Adds points to the bounding box. More...
 
bool add (std::vector< Point2 * >::const_iterator start_it, std::vector< Point2 * >::const_iterator end_it)
 Adds points to the bounding box. More...
 
bool add (std::vector< Point2 >::const_iterator start_it, std::vector< Point2 >::const_iterator end_it)
 Adds points to the bounding box. More...
 
Point2 computeCenter () const
 Computes the 2D midpoint of the bounding box. More...
 
bool doIntersect (const Bbox2 &other) const
 Checks if this bounding box intersects with another. More...
 
void doubleTheBox ()
 Doubles the size of the bounding box. More...
 
void enlargeRanges (double factor, bool bUseMaxRange, double minRange)
 Enlarges the bounding box's ranges symmetrically. More...
 
double get_maxX () const
 Retrieves the maxX value. More...
 
double get_maxY () const
 Retrieves the maxY value. More...
 
double get_minX () const
 Retrieves the minX value. More...
 
double get_minY () const
 Retrieves the minY value. More...
 
void getBoundary (std::vector< Segment2 > &vBoundary) const
 Retrieves the boundary of the bounding box. More...
 
void getBounds (double &minX_, double &maxX_, double &minY_, double &maxY_) const
 Retrieves the bounding box coordinates. More...
 
void getCorners (std::vector< Point2 > &vBoxCorners) const
 Retrieves the corners of the bounding box. More...
 
double getMaxCoord () const
 Retrieves the largest coordinate value. More...
 
Point2 getMaxPoint () const
 Retrieves the maximum corner point of the bounding box. More...
 
double getMaxRange () const
 Retrieves the largest range of the bounding box. More...
 
double getMinCoord () const
 Retrieves the smallest coordinate value. More...
 
Point2 getMinPoint () const
 Retrieves the minimum corner point of the bounding box. More...
 
void getOffsetCorners (double offset, std::vector< Point2 > &vBoxCorners) const
 Retrieves the offset corners of the bounding box. More...
 
double getRangeX () const
 Retrieves the X-range of the bounding box. More...
 
double getRangeY () const
 Retrieves the Y-range of the bounding box. More...
 
void inflateIfDegenerate (double val)
 Inflates the bounding box if degenerate. More...
 
bool isInBox (const Point2 &p) const
 Checks if a point is inside the bounding box. More...
 
bool isValid () const
 Checks if the bounds are valid. More...
 
Bbox2 operator+ (const Bbox2 &b)
 Adds another bounding box to this one. More...
 
void reset ()
 Resets the bounds. More...
 
void setMaxX (double val)
 Sets the maxX value. More...
 
void setMaxY (double val)
 Sets the maxY value. More...
 
void setMinX (double val)
 Sets the minX value. More...
 
void setMinY (double val)
 Sets the minY value. More...
 

Protected Member Functions

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

Protected Attributes

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

Friends

Bbox2 intersection (const Bbox2 &a, const Bbox2 &b)
 Computes the intersection of two bounding boxes. More...
 
std::ostream & operator<< (std::ostream &stream, const Bbox2 &pC)
 Prints the bounding box to a stream. More...
 

Detailed Description

The Bbox2 class represents a 2D axis-aligned bounding box with minimum and maximum coordinates in the X and Y directions.

Constructor & Destructor Documentation

◆ Bbox2()

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

Initializes the bounding box with minX and minY set to DBL_MAX and maxX and maxY set to -DBL_MAX.

Member Function Documentation

◆ add() [1/5]

bool GEOM_FADE2D::Bbox2::add ( const Bbox2 other)
inline

Extends the 2D bounding box if required.

Parameters
otherThe bounding box to add.
Returns
true if the bounding box changes, false otherwise.

◆ add() [2/5]

bool GEOM_FADE2D::Bbox2::add ( const Point2 p)
inline

Extends the 2D bounding box if required.

Parameters
pThe point to add.
Returns
true if the bounding box changes, false otherwise.

◆ add() [3/5]

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

Extends the 2D bounding box if required.

Parameters
numPointsThe number of points to add.
coordinatesA pointer to an array of coordinates (x, y).
Returns
true if the bounding box changes, false otherwise.

◆ add() [4/5]

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

Adds points, extends the 2D bounding box if required.

Parameters
start_it,end_itIterator range containing the points to add
Returns
true if the bounding box changes, false otherwise.

◆ add() [5/5]

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

Extends the 2D bounding box if required.

Parameters
start_itAn iterator pointing to the first point to add.
end_itAn iterator pointing to one past the last point to add.
Returns
true if the bounding box changes, false otherwise.

◆ computeCenter()

Point2 GEOM_FADE2D::Bbox2::computeCenter ( ) const

Computes the center of the bounding box.

Returns
The center point of the bounding box.

◆ doIntersect()

bool GEOM_FADE2D::Bbox2::doIntersect ( const Bbox2 other) const

Checks if this bounding box intersects the Bbox2 other.

Parameters
otherThe other bounding box to check for intersection.
Returns
true if the boxes intersect, false otherwise.

◆ doubleTheBox()

void GEOM_FADE2D::Bbox2::doubleTheBox ( )

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

◆ enlargeRanges()

void GEOM_FADE2D::Bbox2::enlargeRanges ( double  factor,
bool  bUseMaxRange,
double  minRange 
)

This method updates minX, minY, maxX, and maxY symmetrically to enlarge the X- and Y-ranges of the bounding box.

Parameters
factorThe factor by which the existing ranges rangeX and rangeY shall grow.
bUseMaxRangeIf true, a square bounding box with side length factor * max(rangeX, rangeY) is created.
minRangeThe minimum allowable range to avoid a degenerate box.

◆ get_maxX()

double GEOM_FADE2D::Bbox2::get_maxX ( ) const
inline
Returns
The maxX coordinate.

◆ get_maxY()

double GEOM_FADE2D::Bbox2::get_maxY ( ) const
inline
Returns
The maxY coordinate.

◆ get_minX()

double GEOM_FADE2D::Bbox2::get_minX ( ) const
inline
Returns
The minX coordinate.

◆ get_minY()

double GEOM_FADE2D::Bbox2::get_minY ( ) const
inline
Returns
The minY coordinate.

◆ getBoundary()

void GEOM_FADE2D::Bbox2::getBoundary ( std::vector< Segment2 > &  vBoundary) const

Convenience function: Returns 4 border segments.

Parameters
vBoundaryA vector to store the 4 boundary segments.

◆ getBounds()

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

Retrieves the bounding box coordinates.

Parameters
minX_A reference to store the minX value.
maxX_A reference to store the maxX value.
minY_A reference to store the minY value.
maxY_A reference to store the maxY value.

◆ getCorners()

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

Convenience function: Returns the 4 corners of the box.

Parameters
vBoxCornersA vector to store the 4 corners of the box.

◆ getMaxCoord()

double GEOM_FADE2D::Bbox2::getMaxCoord ( ) const
inline
Returns
The maximum of maxX and maxY.

◆ getMaxPoint()

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

◆ getMaxRange()

double GEOM_FADE2D::Bbox2::getMaxRange ( ) const
inline
Returns
The larger of the X-range and Y-range.

◆ getMinCoord()

double GEOM_FADE2D::Bbox2::getMinCoord ( ) const
inline
Returns
The minimum of minX and minY.

◆ getMinPoint()

Point2 GEOM_FADE2D::Bbox2::getMinPoint ( ) const
inline

Retrieves the minimum corner point of the bounding box.

Returns
The 2D corner point with the minimum coordinates.

◆ getOffsetCorners()

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

Returns the 4 corners of an enlarged box. The box is enlarged by offset in each direction.

Parameters
offsetThe enlargement value for each direction.
vBoxCornersA vector to store the 4 offset corners of the box.

◆ getRangeX()

double GEOM_FADE2D::Bbox2::getRangeX ( ) const
inline
Returns
The difference between maxX and minX.

◆ getRangeY()

double GEOM_FADE2D::Bbox2::getRangeY ( ) const
inline
Returns
The difference between maxY and minY.

◆ inflateIfDegenerate()

void GEOM_FADE2D::Bbox2::inflateIfDegenerate ( double  val)
inline

If the bounding box is degenerate (i.e., it only contains one point or has identical x and/or y coordinates), this method inflates the box by adding a value (val) to maxX and/or maxY.

Parameters
valThe value to inflate the bounding box.

◆ isInBox()

bool GEOM_FADE2D::Bbox2::isInBox ( const Point2 p) const

Checks if the query point p is inside the box.

Parameters
pThe point to check.
Returns
true if the point is inside the box, false otherwise.

◆ isValid()

bool GEOM_FADE2D::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 GEOM_FADE2D::Bbox2::operator+ ( const Bbox2 b)

Extends the 2D bounding box and returns the resulting bounding box.

Parameters
bThe bounding box to add.
Returns
The resulting bounding box after the addition.

◆ reset()

void GEOM_FADE2D::Bbox2::reset ( )
inline

Resets the bounding box to default values.

◆ setMaxX()

void GEOM_FADE2D::Bbox2::setMaxX ( double  val)
inline
Parameters
valThe new value for maxX.

◆ setMaxY()

void GEOM_FADE2D::Bbox2::setMaxY ( double  val)
inline
Parameters
valThe new value for maxY.

◆ setMinX()

void GEOM_FADE2D::Bbox2::setMinX ( double  val)
inline
Parameters
valThe new value for minX.

◆ setMinY()

void GEOM_FADE2D::Bbox2::setMinY ( double  val)
inline
Parameters
valThe new value for minY.

Friends And Related Function Documentation

◆ intersection

Bbox2 intersection ( const Bbox2 a,
const Bbox2 b 
)
friend

This function calculates the intersection of two 2D axis-aligned bounding boxes, a and b. The intersection is the region where both bounding boxes overlap. If there is no overlap, the resulting bounding box is marked as invalid (bValid = false).

Parameters
aThe first bounding box.
bThe second bounding box.
Returns
A Bbox2 object representing the intersection of a and b. If the boxes do not intersect, the resulting bounding box is invalid.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const Bbox2 pC 
)
friend
Parameters
streamThe output stream
pCThe bounding box to print.
Returns
The output stream

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