Example #1
0
        /// <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>());
        }
Example #2
0
        /// <summary>
        /// Create the manager.
        /// </summary>
        /// <param name="hull">The hull.</param>
        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>();
        }
Example #3
0
        /// <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&lt;TVertex, TFace&gt;.
        /// </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>()
            });
        }
Example #4
0
        /// <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&lt;TVertex, TCell&gt;.</returns>
        /// <exception cref="System.ArgumentNullException">data</exception>
        /// <exception cref="ArgumentNullException">data</exception>
        public static DelaunayTriangulation <TVertex, TCell> Create(IList <TVertex> data,
                                                                    double 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
            });
        }
    }