Create a renderer, actor, mapper to contour the polydata poly : polydata to contour mode : scalar-mode for BPDCF
(poly,mode)
| 114 | return poly |
| 115 | |
| 116 | def contourCase(poly,mode): |
| 117 | """ |
| 118 | Create a renderer, actor, mapper to contour the polydata |
| 119 | poly : polydata to contour |
| 120 | mode : scalar-mode for BPDCF |
| 121 | """ |
| 122 | # Prepare an array of point-data scalars |
| 123 | |
| 124 | # Perform the contouring. Note that we need to set scalar |
| 125 | # mode to index because line cells do not get contour values |
| 126 | # even if scalar mode is set to value. |
| 127 | valueRange=poly.GetPointData().GetScalars().GetRange() |
| 128 | num=5 |
| 129 | bpdcf = vtkBandedPolyDataContourFilter() |
| 130 | bpdcf.SetInputData(poly) |
| 131 | bpdcf.GenerateValues( num, valueRange[0],valueRange[1] ) |
| 132 | bpdcf.GenerateContourEdgesOff() |
| 133 | if mode == 'index': |
| 134 | bpdcf.SetScalarModeToIndex() |
| 135 | elif mode == 'value': |
| 136 | bpdcf.SetScalarModeToValue() |
| 137 | bpdcf.Update() |
| 138 | |
| 139 | # Shrink all cells somewhat so the contouring of edges can |
| 140 | # be seen better |
| 141 | sf = vtkShrinkFilter() |
| 142 | sf.SetShrinkFactor(0.90) |
| 143 | sf.SetInputConnection( bpdcf.GetOutputPort()) |
| 144 | |
| 145 | # Mapper shows contour index values |
| 146 | m = vtkDataSetMapper() |
| 147 | m.SetInputConnection(sf.GetOutputPort()) |
| 148 | m.SetScalarModeToUseCellData() |
| 149 | m.SetScalarRange(bpdcf.GetOutput().GetCellData().GetArray('Scalars').GetRange()) |
| 150 | |
| 151 | a = vtkActor() |
| 152 | a.SetMapper(m) |
| 153 | |
| 154 | return a |
| 155 | |
| 156 | # four contouring cases to test |
| 157 | cases = [ (True, 'quad', 100.0, [0.0,0.5,0.5,1.0]), # 1,5 : upper-left |
no test coverage detected