コード例 #1
0
        private static List <Vector4> MergePolygon(EarPolygon poly)
        {
            List <Vector4> connects = new List <Vector4>();

            if (poly.NumChildren() > 0)
            {
                List <EarPolygon> children = poly.GetChildren();
                List <KeyValuePair <int, float> > order = ChildOrder(children);
                KeyValuePair <LinkedListNode <EarPoint>, LinkedListNode <EarPoint> > connection;
                LinkedListNode <EarPoint> temp;
                for (int i = 0; i < order.Count; i++)
                {
                    connection = GetSplit(poly, children[order[i].Key], order[i].Value);
                    connects.Add(new Vector4(connection.Key.Value[0], connection.Key.Value[1], connection.Value.Value[0], connection.Value.Value[1]));
                    LinkedListNode <EarPoint> newP = poly.InsertPoint(connection.Key.Value[0], connection.Key.Value[1], connection.Value);
                    temp = connection.Key;
                    do
                    {
                        temp = children[order[i].Key].Next(temp);
                        newP = poly.InsertPoint(temp.Value[0], temp.Value[1], newP);
                    } while (temp.Value != connection.Key.Value);
                    newP = poly.InsertPoint(connection.Value.Value[0], connection.Value.Value[1], newP);
                }
            }
            return(connects);
        }
コード例 #2
0
 private static void OrientatePolygon(EarPolygon poly)
 {
     poly.CalculateArea();
     if (!poly.IsCCW())
     {
         poly.Reverse(-1);
     }
     for (int i = 0; i < poly.NumChildren(); i++)
     {
         poly[i].CalculateArea();
         if (poly[i].IsCCW())
         {
             poly[i].Reverse(-1);
         }
     }
 }