File: example1.py

package info (click to toggle)
pyvtk 0.4.66-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 268 kB
  • ctags: 355
  • sloc: python: 2,049; makefile: 120; sh: 1
file content (38 lines) | stat: -rw-r--r-- 1,161 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python

import sys
sys.path = ['..']+sys.path
if sys.version[:3]=='1.5':
    from lib152 import *
else:
    from lib import *

#from pyvtk import *

structure = PolyData(points=[[0,0,0],[1,0,0],[1,1,0],[0,1,0],
                             [0,0,1],[1,0,1],[1,1,1],[0,1,1]],
                     polygons=[[0,1,2,3],[4,5,6,7],[0,1,5,4],
                               [2,3,7,6],[0,4,7,3],[1,2,6,5]])
pointdata = PointData(\
    Scalars([0,1,2,3,4,5,6,7],
            name='sample_scalars',
            lookup_table='my_table'),
    LookupTable([[0,0,0,1],[1,0,0,1],[0,1,0,1],[1,1,0,1],
                 [0,0,1,1],[1,0,1,1],[0,1,1,1],[1,1,1,1]],
                name='my_table'))

celldata = CellData(\
    Scalars([0,1,2,3,4,5],
            name='cell_scalars'),
    Normals([[0,0,-1],[0,0,1],[0,-1,0],
             [0,1,0],[-1,0,0],[1,0,0]],
            name='cell_normals'),
    Field('FieldData',
          cellIds=[[0],[1],[2],[3],[4],[5]],
          faceAttributes=[[0,1],[1,2],[2,3],[3,4],[4,5],[5,6]]))

vtk = VtkData(structure,pointdata,celldata)
vtk.tofile('example1','ascii')
vtk.tofile('example1b','binary')

vtk2 = VtkData('example1')