30#define DBL_MAX 1.797693E308
65 for (i = 1; i <
maxkids + 1; i++) {
86 if (p->
count[group] == 0)
112 for (i = 0; i < p->
total; i++)
116 for (i = 0; i < p->
total - 1; i++) {
117 for (
j = i + 1;
j < p->
total;
j++) {
130 RTreeClassify(
seed0, 0, p,
t);
131 RTreeClassify(
seed1, 1, p,
t);
143 for (i = 0; i < p->
total; i++) {
186 for (i = 0; i < p->
total; i++) {
190 for (i = 0; i < p->
total; i++) {
197 for (i = 0; i < p->
total; i++) {
249 for (i = 0; i < p->
total; i++) {
253 r = &(
t->BranchBuf[i].rect);
287 for (i = 0; i < p->
total; i++) {
289 RTreeClassify(i, group, p,
t);
332static int RTreeBranchBufIsSorted(
int first,
int last,
int side,
337 for (i = first; i < last; i++) {
338 if (RTreeCompareBranches(&(
t->BranchBuf[i]), &(
t->BranchBuf[i + 1]),
349static int RTreePartitionBranchBuf(
int first,
int last,
int side,
352 int pivot,
mid = ((first + last) >> 1);
355 if (last - first == 1) {
356 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
358 RTreeSwapBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
t);
366 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[
mid]),
372 if (RTreeCompareBranches(&(
t->BranchBuf[
larger]), &(
t->BranchBuf[last]),
376 if (RTreeCompareBranches(&(
t->BranchBuf[
smaller]),
377 &(
t->BranchBuf[last]),
side) == 1) {
383 RTreeSwapBranches(&(
t->BranchBuf[
pivot]), &(
t->BranchBuf[last]),
t);
388 while (first < last) {
389 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
391 if (
pivot != first) {
392 RTreeSwapBranches(&(
t->BranchBuf[
pivot]),
393 &(
t->BranchBuf[first]),
t);
401 RTreeSwapBranches(&(
t->BranchBuf[
pivot]), &(
t->BranchBuf[last]),
t);
410static void RTreeQuicksortBranchBuf(
int side,
struct RTree *
t)
412 int pivot, first, last;
416 s_last[0] =
t->BranchCount - 1;
426 if (!RTreeBranchBufIsSorted(first, last,
side,
t)) {
428 pivot = RTreePartitionBranchBuf(first, last,
side,
t);
487 for (i = 0; i <
t->ndims; i++) {
498 RTreeQuicksortBranchBuf(i + s *
t->ndims_alloc,
t);
506 r1 = &(
t->BranchBuf[
j].rect);
518 r1 = &(
t->BranchBuf[
j].rect);
522 for (k =
j + 1; k <
t->BranchCount - minfill; k++) {
523 r2 = &(
t->BranchBuf[k].rect);
543 for (k = 0; k <
t->ndims; k++) {
546 rect_1->boundary[k +
t->ndims_alloc] ||
547 rect_0->boundary[k +
t->ndims_alloc] <
559 l = k +
t->ndims_alloc;
592 RTreeQuicksortBranchBuf(
598 RTreeClassify(i, 0, p,
t);
601 RTreeClassify(i, 1, p,
t);
636 (
nn)->level = n->
level = level;
637 RTreeLoadNodes(n,
nn, p,
t);
#define MAXKIDS(level, t)
#define MINFILL(level, t)
int RTreeAddBranch(struct RTree_Branch *, struct RTree_Node *, struct RTree_Node **, struct RTree_ListBranch **, struct RTree_Rect *, char *, struct RTree *)
RectReal RTreeRectSphericalVolume(struct RTree_Rect *, struct RTree *)
void RTreeNullRect(struct RTree_Rect *, struct RTree *)
void RTreeCopyBranch(struct RTree_Branch *, struct RTree_Branch *, struct RTree *)
RectReal RTreeRectVolume(struct RTree_Rect *, struct RTree *)
RectReal RTreeRectMargin(struct RTree_Rect *, struct RTree *)
void RTreeCombineRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
int RTreeExpandRect(struct RTree_Rect *, struct RTree_Rect *, struct RTree *)
void RTreeInitRect(struct RTree_Rect *, struct RTree *)
Initialize a rectangle to have all 0 coordinates.
#define RTreeCopyRect(r1, r2, t)
#define assert(condition)
void RTreeInitNode(struct RTree *t, struct RTree_Node *n, int type)
void RTreePrintRect(struct RTree_Rect *R, int depth, struct RTree *t)
void RTreeInitPVars(struct RTree_PartitionVars *p, int maxrects, int minfill, struct RTree *t)
void RTreeSplitNode(struct RTree_Node *n, struct RTree_Branch *b, struct RTree_Node *nn, struct RTree *t)
struct RTree_Branch * branch
struct RTree_Rect cover[2]
#define MAXLEVEL
Maximum verbosity level.