Exemplo n.º 1
0
Arquivo: Form1.cs Projeto: am1guma/BR
 private void DefineTriangles()
 {
     TriangleManager.Triangles = new List <Triangle>();
     NodManager.Noduri         = new List <Nod>();
     DrumManager.Drumuri       = new List <Drum>();
     foreach (var s in SegmentsManager.Segments)
     {
         var listFirstSegments  = SegmentsManager.GetSegmentsThatContainsASpecificPoint(s.A);
         var listSecondSegments = SegmentsManager.GetSegmentsThatContainsASpecificPoint(s.B);
         listFirstSegments.Remove(s);
         listSecondSegments.Remove(s);
         for (var i = 0; i < listFirstSegments.Count; i++)
         {
             var a = listFirstSegments[i].GetTheOtherPoint(s.A);
             for (var j = 0; j < listSecondSegments.Count; j++)
             {
                 var b = listSecondSegments[j].GetTheOtherPoint(s.B);
                 if (a.Equals(b))
                 {
                     var t = new Triangle(s.A, s.B, a);
                     if (!TriangleManager.CheckIfPointIsInsideTriangle(t) && !PolygonManager.CheckIfTriangleIsAShape(t))
                     {
                         if (TriangleManager.Triangles.Count > 0)
                         {
                             if (!TriangleManager.CheckIfTriangleAlreadyExists(t))
                             {
                                 TriangleManager.Triangles.Add(t);
                             }
                         }
                         else
                         {
                             TriangleManager.Triangles.Add(t);
                         }
                     }
                 }
             }
         }
     }
     foreach (var p in TriangleManager.Triangles.Select(tr => tr.GetGravityCenter()))
     {
         var n = new Nod(Id, p);
         if (NodManager.Noduri.Count > 0)
         {
             if (!NodManager.CheckIfNodExists(n))
             {
                 _g.FillEllipse(new SolidBrush(Color.Blue), p.X - 6, p.Y - 6, 12, 12);
                 NodManager.Noduri.Add(n);
                 Id++;
             }
         }
         else
         {
             _g.FillEllipse(new SolidBrush(Color.Blue), p.X - 6, p.Y - 6, 12, 12);
             NodManager.Noduri.Add(n);
             Id++;
         }
     }
 }
Exemplo n.º 2
0
 public static List<Nod> CheckWehereANodCanGo(Nod n)
 {
     var returnList = new List<Nod>();
     foreach (var nod in Noduri)
     {
         if (!n.P.Equals(nod.P) && DrumManager.CheckIfDrumExists(new Drum(n, nod, new Segment(n.P, nod.P).GetLength())))
         {
             returnList.Add(nod);
         }
     }
     return returnList;
 }
Exemplo n.º 3
0
        public static List <Nod> CheckWehereANodCanGo(Nod n)
        {
            var returnList = new List <Nod>();

            foreach (var nod in Noduri)
            {
                if (!n.P.Equals(nod.P) && DrumManager.CheckIfDrumExists(new Drum(n, nod, new Segment(n.P, nod.P).GetLength())))
                {
                    returnList.Add(nod);
                }
            }
            return(returnList);
        }
