File: example1.py

package info (click to toggle)
pyvtk 0.4.74-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 292 kB
  • ctags: 354
  • sloc: python: 2,073; makefile: 71; sh: 1
file content (31 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python

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')