35 static void RTreeGetBranches(
struct Node *
n,
struct Branch *
b)
43 for (i = 0; i <
MAXKIDS(n); i++) {
52 for (i = 1; i <
MAXKIDS(n) + 1; i++) {
66 static void RTreeClassify(
int i,
int group,
struct PartitionVars *p)
74 if (p->
count[group] == 0)
92 int i, j, seed0 = 0, seed1 = 0;
95 for (i = 0; i < p->
total; i++)
99 for (i = 0; i < p->
total - 1; i++) {
100 for (j = i + 1; j < p->
total; j++) {
101 struct Rect one_rect;
113 RTreeClassify(seed0, 0, p);
114 RTreeClassify(seed1, 1, p);
123 static void RTreeLoadNodes(
struct Node *n,
struct Node *
q,
132 for (i = 0; i < p->
total; i++) {
147 static void RTreeInitPVars(
struct PartitionVars *p,
int maxrects,
int minfill)
158 for (i = 0; i < maxrects; i++) {
176 fprintf(stdout,
"\npartition:\n");
177 for (i = 0; i < p->
total; i++) {
178 fprintf(stdout,
"%3d\t", i);
180 fprintf(stdout,
"\n");
181 for (i = 0; i < p->
total; i++) {
183 fprintf(stdout,
" t\t");
185 fprintf(stdout,
"\t");
187 fprintf(stdout,
"\n");
188 for (i = 0; i < p->
total; i++) {
189 fprintf(stdout,
"%3d\t", p->
partition[i]);
191 fprintf(stdout,
"\n");
193 fprintf(stdout,
"count[0] = %d area = %f\n", p->
count[0], p->
area[0]);
194 fprintf(stdout,
"count[1] = %d area = %f\n", p->
count[1], p->
area[1]);
196 fprintf(stdout,
"total area = %f effectiveness = %3.2f\n",
200 fprintf(stdout,
"cover[0]:\n");
203 fprintf(stdout,
"cover[1]:\n");
221 static void RTreeMethodZero(
struct PartitionVars *p,
int minfill)
225 int group, chosen = 0, betterGroup = 0;
236 for (i = 0; i < p->
total; i++) {
238 struct Rect *
r, rect_0, rect_1;
246 diff = growth1 - growth0;
254 if (diff > biggestDiff) {
259 else if (diff == biggestDiff &&
266 RTreeClassify(chosen, betterGroup, p);
275 for (i = 0; i < p->
total; i++) {
277 RTreeClassify(i, group, p);
302 RTreeGetBranches(n, b);
314 (*nn)->level = n->
level = level;
315 RTreeLoadNodes(n, *nn, p);
struct PartitionVars Partitions[METHODS]
struct Branch BranchBuf[MAXCARD+1]
int RTreeAddBranch(struct Branch *, struct Node *, struct Node **)
RectReal RTreeRectSphericalVolume(struct Rect *R)
void RTreeSplitNode(struct Node *, struct Branch *, struct Node **)
struct Node * RTreeNewNode(void)
void RTreePrintRect(struct Rect *, int)
struct Rect RTreeNullRect(void)
struct Rect RTreeCombineRect(struct Rect *, struct Rect *)
void RTreeInitNode(struct Node *)
struct Branch branch[MAXCARD]