forked from 541435721/myVTKPythonLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateIntArray.py
53 lines (41 loc) · 1.59 KB
/
createIntArray.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
46
47
48
49
50
51
52
53
#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 vtk
import myVTKPythonLibrary as myVTK
########################################################################
def createIntArray(
name,
n_components=1,
n_tuples=0,
init_to_zero=0,
verbose=1):
iarray = vtk.vtkIntArray()
iarray.SetName(name)
iarray.SetNumberOfComponents(n_components)
iarray.SetNumberOfTuples(n_tuples)
if (init_to_zero):
for k_tuple in xrange(n_tuples):
iarray.SetTuple(k_tuple, [0]*n_components)
return iarray
def createUnsignedIntArray(
name,
n_components=1,
n_tuples=0,
init_to_zero=0,
verbose=1):
uiarray = vtk.vtkUnsignedIntArray()
uiarray.SetName(name)
uiarray.SetNumberOfComponents(n_components)
uiarray.SetNumberOfTuples(n_tuples)
if (init_to_zero):
for k_tuple in xrange(n_tuples):
uiarray.SetTuple(k_tuple, [0]*n_components)
return uiarray