|
libcrn
3.9.5
A document image processing library
|
A rectangle class. More...
#include <CRNRect.h>
Inheritance diagram for crn::Rect:
Collaboration diagram for crn::Rect:Classes | |
| class | AreaSorter |
| Functor to sort rectangles regarding surfaces. More... | |
| struct | BitwiseCompare |
| Functor to sort Rects in sets and maps. More... | |
| class | HeightSorter |
| Functor to sort rectangles regarding surfaces. More... | |
| class | HorizontalStretchingSorter |
| Functor to sort rectangles regarding horizontal stretching values. More... | |
| class | InclusionSorter |
| Functor to sort rectangles by inclusion. More... | |
| class | iterator |
| iterator for a Rect More... | |
| class | OrthogonalSorter |
| Functor to sort rectangles regarding orthogonal directions. More... | |
| class | Sorter |
| Functor to sort rectangles regarding directions. More... | |
| class | spiral_iterator |
| Spiral iterator for a Rect. More... | |
Public Types | |
| using | Set = std::set< Rect, Rect::BitwiseCompare > |
| A set of Rects. More... | |
Public Member Functions | |
| Rect () noexcept | |
| Dummy constructor. DO NOT USE. More... | |
| Rect (int begX, int begY, int endX, int endY) noexcept | |
| Rectangle constructor. More... | |
| Rect (int x, int y) noexcept | |
| Rectangle constructor. More... | |
| Rect (const Point2DInt &p) noexcept | |
| Rectangle constructor. More... | |
| Rect (const Rect &)=default | |
| Rect (Rect &&)=default | |
| virtual | ~Rect () override=default |
| Rect & | operator= (const Rect &)=default |
| Rect & | operator= (Rect &&)=default |
| bool | operator== (const Rect &r) const noexcept |
| Checks if two rectangles are identical. More... | |
| bool | operator!= (const Rect &r) const noexcept |
| Checks if two rectangles are different. More... | |
| bool | IsValid () const noexcept |
| Returns whether the rect is valid. More... | |
| int | GetLeft () const |
| Returns the leftmost coordinate. More... | |
| int | GetRight () const |
| Returns the rightmost coordinate. More... | |
| int | GetTop () const |
| Returns the topmost coordinate. More... | |
| int | GetBottom () const |
| Returns the bottommost coordinate. More... | |
| int | GetWidth () const |
| Returns the width of the rectangle. More... | |
| int | GetHeight () const |
| Returns the height of the rectangle. More... | |
| Point2DInt | GetTopLeft () const |
| Returns the top-left coordinates. More... | |
| Point2DInt | GetBottomRight () const |
| Returns the bottom-right coordinates. More... | |
| Point2DInt | GetCenter () const |
| Returns the center coordinates. More... | |
| int | GetCenterX () const |
| Returns the horizontal center coordinate. More... | |
| int | GetCenterY () const |
| Returns the vertical center coordinate. More... | |
| unsigned int | GetArea () const noexcept |
| Returns the area of the rectangle. More... | |
| unsigned int | GetPerimeter () const noexcept |
| Returns the perimeter of the rectangle. More... | |
| int | SetLeft (int begX) noexcept |
| Changes the leftmost coordinate. More... | |
| int | SetRight (int endX) noexcept |
| Changes the rightmost coordinate. More... | |
| int | SetTop (int begY) noexcept |
| Changes the topmost coordinate. More... | |
| int | SetBottom (int endY) noexcept |
| Changes the bottommost coordinate. More... | |
| int | SetWidth (int wid) |
| Changes the width of the rectangle. More... | |
| int | SetHeight (int hei) |
| Changes the height of the rectangle. More... | |
| int | Overlap (const Rect &r, Orientation orientation) const |
| Compute overlap in a given orientation. More... | |
| Rect | operator& (const Rect &r) const |
| Computes the intersection of two rectangles. More... | |
| Rect | operator| (const Rect &r) const |
| Computes the union of two rectangles. More... | |
| void | operator&= (const Rect &r) |
| Keeps only the intersecting part with another rectangle. More... | |
| void | operator|= (const Rect &r) |
| Merges with another rectangle. More... | |
| bool | Contains (int x, int y) const noexcept |
| Checks if the rectangle contains a point. More... | |
| bool | Contains (const Rect &rct) const |
| Checks if the rectangle contains another rectangle. More... | |
| const Rect & | operator*= (double s) |
| Scales the rectangle. More... | |
| Rect | operator* (double s) const |
| Creates a scaled rectangle. More... | |
| void | Translate (int x, int y) |
| Translates the rectangle. More... | |
| template<class ITER > | |
| std::vector< Rect > | FindIncluded (ITER it_begin, ITER it_end) |
| Get the rectangles included in this. More... | |
| template<class ITER > | |
| std::vector< Rect > | FindIntersecting (ITER it_begin, ITER it_end, double ratio=0) |
| Get the rectangles intersecting significantly this from a collection. More... | |
| String | ToString () const |
| Dumps to a string. More... | |
| iterator | begin () const |
| Returns an iterator to the first point of the rectangle. More... | |
| iterator | end () const |
| Returns an iterator after the last point of the rectangle. More... | |
| iterator | cbegin () const |
| Returns an iterator to the first point of the rectangle. More... | |
| iterator | cend () const |
| Returns an iterator after the last point of the rectangle. More... | |
| spiral_iterator | SBegin () const |
| Returns an spiral iterator to the first point of the rectangle. More... | |
| spiral_iterator | SEnd () const |
| Returns an spiral iterator after the last point of the rectangle. More... | |
| void | Deserialize (xml::Element &el) |
| Initializes the object from an XML element. Unsafe. More... | |
| xml::Element | Serialize (xml::Element &parent) const |
| Dumps the object to an XML element. Unsafe. More... | |
Public Member Functions inherited from crn::Object | |
| virtual | ~Object ()=default |
Static Public Member Functions | |
| template<class ITER > | |
| static Rect | SmallestRectEmbedding (ITER it_begin, ITER it_end) |
| Get the smallest rectangle embedding a collection of rectangles. More... | |
| template<class ITER > | |
| static int | MedianWidth (ITER it_begin, ITER it_end) |
| Get median width value for a collection of rectangles. More... | |
| template<class ITER > | |
| static int | MedianHeight (ITER it_begin, ITER it_end) |
| Get median height value for a collection of rectangles. More... | |
| template<class ITER > | |
| static double | MeanWidth (ITER it_begin, ITER it_end) |
| Get average width value for a collection of rectangles. More... | |
| template<class ITER > | |
| static double | MeanHeight (ITER it_begin, ITER it_end) |
| Get median height value for a collection of rectangles. More... | |
| template<class ITER > | |
| static std::vector< Rect > | FindClosestsToBorder (ITER it_begin, ITER it_end, Direction drt) |
| Get rectangles closest to border in a direction from a collection of rectangles. More... | |
| static Set | EmptySet () |
| Creates an empty set of Rects. More... | |
A rectangle class.
class CRNRect Convenience rectangle class. Uses signed int.
| using crn::Rect::Set = std::set<Rect, Rect::BitwiseCompare> |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
default |
|
default |
|
overridevirtualdefault |
|
inline |
|
inline |
|
inline |
|
noexcept |
Checks if the rectangle contains a point.
Checks if the rectangle contains a point
| [in] | x | the abscissa |
| [in] | y | the ordinate |
Definition at line 514 of file CRNRect.cpp.
| bool Rect::Contains | ( | const Rect & | rct | ) | const |
Checks if the rectangle contains another rectangle.
Checks if the rectangle contains another rectangle
| [in] | rct | the possibly contained rectangle |
Definition at line 533 of file CRNRect.cpp.
| void Rect::Deserialize | ( | xml::Element & | el | ) |
Initializes the object from an XML element. Unsafe.
Initializes the object from an XML element. Unsafe.
| ExceptionInvalidArgument | not a Rect |
| [in] | el | the XML element to read |
Definition at line 550 of file CRNRect.cpp.
|
inlinestatic |
|
inline |
|
inlinestatic |
Get rectangles closest to border in a direction from a collection of rectangles.
Get rectangles closest to border in a given direction from a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
| [in] | drt | The reference direction |
|
inline |
|
inline |
Get the rectangles intersecting significantly this from a collection.
Get the rectangles intersecting significantly this from a collection
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
| [in] | ratio | The intersection significance threshold |
|
inlinenoexcept |
|
inline |
Returns the bottommost coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the bottom-right coordinates.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the center coordinates.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the horizontal center coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the vertical center coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the height of the rectangle.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the leftmost coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inlinenoexcept |
|
inline |
Returns the rightmost coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the topmost coordinate.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the top-left coordinates.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inline |
Returns the width of the rectangle.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inlinenoexcept |
|
inlinestatic |
Get median height value for a collection of rectangles.
Get median height value for a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
|
inlinestatic |
Get average width value for a collection of rectangles.
Get median width value for a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
|
inlinestatic |
Get median height value for a collection of rectangles.
Get median height value for a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
|
inlinestatic |
Get median width value for a collection of rectangles.
Get median width value for a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
|
noexcept |
Checks if two rectangles are different.
Checks if two rectangles are different
| [in] | r | The rectangle to check |
Definition at line 56 of file CRNRect.cpp.
Computes the intersection of two rectangles.
Computes the intersection of two rectangles
| [in] | r | The rectangle to intersect |
Definition at line 74 of file CRNRect.cpp.
| void Rect::operator&= | ( | const Rect & | r | ) |
Keeps only the intersecting part with another rectangle.
Keeps only the intersecting part with another rectangle
| [in] | r | The intersecting rectangle |
Definition at line 147 of file CRNRect.cpp.
| Rect Rect::operator* | ( | double | s | ) | const |
Creates a scaled rectangle.
Creates a scaled rectangle
| ExceptionUninitialized | uninitialized rectangle |
| ExceptionInvalidArgument | negative scale |
| [in] | s | the scale |
Definition at line 460 of file CRNRect.cpp.
| const Rect & Rect::operator*= | ( | double | s | ) |
Scales the rectangle.
Scales the rectangle
| ExceptionUninitialized | uninitialized rectangle |
| ExceptionInvalidArgument | negative scale |
| [in] | s | the scale |
Definition at line 436 of file CRNRect.cpp.
|
noexcept |
Checks if two rectangles are identical.
Checks if two rectangles are identical
| [in] | r | The rectangle to check |
Definition at line 38 of file CRNRect.cpp.
Computes the union of two rectangles.
Computes the union of two rectangles
| [in] | r | The rectangle to unite |
Definition at line 124 of file CRNRect.cpp.
| void Rect::operator|= | ( | const Rect & | r | ) |
Merges with another rectangle.
Merges with another rectangle
| [in] | r | The rectangle to merge |
Definition at line 178 of file CRNRect.cpp.
| int Rect::Overlap | ( | const Rect & | r, |
| Orientation | orientation | ||
| ) | const |
Compute overlap in a given orientation.
Computes overlap of with another rectangle in a given orientation
| ExceptionInvalidArgument | no orientation given |
| [in] | r | The other rectangle |
| [in] | orientation | the orientation in which the overlapping is considered |
Definition at line 101 of file CRNRect.cpp.
|
inline |
|
inline |
| xml::Element Rect::Serialize | ( | xml::Element & | parent | ) | const |
Dumps the object to an XML element. Unsafe.
Dumps the object to an XML element. Unsafe.
| [in] | parent | the element in which the new element will be stored |
Definition at line 579 of file CRNRect.cpp.
|
inlinenoexcept |
|
inline |
Changes the height of the rectangle.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Changes the width of the rectangle.
| ExceptionUninitialized | the rectangle is not properly initialized |
|
inlinestatic |
Get the smallest rectangle embedding a collection of rectangles.
Get the smallest rectangle embedding a collection of rectangles
| [in] | it_begin | The iterator pointing to the begining of the collection |
| [in] | it_end | The iterator pointing to the end of the collection |
| String Rect::ToString | ( | ) | const |
Dumps to a string.
Creates a string with the coordiantes of the rectangle
Definition at line 206 of file CRNRect.cpp.
| void Rect::Translate | ( | int | x, |
| int | y | ||
| ) |
Translates the rectangle.
Translates the rectangle
| ExceptionUninitialized | the rectangle is not properly initialized |
| [in] | x | the x translation term |
| [in] | y | the y translation term |
Definition at line 598 of file CRNRect.cpp.
1.8.6