DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Morton.h
1 
17 #pragma once
18 
31 #if defined(Morton_RECURSES)
32 #error Recursive header files inclusion detected in Morton.h
33 #else // defined(Morton_RECURSES)
34 
35 #define Morton_RECURSES
36 
37 #if !defined Morton_h
38 
39 #define Morton_h
40 
42 // Inclusions
43 #include <iostream>
44 #include <boost/array.hpp>
45 #include "DGtal/base/Common.h"
46 #include "DGtal/kernel/PointVector.h"
47 #include "DGtal/kernel/CUnsignedInteger.h"
48 #include "DGtal/kernel/CInteger.h"
49 
50 #include "DGtal/base/Bits.h"
52 
53 namespace DGtal
54 {
55 
57  // template class Morton
75  template <typename THashKey, typename TPoint >
76  class Morton
77  {
78  public:
79  typedef THashKey HashKey;
80  typedef TPoint Point;
81  typedef typename Point::Coordinate Coordinate;
83 
86 
91  Morton();
92 
98  void interleaveBits(const Point & aPoint, HashKey & output) const;
99 
100 
110  HashKey keyFromCoordinates(const std::size_t treeDepth, const Point & coordinates) const;
111 
118  void coordinatesFromKey(const HashKey key, Point & coordinates) const;
119 
125  inline HashKey parentKey(const HashKey key) const
126  {
127  return key >> dimension;
128  }
129 
137  void brotherKeys(const HashKey key, HashKey* result ) const;
138 
139 
146  void childrenKeys(const HashKey key, HashKey* result ) const;
147 
148  private:
149 
151  //boost::array< HashKey,LOG2<sizeof(HashKey)*8>::VALUE> myDilateMasks;
152  //boost::array< HashKey,LOG2<sizeof(HashKey)*8>::VALUE> myContractMasks;
153  };
154 } // namespace DGtal
155 
156 
157 // //
160 // Includes inline functions
161 #include "DGtal/images/Morton.ih"
162 
163 #endif // !defined Morton_h
164 
165 #undef Morton_RECURSES
166 #endif // else defined(Morton_RECURSES)