{
tl1[cIndex] = dataLow[cIndex].m_pRegion;
th1[cIndex] = dataHigh[cIndex].m_pRegion;
}
Region bbl1 = Region.combinedRegion(tl1);
Region bbh1 = Region.combinedRegion(th1);
Region[] tl2 = new Region[m_capacity + 1 - l];
Region[] th2 = new Region[m_capacity + 1 - l];
int tmpIndex = 0;
for (cIndex = l; cIndex < m_capacity + 1; cIndex++)
{
tl2[tmpIndex] = dataLow[cIndex].m_pRegion;
th2[tmpIndex] = dataHigh[cIndex].m_pRegion;
tmpIndex++;
}
Region bbl2 = Region.combinedRegion(tl2);
Region bbh2 = Region.combinedRegion(th2);
marginl += bbl1.getMargin() + bbl2.getMargin();
marginh += bbh1.getMargin() + bbh2.getMargin();
} // for (cChild)
double margin = Math.min(marginl, marginh);
// keep minimum margin as split axis.
if (margin < minimumMargin)
{
minimumMargin = margin;
splitAxis = cDim;
sortOrder = (marginl < marginh) ? 0 : 1;
}
// increase the dimension according to which the data entries should be sorted.
for (cChild = 0; cChild < m_capacity + 1; cChild++)
{
dataLow[cChild].m_sortDim = cDim + 1;
}
} // for (cDim)
for (cChild = 0; cChild < m_capacity + 1; cChild++)
{
dataLow[cChild].m_sortDim = splitAxis;
}
if (sortOrder == 0)
Arrays.sort(dataLow, new RstarSplitEntryComparatorLow());
else
Arrays.sort(dataLow, new RstarSplitEntryComparatorHigh());
double ma = Double.POSITIVE_INFINITY;
double mo = Double.POSITIVE_INFINITY;
int splitPoint = -1;
for (cChild = 1; cChild <= splitDistribution; cChild++)
{
int l = nodeSPF - 1 + cChild;
Region[] t1 = new Region[l];
for (cIndex = 0; cIndex < l; cIndex++)
{
t1[cIndex] = dataLow[cIndex].m_pRegion;
}
Region bb1 = Region.combinedRegion(t1);
Region[] t2 = new Region[m_capacity + 1 - l];
int tmpIndex = 0;
for (cIndex = l; cIndex < m_capacity + 1; cIndex++)
{
t2[tmpIndex] = dataLow[cIndex].m_pRegion;
tmpIndex++;
}
Region bb2 = Region.combinedRegion(t2);
double o = bb1.getIntersectingArea(bb2);
if (o < mo)
{
splitPoint = cChild;
mo = o;
ma = bb1.getArea() + bb2.getArea();
}
else if (o == mo)
{
double a = bb1.getArea() + bb2.getArea();
if (a < ma)
{
splitPoint = cChild;
ma = a;