Example #1
0
        public void addRegion(PointList region)
        {
            if (!selfIntersection)
            {
                throw new Exception("The addRegion() function is only intended for use when selfIntersection = false");
            }

            // Ensure that the polygon is fully closed (the start point and end point are exactly the same)
            if (!Epsilon.pointsSame(region[region.Count - 1], region[0]))
            {
                region.Add(region[0]);
            }

            // regions are a list of points:
            //  [ [0, 0], [100, 0], [50, 100] ]
            // you can add multiple regions before running calculate
            var pt1 = new Point();
            var pt2 = region[region.Count - 1];

            for (var i = 0; i < region.Count; i++)
            {
                pt1 = pt2;
                pt2 = region[i];

                var forward = Epsilon.pointsCompare(pt1, pt2);
                if (forward == 0)                 // points are equal, so we have a zero-length segment
                {
                    continue;                     // just skip it
                }
                eventAddSegment(
                    segmentNew(
                        forward < 0 ? pt1 : pt2,
                        forward < 0 ? pt2 : pt1
                        ),
                    true
                    );
            }
        }
Example #2
0
 public PointListDebugProxy(PointList target)
 {
     this.list = target;
 }