LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::tbox< T, S > Class Template Reference
[Geometry Data Structures]

Class to describe a 3D box aligned with the coordinate system. More...

#include <ltiBox.h>

List of all members.

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

Detailed Description

template<class T, class S = boxSide<T>>
class lti::tbox< T, S >

Class to describe a 3D box aligned with the coordinate system.

It is specified through two points with the minimum and maximum coordinates.


Constructor & Destructor Documentation

template<class T, class S = boxSide<T>>
lti::tbox< T, S >::tbox (  )  [inline]

default constructor

template<class T, class S = boxSide<T>>
lti::tbox< T, S >::tbox ( const tpoint3D< T > &  p1,
const tpoint3D< T > &  p2 
) [inline]

constructor

template<class T, class S = boxSide<T>>
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

template<class T, class S = boxSide<T>>
lti::tbox< T, S >::tbox ( const T &  size  )  [inline]

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.

template<class T, class S = boxSide<T>>
lti::tbox< T, S >::tbox ( const tbox< T > &  other  )  [inline]

copy constructor


Member Function Documentation

template<class T, class S = boxSide<T>>
template<class U , class SU >
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.

template<class T, class S = boxSide<T>>
tbox<T>& lti::tbox< T, S >::copy ( const tbox< T > &  other  )  [inline]
template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
tpoint3D<T> lti::tbox< T, S >::getCenter (  )  const [inline]

Get center of tbox<T>.

References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.

Referenced by lti::tbox< T, S >::resize().

template<class T, class S = boxSide<T>>
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.

Warning:
Note that the result of this method depends on the type T

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.

template<class T, class S = boxSide<T>>
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.

Warning:
Note that the result of this method depends on the type T

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.

template<class T, class S = boxSide<T>>
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.

Returns:
a reference to this (modified) instance.

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

template<class T, class S = boxSide<T>>
bool lti::tbox< T, S >::isConsistent (  )  const [inline]

Check for consistent tbox<T>.

Returns:
True if minimum and maximum corners are correct

References lti::tbox< T, S >::max, and lti::tbox< T, S >::min.

Referenced by lti::tbox< T, S >::overlaps().

template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
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.

Returns:
a reference to this (modified) 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|=().

template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
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().

template<class T, class S = boxSide<T>>
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().

template<class T, class S = boxSide<T>>
tbox<T>& lti::tbox< T, S >::operator= ( const tbox< T > &  other  )  [inline]

alias for copy

References lti::tbox< T, S >::copy().

template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
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().

template<class T, class S = boxSide<T>>
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().

template<class T, class S = boxSide<T>>
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().

template<class T, class S = boxSide<T>>
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.

template<class T, class S = boxSide<T>>
void lti::tbox< T, S >::resize ( const tpoint3D< T > &  dim  )  [inline]
template<class T, class S = boxSide<T>>
void lti::tbox< T, S >::setCenter ( tpoint3D< T >  center  )  [inline]
template<class T, class S = boxSide<T>>
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.


Member Data Documentation

template<class T, class S = boxSide<T>>
tpoint3D<T> lti::tbox< T, S >::max
template<class T, class S = boxSide<T>>
tpoint3D<T> lti::tbox< T, S >::min

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

Generated on Sat Apr 10 15:26:43 2010 for LTI-Lib by Doxygen 1.6.1