internal static ConvexHull <TVertex, TFace> GetConvexHull <TVertex, TFace>(IList <TVertex> data, double PlaneDistanceTolerance) where TVertex : IVertex where TFace : ConvexFace <TVertex, TFace>, new() { ConvexHullAlgorithm convexHullAlgorithm = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), false, PlaneDistanceTolerance); convexHullAlgorithm.GetConvexHull(); if (convexHullAlgorithm.NumOfDimensions == 2) { return(convexHullAlgorithm.Return2DResultInOrder <TVertex, TFace>(data)); } ConvexHull <TVertex, TFace> convexHull = new ConvexHull <TVertex, TFace>(); convexHull.Points = convexHullAlgorithm.GetHullVertices(data); convexHull.Faces = convexHullAlgorithm.GetConvexFaces <TVertex, TFace>(); return(convexHull); }
/// <summary> /// The main function for the Convex Hull algorithm. It is static, but it creates /// an instantiation of this class in order to allow for parallel execution. /// Following this simple function, the constructor and the main function "FindConvexHull" is listed. /// </summary> /// <typeparam name="TVertex">The type of the vertices in the data.</typeparam> /// <typeparam name="TFace">The desired type of the faces.</typeparam> /// <param name="data">The data is the vertices as a collection of IVertices.</param> /// <param name="PlaneDistanceTolerance">The plane distance tolerance.</param> /// <returns> /// MIConvexHull.ConvexHull<TVertex, TFace>. /// </returns> internal static ConvexHull <TVertex, TFace> GetConvexHull <TVertex, TFace>(IList <TVertex> data, double PlaneDistanceTolerance) where TFace : ConvexFace <TVertex, TFace>, new() where TVertex : IVertex { var ch = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), false, PlaneDistanceTolerance); ch.GetConvexHull(); if (ch.NumOfDimensions == 2) { return(ch.Return2DResultInOrder <TVertex, TFace>(data)); } return(new ConvexHull <TVertex, TFace> { Points = ch.GetHullVertices(data), Faces = ch.GetConvexFaces <TVertex, TFace>() }); }