亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? split_l.c

?? Rtree R樹的C語言實現 ,學習R樹的朋友們共同學習,向你們學習
?? C
字號:

#include <stdio.h>
#include "assert.h"
#include "index.h"
#include "card.h"
#include "split_l.h"


/*-----------------------------------------------------------------------------
| Load branch buffer with branches from full node plus the extra branch.
-----------------------------------------------------------------------------*/
static void RTreeGetBranches(struct Node *N, struct Branch *B)
{
	register struct Node *n = N;
	register struct Branch *b = B;
	register int i;

	assert(n);
	assert(b);

	/* load the branch buffer */
	for (i=0; i<MAXKIDS(n); i++)
	{
		assert(n->branch[i].child);  /* every entry should be full */
		BranchBuf[i] = n->branch[i];
	}
	BranchBuf[MAXKIDS(n)] = *b;
	BranchCount = MAXKIDS(n) + 1;

	/* calculate rect containing all in the set */
	CoverSplit = BranchBuf[0].rect;
	for (i=1; i<MAXKIDS(n)+1; i++)
	{
		CoverSplit = RTreeCombineRect(&CoverSplit, &BranchBuf[i].rect);
	}

	RTreeInitNode(n);
}



/*-----------------------------------------------------------------------------
| Initialize a PartitionVars structure.
-----------------------------------------------------------------------------*/
static void RTreeInitPVars(struct PartitionVars *P, int maxrects, int minfill)
{
	register struct PartitionVars *p = P;
	register int i;
	assert(p);

	p->count[0] = p->count[1] = 0;
	p->total = maxrects;
	p->minfill = minfill;
	for (i=0; i<maxrects; i++)
	{
		p->taken[i] = FALSE;
		p->partition[i] = -1;
	}
}



/*-----------------------------------------------------------------------------
| Put a branch in one of the groups.
-----------------------------------------------------------------------------*/
static void RTreeClassify(int i, int group, struct PartitionVars *p)
{
	assert(p);
	assert(!p->taken[i]);

	p->partition[i] = group;
	p->taken[i] = TRUE;

	if (p->count[group] == 0)
		p->cover[group] = BranchBuf[i].rect;
	else
		p->cover[group] = RTreeCombineRect(&BranchBuf[i].rect,
					&p->cover[group]);
	p->area[group] = RTreeRectSphericalVolume(&p->cover[group]);
	p->count[group]++;
}



/*-----------------------------------------------------------------------------
| Pick two rects from set to be the first elements of the two groups.
| Pick the two that are separated most along any dimension, or overlap least.
| Distance for separation or overlap is measured modulo the width of the
| space covered by the entire set along that dimension.
-----------------------------------------------------------------------------*/
static void RTreePickSeeds(struct PartitionVars *P)
{
	register struct PartitionVars *p = P;
	register int i, dim, high;
	register struct Rect *r, *rlow, *rhigh;
	register float w, separation, bestSep;
	RectReal width[NUMDIMS];
	int leastUpper[NUMDIMS], greatestLower[NUMDIMS];
	int seed0, seed1;
	assert(p);
	
	for (dim=0; dim<NUMDIMS; dim++)
	{
		high = dim + NUMDIMS;

		/* find the rectangles farthest out in each direction
		 * along this dimens */
		greatestLower[dim] = leastUpper[dim] = 0;
		for (i=1; i<NODECARD+1; i++)
		{
			r = &BranchBuf[i].rect;
			if (r->boundary[dim] >
			    BranchBuf[greatestLower[dim]].rect.boundary[dim])
			{
				greatestLower[dim] = i;
			}
			if (r->boundary[high] <
			    BranchBuf[leastUpper[dim]].rect.boundary[high])
			{
				leastUpper[dim] = i;
			}
		}

		/* find width of the whole collection along this dimension */
		width[dim] = CoverSplit.boundary[high] -
			     CoverSplit.boundary[dim];
	}

	/* pick the best separation dimension and the two seed rects */
	for (dim=0; dim<NUMDIMS; dim++)
	{
		high = dim + NUMDIMS;

		/* divisor for normalizing by width */
		assert(width[dim] >= 0);
		if (width[dim] == 0)
			w = (RectReal)1;
		else
			w = width[dim];

		rlow = &BranchBuf[leastUpper[dim]].rect;
		rhigh = &BranchBuf[greatestLower[dim]].rect;
		if (dim == 0)
		{
			seed0 = leastUpper[0];
			seed1 = greatestLower[0];
			separation = bestSep =
				(rhigh->boundary[0] -
				 rlow->boundary[NUMDIMS]) / w;
		}
		else
		{
			separation =
				(rhigh->boundary[dim] -
				rlow->boundary[dim+NUMDIMS]) / w;
			if (separation > bestSep)
			{
				seed0 = leastUpper[dim];
				seed1 = greatestLower[dim];
				bestSep = separation;
			}
		}
	}

	if (seed0 != seed1)
	{
		RTreeClassify(seed0, 0, p);
		RTreeClassify(seed1, 1, p);
	}
}



