TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator Class Reference

#include <PointHashGrid.h>

Public Member Functions

bool operator!= (const BoxIterator &other) const
 
bool operator== (const BoxIterator &other) const
 
BoxIteratoroperator++ ()
 
BoxIterator operator++ (int)
 
const Valueoperator* () const
 
const Valueoperator-> () const
 
 operator Value * () const
 
bool hasMore () const
 
bool isValid () const
 

Private Member Functions

void advanceCell ()
 
void advance ()
 
 BoxIterator ()
 
 BoxIterator (const ThisType *grid, bool exact, const AABox &box)
 
const Valuevalue () const
 
const Vector3position () const
 
BoxIteratoroperator= (const BoxIterator &)
 

Private Attributes

bool m_isEnd
 
const ThisTypem_grid
 
Vector3int32 m_lo
 
Vector3int32 m_hi
 
bool m_exact
 
AABox m_box
 
Vector3int32 m_current
 
Cellm_cell
 
int m_arrayIndex
 
const int m_epoch
 

Friends

class ThisType
 
class SphereIterator
 

Constructor & Destructor Documentation

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::BoxIterator ( )
inlineprivate

End iterator

610 : m_isEnd(true), m_grid(NULL), m_exact(true), m_current(0,0,0), m_cell(NULL), m_arrayIndex(0), m_epoch(0) {}
Cell * m_cell
Definition: PointHashGrid.h:553
Vector3int32 m_current
Definition: PointHashGrid.h:550
arena_t NULL
Definition: jemalloc_internal.h:624
const ThisType * m_grid
Definition: PointHashGrid.h:533
bool m_exact
Definition: PointHashGrid.h:542
bool m_isEnd
Definition: PointHashGrid.h:531
const int m_epoch
Definition: PointHashGrid.h:558
int m_arrayIndex
Definition: PointHashGrid.h:556
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::BoxIterator ( const ThisType grid,
bool  exact,
const AABox box 
)
inlineprivate

Begin iterator

613  :
614  m_isEnd(false),
615  m_grid(grid),
616  m_exact(exact),
617  m_box(box),
618  m_current(-1, 0 ,0),
619  m_cell(NULL),
620  m_arrayIndex(0),
621  m_epoch(grid->m_epoch) {
622 
623  m_grid->getCellCoord(box.low(), m_lo);
624  m_grid->getCellCoord(box.high(), m_hi);
625 
626  // Get to the first value
627  m_current = m_lo;
628  // Back up one so that advancing takes us to the first
629  --m_current.x;
630  advance();
631  }
AABox m_box
Definition: PointHashGrid.h:545
Cell * m_cell
Definition: PointHashGrid.h:553
Vector3int32 m_current
Definition: PointHashGrid.h:550
arena_t NULL
Definition: jemalloc_internal.h:624
const ThisType * m_grid
Definition: PointHashGrid.h:533
bool m_exact
Definition: PointHashGrid.h:542
bool m_isEnd
Definition: PointHashGrid.h:531
void advance()
Definition: PointHashGrid.h:585
Vector3int32 m_hi
Definition: PointHashGrid.h:539
const int m_epoch
Definition: PointHashGrid.h:558
int m_arrayIndex
Definition: PointHashGrid.h:556
Vector3int32 m_lo
Definition: PointHashGrid.h:536

+ Here is the call graph for this function:

Member Function Documentation

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
void G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::advance ( )
inlineprivate

Advance to the next value

585  {
586  debugAssert(! m_isEnd);
587 
588  do {
589  ++m_arrayIndex;
590  bool inConstructor = (m_cell == NULL);
591  if (inConstructor || m_arrayIndex >= m_cell->size()) {
592  advanceCell();
593  m_arrayIndex = 0;
594 
595  if (m_isEnd) {
596  // Ran out of values
597  return;
598  }
599  debugAssert(m_cell != NULL);
600  }
601 
602  // Advance until we have a value that can be returned, either
603  // because we don't care about exactness or because it is
604  // guaranteed to be within the box.
605  } while (m_exact && ! m_box.contains(position()));
606  }
AABox m_box
Definition: PointHashGrid.h:545
Cell * m_cell
Definition: PointHashGrid.h:553
bool contains(const AABox &other) const
Definition: AABox.h:238
arena_t NULL
Definition: jemalloc_internal.h:624
void advanceCell()
Definition: PointHashGrid.h:562
bool m_exact
Definition: PointHashGrid.h:542
bool m_isEnd
Definition: PointHashGrid.h:531
#define debugAssert(exp)
Definition: debugAssert.h:160
const Vector3 & position() const
Definition: PointHashGrid.h:639
int size() const
Definition: SmallArray.h:37
int m_arrayIndex
Definition: PointHashGrid.h:556

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
void G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::advanceCell ( )
inlineprivate

Called from advance()

