DGtal  0.9.2
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/CUnsignedNumber.h"
48 #include "DGtal/kernel/CIntegralNumber.h"
49 #include "DGtal/kernel/CInteger.h"
50 
51 #include "DGtal/base/Bits.h"
53 
54 namespace DGtal
55 {
56 
58  // template class Morton
76  template <typename THashKey, typename TPoint >
77  class Morton
78  {
79  public:
80  typedef THashKey HashKey;
81  typedef TPoint Point;
82  typedef typename Point::Coordinate Coordinate;
83 
87 
88  BOOST_STATIC_CONSTANT(Dimension, dimension = TPoint::dimension);
89 
94  Morton();
95 
101  void interleaveBits(const Point & aPoint, HashKey & output) const;
102 
103 
113  HashKey keyFromCoordinates(const std::size_t treeDepth, const Point & coordinates) const;
114 
121  void coordinatesFromKey(const HashKey key, Point & coordinates) const;
122 
128  inline HashKey parentKey(const HashKey key) const
129  {
130  return key >> dimension;
131  }
132 
140  void brotherKeys(const HashKey key, HashKey* result ) const;
141 
142 
149  void childrenKeys(const HashKey key, HashKey* result ) const;
150 
151  private:
152 
154  //boost::array< HashKey,LOG2<sizeof(HashKey)*8>::VALUE> myDilateMasks;
155  //boost::array< HashKey,LOG2<sizeof(HashKey)*8>::VALUE> myContractMasks;
156  };
157 } // namespace DGtal
158 
159 
160 // //
163 // Includes inline functions
164 #include "DGtal/images/Morton.ih"
165 
166 #endif // !defined Morton_h
167 
168 #undef Morton_RECURSES
169 #endif // else defined(Morton_RECURSES)
Point::Coordinate Coordinate
Definition: Morton.h:82
void childrenKeys(const HashKey key, HashKey *result) const
Component Coordinate
Type for Point elements.
Definition: PointVector.h:158
BOOST_STATIC_CONSTANT(Dimension, dimension=TPoint::dimension)
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...
HashKey keyFromCoordinates(const std::size_t treeDepth, const Point &coordinates) const
BOOST_CONCEPT_ASSERT((concepts::CUnsignedNumber< THashKey >))
DGtal::uint32_t Dimension
Definition: Common.h:113
THashKey HashKey
Definition: Morton.h:80
HashKey parentKey(const HashKey key) const
Definition: Morton.h:128
void brotherKeys(const HashKey key, HashKey *result) const
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:87
Aim: Concept checking for Integral Numbers. Models of this concept should be listed in NumberTraits c...
void interleaveBits(const Point &aPoint, HashKey &output) const
DGtal is the top-level namespace which contains all DGtal functions and types.
void coordinatesFromKey(const HashKey key, Point &coordinates) const
TPoint Point
Definition: Morton.h:81
Aim: Implements the binary Morton code construction in nD.
Definition: Morton.h:77