Exemple #1
0
 public int Cut(PolygonSide a, PolygonSide b, out List <MPolygon> newPolys, int vertexCount)
 {
     if (!a.SameAs(b))
     {
         var newV1 = vertexCount;
         var newV2 = vertexCount + 1;
         var part1 = new List <int> ();
         var part2 = new List <int> ();
         var part3 = new List <int> ();
         if (contains(a.Reversed()))
         {
             a.Reverse();
         }
         if (contains(b.Reversed()))
         {
             b.Reverse();
         }
         List <int> side1 = GetSideWalk(a.right, b.left);
         side1.Add(newV1);
         side1.Add(newV2);
         List <int> side2 = GetSideWalk(b.right, a.left);
         side2.Add(newV2);
         side2.Add(newV1);
         newPolys = new List <MPolygon> ();
         newPolys.Add(new MPolygon(side1));
         newPolys.Add(new MPolygon(side2));
         return(2);
     }
     newPolys = null;
     return(-1);
 }
Exemple #2
0
 public bool ContainsEdge(PolygonSide pairEntry, Dictionary <PolygonSide, int> replacedNeighbors)
 {
     if (!replacedNeighbors.ContainsKey(pairEntry))
     {
         return(contains(pairEntry) || contains(pairEntry.Reversed()));
     }
     else
     {
         var neighbor = replacedNeighbors[pairEntry];
         var pair1    = new PolygonSide(pairEntry.left, neighbor);
         var pair2    = new PolygonSide(pairEntry.right, neighbor);
         return(contains(pair1) || contains(pair1.Reversed()) || contains(pair2) || contains(pair2.Reversed()));
     }
 }
Exemple #3
0
 public int Cut(PolygonSide a, int corner, out List <MPolygon> newPolys, int vertexCount)
 {
     // Debug.Log ("Check if not contain corner");
     if (!a.Contains(corner))
     {
         // Debug.Log ("Does not contain corner");
         var newV1 = vertexCount;
         if (contains(a.Reversed()))
         {
             a.Reverse();
         }
         List <int> side1 = GetSideWalk(corner, a.left);
         side1.Add(newV1);
         List <int> side2 = GetSideWalk(a.right, corner);
         side2.Add(newV1);
         newPolys = new List <MPolygon> ();
         newPolys.Add(new MPolygon(side1));
         newPolys.Add(new MPolygon(side2));
         return(2);
     }
     newPolys = null;
     return(-1);
 }
Exemple #4
0
 public bool ContainsEdge(PolygonSide pairEntry)
 {
     return(contains(pairEntry) || contains(pairEntry.Reversed()));
 }