Exemplo n.º 1
0
        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&lt;TVertex, TCell&gt;.</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&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,
                                                                    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
            });
        }
    }