27#define DBL_MAX 1.797693E308
62 for (i = 1; i <
maxkids + 1; i++) {
83 if (p->
count[group] == 0)
109 for (i = 0; i < p->
total; i++)
113 for (i = 0; i < p->
total - 1; i++) {
114 for (
j = i + 1;
j < p->
total;
j++) {
127 RTreeClassify(
seed0, 0, p,
t);
128 RTreeClassify(
seed1, 1, p,
t);
140 for (i = 0; i < p->
total; i++) {
183 for (i = 0; i < p->
total; i++) {
187 for (i = 0; i < p->
total; i++) {
194 for (i = 0; i < p->
total; i++) {
246 for (i = 0; i < p->
total; i++) {
250 r = &(
t->BranchBuf[i].rect);
284 for (i = 0; i < p->
total; i++) {
286 RTreeClassify(i, group, p,
t);
329static int RTreeBranchBufIsSorted(
int first,
int last,
int side,
334 for (i = first; i < last; i++) {
335 if (RTreeCompareBranches(&(
t->BranchBuf[i]), &(
t->BranchBuf[i + 1]),
346static int RTreePartitionBranchBuf(
int first,
int last,
int side,
349 int pivot,
mid = ((first + last) >> 1);
352 if (last - first == 1) {
353 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
355 RTreeSwapBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
t);
363 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[
mid]),
369 if (RTreeCompareBranches(&(
t->BranchBuf[
larger]), &(
t->BranchBuf[last]),
373 if (RTreeCompareBranches(&(
t->BranchBuf[
smaller]),
374 &(
t->BranchBuf[last]),
side) == 1) {
380 RTreeSwapBranches(&(
t->BranchBuf[
pivot]), &(
t->BranchBuf[last]),
t);
385 while (first < last) {
386 if (RTreeCompareBranches(&(
t->BranchBuf[first]), &(
t->BranchBuf[last]),
388 if (
pivot != first) {
389 RTreeSwapBranches(&(
t->BranchBuf[
pivot]),
390 &(
t->BranchBuf[first]),
t);
398 RTreeSwapBranches(&(
t->BranchBuf[
pivot]), &(
t->BranchBuf[last]),
t);
407static void RTreeQuicksortBranchBuf(
int side,
struct RTree *
t)
409 int pivot, first, last;
413 s_last[0] =
t->BranchCount - 1;
423 if (!RTreeBranchBufIsSorted(first, last,
side,
t)) {
425 pivot = RTreePartitionBranchBuf(first, last,
side,
t);
484 for (i = 0; i <
t->ndims; i++) {
495 RTreeQuicksortBranchBuf(i + s *
t->ndims_alloc,
t);
503 r1 = &(
t->BranchBuf[
j].rect);
515 r1 = &(
t->BranchBuf[
j].rect);
519 for (k =
j + 1; k <
t->BranchCount - minfill; k++) {
520 r2 = &(
t->BranchBuf[k].rect);
540 for (k = 0; k <
t->ndims; k++) {
543 rect_1->boundary[k +
t->ndims_alloc] ||
544 rect_0->boundary[k +
t->ndims_alloc] <
556 l = k +
t->ndims_alloc;
589 RTreeQuicksortBranchBuf(
595 RTreeClassify(i, 0, p,
t);
598 RTreeClassify(i, 1, p,
t);
633 (
nn)->level = n->
level = level;
634 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.