37 int portionSize = high - low;
40 assert(portionSize > 0);
42 if (portionSize == 1) {
64 double medianVal = eltList[medianId].dim2;
66 rightRegion.
dim2min = medianVal;
70 double medianVal = eltList[medianId].dim1;
72 rightRegion.
dim1min = medianVal;
80 node->
left =
recBuild(eltList, low, medianId, depth, leftRegion);
81 node->
right =
recBuild(eltList, medianId, high, depth, rightRegion);
98 int nbrElts = high - low;
99 int median = (nbrElts & 1) ? nbrElts / 2
116 while (eltList[i].dim2 < elt.
dim2) i++;
117 while (eltList[j].dim2 > elt.
dim2) j--;
119 while (eltList[i].dim1 < elt.
dim1) i++;
120 while (eltList[j].dim1 > elt.
dim1) j--;
124 swap(eltList[i], eltList[j]);
129 if (j < median) l =
i;
130 if (i > median) m =
j;
147 std::vector<KDTreeNodeInfo> &recHits)
156 std::vector<KDTreeNodeInfo> &recHits)
159 assert(current != 0);
162 assert (!(((current->
left == 0) && (current->
right != 0)) ||
163 ((current->
left != 0) && (current->
right == 0))));
165 if ((current->
left == 0) && (current->
right == 0)) {
170 recHits.push_back(current->
rh);
210 std::vector<KDTreeNodeInfo> &recHits)
213 assert(current != 0);
215 if ((current->
left == 0) && (current->
right == 0))
216 recHits.push_back(current->
rh);
void setAttributs(const KDTreeBox ®ionBox, const KDTreeNodeInfo &rhinfo)
void addSubtree(const KDTreeNode *current, std::vector< KDTreeNodeInfo > &recHits)
KDTreeNode * getNextNode()
KDTreeNode * recBuild(std::vector< KDTreeNodeInfo > &eltList, int low, int hight, int depth, const KDTreeBox ®ion)
void build(std::vector< KDTreeNodeInfo > &eltList, const KDTreeBox ®ion)
void search(const KDTreeBox &searchBox, std::vector< KDTreeNodeInfo > &resRecHitList)
void swap(KDTreeNodeInfo &e1, KDTreeNodeInfo &e2)
std::vector< std::vector< double > > tmp
void recSearch(const KDTreeNode *current, const KDTreeBox &trackBox, std::vector< KDTreeNodeInfo > &recHits)
static const char root_[]
int medianSearch(std::vector< KDTreeNodeInfo > &eltList, int low, int high, int treeDepth)