42 register struct Node *
n =
N;
43 register struct Rect *
r = R;
46 register int hitCount = 0;
50 assert(n->
level >= 0);
81 static int RTreeInsertRect2(
struct Rect *
r,
96 assert(r && n && new_node);
97 assert(level >= 0 && level <= n->level);
100 if (n->
level > level) {
102 if (!RTreeInsertRect2(r, child, n->
branch[i].
child, &n2, level)) {
117 else if (n->
level == level) {
146 register struct Rect *r = R;
147 register struct Node *child = Child;
148 register struct Node **root = Root;
149 register int level = Level;
151 register struct Node *newroot;
152 struct Node *newnode;
157 assert(level >= 0 && level <= (*root)->level);
158 for (i = 0; i <
NUMDIMS; i++) {
162 if (RTreeInsertRect2(r, child, *root, &newnode, level)) {
164 newroot->
level = (*root)->level + 1;
184 static struct ListNode *RTreeNewListNode(
void)
190 static void RTreeFreeListNode(
struct ListNode *p)
200 static void RTreeReInsert(
struct Node *n,
struct ListNode **ee)
204 l = RTreeNewListNode();
217 RTreeDeleteRect2(
struct Rect *R,
struct Node *Child,
struct Node *
N,
220 register struct Rect *r = R;
221 register struct Node *child = Child;
222 register struct Node *n =
N;
226 assert(r && n && ee);
228 assert(n->
level >= 0);
233 if (!RTreeDeleteRect2(r, child, n->
branch[i].
child, ee)) {
277 register struct Rect *r = R;
278 register struct Node *child = Child;
279 register struct Node **nn = Nn;
289 if (!RTreeDeleteRect2(r, child, *nn, &reInsertList)) {
293 while (reInsertList) {
294 tmp_nptr = reInsertList->
node;
295 for (i = 0; i <
MAXKIDS(tmp_nptr); i++) {
299 nn, tmp_nptr->
level);
303 reInsertList = reInsertList->
next;
305 RTreeFreeListNode(e);
309 if ((*nn)->count == 1 && (*nn)->level > 0) {
RectReal boundary[NUMSIDES]
int RTreePickBranch(struct Rect *, struct Node *)
int RTreeSearch(struct Node *N, struct Rect *R, SearchHitCallback shcb, void *cbarg)
int RTreeAddBranch(struct Branch *, struct Node *, struct Node **)
int RTreeInsertRect(struct Rect *R, int Tid, struct Node **Root, int Level)
struct Node * RTreeNewNode(void)
int RTreeOverlap(struct Rect *, struct Rect *)
struct Rect RTreeNodeCover(struct Node *)
int(* SearchHitCallback)(int id, void *arg)
struct Rect RTreeCombineRect(struct Rect *, struct Rect *)
struct Node * RTreeNewIndex(void)
int RTreeDeleteRect(struct Rect *R, int Tid, struct Node **Nn)
void RTreeFreeNode(struct Node *)
struct Branch branch[MAXCARD]
int RTreeDeleteRect1(struct Rect *R, struct Node *Child, struct Node **Nn)
int RTreeInsertRect1(struct Rect *R, struct Node *Child, struct Node **Root, int Level)
void RTreeDisconnectBranch(struct Node *, int)