src/stringmap/split_q.cpp
static void RTreeMethodZero(struct PartitionVars *p)
{
	register int i;
	RectReal biggestDiff;
	register int group, chosen, betterGroup;
	assert(p);

	RTreeInitPVars(p);
	RTreePickSeeds(p);

	while (p->count[0] + p->count[1] < NODECARD + 1
		&& p->count[0] < NODECARD + 1 - MinFill
		&& p->count[1] < NODECARD + 1 - MinFill)
	{
		biggestDiff = (RectReal)-1.;
		for (i=0; i<NODECARD+1; i++)
		{
			if (!p->taken[i])
			{
				struct Rect *r, rect_0, rect_1;
				RectReal growth0, growth1, diff;

				r = &BranchBuf[i].rect;
				rect_0 = RTreeCombineRect(r, &p->cover[0]);
				rect_1 = RTreeCombineRect(r, &p->cover[1]);
				growth0 = RTreeRectSphericalVolume(
						&rect_0)-p->area[0];
				growth1 = RTreeRectSphericalVolume(
						&rect_1)-p->area[1];
				diff = growth1 - growth0;
				if (diff >= 0)
					group = 0;
				else
				{
					group = 1;
					diff = -diff;
				}

				if (diff > biggestDiff)
				{
					biggestDiff = diff;
					chosen = i;
					betterGroup = group;
				}
				else if (diff==biggestDiff &&
					 p->count[group]<p->count[betterGroup])
				{
					chosen = i;
					betterGroup = group;
				}
			}
		}
		RTreeClassify(chosen, betterGroup, p);
	}

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

	assert(p->count[0] + p->count[1] == NODECARD+1);
	assert(p->count[0] >= MinFill && p->count[1] >= MinFill);
}
/*-----------------------------------------------------------------------------
| Method #0 for choosing a partition:
| As the seeds for the two groups, pick the two rects that would waste the
| most area if covered by a single rectangle, i.e. evidently the worst pair
| to have in the same group.
| Of the remaining, one at a time is chosen to be put in one of the two groups.
| The one chosen is the one with the greatest difference in area expansion
| depending on which group - the rect most strongly attracted to one group
| and repelled from the other.
| If one group gets too full (more would force other group to violate min
| fill requirement) then other group gets the rest.
| These last are the ones that can go in either group most easily.
-----------------------------------------------------------------------------*/
| Method #0 for choosing a partition:
| As the seeds for the two groups, pick the two rects that would waste the
| most area if covered by a single rectangle, i.e. evidently the worst pair
| to have in the same group.
| Of the remaining, one at a time is chosen to be put in one of the two groups.
| The one chosen is the one with the greatest difference in area expansion
| depending on which group - the rect most strongly attracted to one group
| and repelled from the other.
| If one group gets too full (more would force other group to violate min
| fill requirement) then other group gets the rest.
| These last are the ones that can go in either group most easily.
| Method #0 for choosing a partition : | As the seeds for the two groups pick the two rects that would waste the | most area if covered by a single rectangle i . e . evidently the worst pair | to have in the same group . | Of the remaining one at a time is chosen to be put in one of the two groups . | The one chosen is the one with the greatest difference in area expansion | depending on which group - the rect most strongly attracted to one group | and repelled from the other . | If one group gets too full ( more would force other group to violate min | fill requirement ) then other group gets the rest . | These last are the ones that can go in either group most easily .
static void RTreeMethodZero(struct PartitionVars *p)
{
	register int i;
	RectReal biggestDiff;
	register int group, chosen, betterGroup;
	assert(p);
	RTreeInitPVars(p);
	RTreePickSeeds(p);
	while (p->count[0] + p->count[1] < NODECARD + 1
		&& p->count[0] < NODECARD + 1 - MinFill
		&& p->count[1] < NODECARD + 1 - MinFill)
	{
		biggestDiff = (RectReal)-1.;
		for (i=0; i<NODECARD+1; i++)
		{
			if (!p->taken[i])
			{
				struct Rect *r, rect_0, rect_1;
				RectReal growth0, growth1, diff;
				r = &BranchBuf[i].rect;
				rect_0 = RTreeCombineRect(r, &p->cover[0]);
				rect_1 = RTreeCombineRect(r, &p->cover[1]);
				growth0 = RTreeRectSphericalVolume(
						&rect_0)-p->area[0];
				growth1 = RTreeRectSphericalVolume(
						&rect_1)-p->area[1];
				diff = growth1 - growth0;
				if (diff >= 0)
					group = 0;
				else
				{
					group = 1;
					diff = -diff;
				}
				if (diff > biggestDiff)
				{
					biggestDiff = diff;
					chosen = i;
					betterGroup = group;
				}
				else if (diff==biggestDiff &&
					 p->count[group]<p->count[betterGroup])
				{
					chosen = i;
					betterGroup = group;
				}
			}
		}
		RTreeClassify(chosen, betterGroup, p);
	}
	if (p->count[0] + p->count[1] < NODECARD + 1)
	{
		if (p->count[0] >= NODECARD + 1 - MinFill)
			group = 1;
		else
			group = 0;
		for (i=0; i<NODECARD+1; i++)
		{
			if (!p->taken[i])
				RTreeClassify(i, group, p);
		}
	}
	assert(p->count[0] + p->count[1] == NODECARD+1);
	assert(p->count[0] >= MinFill && p->count[1] >= MinFill);
}
static void RTreeMethodZero ( struct PartitionVars * p ) { register int i ; RectReal biggestDiff ; register int group , chosen , betterGroup ; assert ( p ) ; RTreeInitPVars ( p ) ; RTreePickSeeds ( p ) ; while ( p -> count [ 0 ] + p -> count [ 1 ] < NODECARD + 1 && p -> count [ 0 ] < NODECARD + 1 - MinFill && p -> count [ 1 ] < NODECARD + 1 - MinFill ) { biggestDiff = ( RectReal ) - 1. ; for ( i = 0 ; i < NODECARD + 1 ; i ++ ) { if ( ! p -> taken [ i ] ) { struct Rect * r , rect_0 , rect_1 ; RectReal growth0 , growth1 , diff ; r = & BranchBuf [ i ] . rect ; rect_0 = RTreeCombineRect ( r , & p -> cover [ 0 ] ) ; rect_1 = RTreeCombineRect ( r , & p -> cover [ 1 ] ) ; growth0 = RTreeRectSphericalVolume ( & rect_0 ) - p -> area [ 0 ] ; growth1 = RTreeRectSphericalVolume ( & rect_1 ) - p -> area [ 1 ] ; diff = growth1 - growth0 ; if ( diff >= 0 ) group = 0 ; else { group = 1 ; diff = - diff ; } if ( diff > biggestDiff ) { biggestDiff = diff ; chosen = i ; betterGroup = group ; } else if ( diff == biggestDiff && p -> count [ group ] < p -> count [ betterGroup ] ) { chosen = i ; betterGroup = group ; } } } RTreeClassify ( chosen , betterGroup , p ) ; } if ( p -> count [ 0 ] + p -> count [ 1 ] < NODECARD + 1 ) { if ( p -> count [ 0 ] >= NODECARD + 1 - MinFill ) group = 1 ; else group = 0 ; for ( i = 0 ; i < NODECARD + 1 ; i ++ ) { if ( ! p -> taken [ i ] ) RTreeClassify ( i , group , p ) ; } } assert ( p -> count [ 0 ] + p -> count [ 1 ] == NODECARD + 1 ) ; assert ( p -> count [ 0 ] >= MinFill && p -> count [ 1 ] >= MinFill ) ; }
| Method #0 for choosing a partition:
| As the seeds for the two groups, pick the two rects that would waste the
| most area if covered by a single rectangle, i.e.
| Method #0 for choosing a partition : | As the seeds for the two groups pick the two rects that would waste the | most area if covered by a single rectangle i . e .
/* if one group too full, put remaining rects in the other */