Loading...
Searching...
No Matches
Box< T > Class Template Reference
Data Structures » Auxiliary Data Structures » Geometric Data Structures

## 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.
| Box (T l, T b, T r, T t)
| Construct a box from four numbers.
bool | empty () const
| Return `true` if the box is empty.
void | clear ()
| Make the box empty.
Point< T > | bottomLeft () const
| Give back the bottom left corner of the box.
void | bottomLeft (Point< T > p)
| Set the bottom left corner of the box.
Point< T > | topRight () const
| Give back the top right corner of the box.
void | topRight (Point< T > p)
| Set the top right corner of the box.
Point< T > | bottomRight () const
| Give back the bottom right corner of the box.
void | bottomRight (Point< T > p)
| Set the bottom right corner of the box.
Point< T > | topLeft () const
| Give back the top left corner of the box.
void | topLeft (Point< T > p)
| Set the top left corner of the box.
T | bottom () const
| Give back the bottom of the box.
void | bottom (T t)
| Set the bottom of the box.
T | top () const
| Give back the top of the box.
void | top (T t)
| Set the top of the box.
T | left () const
| Give back the left side of the box.
void | left (T t)
| Set the left side of the box.
T | right () const
| Give back the right side of the box.
void | right (T t)
| Set the right side of the box.
T | height () const
| Give back the height of the box.
T | width () const
| Give back the width of the box.
bool | inside (const Point< T > &u) const
| Checks whether a point is inside the box.
Box & | add (const Point< T > &u)
| Increments the box with a point.
Box & | add (const Box &u)
| Increments the box to contain another box.
Box | operator& (const Box &u) const
| Intersection of two boxes.

## Related Symbols

(Note that these are not member symbols.)
template<typename T>
std::istream & | operator>> (std::istream &is, Box< T > &b)
| Read a box from a stream.
template<typename T>
std::ostream & | operator<< (std::ostream &os, const Box< T > &b)
| Write a box to a stream.

## Constructor & Destructor Documentation

## Box() [1/2]

template<typename T>

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

inline

Construct a box from two points.

Parameters

  a | The bottom left corner.
  b | The top right corner.

Warning
  The coordinates of the bottom left corner must be no more than those of the top right one.

## Box() [2/2]

template<typename T>

Box | ( | T | l,
|  | T | b,
|  | T | r,
|  | T | t )

inline

Construct a box from four numbers.

Parameters

  l | The left side of the box.
  b | The bottom of the box.
  r | The right side of the box.
  t | The 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

## empty()

template<typename T>

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.

## bottomLeft() [1/2]

template<typename T>

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.

## bottomLeft() [2/2]

template<typename T>

void bottomLeft | ( | Point< T > | p | ) |

inline

Set the bottom left corner of the box.

Precondition
  The box must not be empty.

## topRight() [1/2]

template<typename T>

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.

## topRight() [2/2]

template<typename T>

void topRight | ( | Point< T > | p | ) |

inline

Set the top right corner of the box.

Precondition
  The box must not be empty.

## bottomRight() [1/2]

template<typename T>

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.

## bottomRight() [2/2]

template<typename T>

void bottomRight | ( | Point< T > | p | ) |

inline

Set the bottom right corner of the box.

Precondition
  The box must not be empty.

## topLeft() [1/2]

template<typename T>

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.

## topLeft() [2/2]

template<typename T>

void topLeft | ( | Point< T > | p | ) |

inline

Set the top left corner of the box.

Precondition
  The box must not be empty.

## bottom() [1/2]

template<typename T>

T bottom | ( |  | ) | const

inline

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

## bottom() [2/2]

template<typename T>

void bottom | ( | T | t | ) |

inline

Set the bottom of the box.

Precondition
  The box must not be empty.

## top() [1/2]

template<typename T>

T top | ( |  | ) | const

inline

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

## top() [2/2]

template<typename T>

void top | ( | T | t | ) |

inline

Set the top of the box.

Precondition
  The box must not be empty.

## left() [1/2]

template<typename T>

T left | ( |  | ) | const

inline

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

## left() [2/2]

template<typename T>

void left | ( | T | t | ) |

inline

Set the left side of the box.

Precondition
  The box must not be empty.

## right() [1/2]

template<typename T>

T right | ( |  | ) | const

inline

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

## right() [2/2]

template<typename T>

void right | ( | T | t | ) |

inline

Set the right side of the box.

Precondition
  The box must not be empty.

## height()

template<typename T>

T height | ( |  | ) | const

inline

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

## width()

template<typename T>

T width | ( |  | ) | const

inline

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

## add() [1/2]

template<typename T>

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

inline

Increments the box with a point.

## add() [2/2]

template<typename T>

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

inline

Increments the box to contain another box.

## operator&()

template<typename T>

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

inline

Intersection of two boxes.