MCPcopy Create free account
hub / github.com/Kitware/VTK / contourCase

Function contourCase

Filters/Modeling/Testing/Python/TestBandedContourFilter2.py:116–154  ·  view source on GitHub ↗

Create a renderer, actor, mapper to contour the polydata poly : polydata to contour mode : scalar-mode for BPDCF

(poly,mode)

Source from the content-addressed store, hash-verified

114 return poly
115
116def 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
157cases = [ (True, 'quad', 100.0, [0.0,0.5,0.5,1.0]), # 1,5 : upper-left

Callers 1

Calls 15

vtkDataSetMapperClass · 0.85
vtkActorClass · 0.50
GetRangeMethod · 0.45
GetScalarsMethod · 0.45
GetPointDataMethod · 0.45
SetInputDataMethod · 0.45
GenerateValuesMethod · 0.45
UpdateMethod · 0.45
SetInputConnectionMethod · 0.45
GetOutputPortMethod · 0.45
SetScalarRangeMethod · 0.45
GetArrayMethod · 0.45

Tested by

no test coverage detected