All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
List of all members | Public Member Functions | Related Functions
Box< T > Class Template Reference

Detailed Description

template<typename T>
class lemon::dim2::Box< T >

A class to calculate or store the bounding box of plain vectors (points).

#include <lemon/dim2.h>

Public Member Functions

 Box ()
 Default constructor: creates an empty box.
 
 Box (Point< T > a)
 Construct a box from one point.
 
 Box (Point< T > a, Point< T > b)
 Construct a box from two points. More...
 
 Box (T l, T b, T r, T t)
 Construct a box from four numbers. More...
 
bool empty () const
 Return true if the box is empty. More...
 
void clear ()
 Make the box empty.
 
Point< T > bottomLeft () const
 Give back the bottom left corner of the box. More...
 
void bottomLeft (Point< T > p)
 Set the bottom left corner of the box. More...
 
Point< T > topRight () const
 Give back the top right corner of the box. More...
 
void topRight (Point< T > p)
 Set the top right corner of the box. More...
 
Point< T > bottomRight () const
 Give back the bottom right corner of the box. More...
 
void bottomRight (Point< T > p)
 Set the bottom right corner of the box. More...
 
Point< T > topLeft () const
 Give back the top left corner of the box. More...
 
void topLeft (Point< T > p)
 Set the top left corner of the box. More...
 
bottom () const
 Give back the bottom of the box. More...
 
void bottom (T t)
 Set the bottom of the box. More...
 
top () const
 Give back the top of the box. More...
 
void top (T t)
 Set the top of the box. More...
 
left () const
 Give back the left side of the box. More...
 
void left (T t)
 Set the left side of the box. More...
 
right () const
 Give back the right side of the box. More...
 
void right (T t)
 Set the right side of the box. More...
 
height () const
 Give back the height of the box. More...
 
width () const
 Give back the width of the box. More...
 
bool inside (const Point< T > &u) const
 Checks whether a point is inside the box.
 
Boxadd (const Point< T > &u)
 Increments the box with a point. More...
 
Boxadd (const Box &u)
 Increments the box to contain another box. More...
 
Box operator& (const Box &u) const
 Intersection of two boxes. More...
 

Related Functions

(Note that these are not member functions.)

template<typename T >
std::istream & operator>> (std::istream &is, Box< T > &b)
 Read a box from a stream. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &os, const Box< T > &b)
 Write a box to a stream. More...
 

Constructor & Destructor Documentation

Box ( Point< T >  a,
Point< T >  b 
)
inline

Construct a box from two points.

Parameters
aThe bottom left corner.
bThe top right corner.
Warning
The coordinates of the bottom left corner must be no more than those of the top right one.
Box ( l,
b,
r,
t 
)
inline

Construct a box from four numbers.

Parameters
lThe left side of the box.
bThe bottom of the box.
rThe right side of the box.
tThe top of the box.
Warning
The left side must be no more than the right side and bottom must be no more than the top.

Member Function Documentation

bool empty ( ) const
inline

Return true if the box is empty (i.e. return false if at least one point was added to the box or the coordinates of the box were set).

The coordinates of an empty box are not defined.

Point<T> bottomLeft ( ) const
inline

Give back the bottom left corner of the box. If the box is empty, then the return value is not defined.

void bottomLeft ( Point< T >  p)
inline

Set the bottom left corner of the box.

Precondition
The box must not be empty.
Point<T> topRight ( ) const
inline

Give back the top right corner of the box. If the box is empty, then the return value is not defined.

void topRight ( Point< T >  p)
inline

Set the top right corner of the box.

Precondition
The box must not be empty.
Point<T> bottomRight ( ) const
inline

Give back the bottom right corner of the box. If the box is empty, then the return value is not defined.

void bottomRight ( Point< T >  p)
inline

Set the bottom right corner of the box.

Precondition
The box must not be empty.
Point<T> topLeft ( ) const
inline

Give back the top left corner of the box. If the box is empty, then the return value is not defined.

void topLeft ( Point< T >  p)
inline

Set the top left corner of the box.

Precondition
The box must not be empty.
T bottom ( ) const
inline

Give back the bottom of the box. If the box is empty, then the return value is not defined.

void bottom ( t)
inline

Set the bottom of the box.

Precondition
The box must not be empty.
T top ( ) const
inline

Give back the top of the box. If the box is empty, then the return value is not defined.

void top ( t)
inline

Set the top of the box.

Precondition
The box must not be empty.
T left ( ) const
inline

Give back the left side of the box. If the box is empty, then the return value is not defined.

void left ( t)
inline

Set the left side of the box.

Precondition
The box must not be empty.
T right ( ) const
inline

Give back the right side of the box. If the box is empty, then the return value is not defined.

void right ( t)
inline

Set the right side of the box.

Precondition
The box must not be empty.
T height ( ) const
inline

Give back the height of the box. If the box is empty, then the return value is not defined.

T width ( ) const
inline

Give back the width of the box. If the box is empty, then the return value is not defined.

Box& add ( const Point< T > &  u)
inline

Increments the box with a point.

Box& add ( const Box< T > &  u)
inline

Increments the box to contain another box.

Box operator& ( const Box< T > &  u) const
inline

Intersection of two boxes.