CellLevelTreeStrategy.h
Go to the documentation of this file.
1#ifndef GfxTL__CELLLEVELTREESTRATEGY_HEADER__
2#define GfxTL__CELLLEVELTREESTRATEGY_HEADER__
3
4namespace 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
void InitCell(const CellType &parent, const BuildInformationT &pbi, unsigned int child, const BuildInformationT &bi, CellType *cell)
void InitRoot(const BuildInformationT &bi, CellType *root)
void InitBuildInformation(const CellType &parent, const BuildInformationT &parentInfo, unsigned int childIdx, BuildInformationT *bi) const
const size_t CellLevel(const CellType &cell, const TraversalInformationT &) const
InheritedStrategyT::template StrategyBase< BaseT > BaseType
void InitRootBuildInformation(BuildInformationT *bi)
Definition AABox.h:10
InheritedStrategyT::value_type value_type