コード例 #1
0
 static MICHVertex <T>[] Wrap <T>(IList <T> nodes)
     where T : ILocatable
 {
     MICHVertex <T>[] startNodes = new MICHVertex <T> [nodes.Count];
     for (int i = 0; i < nodes.Count; ++i)
     {
         startNodes[i] = new MICHVertex <T>(nodes[i].Position, nodes[i]);
     }
     return(startNodes);
 }
コード例 #2
0
ファイル: MICMesher.cs プロジェクト: rohitvuppala/BoSSS
        static (VariableCell <T>[] cells, Vertex[] vertices) CreateMeshLists(
            IEnumerable <MICHDelaunayCell <T> > delaunayCells,
            IEnumerable <MIConvexHull.VoronoiEdge <MICHVertex <T>, MICHDelaunayCell <T> > > edges,
            int numberOfVoronois)
        {
            //Merge Position and ID of Vertices of zero-Edges
            MergeVerticesOfZeroEdges(edges);

            Vertex[]           vertices = new Vertex[delaunayCells.Count()];
            VariableCell <T>[] cells    = new VariableCell <T> [numberOfVoronois];

            foreach (MICHDelaunayCell <T> delaCell in delaunayCells)
            {
                delaCell.done = true;
                MICHDelaunayCell <T>[] neighbors    = delaCell.Adjacency;
                VariableCell <T>[]     voronoiCells = new VariableCell <T> [3];
                vertices[delaCell.ID] = delaCell.Circumcenter;

                //Create Voronoi Cells
                //--------------------------------------------------------------
                for (int i = 0; i < 3; ++i)
                {
                    MICHVertex <T> vert = delaCell.Vertices[i];
                    //Create or pick cell
                    VariableCell <T> voronoiCell = null;
                    if (cells[vert.ID] == null)
                    {
                        voronoiCell = new VariableCell <T> {
                            ID = vert.ID, Node = vert.Node
                        };
                        cells[vert.ID] = voronoiCell;
                    }
                    else
                    {
                        voronoiCell = cells[vert.ID];
                    }
                    voronoiCells[i] = voronoiCell;
                }
                //Create Ridges for each neighbor
                //--------------------------------------------------------------
                for (int i = 0; i < 3; ++i)
                {
                    MICHDelaunayCell <T> neighbor = neighbors[i];
                    if (neighbor != null)
                    {
                        if (!neighbor.done)
                        {
                            if (delaCell.Circumcenter.ID != neighbor.Circumcenter.ID)
                            {
                                (int k, int j) = OpposingIndices(i);
                                //Create Ridges
                                Edge <T> ridgeOutwards = new Edge <T>
                                {
                                    Start = delaCell.Circumcenter,
                                    End   = neighbor.Circumcenter,
                                    Cell  = voronoiCells[k]
                                };
                                Edge <T> ridgeInwards = new Edge <T>
                                {
                                    Start = neighbor.Circumcenter,
                                    End   = delaCell.Circumcenter,
                                    Cell  = voronoiCells[j]
                                };
                                ridgeInwards.Twin  = ridgeOutwards;
                                ridgeOutwards.Twin = ridgeInwards;
                                //add to the two cells

                                voronoiCells[k].Insert(ridgeOutwards);
                                voronoiCells[j].Insert(ridgeInwards);
                            }
                        }
                    }
                    else
                    {
                        (int k, int j)           = OpposingIndices(i);
                        voronoiCells[k].boundary = true;
                        voronoiCells[j].boundary = true;
                    }
                }
            }
            return(cells, vertices);
        }
コード例 #3
0
        static void ResetDataIDCounters <T>()
        {
            MICHVertex <T> .Clear();

            MICHDelaunayCell <T> .Clear();
        }