public C5.LinkedList <CCorrespondSegment> DWByOptCorSimplified(CPolyline frcpl, CPolyline tocpl, int intMaxBackK, CPoint StandardVetorCpt) { double dblSmallDis = CGeometricMethods.CalSmallDis(frcpl); List <CPolyline> CFrEdgeLt = CGeometricMethods.CreateCplLt(frcpl.cptlt); List <CPolyline> CToEdgeLt = CGeometricMethods.CreateCplLt(tocpl.cptlt); CTable[,] T = CreatT(frcpl, tocpl, CFrEdgeLt, CToEdgeLt, intMaxBackK, StandardVetorCpt); //创建T矩阵 C5.LinkedList <CCorrespondSegment> pCorrespondSegmentLk = FindCorrespondSegmentLk(T, frcpl, tocpl, CFrEdgeLt, CToEdgeLt); return(pCorrespondSegmentLk); }
/// <summary>创建T矩阵</summary> /// <param name="frcpl">大比例尺线状要素</param> /// <param name="tocpl">小比例尺线状要素</param> /// <param name="CFrEdgeLt">大比例尺线段</param> /// <param name="CToEdgeLt">小比例尺线段</param> /// <param name="frlastcpllt">大比例尺终点线段(只有一个点)</param> /// <param name="tolastcpllt">小比例尺终点线段(只有一个点)</param> /// <param name="intMaxBackK">回溯系数</param> /// <remarks>已释放内存</remarks> /// <returns>T矩阵</returns> public override CTable[,] CreatTable(CPolyline frcpl, CPolyline tocpl, int intMaxBackK, CPoint StandardVetorCpt, double dblSmallDis) { List <CPolyline> CFrEdgeLt = CGeometricMethods.CreateCplLt(frcpl.cptlt); List <CPolyline> CToEdgeLt = CGeometricMethods.CreateCplLt(tocpl.cptlt); int intFrPtNum = frcpl.cptlt.Count; int intToPtNum = tocpl.cptlt.Count; List <CPolyline> frlastcpllt = new List <CPolyline>(intFrPtNum - 1); List <CPolyline> tolastcpllt = new List <CPolyline>(intToPtNum - 1); //注意:T矩阵中的序号跟原文算法中的序号是统一的,但线数组中的序号则应减1 CTable[,] T = new CTable[intFrPtNum, intToPtNum]; //T[0,0] T[0, 0] = new CTable(); T[0, 0].dblEvaluation = 0; LinkedList <CCorrespondCPoint> CorrCptLk0 = new LinkedList <CCorrespondCPoint>(); CorrCptLk0.AddLast(new CCorrespondCPoint(CFrEdgeLt[0].FrCpt, CToEdgeLt[0].FrCpt)); T[0, 0].CorrCptLk = CorrCptLk0; CPolyline frfirstcpl = new CPolyline(0, CFrEdgeLt[0].FrCpt); //以线状要素的第一个点作为线段 for (int j = 1; j < intToPtNum; j++) { T[0, j] = new CTable(); T[0, j].intBackK1 = 0; T[0, j].intBackK2 = 1; LinkedList <CCorrespondCPoint> CorrCptLkj; T[0, j].dblEvaluation = T[0, j - 1].dblEvaluation + CalDistance(frfirstcpl, CToEdgeLt[j - 1], StandardVetorCpt, dblSmallDis, frcpl, tocpl, out CorrCptLkj); T[0, j].CorrCptLk = CorrCptLkj; } CPolyline tofirstcpl = new CPolyline(0, CToEdgeLt[0].FrCpt); //以线状要素的第一个点作为线段 for (int i = 1; i < intFrPtNum; i++) { T[i, 0] = new CTable(); T[i, 0].intBackK1 = 1; T[i, 0].intBackK2 = 0; LinkedList <CCorrespondCPoint> CorrCptLki; T[i, 0].dblEvaluation = T[i - 1, 0].dblEvaluation + CalDistance(CFrEdgeLt[i - 1], tofirstcpl, StandardVetorCpt, dblSmallDis, frcpl, tocpl, out CorrCptLki); T[i, 0].CorrCptLk = CorrCptLki; } //循环填满二维数组T中的各个值 for (int i = 0; i < CFrEdgeLt.Count; i++)//大比例尺线段终点数据准备 { List <CPoint> frlastptlt = new List <CPoint>(1); frlastptlt.Add(CFrEdgeLt[i].ToCpt); frlastcpllt.Add(new CPolyline(0, frlastptlt)); } for (int i = 0; i < CToEdgeLt.Count; i++)//小比例尺线段终点数据准备 { List <CPoint> frlastptlt = new List <CPoint>(1); frlastptlt.Add(CToEdgeLt[i].ToCpt); tolastcpllt.Add(new CPolyline(0, frlastptlt)); } //注意:T中的序号1指定第一个元素,而各LT中(如CFrEdgeLt,tolastcpllt)的序号1则指定第二个元素 for (int i = 1; i < intFrPtNum; i++) //计算各空格值 { int intBackKforI = Math.Min(i, intMaxBackK); //程序刚开始执行时,之前已遍历过线段数较少,可能小于intMaxBackK for (int j = 1; j < intToPtNum; j++) { int intBackKforJ = Math.Min(j, intMaxBackK); //程序刚开始执行时,之前已遍历过线段数较少,可能小于intMaxBackK List <CTable> CTableLt = new List <CTable>(intBackKforI * intBackKforJ); for (int k1 = 1; k1 <= intBackKforI; k1++) { for (int k2 = 1; k2 <= intBackKforJ; k2++) { CTable tableij = new CTable(); tableij.intBackK1 = k1; tableij.intBackK2 = k2; LinkedList <CCorrespondCPoint> CorrCptLkij; CPolyline frcpli = frcpl.GetSubPolyline(CFrEdgeLt[i - k1].FrCpt, CFrEdgeLt[i - 1].ToCpt); CPolyline tocplj = tocpl.GetSubPolyline(CToEdgeLt[j - k2].FrCpt, CToEdgeLt[j - 1].ToCpt); tableij.dblEvaluation = T[i - k1, j - k2].dblEvaluation + CalDistance(frcpli, tocplj, StandardVetorCpt, dblSmallDis, frcpl, tocpl, out CorrCptLkij); tableij.CorrCptLk = CorrCptLkij; CTableLt.Add(tableij); } } //find the minimum one T[i, j] = FindMinTable(CTableLt); } } return(T); }