562  {
563  do {
564  ++m_current.x;
565  if (m_current.x > m_hi.x) {
566  m_current.x = m_lo.x;
567  ++m_current.y;
568  if (m_current.y > m_hi.y) {
569  m_current.y = m_lo.y;
570  ++m_current.z;
571  if (m_current.z > m_hi.z) {
572  m_isEnd = true;
573  return;
574  }
575  }
576  }
577 
578  // Pick up the new cell
579  m_cell = m_grid->m_data.getPointer(m_current);
580  // Keep advancing if the cell does not exist
581  } while ((m_cell == NULL) || (m_cell->size() == 0));
582  }
Cell * m_cell
Definition: PointHashGrid.h:553
Vector3int32 m_current
Definition: PointHashGrid.h:550
arena_t NULL
Definition: jemalloc_internal.h:624
const ThisType * m_grid
Definition: PointHashGrid.h:533
bool m_isEnd
Definition: PointHashGrid.h:531
int size() const
Definition: SmallArray.h:37
Vector3int32 m_hi
Definition: PointHashGrid.h:539
Vector3int32 m_lo
Definition: PointHashGrid.h:536

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::hasMore ( ) const
inline
Deprecated:
Use isValid
687  {
688  return ! m_isEnd;
689  }
bool m_isEnd
Definition: PointHashGrid.h:531
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::isValid ( ) const
inline
691  {
692  return ! m_isEnd;
693  }
bool m_isEnd
Definition: PointHashGrid.h:531

+ Here is the caller graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator Value * ( ) const
inline
684 { return &value(); }
const Value & value() const
Definition: PointHashGrid.h:633

+ Here is the call graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator!= ( const BoxIterator other) const
inline
649  {
650  if (other.m_isEnd && m_isEnd) {
651  return false;
652  } else {
653  return (m_isEnd != other.m_isEnd) ||
654  (m_cell != other.m_cell) ||
655  (m_arrayIndex != other.m_arrayIndex);
656  }
657  }
Cell * m_cell
Definition: PointHashGrid.h:553
bool m_isEnd
Definition: PointHashGrid.h:531
int m_arrayIndex
Definition: PointHashGrid.h:556
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const Value& G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator* ( ) const
inline
682 { return value(); }
const Value & value() const
Definition: PointHashGrid.h:633

+ Here is the call graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
BoxIterator& G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator++ ( )
inline

Preincrement

664  {
665  debugAssert(! m_isEnd);
666  debugAssertM(m_epoch == m_grid->m_epoch,
667  "It is illegal to mutate the HashGrid "
668  "while iterating through it.");
669 
670  advance();
671 
672  return *this;
673  }
const ThisType * m_grid
Definition: PointHashGrid.h:533
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
bool m_isEnd
Definition: PointHashGrid.h:531
#define debugAssert(exp)
Definition: debugAssert.h:160
void advance()
Definition: PointHashGrid.h:585
const int m_epoch
Definition: PointHashGrid.h:558

+ Here is the call graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
BoxIterator G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator++ ( int  )
inline

Post increment (slower)

676  {
677  Iterator old = *this;
678  ++(*this);
679  return old;
680  }
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const Value* G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator-> ( ) const
inline
683 { return &value(); }
const Value & value() const
Definition: PointHashGrid.h:633

+ Here is the call graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
BoxIterator& G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator= ( const BoxIterator )
private
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::operator== ( const BoxIterator other) const
inline
659  {
660  return !(*this != other);
661  }
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const Vector3& G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::position ( ) const
inlineprivate

Used by SphereIterator::advance()

639  {
640  debugAssert(! m_isEnd);
641  return (*m_cell)[m_arrayIndex].position;
642  }
Cell * m_cell
Definition: PointHashGrid.h:553
bool m_isEnd
Definition: PointHashGrid.h:531
#define debugAssert(exp)
Definition: debugAssert.h:160
int m_arrayIndex
Definition: PointHashGrid.h:556

+ Here is the caller graph for this function:

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const Value& G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::value ( ) const
inlineprivate
633  {
634  debugAssert(! m_isEnd);
635  return (*m_cell)[m_arrayIndex].value;
636  }
Cell * m_cell
Definition: PointHashGrid.h:553
bool m_isEnd
Definition: PointHashGrid.h:531
#define debugAssert(exp)
Definition: debugAssert.h:160
int m_arrayIndex
Definition: PointHashGrid.h:556

+ Here is the caller graph for this function:

Friends And Related Function Documentation

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
friend class SphereIterator
friend
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
friend class ThisType
friend

Member Data Documentation

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
int G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_arrayIndex
private

Index within m_cell of the current value

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
AABox G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_box
private

The underlying box in 3D space

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
Cell* G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_cell
private

The current cell.

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
Vector3int32 G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_current
private

The iterator winds through the 3D grid between m_lo and (m_lo + m_extent) in Z,Y,X-major order. This is the index keeping track of how far it has come

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const int G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_epoch
private
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_exact
private

If true, test values against m_box before returning them.

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
const ThisType* G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_grid
private
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
Vector3int32 G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_hi
private

Upper bound on the boxes covered, inclusive.

template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
bool G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_isEnd
private
template<class Value, class PosFunc = PositionTrait<Value>, class EqualsFunc = EqualsTrait<Value>>
Vector3int32 G3D::PointHashGrid< Value, PosFunc, EqualsFunc >::BoxIterator::m_lo
private

Lower bound on the boxes covered, inclusive.


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