ScoreAACubeTreeStrategy.h
Go to the documentation of this file.
1 #ifndef SCOREAACUBETREESTRATEGY_HEADER
2 #define SCOREAACUBETREESTRATEGY_HEADER
3 #include "basic.h"
4 #include <MiscLib/Vector.h>
5 #include <GfxTL/NullClass.h>
7 #include <MiscLib/Random.h>
8 
9 template< unsigned int DimT, class InheritedStrategyT >
11 {
12  typedef typename InheritedStrategyT::value_type value_type;
13 
14  class CellData
15  : public InheritedStrategyT::CellData
16  {
17  public:
20  const ScalarType Radius() const
21  {
22  return m_radius;
23  }
25  {
26  return m_radius;
27  }
28  //size_t GlobalSize() const { return m_globalSize; }
29  //void GlobalSize(size_t globalSize) { m_globalSize = globalSize; }
30 
31  private:
32  ScalarType m_radius;
33  //size_t m_globalSize;
34  };
35 
36  template< class BaseT >
38  : public InheritedStrategyT::template StrategyBase< BaseT >
39  {
40 public:
41  typedef typename InheritedStrategyT::template StrategyBase< BaseT >
43  typedef typename BaseType::CellType CellType;
46 
47  template< class ShapeT, class ScoreT >
48  void Score(const ShapeT& shape, /*size_t maxCellSize,*/
49  ScoreT* score) const
50  {
51  typedef typename BaseType::template
52  TraversalInformationBase< GfxTL::NullClass > tibT;
53  typedef typename BaseType::template
54  CellCenterTraversalInformation< tibT > TraversalInformation;
55  TraversalInformation ti;
56  this->InitRootTraversalInformation(*BaseType::Root(), &ti);
57  Score(*BaseType::Root(), ti, shape, /*maxCellSize,*/ score);
58  }
59 
60 protected:
61  template< class BuildInformationT >
62  void InitRoot(const BuildInformationT& bi, CellType* root)
63  {
64  BaseType::InitRoot(bi, root);
65  root->Radius() = bi.Cube().DiagLength() / 2;
66  }
67  template< class BuildInformationT >
68  void InitCell(const CellType& parent, const BuildInformationT& pbi,
69  unsigned int child, const BuildInformationT& bi,
70  CellType* cell)
71  {
72  BaseType::InitCell(parent, pbi, child, bi, cell);
73  cell->Radius() = bi.Cube().DiagLength() / 2;
74  }
75 
76 private:
77  template< class TraversalInformationT, class ShapeT, class ScoreT >
78  void Score(const CellType& cell, const TraversalInformationT& ti,
79  const ShapeT& shape, /*size_t maxCellSize,*/ ScoreT* score) const
80  {
81  if (/*cell.Size() <= maxCellSize ||*/ this->IsLeaf(cell))
82  {
83  //score->UpperBound() += cell.GlobalSize();
84  //score->SampledPoints() += cell.Size();
85  //typename BaseType::CellRange range;
86  //BaseType::GetCellRange(cell, ti, &range);
87  //if(maxCellSize > 1)
88  //{
89  // size_t r = MiscLib::rn_rand() % cell.Size();
90  // (*score)(shape, *this, Dereference(range.first + r));
91  //}
92  //else
93  //{
94  for (typename BaseType::HandleType h = cell.Range().first;
95  h != cell.Range().second; ++h)
96  {
97  (*score)(shape, *this, this->Dereference(h));
98  }
99  //}
100  return;
101  }
102  for (unsigned int i = 0; i < CellType::NChildren; ++i)
103  {
104  if (!this->ExistChild(cell, i))
105  {
106  continue;
107  }
108  TraversalInformationT cti;
109  this->InitTraversalInformation(cell, ti, i, &cti);
110  //typename BaseType::CellCenterType center;
111  //CellCenter(cell[i], cti, &center);
112  ScalarType dist = shape.Distance(*((const Vec3f*)&cell[i].Center()/*center*/));
113  if (dist < cell[i].Radius() + score->Epsilon())
114  {
115  Score(cell[i], cti, shape, /*maxCellSize,*/ score);
116  }
117  }
118  }
119  };
120 };
121 
122 #endif
Vector.h
Vec3f
Definition: basic.h:16
ScoreAACubeTreeStrategy::CellData
Definition: ScoreAACubeTreeStrategy.h:14
ScoreAACubeTreeStrategy::StrategyBase::ScalarType
GfxTL::ScalarTypeDeferer< value_type >::ScalarType ScalarType
Definition: ScoreAACubeTreeStrategy.h:45
GfxTL::ScalarTypeDeferer::ScalarType
PointT::value_type ScalarType
Definition: ScalarTypeDeferer.h:14
ScoreAACubeTreeStrategy::value_type
InheritedStrategyT::value_type value_type
Definition: ScoreAACubeTreeStrategy.h:12
ScoreAACubeTreeStrategy::StrategyBase::InitCell
void InitCell(const CellType &parent, const BuildInformationT &pbi, unsigned int child, const BuildInformationT &bi, CellType *cell)
Definition: ScoreAACubeTreeStrategy.h:68
ScoreAACubeTreeStrategy::StrategyBase
Definition: ScoreAACubeTreeStrategy.h:37
ScoreAACubeTreeStrategy::CellData::Radius
ScalarType & Radius()
Definition: ScoreAACubeTreeStrategy.h:24
ScoreAACubeTreeStrategy::StrategyBase::CellType
BaseType::CellType CellType
Definition: ScoreAACubeTreeStrategy.h:43
ScoreAACubeTreeStrategy::CellData::Radius
const ScalarType Radius() const
Definition: ScoreAACubeTreeStrategy.h:20
ScoreAACubeTreeStrategy::CellData::ScalarType
GfxTL::ScalarTypeDeferer< value_type >::ScalarType ScalarType
Definition: ScoreAACubeTreeStrategy.h:19
ScoreAACubeTreeStrategy
Definition: ScoreAACubeTreeStrategy.h:10
Random.h
basic.h
NullClass.h
ScoreAACubeTreeStrategy::StrategyBase::InitRoot
void InitRoot(const BuildInformationT &bi, CellType *root)
Definition: ScoreAACubeTreeStrategy.h:62
ScoreAACubeTreeStrategy::StrategyBase::BaseType
InheritedStrategyT::template StrategyBase< BaseT > BaseType
Definition: ScoreAACubeTreeStrategy.h:42
ScoreAACubeTreeStrategy::StrategyBase::Score
void Score(const ShapeT &shape, ScoreT *score) const
Definition: ScoreAACubeTreeStrategy.h:48
ScalarTypeDeferer.h