34 #include <cugar/basic/types.h> 35 #include <cugar/linalg/vector.h> 67 x = (x | (x << 8)) & 0x00FF00FF;
68 x = (x | (x << 4)) & 0x0F0F0F0F;
69 x = (x | (x << 2)) & 0x33333333;
70 x = (x | (x << 1)) & 0x55555555;
72 y = (y | (y << 8)) & 0x00FF00FF;
73 y = (y | (y << 4)) & 0x0F0F0F0F;
74 y = (y | (y << 2)) & 0x33333333;
75 y = (y | (y << 1)) & 0x55555555;
90 x = (x | (x << 16)) & 0x030000FF;
91 x = (x | (x << 8)) & 0x0300F00F;
92 x = (x | (x << 4)) & 0x030C30C3;
93 x = (x | (x << 2)) & 0x09249249;
95 y = (y | (y << 16)) & 0x030000FF;
96 y = (y | (y << 8)) & 0x0300F00F;
97 y = (y | (y << 4)) & 0x030C30C3;
98 y = (y | (y << 2)) & 0x09249249;
100 z = (z | (z << 16)) & 0x030000FF;
101 z = (z | (z << 8)) & 0x0300F00F;
102 z = (z | (z << 4)) & 0x030C30C3;
103 z = (z | (z << 2)) & 0x09249249;
105 return x | (y << 1) | (z << 2);
119 x = (x | (x << 16)) & 0x0000FFFF0000FFFFull;
120 x = (x | (x << 8)) & 0x00FF00FF00FF00FFull;
121 x = (x | (x << 4)) & 0x0F0F0F0F0F0F0F0Full;
122 x = (x | (x << 2)) & 0x3333333333333333ull;
123 x = (x | (x << 1)) & 0x5555555555555555ull;
125 y = (y | (y << 16)) & 0x0000FFFF0000FFFFull;
126 y = (y | (y << 8)) & 0x00FF00FF00FF00FFull;
127 y = (y | (y << 4)) & 0x0F0F0F0F0F0F0F0Full;
128 y = (y | (y << 2)) & 0x3333333333333333ull;
129 y = (y | (y << 1)) & 0x5555555555555555ull;
144 uint32 lo_x = x & 1023u;
145 uint32 lo_y = y & 1023u;
146 uint32 lo_z = z & 1023u;
147 uint32 hi_x = x >> 10u;
148 uint32 hi_y = y >> 10u;
149 uint32 hi_z = z >> 10u;
159 template <
typename Integer, u
int32 DIM,
typename BboxType>
164 template <
typename BboxType>
167 typedef typename BboxType::value_type value_type;
168 typedef typename BboxType::vector_type vector_type;
176 value_type(1.0) / (bbox[1][0] - bbox[0][0]),
177 value_type(1.0) / (bbox[1][1] - bbox[0][1]) )
180 template <
typename Po
int_type>
181 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 operator() (
const Point_type point)
const 183 uint32 x =
quantize( (point[0] - m_base[0]) * m_inv[0], 65536u );
184 uint32 y =
quantize( (point[1] - m_base[1]) * m_inv[1], 65536u );
189 const vector_type m_base;
190 const vector_type m_inv;
195 template <
typename BboxType>
198 typedef typename BboxType::value_type value_type;
199 typedef typename BboxType::vector_type vector_type;
207 value_type(1.0) / (bbox[1][0] - bbox[0][0]),
208 value_type(1.0) / (bbox[1][1] - bbox[0][1]) )
211 template <
typename Po
int_type>
212 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint64 operator() (
const Point_type point)
const 214 uint32 x =
quantize( (point[0] - m_base[0]) * m_inv[0], 0xFFFFFFFFu );
215 uint32 y =
quantize( (point[1] - m_base[1]) * m_inv[1], 0xFFFFFFFFu );
220 const vector_type m_base;
221 const vector_type m_inv;
226 template <
typename BboxType>
229 typedef typename BboxType::value_type value_type;
230 typedef typename BboxType::vector_type vector_type;
238 value_type(1.0) / (bbox[1][0] - bbox[0][0]),
239 value_type(1.0) / (bbox[1][1] - bbox[0][1]),
240 value_type(1.0) / (bbox[1][2] - bbox[0][2]) )
243 template <
typename Po
int_type>
244 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 operator() (
const Point_type point)
const 246 uint32 x =
quantize( (point[0] - m_base[0]) * m_inv[0], 1024u );
247 uint32 y =
quantize( (point[1] - m_base[1]) * m_inv[1], 1024u );
248 uint32 z =
quantize( (point[2] - m_base[2]) * m_inv[2], 1024u );
253 const vector_type m_base;
254 const vector_type m_inv;
259 template <
typename BboxType>
262 typedef typename BboxType::value_type value_type;
263 typedef typename BboxType::vector_type vector_type;
271 value_type(1.0) / (bbox[1][0] - bbox[0][0]),
272 value_type(1.0) / (bbox[1][1] - bbox[0][1]),
273 value_type(1.0) / (bbox[1][2] - bbox[0][2]) )
276 template <
typename Po
int_type>
277 CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint64 operator() (
const Point_type point)
const 279 uint32 x =
quantize( (point[0] - m_base[0]) * m_inv[0], 1u << 20 );
280 uint32 y =
quantize( (point[1] - m_base[1]) * m_inv[1], 1u << 20 );
281 uint32 z =
quantize( (point[2] - m_base[2]) * m_inv[2], 1u << 20 );
286 const vector_type m_base;
287 const vector_type m_inv;
CUGAR_HOST_DEVICE morton_functor(const BboxType &bbox)
Definition: morton.h:235
CUGAR_HOST_DEVICE uint32 quantize(const float x, const uint32 n)
Definition: numbers.h:600
CUGAR_HOST_DEVICE morton_functor(const Bbox2f &bbox)
Definition: morton.h:204
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint32 morton_code(uint32 x, uint32 y)
Definition: morton.h:60
CUGAR_FORCEINLINE CUGAR_HOST_DEVICE uint64 morton_code60(uint32 _x, uint32 _y)
Definition: morton.h:112
Define a vector_view POD type and plain_view() for std::vector.
Definition: diff.h:38
CUGAR_HOST_DEVICE morton_functor(const BboxType &bbox)
Definition: morton.h:268
CUGAR_HOST_DEVICE morton_functor(const Bbox2f &bbox)
Definition: morton.h:173