3
# 2d mode: x y z, z = f(x,y)
9
base = filename.split(".")[0]
10
output = "%s.vtk" % (base,)
11
print "output to %s" % (output,)
13
print "python asci2vtk.py foo"
17
fin = open( filename , "r" )
21
for line in fin.xreadlines():
22
coords.append( line.split() )
28
print "%s points" % (str(n),)
31
fout = open( output , "w" )
32
print >>fout, """# vtk DataFile Version 2.0
35
DATASET UNSTRUCTURED_GRID
36
POINTS %s float""" % (str(n),)
39
print >>fout, "%s %s %s" % (c[0],c[1],0)
41
print >>fout, "CELLS %s %s" % (n,2*n)
43
print >>fout, "1 %s" % (i,)
45
print >>fout, "CELL_TYPES %s" % (n,)
49
print >>fout, "POINT_DATA %s" % (n,)
50
print >>fout, """SCALARS Z float 1
51
LOOKUP_TABLE default"""
54
print >>fout, coords[i][2]