<div dir="ltr"><div><div><div></div>There are multiple choices.<br><br>You can create the same number of  cylinders as number of colors with height divided by number of colors.</div><div><br>a) then define transformation for 2 actors so each actor is above another <br>
</div><div><br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TransformActor">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/TransformActor</a><br><br><br></div><div>b) modify created polydata using transformFilter:<br>
</div><div><br><a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/TransformFilter">http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/TransformFilter</a><br><br></div><br></div>Google &quot;vtk example transformation&quot;<br>
<div><div><div><div><div><div><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Arindam</b> <span dir="ltr">&lt;<a href="mailto:arindam@triassicsolutions.com">arindam@triassicsolutions.com</a>&gt;</span><br>
Date: Tue, May 7, 2013 at 10:16 PM<br>Subject: Re: [vtkusers] How to color cylinder with different colors<br>To: Alex Malyushytskyy &lt;<a href="mailto:alexmalvtk@gmail.com">alexmalvtk@gmail.com</a>&gt;<br><br><br>
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>If i m combining 2 cylinder i m getting
      like following.How can i make cylinders on top of each other?<br>
      <br>
      <img src="" alt=""><div><div class="h5"><br>
      <br>
      On 5/8/2013 3:30 AM, Alex Malyushytskyy wrote:<br>
    </div></div></div><div><div class="h5">
    <blockquote type="cite">
      <div dir="ltr">Or you can create 3 cylinders (1 for each color) on
        top of each other if you want to follow your own approach.<br>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Tue, May 7, 2013 at 2:58 PM, Alex
          Malyushytskyy <span dir="ltr">&lt;<a href="mailto:alexmalvtk@gmail.com" target="_blank">alexmalvtk@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
            <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" target="_blank">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" target="_blank">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">
                <div>
                  <div>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>
                  </div>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
                  <div>
                    <div>
                      <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="" 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><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="" 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>
                    </div>
                  </div>
                  _______________________________________________<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>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a>

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>

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>

Follow this link to subscribe/unsubscribe:
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
    </blockquote>
    <br>
    <br>
    </div></div><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>ARINDAM SAHA<br>
                          Software Engineer</b></font><div class="im"><br>
                      Triassic Solutions Pvt. Ltd.<br>
                      <a href="tel:%28%2B91%29%20471%202700050" value="+914712700050" target="_blank">(+91) 471 2700050</a> (Office)<br></div>
                      9746145220 (Mobile)</font></span></td>
              </tr>
              <tr>
                <td valign="top" width="100%"><a href="http://www.triassicsolutions.com" target="_blank"><img src="" 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>
  </div>

</div><br></div></div></div></div></div></div></div>