Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub | SourceForge
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;

    cv::Rect cvRect;
    Rect simdRect;

    simdRect = cvRect;
    cvRect = simdRect;

    return 0;
}

Related Functions.

Member Typedef Documentation

◆ Type

typedef T Type

Type definition.

Constructor & Destructor Documentation

◆ Rectangle() [1/6]

SIMD_INLINE Rectangle ( )

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

◆ Rectangle() [2/6]

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() [3/6]

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() [4/6]

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() [5/6]

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() [6/6]

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.

◆ ~Rectangle()

SIMD_INLINE ~Rectangle ( )

A rectangle destructor.

Member Function Documentation

◆ operator TRectangle< TR >()

operator TRectangle< TR > ( ) const

Converts itself to rectangle of arbitrary type.

Returns
a rectangle of arbitrary type.

◆ operator cv::Rect_< TR >()

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.

◆ operator=() [1/2]

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.

◆ operator=() [2/2]

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.

◆ SetLeft()

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.

◆ SetTop()

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.

◆ SetRight()

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.

◆ SetBottom()

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.

◆ SetTopLeft()

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.

◆ SetTopRight()

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.

◆ SetBottomLeft()

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.

◆ SetBottomRight()

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.

◆ Left()

SIMD_INLINE T Left ( ) const

Gets position of left side.

Returns
a position of left side.

◆ Top()

SIMD_INLINE T Top ( ) const

Gets position of top side.

Returns
a position of top side.

◆ Right()

SIMD_INLINE T Right ( ) const

Gets position of right side.

Returns
a position of right side.

◆ Bottom()

SIMD_INLINE T Bottom ( ) const

Gets position of bottom side.

Returns
a position of bottom side.

◆ TopLeft()

SIMD_INLINE Point< T > TopLeft ( ) const

Gets coordinates of top-left corner.

Returns
a point with coordinates of top-left corner.

◆ TopRight()

SIMD_INLINE Point< T > TopRight ( ) const

Gets coordinates of top-right corner.

Returns
a point with coordinates of top-right corner.

◆ BottomLeft()

SIMD_INLINE Point< T > BottomLeft ( ) const

Gets coordinates of bottom-left corner.

Returns
a point with coordinates of bottom-left corner.

◆ BottomRight()

SIMD_INLINE Point< T > BottomRight ( ) const

Gets coordinates of bottom-right corner.

Returns
a point with coordinates of bottom-right corner.

◆ Width()

SIMD_INLINE T Width ( ) const

Gets rectangle width.

Returns
a rectangle width.

◆ Height()

SIMD_INLINE T Height ( ) const

Gets rectangle height.

Returns
a rectangle height.

◆ Area()

SIMD_INLINE T Area ( ) const

Gets rectangle area.

Returns
a rectangle area.

◆ Empty()

SIMD_INLINE bool Empty ( ) const

Returns true if rectangle area is equal to zero.

Returns
a boolean value.

◆ Size()

SIMD_INLINE Point< T > Size ( ) const

Gets size (width and height) of the rectangle.

Returns
a point with rectangle size.

◆ Center()

SIMD_INLINE Point< T > Center ( ) const

Gets coordinates of rectangle center.

Returns
a point with coordinates of rectangle center.

◆ Contains() [1/4]

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.

◆ Contains() [2/4]

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.

◆ Contains() [3/4]

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.

◆ Contains() [4/4]

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.

◆ Shift() [1/2]

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.

◆ Shift() [2/2]

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.

◆ Shifted() [1/2]

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.

◆ Shifted() [2/2]

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.

◆ AddBorder()

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.

◆ Intersection()

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.

◆ operator&=() [1/2]

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.

◆ operator&=() [2/2]

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.

◆ operator|=() [1/2]

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.

◆ operator|=() [2/2]

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.

◆ operator+=()

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.

◆ Overlaps()

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.