private List <List <Vector2> > GenerateInsidePoints(IEnumerable <PSPolygon> polygons, int r) { var area = new Vector2[] { new Vector2(r, r), new Vector2(r, -r), new Vector2(-r, -r), new Vector2(-r, r) }; var insidePolygons = MeshToPolygonConverter.InsidePolygons(area, polygons, -insideOffset).ToList(); insidePolygons.ForEach(p => p.Precalc()); var insideLookup = insidePolygons.ToLookup(p => p.IsHole); var magnitudeStep = 1f; var magnitudeCount = Mathf.CeilToInt((outerRadius - insideInnerRadius) / magnitudeStep); return(Enumerable.Range(0, 360).Select(i => { var angle = i * Mathf.Deg2Rad; var direction = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle)); return Enumerable.Range(0, magnitudeCount).Select(j => direction * (insideInnerRadius + j * magnitudeStep)).Where(p => { return insideLookup[false].Any(c => c.PointInPolygon(p)) && insideLookup[true].All(c => !c.PointInPolygon(p)); }).ToList(); }).Where(l => l.Count > 0).ToList()); }
private List <PSPolygon> GeneratePolygons(List <Vector2> vertices, List <int> triangles, Vector2[][] segments) { var contours = MeshToPolygonConverter.ContourPolygons(vertices, triangles).ToList(); return(segments.AsParallel().SelectMany(segment => MeshToPolygonConverter.FragmentPolygons(contours, segment)).ToList()); }