/*-----------------------------------------------------------------------------
| Put each rect that is not already in a group into a group.
| Process one rect at a time, using the following hierarchy of criteria.
| In case of a tie, go to the next test.
| 1) If one group already has the max number of elements that will allow
| the minimum fill for the other group, put r in the other.
| 2) Put r in the group whose cover will expand less.  This automatically
| takes care of the case where one group cover contains r.
| 3) Put r in the group whose cover will be smaller.  This takes care of the
| case where r is contained in both covers.
| 4) Put r in the group with fewer elements.
| 5) Put in group 1 (arbitrary).
|
| Also update the covers for both groups.
-----------------------------------------------------------------------------*/
static void RTreePigeonhole(struct PartitionVars *P)
{
	register struct PartitionVars *p = P;
	struct Rect newCover[2];
	register int i, group;
	RectReal newArea[2], increase[2];

	for (i=0; i<NODECARD+1; i++)
	{
		if (!p->taken[i])
		{
			/* if one group too full, put rect in the other */
			if (p->count[0] >= p->total - p->minfill)
			{
				RTreeClassify(i, 1, p);
				continue;
			}
			else if (p->count[1] >= p->total - p->minfill)
			{
				RTreeClassify(i, 0, p);
				continue;
			}

			/* find areas of the two groups' old and new covers */
			for (group=0; group<2; group++)
			{
				if (p->count[group]>0)
					newCover[group] = RTreeCombineRect(
						&BranchBuf[i].rect,
						&p->cover[group]);
				else
					newCover[group] = BranchBuf[i].rect;
				newArea[group] = RTreeRectSphericalVolume(
							&newCover[group]);
				increase[group] = newArea[group]-p->area[group];
			}

			/* put rect in group whose cover will expand less */
			if (increase[0] < increase[1])
				RTreeClassify(i, 0, p);
			else if (increase[1] < increase[0])
				RTreeClassify(i, 1, p);

			/* put rect in group that will have a smaller cover */
			else if (p->area[0] < p->area[1])
				RTreeClassify(i, 0, p);
			else if (p->area[1] < p->area[0])
				RTreeClassify(i, 1, p);

			/* put rect in group with fewer elements */
			else if (p->count[0] < p->count[1])
				RTreeClassify(i, 0, p);
			else
				RTreeClassify(i, 1, p);
		}
	}
	assert(p->count[0] + p->count[1] == NODECARD + 1);
}



/*-----------------------------------------------------------------------------
| Method 0 for finding a partition:
| First find two seeds, one for each group, well separated.
| Then put other rects in whichever group will be smallest after addition.
-----------------------------------------------------------------------------*/
static void RTreeMethodZero(struct PartitionVars *p, int minfill)
{
	RTreeInitPVars(p, BranchCount, minfill);
	RTreePickSeeds(p);
	RTreePigeonhole(p);
}




/*-----------------------------------------------------------------------------
| Copy branches from the buffer into two nodes according to the partition.
-----------------------------------------------------------------------------*/
static void RTreeLoadNodes(struct Node *N, struct Node *Q,
			struct PartitionVars *P)
{
	register struct Node *n = N, *q = Q;
	register struct PartitionVars *p = P;
	register int i;
	assert(n);
	assert(q);
	assert(p);

	for (i=0; i<NODECARD+1; i++)
	{
		if (p->partition[i] == 0)
			RTreeAddBranch(&BranchBuf[i], n, NULL);
		else if (p->partition[i] == 1)
			RTreeAddBranch(&BranchBuf[i], q, NULL);
		else
			assert(FALSE);
	}
}



