<div dir="ltr"><div class="gmail_quote"><div dir="ltr">Hello.<div><br></div><div>I hope I am going in the right direction here </div><div><br></div><div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">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 <code style="margin:0px;padding:1px 5px;border:0px;font-size:13px;font-family:consolas,menlo,monaco,"lucida console","liberation mono","dejavu sans mono","bitstream vera sans mono","courier new",monospace,sans-serif;background-color:rgb(239,240,241);white-space:pre-wrap">data</code> is a PolyData array that contains points, scalars and cells with the connectivity information.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tube = vtk.vtkTubeFilter()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tube.SetInput(data)</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tube.SetNumberOfSides(5);</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">#tube.SetVaryRadiusToVaryRadiusByAbsoluteScalar()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tube.SetVaryRadiusToVaryRadiusOff()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tube.SetRadius(0.1)</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px"><br></span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">"""appendFilter = vtk.vtkAppendPolyData()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">appendFilter.AddInputConnection(tube.GetOutputPort())</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">appendFilter.Update()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px"><br></span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter = vtk.vtkPolyDataConnectivityFilter()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.SetInputConnection(appendFilter.GetOutput())</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.ScalarConnectivityOn()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.FullScalarConnectivityOn()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.SetExtractionModeToAllRegions()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.ColorRegionsOn()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">connectivityFilter.Update()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">"""</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">#print (connectivityFilter.GetNumberOfExtractedRegions())</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px"><br></span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tubeMapper = vtk.vtkPolyDataMapper()</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tubeMapper.SetInputConnection(tube.GetOutputPort())</span></font></p><p style="margin:0px 0px 1em;padding:0px;border:0px;clear:both"><font color="#242729" face="arial, helvetica neue, helvetica, sans-serif"><span style="font-size:15px">tubeMapper.Update()</span></font></p><div><br></div><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">And this is how it looks so far.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif"><a href="https://i.stack.imgur.com/XnmrO.png" target="_blank">https://i.stack.imgur.com/<wbr>XnmrO.png</a><br></p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;color:rgb(36,39,41);font-family:arial,"helvetica neue",helvetica,sans-serif">Thank you world</p></div></div></div>
</div>