예제 #1
0
파일: DrumManager.cs 프로젝트: am1guma/BR
 public static bool CheckIfDrumExists(Drum d)
 {
     foreach (var dr in Drumuri)
     {
         if (((d.Nod1.P.Equals(dr.Nod1.P)) || (d.Nod1.P.Equals(dr.Nod2.P))) &&
             ((d.Nod2.P.Equals(dr.Nod1.P)) || (d.Nod2.P.Equals(dr.Nod2.P))))
             return true;
     }
     return false;
 }
예제 #2
0
 public static bool CheckIfDrumExists(Drum d)
 {
     foreach (var dr in Drumuri)
     {
         if (((d.Nod1.P.Equals(dr.Nod1.P)) || (d.Nod1.P.Equals(dr.Nod2.P))) &&
             ((d.Nod2.P.Equals(dr.Nod1.P)) || (d.Nod2.P.Equals(dr.Nod2.P))))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
파일: Form1.cs 프로젝트: 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);
                        }
                    }
                }
            }
        }
예제 #4
0
파일: Form1.cs 프로젝트: 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);
                        }
                    }
                }
            }
        }