[vtkusers] coloring PolyDataMappers in python

Tudor Achim tachim at cs.stanford.edu
Tue Aug 4 14:15:50 EDT 2015


No, I'd like the entire mesh to be one color (and opacity).

On Tue, Aug 4, 2015 at 2:04 PM, Cory Quammen <cory.quammen at kitware.com>
wrote:

> Are you trying to color map a particular data array in the contour?
>
> On Mon, Aug 3, 2015 at 3:43 PM, Tudor Achim <tachim at cs.stanford.edu>
> wrote:
>
>> Hi all,
>> I have a quick question about coloring vtkPolyMappers. I have the
>> following code:
>>
>> for cluster_ind in ...:
>> threshold = vtk.vtkImageThreshold()
>> threshold.SetInputConnection(importer.GetOutputPort())
>> threshold.ThresholdBetween(cluster_ind-0.1, cluster_ind+0.1)
>> threshold.ReplaceInOn()
>> threshold.SetInValue(0)
>> threshold.ReplaceOutOn()
>> threshold.SetOutValue(1)
>> threshold.Update()
>>
>> dmc = vtk.vtkDiscreteMarchingCubes()
>> dmc.SetInputConnection(threshold.GetOutputPort())
>> dmc.GenerateValues(1, 1, 1)
>> dmc.Update()
>>
>> mapper = vtk.vtkPolyDataMapper()
>> mapper.SetInputConnection(dmc.GetOutputPort())
>>
>> lut = vtk.vtkLookupTable()
>> lut.SetNumberOfTableValues(2)
>> lut.SetTableValue(0, 0, 0, 255)
>> lut.SetTableValue(1, *rgb_cluster_mapping[cluster_ind])
>> lut.Build()
>> mapper.SetLookupTable(lut)
>> mapper.SetScalarModeToUseCellData()
>>
>> However, when I run it only one of the mappers is colored correctly; the
>> other one is just rendered as black. I can tell that it's rendered black
>> because when I spin around the clusters in my viewer I can see it
>> obstructing the other clusters. The intended colors are (0, 255, 0) and
>> (88, 86, 214) (that's what's in rgb_cluster_mapping for these clusters).
>>
>> Any ideas?
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/vtkusers
>>
>>
>
>
> --
> Cory Quammen
> R&D Engineer
> Kitware, Inc.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150804/5fbcd153/attachment.html>


More information about the vtkusers mailing list