CellLevelTreeStrategy.h
Go to the documentation of this file.
1 #ifndef GfxTL__CELLLEVELTREESTRATEGY_HEADER__
2 #define GfxTL__CELLLEVELTREESTRATEGY_HEADER__
3 
4 namespace GfxTL
5 {
6  template <class InheritedStrategyT>
8  {
9  typedef typename InheritedStrategyT::value_type value_type;
10 
11  class CellData : public InheritedStrategyT::CellData
12  {
13  public:
14  const size_t
15  Level() const
16  {
17  return m_level;
18  }
19 
20  void
21  Level(size_t l)
22  {
23  m_level = l;
24  }
25 
26  private:
27  size_t m_level;
28  };
29 
30  template <class BaseT>
31  class StrategyBase : public InheritedStrategyT::template StrategyBase<BaseT>
32  {
33  public:
34  typedef typename InheritedStrategyT::template StrategyBase<BaseT> BaseType;
35  typedef typename BaseType::CellType CellType;
36 
37  protected:
38  class BuildInformation : public BaseType::BuildInformation
39  {
40  public:
41  size_t
42  Level() const
43  {
44  return m_level;
45  }
46 
47  void
48  Level(size_t l)
49  {
50  m_level = l;
51  }
52 
53  private:
54  size_t m_level;
55  };
56 
57  template <class BaseTraversalT>
58  class CellLevelTraversalInformation : public BaseTraversalT
59  {
60  };
61 
62  template <class BuildInformationT>
63  void
64  InitRootBuildInformation(BuildInformationT* bi)
65  {
66  BaseType::InitRootBuildInformation(bi);
67  bi->Level(0);
68  }
69 
70  template <class BuildInformationT>
71  void
73  const BuildInformationT& parentInfo,
74  unsigned int childIdx,
75  BuildInformationT* bi) const
76  {
77  BaseType::InitBuildInformation(parent, parentInfo, childIdx, bi);
78  bi->Level(parentInfo.Level() + 1);
79  }
80 
81  template <class BuildInformationT>
82  void
83  InitRoot(const BuildInformationT& bi, CellType* root)
84  {
85  BaseType::InitRoot(bi, root);
86  root->Level(bi.Level());
87  }
88 
89  template <class BuildInformationT>
90  void
91  InitCell(const CellType& parent,
92  const BuildInformationT& pbi,
93  unsigned int child,
94  const BuildInformationT& bi,
95  CellType* cell)
96  {
97  BaseType::InitCell(parent, pbi, child, bi, cell);
98  cell->Level(bi.Level());
99  }
100 
101  template <class TraversalInformationT>
102  const size_t
103  CellLevel(const CellType& cell, const TraversalInformationT&) const
104  {
105  return cell.Level();
106  }
107  };
108  };
109 }; // namespace GfxTL
110 
111 #endif
GfxTL::CellLevelTreeStrategy::StrategyBase
Definition: CellLevelTreeStrategy.h:31
GfxTL::CellLevelTreeStrategy::StrategyBase::BuildInformation::Level
size_t Level() const
Definition: CellLevelTreeStrategy.h:42
GfxTL::CellLevelTreeStrategy::CellData::Level
void Level(size_t l)
Definition: CellLevelTreeStrategy.h:21
GfxTL::CellLevelTreeStrategy::StrategyBase::CellType
BaseType::CellType CellType
Definition: CellLevelTreeStrategy.h:35
GfxTL::CellLevelTreeStrategy::StrategyBase::CellLevelTraversalInformation
Definition: CellLevelTreeStrategy.h:58
GfxTL::CellLevelTreeStrategy::StrategyBase::InitBuildInformation
void InitBuildInformation(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, BuildInformationT *bi) const
Definition: CellLevelTreeStrategy.h:72
GfxTL::CellLevelTreeStrategy::value_type
InheritedStrategyT::value_type value_type
Definition: CellLevelTreeStrategy.h:9
GfxTL::CellLevelTreeStrategy::CellData
Definition: CellLevelTreeStrategy.h:11
GfxTL
Definition: AABox.h:9
GfxTL::CellLevelTreeStrategy::StrategyBase::InitCell
void InitCell(const CellType &parent, const BuildInformationT &pbi, unsigned int child, const BuildInformationT &bi, CellType *cell)
Definition: CellLevelTreeStrategy.h:91
GfxTL::CellLevelTreeStrategy::StrategyBase::InitRoot
void InitRoot(const BuildInformationT &bi, CellType *root)
Definition: CellLevelTreeStrategy.h:83
GfxTL::CellLevelTreeStrategy
Definition: CellLevelTreeStrategy.h:7
GfxTL::CellLevelTreeStrategy::StrategyBase::CellLevel
const size_t CellLevel(const CellType &cell, const TraversalInformationT &) const
Definition: CellLevelTreeStrategy.h:103
GfxTL::CellLevelTreeStrategy::CellData::Level
const size_t Level() const
Definition: CellLevelTreeStrategy.h:15
GfxTL::CellLevelTreeStrategy::StrategyBase::BaseType
InheritedStrategyT::template StrategyBase< BaseT > BaseType
Definition: CellLevelTreeStrategy.h:34
GfxTL::CellLevelTreeStrategy::StrategyBase::InitRootBuildInformation
void InitRootBuildInformation(BuildInformationT *bi)
Definition: CellLevelTreeStrategy.h:64
GfxTL::CellLevelTreeStrategy::StrategyBase::BuildInformation::Level
void Level(size_t l)
Definition: CellLevelTreeStrategy.h:48
GfxTL::CellLevelTreeStrategy::StrategyBase::BuildInformation
Definition: CellLevelTreeStrategy.h:38