|
|
|
|
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NL3D::CQuadGrid Template Class ReferenceThis container is a simple grid, used to quickly find elements.
More...
#include <quad_grid.h>
Collaboration diagram for NL3D::CQuadGrid:
[legend]List of all members.
Public Methods |
| CQuadGrid () |
| Default constructor, use axes XY!!!, has a size of 16, and EltSize is 1. More...
|
| ~CQuadGrid () |
| dtor. More...
|
|
void | changeBase (const NLMISC::CMatrix& base) |
| Change the base matrix of the quad grid. More...
|
void | create (uint size, float eltSize) |
| Init the container. More...
|
|
void | clear () |
| Clear the container. Elements are deleted, but the quadgrid is not erased. More...
|
CIterator | erase (CIterator it) |
| Erase an interator from the container. More...
|
CIterator | insert (const NLMISC::CVector &bboxmin, const NLMISC::CVector &bboxmax, const T &val) |
| Insert a new element in the container. More...
|
|
void | clearSelection () |
| Clear the selection list. More...
|
void | selectAll () |
| Select all the container. More...
|
void | select (const NLMISC::CVector &bboxmin, const NLMISC::CVector &bboxmax) |
| Select element intersecting a bounding box. More...
|
CIterator | begin () |
| Return the first iterator of the selected element list. More...
|
CIterator | end () |
| Return the end iterator of the selected element list. More...
|
Private Methods |
void | selectQuads (CVector bmin, CVector bmax, sint &x0, sint &x1, sint &y0, sint &y1) |
void | addToSelection (CNode *ptr) |
void | addQuadNodeToSelection (CQuadNode &quad) |
Private Attributes |
std::vector<CQuadNode> | _Grid |
sint | _Size |
sint | _SizePower |
float | _EltSize |
NLMISC::CMatrix | _ChangeBasis |
CBaseNode | _Selection |
Friends |
class | CIterator |
Detailed Description
template<class T> template class NL3D::CQuadGrid
This container is a simple grid, used to quickly find elements.
His purpose is similiar to CQuadTree, but it is a simple grid, so test are in O(1), not in O(log n). It is perfect for local lookup (like in collisions). Use it if you want to select small area, not large. Also, for best use, elements should have approximatively the same size, and this size should be little smaller than the size of a grid element...
By default, the quad grid is aligned on XY. (unlike the quadtree!!!)
Unlike the quadtree, the quadgrid is NOT geographicly delimited, ie, its limits "tiles"!! This is why no "center" is required. As a direct consequence, when you select something, you are REALLY not sure that what you select is not a mile away from your selection :) ....
Also, for memory optimisation, no bbox is stored in the quadgrid. Hence no particular selection is made on the Z components...
-
Author(s):
-
Lionel Berenguier , Nevrax France
-
Date:
-
2000
Definition at line 64 of file quad_grid.h.
Constructor & Destructor Documentation
template<classT> |
NL3D::CQuadGrid< T >::CQuadGrid<T> (
|
)
|
|
|
Default constructor, use axes XY!!!, has a size of 16, and EltSize is 1.
Definition at line 332 of file quad_grid.h. |
template<classT> |
NL3D::CQuadGrid< T >::~CQuadGrid<T> (
|
)
|
|
Member Function Documentation
template<classT> |
void NL3D::CQuadGrid<T>::addQuadNodeToSelection (
|
CQuadNode & quad ) [inline, private]
|
|
template<classT> |
void NL3D::CQuadGrid<T>::addToSelection (
|
CNode * ptr ) [inline, private]
|
|
template<classT> |
CQuadGrid< T >::CIterator NL3D::CQuadGrid< T >::begin (
|
void )
|
|
|
Return the first iterator of the selected element list.
begin and end are valid till the next insert.
Definition at line 528 of file quad_grid.h. |
template<classT> |
void NL3D::CQuadGrid< T >::changeBase (
|
const NLMISC::CMatrix & base )
|
|
|
Change the base matrix of the quad grid.
For exemple this code init the grid tree in the plane XZ: -
Parameters:
-
base
|
Base of the quad grid |
Definition at line 345 of file quad_grid.h. |
template<classT> |
void NL3D::CQuadGrid< T >::clear (
|
)
|
|
|
Clear the container. Elements are deleted, but the quadgrid is not erased.
Definition at line 371 of file quad_grid.h. |
template<classT> |
void NL3D::CQuadGrid< T >::clearSelection (
|
)
|
|
template<classT> |
void NL3D::CQuadGrid< T >::create (
|
uint size,
|
|
float eltSize )
|
|
|
Init the container.
container is first clear() ed. -
Parameters:
-
size
|
is the width and the height of the initial quad tree, in number of square. For performance view, this should be a power of 2, and <=32768. (eg: 256,512, 8, 16 ...) |
eltSize
|
is the width and height of an element. Must be >0. Notice that the quadgrid MUST be square!! |
Definition at line 350 of file quad_grid.h. |
template<classT> |
CQuadGrid< T >::CIterator NL3D::CQuadGrid< T >::end (
|
void )
|
|
|
Return the end iterator of the selected element list.
begin and end are valid till the next insert.
Definition at line 533 of file quad_grid.h. |
|
Erase an interator from the container.
-
Parameters:
-
it
|
is the iterator to erase. |
-
Returns:
-
if element is currently selected, the next selected element is returned, (or end()). if the element is not selected, end() is returned.
Definition at line 384 of file quad_grid.h. |
|
Insert a new element in the container.
-
Parameters:
-
bboxmin
|
is the corner of the bounding box of the element to insert with minimal coordinates. |
bboxmax
|
is the corner of the bounding box of the element to insert with maximal coordinates. |
val
|
is a reference on the value to insert. |
Definition at line 431 of file quad_grid.h. |
|
Select element intersecting a bounding box.
Clear the selection first. -
Parameters:
-
bboxmin
|
is the corner of the bounding box used to select |
bboxmax
|
is the corner of the bounding box used to select |
Definition at line 500 of file quad_grid.h. |
template<classT> |
void NL3D::CQuadGrid< T >::selectAll (
|
)
|
|
template<classT> |
void NL3D::CQuadGrid<T>::selectQuads (
|
CVector bmin,
|
|
CVector bmax,
|
|
sint & x0,
|
|
sint & x1,
|
|
sint & y0,
|
|
sint & y1 ) [inline, private]
|
|
Friends And Related Function Documentation
template<classT> |
class CIterator [friend]
|
|
Member Data Documentation
template<classT> |
NLMISC::CMatrix NL3D::CQuadGrid<T>::_ChangeBasis [private]
|
|
template<classT> |
float NL3D::CQuadGrid<T>::_EltSize [private]
|
|
template<classT> |
std::vector< CQuadNode > NL3D::CQuadGrid<T>::_Grid [private]
|
|
template<classT> |
CBaseNode NL3D::CQuadGrid<T>::_Selection [private]
|
|
template<classT> |
sint NL3D::CQuadGrid<T>::_Size [private]
|
|
template<classT> |
sint NL3D::CQuadGrid<T>::_SizePower [private]
|
|
The documentation for this class was generated from the following file:
|
|