[vtkusers] Fwd: VTK coloring tube filter with connectivity information

Leslie Solorzano zloy.smiertniy2 at gmail.com
Tue Nov 8 04:23:04 EST 2016


Hello.

I hope I am going in the right direction here

I have a molecule I want to represent with spheres and tubes connecting
them. I'd like to color the tubes according to connectivity information.
Meaning that I have various disconnected regions or disconnected components
I would like to color differently per region. So far I have this, in python
and it works. I have commented what I tried to do to achieve this. The
variable data is a PolyData array that contains points, scalars and cells
with the connectivity information.

tube = vtk.vtkTubeFilter()

tube.SetInput(data)

tube.SetNumberOfSides(5);

#tube.SetVaryRadiusToVaryRadiusByAbsoluteScalar()

tube.SetVaryRadiusToVaryRadiusOff()

tube.SetRadius(0.1)


"""appendFilter = vtk.vtkAppendPolyData()

appendFilter.AddInputConnection(tube.GetOutputPort())

appendFilter.Update()


connectivityFilter = vtk.vtkPolyDataConnectivityFilter()

connectivityFilter.SetInputConnection(appendFilter.GetOutput())

connectivityFilter.ScalarConnectivityOn()

connectivityFilter.FullScalarConnectivityOn()

connectivityFilter.SetExtractionModeToAllRegions()

connectivityFilter.ColorRegionsOn()

connectivityFilter.Update()

"""

#print (connectivityFilter.GetNumberOfExtractedRegions())


tubeMapper = vtk.vtkPolyDataMapper()

tubeMapper.SetInputConnection(tube.GetOutputPort())

tubeMapper.Update()

And this is how it looks so far.

https://i.stack.imgur.com/XnmrO.png

The connectivity filter actually works and finds all the connected
components I just have not figured out how to color the tubes with a
different color each.

Thank you world
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161108/af156602/attachment.html>


More information about the vtkusers mailing list