Exemple #1
0
        public MyPolygon CopyWithoutDrawing()
        {
            List <MyPoint> verticleList = new List <MyPoint>();
            MyPolygon      p            = new MyPolygon();

            p.Edges = new List <MyEdge>();
            //add to verticleList
            foreach (var edge in Edges)
            {
                verticleList.Add(edge.first.CopyWithoutDrawing());
            }
            //create edges list from verticleList
            for (int i = 0; i < verticleList.Count; i++)
            {
                var edge = new MyEdge(verticleList[i], verticleList[(i + 1) % verticleList.Count]);
                p.Edges.Add(edge);
            }

            //copying relations
            for (int i = 0; i < Edges.Count; i++)
            {
                p.Edges[i].relationType = Edges[i].relationType;
                if (Edges[i].relationType != RelationType.None)
                {
                    var index = Edges.FindIndex(x => Object.ReferenceEquals(x, Edges[i].relationEdge) == true);
                    p.Edges[i].relationEdge = p.Edges[index];
                }
            }
            return(p);
        }
Exemple #2
0
        public void AddVertexOnLine(Edge e)
        {
            Vertex newVertex = new Vertex(e.GetMiddlePoint());
            Edge   newEdge   = new Edge(e.Vertices[0], newVertex);
            int    index     = Edges.FindIndex(x => x.Vertices[0].Equals(e.Vertices[0]) && x.Vertices[1].Equals(e.Vertices[1]));

            Edges.Insert(index + 1, newEdge);
            index = Edges.FindIndex(x => x.Vertices[1].Equals(e.Vertices[1]));
            Edges[index].Vertices[0] = newVertex;
        }