Exemple #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);
                    }
                }
            }
        }
Exemple #2
0
 public void UpdateEdgeIndices(PolygonEdge ignoreEdge)
 {
     foreach (PolygonEdge edge in Edges)
     {
         if (edge != ignoreEdge)
         {
             edge.UpdateIndices(this);
         }
     }
 }
Exemple #3
0
        public void UpdateEdgeIndices(PolygonEdge ignoreEdge)
        {
            // All of our edges need to update their indices to us
            foreach (var edge in this.Edges)
            {
                if (edge == ignoreEdge)
                {
                    continue;
                }

                edge.UpdateIndices(this);
            }
        }
Exemple #4
0
 public void ReplaceEdgesWithPolygon(CompositionPolygon replacement, PolygonEdge ignoreEdge)
 {
     foreach (PolygonEdge edge in Edges)
     {
         if (edge != ignoreEdge)
         {
             if (edge.MajorPartner == this)
             {
                 edge.ReplaceMajor(replacement);
             }
             else if (edge.MinorPartner == this)
             {
                 edge.ReplaceMinor(replacement);
             }
         }
     }
 }
Exemple #5
0
        public void ReplaceEdgesWithPolygon(CompositionPolygon replacement, PolygonEdge ignoreEdge)
        {
            // This polygon is going away as it was merged with another
            // All edges this polygon referenced will need to reference the replacement instead
            foreach (var edge in this.Edges)
            {
                if (edge == ignoreEdge)
                {
                    continue;
                }

                Debug.Assert(!(edge.MajorPartner == this && edge.MinorPartner == this));

                if (edge.MajorPartner == this)
                {
                    edge.ReplaceMajor(replacement);
                }
                else if (edge.MinorPartner == this)
                {
                    edge.ReplaceMinor(replacement);
                }
            }
        }
        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++;
                }
            }
        }
Exemple #7
0
 public void AddEdge(PolygonEdge edge)
 {
     this.Edges.Add(edge);
 }