#include <qgarlib/BoundingBox.H>
Inheritance diagram for qgar::BoundingBox:

A bounding box is a rectangle with sides parallel to the coordinate system axis. It is represented by its top left and bottom right corners.
0
+---------------------------------------> X
|
| <---- length ---->
| top left o----------------+ ^
| | | |
| | Bounding Box |height
| | | |
| +----------------o v
V bottom right
Y
Definition at line 100 of file BoundingBox.H.
Public Member Functions | |
Constructors | |
| BoundingBox () | |
| Default constructor. | |
| BoundingBox (const BoundingBox &aBox) | |
| Copy constructor. | |
| BoundingBox (const GenPoint< int > &aPt1, const GenPoint< int > &aPt2) | |
| Initialize from two points. | |
| BoundingBox (int aX1, int aY1, int aX2, int aY2) | |
| Initialize from coordinates of two points. | |
| BoundingBox (const GenPoint< int > &aTopLeft, int aLength, int aHeight) throw (QgarErrorDomain) | |
| Initialize from top left corner, length and height. | |
| BoundingBox (int aLength, int aHeight, const GenPoint< int > &aBottomRight) throw (QgarErrorDomain) | |
| Initialize from bottom right corner, length and height. | |
Destructor | |
| ~BoundingBox () | |
| Non-virtual destructor. | |
Access to corners | |
| const GenPoint< int > & | accessTopLeft () const |
| Get top left corner. | |
| GenPoint< int > | topLeft () const |
| Get a copy of the top left corner. | |
| const GenPoint< int > & | accessBottomRight () const |
| Get bottom right corner. | |
| GenPoint< int > | bottomRight () const |
| Get a copy of the bottom right corner. | |
Access to coordinates | |
| int | xTopLeft () const |
| Get X coordinate of top left corner. | |
| int | yTopLeft () const |
| Get Y coordinate of top left corner. | |
| int | xBottomRight () const |
| Get X coordinate of bottom right corner. | |
| int | yBottomRight () const |
| Get Y coordinate of bottom right corner. | |
Access to dimensions | |
| int | length () const |
| Same as qgar::BoundingBox::width. | |
| int | width () const |
| Get width. | |
| int | height () const |
| Get height. | |
| int | area () const |
| Get area. | |
Geometrical predicates | |
| bool | contains (const GenPoint< int > &aPt) const |
| Return true if the given point belongs to the current bounding box, including borders. | |
| bool | contains (int aX, int aY) const |
| Return true if the point defined by the given coordinates belongs to the current bounding box, including borders. | |
| bool | contains (const BoundingBox &aBox) const |
| Return true if the current bounding box contains the given bounding box. | |
| bool | intersects (const BoundingBox &aBox) const |
| Return true if the current bounding box intersects the given bounding box. | |
Geometrical operations | |
| BoundingBox * | intersection (const BoundingBox &aBox) const |
| Intersection between the current and given bounding boxes. | |
Set corners | |
| void | setTopLeft (const GenPoint< int > &aPt) throw (QgarErrorDomain) |
| Set top left corner using a point. | |
| void | setTopLeft (int aX, int aY) throw (QgarErrorDomain) |
| Set top left corner using X and Y coordinates. | |
| void | setXTopLeft (int aX) throw (QgarErrorDomain) |
| Set X coordinate of top left corner. | |
| void | setYTopLeft (int aY) throw (QgarErrorDomain) |
| Set Y coordinate of top left corner. | |
| void | setBottomRight (const GenPoint< int > &aPt) throw (QgarErrorDomain) |
| Set bottom right corner using a point. | |
| void | setBottomRight (int aX, int aY) throw (QgarErrorDomain) |
| Set bottom right corner using X and Y coordinates. | |
| void | setXBottomRight (int aX) throw (QgarErrorDomain) |
| Set X coordinate of bottom right corner. | |
| void | setYBottomRight (int aY) throw (QgarErrorDomain) |
| Set Y coordinate of bottom right corner. | |
| void | setCorners (const GenPoint< int > &aPt1, const GenPoint< int > &aPt2) |
| Set both top left and bottom right corners from two points. | |
| void | setCorners (int aX1, int aY1, int aX2, int aY2) |
| Set both top left and bottom right corners from coordinates of two points. | |
Operators | |
| BoundingBox & | operator= (const BoundingBox &aBox) |
| Assign the given bounding box to the current bounding box. | |
| bool | operator== (const BoundingBox &aBox) const |
| Same as function qgar::BoundingBox::eq. | |
| bool | operator!= (const BoundingBox &aBox) const |
| Same as function qgar::BoundingBox::NotEq. | |
Functional operators | |
| bool | eq (const BoundingBox &aBox) const |
| Equality. | |
| bool | notEq (const BoundingBox &aBox) const |
| Inequality. | |
Serialization/deserialization | |
| virtual std::istream & | read (std::istream &anInStream) |
| Deserializes the current box from an input stream. | |
| virtual std::ostream & | write (std::ostream &anOutStream) const |
| Serializes the current box to an input stream. | |
Protected Attributes | |
Representation of a bounding box | |
| GenPoint< int > | _topLeft |
| Top left corner. | |
| GenPoint< int > | _bottomRight |
| Bottom right corner. | |
|
|
Default constructor. One-unit-length and one-unit-width bounding box located at the origin of the coordinate system. Definition at line 61 of file BoundingBox.C. Referenced by intersection(). |
|
|
Copy constructor.
Definition at line 73 of file BoundingBox.C. |
|
||||||||||||
|
Initialize from two points. The two given points, aPt1 and aPt2, are supposed to be two opposite corners (top left and bottom right, or top right and bottom left) of the resulting bounding box. The corresponding coordinates of top left and bottom right corners are automatically computed.
Definition at line 85 of file BoundingBox.C. References setCorners(). |
|
||||||||||||||||||||
|
Initialize from coordinates of two points. The two given points are supposed to be two opposite corners (top left and bottom right, or top right and bottom left) of the resulting bounding box. The corresponding coordinates of top left and bottom right corners are automatically computed.
Definition at line 94 of file BoundingBox.C. References setCorners(). |
|
||||||||||||||||
|
Initialize from top left corner, length and height. The length and the height must be greater than 0.
Definition at line 102 of file BoundingBox.C. |
|
||||||||||||||||
|
Initialize from bottom right corner, length and height. The length and the height must be greater than 0.
Definition at line 141 of file BoundingBox.C. |
|
|
Non-virtual destructor.
Definition at line 183 of file BoundingBox.C. |
|
|
Get bottom right corner.
Definition at line 640 of file BoundingBox.H. References _bottomRight. |
|
|
Get top left corner.
Definition at line 622 of file BoundingBox.H. References _topLeft. |
|
|
Get area.
Definition at line 731 of file BoundingBox.H. References height(), and length(). Referenced by qgar::Component::densityBox(). |
|
|
Get a copy of the bottom right corner.
Definition at line 649 of file BoundingBox.H. References _bottomRight. Referenced by contains(), eq(), and notEq(). |
|
|
Return true if the current bounding box contains the given bounding box.
Definition at line 754 of file BoundingBox.H. References bottomRight(), contains(), and topLeft(). |
|
||||||||||||
|
Return true if the point defined by the given coordinates belongs to the current bounding box, including borders.
Definition at line 450 of file BoundingBox.C. References _bottomRight, _topLeft, qgar::GenPoint< T >::x(), and qgar::GenPoint< T >::y(). |
|
|
Return true if the given point belongs to the current bounding box, including borders.
Definition at line 745 of file BoundingBox.H. References qgar::GenPoint< T >::x(), and qgar::GenPoint< T >::y(). Referenced by contains(). |
|
|
Equality. Return true if the current bounding box and the given bounding box have the same coordinates.
Definition at line 578 of file BoundingBox.C. References _bottomRight, _topLeft, bottomRight(), and topLeft(). Referenced by operator==(). |
|
|
Get height.
Definition at line 722 of file BoundingBox.H. References _bottomRight, _topLeft, and qgar::GenPoint< T >::y(). Referenced by area(), and qgar::TTBinaryImage::TTBinaryImage(). |
|
|
Intersection between the current and given bounding boxes. If the two bounding boxes intersect, returns a pointer to the bounding box representing the intersection. If the two bounding boxes do not intersect, returns a null pointer.
Definition at line 518 of file BoundingBox.C. References _bottomRight, _topLeft, BoundingBox(), qgar::GenPoint< T >::x(), xBottomRight(), xTopLeft(), qgar::GenPoint< T >::y(), yBottomRight(), and yTopLeft(). |
|
|
Return true if the current bounding box intersects the given bounding box.
Definition at line 478 of file BoundingBox.C. References _bottomRight, _topLeft, qgar::GenPoint< T >::x(), xBottomRight(), xTopLeft(), qgar::GenPoint< T >::y(), yBottomRight(), and yTopLeft(). |
|
|
Same as qgar::BoundingBox::width.
Definition at line 704 of file BoundingBox.H. References width(). Referenced by area(). |
|
|
Inequality. Return true if the current bounding box and the given bounding box have different coordinates.
Definition at line 588 of file BoundingBox.C. References _bottomRight, _topLeft, bottomRight(), and topLeft(). Referenced by operator!=(). |
|
|
Same as function qgar::BoundingBox::NotEq.
Definition at line 778 of file BoundingBox.H. References notEq(). |
|
|
Assign the given bounding box to the current bounding box.
Definition at line 558 of file BoundingBox.C. References _bottomRight, and _topLeft. |
|
|
Same as function qgar::BoundingBox::eq.
Definition at line 769 of file BoundingBox.H. References eq(). |
|
|
Deserializes the current box from an input stream. A serialized bounding box is represented as: BoundingBox(<TOP LEFT CORNER>)(<BOTTOM RIGHT CORNER>)
Implements qgar::ISerializable. Definition at line 601 of file BoundingBox.C. References qgar::qgReadObjData(), qgar::qgReadObjName(), and setCorners(). |
|
||||||||||||
|
Set bottom right corner using X and Y coordinates.
Definition at line 330 of file BoundingBox.C. |
|
|
Set bottom right corner using a point.
Definition at line 304 of file BoundingBox.C. |
|
||||||||||||||||||||
|
Set both top left and bottom right corners from coordinates of two points. The two given points are supposed to be two opposite corners (top left and bottom right, or top right and bottom left) of the resulting bounding box. The corresponding coordinates of top left and bottom right corners are automatically computed.
Definition at line 419 of file BoundingBox.C. References _bottomRight, _topLeft, and qgar::GenPoint< T >::setXY(). |
|
||||||||||||
|
Set both top left and bottom right corners from two points. The two given points, aPt1 and aPt2, are supposed to be two opposite corners (top left and bottom right, or top right and bottom left) of the resulting bounding box. The corresponding coordinates of top left and bottom right corners are automatically computed.
Definition at line 410 of file BoundingBox.C. References qgar::GenPoint< T >::x(), and qgar::GenPoint< T >::y(). Referenced by BoundingBox(), and read(). |
|
||||||||||||
|
Set top left corner using X and Y coordinates.
Definition at line 223 of file BoundingBox.C. |
|
|
Set top left corner using a point.
Definition at line 197 of file BoundingBox.C. |
|
|
Set X coordinate of bottom right corner.
Definition at line 356 of file BoundingBox.C. |
|
|
Set X coordinate of top left corner.
Definition at line 250 of file BoundingBox.C. |
|
|
Set Y coordinate of bottom right corner.
Definition at line 383 of file BoundingBox.C. |
|
|
Set Y coordinate of top left corner.
Definition at line 277 of file BoundingBox.C. |
|
|
Get a copy of the top left corner.
Definition at line 631 of file BoundingBox.H. References _topLeft. Referenced by contains(), eq(), and notEq(). |
|
|
Get width.
Definition at line 713 of file BoundingBox.H. References _bottomRight, _topLeft, and qgar::GenPoint< T >::x(). Referenced by length(), and qgar::TTBinaryImage::TTBinaryImage(). |
|
|
Serializes the current box to an input stream. A serialized bounding boxi is represented as: BoundingBox(<TOP LEFT CORNER>)(<BOTTOM RIGHT CORNER>)
Implements qgar::ISerializable. Definition at line 616 of file BoundingBox.C. References _bottomRight, and _topLeft. |
|
|
Get X coordinate of bottom right corner.
Definition at line 681 of file BoundingBox.H. References _bottomRight, and qgar::GenPoint< T >::x(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), intersection(), intersects(), qgar::Component::PRIVATEcomputeContour(), qgar::TgifFile::write(), and qgar::DxfFile::write(). |
|
|
Get X coordinate of top left corner.
Definition at line 663 of file BoundingBox.H. References _topLeft, and qgar::GenPoint< T >::x(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), intersection(), intersects(), qgar::Component::PRIVATEcomputeContour(), qgar::TTBinaryImage::TTBinaryImage(), qgar::TgifFile::write(), and qgar::DxfFile::write(). |
|
|
Get Y coordinate of bottom right corner.
Definition at line 690 of file BoundingBox.H. References _bottomRight, and qgar::GenPoint< T >::y(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), intersection(), intersects(), qgar::Component::PRIVATEcomputeContour(), qgar::TgifFile::write(), and qgar::DxfFile::write(). |
|
|
Get Y coordinate of top left corner.
Definition at line 672 of file BoundingBox.H. References _topLeft, and qgar::GenPoint< T >::y(). Referenced by qgar::GenImage< T, CheckPolicy >::GenImage(), intersection(), intersects(), qgar::Component::PRIVATEcomputeContour(), qgar::TgifFile::write(), and qgar::DxfFile::write(). |
|
|
Bottom right corner.
Definition at line 596 of file BoundingBox.H. Referenced by accessBottomRight(), bottomRight(), contains(), eq(), height(), intersection(), intersects(), notEq(), operator=(), setCorners(), width(), write(), xBottomRight(), and yBottomRight(). |
|
|
Top left corner.
Definition at line 591 of file BoundingBox.H. Referenced by accessTopLeft(), contains(), eq(), height(), intersection(), intersects(), notEq(), operator=(), setCorners(), topLeft(), width(), write(), xTopLeft(), and yTopLeft(). |