Simd Library Documentation.

Home | Release Notes | Download | Documentation | Forum | SourceForge | GitHub
Rectangle< T > Struct Template Reference

The Rectangle structure defines the positions of left, top, right and bottom sides of a rectangle. More...

Public Types

typedef T Type
 

Public Member Functions

 Rectangle ()
 
template<typename TL , typename TT , typename TR , typename TB >
 Rectangle (TL l, TT t, TR r, TB b)
 
template<typename TLT , typename TRB >
 Rectangle (const Point< TLT > &lt, const Point< TRB > &rb)
 
template<typename TRB >
 Rectangle (const Point< TRB > &rb)
 
template<class TR , template< class > class TRectangle>
 Rectangle (const TRectangle< TR > &r)
 
template<class TR >
 Rectangle (const cv::Rect_< TR > &r)
 
 ~Rectangle ()
 
template<class TR , template< class > class TRectangle>
 operator TRectangle< TR > () const
 
template<class TR >
 operator cv::Rect_< TR > () const
 
template<typename TR >
Rectangle< T > & operator= (const Rectangle< TR > &r)
 
template<typename TR >
Rectangle< T > & operator= (const cv::Rect_< TR > &r)
 
template<typename TL >
Rectangle< T > & SetLeft (const TL &l)
 
template<typename TT >
Rectangle< T > & SetTop (const TT &t)
 
template<typename TR >
Rectangle< T > & SetRight (const TR &r)
 
template<typename TB >
Rectangle< T > & SetBottom (const TB &b)
 
template<typename TP >
Rectangle< T > & SetTopLeft (const Point< TP > &topLeft)
 
template<typename TP >
Rectangle< T > & SetTopRight (const Point< TP > &topRight)
 
template<typename TP >
Rectangle< T > & SetBottomLeft (const Point< TP > &bottomLeft)
 
template<typename TP >
Rectangle< T > & SetBottomRight (const Point< TP > &bottomRight)
 
Left () const
 
Top () const
 
Right () const
 
Bottom () const
 
Point< T > TopLeft () const
 
Point< T > TopRight () const
 
Point< T > BottomLeft () const
 
Point< T > BottomRight () const
 
Width () const
 
Height () const
 
Area () const
 
bool Empty () const
 
Point< T > Size () const
 
Point< T > Center () const
 
template<typename TX , typename TY >
bool Contains (TX x, TY y) const
 
template<typename TP >
bool Contains (const Point< TP > &p) const
 
template<typename TL , typename TT , typename TR , typename TB >
bool Contains (TL l, TT t, TR r, TB b) const
 
template<typename TR >
bool Contains (const Rectangle< TR > &r) const
 
template<typename TP >
Rectangle< T > & Shift (const Point< TP > &shift)
 
template<typename TX , typename TY >
Rectangle< T > & Shift (TX shiftX, TY shiftY)
 
template<typename TP >
Rectangle< T > Shifted (const Point< TP > &shift) const
 
template<typename TX , typename TY >
Rectangle< T > Shifted (TX shiftX, TY shiftY) const
 
template<typename TB >
Rectangle< T > & AddBorder (TB border)
 
template<typename TR >
Rectangle< T > Intersection (const Rectangle< TR > &r) const
 
template<typename TP >
Rectangle< T > & operator&= (const Point< TP > &p)
 
template<typename TR >
Rectangle< T > & operator&= (const Rectangle< TR > &r)
 
template<typename TP >
Rectangle< T > & operator|= (const Point< TP > &p)
 
template<typename TR >
Rectangle< T > & operator|= (const Rectangle< TR > &r)
 
template<typename TR >
Rectangle< T > & operator+= (const Rectangle< TR > &r)
 
bool Overlaps (const Rectangle< T > &r) const
 

Data Fields

left
 Specifies the position of left side of a rectangle.
 
top
 Specifies the position of top side of a rectangle.
 
right
 Specifies the position of right side of a rectangle.
 
bottom
 Specifies the position of bottom side of a rectangle.
 

Detailed Description

template<typename T>
struct Simd::Rectangle< T >

The Rectangle structure defines the positions of left, top, right and bottom sides of a rectangle.

In order to have mutual conversion with OpenCV rectangle you have to define macro SIMD_OPENCV_ENABLE:

    #include "opencv2/core/core.hpp"
    #define SIMD_OPENCV_ENABLE
    #include "Simd/SimdRectangle.hpp"

    int main()
    {
        typedef Simd::Rectangle<ptrdiff_t> Rect;
        Rect rect = cv::Rect(10, 10, 20, 20);
        cv::Rect cvRect = Rect(10, 10, 30, 30);
        return 0;
    }

