/// <summary> /// Slices a polygon by a circle with some thickness. /// Input circle may be a line. /// </summary> /// <remarks>The input polygon might get reversed</remarks> public static void SlicePolygon(Polygon p, CircleNE c, Geometry g, double thickness, out List <Polygon> output) { // Setup the two slicing circles. CircleNE c1 = c.Clone(), c2 = c.Clone(); Mobius m = new Mobius(); Vector3D pointOnCircle = c.IsLine ? c.P1 : c.Center + new Vector3D(c.Radius, 0); m.Hyperbolic2(g, c1.CenterNE, pointOnCircle, thickness / 2); c1.Transform(m); m.Hyperbolic2(g, c2.CenterNE, pointOnCircle, -thickness / 2); c2.Transform(m); SlicePolygonHelper(p, c1, c2, out output); }
/// <summary> /// Slices a polygon by a circle with some thickness. /// Input circle may be a line. /// </summary> /// <remarks>The input polygon might get reversed</remarks> public static void SlicePolygon(Polygon p, CircleNE c, Geometry g, double thickness, out List <Polygon> output) { output = new List <Polygon>(); // Setup the two slicing circles. CircleNE c1 = c.Clone(), c2 = c.Clone(); Mobius m = new Mobius(); Vector3D pointOnCircle = c.IsLine ? c.P1 : c.Center + new Vector3D(c.Radius, 0); m.Hyperbolic2(g, c1.CenterNE, pointOnCircle, thickness / 2); c1.Transform(m); m.Hyperbolic2(g, c2.CenterNE, pointOnCircle, -thickness / 2); c2.Transform(m); // ZZZ - alter Clip method to work on Polygons and use that. // Slice it up. List <Polygon> sliced1, sliced2; Slicer.SlicePolygon(p, c1, out sliced1); Slicer.SlicePolygon(p, c2, out sliced2); // Keep the ones we want. foreach (Polygon newPoly in sliced1) { bool outside = !c1.IsPointInsideNE(newPoly.CentroidApprox); if (outside) { output.Add(newPoly); } } foreach (Polygon newPoly in sliced2) { bool inside = c2.IsPointInsideNE(newPoly.CentroidApprox); if (inside) { output.Add(newPoly); } } }