latest version v1.9 - last update 10 Apr 2010 |
Class to describe a 3D box aligned with the coordinate system. More...
#include <ltiBox.h>
Public Member Functions | |
tbox () | |
tbox (const tpoint3D< T > &p1, const tpoint3D< T > &p2) | |
tbox (const T &x1, const T &y1, const T &z1, const T &x2, const T &y2, const T &z2) | |
tbox (const T &size) | |
tbox (const tbox< T > &other) | |
Dimensions and location | |
void | resize (const tpoint3D< T > &dim) |
void | resize (const T &x, const T &y, const T &z) |
tpoint3D< T > | getDimensions () const |
T | getVolume () const |
tpoint3D< T > | getCenter () const |
void | setCenter (tpoint3D< T > center) |
void | ensureConsistency () |
bool | isConsistent () const |
void | shift (const tpoint3D< T > &delta) |
Simple operations | |
bool | isInside (const tpoint3D< T > &p) const |
bool | isInside (const T &x, const T &y, const T &z) const |
Duplication | |
tbox< T > & | copy (const tbox< T > &other) |
template<class U , class SU > | |
tbox< T > & | castFrom (const tbox< U, SU > &other) |
tbox< T > & | operator= (const tbox< T > &other) |
Comparison | |
bool | operator== (const tbox< T > &other) const |
bool | operator!= (const tbox< T > &other) const |
Geometrical combination | |
tbox< T > & | intersect (const tbox< T > &tRect) |
bool | overlaps (const tbox< T > &tRect) const |
tbox< T > & | operator&= (const tbox< T > &tRect) |
tbox< T > | operator& (const tbox< T > &tRect) |
tbox< T > & | join (const tbox< T > &tRect) |
tbox< T > & | operator|= (const tbox< T > &tRect) |
tbox< T > | operator| (const tbox< T > &tRect) |
Public Attributes | |
tpoint3D< T > | min |
tpoint3D< T > | max |
Class to describe a 3D box aligned with the coordinate system.
It is specified through two points with the minimum and maximum coordinates.
lti::tbox< T, S >::tbox | ( | const tpoint3D< T > & | p1, | |
const tpoint3D< T > & | p2 | |||
) | [inline] |
constructor
lti::tbox< T, S >::tbox | ( | const T & | x1, | |
const T & | y1, | |||
const T & | z1, | |||
const T & | x2, | |||
const T & | y2, | |||
const T & | z2 | |||
) | [inline] |
constructor
construct a cube with the given side size.
If the size is even and T is an integer type, the box will be created from -|_size/2_| to size + |_size/2_| in both coordinates x and y.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
lti::tbox< T, S >::tbox | ( | const tbox< T > & | other | ) | [inline] |
copy constructor
tbox<T>& lti::tbox< T, S >::castFrom | ( | const tbox< U, SU > & | other | ) | [inline] |
cast from a box of another type
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
tbox<T>& lti::tbox< T, S >::copy | ( | const tbox< T > & | other | ) | [inline] |
copy member
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Referenced by lti::tbox< T, S >::operator=().
void lti::tbox< T, S >::ensureConsistency | ( | ) | [inline] |
Ensure consistency of minimum and maximum corners.
A tbox<T> is called "consistent" if the minimum tpoint3D<T> has lower coordinate-values than the maximum tpoint3D<T>.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Get center of tbox<T>.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Referenced by lti::tbox< T, S >::resize().
tpoint3D<T> lti::tbox< T, S >::getDimensions | ( | ) | const [inline] |
Get dimensions of tbox<T>.
If one coordinate of the two points coincide and the box contains fixed point typed points, the returned dimension is one. For floating point types this case will return 0.
For integer types it will be assumed that the box lies on a discrete grid with grid elements of size 1x1, and that is not the box itself what is described but the number of grid elements. This means that the size of a side defined by two scalar values x1 and x2 (x2>x1) is x2-x1+1. This is useful for example when dealing with rectangular regions of images.
For floating point values the size is just x2-x1, because of the assumtion that the box lies on a real valued 2D space.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
T lti::tbox< T, S >::getVolume | ( | ) | const [inline] |
Get the volume of this box.
This value is always positive, regardless of the position of the minimum and maximum corners. A box whose corners coincide has an area of 1 for fixed point types or 0 for floating point ones.
For integer types it will be assumed that the box lies on a discrete grid with grid elements of size 1x1, and that is not the box itself what is described but the index of grid elements. This means that the size of a side defined by two scalar values x1 and x2 (x2>x1) is x2-x1+1. This is useful for example when dealing with rectangular regions of images.
For floating point values the size is just x2-x1, because of the assumtion that the box lies on a real valued 2D space.
References lti::abs(), lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
tbox<T>& lti::tbox< T, S >::intersect | ( | const tbox< T > & | tRect | ) | [inline] |
Intersection of this tbox with tRect.
(the largest box which is contained both inside this box and inside tRect).
The result will be left in this instance. If the boxs do not intersect, the resul will be inconsistent, so you should call isConsistent() to check for this case unless you know for sure that it cannot occur.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Referenced by lti::tbox< T, S >::operator&(), lti::tbox< T, S >::operator&=(), and lti::tbox< T, S >::overlaps().
bool lti::tbox< T, S >::isConsistent | ( | ) | const [inline] |
Check for consistent tbox<T>.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Referenced by lti::tbox< T, S >::overlaps().
bool lti::tbox< T, S >::isInside | ( | const T & | x, | |
const T & | y, | |||
const T & | z | |||
) | const [inline] |
Check if the given coordinates are inside the tbox<T>.
(border included!)
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
bool lti::tbox< T, S >::isInside | ( | const tpoint3D< T > & | p | ) | const [inline] |
Check if tpoint3D<T> p is inside the tbox<T>.
(border included!)
References lti::tbox< T, S >::max, lti::tbox< T, S >::min, lti::tpoint3D< T >::x, lti::tpoint3D< T >::y, and lti::tpoint3D< T >::z.
tbox<T>& lti::tbox< T, S >::join | ( | const tbox< T > & | tRect | ) | [inline] |
Union of this tbox with tRect (the smallest box containing both this tbox and tRect) The result will be left in this instance.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
Referenced by lti::tbox< T, S >::operator|(), and lti::tbox< T, S >::operator|=().
bool lti::tbox< T, S >::operator!= | ( | const tbox< T > & | other | ) | const [inline] |
test for inequality
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
tbox<T> lti::tbox< T, S >::operator& | ( | const tbox< T > & | tRect | ) | [inline] |
new tbox = intersection of tbox with tRect
References lti::tbox< T, S >::intersect().
tbox<T>& lti::tbox< T, S >::operator&= | ( | const tbox< T > & | tRect | ) | [inline] |
tbox = intersection of tbox with tRect.
(alias for intersect)
References lti::tbox< T, S >::intersect().
tbox<T>& lti::tbox< T, S >::operator= | ( | const tbox< T > & | other | ) | [inline] |
alias for copy
References lti::tbox< T, S >::copy().
bool lti::tbox< T, S >::operator== | ( | const tbox< T > & | other | ) | const [inline] |
test for equality
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
tbox<T> lti::tbox< T, S >::operator| | ( | const tbox< T > & | tRect | ) | [inline] |
new tbox = union of this tbox with tRect
References lti::tbox< T, S >::join().
tbox<T>& lti::tbox< T, S >::operator|= | ( | const tbox< T > & | tRect | ) | [inline] |
tbox = union of this tbox with tRect (alias for join)
References lti::tbox< T, S >::join().
bool lti::tbox< T, S >::overlaps | ( | const tbox< T > & | tRect | ) | const [inline] |
Check whether this box overlaps with the given box.
References lti::tbox< T, S >::intersect(), and lti::tbox< T, S >::isConsistent().
void lti::tbox< T, S >::resize | ( | const T & | x, | |
const T & | y, | |||
const T & | z | |||
) | [inline] |
resize tbox<T> with new dimensions, but keep its center
References lti::tbox< T, S >::getCenter(), lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
void lti::tbox< T, S >::resize | ( | const tpoint3D< T > & | dim | ) | [inline] |
resize tbox<T> with new dimensions, but keep its center
References lti::tbox< T, S >::getCenter(), lti::tbox< T, S >::max, lti::tbox< T, S >::min, lti::tpoint3D< T >::x, lti::tpoint3D< T >::y, and lti::tpoint3D< T >::z.
void lti::tbox< T, S >::setCenter | ( | tpoint3D< T > | center | ) | [inline] |
Set the center of this box.
References lti::abs(), lti::tbox< T, S >::max, lti::tbox< T, S >::min, lti::tpoint3D< T >::x, lti::tpoint3D< T >::y, and lti::tpoint3D< T >::z.
void lti::tbox< T, S >::shift | ( | const tpoint3D< T > & | delta | ) | [inline] |
Shift tbox<T> by delta.
References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.
maximum tpoint3D<T>
Referenced by lti::tbox< T, S >::castFrom(), lti::tbox< T, S >::copy(), lti::tbox< T, S >::ensureConsistency(), lti::tbox< T, S >::getCenter(), lti::tbox< T, S >::getDimensions(), lti::tbox< T, S >::getVolume(), lti::tbox< T, S >::intersect(), lti::tbox< T, S >::isConsistent(), lti::tbox< T, S >::isInside(), lti::tbox< T, S >::join(), lti::tbox< T, S >::operator!=(), lti::tbox< T, S >::operator==(), lti::read(), lti::tbox< T, S >::resize(), lti::tbox< T, S >::setCenter(), lti::tbox< T, S >::shift(), lti::tbox< T, S >::tbox(), and lti::write().
minimum tpoint3D<T>
Referenced by lti::tbox< T, S >::castFrom(), lti::tbox< T, S >::copy(), lti::tbox< T, S >::ensureConsistency(), lti::tbox< T, S >::getCenter(), lti::tbox< T, S >::getDimensions(), lti::tbox< T, S >::getVolume(), lti::tbox< T, S >::intersect(), lti::tbox< T, S >::isConsistent(), lti::tbox< T, S >::isInside(), lti::tbox< T, S >::join(), lti::tbox< T, S >::operator!=(), lti::tbox< T, S >::operator==(), lti::read(), lti::tbox< T, S >::resize(), lti::tbox< T, S >::setCenter(), lti::tbox< T, S >::shift(), lti::tbox< T, S >::tbox(), and lti::write().