1 #ifndef _PROTO_MORTON_H_ 2 #define _PROTO_MORTON_H_ 6 #include "Proto_Point.H" 9 #define LOGSIZE 16 // 21 // DIM*LOGSIZE must be less than the size (in bits) of (uint64_t). 10 #define MORTONSIZE 65536 // 2097152 // = 2^LOGSIZE. 13 #define LOGSIZE 10 // DIM*LOGSIZE must be less than the size (in bits) of (uint64_t). 14 #define MORTONSIZE 1024 // = 2^LOGSIZE. 17 #define LOGSIZE 16 // DIM*LOGSIZE must be less than the size (in bits) of (uint64_t). 18 #define MORTONSIZE 65536 // = 2^LOGSIZE. 21 #define LOGSIZE 12 // DIM*LOGSIZE must be less than the size (in bits) of (uint64_t). 22 #define MORTONSIZE 4096 // = 2^LOGSIZE. 25 #define LOGSIZE 10 // DIM*LOGSIZE must be less than the size (in bits) of (uint64_t). 26 #define MORTONSIZE 1024 // = 2^LOGSIZE. 39 array<vector<uint64_t>,DIM> m_morton1D;
44 PR_TIMERS(
"Morton define");
46 for (
int d = 0; d < DIM; d++)
48 m_morton1D[d]=vector<uint64_t>(MORTONSIZE);
52 for (uint64_t i = 0; i <MORTONSIZE; i++)
54 for (uint64_t d = 0; d < DIM;d++)
58 for (uint64_t logi = 0; logi < LOGSIZE; logi++)
60 for (uint64_t d = 0;d < DIM; d++)
63 ((i >> logi) & mask0) << (DIM*logi + d);
72 inline uint64_t mortonIndex(
const Point& a_pt,
const Morton& m_morton)
78 for (
int d = 0; d < DIM; d++)
80 retval +=m_morton.m_morton1D[d][a_pt[d]];
89 inline bool compareSecond(pair<Point,uint64_t> a_a,pair<Point,uint64_t> a_b)
90 {
return a_a.second < a_b.second;}
91 inline void mortonSort(vector<Point>& a_pts,
const Morton& m_morton)
93 vector<pair<Point,uint64_t> > sorter;
94 for (
int k = 0; k < a_pts.size();++k)
96 sorter.push_back(pair<Point,uint64_t>
97 (a_pts[k],mortonIndex(a_pts[k],m_morton)));
100 std::sort(sorter.begin(),sorter.end(),compareSecond);
101 for (
int k = 0; k < sorter.size();++k)
103 a_pts[k] = sorter[k].first;
Definition: Proto_Box.H:11