namespace MIConvexHull { using System.Collections.Generic; using System.Linq; /// /// Factory class for computing convex hulls. /// public static class ConvexHull { /// /// Creates a convex hull of the input data. /// /// /// /// /// public static ConvexHull Create(IEnumerable data) where TVertex : IVertex where TFace : ConvexFace, new() { return ConvexHull.Create(data); } /// /// Creates a convex hull of the input data. /// /// /// /// public static ConvexHull> Create(IEnumerable data) where TVertex : IVertex { return ConvexHull>.Create(data); } /// /// Creates a convex hull of the input data. /// /// /// public static ConvexHull> Create(IEnumerable data) { var points = data.Select(p => new DefaultVertex { Position = p.ToArray() }); return ConvexHull>.Create(points); } } /// /// Representation of a convex hull. /// /// /// public class ConvexHull where TVertex : IVertex where TFace : ConvexFace, new() { /// /// Points of the convex hull. /// public IEnumerable Points { get; private set; } /// /// Faces of the convex hull. /// public IEnumerable Faces { get; private set; } /// /// Creates the convex hull. /// /// /// public static ConvexHull Create(IEnumerable data) { if (!(data is IList)) data = data.ToArray(); var ch = ConvexHullInternal.GetConvexHullAndFaces(data.Cast()); return new ConvexHull { Points = ch.Item1, Faces = ch.Item2 }; } /// /// Can only be created using a factory method. /// private ConvexHull() { } } }