private static Point2DCollection ClipRing(Point2DCollection ring, Edge edge)
{
if ((ring == null) || (ring.Count < 2))
{
return null;
}
Point2DCollection points = new Point2DCollection();
Point2D lastPoint = ring[ring.Count - 1];
for (int i = 0; i < ring.Count; i++)
{
Point2D point = ring[i];
if (Inside(point, edge))
{
if (Inside(lastPoint, edge))
{
points.Add(point);
}
else
{
Point2D item = EdgeIntersection(lastPoint, point, edge);
points.Add(item);
points.Add(point);
}
}
else if (Inside(lastPoint, edge))
{
Point2D item = EdgeIntersection(lastPoint, point, edge);
points.Add(item);
}
lastPoint = point;
}
return points;
}