VIPER REFERENCE MANUAL


NAME
iflTile2D - defines a simple 2-D rectangle

HEADER FILE
#include <ifl/iflTile.h>

PUBLIC METHOD SUMMARY

   Constructors
template<class tileType> iflTile2D (  );
template<class tileType> iflTile2D ( tileType x, tileType y, tileType nx, tileType ny);
template<class tileType> iflTile2D ( const iflTile2D& that);
template<class tileType> iflTile2D ( const iflTile2D& a, const iflTile2D& b);
template<class tileType> iflTile2D ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

   Initialization
iflTile2D& init ( tileType X, tileType Y, tileType Nx, tileType Ny);
iflTile2D& init ( const iflTile2D& tile);

   Intersection
iflTile2D& intersect ( const iflTile2D& a, const iflTile2D& b);
iflTile2D& intersect ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

   Bounding box
iflTile2D& boundingBox ( const iflTile2D& a, const iflTile2D& b);
iflTile2D& boundingBox ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

   Checking for containment
int contains ( tileType X, tileType Y) const;
int contains ( const iflTile2D& tile) const;
int contains ( const iflTile2D& tile, tileType xMax, tileType yMax) const;

   Comparison operators
int operator== ( const iflTile2D& tile) const;
int operator!= ( const iflTile2D& tile) const;

   Offsetting and growing
void operator+= ( const iflXY<tileType>& offset);
void operator-= ( const iflXY<tileType>& offset);
void grow ( const iflXY<tileType>& delta);
void shrink ( const iflXY<tileType>& delta);

   Indexed member access
tileType& origin ( iflAxis axis);
tileType& size ( iflAxis axis);

PUBLIC MEMBER SUMMARY
tileType x, y;
tileType nx, ny;

CLASS DESCRIPTION
This class is used to describe rectangles (tiles). It is mostly used to group together the four values describing the origin (x,y) and size (nx,ny) of a rectangle in a convenient way.

This is a template class that can be used with any scalar data type; e.g, use iflTile2D<int>() to construct a 2D integer tile and iflTile2D<float>() for a 2D-float tile.

The following is an example on how to use a 2D integer tile. iflTile object can be declared in the following way:
    // unitialized
    iflTile2D<int> tile;

    // initialized
    iflTile2D<int> tile(xStart, yStart, xSize, ySize);
    iflTile2D<int> tile(tileA, tileB);
A useful function, contains(), is provided that can be used to determine if this tile fully contains another. An overloaded version allows maximum (x,y) bounds to be specified that are use to clip the other tile; this version is used where a page might extend beyond the edge of an image. Also two operators == and != are provided to find out whether or not two tiles are the same.

A 3D version of this object is provided by iflTile3D.

METHOD DESCRIPTIONS

   iflTile2D()
template<class tileType> iflTile2D (  );
template<class tileType> iflTile2D ( tileType x, tileType y, tileType nx, tileType ny);
template<class tileType> iflTile2D ( const iflTile2D& that);
template<class tileType> iflTile2D ( const iflTile2D& a, const iflTile2D& b);
template<class tileType> iflTile2D ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

The first version with no arguments constructs an uninitialized iflTile2D. The second version constructs an iflTile2D with the origin set to (x,y) and the size set to (nx,ny). The third version constructs a copy of another 2D tile. The fourth version constructs an iflTile2D whose origin and size are set to the intersection of the tiles specified by a and b. The final version constructs an iflTile2D whose origin and size are set to the intersection of the tiles specified by a, b and c.

   boundingBox()
iflTile2D& boundingBox ( const iflTile2D& a, const iflTile2D& b);
iflTile2D& boundingBox ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

The first version sets this object's origin and size to the intersection of the tiles specified by a and b. The second version sets this object's origin and size to the intersection of the tiles specified by a, b and c. The returned value is a reference to this object.

   contains()
int contains ( tileType X, tileType Y) const;
int contains ( const iflTile2D& tile) const;
int contains ( const iflTile2D& tile, tileType xMax, tileType yMax) const;

This function returns TRUE if this object contains the point specified by (X,Y). The second version returns TRUE if this object completely contains the iflTile2D specified by tile. The third version allows tile to be first clipped by the maximum bounds specified by xMax and yMax before checking for containment.

   grow()
void grow ( const iflXY<tileType>& delta);

Increase the size of the tile by the amount specified in delta.

   init()
iflTile2D& init ( tileType X, tileType Y, tileType Nx, tileType Ny);
iflTile2D& init ( const iflTile2D& tile);

The first version initializes this object with the origin set to (X,Y) and the size set to (nX,nY). The second version initializes this object with a copy of the 2D tile specified by tile.

   intersect()
iflTile2D& intersect ( const iflTile2D& a, const iflTile2D& b);
iflTile2D& intersect ( const iflTile2D& a, const iflTile2D& b, const iflTile2D& c);

The first version initializes this object with the origin and size set to the intersection of the tiles specified by a and b. The second version initializes this object with the origin and size set to the intersection of the tiles specified by a, b and c.

   operator!=()
int operator!= ( const iflTile2D& tile) const;

Returns TRUE if tile is not the same as 'this' tile, FALSE otherwise.

   operator+=()
void operator+= ( const iflXY<tileType>& offset);

Shift the origin of the tile by adding to it the amount specified in offset.

   operator-=()
void operator-= ( const iflXY<tileType>& offset);

Shift the origin of the tile by subtracting from it the amount specified in offset.

   operator==()
int operator== ( const iflTile2D& tile) const;

Returns TRUE if tile is the same as 'this' tile, FALSE otherwise.

   origin()
tileType& origin ( iflAxis axis);

Return the x or y origin depening on whether axis is iflX or iflY respectively.

   shrink()
void shrink ( const iflXY<tileType>& delta);

Decrease the size of the tile by the amount specified in delta.

   size()
tileType& size ( iflAxis axis);

Return the x or y size depening on whether axis is iflX or iflY respectively.

MEMBER DESCRIPTIONS

   nx, ny
tileType nx, ny;

The size of the tile in pixels.

   
x, y
tileType x, y;

The origin of the tile in pixels.

SEE ALSO
iflTile3D