Beispiel #1
0
        public void Initialize(List <PointF[]> polygons)
        {
            this.PolygonEdges = new List <PolygonEdge>();

            foreach (var polygon in polygons)
            {
                // Our polygon will be added to each edge
                CompositionPolygon compPolygon = new CompositionPolygon(polygon);

                // Process all edges of the polygon
                for (int p = polygon.Length - 1, q = 0; q < polygon.Length; p = q++)
                {
                    PointF P = polygon[p];
                    PointF Q = polygon[q];

                    // The clockwise edge may already exist if it was added by an earlier polygon as the counter-clockwise edge
                    // If so, add this polygon as the CW partner of that edge
                    PolygonEdge edge = this.PolygonEdges.FirstOrDefault(e => e.P == Q && e.Q == P);
                    if (edge != null)
                    {
                        // Add ourselves as the Minor/CW partner
                        edge.AssignMinorPartner(compPolygon);
                        compPolygon.AddEdge(edge);
                    }
                    else
                    {
                        // If this edge is new to the collection then add it with this polygon being the CCW partner
                        PolygonEdge newEdge = new PolygonEdge(compPolygon, p);
                        compPolygon.AddEdge(newEdge);
                        this.PolygonEdges.Add(newEdge);
                    }
                }
            }
        }
        public void Initialize(List <PointF[]> polygons)
        {
            PolygonEdges = new List <PolygonEdge>();
            int num = 0;

            foreach (PointF[] polygon in polygons)
            {
                CompositionPolygon compositionPolygon = new CompositionPolygon(polygon, num++);
                int num3 = polygon.Length - 1;
                int num4 = 0;
                while (num4 < polygon.Length)
                {
                    PointF      P           = polygon[num3];
                    PointF      Q           = polygon[num4];
                    PolygonEdge polygonEdge = PolygonEdges.FirstOrDefault(delegate(PolygonEdge e)
                    {
                        if (e.P == Q)
                        {
                            return(e.Q == P);
                        }
                        return(false);
                    });
                    if (polygonEdge != null)
                    {
                        polygonEdge.AssignMinorPartner(compositionPolygon);
                        compositionPolygon.AddEdge(polygonEdge);
                    }
                    else
                    {
                        PolygonEdge polygonEdge2 = new PolygonEdge(compositionPolygon, num3);
                        compositionPolygon.AddEdge(polygonEdge2);
                        PolygonEdges.Add(polygonEdge2);
                    }
                    num3 = num4++;
                }
            }
        }