Generate poly-data and point-scalars
(orientation,fillWith,factor)
| 60 | |
| 61 | |
| 62 | def generatePolyData(orientation,fillWith,factor): |
| 63 | """ |
| 64 | Generate poly-data and point-scalars |
| 65 | """ |
| 66 | poly = vtkPolyData() |
| 67 | pts = vtkPoints() |
| 68 | coords=[ (0,0,0),(1,0,0),(1,1,0),(0,1,0)] |
| 69 | for coord in coords: |
| 70 | pts.InsertNextPoint(coord[0],coord[1],coord[2]) |
| 71 | poly.SetPoints(pts) |
| 72 | |
| 73 | # Vertices at all corners |
| 74 | # two 1-point vertices and 1 2-point poly-vertex |
| 75 | vertices = [[0],[1],[2,3]] |
| 76 | verts = vtkCellArray() |
| 77 | for vertex in vertices: |
| 78 | InsertCell(verts,vertex,orientation) |
| 79 | poly.SetVerts(verts) |
| 80 | |
| 81 | # Lines at all sides of the quad |
| 82 | # two 2-point lines and 1 3-point line |
| 83 | edges = [ (0,1),(1,2),(2,3,0) ] |
| 84 | lines = vtkCellArray() |
| 85 | for edge in edges: |
| 86 | InsertCell(lines,edge,orientation) |
| 87 | poly.SetLines(lines) |
| 88 | |
| 89 | # Fill with one quad, two triangles or a triangle-strip |
| 90 | if fillWith=='quad': |
| 91 | quad = (0,1,2,3) |
| 92 | polys = vtkCellArray() |
| 93 | InsertCell(polys,quad,orientation) |
| 94 | poly.SetPolys(polys) |
| 95 | elif fillWith=='triangles': |
| 96 | triangles=[(0,1,3),(3,1,2)] |
| 97 | strips = vtkCellArray() |
| 98 | for triangle in triangles: |
| 99 | InsertCell(strips,triangle,orientation) |
| 100 | poly.SetStrips(strips) |
| 101 | elif fillWith=='strip': |
| 102 | strip=(0,1,3,2) |
| 103 | strips = vtkCellArray() |
| 104 | InsertCell(strips,strip,orientation) |
| 105 | poly.SetStrips(strips) |
| 106 | |
| 107 | # Scalars for contouring |
| 108 | values = [ 0.0, 0.5, 1.5, 1.0 ] |
| 109 | array=vtkDoubleArray() |
| 110 | for v in values: |
| 111 | array.InsertNextValue(factor*v) |
| 112 | poly.GetPointData().SetScalars(array) |
| 113 | |
| 114 | return poly |
| 115 | |
| 116 | def contourCase(poly,mode): |
| 117 | """ |
no test coverage detected