28 #define TIME_START() timeval TIME_DEBUG_t; gettimeofday(&TIME_DEBUG_t,NULL);    29 #define TIME_END() float TIME_DELTA; {timeval TIME_DEBUG_tend; gettimeofday(&TIME_DEBUG_tend,NULL); \    30 TIME_DELTA=(TIME_DEBUG_tend.tv_sec - TIME_DEBUG_t.tv_sec) + ((float)TIME_DEBUG_tend.tv_usec-(float)TIME_DEBUG_t.tv_usec)/1.0e6;}    34 #define M_PI 3.141596254    39     static unsigned int lastProgress=0;
    55     const float SCALE=100;
    61     ions.resize(NUM_IONS);
    62     for(
unsigned int ui=0;ui<
NUM_IONS;ui++)
    66         xyzm[0] = SCALE*((float)rand()/RAND_MAX-0.5);
    67         xyzm[1] = SCALE*((float)rand()/RAND_MAX-0.5);
    68         xyzm[2] = SCALE*((float)rand()/RAND_MAX-0.5);
    69         xyzm[3] = SCALE*((float)rand()/RAND_MAX-0.5);
    70         ions[ui].setHit(xyzm);
    83     cerr << 
"Building tree with " << NUM_IONS/(float)1000000 << 
" M ions..."  << endl << 
" |";
    91     cerr << 
"| done, in " << TIME_DELTA << 
" seconds" << endl;
   101     cerr << 
"Finding all 1NNs...";
   105     #pragma omp parallel for   106     for(
size_t ui=0;ui<kdExact.
size();ui++)
   112     cerr << 
"done, in " << TIME_DELTA << 
" seconds" << endl;
   119     const float SIDE_RATIO= SEARCH_RAD/
SCALE;
   120     const float REL_VOLUME =4.0/3.0*
M_PI*SIDE_RATIO*SIDE_RATIO*SIDE_RATIO*100.0;
   121     cerr << 
"In a cube containing " << kdExact.
size() << 
"points, of side length " << SCALE <<  endl;
   122     cerr << 
" finding pts within " << SEARCH_RAD << 
"distance. (" << REL_VOLUME << 
"\% of points)" <<endl;
   126     cerr << 
"Slow query" << endl;
   129     for(
size_t ui=0;ui<kdExact.
size();ui++)
   131         vector<size_t> result;  
   140     cerr << 
" Average :" << nPts/(double)kdExact.
size() << 
" pts around each other pt. Took "; 
   141     cerr << TIME_DELTA << 
" seconds" << endl;
   146     cerr << 
"Faster (bulk) query" << endl;
   149     for(
size_t ui=0;ui<kdExact.
size();ui++)
   151         vector<size_t> result;  
   160     cerr << 
" Average :" << nPts/(double)kdExact.
size() << 
" pts around each other pt. Took "; 
   161     cerr << TIME_DELTA << 
" seconds" << endl;
 
void getBoundCube(BoundCube &b)
obtain the bounding rectangular prism volume for all elements in the KD tree 
 
const unsigned int NUM_IONS
 
void setProgressPointer(unsigned int *p)
 
void findUntaggedInRadius(const Point3D &queryPt, const BoundCube &b, float radius, std::vector< size_t > &result)
Find untagged points within a given radius. 
 
void setCallback(bool(*cb)(void))
 
Helper class to define a bounding cube. 
 
void resetPts(std::vector< Point3D > &pts, bool clear=true)
Supply points to KD tree. Ouput vector will be erased if clear=true. 
 
bool build()
Build the KD tree using the previously supplied points. 
 
size_t findNearestUntagged(const Point3D &queryPt, const BoundCube &b, bool tag=true)
Find the nearest "untagged" point's internal index. 
 
const Point3D & getPtRef(size_t index) const
 
void ptsInSphere(const Point3D &origin, float radius, std::vector< size_t > &pts) const