Exemplo n.º 4
0
Arquivo: Form1.cs Projeto: am1guma/BR
        private void CreateGraph()
        {
            foreach (var t in TriangleManager.Triangles)
            {
                var mainT = t;
                var a     = mainT.GetGravityCenter();
                var trianglesNextToMaintT = TriangleManager.GetAllTrianglesNextToMainTriangle(mainT);
                foreach (var tr in trianglesNextToMaintT)
                {
                    var b   = tr.GetGravityCenter();
                    var seg = TriangleManager.GetCommonSegmentFromTwoTriangles(t, tr);
                    if (IntersectieManager.CheckIfTwoPointsIntersectOnlyASpecificSegment(a, b, seg))
                    {
                        Drum d = new Drum(NodManager.GetNod(a), NodManager.GetNod(b), new Segment(a, b).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d))
                        {
                            _g.DrawLine(new Pen(Color.Blue), a, b);
                            DrumManager.Drumuri.Add(d);
                        }
                    }

                    else if (IntersectieManager.CheckIfTwoPointsIntersectAShape(a, b))
                    {
                        var n = new Nod(Id, seg.GetTheMiddlePoint());
                        if (!NodManager.CheckIfNodExists(n))
                        {
                            _g.FillEllipse(new SolidBrush(Color.Blue), seg.GetTheMiddlePoint().X - 6, seg.GetTheMiddlePoint().Y - 6, 12, 12);
                            NodManager.Noduri.Add(n);
                            Id++;
                        }

                        Drum d1 = new Drum(NodManager.GetNod(a), NodManager.GetNod(seg.GetTheMiddlePoint()),
                                           new Segment(a, seg.GetTheMiddlePoint()).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d1))
                        {
                            _g.DrawLine(new Pen(Color.Blue), a, seg.GetTheMiddlePoint());
                            DrumManager.Drumuri.Add(d1);
                        }

                        Drum d2 = new Drum(NodManager.GetNod(seg.GetTheMiddlePoint()), NodManager.GetNod(b),
                                           new Segment(seg.GetTheMiddlePoint(), b).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d2))
                        {
                            _g.DrawLine(new Pen(Color.Blue), seg.GetTheMiddlePoint(), b);
                            DrumManager.Drumuri.Add(d2);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
Arquivo: Form1.cs Projeto: am1guma/BR
 private void DefineTriangles()
 {
     TriangleManager.Triangles = new List<Triangle>();
     NodManager.Noduri = new List<Nod>();
     DrumManager.Drumuri = new List<Drum>();
     foreach (var s in SegmentsManager.Segments)
     {
         var listFirstSegments = SegmentsManager.GetSegmentsThatContainsASpecificPoint(s.A);
         var listSecondSegments = SegmentsManager.GetSegmentsThatContainsASpecificPoint(s.B);
         listFirstSegments.Remove(s);
         listSecondSegments.Remove(s);
         for (var i = 0; i < listFirstSegments.Count; i++)
         {
             var a = listFirstSegments[i].GetTheOtherPoint(s.A);
             for (var j = 0; j < listSecondSegments.Count; j++)
             {
                 var b = listSecondSegments[j].GetTheOtherPoint(s.B);
                 if (a.Equals(b))
                 {
                     var t = new Triangle(s.A, s.B, a);
                     if (!TriangleManager.CheckIfPointIsInsideTriangle(t) && !PolygonManager.CheckIfTriangleIsAShape(t))
                     {
                         if (TriangleManager.Triangles.Count > 0)
                         {
                             if(!TriangleManager.CheckIfTriangleAlreadyExists(t))
                                 TriangleManager.Triangles.Add(t);
                         }
                         else
                         {
                             TriangleManager.Triangles.Add(t);
                         }
                     }
                 }
             }
         }
     }
     foreach (var p in TriangleManager.Triangles.Select(tr => tr.GetGravityCenter()))
     {
         var n = new Nod(Id, p);
         if (NodManager.Noduri.Count > 0)
         {
             if (!NodManager.CheckIfNodExists(n))
             {
                 _g.FillEllipse(new SolidBrush(Color.Blue), p.X - 6, p.Y - 6, 12, 12);
                 NodManager.Noduri.Add(n);
                 Id++;
             }
         }
         else
         {
             _g.FillEllipse(new SolidBrush(Color.Blue), p.X - 6, p.Y - 6, 12, 12);
             NodManager.Noduri.Add(n);
             Id++;
         }
     }
 }
Exemplo n.º 6
0
Arquivo: Form1.cs Projeto: am1guma/BR
        private void CreateGraph()
        {
            foreach (var t in TriangleManager.Triangles)
            {
                var mainT = t;
                var a = mainT.GetGravityCenter();
                var trianglesNextToMaintT = TriangleManager.GetAllTrianglesNextToMainTriangle(mainT);
                foreach (var tr in trianglesNextToMaintT)
                {
                    var b = tr.GetGravityCenter();
                    var seg = TriangleManager.GetCommonSegmentFromTwoTriangles(t, tr);
                    if (IntersectieManager.CheckIfTwoPointsIntersectOnlyASpecificSegment(a, b, seg))
                    {

                        Drum d = new Drum(NodManager.GetNod(a), NodManager.GetNod(b), new Segment(a, b).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d))
                        {
                            _g.DrawLine(new Pen(Color.Blue), a, b);
                            DrumManager.Drumuri.Add(d);
                        }
                    }

                    else if (IntersectieManager.CheckIfTwoPointsIntersectAShape(a,b))
                    {
                        var n = new Nod(Id, seg.GetTheMiddlePoint());
                        if (!NodManager.CheckIfNodExists(n))
                        {
                            _g.FillEllipse(new SolidBrush(Color.Blue), seg.GetTheMiddlePoint().X - 6, seg.GetTheMiddlePoint().Y - 6, 12, 12);
                            NodManager.Noduri.Add(n);
                            Id++;
                        }

                        Drum d1 = new Drum(NodManager.GetNod(a), NodManager.GetNod(seg.GetTheMiddlePoint()),
                            new Segment(a, seg.GetTheMiddlePoint()).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d1))
                        {
                            _g.DrawLine(new Pen(Color.Blue), a, seg.GetTheMiddlePoint());
                            DrumManager.Drumuri.Add(d1);
                        }

                        Drum d2 = new Drum(NodManager.GetNod(seg.GetTheMiddlePoint()), NodManager.GetNod(b),
                            new Segment(seg.GetTheMiddlePoint(), b).GetLength());
                        if (!DrumManager.CheckIfDrumExists(d2))
                        {
                            _g.DrawLine(new Pen(Color.Blue), seg.GetTheMiddlePoint(), b);
                            DrumManager.Drumuri.Add(d2);
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
 public static bool CheckIfNodExists(Nod d)
 {
     return Noduri.Any(n => n.P.Equals(d.P));
 }
Exemplo n.º 8
0
 public Drum(Nod nod1, Nod nod2, double distanta)
 {
     Nod1     = nod1;
     Nod2     = nod2;
     Distanta = distanta;
 }
Exemplo n.º 9
0
Arquivo: Drum.cs Projeto: am1guma/BR
 public Drum(Nod nod1, Nod nod2, double distanta)
 {
     Nod1 = nod1;
     Nod2 = nod2;
     Distanta = distanta;
 }
Exemplo n.º 10
0
 public static bool CheckIfNodExists(Nod d)
 {
     return(Noduri.Any(n => n.P.Equals(d.P)));
 }