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

| Box< VALUETYPE, DIMENSION > Class Template Reference 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>`

## Public Types

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

## Public Member Functions

void | addBorder (VALUETYPE borderWidth)
void | addBorder (const Vector &borderWidth)
void | addSize (Vector const &offset)
Vector const & | begin () const
Vector & | begin ()
| Box ()
| Box (Vector const &begin, Vector const &end)
| Box (Vector const &size)
bool | contains (Vector const &p) const
bool | contains (Box const &r) const
Vector const & | end () const
Vector & | end ()
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) const
Box & | operator*= (double scale)
Box | operator+ (const Vector &offset) const
Box & | operator+= (const Vector &offset)
Box | operator- (const Vector &offset) const
Box & | operator-= (const Vector &offset)
Box | operator/ (double scale) const
Box & | operator/= (double scale)
bool | operator== (Box const &r) const
| equality check
Box | operator| (Vector const &p) const
Box | operator| (Box const &r) const
Box & | operator|= (Vector const &p)
Box & | operator|= (Box const &r)
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

## ◆ value_type

typedef VALUETYPE value_type

STL-compatible definition of coordinate valuetype

## ◆ VolumeType

typedef NumericTraits<VALUETYPE>::Promote VolumeType

Promoted coordinate valuetype, used for volume()

## ◆ Vector

typedef TinyVector<VALUETYPE, DIMENSION> Vector

Vector type used for begin() and end()

## ◆ RangePolicy

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

protected

Range policy (EndInsidePolicy/EndOutsidePolicy, depending on valuetype)

## Constructor & Destructor Documentation

## ◆ Box() [1/3]

Box | ( |  | ) |

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

## ◆ Box() [2/3]

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

Box | ( | Vector const & | size | ) |

explicit

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

## Member Function Documentation

## ◆ begin() [1/2]

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.

## ◆ begin() [2/2]

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.

## ◆ end() [1/2]

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.

## ◆ end() [2/2]

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.

## ◆ setBegin()

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

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

## ◆ setEnd()

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

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

## ◆ moveTo()

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

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

## ◆ moveBy()

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

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

## ◆ volume()

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.

## ◆ size()

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.

## ◆ setSize()

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

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

## ◆ addSize()

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.)

## ◆ addBorder() [1/2]

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.)

## ◆ addBorder() [2/2]

void addBorder | ( | const Vector & | 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.)

## ◆ isEmpty()

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.

## ◆ contains() [1/2]

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).

## ◆ contains() [2/2]

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.

## ◆ intersects()

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).

## ◆ operator|=() [1/2]

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.

## ◆ operator|() [1/2]

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.

## ◆ operator|=() [2/2]

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.

## ◆ operator|() [2/2]

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.

## ◆ operator &=()

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.

## ◆ operator &()

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.

## ◆ operator*=()

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

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

## ◆ operator*()

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

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

## ◆ operator/=()

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

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

## ◆ operator/()

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

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

## ◆ operator+=()

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().

## ◆ operator+()

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

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

## ◆ operator-=()

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().

## ◆ operator-()

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

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

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.11.0