Example #1
0
        protected override void Generate(IList <VERTEX> input, IDelaunayTriangulation <VERTEX> delaunay, bool assignIds, bool checkInput = false)
        {
            if (delaunay as IDecoratedDelaunayTriangulation <VERTEX, CELLDATA> == null)
            {
                // TODO:
                throw new ArgumentException();
            }

            base.Generate(input, delaunay, assignIds, checkInput);
        }
 public void Generate(IList <VERTEX> input, out IDelaunayTriangulation <VERTEX> delaunay, bool assignIds = true, bool checkInput = false)
 {
     delaunay = new DecoratedDelaunayTriangulation2 <VERTEX, CELLDATA>();
     Generate(input, delaunay, assignIds, checkInput);
 }
 public static void Iterate <VERTEX>(IVoronoiMesh2 <VERTEX> src, out IVoronoiMesh2 <VERTEX> dst1, out IDelaunayTriangulation <VERTEX> dst2)
     where VERTEX : class, IVertex, new ()
 {
     dst1 = new VoronoiMesh2 <VERTEX>();
     dst1.Generate(GetCentroids(src), out dst2);
 }
Example #4
0
        protected virtual void Generate(IList <VERTEX> input, IDelaunayTriangulation <VERTEX> delaunay, bool assignIds, bool checkInput = false)
        {
            Clear();
            delaunay.Generate(input, assignIds, checkInput);

            for (int i = 0; i < delaunay.Vertices.Count; i++)
            {
                delaunay.Vertices[i].Tag = i;
            }

            for (int i = 0; i < delaunay.Cells.Count; i++)
            {
                delaunay.Cells[i].CircumCenter.Id = i;
                delaunay.Cells[i].Simplex.Tag     = i;
                Cells.Add(delaunay.Cells[i]);
            }

            var cells         = new List <IDelaunayCell <VERTEX> >();
            var neighbourCell = new Dictionary <int, IDelaunayCell <VERTEX> >();

            for (int i = 0; i < delaunay.Vertices.Count; i++)
            {
                cells.Clear();
                VERTEX vertex = delaunay.Vertices[i];

                for (int j = 0; j < delaunay.Cells.Count; j++)
                {
                    Simplex <VERTEX> simplex = delaunay.Cells[j].Simplex;

                    for (int k = 0; k < simplex.Vertices.Length; k++)
                    {
                        if (simplex.Vertices[k].Tag == vertex.Tag)
                        {
                            cells.Add(delaunay.Cells[j]);
                            break;
                        }
                    }
                }

                if (cells.Count > 0)
                {
                    var region = CreateRegion();

                    for (int j = 0; j < cells.Count; j++)
                    {
                        region.Cells.Add(cells[j]);
                    }

                    neighbourCell.Clear();

                    for (int j = 0; j < cells.Count; j++)
                    {
                        neighbourCell.Add(cells[j].CircumCenter.Id, cells[j]);
                    }

                    for (int j = 0; j < cells.Count; j++)
                    {
                        Simplex <VERTEX> simplex = cells[j].Simplex;

                        for (int k = 0; k < simplex.Adjacent.Length; k++)
                        {
                            if (simplex.Adjacent[k] == null)
                            {
                                continue;
                            }

                            int tag = simplex.Adjacent[k].Tag;

                            if (neighbourCell.ContainsKey(tag))
                            {
                                region.Edges.Add(CreateEdge(cells[j], neighbourCell[tag]));
                            }
                        }
                    }

                    region.Id = Regions.Count;
                    Regions.Add(region);
                }
            }
        }