[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

| Box [Ranges and Points] |

Represent an n-dimensional box as a (begin, end) pair. Depending on the value type, end() is considered to be outside the box (as in the STL, for integer types), or inside (for floating point types). size() will always be end() - begin(). More...

`#include <vigra/box.hxx>`

List of all members.

## Public Types

typedef VALUETYPE | value_type
typedef TinyVector< VALUETYPE, DIMENSION > | Vector
typedef NumericTraits < VALUETYPE >::Promote | VolumeType

## Public Member Functions

void | addBorder (VALUETYPE borderWidth)
void | addSize (Vector const &offset)
Vector & | begin ()
Vector const & | begin () const
| Box (Vector const &size)
| Box (Vector const &begin, Vector const &end)
| Box ()
bool | contains (Box const &r) const
bool | contains (Vector const &p) const
Vector & | end ()
Vector const & | end () const
bool | intersects (Box const &r) const
bool | isEmpty () const
void | moveBy (Vector const &offset)
void | moveTo (Vector const &newBegin)
Box | operator & (Box const &r) const
Box & | operator &= (Box const &r)
bool | operator!= (Box const &r) const
| inequality check
Box | operator* (double scale)
Box & | operator*= (double scale)
Box | operator+ (const Vector &offset)
Box & | operator+= (const Vector &offset)
Box | operator- (const Vector &offset)
Box & | operator-= (const Vector &offset)
Box | operator/ (double scale)
Box & | operator/= (double scale)
bool | operator== (Box const &r) const
| equality check
Box | operator| (Box const &r) const
Box | operator| (Vector const &p) const
Box & | operator|= (Box const &r)
Box & | operator|= (Vector const &p)
void | setBegin (Vector const &begin)
void | setEnd (Vector const &end)
void | setSize (Vector const &size)
Vector | size () const
VolumeType | volume () const

## Protected Types

typedef If< typename NumericTraits< VALUETYPE > ::isIntegral, detail::EndOutsidePolicy < VALUETYPE > , detail::EndInsidePolicy < VALUETYPE > >::type | RangePolicy

## Detailed Description

### template<class VALUETYPE, unsigned int DIMENSION>
class vigra::Box< VALUETYPE, DIMENSION >

Represent an n-dimensional box as a (begin, end) pair. Depending on the value type, end() is considered to be outside the box (as in the STL, for integer types), or inside (for floating point types). size() will always be end() - begin().

## Member Typedef Documentation

typedef If<typename NumericTraits<VALUETYPE>::isIntegral, detail::EndOutsidePolicy<VALUETYPE>, detail::EndInsidePolicy<VALUETYPE> >::type RangePolicy `[protected]`

Range policy (EndInsidePolicy/EndOutsidePolicy, depending on valuetype)

typedef VALUETYPE value_type

STL-compatible definition of coordinate valuetype

typedef TinyVector<VALUETYPE, DIMENSION> Vector

Vector type used for begin() and end()

typedef NumericTraits<VALUETYPE>::Promote VolumeType

Promoted coordinate valuetype, used for volume()

## Constructor & Destructor Documentation

Box | ( |  | ) |

Construct an empty box (isEmpty() will return true). (Internally, this will initialize all dimensions with the empty range [1..0].)

Box | ( | Vector const & | begin,
|  | Vector const & | end |
| ) |  |  |

Construct a box representing the given range. Depending on the value type, end() is considered to be outside the box (as in the STL, for integer types), or inside (for floating point types).

Box | ( | Vector const & | size | ) | `[explicit]`

Construct a box of given size at the origin (i.e. end() == size()).

## Member Function Documentation

void addBorder | ( | VALUETYPE | borderWidth | ) |

Adds a border of the given width around the box. That means, begin()'s components are moved by -borderWidth and end()'s by borderWidth. (If borderWidth is negative, the box will get smaller accordingly.)

void addSize | ( | Vector const & | offset | ) |

Increase the size of the box by the given offset. This will move end() only. (If any of offset's components is negative, the box will get smaller accordingly.)

Vector& begin | ( |  | ) |

Access begin vector (i.e. smallest coordinates for each dimension). This is the first point (scan-order wise) which is considered to be "in" the box.

Vector const& begin | ( |  | ) | const

Get begin vector (i.e. smallest coordinates for each dimension). This is the first point (scan-order wise) which is considered to be "in" the box.

bool contains | ( | Box< VALUETYPE, DIMENSION > const & | r | ) | const

Return whether this box contains the given one. `r1.contains(r2)` returns the same as `r1 == (r1|r2)` (but is of course more efficient). That also means, a box (even an empty one!) contains() any empty box.

bool contains | ( | Vector const & | p | ) | const

Return whether this box contains the given point. That is, if the point lies within the range [begin, end] in each dimension (excluding end() itself for integer valuetypes).

Vector& end | ( |  | ) |

Access end vector (i.e. coordinates higher than begin() in each dimension for non-empty boxes). This is begin() + size(), and depending on the valuetype (float/int), this is the last point within or the first point outside the box, respectively.

Vector const& end | ( |  | ) | const

Get end vector (i.e. coordinates higher than begin() in each dimension for non-empty boxes). This is begin() + size(), and depending on the valuetype (float/int), this is the last point within or the first point outside the box, respectively.

bool intersects | ( | Box< VALUETYPE, DIMENSION > const & | r | ) | const

Return whether this box overlaps with the given one. `r1.intersects(r2)` returns the same as `!(r1&r2).isEmpty()` (but is of course much more efficient).

bool isEmpty | ( |  | ) | const

Return whether this box is considered empty. It is non-empty if all end() coordinates are greater than (or equal, for floating point valuetypes) the corresponding begin() coordinates. Uniting an empty box with something will return the bounding box of the 'something', and intersecting any box with an empty box will again yield an empty box.

void moveBy | ( | Vector const & | offset | ) |

Move the whole box by the given offset. (Equivalent to operator+=)

void moveTo | ( | Vector const & | newBegin | ) |

Move the whole box so that the given point will be begin() afterwards.

Box operator & | ( | Box< VALUETYPE, DIMENSION > const & | r | ) | const

Intersects this box with the given one. The result will be the maximal box contained in both original ones. Intersecting with an empty box will yield again an empty box.

Box& operator &= | ( | Box< VALUETYPE, DIMENSION > const & | r | ) |

Modifies this box by intersecting it with the given one. The result will be the maximal box contained in both original ones. Intersecting with an empty box will yield again an empty box.

Box operator* | ( | double | scale | ) |

Return box scaled by given factor. The same scalar multiplication will be performed on both begin() and end().

Box& operator*= | ( | double | scale | ) |

Scale box by scalar multiply-assignment. The same scalar multiply-assignment operation will be performed on both begin() and end().

Box operator+ | ( | const Vector & | offset | ) |

Translate box by vector addition. The same vector addition operation will be performed on both begin() and end().

Box& operator+= | ( | const Vector & | offset | ) |

Translate box by vector addition-assignment. The same vector addition-assignment operation will be performed on both begin() and end().

Box operator- | ( | const Vector & | offset | ) |

Translate box by vector subtract. The same vector subtract operation will be performed on both begin() and end().

Box& operator-= | ( | const Vector & | offset | ) |

Translate box by vector subtract-assignment. The same vector subtract-assignment operation will be performed on both begin() and end().

Box operator/ | ( | double | scale | ) |

Return box scaled by inverse of given factor. The same scalar division will be performed on both begin() and end().

Box& operator/= | ( | double | scale | ) |

Scale box by scalar divide-assignment. The same scalar divide-assignment operation will be performed on both begin() and end().

Box operator| | ( | Box< VALUETYPE, DIMENSION > const & | r | ) | const

Returns the union of this box and the given one. The result will be the bounding box of both boxs. If one of the boxes isEmpty(), the union will be the other one.

Box operator| | ( | Vector const & | p | ) | const

Returns the union of this box and the given point. The result will be the bounding box of the box and the point. If isEmpty() returns true on the original box, the union will be a box containing only the given point.

Box& operator|= | ( | Box< VALUETYPE, DIMENSION > const & | r | ) |

Modifies this box by uniting it with the given one. The result will be the bounding box of both boxs. If one of the boxes isEmpty(), the union will be the other one.

Box& operator|= | ( | Vector const & | p | ) |

Modifies this box by including the given point. The result will be the bounding box of the box and the point. If isEmpty() returns true on the original box, the union will be a box containing only the given point.

void setBegin | ( | Vector const & | begin | ) |

Change begin() without changing end(), changing size() accordingly.

void setEnd | ( | Vector const & | end | ) |

Change end() without changing begin(), which will change the size() most probably.

void setSize | ( | Vector const & | size | ) |

Resize this box to the given extents. This will change end() only.

Vector size | ( |  | ) | const

Determine and return the size of this box. The size might be zero or even negative in one or more dimensions, and if so, isEmpty() will return true.

VolumeType volume | ( |  | ) | const

Determine and return the area of this box. That is, if this rect isEmpty(), returns zero, otherwise returns the product of the extents in each dimension.

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

- vigra/box.hxx

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany | html generated using doxygen and Python vigra 1.7.1 (3 Dec 2010)