<div dir="ltr"><div><div>Your cylinder source produces  polydata.<br></div><br>Common ways to define color for polydata in vtk  for cells or nodes ( in your case you want cells ) <br></div>is either define color as rgb values in a char array:<br>
<div><div><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/TriangleSolidColor">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/TriangleSolidColor</a><br><br>or as a value which later can be mapped using LookUp table:<br>
<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ColorCells">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/ColorCells</a><br><br></div><div>You will have to make sure your cylinder has at least 3 cells along the axis to obtain desired results.<br>
<br></div><div>Alex<br></div><div><br><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, May 6, 2013 at 10:03 PM, Divya <span dir="ltr">&lt;<a href="mailto:divya@triassicsolutions.com" target="_blank">divya@triassicsolutions.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div text="#000000" bgcolor="#FFFFFF">
    Dear All,<br>
    <br>
    I want to color a cylinder like the image attached. I have tried
    combining 2 different cylinder source with different colors but I am
    getting the following result<br>
    <img src="cid:part1.06010803.00090407@triassicsolutions.com" alt=""><br>
    <br>
     Any help will be greatly appreciated.<br>
    <br>
    My source code is as follows:<br>
    <br>
    vtkCylinderSource catheter = vtkCylinderSource.New();<br>
                catheter.SetRadius(1);<br>
                catheter.SetHeight(15.0);<br>
                catheter.Update();<br>
                //catheter.CappingOn();<br>
    <br>
                vtkFloatArray cylColor1 = vtkFloatArray.New();<br>
                cylColor1.SetNumberOfComponents(3);<br>
                cylColor1.SetName(&quot;Color1&quot;);<br>
    <br>
                for (int i = 0; i &lt;
    catheter.GetOutput().GetNumberOfPoints(); i++)<br>
                {<br>
                    cylColor1.InsertTuple3(i, 255, 0, 0);<br>
                }<br>
               
    catheter.GetOutput().GetPointData().SetScalars(cylColor1);<br>
    <br>
                vtkCylinderSource catheter2 = vtkCylinderSource.New();<br>
                catheter2.SetRadius(1);<br>
                catheter2.SetHeight(10.0);<br>
                catheter2.Update();<br>
                //catheter2.CappingOn();<br>
    <br>
                vtkFloatArray cylColor = vtkFloatArray.New();<br>
                cylColor.SetNumberOfComponents(3);<br>
                cylColor.SetName(&quot;Color2&quot;);<br>
    <br>
                for (int i = 0; i &lt;
    catheter2.GetOutput().GetNumberOfPoints(); i++)<br>
                {<br>
                    cylColor.InsertTuple3(i, 0, 0, 255);<br>
                }<br>
               
    catheter2.GetOutput().GetPointData().SetScalars(cylColor);<br>
    <br>
                // append both polydata sets<br>
                vtkAppendPolyData apd = new vtkAppendPolyData();<br>
                apd.AddInput(catheter.GetOutput());<br>
                apd.AddInput(catheter2.GetOutput());<br>
                apd.Update();<br>
    <br>
                ////vtkCleanPolyData cleanFilter =
    vtkCleanPolyData.New();<br>
                ////cleanFilter.SetInput(apd.GetOutput());<br>
                ////cleanFilter.Update();<br>
    <br>
                vtkPolyDataMapper catheterMapper =
    vtkPolyDataMapper.New();<br>
                catheterMapper.SetInputConnection(apd.GetOutputPort());<br>
                catheterActor.SetMapper(catheterMapper);<span class="HOEnZb"><font color="#888888"><br>
    <br>
    <div>-- <br>
      <br>
      <font color="#262626" face="calibri,sans serif,arial">
        <div>
          <table border="0" cellpadding="0" cellspacing="0">
            <tbody>
              <tr>
                <td colspan="2" valign="top" width="230"><span style="line-height:100%"><font color="#262626" face="calibri,sans serif,arial">Regards,<br>
                      <font color="#5C83B4"><b>DIVYA SADANANDAN<br>
                          Software Engineer</b></font><br>
                      Triassic Solutions Pvt. Ltd.<br>
                      <a href="tel:%28%2B91%29%20471%202700050" value="+914712700050" target="_blank">(+91) 471 2700050</a> (Office)<br>
                      <a href="tel:7736382699" value="+17736382699" target="_blank">7736382699</a> (Mobile)</font></span></td>
              </tr>
              <tr>
                <td valign="top" width="100%"><a href="http://www.triassicsolutions.com" target="_blank"><img src="cid:part2.07010205.05000105@triassicsolutions.com" border="0"></a></td>
              </tr>
              <tr>
                <td><span style="line-height:75%"><font color="#1F497D" face="calibri,sans serif,arial"><br>
                      Disclaimer: This e-mail contains confidential
                      information intended solely for the intended
                      recipient. If you are not the intended recipient,
                      please notify the sender by e-mail and delete this
                      email permanently from your records. Do not copy
                      or distribute this e-mail and any such actions are
                      unlawful. Except where this email is sent in the
                      usual course of business, the views expressed in
                      this email are those of the sender. Triassic
                      Solutions Pvt. Ltd. accepts no responsibility for
                      any indirect damage or loss suffered by reason of
                      inaccuracy or incorrectness of the information in
                      this email.</font></span><br>
                  <span><font color="#33CC00" face="calibri,sans serif,arial">+ Please consider
                      our environment before printing this e-mail.</font></span></td>
              </tr>
            </tbody>
          </table>
        </div>
      </font></div>
  </font></span></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></div>