DGtal  1.4.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)
35 #define Morton_RECURSES
36 
37 #if !defined Morton_h
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)
Aim: Implements the binary Morton code construction in nD.
Definition: Morton.h:78
BOOST_STATIC_CONSTANT(Dimension, dimension=TPoint::dimension)
void interleaveBits(const Point &aPoint, HashKey &output) const
BOOST_CONCEPT_ASSERT((concepts::CInteger< Coordinate >))
void childrenKeys(const HashKey key, HashKey *result) const
BOOST_CONCEPT_ASSERT((concepts::CIntegralNumber< THashKey >))
BOOST_CONCEPT_ASSERT((concepts::CUnsignedNumber< THashKey >))
void coordinatesFromKey(const HashKey key, Point &coordinates) const
TPoint Point
Definition: Morton.h:81
HashKey keyFromCoordinates(const std::size_t treeDepth, const Point &coordinates) const
void brotherKeys(const HashKey key, HashKey *result) const
Point::Coordinate Coordinate
Definition: Morton.h:82
THashKey HashKey
Definition: Morton.h:80
HashKey parentKey(const HashKey key) const
Definition: Morton.h:128
DGtal is the top-level namespace which contains all DGtal functions and types.
DGtal::uint32_t Dimension
Definition: Common.h:136
Aim: Concept checking for Integer Numbers. More precisely, this concept is a refinement of both CEucl...
Definition: CInteger.h:88
Aim: Concept checking for Integral Numbers. Models of this concept should be listed in NumberTraits c...
Aim: Concept checking for Unsigned numbers. Models of this concept should be listed in NumberTraits c...
const Point aPoint(3, 4)