如何计算两曲线间最短路径?
C#开发|冯美娟|2018-07-25 15:22
-
回答:
axMxDrawX1.StopAllTwinkeEnt(); MxDrawEntity ent1 = (MxDrawEntity)(axMxDrawX1.GetEntity("选择开始曲线:") ); if (ent1 == null) return; MxDrawEntity ent2 = (MxDrawEntity)(axMxDrawX1.GetEntity("选择结束曲线:")); if (ent2 == null) return; MxDrawDatabase database = (MxDrawDatabase)(axMxDrawX1.GetDatabase()); MxDrawResbuf param = new MxDrawResbuf(); param.AddObjectId(ent1.ObjectID); param.AddObjectId(ent2.ObjectID); MxDrawResbuf ret = (MxDrawResbuf)(axMxDrawX1.CallEx("ExApp_ShortestPath",param)); if (ret.AtString(0) != "Ok") { MessageBox.Show("曲线不连通!"); } else { for (int i = 1; i < ret.Count; i++) { Int64 lId = ret.AtObjectId(i); axMxDrawX1.TwinkeEnt(lId); // 由lId得到对象,并得到对象的坐标 MxDrawMcDbObject obj = database.ObjectIdToObject(lId); if (obj == null) continue; if (obj is MxDrawLine) { MxDrawLine line = (MxDrawLine)obj; MxDrawPoint sPt = (MxDrawPoint)(line.StartPoint); MxDrawPoint ePt = (MxDrawPoint)(line.EndPoint); //MessageBox.Show(sPt.x.ToString() + "," + sPt.y.ToString() + "," // + ePt.x.ToString() + "," + ePt.y.ToString() // ); } else if (obj is MxDrawText) { MxDrawText text = (MxDrawText)obj; // 是这文字对象 } } }