src/stringmap/split_l.cpp
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);
	}
}
/*-----------------------------------------------------------------------------
| 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.
-----------------------------------------------------------------------------*/
| 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.
| 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;
		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;
			}
		}
		width[dim] = CoverSplit.boundary[high] -
			     CoverSplit.boundary[dim];
	}
	for (dim=0; dim<NUMDIMS; dim++)
	{
		high = dim + NUMDIMS;
		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);
	}
}
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 ; 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 ; } } width [ dim ] = CoverSplit . boundary [ high ] - CoverSplit . boundary [ dim ] ; } for ( dim = 0 ; dim < NUMDIMS ; dim ++ ) { high = dim + NUMDIMS ; 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 ) ; } }
| Pick two rects from set to be the first elements of the two groups.
| Pick two rects from set to be the first elements of the two groups .
/* find the rectangles farthest out in each direction
		 * along this dimens */ /* find width of the whole collection along this dimension */ /* pick the best separation dimension and the two seed rects */ /* divisor for normalizing by width */