Exemple #1
0
        private IEnumerable <CRegion> AggregateAndUpdateQ_Common(CRegion crg, CRegion lscrg, CRegion sscrg, SortedSet <CRegion> Q,
                                                                 SortedDictionary <CCorrCphs, CCorrCphs> pAdjCorrCphsSD, CCorrCphs unitingCorrCphs,
                                                                 List <SortedDictionary <CRegion, CRegion> > ExistingCrgSDLt, List <SortedDictionary <CPatch, CPatch> > ExistingCphSDLt,
                                                                 SortedDictionary <CCorrCphs, CCorrCphs> ExistingCorrCphsSD, double[,] padblTD, int intEstSteps)
        {
            var newcph           = crg.ComputeNewCph(unitingCorrCphs, ExistingCphSDLt);
            var newAdjCorrCphsSD = CRegion.ComputeNewAdjCorrCphsSDAndUpdateExistingCorrCphsSD(pAdjCorrCphsSD,
                                                                                              unitingCorrCphs, newcph, ExistingCorrCphsSD);


            var frcph          = unitingCorrCphs.FrCph;
            var tocph          = unitingCorrCphs.ToCph;
            int intfrTypeIndex = crg.GetCphTypeIndex(frcph);
            int inttoTypeIndex = crg.GetCphTypeIndex(tocph);


            //if the two cphs have the same type, then we only need to aggregate the smaller one into the larger one
            //(this will certainly have smaller cost in terms of area)
            //otherwise, we need to aggregate from two directions
            if (intfrTypeIndex == inttoTypeIndex)
            {
                if (frcph.dblArea >= tocph.dblArea)
                {
                    yield return(GenerateCrgAndUpdateQ(crg, lscrg, sscrg, Q, ExistingCrgSDLt, newAdjCorrCphsSD,
                                                       frcph, tocph, newcph, unitingCorrCphs, padblTD, intEstSteps));
                }
                else
                {
                    yield return(GenerateCrgAndUpdateQ(crg, lscrg, sscrg, Q, ExistingCrgSDLt, newAdjCorrCphsSD,
                                                       tocph, frcph, newcph, unitingCorrCphs, padblTD, intEstSteps));
                }
            }
            else
            {
                //The aggregate can happen from two directions
                yield return(GenerateCrgAndUpdateQ(crg, lscrg, sscrg, Q, ExistingCrgSDLt, newAdjCorrCphsSD,
                                                   frcph, tocph, newcph, unitingCorrCphs, padblTD, intEstSteps));

                yield return(GenerateCrgAndUpdateQ(crg, lscrg, sscrg, Q, ExistingCrgSDLt, newAdjCorrCphsSD,
                                                   tocph, frcph, newcph, unitingCorrCphs, padblTD, intEstSteps));
            }
        }