-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathcreateArray.py
More file actions
67 lines (59 loc) · 2.83 KB
/
createArray.py
File metadata and controls
67 lines (59 loc) · 2.83 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#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 myVTKPythonLibrary as myVTK
########################################################################
def createArray(
array_name,
n_components=1,
n_tuples=0,
array_type="float",
init_to_zero=0,
verbose=1):
assert (type(array_type) in [type, str]), "array_type must be a type or a str. Aborting."
if (type(array_type) is type):
assert (array_type in [float, int]), "if a type, array_type must be equal to float or int. Aborting."
if (array_type == float):
return myVTK.createFloatArray(
name=array_name,
n_components=n_components,
n_tuples=n_tuples,
init_to_zero=init_to_zero,
verbose=verbose-1)
elif (array_type == int):
return myVTK.createIntArray(
name=array_name,
n_components=n_components,
n_tuples=n_tuples,
init_to_zero=init_to_zero,
verbose=verbose-1)
elif (type(array_type) is str):
assert (array_type in ["double", "float", "int", "short"]), "if a str, array_type must be equal to double, float, int or short. Aborting."
if (array_type == "float") or (array_type == "double"):
return myVTK.createFloatArray(
name=array_name,
n_components=n_components,
n_tuples=n_tuples,
init_to_zero=init_to_zero,
verbose=verbose-1)
elif (array_type == "int"):
return myVTK.createIntArray(
name=array_name,
n_components=n_components,
n_tuples=n_tuples,
init_to_zero=init_to_zero,
verbose=verbose-1)
elif (array_type == "short"):
return myVTK.createShortArray(
name=array_name,
n_components=n_components,
n_tuples=n_tuples,
init_to_zero=init_to_zero,
verbose=verbose-1)