Esempio n. 1
0
        public void AddHole(Polygon2d hole, bool bCheck = true)
        {
            if (outer == null)
            {
                throw new Exception("GeneralPolygon2d.AddHole: outer polygon not set!");
            }
            if (bCheck)
            {
                if (outer.Contains(hole) == false)
                {
                    throw new Exception("GeneralPolygon2d.AddHole: outer does not contain hole!");
                }

                // [RMS] segment/segment intersection broken?
                foreach (var hole2 in holes)
                {
                    if (hole.Intersects(hole2))
                    {
                        throw new Exception("GeneralPolygon2D.AddHole: new hole intersects existing hole!");
                    }
                }
            }

            if ((bOuterIsCW && hole.IsClockwise) || (bOuterIsCW == false && hole.IsClockwise == false))
            {
                throw new Exception("GeneralPolygon2D.AddHole: new hole has same orientation as outer polygon!");
            }

            holes.Add(hole);
        }
Esempio n. 2
0
 public bool Intersects(Polygon2d poly)
 {
     if (outer.Intersects(poly))
     {
         return(true);
     }
     foreach (var h in holes)
     {
         if (h.Intersects(poly))
         {
             return(true);
         }
     }
     return(false);
 }