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