File: otherDataSetAttributes.py

package info (click to toggle)
vtk6 6.3.0%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 118,532 kB
  • ctags: 138,251
  • sloc: cpp: 1,443,749; ansic: 113,395; python: 72,383; tcl: 46,998; xml: 8,127; yacc: 4,525; java: 4,239; perl: 3,108; lex: 1,694; sh: 1,093; asm: 471; makefile: 95; objc: 17
file content (83 lines) | stat: -rwxr-xr-x 1,973 bytes parent folder | download | duplicates (16)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
import vtk
dsa = vtk.vtkDataSetAttributes()
for array in "Bit Char Double Float Int Long Short UnsignedChar UnsignedInt UnsignedLong UnsignedShort".split():

    var =  eval('vtk.vtk'+ array +'Array')()
    var.Allocate(1,1)
    var.SetNumberOfComponents(3)
    var.SetNumberOfTuples(4)
    var.SetName("a"+array+"Array")

    # SetComponent
    k = 0
    i = 0
    while i < var.GetNumberOfTuples():
        j = 0
        while j < var.GetNumberOfComponents():
            var.SetComponent(i,j,1)
            k = k + 1
            j = j + 1

        i = i + 1

    dsa.AddArray(var)
    del var

    pass

anotherFloatArray = vtk.vtkFloatArray()
anotherFloatArray.Allocate(1,1)
anotherFloatArray.SetNumberOfComponents(3)
anotherFloatArray.SetNumberOfTuples(4)
anotherFloatArray.SetName("anotherFloatArray")

foo = ''

for attribute in "Scalars Vectors Normals TCoords".split():
    eval('dsa.SetActive'+attribute+'(\"anotherFloatArray\")')
    eval('dsa.Get'+attribute+'(\"anotherFloatArray\")')
    eval('dsa.Get'+attribute+'(foo)')

del anotherFloatArray


aFloatTensors = vtk.vtkFloatArray()
aFloatTensors.Allocate(1,1)
aFloatTensors.SetNumberOfComponents(9)
aFloatTensors.SetNumberOfTuples(4)
aFloatTensors.SetName("aFloatTensors")
i = 0
while i < aFloatTensors.GetNumberOfTuples():
    j = 0
    while j < aFloatTensors.GetNumberOfComponents():
        aFloatTensors.SetComponent(i,j,1)
        k = k + 1
        j = j + 1

    i = i + 1

dsa.AddArray(aFloatTensors)
del aFloatTensors
dsa.SetActiveTensors("aFloatTensors")
dsa.GetTensors("aFloatTensors")
dsa.GetTensors(foo)

dsa.RemoveArray("anotherFloatArray")

dsa2 = vtk.vtkDataSetAttributes()
dsa2.CopyAllocate(dsa,4,4)
dsa2.CopyData(dsa,0,0)
del dsa2

dsa3 = vtk.vtkDataSetAttributes()
dsa3.InterpolateAllocate(dsa,4,4)
dsa3.InterpolateEdge(dsa,0,0,1,0.5)

dsa4 = vtk.vtkDataSetAttributes()
dsa4.InterpolateAllocate(dsa,4,4)
dsa4.InterpolateTime(dsa,dsa3,0,0.5)
del dsa4

del dsa3
del dsa