Related Functions.

Member Typedef Documentation

typedef T Type

Type definition.

Constructor & Destructor Documentation

SIMD_INLINE Rectangle ( )

Creates a new Rectangle structure that contains the default (0, 0, 0, 0) positions of its sides.

Rectangle ( TL  l,
TT  t,
TR  r,
TB  b 
)

Creates a new Rectangle structure that contains the specified positions of its sides.

Parameters
[in]l- initial left value.
[in]t- initial top value.
[in]r- initial right value.
[in]b- initial bottom value.
Rectangle ( const Point< TLT > &  lt,
const Point< TRB > &  rb 
)

Creates a new Rectangular structure that contains the specified coordinates of its left-top and right-bottom corners.

Parameters
[in]lt- initial coordinates of left-top corner.
[in]rb- initial coordinates of right-bottom corner.
Rectangle ( const Point< TRB > &  rb)

Creates a new Rectangular structure that contains the specified coordinates of its right-bottom corner. The coordinates of left-top corner is set to (0, 0).

Parameters
[in]rb- initial coordinates of right-bottom corner.
Rectangle ( const TRectangle< TR > &  r)

Creates a new Rectangle structure on the base of another rectangle of arbitrary type.

Parameters
[in]r- a rectangle of arbitrary type.
Rectangle ( const cv::Rect_< TR > &  r)

Creates a new Rectangle structure on the base of OpenCV rectangle.

Note
You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
Parameters
[in]r- an OpenCV rectangle.
SIMD_INLINE ~Rectangle ( )

A rectangle destructor.

Member Function Documentation

operator TRectangle< TR > ( ) const

Converts itself to rectangle of arbitrary type.

Returns
a rectangle of arbitrary type.
operator cv::Rect_< TR > ( ) const

Converts itself to OpenCV rectangle.

Note
You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
Returns
an OpenCV rectangle.
Rectangle<T>& operator= ( const Rectangle< TR > &  r)

Performs copying from rectangle of arbitrary type.

Parameters
[in]r- a rectangle of arbitrary type.
Returns
a reference to itself.
Rectangle<T>& operator= ( const cv::Rect_< TR > &  r)

Performs copying from OpenCV rectangle.

Note
You have to define SIMD_OPENCV_ENABLE in order to use this functionality.
Parameters
[in]r- an OpenCV rectangle.
Returns
a reference to itself.
Rectangle<T>& SetLeft ( const TL &  l)

Sets position of left side.

Parameters
[in]l- a new position of left side.
Returns
a reference to itself.
Rectangle<T>& SetTop ( const TT &  t)

Sets position of top side.

Parameters
[in]t- a new position of top side.
Returns
a reference to itself.
Rectangle<T>& SetRight ( const TR &  r)

Sets position of right side.

Parameters
[in]r- a new position of right side.
Returns
a reference to itself.
Rectangle<T>& SetBottom ( const TB &  b)

Sets position of bottom side.

Parameters
[in]b- a new position of bottom side.
Returns
a reference to itself.
Rectangle<T>& SetTopLeft ( const Point< TP > &  topLeft)

Sets coordinates of top-left corner.

Parameters
[in]topLeft- a new coordinates of top-left corner.
Returns
a reference to itself.
Rectangle<T>& SetTopRight ( const Point< TP > &  topRight)

Sets coordinates of top-right corner.

Parameters
[in]topRight- a new coordinates of top-right corner.
Returns
a reference to itself.
Rectangle<T>& SetBottomLeft ( const Point< TP > &  bottomLeft)

Sets coordinates of bottom-left corner.

Parameters
[in]bottomLeft- a new coordinates of bottom-left corner.
Returns
a reference to itself.
Rectangle<T>& SetBottomRight ( const Point< TP > &  bottomRight)

Sets coordinates of bottom-right corner.

Parameters
[in]bottomRight- a new coordinates of bottom-right corner.
Returns
a reference to itself.
SIMD_INLINE T Left ( ) const

Gets position of left side.

Returns
a position of left side.
SIMD_INLINE T Top ( ) const

Gets position of top side.

Returns
a position of top side.
SIMD_INLINE T Right ( ) const

Gets position of right side.

Returns
a position of right side.
SIMD_INLINE T Bottom ( ) const

Gets position of bottom side.

Returns
a position of bottom side.
SIMD_INLINE Point< T > TopLeft ( ) const

Gets coordinates of top-left corner.

Returns
a point with coordinates of top-left corner.
SIMD_INLINE Point< T > TopRight ( ) const

Gets coordinates of top-right corner.

