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... | |
The Bbox2
class represents a 2D axis-aligned bounding box with minimum and maximum coordinates in the X and Y directions.
|
inlineexplicit |
Initializes the bounding box with minX
and minY
set to DBL_MAX
and maxX
and maxY
set to -DBL_MAX
.
|
inline |
Extends the 2D bounding box if required.
other | The bounding box to add. |
true
if the bounding box changes, false
otherwise.
|
inline |
Extends the 2D bounding box if required.
p | The point to add. |
true
if the bounding box changes, false
otherwise.
|
inline |
Extends the 2D bounding box if required.
numPoints | The number of points to add. |
coordinates | A pointer to an array of coordinates (x, y). |
true
if the bounding box changes, false
otherwise.
|
inline |
Adds points, extends the 2D bounding box if required.
start_it,end_it | Iterator range containing the points to add |
true
if the bounding box changes, false
otherwise.
|
inline |
Extends the 2D bounding box if required.
start_it | An iterator pointing to the first point to add. |
end_it | An iterator pointing to one past the last point to add. |
true
if the bounding box changes, false
otherwise. Point2 GEOM_FADE2D::Bbox2::computeCenter | ( | ) | const |
Computes the center of the bounding box.
bool GEOM_FADE2D::Bbox2::doIntersect | ( | const Bbox2 & | other | ) | const |
Checks if this bounding box intersects the Bbox2 other
.
other | The other bounding box to check for intersection. |
true
if the boxes intersect, false
otherwise. void GEOM_FADE2D::Bbox2::doubleTheBox | ( | ) |
Changes the bounds such that the box grows in each direction by half the previous range.
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.
factor | The factor by which the existing ranges rangeX and rangeY shall grow. |
bUseMaxRange | If true , a square bounding box with side length factor * max(rangeX, rangeY) is created. |
minRange | The minimum allowable range to avoid a degenerate box. |
|
inline |
maxX
coordinate.
|
inline |
maxY
coordinate.
|
inline |
minX
coordinate.
|
inline |
minY
coordinate. void GEOM_FADE2D::Bbox2::getBoundary | ( | std::vector< Segment2 > & | vBoundary | ) | const |
Convenience function: Returns 4 border segments.
vBoundary | A vector to store the 4 boundary segments. |
void GEOM_FADE2D::Bbox2::getBounds | ( | double & | minX_, |
double & | maxX_, | ||
double & | minY_, | ||
double & | maxY_ | ||
) | const |
Retrieves the bounding box coordinates.
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. |
void GEOM_FADE2D::Bbox2::getCorners | ( | std::vector< Point2 > & | vBoxCorners | ) | const |
Convenience function: Returns the 4 corners of the box.
vBoxCorners | A vector to store the 4 corners of the box. |
|
inline |
maxX
and maxY
.
|
inline |
|
inline |
|
inline |
minX
and minY
.
|
inline |
Retrieves the minimum corner point of the bounding box.
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.
offset | The enlargement value for each direction. |
vBoxCorners | A vector to store the 4 offset corners of the box. |
|
inline |
maxX
and minX
.
|
inline |
maxY
and minY
.
|
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
.
val | The value to inflate the bounding box. |
bool GEOM_FADE2D::Bbox2::isInBox | ( | const Point2 & | p | ) | const |
Checks if the query point p
is inside the box.
p | The point to check. |
true
if the point is inside the box, false
otherwise.
|
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
.
Extends the 2D bounding box and returns the resulting bounding box.
b | The bounding box to add. |
|
inline |
Resets the bounding box to default values.
|
inline |
val | The new value for maxX . |
|
inline |
val | The new value for maxY . |
|
inline |
val | The new value for minX . |
|
inline |
val | The new value for minY . |
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
).
a | The first bounding box. |
b | The second bounding box. |
Bbox2
object representing the intersection of a
and b
. If the boxes do not intersect, the resulting bounding box is invalid.
|
friend |
stream | The output stream |
pC | The bounding box to print. |