/// <summary> /// Find cut lines through each polygon. /// A polygon represents an area bounded by lines in the dual plane. /// The cut line will be a point in the dual plane, being the line of greatest seperation in the real plane. /// </summary> /// <param name="a_region"></param> /// <returns></returns> public static List <Line> FindCutLinesInDual(IEnumerable <Polygon2D> a_region) { if (a_region.Count() <= 0) // no valid faces are supplied { return(new List <Line>()); } //facebased approach var lines = new List <Line>(); foreach (var poly in a_region.Skip(1).Take(a_region.Count() - 2)) //Treat faces on the bounding box separately { var line = Separator.LineOfGreatestMinimumSeparationInTheDual(poly, false).Line; if (line == null) { throw new GeomException("Polygon should have a seperation line"); } lines.Add(line); } // Solve bounding box cases (Take only the line with the greatest separation) var firstBoundingboxPoly = a_region.ElementAt(0); var lastBoundingboxPoly = a_region.ElementAt(a_region.Count() - 1); var firstTuple = Separator.LineOfGreatestMinimumSeparationInTheDual(firstBoundingboxPoly, true); var lastTuple = Separator.LineOfGreatestMinimumSeparationInTheDual(lastBoundingboxPoly, true); if (firstTuple.Separation > lastTuple.Separation) { lines.Add(firstTuple.Line); } else { lines.Add(lastTuple.Line); } return(lines); }