/// <summary> /// 获取折线的弯曲森林 /// </summary> /// <param name="cpl">折线</param> /// <param name="pLeftBendForest">折线左边的弯曲森林</param> /// <param name="pRightBendForest">折线右边的弯曲森林</param> /// <param name="strName">留作保存三角网用</param> /// <remarks>创建约束三角网时,并未使用外包多边形作为约束边</remarks> public void MGetBendForest(CParameterVariable pParameterVariable, ref CBendForest pBendForest, string strSide, CParameterInitialize pParameterInitialize) { //List<CPoint> cptlt = pParameterVariable.CPolyline.CptLt; //List<CEdge> CEdgeLt = new List<CEdge>(); //for (int i = 0; i < cptlt.Count - 1; i++) //{ // CEdge pEdge = new CEdge(cptlt[i], cptlt[i + 1]); // CEdgeLt.Add(pEdge); //} //CTriangulator OptCDT = new CTriangulator(); //List<CTriangle> CDTLt = OptCDT.CreateCDT(pParameterVariable); ////for (int i = 0; i < CDTLt.Count; i++) CDTLt[i].TID = i; //到此为止,约束三角形建立完成,各三角形不再发生变化,将各三角形编号 //OptCDT.GetSETriangle(ref CDTLt); //确定共边三角形 //OptCDT.ConfirmTriangleSide(ref CDTLt, CEdgeLt); //确定各三角形位于折线的左右边 //OptCDT.SignTriTypeAll(ref CDTLt); //标记I、II、III、VI类三角形 //pLeftBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, cptlt, "Left"); //pRightBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, cptlt, "Right"); //List<CTriangle> CTriangleLt = new List<CTriangle>(); //for (int i = 0; i < CDTLt.Count; i++) //{ // if (CDTLt[i].strTriType != "I") // { // CTriangleLt.Add(CDTLt[i]); // } //} //CHelpFunc.SaveTriangles(CTriangleLt, pParameterVariable.strName, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); }
/// <summary> /// 用基于弯曲的Morphing方法进行处理 /// </summary> /// <param name="pParameterInitialize">参数</param> /// <param name="pParameterVariableFrom">有关大比例尺折线的参数变量,主要储存了大比例尺线要素、文件保存时的名字、大比例尺图层和极小值</param> /// <param name="pParameterVariableTo">有关小比例尺折线的参数变量,主要储存了:小比例尺线要素、文件保存时的名字、小比例尺图层和极小值</param> /// <param name="ParameterThreshold">阈值参数,主要储存了:大、小比例尺线要素长度,弯曲基线比阈值范围</param> /// <remarks>创建约束三角网时,已使用外包多边形作为约束边</remarks> public LinkedList <CCorrSegment> DWByMPBBSL(CParameterInitialize pParameterInitialize, CParameterVariable pParameterVariableFrom, CParameterVariable pParameterVariableTo, CParameterThreshold ParameterThreshold) { CPolyline frcpl = pParameterVariableFrom.CPolyline; frcpl.SetPolyline(); CPolyline tocpl = pParameterVariableTo.CPolyline; tocpl.SetPolyline(); List <CPoint> frchcptlt = _Triangulator.CreateConvexHullEdgeLt2(frcpl, pParameterVariableFrom.dblVerySmall); CPolyline frchcpl = new CPolyline(0, frchcptlt); //大比例尺折线外包多边形线段 frchcpl.SetPolyline(); List <CPoint> tochcptlt = _Triangulator.CreateConvexHullEdgeLt2(tocpl, pParameterVariableFrom.dblVerySmall); CPolyline tochcpl = new CPolyline(0, tochcptlt); //小比例尺折线外包多边形线段 tochcpl.SetPolyline(); //添加约束数据生成图层,以便于利用AE中的功能(ct:constraint) List <CPolyline> frctcpllt = new List <CPolyline>(); frctcpllt.Add(frcpl); frctcpllt.Add(frchcpl); List <CPolyline> toctcpllt = new List <CPolyline>(); toctcpllt.Add(tocpl); toctcpllt.Add(tochcpl); IFeatureLayer pBSFLayer = CHelpFunc.SaveCPlLt(frctcpllt, "frctcpllt", pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); IFeatureLayer pSSFLayer = CHelpFunc.SaveCPlLt(toctcpllt, "toctcpllt", pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); pParameterVariableFrom.pFeatureLayer = pBSFLayer; pParameterVariableTo.pFeatureLayer = pSSFLayer; //建立CDT并获取弯曲森林 CBendForest FromLeftBendForest = new CBendForest(); CBendForest FromRightBendForest = new CBendForest(); GetBendForest(pParameterVariableFrom, ref FromLeftBendForest, ref FromRightBendForest, pParameterInitialize); CBendForest ToLeftBendForest = new CBendForest(); CBendForest ToRightBendForest = new CBendForest(); GetBendForest(pParameterVariableTo, ref ToLeftBendForest, ref ToRightBendForest, pParameterInitialize); //弯曲树匹配,寻找对应独立弯曲 List <CCorrespondBend> IndependCorrespondBendLt = new List <CCorrespondBend>(); IndependCorrespondBendLt.AddRange(BendTreeMatch(FromLeftBendForest, ToLeftBendForest, ParameterThreshold)); IndependCorrespondBendLt.AddRange(BendTreeMatch(FromRightBendForest, ToRightBendForest, ParameterThreshold)); //弯曲匹配,寻找对应弯曲 List <CCorrespondBend> CorrespondBendLt = BendMatch(IndependCorrespondBendLt, ParameterThreshold); //提取对应线段 LinkedList <CCorrSegment> CorrespondSegmentLk = CHelpFunc.DetectCorrespondSegment(frcpl, tocpl, CorrespondBendLt); //CHelpFunc.PreviousWorkCSeLt(ref CorrespondSegmentLk); return(CorrespondSegmentLk); }
/// <summary> /// 整理弯曲森林中的弯曲 /// </summary> /// <param name="cpl">折线</param> /// <param name="pBendForest">弯曲森林</param> /// <returns>按相对位置排序的弯曲列表</returns> /// <remarks>计算各弯曲的相对起始位置;并给按顺序编号</remarks> public SortedDictionary <double, CBend> NeatenBendForest(CPolyline cpl, CBendForest pBendForest) { SortedDictionary <double, CBend> pBendSlt = new SortedDictionary <double, CBend>(new CCmpDbl()); //整理弯曲 for (int i = 0; i < pBendForest.Count; i++) { CBend pBend = pBendForest.ElementAt(i).Value; RecursiveNeatenBendForest(cpl, pBend, pBendSlt); } //给弯曲编号 for (int i = 0; i < pBendSlt.Count; i++) { pBendSlt.ElementAt(i).Value.ID = i; } return(pBendSlt); }
/// <summary> /// 递归调用弯曲结构 /// </summary> /// <param name="CCorrespondBend">对应弯曲</param> /// <param name="ParameterThreshold">阈值参数</param> /// <param name="pRightBendForest">折线右边的弯曲森林</param> /// <param name="strName">留作保存三角网用</param> /// <remarks></remarks> public List <CCorrespondBend> RBS(CCorrespondBend pCorrespondBend, CParameterThreshold ParameterThreshold, CParameterInitialize pParameterInitialize) { string strSide = pCorrespondBend.CFromBend.strSide; CPolyline subfrcpl = new CPolyline(0, pCorrespondBend.CFromBend.CptLt); CPolyline subtocpl = new CPolyline(0, pCorrespondBend.CToBend.CptLt); List <CPoint> subfrchcptlt = _Triangulator.CreateConvexHullEdgeLt2(subfrcpl, CConstants.dblVerySmallCoord); CPolyline subfrchcpl = new CPolyline(0, subfrchcptlt); //大比例尺折线外包多边形线段 List <CPoint> subtochcptlt = _Triangulator.CreateConvexHullEdgeLt2(subtocpl, CConstants.dblVerySmallCoord); CPolyline subtochcpl = new CPolyline(0, subtochcptlt); //小比例尺折线外包多边形线段 //添加数据生成图层,以便于利用AE中的功能 List <CPolyline> subfrcpllt = new List <CPolyline>(); subfrcpllt.Add(subfrcpl); subfrcpllt.Add(subfrchcpl); List <CPolyline> subtocpllt = new List <CPolyline>(); subtocpllt.Add(subtocpl); subtocpllt.Add(subtochcpl); IFeatureLayer pBSFLayer = CHelpFunc.SaveCPlLt(subfrcpllt, "subfrcpl" + _dblCDTNum, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); IFeatureLayer pSSFLayer = CHelpFunc.SaveCPlLt(subtocpllt, "subtocpl" + _dblCDTNum, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); CParameterVariable pParameterVariableFrom = new CParameterVariable(subfrcpl, "subFromCDT" + _dblCDTNum, pBSFLayer, CConstants.dblVerySmallCoord); CParameterVariable pParameterVariableTo = new CParameterVariable(subtocpl, "subToCDT" + _dblCDTNum, pSSFLayer, CConstants.dblVerySmallCoord); _dblCDTNum = _dblCDTNum + 1; CMPBBSL OptMPBBSL = new CMPBBSL(); //建立CDT并获取弯曲森林 CBendForest FromBendForest = new CBendForest(); GetSideBendForest(pParameterVariableFrom, ref FromBendForest, pParameterInitialize, strSide); CBendForest ToBendForest = new CBendForest(); GetSideBendForest(pParameterVariableTo, ref ToBendForest, pParameterInitialize, strSide); //弯曲树匹配,寻找对应独立弯曲 List <CCorrespondBend> IndependCorrespondBendLt = BendTreeMatch(FromBendForest, ToBendForest, ParameterThreshold, pParameterInitialize); //弯曲匹配,寻找对应弯曲 List <CCorrespondBend> CorrespondBendLt = BendMatch(IndependCorrespondBendLt, ParameterThreshold, pParameterInitialize); return(CorrespondBendLt); }
/// <summary> /// 进行弯曲匹配,提取对应线段 /// </summary> /// <param name="CFromBendForest">大比例尺弯曲森林</param> /// <param name="CToBendForest">小比例尺弯曲森林</param> /// <param name="ParameterThreshold">参数容器</param> /// <param name="CorrespondSegmentLk">对应线段列</param> /// <remarks>弯曲树匹配和孩子弯曲匹配都由本函数来执行 /// 注意:此处的弯曲树匹配及弯曲匹配与"MPBBSL"中有所不同,此处增加了递归识别独立弯曲</remarks> public List <CCorrespondBend> BendTreeMatch(CBendForest CFromBendForest, CBendForest CToBendForest, CParameterThreshold ParameterThreshold, CParameterInitialize pParameterInitialize) { //大比例尺独立弯曲 SortedDictionary <double, CBend> pFromIndependBendSlt = new SortedDictionary <double, CBend>(new CCmpDbl()); for (int i = 0; i < CFromBendForest.Count; i++) { pFromIndependBendSlt.Add(CFromBendForest.ElementAt(i).Value.dblStartRL, CFromBendForest.ElementAt(i).Value); } //小比例尺独立弯曲 SortedDictionary <double, CBend> pToIndependBendSlt = new SortedDictionary <double, CBend>(new CCmpDbl()); for (int i = 0; i < CToBendForest.Count; i++) { pToIndependBendSlt.Add(CToBendForest.ElementAt(i).Value.dblStartRL, CToBendForest.ElementAt(i).Value); } //获取对应弯曲 List <CCorrespondBend> pIndependCorrespondBendLt = IndependBendMatch(pFromIndependBendSlt, pToIndependBendSlt, ParameterThreshold, pParameterInitialize); return(pIndependCorrespondBendLt); }
/// <summary> /// 获取折线某一边的弯曲森林 /// </summary> /// <param name="cpl">折线</param> /// <param name="pParameterVariable">变量参数:包含线状要素,需建立CDT的图层,CDT被保存的文件名称</param> /// <param name="pBendForest">待建立的一边的弯曲森林</param> /// <param name="pParameterInitialize">参数</param> /// <param name="strForeSide">弯曲在线状要素的侧边(右侧或左侧),此处将建立另外一侧的弯曲森林</param> /// <remarks>注意:本方法中的CreateCDT将会改变pParameterVariable中的CPolyline</remarks> public void GetSideBendForest(CParameterVariable pParameterVariable, ref CBendForest pBendForest, CParameterInitialize pParameterInitialize, string strForeSide) { CTriangulator OptCDT = new CTriangulator(); CPolyline newcpl = new CPolyline(pParameterVariable.CPolyline.ID, pParameterVariable.CPolyline.CptLt); List <CTriangle> CDTLt = OptCDT.CreateCDT(pParameterVariable.pFeatureLayer, ref newcpl, pParameterVariable.dblVerySmall); pParameterVariable.CPolyline = newcpl; //for (int i = 0; i < CDTLt.Count; i++) CDTLt[i].TID = i; //到此为止,约束三角形建立完成,各三角形不再发生变化,将各三角形编号 OptCDT.GetSETriangle(ref CDTLt, pParameterVariable.dblVerySmall); //确定共边三角形 OptCDT.ConfirmTriangleSide(ref CDTLt, pParameterVariable.CPolyline, pParameterVariable.dblVerySmall); //确定各三角形位于折线的左右边 OptCDT.SignTriTypeAll(ref CDTLt); //标记I、II、III、VI类三角形 if (strForeSide == "Left") { pBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, pParameterVariable.CPolyline.CptLt, "Right", pParameterVariable.dblVerySmall); } else if (strForeSide == "Right") { pBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, pParameterVariable.CPolyline.CptLt, "Left", pParameterVariable.dblVerySmall); } else { MessageBox.Show("GetSideBendForest出现问题!"); } //保存三角网 //List<CTriangle> CTriangleLt = new List<CTriangle>(); //for (int i = 0; i < CDTLt.Count; i++) //{ // if (CDTLt[i].strTriType != "I") // { // CTriangleLt.Add(CDTLt[i]); // } //} //CHelpFunc.SaveTriangles(CTriangleLt, pParameterVariable.strName, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); }
/// <summary> /// 获取折线的弯曲森林 /// </summary> /// <param name="cpl">折线</param> /// <param name="pLeftBendForest">折线左边的弯曲森林</param> /// <param name="pRightBendForest">折线右边的弯曲森林</param> /// <param name="strName">留作保存三角网用</param> /// <remarks>创建约束三角网时,并未使用外包多边形作为约束边 /// 注意:本方法中的CreateCDT将会改变pParameterVariable中的CPolyline</remarks> public void GetBendForest(CParameterVariable pParameterVariable, ref CBendForest pLeftBendForest, ref CBendForest pRightBendForest, CParameterInitialize pParameterInitialize) { //List<CPoint> cptlt = pParameterVariable.CPolyline.CptLt; //List<CEdge> CEdgeLt = new List<CEdge>(); //for (int i = 0; i < cptlt.Count - 1; i++) //{ // CEdge pEdge = new CEdge(cptlt[i], cptlt[i + 1]); // CEdgeLt.Add(pEdge); //} CTriangulator OptCDT = new CTriangulator(); CPolyline newcpl = new CPolyline(pParameterVariable.CPolyline.ID, pParameterVariable.CPolyline.CptLt); List <CTriangle> CDTLt = OptCDT.CreateCDT(pParameterVariable.pFeatureLayer, ref newcpl, pParameterVariable.dblVerySmall); pParameterVariable.CPolyline = newcpl; //for (int i = 0; i < CDTLt.Count; i++) CDTLt[i].TID = i; //到此为止,约束三角形建立完成,各三角形不再发生变化,将各三角形编号 OptCDT.GetSETriangle(ref CDTLt, pParameterVariable.dblVerySmall); //确定共边三角形 OptCDT.ConfirmTriangleSide(ref CDTLt, pParameterVariable.CPolyline, pParameterVariable.dblVerySmall); //确定各三角形位于折线的左右边 OptCDT.SignTriTypeAll(ref CDTLt); //标记I、II、III、VI类三角形 pLeftBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, pParameterVariable.CPolyline.CptLt, "Left", pParameterVariable.dblVerySmall); pRightBendForest = OptCDT.BuildBendForestNeed2(ref CDTLt, pParameterVariable.CPolyline.CptLt, "Right", pParameterVariable.dblVerySmall); //保存三角网 List <CTriangle> CTriangleLt = new List <CTriangle>(); for (int i = 0; i < CDTLt.Count; i++) { if (CDTLt[i].strTriType != "I") { CTriangleLt.Add(CDTLt[i]); } } //CHelpFunc.SaveTriangles(CTriangleLt, pParameterVariable.strName, pParameterInitialize.pWorkspace, pParameterInitialize.m_mapControl); }