PyVTK-0.4.74/ 0000755 0001750 0001750 00000000000 10567304606 011604 5 ustar pearu pearu PyVTK-0.4.74/doc/ 0000755 0001750 0001750 00000000000 10567304606 012351 5 ustar pearu pearu PyVTK-0.4.74/doc/index.html 0000644 0001750 0001750 00000007356 10567254627 014370 0 ustar pearu pearu
PyVTK - Manipulate VTK files in Python
PyVTK Tools for manipulating VTK files in Python
by Pearu Peterson
What's new?
0.4.73 (Feb 22, 2007)
Minor bug fixes.
0.4.71 (May 18, 2006)
Added numpy support. Bug fixes.
0.4.66 (January 26, 2003)
Fixed binary write of UnstructuredGrid.
0.4.62 (November 19, 2002)
Minor fixes.
0.4 (September 2, 2002)
Writing binary files works (thanks to Hans Fangohr).
0.4 (June 8, 2001)
VTK files reader (only for Python 2.x). Usage: VtkData(filename)
0.3 (May 21, 2001)
First release.
Introduction
PyVTK provides the following tools for manipulating Visualization Toolkit (VTK) files in Python:
VtkData
Create VTK file from Python objects. It fully
supports VTK
File Formats Standard 2.0
(see also VTK
File Formats Standard 3.0 ).
The features include:
ascii and binary output, ascii input from VTK file
DataSet formats:
StructuredPoints, StructuredGrid, RectilinearGrid,
PolyData, UnstructuredGrid
Data formats:
PointData, CellData
DataSetAttr formats:
Scalars, ColorScalars, LookupTable, Vectors,
Normals, TextureCoordinates, Tensors, Field
Related software
MayaVi - free, easy
to use scientific data visualizer, written in Python by Prabhu
Ramachandran.
Requirements
Python (PyVTK is developed under Python 2.1, but it is tested to work also with Python 1.5.2 and 2.0)
Download
Snapshots of release:
rel-0.x /PyVTK-0.latest.tar.gz
Installation
To install PyVTK
, unpack the source file, change to directory PyVTK-?.?.?
and
run python setup.py install
, or make install
if under Python 1.x.
PyVTK
is being developed under
CVS and those who are
interested in the latest version of PyVTK
(possibly
unstable) can get it from the repository as follows:
First you need to login (the password is guest
):
> cvs -d :pserver:anonymous@cens.ioc.ee:/home/cvs login
and then do the checkout:
> cvs -z6 -d :pserver:anonymous@cens.ioc.ee:/home/cvs checkout python/pyvtk
In the directory pyvtk
you can get the updates by hitting
> cvs -z6 update -P -d
You can browse PyVTK
CVS repository here .
Pearu Peterson
<pearu@cens.ioc.ee>
Last modified: Fri May 18 16:44:25 EET 2006
PyVTK-0.4.74/examples/ 0000755 0001750 0001750 00000000000 10567304606 013422 5 ustar pearu pearu PyVTK-0.4.74/examples/example1.py 0000644 0001750 0001750 00000002211 07304773331 015504 0 ustar pearu pearu #!/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')
PyVTK-0.4.74/examples/example2.py 0000644 0001750 0001750 00000003074 07305502006 015503 0 ustar pearu pearu #!/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 *
vtk = VtkData(StructuredPoints([3,4,6]),
PointData(Scalars([0,0,0,0,0,0,0,0,0,0,0,0,
0,5,10,15,20,25,25,20,15,10,5,0,
0,10,20,30,40,50,50,40,30,20,10,0,
0,10,20,30,40,50,50,40,30,20,10,0,
0,5,10,15,20,25,25,20,15,10,5,0,
0,0,0,0,0,0,0,0,0,0,0,0
])))
vtk.tofile('example2')
vtk.tofile('example2b','binary')
vtk = VtkData('example2',only_structure = 1)
def f(x,y,z):
return x*y*z
vtk.point_data.append(vtk.structure.Scalars(f,'x*y*z'))
vtk.tofile('example2f_sp')
pp = [(i,j,k) for k in range(6) for j in range(4) for i in range(3)]
vtk = VtkData(StructuredGrid([3,4,6],pp))
vtk.point_data.append(vtk.structure.Scalars(f,'x*y*z'))
vtk.tofile('example2f_sg')
vtk = VtkData(RectilinearGrid(range(3),range(4),range(6)))
vtk.point_data.append(vtk.structure.Scalars(f,'x*y*z'))
vtk.tofile('example2f_rg')
voxels = []
points = []
n = 0
for k in range(6):
for j in range(4):
for i in range(3):
points.append((i,j,k))
if not (k==5 or j==3 or i==2):
voxels.append([n,n+1,n+3,n+3+1,n+3*4,n+3*4+1,n+3*4+3,n+3*4+3+1])
n += 1
vtk = VtkData(UnstructuredGrid(points,voxel=voxels))
vtk.point_data.append(vtk.structure.Scalars(f,'x*y*z'))
vtk.tofile('example2f_usg')
PyVTK-0.4.74/examples/example3.py 0000644 0001750 0001750 00000002771 07305502006 015507 0 ustar pearu pearu #!/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 *
points = [[0,0,0],[1,0,0],[2,0,0],[0,1,0],[1,1,0],[2,1,0],
[0,0,1],[1,0,1],[2,0,1],[0,1,1],[1,1,1],[2,1,1],
[0,1,2],[1,1,2],[2,1,2],[0,1,3],[1,1,3],[2,1,3],
[0,1,4],[1,1,4],[2,1,4],[0,1,5],[1,1,5],[2,1,5],
[0,1,6],[1,1,6],[2,1,6]
]
vectors = [[1,0,0],[1,1,0],[0,2,0],[1,0,0],[1,1,0],[0,2,0],
[1,0,0],[1,1,0],[0,2,0],[1,0,0],[1,1,0],[0,2,0],
[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],
[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],[0,0,1],
[0,0,1],[0,0,1],[0,0,1]
]
vtk = VtkData(\
UnstructuredGrid(points,
hexahedron=[[0,1,4,3,6,7,10,9],
[1,2,5,4,7,8,11,10]],
tetra=[[6,10,9,12],
[5,11,10,14]],
polygon=[15,16,17,14,13,12],
triangle_strip=[18,15,19,16,20,17],
quad=[22,23,20,19],
triangle=[[21,22,18],
[22,19,18]],
line=[26,25],
vertex=[24]
),
PointData(Vectors(vectors),Scalars(range(27))),
'Unstructured Grid Example'
)
vtk.tofile('example3')
vtk.tofile('example3b','binary')
VtkData('example3')
PyVTK-0.4.74/lib/ 0000755 0001750 0001750 00000000000 10567304606 012352 5 ustar pearu pearu PyVTK-0.4.74/lib/ColorScalars.py 0000644 0001750 0001750 00000003711 07305502006 015303 0 ustar pearu pearu #!/usr/bin/env python
"""
ColorScalars
"""
"""
Copyright 2001 Pearu Peterson all rights reserved,
Pearu Peterson
Permission to use, modify, and distribute this software is given under the
terms of the LGPL. See http://www.fsf.org
NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
$Revision: 1.2 $
$Date: 2001-05-31 17:48:54 $
Pearu Peterson
"""
__version__ = "$Id: ColorScalars.py,v 1.2 2001-05-31 17:48:54 pearu Exp $"
import common
import DataSetAttr
class ColorScalars(DataSetAttr.DataSetAttr):
"""Holds VTK color scalars.
Usage:
ColorScalars( ,name = )
Attributes:
scalars
name
Public methods:
get_size()
to_string(format = 'ascii')
"""
def __init__(self,scalars,name=None):
self.name = self._get_name(name)
self.scalars = self.get_n_seq_seq(scalars,self.default_value)
def to_string(self,format='ascii'):
ret = ['COLOR_SCALARS %s %s'%(self.name,len(self.scalars[0]))]
seq = self.scalars
if format=='binary':
if not common.is_int255(seq):
seq = self.float01_to_int255(seq)
ret.append(self.seq_to_string(seq,format,'unsigned char'))
else:
if not common.is_float01(seq):
seq = self.int255_to_float01(seq)
ret.append(self.seq_to_string(seq,format,'float'))
return '\n'.join(ret)
def get_size(self):
return len(self.scalars)
def color_scalars_fromfile(f,n,sl):
assert len(sl)==2
dataname = sl[0].strip()
nvals = eval(sl[1])
scalars = []
while len(scalars)