/// <summary>compute the cost</summary> /// <param name="subfrcptlt">it is allowed that there is only one point in subfrcptlt</param> /// <param name="subtocptlt">it is allowed that there is only one point in subfrcptlt</param> /// <param name="StandardVectorCpt">if frcpl and tocpl are not in the same place, we use StandardVectorCpt to offset their distance</param> /// <returns>the cost</returns> protected double CalDistance(List <CPoint> subfrcptlt, List <CPoint> subtocptlt) { CLIA pLIA = new CLIA(subfrcptlt, subtocptlt, true); //linear interpolation between subfrcptlt and subtocptlt double dblEvaluation = _pEvaluation.CalEvaluationCorr(pLIA.CLI(), _pEvaluation.dlgEvaluationMethod, pLIA.dblFrTotalLength, pLIA.dblToTotalLength); return(dblEvaluation); }
public CParameterResult LIMorphing() { List <CPolyline> pLSCPlLt = _LSCPlLt; List <CPolyline> pSSCPlLt = _SSCPlLt; long lngStartTime1 = System.Environment.TickCount; //lngTime1 pLSCPlLt.ForEach(cpl => cpl.SetEdgeLengthOnToCpt()); pSSCPlLt.ForEach(cpl => cpl.SetEdgeLengthOnToCpt()); long lngTime1 = System.Environment.TickCount - lngStartTime1; //lngTime1 double dblX = pSSCPlLt[0].FrCpt.X - pLSCPlLt[0].FrCpt.X; double dblY = pSSCPlLt[0].FrCpt.Y - pLSCPlLt[0].FrCpt.Y; CPoint StandardVectorCpt = new CPoint(0, dblX, dblY); _StandardVectorCpt = StandardVectorCpt; double dblStandardLength = CGeoFunc.CalDis(0, 0, dblX, dblY); List <List <CCorrCpts> > pCorrCptsLtLt = new List <List <CCorrCpts> >(pLSCPlLt.Count); long lngStartTime2 = System.Environment.TickCount; //lngTime2 pCorrCptsLtLt = new List <List <CCorrCpts> >(pLSCPlLt.Count); //initialize //pCtrlCptLtLt = new List<List<CCorrCpts>>(pLSCPlLt.Count); //initialize for (int i = 0; i < LSCPlLt.Count; i++) { CLIA pCLIA = new CLIA(LSCPlLt[i], SSCPlLt[i]); pCorrCptsLtLt.Add(pCLIA.CLI().ToList()); } long lngTime2 = System.Environment.TickCount - lngStartTime2; //lngTime2 _ParameterInitialize.tsslTime.Text = "Running Time: " + Convert.ToString(lngTime2) + "ms"; //显示运行时间 CHelpFunc.SaveCorrLine(pCorrCptsLtLt, "Linear", _ParameterInitialize.pWorkspace, _ParameterInitialize.m_mapControl); _CorrCptsLtLt = pCorrCptsLtLt; //the results will be recorded in _ParameterResult CParameterResult ParameterResult = new CParameterResult(); ParameterResult.pMorphingBase = this as CMorphingBase; _ParameterResult = ParameterResult; return(ParameterResult); }
/// <summary>以回溯的方式寻找对应线段</summary> /// <returns>对应线段数组</returns> protected List <CCorrCpts> GetCorrespondences(CTable Table, List <CPoint> frcptlt, List <CPoint> tocptlt, out List <CCorrCpts> CtrlCptsLt) { var CPairIntLt = new List <CPairInt>(frcptlt.Count + tocptlt.Count); int inti = Table.intRow - 1; int intj = Table.intCol - 1; //record all the nodes int intCtrlCount = 1; //number of pairs of control points while (inti > 0 || intj > 0) { int intI = inti; int intJ = intj; CPairIntLt.Add(new CPairInt(intI, intJ)); inti = inti - Table.aCell[intI, intJ].intBackK1; intj = intj - Table.aCell[intI, intJ].intBackK2; intCtrlCount++; } //get results List <CCorrCpts> CorrCptsLt = new List <CCorrCpts>(frcptlt.Count + tocptlt.Count - 2); CtrlCptsLt = new List <CCorrCpts>(intCtrlCount); //var CCorrCptsFirst = new CCorrCpts(frcptlt[0], tocptlt[0]); //CorrCptsLt.Add(CCorrCptsFirst); //CtrlCptsLt.Add(CCorrCptsFirst); // add the first pair of control points for (int i = CPairIntLt.Count - 1; i >= 0; i--) { int intI = CPairIntLt[i].Int1; int intJ = CPairIntLt[i].Int2; var subfrcptlt = frcptlt.GetRange(intI - Table.aCell[intI, intJ].intBackK1, Table.aCell[intI, intJ].intBackK1 + 1); var subtocptlt = tocptlt.GetRange(intJ - Table.aCell[intI, intJ].intBackK2, Table.aCell[intI, intJ].intBackK2 + 1); CLIA pLIA = new CLIA(subfrcptlt, subtocptlt, true); CorrCptsLt.AddRange(pLIA.CLI(false)); //to reduce memory using of Table, we interpolate here again CtrlCptsLt.Add(CorrCptsLt.Last()); } return(CorrCptsLt); }