Returns
a point with coordinates of top-right corner.
SIMD_INLINE Point< T > BottomLeft ( ) const

Gets coordinates of bottom-left corner.

Returns
a point with coordinates of bottom-left corner.
SIMD_INLINE Point< T > BottomRight ( ) const

Gets coordinates of bottom-right corner.

Returns
a point with coordinates of bottom-right corner.
SIMD_INLINE T Width ( ) const

Gets rectangle width.

Returns
a rectangle width.
SIMD_INLINE T Height ( ) const

Gets rectangle height.

Returns
a rectangle height.
SIMD_INLINE T Area ( ) const

Gets rectangle area.

Returns
a rectangle area.
SIMD_INLINE bool Empty ( ) const

Returns true if rectangle area is equal to zero.

Returns
a boolean value.
SIMD_INLINE Point< T > Size ( ) const

Gets size (width and height) of the rectangle.

Returns
a point with rectangle size.
SIMD_INLINE Point< T > Center ( ) const

Gets coordinates of rectangle center.

Returns
a point with coordinates of rectangle center.
bool Contains ( TX  x,
TY  y 
) const

Checks on the point with specified coordinates to belonging to the rectangle.

Parameters
[in]x- x-coordinate of checked point.
[in]y- y-coordinate of checked point.
Returns
a result of checking.
bool Contains ( const Point< TP > &  p) const

Checks on the point to belonging to the rectangle.

Parameters
[in]p- a checked point.
Returns
a result of checking.
bool Contains ( TL  l,
TT  t,
TR  r,
TB  b 
) const

Checks on the rectangle with specified coordinates to belonging to the rectangle.

Parameters
[in]l- a left side of checked rectangle.
[in]t- a top side of checked rectangle.
[in]r- a right side of checked rectangle.
[in]b- a bottom side of checked rectangle.
Returns
a result of checking.
bool Contains ( const Rectangle< TR > &  r) const

Checks on the rectangle to belonging to the rectangle.

Parameters
[in]r- a checked rectangle.
Returns
a result of checking.
Rectangle<T>& Shift ( const Point< TP > &  shift)

Shifts a rectangle on the specific value.

Parameters
[in]shift- a point with shift value.
Returns
a reference to itself.
Rectangle<T>& Shift ( TX  shiftX,
TY  shiftY 
)

Shifts a rectangle on the specific value.

Parameters
[in]shiftX- x-coordinate of the shift.
[in]shiftY- y-coordinate of the shift.
Returns
a reference to itself.
Rectangle<T> Shifted ( const Point< TP > &  shift) const

Gets a rectangle with shifted coordinates.

Parameters
[in]shift- a point with shift value.
Returns
a shifted rectangle.
Rectangle<T> Shifted ( TX  shiftX,
TY  shiftY 
) const

Gets a rectangle with shifted coordinates.

Parameters
[in]shiftX- x-coordinate of the shift.
[in]shiftY- y-coordinate of the shift.
Returns
a shifted rectangle.
Rectangle<T>& AddBorder ( TB  border)

Adds border to rectangle.

Note
The value of border can be negative.
Parameters
[in]border- a width of added border.
Returns
a reference to itself.
Rectangle<T> Intersection ( const Rectangle< TR > &  r) const

Gets an intersection of the two rectangles (current and specified).

Parameters
[in]r- specified rectangle.
Returns
a rectangle with result of intersection.
Rectangle<T>& operator&= ( const Point< TP > &  p)

Sets to the rectangle results of the intersection of the rectangle and specified point.

Parameters
[in]p- specified point.
Returns
a reference to itself.
Rectangle<T>& operator&= ( const Rectangle< TR > &  r)

Sets to the rectangle results of the intersection of the rectangle and specified rectangle.

Parameters
[in]r- specified rectangle.
Returns
a reference to itself.
Rectangle<T>& operator|= ( const Point< TP > &  p)

Sets to the rectangle results of the union of the rectangle and specified point.

Parameters
[in]p- specified point.
Returns
a reference to itself.
Rectangle<T>& operator|= ( const Rectangle< TR > &  r)

Sets to the rectangle results of the union of the rectangle and specified rectangle.

Parameters
[in]r- specified rectangle.
Returns
a reference to itself.
Rectangle<T>& operator+= ( const Rectangle< TR > &  r)

Adds to the rectangle's coordinates corresponding coordinates of specified rectangle.

Parameters
[in]r- specified rectangle.
Returns
a reference to itself.
SIMD_INLINE bool Overlaps ( const Rectangle< T > &  r) const

Checks on overlapping of current rectangle and specified rectangle.

Parameters
[in]r- specified rectangle.
Returns
a result of checking.