[vtkusers] Assigning colors to scalars

Bruno da Silva de Oliveira bruno at esss.com.br
Mon Nov 7 09:36:29 EST 2005


You can't assign the scalars by hand; in the next update of the 
pipeline, you will lose this modification. Try to use a 
vtkAssignAttribute filter.

HTH,

Jens wrote:

>Hi Lise
>You seem to have the same problem that I have. 
>I can make a cell-attribute visible as long as I call 
>SetActiveScalars(attName) before I use Render() the first time.
>After I have called Render() once I can change the active scalars but get no 
>visible change after a Render()-call.
>
>Try to use pointers for vtk-instance.
>
>Am Montag, 7. November 2005 11:42 schrieb Lise Angell:
>  
>
>>..........
>>With:
>>	# allocate VTK structures
>>	vtk_field = vtk.vtkUnstructuredGrid()
>>	pts = vtk.vtkPoints()					# coordinates
>>	pts.SetNumberOfPoints(nno)
>>	data = vtk.vtkDoubleArray()				# data
>>	data.SetNumberOfValues(nno)
>>	data.SetName('Values')
>>
>>       [...]  # read node and coordinate info
>>    
>>
>
>You add a attribute array using 
>	myAttArray->SetArray(...);
>	vtk_field->AddArray(myAttArray);
>
>  
>
>>	vtk_field.SetPoints(pts)
>>	vtk_field.GetPointData().SetActiveScalars('Values')
>>
>>       [...]  # mount graphics stuff
>>
>>	lut = vtk.vtkLookupTable()
>>	lut.SetNumberOfColors(10)
>>	#lut.SetTableRange(scalar_range[0], scalar_range[1])
>>	lut.SetHueRange(0.0, 0.3)
>>	#lut.SetSaturationRange(0, 0)
>>	#lut.SetValueRange(0.2, 1.0)
>>	lut.Build()
>>
>>	mapper = visualize(renderer, vtk_field, nsd)
>>    
>>
>That should work... perhaps your scalar-field is wrong ?
>  
>
>>	#mapper.SetScalarRange(vtk_field.GetScalarRange())    # gives [0,1], wrong
>>	mapper.SetScalarRange(scalar_range) # contains min,max of the scalar
>>fields mapper.SetLookupTable(lut)
>>
>>       for each scalar field:
>>              [read field from file into vtk_field]
>>              vtk_field.Update()
>>		mapper.Update()
>>		renWin.Render()
>>    
>>
>
>	Greetings
>		Jens
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>  
>

-- 
Bruno da Silva de Oliveira
bruno at esss.com.br
ESSS - Engineering Simulation and Scientific Software
http://www.esss.com.br




More information about the vtkusers mailing list