Example #1
0
File: Form1.cs Project: 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);
                        }
                    }
                }
            }
        }