/*-----------------------------------------------------------------------------
| Split a node.
| Divides the nodes branches and the extra one between two nodes.
| Old node is one of the new ones, and one really new one is created.
-----------------------------------------------------------------------------*/
void RTreeSplitNode(struct Node *n, struct Branch *b, struct Node **nn)
{
	register struct PartitionVars *p;
	register int level;
	RectReal area;

	assert(n);
	assert(b);

	/* load all the branches into a buffer, initialize old node */
	level = n->level;
	RTreeGetBranches(n, b);

	/* find partition */
	p = &Partitions[0];

	/* Note: can't use MINFILL(n) below since n was cleared by GetBranches() */
	RTreeMethodZero(p, level>0 ? MinNodeFill : MinLeafFill);

	/* record how good the split was for statistics */
	area = p->area[0] + p->area[1];

	/* put branches from buffer in 2 nodes according to chosen partition */
	*nn = RTreeNewNode();
	(*nn)->level = n->level = level;
	RTreeLoadNodes(n, *nn, p);
	assert(n->count + (*nn)->count == NODECARD+1);
}



/*-----------------------------------------------------------------------------
| Print out data for a partition from PartitionVars struct.
-----------------------------------------------------------------------------*/
static void RTreePrintPVars(struct PartitionVars *p)
{
	int i;
	assert(p);

	printf("\npartition:\n");
	for (i=0; i<NODECARD+1; i++)
	{
		printf("%3d\t", i);
	}
	printf("\n");
	for (i=0; i<NODECARD+1; i++)
	{
		if (p->taken[i])
			printf("  t\t");
		else
			printf("\t");
	}
	printf("\n");
	for (i=0; i<NODECARD+1; i++)
	{
		printf("%3d\t", p->partition[i]);
	}
	printf("\n");

	printf("count[0] = %d  area = %f\n", p->count[0], p->area[0]);
	printf("count[1] = %d  area = %f\n", p->count[1], p->area[1]);
	printf("total area = %f  effectiveness = %3.2f\n",
		p->area[0] + p->area[1],
		RTreeRectSphericalVolume(&CoverSplit)/(p->area[0]+p->area[1]));

	printf("cover[0]:\n");
	RTreePrintRect(&p->cover[0], 0);

	printf("cover[1]:\n");
	RTreePrintRect(&p->cover[1], 0);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区二区精品久久av| fc2成人免费人成在线观看播放| 色婷婷综合久色| 中文字幕亚洲电影| 色偷偷成人一区二区三区91| 亚洲一区二区欧美日韩| 欧美高清性hdvideosex| 亚洲精品久久7777| 粉嫩av亚洲一区二区图片| 99久久久无码国产精品| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 亚洲欧洲av在线| 色综合天天综合在线视频| 亚洲观看高清完整版在线观看 | 欧洲一区二区三区在线| 一区二区三区蜜桃| 91精品国产色综合久久ai换脸| 捆绑变态av一区二区三区| www成人在线观看| 色诱视频网站一区| 欧美aaa在线| 国产精品剧情在线亚洲| 91福利在线看| 国内精品嫩模私拍在线| 最好看的中文字幕久久| 在线播放91灌醉迷j高跟美女| 日韩女优av电影| 日韩欧美久久一区| 亚洲成av人片在线观看无码| 日韩小视频在线观看专区| 成人免费视频视频在线观看免费 | 日韩精彩视频在线观看| 久久嫩草精品久久久精品| 色欧美片视频在线观看在线视频| 日韩和的一区二区| 国产精品麻豆欧美日韩ww| 久久精品综合网| 欧美在线|欧美| 大美女一区二区三区| 日韩vs国产vs欧美| 亚洲少妇30p| 久久久久国产精品人| 精品视频在线看| av网站免费线看精品| 免费成人在线播放| 一区二区三区高清不卡| 国产69精品久久久久毛片| 成人免费毛片a| 日本vs亚洲vs韩国一区三区二区 | 国产福利一区二区| 婷婷激情综合网| 一区二区三区欧美日| 欧美国产成人在线| xvideos.蜜桃一区二区| 欧美福利视频一区| 在线精品视频一区二区三四| 国产高清精品久久久久| 麻豆成人久久精品二区三区小说| 亚洲午夜激情网站| 亚洲免费在线观看视频| 国产精品天美传媒| 久久久久99精品一区| 日韩欧美视频在线| 91精品国产综合久久精品麻豆| 91网站视频在线观看| 成人免费视频一区| 丁香婷婷综合网| 国产成人夜色高潮福利影视| 蜜臂av日日欢夜夜爽一区| 极品少妇xxxx偷拍精品少妇| 亚洲欧洲国产专区| 日韩欧美一级二级| 91精品国产福利| 91精品国产aⅴ一区二区| 欧美日韩成人一区二区| 欧美日韩一区不卡| 欧美人妇做爰xxxⅹ性高电影| 一本色道久久综合狠狠躁的推荐| 不卡的av网站| 不卡欧美aaaaa| 91网上在线视频| 久久久蜜臀国产一区二区| 日韩一卡二卡三卡| 精品播放一区二区| 久久精品这里都是精品| 国产网站一区二区| 国产精品国产馆在线真实露脸| 国产精品久久久久久一区二区三区| 国产精品无遮挡| 亚洲精品v日韩精品| 亚洲国产综合色| 免费观看成人鲁鲁鲁鲁鲁视频| 蜜臀av国产精品久久久久| 精品亚洲国内自在自线福利| 国产精品一区二区视频| 精品国产乱子伦一区| 色综合久久久久网| 极品美女销魂一区二区三区 | 免费人成黄页网站在线一区二区| 日韩国产欧美视频| 久久99这里只有精品| 国产成人精品三级麻豆| 色综合一区二区| 欧美肥胖老妇做爰| 精品第一国产综合精品aⅴ| 国产精品毛片久久久久久| 依依成人精品视频| 美腿丝袜在线亚洲一区| 国产成人高清视频| 欧美午夜精品久久久久久孕妇| 91精品国产综合久久精品性色| 久久久久国产一区二区三区四区| 亚洲人妖av一区二区| 日本欧洲一区二区| 丁香激情综合国产| 欧美日韩亚洲综合在线 | 久久精品亚洲麻豆av一区二区| 中文字幕一区免费在线观看 | 欧美三区在线观看| 精品福利一二区| 亚洲综合视频在线| 黄页视频在线91| 欧美在线观看视频一区二区| www国产精品av| 亚洲国产精品久久久久婷婷884 | 精品国产一二三区| 一区二区三区蜜桃| 成人永久aaa| 欧美岛国在线观看| 亚洲一区二区三区影院| 国产98色在线|日韩| 欧美一卡二卡在线观看| 亚洲欧美日韩一区二区三区在线观看| 免费在线观看一区| 色综合久久99| 欧美精彩视频一区二区三区| 三级一区在线视频先锋 | 夜夜嗨av一区二区三区| 国产.精品.日韩.另类.中文.在线.播放| 欧美性极品少妇| 国产精品久久久久久久久搜平片 | 欧美视频三区在线播放| 欧美国产精品劲爆| 国产美女视频一区| 日韩欧美一区在线| 婷婷中文字幕一区三区| 色综合天天综合网天天看片| 欧美激情一区二区| 激情文学综合插| 日韩你懂的在线播放| 日本网站在线观看一区二区三区| 日本电影欧美片| 亚洲人被黑人高潮完整版| 成人黄色综合网站| 国产欧美一区二区精品仙草咪| 久久国产精品99久久人人澡| 欧美乱妇20p| 婷婷开心久久网| 欧美日韩精品一区二区天天拍小说 | 欧美久久免费观看| 色老汉一区二区三区| 欧美怡红院视频| 中文字幕一区在线观看| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 26uuu精品一区二区三区四区在线| 偷拍亚洲欧洲综合| 欧美精品三级日韩久久| 五月天欧美精品| 欧美人与禽zozo性伦| 日本最新不卡在线| 日韩视频在线永久播放| 久久电影网电视剧免费观看| 日韩一区二区三区免费观看| 另类中文字幕网| 久久伊99综合婷婷久久伊| 国产精品白丝jk白祙喷水网站 | 中文字幕一区二区三区在线不卡| 成人免费高清视频| 亚洲欧美日韩国产手机在线| 色婷婷亚洲一区二区三区| 亚洲一区二区三区激情| 91精选在线观看| 紧缚捆绑精品一区二区| 国产欧美一区二区三区在线看蜜臀| 国产宾馆实践打屁股91| 综合久久综合久久| 欧美日本一区二区| 韩国女主播成人在线| 国产精品乱码人人做人人爱| 91视频.com| 日韩主播视频在线| 国产午夜精品久久| 在线视频中文字幕一区二区| 奇米一区二区三区av| 国产女人水真多18毛片18精品视频| 99国产麻豆精品| 视频一区二区中文字幕| 久久久久久一二三区| 一本色道久久综合亚洲精品按摩| 婷婷六月综合亚洲|