Instigate Open Source Documentation

instigate::geometry::rectangle Class Reference

Rectangle in 2-dimensional plane, with edges parallel to axes. More...

#include <rectangle.hpp>

List of all members.

Public Member Functions

Special member functions



 ~rectangle () throw ()
 Destructor.
 rectangle () throw ()
 Default constructor.
 rectangle (coordinate_type l, coordinate_type b, coordinate_type r, coordinate_type t) throw ()
 Create rectangle with given coordinates.
 rectangle (const rectangle &r) throw ()
 Copy constructor.
template<typename R >
 rectangle (const R &r)
 Generic copy constructor.
rectangleoperator= (const rectangle &r) throw ()
 operator =
template<typename R >
rectangleoperator= (const R &r)
 Template assignment operator.

Coordinates of the rectangle



typedef point::coordinate_type coordinate_type
coordinate_type get_left () const throw ()
 Returns the left coordinate (x1) of the rectangle.
coordinate_type get_bottom () const throw ()
 Returns the bottom coordinate (y1) of the rectangle.
coordinate_type get_right () const throw ()
 Returns the right coordinate (x2) of the rectangle.
coordinate_type get_top () const throw ()
 Returns the top coordinate (y2) of the rectangle.
void set_left (const coordinate_type &l) throw ()
 Sets the left coordinate of the rectangle.
void set_bottom (const coordinate_type &b) throw ()
 Sets the bottom coordinate of the rectangle.
void set_right (const coordinate_type &r) throw ()
 Sets the right coordinate of the rectangle.
void set_top (const coordinate_type &t) throw ()
 Sets the top coordinate of the rectangle.

Detailed Description

Rectangle in 2-dimensional plane, with edges parallel to axes.

This class is a model of geometry::concept::rectangle


Member Typedef Documentation

coordinate type is same as for instigate::geometry::point


Constructor & Destructor Documentation

instigate::geometry::rectangle::rectangle ( coordinate_type  l,
coordinate_type  b,
coordinate_type  r,
coordinate_type  t 
) throw () [inline]

Create rectangle with given coordinates.

Parameters:
l is the left coordinate (x1)
b is the bottom coordinate (y1)
r is the right coordinate (x2)
t is the right coordinate (y2)
instigate::geometry::rectangle::rectangle ( const rectangle r  )  throw ()

Copy constructor.

Parameters:
r - object to copy from
template<typename R >
instigate::geometry::rectangle::rectangle ( const R &  r  )  [inline]

Generic copy constructor.

Parameters:
r - rectangle object
Precondition:
R must be model of instigate::geometry::concept::rectangle
coordinate type of R must be convertible to instigate::geometry::rectangle::coordinate_type

Member Function Documentation

coordinate_type instigate::geometry::rectangle::get_bottom (  )  const throw ()

Returns the bottom coordinate (y1) of the rectangle.

Precondition:
get_left(this) <= get_right(this)
get_bottom(this) <= get_top(this)
Postcondition:
get_bottom(this) <= get_top(this)

Referenced by operator=().

coordinate_type instigate::geometry::rectangle::get_left (  )  const throw ()

Returns the left coordinate (x1) of the rectangle.

Precondition:
get_left(this) <= get_right(this)
get_bottom(this) <= get_top(this)
Postcondition:
get_left(this) <= get_right(this)

Referenced by operator=().

coordinate_type instigate::geometry::rectangle::get_right (  )  const throw ()

Returns the right coordinate (x2) of the rectangle.

Precondition:
get_left(this) <= get_right(this)
get_bottom(this) <= get_top(this)
Postcondition:
get_left(this) <= get_right(this)

Referenced by operator=().

coordinate_type instigate::geometry::rectangle::get_top (  )  const throw ()

Returns the top coordinate (y2) of the rectangle.

Precondition:
get_left(this) <= get_right(this)
get_bottom(this) <= get_top(this)
Postcondition:
get_bottom(this) <= get_top(this)

Referenced by operator=().

template<typename R >
rectangle& instigate::geometry::rectangle::operator= ( const R &  r  )  [inline]

Template assignment operator.

Parameters:
r - object to copy from
Precondition:
The type R must be a model of concept geometry::concept::rectangle

References CHECK, get_bottom(), get_left(), get_right(), and get_top().

rectangle& instigate::geometry::rectangle::operator= ( const rectangle r  )  throw ()

operator =

Parameters:
r - object to copy from
void instigate::geometry::rectangle::set_bottom ( const coordinate_type b  )  throw ()

Sets the bottom coordinate of the rectangle.

Parameters:
b - the new value for the bottom coordinate
Postcondition:
get_bottom(this) == b
Remarks:
The condition bottom <= top is not asserted here in order to allow temporarily making invalid rectangles for sake of efficiency. It is user's responsibility to ensure this pre-condition holds, because in many other algorithms the assertion is present, and if it fires somewhere else it will be very hard to find out where was this condition violated.
Complexity
O(1)
void instigate::geometry::rectangle::set_left ( const coordinate_type l  )  throw ()

Sets the left coordinate of the rectangle.

Parameters:
l - the new value for the left coordinate
Postcondition:
get_left(this) == l
Remarks:
The condition rigth >= left is not asserted here in order to allow temporarily making invalid rectangles for sake of efficiency. It is user's responsibility to ensure this pre-condition holds, because in many other algorithms the assertion is present, and if it fires somewhere else it will be very hard to find out where was this condition violated.
Complexity
O(1)
void instigate::geometry::rectangle::set_right ( const coordinate_type r  )  throw ()

Sets the right coordinate of the rectangle.

Parameters:
r - the new value for the right coordinate
Postcondition:
get_right(this) == r
Remarks:
The condition rigth >= left is not asserted here in order to allow temporarily making invalid rectangles for sake of efficiency. It is user's responsibility to ensure this pre-condition holds, because in many other algorithms the assertion is present, and if it fires somewhere else it will be very hard to find out where was this condition violated.
Complexity
O(1)
void instigate::geometry::rectangle::set_top ( const coordinate_type t  )  throw ()

Sets the top coordinate of the rectangle.

Parameters:
t - the new value for the top coordinate
Postcondition:
get_top(this) == t
Remarks:
The condition top >= bottom is not asserted here in order to allow temporarily making invalid rectangles for sake of efficiency. It is user's responsibility to ensure this pre-condition holds, because in many other algorithms the assertion is present, and if it fires somewhere else it will be very hard to find out where was this condition violated.
Complexity
O(1)

The documentation for this class was generated from the following file:


© Instigate CJSC, Open Source