override public IPosition GetPosition() { if (isPositionEdit) { return(new Position_Edit_Transformed((IPosition_Edit)positionSet.GetPosition(), transform)); } else { return(new Position_Transformed(positionSet.GetPosition(), transform)); } }
//测试点集引用 private void TestReference() { cps.InitToTraverseSet(); ps.InitToTraverseSet(); correct = true; while (correct && cps.NextPosition()) { IPosition cp = cps.GetPosition(); bool find = false; ps.InitToTraverseSet(); while (!find && ps.NextPosition()) { IPosition p = ps.GetPosition(); if (cp == p) { find = true; } } if (!find) { correct = false; } } report += "【引用测试】\r\n" + (correct ? "通过!" : "未通过!") + "\r\n"; }
//根据点序列来作图 public void draw() { //生成报表第一行 reportTable = "\t"; IPositionSet ps0 = psList[0]; ps0.InitToTraverseSet(); while (ps0.NextPosition()) { IPosition p = ps0.GetPosition(); reportTable += p.GetX() + "\t"; } reportTable += "\r\n"; //作图并生成报表 for (int i = 0; i < nameList.Count; i++) { reportTable += nameList[i] + "\t"; List <double> xData = new List <double>(); List <double> yData = new List <double>(); IPositionSet ps = psList[i]; ps.InitToTraverseSet(); while (ps.NextPosition()) { if (bLogX) { xData.Add(Math.Log10(ps.GetPosition().GetX())); } else { xData.Add(ps.GetPosition().GetX()); } yData.Add(ps.GetPosition().GetY()); reportTable += ps.GetPosition().GetY() + "\t"; } reportTable += "\r\n"; form.addCurve(nameList[i], xData.ToArray(), yData.ToArray()); } FileStream fs = new FileStream(reportFileName, System.IO.FileMode.Create, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs, System.Text.UnicodeEncoding.Unicode); sw.Write(reportTable); sw.Close(); fs.Close(); form.Show(); }
public void Preprocessing(IPositionSet positionSet) { positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { Insert(positionSet.GetPosition()); } }
public static void printPositionSet(IPositionSet ps) { ps.InitToTraverseSet(); while (ps.NextPosition()) { IPosition p = ps.GetPosition(); System.Console.Out.WriteLine(p.GetX() + "," + p.GetY() + ","); } }
override public void InitToTraverseSet() { if (true) { if (AncestorLevelSequence == DescendantLevelSequence - 1) { DescendentPositionSetOfChildPart = M2MS.GetChildPositionSetByParentPart(AncestorLevelSequence, AncestorPart); DescendentPositionSetOfChildPart.InitToTraverseSet(); } else if (AncestorLevelSequence > DescendantLevelSequence - 1) { throw new Exception("AncestorLevelSequence > DescendantLevelSequence - 1"); } else { childPositionSet = M2MS.GetChildPositionSetByParentPart(AncestorLevelSequence, AncestorPart); childPositionSet.InitToTraverseSet(); if (childPositionSet.NextPosition()) { childPart = (IPart)childPositionSet.GetPosition(); //if (true) { DescendentPositionSetOfChildPart = new PositionSet_DescendentPosition(DescendantLevelSequence, (IPart)childPositionSet.GetPosition(), AncestorLevelSequence + 1, M2MS); DescendentPositionSetOfChildPart.InitToTraverseSet(); } //else //{ // state = State.ChildPartSubPointNumIsOne; // state = State.None; //} } } } }
public PositionSet_Transformed(IPositionSet positionSet, Transform transform) { this.positionSet = positionSet; this.transform = transform; positionSet.InitToTraverseSet(); positionSet.NextPosition(); if (positionSet.GetPosition() is IPosition_Edit) { isPositionEdit = true; } }
private void button6_Click(object sender, EventArgs e) { QuickHull qn = new QuickHull(); IPositionSet ps = qn.ConvexHull(getPoints2((Bitmap)pictureBox1.Image)); Graphics g = Graphics.FromImage(pictureBox1.Image); IPosition p1 = ps.GetPosition(); IPosition p2 = ps.GetPosition(); while (p2 != null) { g.DrawLine(new Pen(Color.Green), new PointF(p1.GetX(), p1.GetY()), new PointF(p2.GetX(), p2.GetY())); p1 = p2; p2 = ps.GetPosition(); } ps.InitToTraverseSet(); p2 = ps.GetPosition(); g.DrawLine(new Pen(Color.Green), new PointF(p1.GetX(), p1.GetY()), new PointF(p2.GetX(), p2.GetY())); pictureBox1.Refresh(); }
private void AddChildPositionSetToList(int parentPartLevelSequence, IPosition parentPart) { childPositionSetOfPart = m2mStructure.GetChildPositionSetByParentPart(parentPartLevelSequence, (IPart)parentPart); //得到凸包上的点的子分块集合 childPositionSetOfPart.InitToTraverseSet(); while (childPositionSetOfPart.NextPosition()) { tempChildPositionList.Add(childPositionSetOfPart.GetPosition()); } }
private void button1_Click_1(object sender, EventArgs e) { //取得测试数据 float rx = float.Parse(txtRX.Text); float ry = float.Parse(txtRY.Text); float sx = float.Parse(txtSX.Text); float sy = float.Parse(txtSY.Text); float ex = float.Parse(txtEX.Text); float ey = float.Parse(txtEY.Text); float itv = float.Parse(txtItv.Text); //求解 Position_Point rp = new Position_Point(rx, ry); Position_Point sp = new Position_Point(sx, sy); Position_Point ep = new Position_Point(ex, ey); IPositionSet ps = BlockLine.getBlockLine(rp, itv, sp, ep); //作图 pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height); Graphics g = Graphics.FromImage(pictureBox1.Image); g.Clear(Color.White); //网格线 for (float x = rx - itv; x >= 0; x -= itv) { g.DrawLine(Pens.Black, x, 0, x, pictureBox1.Height); } for (float y = ry - itv; y >= 0; y -= itv) { g.DrawLine(Pens.Black, 0, y, pictureBox1.Width, y); } for (float x = rx; x < pictureBox1.Width; x += itv) { g.DrawLine(Pens.Black, x, 0, x, pictureBox1.Height); } for (float y = ry; y < pictureBox1.Width; y += itv) { g.DrawLine(Pens.Black, 0, y, pictureBox1.Width, y); } //经过的网格 ps.InitToTraverseSet(); while (ps.NextPosition()) { IPosition p = ps.GetPosition(); float x = p.GetX(); float y = p.GetY(); g.FillRectangle(Brushes.Gray, x - itv / 2 + 1, y - itv / 2 + 1, itv - 1, itv - 1); } //起点和终点 g.FillEllipse(Brushes.Black, sx - 2, sy - 2, 4, 4); g.FillEllipse(Brushes.Black, ex - 2, ey - 2, 4, 4); g.DrawLine(Pens.Red, sx, sy, ex, ey); }
public PositionSet_Cloned(IPositionSet positionSet) { List <IPosition> positionList = new List <IPosition>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { positionList.Add(new Position_Point(positionSet.GetPosition().GetX(), positionSet.GetPosition().GetY())); } this.positionSetEdit = new PositionSetEdit_ImplementByICollectionTemplate(positionList); this.positionSet = positionSetEdit; }
//计算多边形的重心 public static IPosition GetGravityCenter(IPositionSet ps) { //double xsum = 0, ysum = 0; //IPosition[] pa = (IPosition[])ps.ToArray(); //int n = pa.Length; //int nn = (pa[0] == pa[n - 1]) ? n : n + 1; //for (int i = 0; i < nn - 1; i++) //{ // double tvalue = pa[i].GetX() * pa[(i + 1) % n].GetY() - pa[i].GetY() * pa[(i + 1) % n].GetX(); // xsum += (pa[i].GetX() + pa[(i + 1) % n].GetX()) * tvalue; // ysum += (pa[i].GetY() + pa[(i + 1) % n].GetY()) * tvalue; //} //double area = GetArea(ps); //double cx = xsum / (6 * area); //double cy = ysum / (6 * area); //return new Position_Point((float)cx, (float)cy); ps.InitToTraverseSet(); ps.NextPosition(); float maxX = ps.GetPosition().GetX(); float minX = ps.GetPosition().GetX(); float maxY = ps.GetPosition().GetY(); float minY = ps.GetPosition().GetY(); while (ps.NextPosition()) { float x = ps.GetPosition().GetX(); float y = ps.GetPosition().GetY(); if (x > maxX) { maxX = x; } else if (x < minX) { minX = x; } if (y > maxY) { maxY = y; } else if (y < minY) { minY = y; } } return(new Position_Point((minX + maxX) / 2f, (minY + maxY) / 2f)); }
private void OnGetLinePositionSetInSpecificLevel(ILevel level, int levelSequence, IPositionSet positionSet) { lock (layers) { if (linePartSetLayer == null) { linePartSetLayer = new Layer_M2MPartSetInSpecificLevel(level, positionSet); linePartSetLayer.MainColor = Settings.Default.LinePositionSetInSpecificLevelColor; linePartSetLayer.Alpha = 50; //linePartSetLayer.LineColor = Color.Red; linePartSetLayer.Active = true; layers.Add(linePartSetLayer); positionSetSet = new PositionSetSet(); BottonLevelPositionSetLayer = new Layer_PositionSet_Point(positionSetSet); BottonLevelPositionSetLayer.Point.IsDrawPointBorder = true; BottonLevelPositionSetLayer.Point.PointRadius = 2; BottonLevelPositionSetLayer.Point.PointColor = Settings.Default.BottonLevelPositionSetColor; layers.Add(BottonLevelPositionSetLayer); } else { linePartSetLayer.SpringLayerRepresentationChangedEvent(linePartSetLayer); } positionSetSet.Clear(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { IPart tempPart = level.GetPartRefByPartIndex((int)positionSet.GetPosition().GetX(), (int)positionSet.GetPosition().GetY()); if (tempPart != null) { positionSetSet.AddPositionSet(m2mStructure.GetBottonLevelPositionSetByAncestorPart(( tempPart), levelSequence)); } } BottonLevelPositionSetLayer.SpringLayerRepresentationChangedEvent(BottonLevelPositionSetLayer); } flowControlerForm.BeginInvoke(Update); flowControlerForm.SuspendAndRecordWorkerThread(); }
public static List <IPosition_Connected_Edit> convertPositionSetToList_Integer(IPositionSet set, int width, int height, bool bounded) { List <IPosition_Connected_Edit> all = new List <IPosition_Connected_Edit>(); IPosition position; int x, y; //将点坐标取整,为将地图范围以内的点坐标创建节点 set.InitToTraverseSet(); while (set.NextPosition()) { position = set.GetPosition(); x = (int)position.GetX(); y = (int)position.GetY(); if (!bounded || (x < width && y < height)) { all.Add(new Position_Connected_Edit(x, y)); } } return(all); }
public static List <IPosition_Connected_Edit> convertPositionSetToList(IPositionSet set, int width, int height, bool bounded) { List <IPosition_Connected_Edit> all = new List <IPosition_Connected_Edit>(); IPosition position; float x, y; //为将地图范围以内的点坐标创建节点 set.InitToTraverseSet(); while (set.NextPosition()) { position = set.GetPosition(); x = position.GetX(); y = position.GetY(); if (!bounded || (x <= width - 1 && y <= height - 1)) { all.Add(new Position_Connected_Edit(x, y)); } } return(all); }
public IPosition GetTheNearestPointInPart() { IPositionSet BottonLevelPositionSet = M2MS.GetBottonLevelPositionSetByAncestorPart(currentPart, AncestorLevelSequence); BottonLevelPositionSet.InitToTraverseSet(); while (BottonLevelPositionSet.NextPosition()) { CompareToThePoint(BottonLevelPositionSet.GetPosition()); } //currentPart.OnGetOnePoint = this.CompareToThePoint; //((Part)currentPart).OnGetOnePoint += CompareToThePoint; //((Part)currentPart).TravelAllPointInPart(); //((Part)currentPart).OnGetOnePoint -= CompareToThePoint; return(nearestPointToComparePoint); }
private void ThreadProc(Object o) { IPosition tempPosition; while (true) { Monitor.Enter(positionSet); if (positionSet.NextPosition()) { tempPosition = positionSet.GetPosition(); } else { Monitor.Exit(positionSet); break; } Monitor.Exit(positionSet); Insert(tempPosition); } Interlocked.Increment(ref completeThreadNum); }
protected RectangleF GetMaxRect() { RectangleF rect = new RectangleF(0f, 0f, 0f, 0f); float minX = float.MaxValue; float minY = float.MaxValue; float maxX = float.MinValue; float maxY = float.MinValue; positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { IPosition point = positionSet.GetPosition(); float x = point.GetX() * this.PositionSetScaleX + this.PositionSetTranslationX; if (minX > x) { minX = x; } else if (maxX < x) { maxX = x; } float y = point.GetY() * this.PositionSetScaleY + this.PositionSetTranslationY; if (minY > y) { minY = y; } else if (maxY < y) { maxY = y; } } return(new RectangleF(minX - 10, minY - 10, maxX - minX + 20, maxY - minY + 20)); }
public GetRandomPositionFromPositionSetRectangle(IPositionSet positionSet) { positionSet.InitToTraverseSet(); if (positionSet.NextPosition()) { minX = positionSet.GetPosition().GetX(); minY = positionSet.GetPosition().GetY(); maxX = positionSet.GetPosition().GetX(); maxY = positionSet.GetPosition().GetY(); } while (positionSet.NextPosition()) { if (minX > positionSet.GetPosition().GetX()) { minX = positionSet.GetPosition().GetX(); } else if (maxX < positionSet.GetPosition().GetX()) { maxX = positionSet.GetPosition().GetX(); } if (minY > positionSet.GetPosition().GetY()) { minY = positionSet.GetPosition().GetY(); } else if (maxY < positionSet.GetPosition().GetY()) { maxY = positionSet.GetPosition().GetY(); } } }
override public bool NextPosition() { //if (state == State.ChildPartSubPointNumIsOne) //{ // returnPosition = childPart.GetRandomOneFormDescendantPoint(); // if (childPositionSet.NextPosition()) // { // childPart = (IPart)childPositionSet.GetPosition(); // if (childPart.GetBottomLevelPointNum() != 1) // { // DescendentPositionSetOfChildPart = // new PositionSet_DescendentPosition(DescendantLevelSequence, // childPart, // AncestorLevelSequence + 1, M2MS); // DescendentPositionSetOfChildPart.InitToTraverseSet(); // state = State.None; // } // else // { // state = State.ChildPartSubPointNumIsOne; // state = State.None; // } // } // else // { // DescendentPositionSetOfChildPart = null; // state = State.None; // } // return true; //} if (DescendentPositionSetOfChildPart == null) { //if (state == State.CurrentPartSubPointNumIsOne) //{ // state = State.None; // returnPosition = AncestorPart.GetRandomOneFormDescendantPoint(); // return true; //} return(false); } if (DescendentPositionSetOfChildPart.NextPosition()) { returnPosition = DescendentPositionSetOfChildPart.GetPosition(); return(true); } else { if (childPositionSet == null) { return(false); } if (childPositionSet.NextPosition()) { childPart = (IPart)childPositionSet.GetPosition(); if (true) { if (AncestorLevelSequence >= DescendantLevelSequence - 2) { DescendentPositionSetOfChildPart = M2MS.GetChildPositionSetByParentPart(AncestorLevelSequence, childPart); DescendentPositionSetOfChildPart.InitToTraverseSet(); if (DescendentPositionSetOfChildPart.NextPosition()) { returnPosition = DescendentPositionSetOfChildPart.GetPosition(); return(true); } else { return(false); } } else { DescendentPositionSetOfChildPart = new PositionSet_DescendentPosition(DescendantLevelSequence, childPart, AncestorLevelSequence + 1, M2MS); DescendentPositionSetOfChildPart.InitToTraverseSet(); if (DescendentPositionSetOfChildPart.NextPosition()) { returnPosition = DescendentPositionSetOfChildPart.GetPosition(); return(true); } else { return(false); } } } } else { return(false); } } }
public static void lanch(IConvexHullEngine chEngine, int pointCount, float min, float max) { //求解凸包并作图 //IPositionSet ps = testData(); IPositionSet ps = new RandomPositionSet(pointCount, min, max); //System.Console.Out.WriteLine("position set:"); //printPositionSet(ps); IPositionSet cps = chEngine.ConvexHull(ps); //System.Console.Out.WriteLine("Jarvis Match:"); //printPositionSet(cps); PainterDialog.Clear(); PainterDialog.DrawPositionSet(ps); PainterDialog.DrawConvexHull(cps); PainterDialog.Show(); AnalyzeReport report = new AnalyzeReport(); //测试点集引用 cps.InitToTraverseSet(); ps.InitToTraverseSet(); bool correct = true; while (correct && cps.NextPosition()) { IPosition cp = cps.GetPosition(); bool find = false; ps.InitToTraverseSet(); while (!find && ps.NextPosition()) { IPosition p = ps.GetPosition(); if (cp == p) { find = true; } } if (!find) { correct = false; } } report.content += "引用测试:" + (correct ? "正确" : "错误") + "\n"; //测试凸包 if (correct) { report.content += "凸包正确性测试:\n"; IPositionSet cps_ref = (new QuickHull()).ConvexHull(ps); // System.Console.Out.WriteLine("Quick Hull:"); // printPositionSet(cps_ref); IPosition[] cpa = (IPosition[])(cps.ToArray()); IPosition[] cpa_ref = (IPosition[])(cps_ref.ToArray()); if (cpa.Length != cpa_ref.Length) { report.content += "数目不等"; correct = false; } if (correct) { int n = cpa.Length; int m = 0; int p = 0; for (; p < n; p++) { if (cpa[0] == cpa_ref[p]) { break; } } if (p == n) { correct = false; report.content += "发生错误!"; } if (correct) { for (int i = 0; i < n; i++) { if (cpa[i] == cpa_ref[(p + i + n) % n]) { m++; } } int tm = 0; for (int i = 0; i < n; i++) { if (cpa[i] == cpa_ref[(p - i + n) % n]) { tm++; } } if (tm > m) { m = tm; } report.content += "正确率:" + m.ToString() + "/" + n.ToString(); if (m == n) { report.content += "正确!"; } else { report.content += "不正确!"; } } } } report.Show(); }
override public IPosition GetPosition() { return(positionSet.GetPosition()); }
//求散点集的凸包 public IPositionSet ConvexHull(IPositionSet ps) { IPosition p1 = null; IPosition p2 = null; PositionSetEdit_ImplementByICollectionTemplate rest = new PositionSetEdit_ImplementByICollectionTemplate(); //找到最低点 /* * p1 = pts[0]; * for (int i = 1; i < pts.Length; i++) * { * if (pts[i].Y < p1.Y || ( pts[i].Y == p1.Y && pts[i].X < p1.X) ) * { * rest.Add(p1); * p1 = pts[i]; * } * else * rest.Add(pts[i]); * } * */ ps.InitToTraverseSet(); if (ps.NextPosition()) { p1 = ps.GetPosition(); } while (ps.NextPosition()) { p2 = ps.GetPosition(); if (p2.GetY() < p1.GetY() || (p2.GetY() == p1.GetY() && p2.GetX() < p1.GetX())) { rest.AddPosition(p1); p1 = p2; } else { rest.AddPosition(p2); } } rest.InitToTraverseSet(); //找到与最低点成角最小的点 /* * int p2_i = 0; * double p2_angle = getAngle(rest[0], p1); * for (int i = 1; i < rest.Count; i++) * { * double angle_t = getAngle(rest[i], p1); * if (angle_t < p2_angle || (angle_t == p2_angle && getDistance(p1, rest[i]) > getDistance(p1, rest[p2_i])) ) * { * p2_i = i; * p2_angle = angle_t; * } * } * p2 = rest[p2_i]; * rest.RemoveAt(p2_i); * */ ps = rest; rest = new PositionSetEdit_ImplementByICollectionTemplate(); ps.InitToTraverseSet(); if (ps.NextPosition()) { p2 = ps.GetPosition(); } double p2_angle = getAngle(p2, p1); while (ps.NextPosition()) { IPosition pt = ps.GetPosition(); double angle_t = getAngle(pt, p1); if (angle_t < p2_angle || (angle_t == p2_angle && getDistance(p1, pt) > getDistance(p1, p2))) { rest.AddPosition(p2); p2 = pt; p2_angle = angle_t; } else { rest.AddPosition(pt); } } //求解剩余点 IPositionSet subResult = solveHelp(p1, p2, rest); //组合成凸包 PositionSetEdit_ImplementByICollectionTemplate result = new PositionSetEdit_ImplementByICollectionTemplate(); result.AddPosition(p1); /* * foreach (Point p in subResult) * result.Add(p); * */ subResult.InitToTraverseSet(); while (subResult.NextPosition()) { result.AddPosition(subResult.GetPosition()); } result.AddPosition(p2); return(result); }
//求散点子集的凸包 private IPositionSet solveHelp(IPosition p1, IPosition p2, IPositionSet ps) { //求离p1,p2最远的点 ps.InitToTraverseSet(); if (!ps.NextPosition()) { return(ps); } IPosition p3 = ps.GetPosition(); double p3_h = getH(p1, p2, p3); PositionSetEdit_ImplementByICollectionTemplate rest = new PositionSetEdit_ImplementByICollectionTemplate(); while (ps.NextPosition()) { IPosition pt = ps.GetPosition(); double pt_h = getH(p1, p2, pt); if (pt_h > p3_h) { rest.AddPosition(p3); p3 = pt; p3_h = pt_h; } else { rest.AddPosition(pt); } } //把散点分成几部分 PositionSetEdit_ImplementByICollectionTemplate leftpart = new PositionSetEdit_ImplementByICollectionTemplate(); PositionSetEdit_ImplementByICollectionTemplate rightpart = new PositionSetEdit_ImplementByICollectionTemplate(); PositionSetEdit_ImplementByICollectionTemplate p1set = new PositionSetEdit_ImplementByICollectionTemplate(); PositionSetEdit_ImplementByICollectionTemplate p2set = new PositionSetEdit_ImplementByICollectionTemplate(); ps = rest; IPosition p11 = new Position_Point(2 * p2.GetX() - p1.GetX(), 2 * p2.GetY() - p1.GetY()); //p1关于p2的对称点 double leftangle = getAngle(p1, p2, p3); double rightangle = getAngle(p2, p11, p3); ps.InitToTraverseSet(); while (ps.NextPosition()) { IPosition p = ps.GetPosition(); if (p.GetX() == p1.GetX() && p.GetY() == p1.GetY()) { p1set.AddPosition(p); } else if (p.GetX() == p2.GetX() && p.GetY() == p2.GetY()) { p2set.AddPosition(p); } else if (p.GetX() == p3.GetX() && p.GetY() == p3.GetY()) { leftpart.AddPosition(p); } else { double a = getAngle(p1, p2, p); if (a > leftangle) { leftpart.AddPosition(p); } a = getAngle(p2, p11, p); if (a < rightangle) { rightpart.AddPosition(p); } } } //对子集求解 IPositionSet subResult1 = solveHelp(p1, p3, leftpart); IPositionSet subResult2 = solveHelp(p3, p2, rightpart); //合并各部分解 PositionSetEdit_ImplementByICollectionTemplate result = new PositionSetEdit_ImplementByICollectionTemplate(); p1set.InitToTraverseSet(); while (p1set.NextPosition()) { result.AddPosition(p1set.GetPosition()); } subResult1.InitToTraverseSet(); while (subResult1.NextPosition()) { result.AddPosition(subResult1.GetPosition()); } result.AddPosition(p3); subResult2.InitToTraverseSet(); while (subResult2.NextPosition()) { result.AddPosition(subResult2.GetPosition()); } p2set.InitToTraverseSet(); while (p2set.NextPosition()) { result.AddPosition(p2set.GetPosition()); } return(result); }
private void TestBotton_Click(object sender, EventArgs e) { PainterDialog painterDialog = new PainterDialog(); RandomPositionSet_Connected_Config config = new RandomPositionSet_Connected_Config(); new ConfiguratedByForm(config); IPositionSet_ConnectedEdit pSet = config.Produce(); painterDialog.DrawPositionSet_Connected(pSet); M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2m_Creater_ForGeneralM2MStruture.PartType = typeof(Part_Multi); m2m_Creater_ForGeneralM2MStruture.SetPointInPartFactor(10); m2m_Creater_ForGeneralM2MStruture.SetUnitNumInGridLength(4); IM2MStructure m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pSet); m2mStructure.Preprocessing(pSet); painterDialog.DrawM2MStructure(m2mStructure); BuildPartSetConnectionForM2MStructure buildPartSetConnectionForM2MStructure = new BuildPartSetConnectionForM2MStructure(); buildPartSetConnectionForM2MStructure.GetPartSetInSpecificLevel += delegate(ILevel level, int levelSequence, IPositionSet positionSet) { List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition(); IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet(); foreach (IPart_Connected part in part_ConnectedEnumerable) { position_ConnectedList.Add((IPosition_Connected)part); } } PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList); Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); layer_PositionSet_Connected.SetPositionSetTransformByM2MLevel(level); painterDialog.Layers.Add(layer_PositionSet_Connected); painterDialog.Show(); }; buildPartSetConnectionForM2MStructure.TraversalEveryLevelAndBuild(m2mStructure); for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++) { ILevel level = m2mStructure.GetLevel(levelSequence); IPart rootPart = m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0); IPositionSet positionSet = m2mStructure.GetDescendentPositionSetByAncestorPart(levelSequence, rootPart, 0); List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { if (positionSet.GetPosition() is IPart_Multi) { IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition(); IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet(); foreach (IPart_Connected part in part_ConnectedEnumerable) { position_ConnectedList.Add((IPosition_Connected)part); } } else { position_ConnectedList.Add((IPosition_Connected)positionSet.GetPosition()); } } PositionSet_Connected positionSet_Connected = new PositionSet_Connected(position_ConnectedList); Layer_PositionSet_Connected layer_PartSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); //layer_PartSet_Connected.MainColor //layer_PartSet_Connected.Active = true; layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level); painterDialog.Layers.Add(layer_PartSet_Connected); } painterDialog.Show(); //painterDialog.Show(); }
public void PreProcess(PositionSetEditSet pointList) { #region code for algorithm demo if (GetPositionSetToGetConvexHull != null) { GetPositionSetToGetConvexHull(pointList); } #endregion //请在这里改变不同的m2mStructure实现。 M2MSCreater_ForGeneralM2MStruture m2m_Creater_ForGeneralM2MStruture = new M2MSCreater_ForGeneralM2MStruture(); m2mStructure = m2m_Creater_ForGeneralM2MStruture.CreateAutomatically(pointList, levelNum); PositionSetEdit_ImplementByICollectionTemplate positionSet = new PositionSetEdit_ImplementByICollectionTemplate(); ILevel bottomLevel = m2mStructure.GetLevel(m2mStructure.GetLevelNum() - 1); for (int i = 0; i < pointList.GetPositionSetNum(); i++) { IPosition start = new Position_Point(); IPosition end = new Position_Point(); IPosition first = new Position_Point(); IPositionSet positionListTemp = pointList.GetNthPositionSet(i); positionListTemp.InitToTraverseSet(); if (positionListTemp.NextPosition()) { start = new Position_Point(bottomLevel.ConvertRealValueToRelativeValueX(positionListTemp.GetPosition().GetX()), bottomLevel.ConvertRealValueToRelativeValueY(positionListTemp.GetPosition().GetY())); first = start; positionSet.AddPosition(start); } while (positionListTemp.NextPosition()) { end = new Position_Point(bottomLevel.ConvertRealValueToRelativeValueX(positionListTemp.GetPosition().GetX()), bottomLevel.ConvertRealValueToRelativeValueY(positionListTemp.GetPosition().GetY())); IPositionSet positionSetTemp = writeLineInGridEngine.WriteLineInGrid(bottomLevel.GetGridWidth(), bottomLevel.GetGridHeight(), start, end); if (positionSetTemp != null) { positionSetTemp.InitToTraverseSet(); while (positionSetTemp.NextPosition()) { positionSet.AddPosition(positionSetTemp.GetPosition()); } } start = end; positionSet.AddPosition(start); } IPositionSet positionSetTemp2 = writeLineInGridEngine.WriteLineInGrid(bottomLevel.GetGridWidth(), bottomLevel.GetGridHeight(), end, first); if (positionSetTemp2 != null) { positionSetTemp2.InitToTraverseSet(); while (positionSetTemp2.NextPosition()) { positionSet.AddPosition(positionSetTemp2.GetPosition()); } } } m2mStructure.Preprocessing(positionSet); #region code for algorithm demo if (GetM2MStructure != null) { GetM2MStructure(m2mStructure); } #endregion }
public bool Collide(IPositionSet objPositionSet) { IPosition start = new Position_Point(); IPosition end = new Position_Point(); IPosition first = new Position_Point(); ILevel currentLevel = new Level(); for (int i = 1; i < m2mStructure.GetLevelNum(); i++) { currentLevel = m2mStructure.GetLevel(i); objPositionSet.InitToTraverseSet(); //判断第一点所在的分块是否相交 if (objPositionSet.NextPosition()) { start = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(objPositionSet.GetPosition().GetX()), currentLevel.ConvertRealValueToRelativeValueY(objPositionSet.GetPosition().GetY())); first = start; if (currentLevel.GetPartRefByPoint(start) != null) { if (i < m2mStructure.GetLevelNum() - 1) { goto NextLevel; } else { tempIntersectPositionSet.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(start.GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(start.GetY()))); } } } while (objPositionSet.NextPosition()) { //判断每条边所在的分块是否相交 end = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(objPositionSet.GetPosition().GetX()), currentLevel.ConvertRealValueToRelativeValueY(objPositionSet.GetPosition().GetY())); IPositionSet positionSetTemp = writeLineInGridEngine.WriteLineInGrid(currentLevel.GetGridWidth(), currentLevel.GetGridHeight(), start, end); if (positionSetTemp != null) { positionSetTemp.InitToTraverseSet(); while (positionSetTemp.NextPosition()) { if (currentLevel.GetPartRefByPoint(positionSetTemp.GetPosition()) != null) { if (i < m2mStructure.GetLevelNum() - 1) { goto NextLevel; } else { tempIntersectPositionSet.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(positionSetTemp.GetPosition().GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(positionSetTemp.GetPosition().GetY()))); } } } } //判断每条边的终点所在的分块是否相交 start = end; if (currentLevel.GetPartRefByPoint(start) != null) { if (i < m2mStructure.GetLevelNum() - 1) { goto NextLevel; } else { tempIntersectPositionSet.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(start.GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(start.GetY()))); } } } //判断最后一条边所在的分块是否相交 IPositionSet positionSetTemp2 = writeLineInGridEngine.WriteLineInGrid(currentLevel.GetGridWidth(), currentLevel.GetGridHeight(), end, first); if (positionSetTemp2 != null) { positionSetTemp2.InitToTraverseSet(); while (positionSetTemp2.NextPosition()) { if (currentLevel.GetPartRefByPoint(positionSetTemp2.GetPosition()) != null) { if (i < m2mStructure.GetLevelNum() - 1) { goto NextLevel; } else { tempIntersectPositionSet.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(positionSetTemp2.GetPosition().GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(positionSetTemp2.GetPosition().GetY()))); } } } } if (i == m2mStructure.GetLevelNum() - 1 && tempIntersectPositionSet.GetNum() > 0) { goto NextLevel; } #region code for algorithm demo if (GetNoCollision != null) { GetNoCollision(objPositionSet); Debug.WriteLine(i); } #endregion return(false);//free of collision NextLevel :; } #region code for algorithm demo if (GetCollision != null) { GetCollision(objPositionSet); } if (GetIntersectPart != null) { GetIntersectPart(currentLevel, tempIntersectPositionSet); } #endregion tempIntersectPositionSet.Clear(); return(true); }
public IPositionSet QueryConvexHull() { #region code for algorithm demo if (GetChildPositionSetInSpecificLevelOfConvexHull != null) { GetChildPositionSetInSpecificLevelOfConvexHull(m2mStructure.GetLevel(1), 1, m2mStructure.GetChildPositionSetByParentPart(0, m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0))); } #endregion IPositionSet PositionSetInConvexHull = convexHullEngine.ConvexHull( m2mStructure.GetChildPositionSetByParentPart(0, m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0))); for (int i = 1; i < m2mStructure.GetLevelNum(); i++) { ILevel currentLevel = m2mStructure.GetLevel(i); #region code for algorithm demo if (GetConvexHullPositionSetInSpecificLevel != null) { GetConvexHullPositionSetInSpecificLevel(currentLevel, i, PositionSetInConvexHull); } #endregion tempChildPositionList = new List <IPosition>(); tempChildPositionList.Capacity = 4 * PositionSetInConvexHull.GetNum(); PositionSetInConvexHull.InitToTraverseSet(); IPosition hullStartPoint = null; IPosition temp1 = null; IPosition temp2 = null; if (PositionSetInConvexHull.NextPosition()) { temp1 = PositionSetInConvexHull.GetPosition(); hullStartPoint = temp1; AddChildPositionSetToList(i, temp1); #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { linePositionSetInSpecificLevel = new PositionSetEdit_ImplementByICollectionTemplate(); linePositionSetInSpecificLevel.AddPosition(new Position_Point(temp1.GetX(), temp1.GetY())); } #endregion } #region code for algorithm demo if (GetRepresentativeHullInSpecificLevel != null) { representativeHull = new PositionSetEdit_ImplementByICollectionTemplate(); } #endregion bool isWaitingLastPoint = true; //遍历该层凸包的每个分块,以确定下一层的候选分块 while (true) { if (isWaitingLastPoint) { if (PositionSetInConvexHull.NextPosition() == false) { isWaitingLastPoint = false; temp2 = hullStartPoint; } else { temp2 = PositionSetInConvexHull.GetPosition(); AddChildPositionSetToList(i, temp2); } } else { break; } IPosition start = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(((IPart)temp1).GetRandomOneFormDescendantPoint().GetX()), currentLevel.ConvertRealValueToRelativeValueY(((IPart)temp1).GetRandomOneFormDescendantPoint().GetY())); IPosition end = new Position_Point(currentLevel.ConvertRealValueToRelativeValueX(((IPart)temp2).GetRandomOneFormDescendantPoint().GetX()), currentLevel.ConvertRealValueToRelativeValueY(((IPart)temp2).GetRandomOneFormDescendantPoint().GetY())); IPositionSet tempPositionSet = writeLineInGridEngine.WriteLineInGrid(currentLevel.GetGridWidth(), currentLevel.GetGridHeight(), start, end); #region code for algorithm demo if (GetRepresentativeHullInSpecificLevel != null) { representativeHull.AddPosition(start); representativeHull.AddPosition(end); GetRepresentativeHullInSpecificLevel(m2mStructure.GetLevel(i), i, representativeHull); } #endregion tempPositionSet.InitToTraverseSet(); while (tempPositionSet.NextPosition()) { IPosition tempPosition = tempPositionSet.GetPosition(); IPart tempPart = currentLevel.GetPartRefByPartIndex(currentLevel.ConvertRelativeValueToPartSequenceX(tempPosition.GetX()), currentLevel.ConvertRelativeValueToPartSequenceY(tempPosition.GetY())); #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { linePositionSetInSpecificLevel.AddPosition(new Position_Point(currentLevel.ConvertRelativeValueToPartSequenceX(tempPosition.GetX()) , currentLevel.ConvertRelativeValueToPartSequenceY(tempPosition.GetY()))); } #endregion if (tempPart != null) { AddChildPositionSetToList(i, tempPart); } } #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { if (isWaitingLastPoint) { linePositionSetInSpecificLevel.AddPosition(new Position_Point(temp2.GetX(), temp2.GetY())); } } #endregion #region code for algorithm demo if (GetLinePositionSetInSpecificLevel != null) { GetLinePositionSetInSpecificLevel(m2mStructure.GetLevel(i), i, linePositionSetInSpecificLevel); } #endregion temp1 = temp2; } IPositionSet ChildPositionSetInConvexHull = new PositionSetEdit_ImplementByICollectionTemplate(tempChildPositionList); #region code for algorithm demo if (GetChildPositionSetInSpecificLevelOfConvexHull != null) { if (i < m2mStructure.GetLevelNum() - 1) { GetChildPositionSetInSpecificLevelOfConvexHull(m2mStructure.GetLevel(i + 1), i + 1, ChildPositionSetInConvexHull); } } #endregion PositionSetInConvexHull = convexHullEngine.ConvexHull(ChildPositionSetInConvexHull); } #region code for algorithm demo if (GetRealConvexHull != null) { GetRealConvexHull(PositionSetInConvexHull); } #endregion return(PositionSetInConvexHull); }
public M2MStructure_General CreateAutomatically(IPositionSet positionSet, int level) { int PointNum = 0; float leftestX = 0; float rightestX = 0; float lowestY = 0; float highestY = 0; positionSet.InitToTraverseSet(); if (positionSet.NextPosition()) { leftestX = positionSet.GetPosition().GetX(); rightestX = positionSet.GetPosition().GetX(); lowestY = positionSet.GetPosition().GetY(); highestY = positionSet.GetPosition().GetY(); PointNum++; } while (positionSet.NextPosition()) { if (positionSet.GetPosition().GetX() > rightestX) { rightestX = positionSet.GetPosition().GetX(); } else if (positionSet.GetPosition().GetX() < leftestX) { leftestX = positionSet.GetPosition().GetX(); } if (positionSet.GetPosition().GetY() > highestY) { highestY = positionSet.GetPosition().GetY(); } else if (positionSet.GetPosition().GetY() < lowestY) { lowestY = positionSet.GetPosition().GetY(); } PointNum++; } if (PointNum == 0) { throw new Exception("PointNum == 0"); } float mapWidth = (rightestX - leftestX) * set_Bias; float mapHeight = (highestY - lowestY) * set_Bias; int MicPartNumInMacPart = set_UnitNumInGridLength * set_UnitNumInGridLength; float maxGridLength; if (mapWidth > mapHeight) { maxGridLength = mapHeight / set_UnitNumInGridLength + float.Epsilon; } else { maxGridLength = mapWidth / set_UnitNumInGridLength + float.Epsilon; } Init(leftestX, lowestY, mapWidth, mapHeight, maxGridLength, set_UnitNumInGridLength, level); return(Create()); }
private void pathFindingToolStripMenuItem_Click(object sender, EventArgs e) { IPositionSet_Connected positionSet_Connected = (IPositionSet_Connected)positionSetContainer.GetPositionSet(); Dijkstra dijkstra = new Dijkstra(); AStar astar = new AStar(); M2M_PF m2m_PF = new M2M_PF(); IM2MStructure m2mStructure = null; List <IPosition_Connected> m2mPath = null; List <IPosition_Connected> path = null; //计算算法运行时间用 //IPosition_Connected start = null; //IPosition_Connected end = null; ISearchPathEngine searchPathEngine1 = m2m_PF; ISearchPathEngine searchPathEngine2 = dijkstra; m2m_PF.GetM2MStructure += delegate(IM2MStructure m2mS) { m2mStructure = m2mS; }; m2m_PF.GetM2MStructureInPreprocess += delegate(IM2MStructure m2mS) { m2mStructure = m2mS; }; List <ushort> timeStampList = new List <ushort>(); m2m_PF.GetTimeStamp += delegate(ushort timeStamp) { timeStampList.Add(timeStamp); }; searchPathEngine1.InitEngineForMap(positionSet_Connected); searchPathEngine2.InitEngineForMap(positionSet_Connected); //以下代码必须在UI线程中调用,即不能在另开的线程中调用 LayersExOptDlg layers = new LayersExOptDlg(); LayersPainterForm layersPainterForm = new LayersPainterForm(layers); LayersPaintedControl layersPaintedControl = layersPainterForm.LayersPaintedControl; LayersEditedControl layersEditedControl = new LayersEditedControl(); layersEditedControl.Dock = DockStyle.Top; layersEditedControl.LayersPaintedControl = layersPaintedControl; layersPainterForm.Controls.Add(layersEditedControl); layersPainterForm.Show(); //打开一个Worker线程来进行算法流程的演示(否则会阻塞UI线程以至于演示不能进行) IAsyncResult result = new dDemoProcess(delegate { Layer_PositionSet_Connected layer_PositionSet_Connected = new Layer_PositionSet_Connected(positionSet_Connected); layer_PositionSet_Connected.Point.PointColor = Color.Yellow; layer_PositionSet_Connected.Connection.LineColor = Color.Blue; layer_PositionSet_Connected.Connection.LineWidth = 0.6f; layer_PositionSet_Connected.Point.PointRadius = 1.2f; layers.Add(layer_PositionSet_Connected); layer_PositionSet_Connected.SpringLayerRepresentationChangedEvent(layer_PositionSet_Connected); for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++) { Layer_PartSet_Connected layer_PartSet_Connected = new Layer_PartSet_Connected(m2mStructure, levelSequence); layer_PartSet_Connected.Visible = false; layers.Add(layer_PartSet_Connected); } while (true) { IPosition_Connected start = (IPosition_Connected)layersEditedControl.GetMouseDoubleChickedNearestPositionInCurrentPositionSet(positionSet_Connected); PositionSet_ConnectedEdit startPointSet = new PositionSet_ConnectedEdit(); startPointSet.AddPosition_Connected(start); Layer_PositionSet_Point layerStartPoint = new Layer_PositionSet_Point(startPointSet); layerStartPoint.Active = true; layerStartPoint.Point.IsDrawPointBorder = true; layerStartPoint.Point.PointRadius = 5; layerStartPoint.Point.PointColor = Color.PaleGreen; layers.Add(layerStartPoint); layerStartPoint.SpringLayerRepresentationChangedEvent(layerStartPoint); IPosition_Connected end = (IPosition_Connected)layersEditedControl.GetMouseDoubleChickedNearestPositionInCurrentPositionSet(positionSet_Connected); PositionSet_ConnectedEdit endPointSet = new PositionSet_ConnectedEdit(); endPointSet.AddPosition_Connected(end); Layer_PositionSet_Point layerEndPoint = new Layer_PositionSet_Point(endPointSet); layerEndPoint.Active = true; layerEndPoint.Point.IsDrawPointBorder = true; layerEndPoint.Point.PointRadius = 5; layerEndPoint.Point.PointColor = Color.Cyan; layers.Add(layerEndPoint); layerEndPoint.SpringLayerRepresentationChangedEvent(layerEndPoint); CountTimeTool.TimeCounter timeCounter = new CountTimeTool.TimeCounter(); searchPathEngine2.InitEngineForMap(positionSet_Connected); double time2 = timeCounter.CountTimeForRepeatableMethod(delegate { searchPathEngine2.SearchPath(start, end); }); path = searchPathEngine2.SearchPath(start, end); float pathLength2 = ((Dijkstra)searchPathEngine2).GetPathLength(); Console.WriteLine("Dijkstra consume time: " + time2 + " path Length = " + pathLength2); searchPathEngine1.InitEngineForMap(positionSet_Connected); //清空timeStampList以记录寻径过程各层的timeStamp double time1 = timeCounter.CountTimeForRepeatableMethod(delegate { searchPathEngine1.SearchPath(start, end); }); timeStampList.Clear(); m2mPath = searchPathEngine1.SearchPath(start, end); float pathLength1 = ((M2M_PF)searchPathEngine1).GetPathLength(); Console.WriteLine("M2M_PF consume time: " + time1 + " path Length = " + pathLength1); //searchPathEngine1.SearchPath(start, end); if (searchPathEngine1 is M2M_PF && m2mStructure != null) { for (int levelSequence = 1; levelSequence < m2mStructure.GetLevelNum(); levelSequence++) { ILevel level = m2mStructure.GetLevel(levelSequence); IPart rootPart = m2mStructure.GetLevel(0).GetPartRefByPartIndex(0, 0); IPositionSet positionSet = m2mStructure.GetDescendentPositionSetByAncestorPart(levelSequence, rootPart, 0); List <IPosition_Connected> position_ConnectedList = new List <IPosition_Connected>(); positionSet.InitToTraverseSet(); while (positionSet.NextPosition()) { if (positionSet.GetPosition() is IPart_Multi) { IPart_Multi partMulti = (IPart_Multi)positionSet.GetPosition(); IEnumerable <IPart_Connected> part_ConnectedEnumerable = partMulti.GetSubPartSet(); foreach (IPart_Connected part in part_ConnectedEnumerable) { IPosition_Connected tempPartConnected = (IPosition_Connected)part; if (((Tag_M2M_Part)tempPartConnected.GetAttachment()).isNeedToSearch == true) { if (timeStampList[levelSequence - 1] == ((Tag_M2M_Part)tempPartConnected.GetAttachment()).timeStamp) { position_ConnectedList.Add(tempPartConnected); } } } } else { IPosition_Connected tempPartConnected = (IPosition_Connected)positionSet.GetPosition(); if (((Tag_M2M_Part)tempPartConnected.GetAttachment()).isNeedToSearch == true) { if (timeStampList[levelSequence - 1] == ((Tag_M2M_Part)tempPartConnected.GetAttachment()).timeStamp) { position_ConnectedList.Add(tempPartConnected); } } } } IPositionSet partSet = new PositionSet_Connected(position_ConnectedList); Layer_M2MPartSetInSpecificLevel layer_M2MPartSetInSpecificLevel = new Layer_M2MPartSetInSpecificLevel(m2mStructure.GetLevel(levelSequence), partSet); layer_M2MPartSetInSpecificLevel.Active = true; layer_M2MPartSetInSpecificLevel.Alpha = 100; //layer_M2MPartSetInSpecificLevel. layers.Add(layer_M2MPartSetInSpecificLevel); //PositionSet_Connected partSet_Connected = new PositionSet_Connected(position_ConnectedList); //Layer_PositionSet_Connected layer_PartSet_Connected = new Layer_PositionSet_Connected(partSet_Connected); ////layer_PartSet_Connected.MainColor ////layer_PartSet_Connected.Active = true; //layer_PartSet_Connected.SetPositionSetTransformByM2MLevel(level); //layers.Add(layer_PartSet_Connected); } } if (path != null) { Layer_PositionSet_Path layer = new Layer_PositionSet_Path(new PositionSet_Connected(path)); layer.Active = true; layer.PathLine.LineColor = Color.Black; layer.PathLine.LineWidth = 2; layer.PathPoint.PointRadius = 2; layer.PathPoint.IsDrawPointBorder = true; //layer.EditAble = true; //layer.Point.PointColor = Color.Yellow; //layer.Point.PointRadius = 2; //layer.Point.IsDrawPointBorder = true; layers.Add(layer); layer.SpringLayerRepresentationChangedEvent(layer); } else { this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "There is no path between two node" }); } if (m2mPath != null) { Layer_PositionSet_Path layer = new Layer_PositionSet_Path(new PositionSet_Connected(m2mPath)); layer.Active = true; layer.PathLine.LineColor = Color.Red; layer.PathLine.LineWidth = 2; layer.PathPoint.PointRadius = 2; layer.PathPoint.IsDrawPointBorder = true; //layer.EditAble = true; //layer.Point.PointColor = Color.Yellow; //layer.Point.PointRadius = 2; //layer.Point.IsDrawPointBorder = true; layers.Add(layer); layer.SpringLayerRepresentationChangedEvent(layer); } else { this.BeginInvoke(new dShow(MessageBox.Show), new object[] { "There is no path between two node by M2M_PF" }); } } }).BeginInvoke(null, null); }