Пример #1
0
 public static bool CheckIfSegmentIntersectTwoPointsFromAnInternalShape(Segment s)
 {
     for (var i = 1; i < ListOfPolygons.Count; i++)
     {
         var lp = GetAllPolygonPoints(ListOfPolygons[i]);
         if (lp.Contains(s.A) && lp.Contains(s.B))
         {
             if (!SegmentsManager.CheckIfSegmentAlreadyExists(s))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #2
0
        private void b3_Click(object sender, EventArgs e)
        {
            try
            {
                _id        = "b3";
                b3.Checked = true;
                b1.Checked = false;
                b2.Checked = false;
                b4.Checked = false;
                b5.Checked = false;

                if (_spDefined && _epDefined)
                {
                    PolygonManager.ListOfPolygons = _polygons;
                    SegmentsManager.Segments      = PolygonManager.GetAllPolygonsSegments();
                    var allPoints = PolygonManager.GetAllPoints();
                    for (var i = 0; i < allPoints.Count; i++)
                    {
                        for (var j = 0; j < allPoints.Count; j++)
                        {
                            if (i != j)
                            {
                                var s = new Segment(allPoints[i], allPoints[j]);
                                if (!SegmentsManager.CheckIfSegmentAlreadyExists(s) &&
                                    IntersectieManager.CheckIfASegmentIntersectsAnotherSegment(s) &&
                                    !PolygonManager.CheckIfSegmentIntersectTwoPointsFromAnInternalShape(s))
                                {
                                    _g.DrawLine(new Pen(Color.Black), allPoints[i], allPoints[j]);
                                    SegmentsManager.Segments.Add(s);
                                }
                            }
                        }
                    }
                    DefineTriangles();
                    CreateGraph();
                    FindTheShortestPath();
                }
                else
                {
                    MessageBox.Show(@"StartPoint and EndPoint are not defined!");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }