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

Public Types | Public Member Functions | Protected Types | List of all members
Box< VALUETYPE, DIMENSION > Class Template Reference

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 (const Vector &borderWidth)
void | addBorder (VALUETYPE borderWidth)
void | addSize (Vector const &offset)
Vector & | begin ()
Vector const & | begin () const
| Box ()
| Box (Vector const &begin, Vector const &end)
| Box (Vector const &size)
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)
bool | operator!= (Box const &r) const
| inequality check
Box | operator& (Box const &r) const
Box & | operator&= (Box const &r)
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| (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< typenameNumericTraits< 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

template<class VALUETYPE, unsigned int DIMENSION>

typedef VALUETYPE value_type

STL-compatible definition of coordinate valuetype

## ◆ VolumeType

template<class VALUETYPE, unsigned int DIMENSION>

typedef NumericTraits<VALUETYPE>::Promote VolumeType

Promoted coordinate valuetype, used for volume()

## ◆ Vector

template<class VALUETYPE, unsigned int DIMENSION>

typedef TinyVector<VALUETYPE, DIMENSION> Vector

Vector type used for begin() and end()

## ◆ RangePolicy

template<class VALUETYPE, unsigned int DIMENSION>

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

protected

Range policy (EndInsidePolicy/EndOutsidePolicy, depending on valuetype)

## Constructor & Destructor Documentation

## ◆ Box() [1/3]

template<class VALUETYPE, unsigned int DIMENSION>

Box | ( |  | ) |

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

## ◆ Box() [2/3]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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

explicit

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

## Member Function Documentation

## ◆ begin() [1/2]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ setEnd()

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ moveTo()

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ moveBy()

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ volume()

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ addSize()

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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]

template<class VALUETYPE, unsigned int DIMENSION>

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&=()

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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*=()

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

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

## ◆ operator/=()

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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+=()

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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

template<class VALUETYPE, unsigned int DIMENSION>

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