forked from gacevedobolton/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadPData.py
45 lines (34 loc) · 1.68 KB
/
readPData.py
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
39
40
41
42
43
44
45
#coding=utf8
########################################################################
### ###
### Created by Martin Genet, 2012-2016 ###
### ###
### University of California at San Francisco (UCSF), USA ###
### Swiss Federal Institute of Technology (ETH), Zurich, Switzerland ###
### École Polytechnique, Palaiseau, France ###
### ###
########################################################################
import os
import vtk
import myVTKPythonLibrary as myVTK
########################################################################
def readPData(
filename,
verbose=1):
myVTK.myPrint(verbose, "*** readPData: "+filename+" ***")
assert (os.path.isfile(filename)), "Wrong filename (\""+filename+"\"). Aborting."
if ('vtk' in filename):
pdata_reader = vtk.vtkPolyDataReader()
elif ('vtp' in filename):
pdata_reader = vtk.vtkXMLPolyDataReader()
else:
assert 0, "File must be .vtk or .vtp. Aborting."
pdata_reader.SetFileName(filename)
pdata_reader.Update()
pdata = pdata_reader.GetOutput()
myVTK.myPrint(verbose-1, "n_points = "+str(pdata.GetNumberOfPoints()))
myVTK.myPrint(verbose-1, "n_verts = "+str(pdata.GetNumberOfVerts()))
myVTK.myPrint(verbose-1, "n_lines = "+str(pdata.GetNumberOfLines()))
myVTK.myPrint(verbose-1, "n_polys = "+str(pdata.GetNumberOfPolys()))
myVTK.myPrint(verbose-1, "n_strips = "+str(pdata.GetNumberOfStrips()))
return pdata