Exemplo n.º 1
0
        public static DelaunayMesh2d GetMesh(List <Point2d> plist)
        {
            DelaunayMesh2d        mesh = new DelaunayMesh2d();
            DelaunayTriangulation del  = new DelaunayTriangulation();

            for (int i = 1; i <= plist.Count; i++)
            {
                del.Vertex[i].x = (int)plist[i - 1].X;
                del.Vertex[i].y = (int)plist[i - 1].Y;
            }
            int ntri = del.Triangulate(plist.Count);

            for (int i = 0; i < plist.Count; i++)
            {
                mesh.AddVertex(plist[i]);
            }
            for (int i = 1; i <= ntri; i++)
            {
                mesh.AddFace(new Triangle((int)del.Triangle[i].vv0 - 1, (int)del.Triangle[i].vv1 - 1, (int)del.Triangle[i].vv2 - 1));
            }
            for (int i = 0; i < ntri; i++)
            {
                Triangle t = mesh.Faces[i];
                t.Index       = i;
                mesh.Faces[i] = t;
            }
            return(mesh);
        }
Exemplo n.º 2
0
 public static DelaunayMesh2d GetMesh(List<Point2d> plist)
 {
     DelaunayMesh2d mesh = new DelaunayMesh2d();
     DelaunayTriangulation del = new DelaunayTriangulation();
     for (int i = 1; i <= plist.Count; i++)
     {
         del.Vertex[i].x = (int)plist[i - 1].x;
         del.Vertex[i].y = (int)plist[i - 1].y;
     }
     int ntri = del.Triangulate(plist.Count);
     for (int i = 0; i < plist.Count; i++)
     {
         mesh.AddVertex(plist[i]);
     }
     for (int i = 1; i <= ntri; i++)
     {
         mesh.AddFace(new Triangle((int)del.Triangle[i].vv0 - 1, (int)del.Triangle[i].vv1 - 1, (int)del.Triangle[i].vv2 - 1));
     }
     for (int i = 0; i < ntri; i++)
     {
         Triangle t = mesh.Faces[i];
         t.Index = i;
         mesh.Faces[i] = t;
     }
     return mesh;
 }