-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathreadUGrid.py
More file actions
46 lines (34 loc) · 1.5 KB
/
readUGrid.py
File metadata and controls
46 lines (34 loc) · 1.5 KB
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
46
#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 readUGrid(
filename,
verbose=1):
myVTK.myPrint(verbose, "*** readUGrid: " + filename + " ***")
if ('vtk' in filename):
ugrid_reader = vtk.vtkUnstructuredGridReader()
elif ('vtu' in filename):
ugrid_reader = vtk.vtkXMLUnstructuredGridReader()
else:
assert 0, "File must be .vtk or .vtu. Aborting."
assert (os.path.isfile(filename)), "Wrong filename. Aborting."
ugrid_reader.SetFileName(filename)
ugrid_reader.Update()
ugrid = ugrid_reader.GetOutput()
if (verbose):
n_points = ugrid.GetNumberOfPoints()
print 'n_points =', n_points
n_cells = ugrid.GetNumberOfCells()
print 'n_cells =', n_cells
return ugrid