예제 #1
0
        public static BoundaryMesh <T> ComputeMesh <T>(IList <T> nodeList, Settings settings)
            where T : IMesherNode, new()
        {
            // Create Voronoi mesh
            // =================================
            IEnumerator <Line>   boundaryLines = Line.GetEnumerator(settings.Boundary);
            IntersectionMesh <T> mesh          = null;

            for (int iLloyd = 0; iLloyd <= settings.NumberOfLloydIterations; ++iLloyd)
            {
                // Mesh generation
                //-------------------------------------
                AddDistantBoundingNodes(nodeList, settings.BoundingBox);
                mesh = IntersectionMeshGenerator.CreateMesh(nodeList, settings.FirstCellNode_indice);
                //Clip
                //-------------------------------------
                Intersecter.Intersect(mesh, boundaryLines);

                // Lloyds algorithm (Voronoi relaxation)
                // -------------------------------------
                IReadOnlyList <MeshCell <T> > cells = mesh.GetCells(); //GetInsideCell : Return Cells in order of MeshArray.
                if (iLloyd != settings.NumberOfLloydIterations)
                {
                    MoveNodesTowardsCellCenter(cells, ref settings.FirstCellNode_indice);
                }
                nodeList = mesh.GetNodes();
            }
            return(mesh);
        }
예제 #2
0
        static IntersectionMesh <T> CreateMesh <T>(IList <MICHVertex <T> > startNodes, int startCell_NodeIndice)
            where T : IMesherNode, new()
        {
            SimpleIdMesh <T> mesh = MICMesher <T> .Create(startNodes);

            IntersectionMesh <T> intersectionMesh = new IntersectionMesh <T>(mesh, startCell_NodeIndice);

            return(intersectionMesh);
        }
예제 #3
0
        public static IntersectionMesh <T> CreateMesh <T>(IList <T> nodes, int startCell_NodeIndice)
            where T : IMesherNode, new()
        {
            ResetDataIDCounters <T>();
            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]);
            }
            IntersectionMesh <T> mesh = CreateMesh(startNodes, startCell_NodeIndice);

            return(mesh);
        }