/// <summary> /// Computes the Delaunay triangulation. /// </summary> /// <typeparam name="TVertex">The type of the t vertex.</typeparam> /// <typeparam name="TCell">The type of the t cell.</typeparam> /// <param name="data">The data.</param> /// <param name="PlaneDistanceTolerance">The plane distance tolerance.</param> /// <returns>TCell[].</returns> internal static TCell[] GetDelaunayTriangulation <TVertex, TCell>(IList <TVertex> data, double PlaneDistanceTolerance) where TCell : TriangulationCell <TVertex, TCell>, new() where TVertex : IVertex { var ch = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), true, PlaneDistanceTolerance); ch.GetConvexHull(); ch.RemoveUpperFaces(); return(ch.GetConvexFaces <TVertex, TCell>()); }
/// <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> /// MGSharp.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>() }); }