NLPACS::CFaceGrid Class Reference

#include <face_grid.h>


Detailed Description

A selection grid for the interior faces. It contains the indexes of the faces, as uint32.
Author:
Benjamin Legros

Nevrax France

Date:
2001

Definition at line 57 of file face_grid.h.

Public Member Functions

 CFaceGrid ()
 Constructor.

void clear ()
 Clear the grid.

void create (const CFaceGridBuild &fgb)
 Create the face grid from a CFaceGridBuild.

void select (const NLMISC::CVector &pos, std::vector< uint32 > &selected) const
 Select faces indexes close to a given point.

void serial (NLMISC::IStream &f)
 Serial the face grid.


Protected Attributes

float _ElSize
 The size (in meter) of each grid element.

std::vector< uint32_Grid
 The grid of indexes to the data buffer.

std::vector< uint32_GridData
 The grid data buffer (packed datas).

uint16 _Log2Width
 The 2Log of the width of the grid.

uint16 _Width
 The width of the grid in rows and lines.


Constructor & Destructor Documentation

NLPACS::CFaceGrid::CFaceGrid  )  [inline]
 

Constructor.

Definition at line 102 of file face_grid.h.

References _ElSize, and _Log2Width.

00102 : _Width(0), _Log2Width(0), _ElSize(0.0f) {}


Member Function Documentation

void NLPACS::CFaceGrid::clear  )  [inline]
 

Clear the grid.

Definition at line 120 of file face_grid.h.

References _ElSize, _Log2Width, and NLMISC::contReset().

Referenced by NLPACS::CLocalRetriever::clear(), and create().

00121 {
00122         _Width = 0;
00123         _Log2Width = 0;
00124         _ElSize = 0.0f;
00125         NLMISC::contReset(_Grid);
00126         NLMISC::contReset(_GridData);
00127 }

void NLPACS::CFaceGrid::create const CFaceGridBuild fgb  )  [inline]
 

Create the face grid from a CFaceGridBuild.

Definition at line 129 of file face_grid.h.

References _ElSize, _Log2Width, clear(), NLMISC::getPowerOf2(), NLPACS::CFaceGrid::CFaceGridBuild::Grid, nlassert, NLPACS::CFaceGrid::CFaceGridBuild::Size, uint, uint16, and NLPACS::CFaceGrid::CFaceGridBuild::Width.

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

00130 {
00131         nlassert(fgb.Grid.size() == fgb.Width*fgb.Width);
00132         nlassert(fgb.Width < 32768);
00133 
00134         // clear first
00135         clear();
00136 
00137         // setup grid size
00138         _Width = (uint16)fgb.Width;
00139         _ElSize = fgb.Size;
00140         _Log2Width = NLMISC::getPowerOf2(_Width);
00141 
00142         // and store in packed format the data of the face grid build
00143         uint    i;
00144         for (i=0; i<fgb.Grid.size(); ++i)
00145         {
00146                 _Grid.push_back(_GridData.size());
00147                 _GridData.insert(_GridData.end(), fgb.Grid[i].begin(), fgb.Grid[i].end());
00148         }
00149 }

void NLPACS::CFaceGrid::select const NLMISC::CVector pos,
std::vector< uint32 > &  selected
const [inline]
 

Select faces indexes close to a given point.

Definition at line 151 of file face_grid.h.

References _ElSize, _Log2Width, sint, uint, NLMISC::CVector::x, x, NLMISC::CVector::y, and y.

Referenced by NLPACS::CLocalRetriever::getHeight(), and NLPACS::CLocalRetriever::snapToInteriorGround().

00152 {
00153         selected.clear();
00154 
00155         uint    start, stop, idx;
00156         uint    x, y;
00157 
00158         x = ((sint)(pos.x/_ElSize) & (_Width-1));
00159         y = ((sint)(pos.y/_ElSize) & (_Width-1));
00160 
00161         idx = x+(y<<_Log2Width);
00162 
00163         start = _Grid[idx++];
00164         stop = (idx == _Grid.size()) ? _GridData.size() : _Grid[idx];
00165 
00166         for (; start<stop; ++start)
00167                 selected.push_back(_GridData[start]);
00168 }

void NLPACS::CFaceGrid::serial NLMISC::IStream f  )  [inline]
 

Serial the face grid.

Definition at line 170 of file face_grid.h.

References _ElSize, _Log2Width, NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), and NLMISC::IStream::serialVersion().

00171 {
00172         /*
00173         Version 0:
00174                 - base version
00175         */
00176         (void)f.serialVersion(0);
00177 
00178         f.serial(_Width, _Log2Width, _ElSize);
00179         f.serialCont(_Grid);
00180         f.serialCont(_GridData);
00181 }


Field Documentation

float NLPACS::CFaceGrid::_ElSize [protected]
 

The size (in meter) of each grid element.

Definition at line 93 of file face_grid.h.

Referenced by CFaceGrid(), clear(), create(), select(), and serial().

std::vector<uint32> NLPACS::CFaceGrid::_Grid [protected]
 

The grid of indexes to the data buffer.

Definition at line 96 of file face_grid.h.

std::vector<uint32> NLPACS::CFaceGrid::_GridData [protected]
 

The grid data buffer (packed datas).

Definition at line 98 of file face_grid.h.

uint16 NLPACS::CFaceGrid::_Log2Width [protected]
 

The 2Log of the width of the grid.

Definition at line 90 of file face_grid.h.

Referenced by CFaceGrid(), clear(), create(), select(), and serial().

uint16 NLPACS::CFaceGrid::_Width [protected]
 

The width of the grid in rows and lines.

Definition at line 88 of file face_grid.h.


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