|
20 | 20 | import vtkmodules.vtkRenderingFreeType
|
21 | 21 | import vtkmodules.vtkRenderingOpenGL2
|
22 | 22 | from vtkmodules.util.misc import vtkGetDataRoot
|
| 23 | +import math |
| 24 | + |
23 | 25 | VTK_DATA_ROOT = vtkGetDataRoot()
|
24 | 26 |
|
25 | 27 | #
|
|
83 | 85 | pressureGradient = vtkHedgeHog()
|
84 | 86 | pressureGradient.SetInputConnection(probe_gradient.GetOutputPort())
|
85 | 87 | pressureGradient.SetScaleFactor(0.00002)
|
86 |
| -def ExecuteDot (__vtk__temp0=0,__vtk__temp1=0): |
87 |
| - # proc for ProgrammableAttributeDataFilter. Note the use of "double()" |
88 |
| - # in the calculations. This protects us from Python using ints and |
89 |
| - # overflowing. |
| 88 | +def ExecuteDot(): |
| 89 | + # proc for ProgrammableAttributeDataFilter. |
90 | 90 | inputs = dotProduct.GetInputList()
|
91 | 91 | input0 = inputs.GetDataSet(0)
|
92 | 92 | input1 = inputs.GetDataSet(1)
|
93 | 93 | numPts = input0.GetNumberOfPoints()
|
94 | 94 | vectors0 = input0.GetPointData().GetVectors()
|
95 | 95 | vectors1 = input1.GetPointData().GetVectors()
|
96 | 96 | scalars = vtkFloatArray()
|
97 |
| - i = 0 |
98 |
| - while i < numPts: |
99 |
| - v0 = vectors0.GetTuple3(i) |
100 |
| - v1 = vectors1.GetTuple3(i) |
101 |
| - v0x = lindex(v0,0) |
102 |
| - v0y = lindex(v0,1) |
103 |
| - v0z = lindex(v0,2) |
104 |
| - v1x = lindex(v1,0) |
105 |
| - v1y = lindex(v1,1) |
106 |
| - v1z = lindex(v1,2) |
107 |
| - l0 = expr.expr(globals(), locals(),["double","(","v0x",")*","double","(","v0x",")","+","double","(","v0y",")*","double","(","v0y",")","+","double","(","v0z",")*","double","(","v0z",")"]) |
108 |
| - l1 = expr.expr(globals(), locals(),["double","(","v1x",")*","double","(","v1x",")","+","double","(","v1y",")*","double","(","v1y",")","+","double","(","v1z",")*","double","(","v1z",")"]) |
109 |
| - l0 = expr.expr(globals(), locals(),["sqrt","(","double","(","l0","))"]) |
110 |
| - l1 = expr.expr(globals(), locals(),["sqrt","(","double","(","l1","))"]) |
111 |
| - if (l0 > 0.0 and l1 > 0.0): |
112 |
| - d = expr.expr(globals(), locals(),["(","double","(","v0x",")*","double","(","v1x",")","+","double","(","v0y",")*","double","(","v1y",")","+","double","(","v0z",")*","double","(","v1z","))/(","l0","*","l1",")"]) |
113 |
| - pass |
| 97 | + for i in range(numPts): |
| 98 | + v0x,v0y,v0z = vectors0.GetTuple3(i) |
| 99 | + v1x,v1y,v1z = vectors1.GetTuple3(i) |
| 100 | + l0 = math.sqrt(v0x*v0x + v0y*v0y + v0z*v0z) |
| 101 | + l1 = math.sqrt(v1x*v1x + v1y*v1y + v1z*v1z) |
| 102 | + if l0 > 0.0 and l1 > 0.0: |
| 103 | + d = (v0x*v1x + v0y*v1y + v0z*v1z)/(l0*l1) |
114 | 104 | else:
|
115 | 105 | d = 0.0
|
116 |
| - pass |
117 | 106 | scalars.InsertValue(i,d)
|
118 |
| - i = i + 1 |
119 | 107 |
|
120 | 108 | dotProduct.GetOutput().GetPointData().SetScalars(scalars)
|
121 |
| - del scalars |
122 | 109 |
|
123 | 110 | #
|
124 | 111 | # We use the ProgrammableAttributeDataFilter to compute the cosine
|
|
0 commit comments