<div>The mapper defaults to the color by the array that is marked as the active scalars, but you can tell it to use any array you want. See the doxygen for vtkMapper::SelectColorArray()</div>
<div><br clear="all">Dave DeMarle<br>Kitware, Inc.<br>R&D Engineer<br>28 Corporate Drive<br>Clifton Park, NY 12065-8662<br>Phone: 518-371-3971 x109<br><br><br></div>
<div class="gmail_quote">On Tue, Dec 8, 2009 at 4:29 PM, Marcus Thamson <span dir="ltr"><<a href="mailto:markie_thomson@yahoo.de">markie_thomson@yahoo.de</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top">Dear All,<br><br>Is it possible to set both a varying radius *and* independently varying color (scalar, RGB triples...) when using vtkTubeFilter? (i.e. with two sets of scalar arrays)<br><br>I have a running code using SetVaryRadiusToVaryRadiusByScalar (with scalar values added to the input vtkPolyData with "...->GetPointData()->SetScalars(...)").<br>
<br>The coloring of the resulting tube is also then based on these same scalars...<br>I would have liked to set the RGB values for each segment of the tube using another vtkUnsignedCharArray of RGB triples, as I do for surfaces.<br>
<br>An excerpt of the (fairly unoriginal) code is as follows:<br><br>//------------------<br>...<br><br>// v: Pointer to array of tube path coordinates<br>// nV: Length of v<br><br>// Tube path points<br>vtkSmartPointer<vtkPoints> tpoints = vtkSmartPointer<vtkPoints>::New();<br>
for(i=0; i<nV; i++) tpoints->InsertPoint(i,v[i],v[nV+i],v[2*nV+i]);<br><br>// and (somewhat trivial) lines<br>vtkSmartPointer<vtkCellArray> tlines = vtkSmartPointer<vtkCellArray>::New();<br>tlines->InsertNextCell(nV);<br>
for (i=0; i < nV; i++) tlines->InsertCellPoint(i);<br><br>// Scalars for tube radius (from array 'trad')<br>vtkSmartPointer<vtkDoubleArray> tscalars = vtkSmartPointer<vtkDoubleArray>::New();<br>
tscalars->SetNumberOfTuples(nV);<br>
for (i=0 ;i<nV ; i++) tscalars->SetTuple1(i,trad[i]);<br>tscalars->GetRange(tscalar_range);<br><br>vtkSmartPointer<vtkPolyData> tprofile = vtkSmartPointer<vtkPolyData>::New();<br>tprofile->SetPoints((vtkPoints *)(tpoints));<br>
tprofile->SetLines(tlines);<br>tprofile->GetPointData()->SetScalars(tscalars);<br>tprofile->BuildLinks();<br><br>vtkSmartPointer<vtkTubeFilter> tube = vtkSmartPointer<vtkTubeFilter>::New();<br>tube->SetInput(tprofile);<br>
tube->SetVaryRadiusToVaryRadiusByScalar();<br>tube->SetRadius(tscalar_range[0]);<br>tube->SetRadiusFactor(tscalar_range[1]/tscalar_range[0]);<br><br>vtkSmartPointer<vtkPolyDataMapper> tubeMapper = vtkSmartPointer<vtkPolyDataMapper>::New();<br>
tubeMapper->SetInput(tube->GetOutput());<br>surfActor->SetMapper(tubeMapper);<br>...<br>//------------------<br><br>Many thanks, MT<br>
<div class="hm"><br><br><br></div></td></tr></tbody></table>
<div class="hm"><br>__________________________________________________<br>Do You Yahoo!?<br>Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. <br><a href="http://mail.yahoo.com/" target="_blank">http://mail.yahoo.com</a> </div>
<br>_______________________________________________<br>Powered by <a href="http://www.kitware.com/" target="_blank">www.kitware.com</a><br><br>Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>