Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/MIConvexHull/Triangulation/Triangulation.cs @ 10530

Last change on this file since 10530 was 9730, checked in by ascheibe, 11 years ago

#1886 added a library that calculates convex hulls

File size: 2.3 KB
Line 
1namespace MIConvexHull
2{
3    using System.Collections.Generic;
4    using System.Linq;
5
6    /// <summary>
7    /// Simple interface to unify different types of triangulations in the future.
8    /// </summary>
9    /// <typeparam name="TVertex"></typeparam>
10    /// <typeparam name="TCell"></typeparam>
11    public interface ITriangulation<TVertex, TCell>
12        where TCell : TriangulationCell<TVertex, TCell>, new()
13        where TVertex : IVertex
14    {
15        IEnumerable<TCell> Cells { get; }
16    }
17
18    /// <summary>
19    /// Factory class for creating triangulations.
20    /// </summary>
21    public static class Triangulation
22    {
23        /// <summary>
24        /// Creates the Delaunay triangulation of the input data.
25        /// </summary>
26        /// <typeparam name="TVertex"></typeparam>
27        /// <param name="data"></param>
28        /// <returns></returns>
29        public static ITriangulation<TVertex, DefaultTriangulationCell<TVertex>> CreateDelaunay<TVertex>(IEnumerable<TVertex> data)
30            where TVertex : IVertex
31        {
32            return DelaunayTriangulation<TVertex, DefaultTriangulationCell<TVertex>>.Create(data);
33        }
34
35        /// <summary>
36        /// Creates the Delaunay triangulation of the input data.
37        /// </summary>
38        /// <param name="data"></param>
39        /// <returns></returns>
40        public static ITriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>> CreateDelaunay(IEnumerable<double[]> data)
41        {
42            var points = data.Select(p => new DefaultVertex { Position = p.ToArray() });
43            return DelaunayTriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>>.Create(points);
44        }
45
46        /// <summary>
47        /// Creates the Delaunay triangulation of the input data.
48        /// </summary>
49        /// <typeparam name="TVertex"></typeparam>
50        /// <typeparam name="TFace"></typeparam>
51        /// <param name="data"></param>
52        /// <returns></returns>
53        public static ITriangulation<TVertex, TFace> CreateDelaunay<TVertex, TFace>(IEnumerable<TVertex> data)
54            where TVertex : IVertex
55            where TFace : TriangulationCell<TVertex, TFace>, new()
56        {
57            return DelaunayTriangulation<TVertex, TFace>.Create(data);
58        }
59    }
60}
Note: See TracBrowser for help on using the repository browser.