33 #include "DGtal/images/Morton.h"
39 template <
typename HashKey,
typename Po
int >
47 template <
typename HashKey,
typename Po
int >
52 unsigned int coordSize = (
sizeof (
HashKey ) <<3 ) / dimension;
55 for (
unsigned int i = 0; i < coordSize; ++i )
56 for (
unsigned int n = 0; n < dimension; ++n )
58 if ( ( aPoint[n] ) & (
static_cast<Coordinate> ( 1 ) << i ) )
59 output |= static_cast<Coordinate> ( 1 ) << (( i*dimension ) +n);
64 template <
typename HashKey,
typename Po
int >
66 const Point & coordinates )
const
70 interleaveBits ( coordinates, result );
74 result |= (
static_cast<HashKey> ( 1 ) << dimension*treeDepth );
81 template <
typename HashKey,
typename Po
int >
86 keycopy <<= dimension;
89 for ( std::size_t i = 0;
90 i < POW<2,dimension>::VALUE;
93 result[i] = ( keycopy & mask ) |i;
97 template <
typename HashKey,
typename Po
int >
103 for ( std::size_t i = 0; i < POW<2,dimension>::VALUE; ++i )
105 HashKey key2 = ( key & mask ) |i;
114 template <
typename HashKey,
typename Po
int >
119 for (
int i = (
sizeof (
HashKey ) <<3 )-1; i >= 0; --i )
120 if ( akey & Bits::mask<HashKey> ( i ) )
122 akey &= ~
Bits::mask<HashKey> ( i );
127 for ( std::size_t i = 0; i < dimension; ++i )
131 for ( std::size_t bitPos = 0; bitPos < (
sizeof (
HashKey ) <<3 ) / dimension; ++bitPos )
133 if ( akey & Bits::mask<HashKey> ( (
unsigned int)(bitPos*dimension+i) ) )
135 coordinates[(
Dimension)i] |= Bits::mask<HashKey> ( (
unsigned int)bitPos );