14 #ifndef SFCSORTBENCH_SFCSEARCH_H 15 #define SFCSORTBENCH_SFCSEARCH_H 28 int compare(
const void *ap,
const void *bp)
30 const T *a = (T *) ap;
31 const T *b = (T *) bp;
49 template <
typename TKey,
typename TOctant>
50 void SFC_treeSearch(TKey* pKeys , TOctant* pNodes,std::vector<unsigned int>& pSearchIndex,DendroIntL nKeyBegin,DendroIntL nKeyEnd,DendroIntL nNodeBegin,DendroIntL nNodeEnd,
unsigned int pMaxDepthBit,
unsigned int pMaxDepth,
unsigned int rot_id);
53 template <
typename TKey,
typename TOctant>
54 void SFC_treeSearch(TKey* pKeys , TOctant* pNodes,DendroIntL nKeyBegin,DendroIntL nKeyEnd,DendroIntL nNodeBegin,DendroIntL nNodeEnd,
unsigned int pMaxDepthBit,
unsigned int pMaxDepth,
unsigned int rot_id);
63 template <
typename TKey,
typename TOctant>
64 void SFC_treeSearch(TKey* pKeys , TOctant* pNodes,std::vector<unsigned int> & pSearchIndex,DendroIntL nKeyBegin,DendroIntL nKeyEnd,DendroIntL nNodeBegin,DendroIntL nNodeEnd,
unsigned int pMaxDepthBit,
unsigned int pMaxDepth,
unsigned int rot_id)
67 unsigned int lev=pMaxDepth-pMaxDepthBit;
68 DendroIntL splitterKeys[(NUM_CHILDREN + 1)];
69 DendroIntL splitterNodes[(NUM_CHILDREN + 1)];
71 unsigned int hindex = 0;
72 unsigned int hindexN = 0;
73 unsigned int index = 0;
75 hindex = (rotations[2 * NUM_CHILDREN * rot_id] -
'0');
76 hindexN = (rotations[2 * NUM_CHILDREN * rot_id +1] -
'0');
78 SFC::seqSort::SFC_bucketing(pKeys,lev,pMaxDepth,rot_id,nKeyBegin,nKeyEnd,splitterKeys);
79 SFC::seqSort::SFC_bucketing(pNodes,lev,pMaxDepth,rot_id,nNodeBegin,nNodeEnd,splitterNodes);
82 if((pMaxDepthBit) && (((nNodeEnd-nNodeBegin)>=1) && (pNodes[splitterNodes[hindex]].getLevel()>lev)) ) {
94 for (
int i = 0; i < NUM_CHILDREN; i++) {
95 hindex = (rotations[2 * NUM_CHILDREN * rot_id + i] -
'0');
96 if (i == (NUM_CHILDREN - 1))
99 hindexN = (rotations[2 * NUM_CHILDREN * rot_id + i + 1] -
'0');
101 assert(splitterKeys[hindex] <= splitterKeys[hindexN]);
102 assert(splitterNodes[hindex] <= splitterNodes[hindexN]);
104 index = HILBERT_TABLE[NUM_CHILDREN * rot_id + hindex];
105 SFC_treeSearch(pKeys,pNodes,pSearchIndex,splitterKeys[hindex],splitterKeys[hindexN],splitterNodes[hindex],splitterNodes[hindexN],(pMaxDepthBit-1),pMaxDepth,index);
111 if(((nNodeEnd-nNodeBegin)==1) )
113 assert(pNodes[nNodeBegin].getLevel()==lev);
114 for(
unsigned int k=nKeyBegin;k<nKeyEnd;k++)
116 assert(((pNodes[nNodeBegin].isAncestor(pKeys[k]))||(pNodes[nNodeBegin]==pKeys[k])));
117 pKeys[k].setFlag((pKeys[k].getFlag() | OCT_FOUND));
118 assert(pKeys[k].getFlag() & OCT_FOUND);
119 pSearchIndex.push_back(nNodeBegin);
129 template <
typename TKey,
typename TOctant>
130 void SFC_treeSearch(TKey* pKeys , TOctant* pNodes,DendroIntL nKeyBegin,DendroIntL nKeyEnd,DendroIntL nNodeBegin,DendroIntL nNodeEnd,
unsigned int pMaxDepthBit,
unsigned int pMaxDepth,
unsigned int rot_id)
133 unsigned int lev=pMaxDepth-pMaxDepthBit;
134 if(nKeyEnd==nKeyBegin)
return;
138 if( pMaxDepthBit && ((nNodeEnd-nNodeBegin)>1) && (pNodes[nNodeBegin].getLevel()>lev))
141 unsigned int hindex = 0;
142 unsigned int hindexN = 0;
143 unsigned int index = 0;
144 DendroIntL splitterKeys[(NUM_CHILDREN + 1)];
145 DendroIntL splitterNodes[(NUM_CHILDREN + 1)];
147 SFC::seqSort::SFC_bucketing(pKeys, lev, pMaxDepth, rot_id, nKeyBegin, nKeyEnd, splitterKeys);
148 SFC::seqSort::SFC_bucketing(pNodes, lev, pMaxDepth, rot_id, nNodeBegin, nNodeEnd, splitterNodes);
151 for (
int i = 0; i < NUM_CHILDREN; i++) {
152 hindex = (rotations[2 * NUM_CHILDREN * rot_id + i] -
'0');
153 if (i == (NUM_CHILDREN - 1))
156 hindexN = (rotations[2 * NUM_CHILDREN * rot_id + i + 1] -
'0');
158 assert(splitterKeys[hindex] <= splitterKeys[hindexN]);
159 assert(splitterNodes[hindex] <= splitterNodes[hindexN]);
161 index = HILBERT_TABLE[NUM_CHILDREN * rot_id + hindex];
162 if(splitterNodes[hindex]!=splitterNodes[hindexN]) SFC_treeSearch(pKeys,pNodes,splitterKeys[hindex],splitterKeys[hindexN],splitterNodes[hindex],splitterNodes[hindexN],(pMaxDepthBit-1),pMaxDepth,index);
168 if(((nNodeEnd-nNodeBegin)==1) )
171 for(
unsigned int k=nKeyBegin;k<nKeyEnd;k++)
174 if((pNodes[nNodeBegin].isAncestor(pKeys[k])) || (pNodes[nNodeBegin]==pKeys[k])){
175 pKeys[k].setFlag((pKeys[k].getFlag() | OCT_FOUND));
176 assert(pKeys[k].getFlag() & OCT_FOUND);
177 pKeys[k].setSearchResult(nNodeBegin);
184 }
else if(((nNodeEnd-nNodeBegin)>1))
188 unsigned int nCnt=nNodeBegin;
189 for(
unsigned int k=nKeyBegin;k<nKeyEnd;k++)
191 while( (nCnt<nNodeEnd) && (!(pNodes[nCnt].isAncestor(pKeys[k]))&& !(pNodes[nCnt]==pKeys[k])))
196 pKeys[k].setFlag((pKeys[k].getFlag() | OCT_FOUND));
198 assert(((pNodes[nCnt].isAncestor(pKeys[k]))||(pNodes[nCnt]==pKeys[k])));
199 pKeys[k].setSearchResult(nCnt);
226 #endif //SFCSORTBENCH_SFCSEARCH_H Definition: sfcSearch.h:22