TNeighbourBinCaller.h
Go to the documentation of this file.
1 #ifndef ialgo_TNeighbourBinCaller_included
2 #define ialgo_TNeighbourBinCaller_included
3 
4 
5 // ACF includes
6 #include <istd/CVarIndex.h>
7 
8 
9 namespace ialgo
10 {
11 
12 
16 template <int SpaceDimension>
18 {
19 public:
21 
22  void InitForCyclicSpace(const istd::CVarIndex& spaceSizes, int leftTolerance, int rightTolerance);
23 
24  template <typename Visitor>
25  void VisitAllCorrelations(Visitor& visitor)
26  {
28  angleDeltaSizes.SetAllTo(m_leftTolerance + m_rightTolerance + 1);
29 
30  visitor.BeginVisiting();
31 
33  do{
34  int imageBinIndex = imageAngleIndices.GetIterationIndex(m_spaceSizes);
35 
36  if (visitor.BeginImageBin(imageBinIndex)){
37  istd::CVarIndex angleDeltaIndices(m_spaceSizes.GetDimensionsCount(), 0);
38  do{
39  istd::TIndex<SpaceDimension> modelAngleIndices;
40  for (int i = 0; i < SpaceDimension; ++i){
41  modelAngleIndices[i] = (imageAngleIndices[i] + angleDeltaIndices[i] + m_spaceSizes[i] - m_leftTolerance) % m_spaceSizes[i];
42  }
43 
44  int modelBinIndex = modelAngleIndices.GetIterationIndex(m_spaceSizes);
45 
46  visitor.VisitCorrelation(imageBinIndex, modelBinIndex);
47  } while (angleDeltaIndices.Increase(angleDeltaSizes));
48  }
49 
50  visitor.EndImageBin(imageBinIndex);
51  } while (imageAngleIndices.Increase(m_spaceSizes));
52 
53  visitor.EndVisiting();
54  }
55 
56 private:
57  istd::CVarIndex m_spaceSizes;
58  int m_leftTolerance;
59  int m_rightTolerance;
60 };
61 
62 
63 // public methods
64 
65 template <int SpaceDimension>
67 : m_spaceSizes(),
68  m_leftTolerance(0),
69  m_rightTolerance(0)
70 {
71 }
72 
73 
74 template <int SpaceDimension>
75 void TNeighbourBinCaller<SpaceDimension>::InitForCyclicSpace(const istd::CVarIndex& spaceSizes, int leftTolerance, int rightTolerance)
76 {
77  m_spaceSizes = spaceSizes;
78  m_leftTolerance = leftTolerance;
79  m_rightTolerance = rightTolerance;
80 }
81 
82 
83 } // namespace ialgo
84 
85 
86 #endif // !ialgo_TNeighbourBinCaller_included
87 
88 
Class providing mechanism to iterate over neighbours in some multidimensional discrete space...
void VisitAllCorrelations(Visitor &visitor)
void InitForCyclicSpace(const istd::CVarIndex &spaceSizes, int leftTolerance, int rightTolerance)
int GetDimensionsCount() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy