NLPACS::CFaceGrid::CFaceGridBuild Class Reference

#include <face_grid.h>


Detailed Description

A temporary grid, used to create a static CFaceGrid object.
Author:
Benjamin Legros

Nevrax France

Date:
2001

Definition at line 66 of file face_grid.h.

Public Member Functions

void init (uint width, float elsize)
 Init an empty build object with width and size.

void insert (const NLMISC::CVector &bmin, const NLMISC::CVector &bmax, uint32 value)
 Insert a value in the grid.


Data Fields

std::vector< std::vector<
uint32 > > 
Grid
 The grid.

float Size
 The size of each element.

uint Width
 The width, in number of rows and lines of the grid.


Member Function Documentation

void NLPACS::CFaceGrid::CFaceGridBuild::init uint  width,
float  elsize
[inline]
 

Init an empty build object with width and size.

Definition at line 187 of file face_grid.h.

References Grid, nlassert, uint, and width.

Referenced by NLPACS::CLocalRetriever::initFaceGrid().

00188 {
00189         nlassert(NLMISC::isPowerOf2(width));
00190         Width = width;
00191         Size = elsize;
00192         Grid.clear();
00193         Grid.resize(Width*Width);
00194 }

void NLPACS::CFaceGrid::CFaceGridBuild::insert const NLMISC::CVector bmin,
const NLMISC::CVector bmax,
uint32  value
[inline]
 

Insert a value in the grid.

Definition at line 196 of file face_grid.h.

References Grid, sint, uint32, value, x, NLMISC::CVector::x, y, and NLMISC::CVector::y.

Referenced by NLPACS::CLocalRetriever::initFaceGrid().

00199 {
00200         sint    x0 = (sint)(bmin.x/Size),
00201                         x1 = (sint)(bmax.x/Size),
00202                         y0 = (sint)(bmin.y/Size),
00203                         y1 = (sint)(bmax.y/Size);
00204 
00205         if (x1-x0 >= (sint)Width)
00206         {
00207                 x0 = 0;
00208                 x1 = Width-1;
00209         }
00210         else
00211         {
00212                 x0 &= (Width-1);
00213                 x1 &= (Width-1);
00214                 if (x1 < x0)
00215                         x1 += Width;
00216         }
00217 
00218         if (y1-y0 >= (sint)Width)
00219         {
00220                 y0 = 0;
00221                 y1 = Width-1;
00222         }
00223         else
00224         {
00225                 y0 &= (Width-1);
00226                 y1 &= (Width-1);
00227                 if (y1 < y0)
00228                         y1 += Width;
00229         }
00230 
00231         sint    x, y;
00232 
00233         for (y=y0; y<=y1; ++y)
00234                 for (x=x0; x<=x1; ++x)
00235                         Grid[(x&(Width-1))+(y&(Width-1))*Width].push_back(value);
00236 }


Field Documentation

std::vector< std::vector<uint32> > NLPACS::CFaceGrid::CFaceGridBuild::Grid
 

The grid.

Definition at line 70 of file face_grid.h.

Referenced by NLPACS::CFaceGrid::create(), init(), and insert().

float NLPACS::CFaceGrid::CFaceGridBuild::Size
 

The size of each element.

Definition at line 76 of file face_grid.h.

Referenced by NLPACS::CFaceGrid::create().

uint NLPACS::CFaceGrid::CFaceGridBuild::Width
 

The width, in number of rows and lines of the grid.

Definition at line 73 of file face_grid.h.

Referenced by NLPACS::CFaceGrid::create().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 14:13:23 2004 for NeL by doxygen 1.3.6