-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrTree.h
49 lines (46 loc) · 1.22 KB
/
rTree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef RTREE_H_INCLUDED
#define RTREE_H_INCLUDED
#include "rNodo.h"
template<int N>
struct rTree{
rNodo<N>*raiz;
rTree(){
raiz=new rNodo<N>(1);
}
void insertion(objeto&E){
rNodo<N>*aux=chooseLeaf(E);
aux->insertar(&E);
while(raiz->padre){
raiz=raiz->padre;
}
cout<<"insertion exitosa";
}
rNodo<N>*chooseLeaf(objeto E){
rNodo<N>*aux=raiz;
while(!aux->hojaFlag){
int menor=0;
float areaMenor;
if(aux->ocupados){
areaMenor=aux->rHijos[0]->caja.diferenciaArea(E.caja);
}
for(int i=1;i<aux->ocupados;++i){
double areaAux=aux->rHijos[i]->caja.diferenciaArea(E.caja);
if(areaAux<areaMenor){
menor=i;
areaMenor=areaAux;
}
}
aux=aux->rHijos[menor];
}
return aux;
}
void draw(){
//cout<<"\nraiz: "<< raiz;
raiz->draw(0);
}
void buscar(double xi, double yi,double xf,double yf){
if(raiz)
raiz->buscar(xi,yi,xf,yf);
}
};
#endif // RTREE_H_INCLUDED