internal static TCell[] GetDelaunayTriangulation <TVertex, TCell>(IList <TVertex> data) where TVertex : IVertex where TCell : TriangulationCell <TVertex, TCell>, new() { ConvexHullAlgorithm convexHullAlgorithm = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), true, 1E-10); convexHullAlgorithm.GetConvexHull(); convexHullAlgorithm.RemoveUpperFaces(); return(convexHullAlgorithm.GetConvexFaces <TVertex, TCell>()); }
/// <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> /// <returns>TCell[].</returns> internal static TCell[] GetDelaunayTriangulation <TVertex, TCell>(IList <TVertex> data) where TCell : TriangulationCell <TVertex, TCell>, new() where TVertex : IVertex { var ch = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), true, Constants.DefaultPlaneDistanceTolerance); ch.GetConvexHull(); ch.RemoveUpperFaces(); return(ch.GetConvexFaces <TVertex, TCell>()); }
public ObjectManager(ConvexHullAlgorithm hull) { Dimension = hull.NumOfDimensions; Hull = hull; FacePool = hull.FacePool; FacePoolSize = 0; FacePoolCapacity = hull.FacePool.Length; FreeFaceIndices = new IndexBuffer(); EmptyBufferStack = new SimpleList <IndexBuffer>(); DeferredFaceStack = new SimpleList <DeferredFace>(); }
/// <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 { // change true -> false var ch = new ConvexHullAlgorithm(data.Cast <IVertex>().ToArray(), false, PlaneDistanceTolerance); ch.GetConvexHull(); // deprecated //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> /// 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(); return(new ConvexHull <TVertex, TFace> { Points = ch.GetHullVertices(data), Faces = ch.GetConvexFaces <TVertex, TFace>() }); }
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>() }); }
public static DelaunayTriangulation <TVertex, TCell> Create(IList <TVertex> data) { if (data == null) { throw new ArgumentNullException("data"); } DelaunayTriangulation <TVertex, TCell> delaunayTriangulation; if (data.Count == 0) { delaunayTriangulation = new DelaunayTriangulation <TVertex, TCell>(); delaunayTriangulation.Cells = new TCell[0]; return(delaunayTriangulation); } TCell[] delaunayTriangulation2 = ConvexHullAlgorithm.GetDelaunayTriangulation <TVertex, TCell>(data); delaunayTriangulation = new DelaunayTriangulation <TVertex, TCell>(); delaunayTriangulation.Cells = delaunayTriangulation2; return(delaunayTriangulation); }
/// <summary> /// Creates the Delaunay triangulation of the input data. /// </summary> /// <param name="data">The data.</param> /// <param name="config">If null, default ConvexHullComputationConfig is used.</param> /// <returns>DelaunayTriangulation<TVertex, TCell>.</returns> /// <exception cref="ArgumentNullException">data</exception> public static DelaunayTriangulation <TVertex, TCell> Create(IList <TVertex> data) { if (data == null) { throw new ArgumentNullException("data"); } if (data.Count == 0) { return new DelaunayTriangulation <TVertex, TCell> { Cells = new TCell[0] } } ; var cells = ConvexHullAlgorithm.GetDelaunayTriangulation <TVertex, TCell>(data); return(new DelaunayTriangulation <TVertex, TCell> { Cells = cells }); } }
/// <summary> /// Creates the Delaunay triangulation of the input data. /// </summary> /// <param name="data">The data.</param> /// <param name="PlaneDistanceTolerance">The plane distance tolerance (default is 1e-10). If too high, points /// will be missed. If too low, the algorithm may break. Only adjust if you notice problems.</param> /// <returns>DelaunayTriangulation<TVertex, TCell>.</returns> /// <exception cref="System.ArgumentNullException">data</exception> /// <exception cref="ArgumentNullException">data</exception> public static DelaunayTriangulation <TVertex, TCell> Create(IList <TVertex> data, float PlaneDistanceTolerance)// = Constants.DefaultPlaneDistanceTolerance) { if (data == null) { throw new ArgumentNullException("data"); } if (data.Count == 0) { return new DelaunayTriangulation <TVertex, TCell> { Cells = new TCell[0] } } ; var cells = ConvexHullAlgorithm.GetDelaunayTriangulation <TVertex, TCell>(data, PlaneDistanceTolerance); return(new DelaunayTriangulation <TVertex, TCell> { Cells = cells }); } }