Hi Lucas,<div><br></div><div>Changing to SetScalars() was correct.  The SetVectors() method is not for colors.</div><div><br></div><div>The bug in your code appears to be how you are filling in the array.  You need to instantiate the vtkUnsignedCharArray before the loop, not inside of the loop:</div>

<div><span style="font-family: &#39;courier new&#39;, monospace; "><br></span></div><div><span style="font-family: &#39;courier new&#39;, monospace; "><span class="Apple-style-span" style="font-family: arial; "><span style="font-family: &#39;courier new&#39;, monospace; ">#setup colors</span><br style="font-family: &#39;courier new&#39;, monospace; ">

<span style="font-family: &#39;courier new&#39;, monospace; ">Colors = vtk.vtkUnsignedCharArray()</span><br style="font-family: &#39;courier new&#39;, monospace; "><span style="font-family: &#39;courier new&#39;, monospace; ">Colors.SetNumberOfComponents(3)</span><br style="font-family: &#39;courier new&#39;, monospace; ">

<span style="font-family: &#39;courier new&#39;, monospace; ">Colors.SetName(&quot;Colors&quot;)</span></span></span></div><div><span style="font-family: &#39;courier new&#39;, monospace; "><span class="Apple-style-span" style="font-family: arial; "><span style="font-family: &#39;courier new&#39;, monospace; "><br>

</span></span></span></div><div><meta charset="utf-8"><span style="font-family: &#39;courier new&#39;, monospace; ">for i in range(255):</span><br style="font-family: &#39;courier new&#39;, monospace; "><span style="font-family: &#39;courier new&#39;, monospace; ">  for j in range(255):</span><br style="font-family: &#39;courier new&#39;, monospace; ">

<span style="font-family: &#39;courier new&#39;, monospace; ">    id = Points.InsertNextPoint(i, j, 1)</span><br style="font-family: &#39;courier new&#39;, monospace; "><span style="font-family: &#39;courier new&#39;, monospace; ">    Vertices.InsertNextCell(1)</span><br style="font-family: &#39;courier new&#39;, monospace; ">

<span style="font-family: &#39;courier new&#39;, monospace; ">    Vertices.InsertCellPoint(id)</span><font class="Apple-style-span" face="&#39;courier new&#39;, monospace"><br></font><span style="font-family: &#39;courier new&#39;, monospace; ">    Colors.InsertNextTuple3(255,i,j)</span><br>

<br></div><div>They way you had written the code, you were creating 255 different arrays and setting only the first tuple of each one.</div><div><br></div><div>  - David</div><div><br></div><div><br><div class="gmail_quote">

On Wed, Feb 2, 2011 at 2:27 PM, Lucas <span dir="ltr">&lt;<a href="mailto:wsacul@gmail.com">wsacul@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I&#39;d like to render a point cloud with points individually colored, so I combined the example <a href="http://www.vtk.org/Wiki/VTK/Examples/Python/TriangleColoredPoints" target="_blank">http://www.vtk.org/Wiki/VTK/Examples/Python/TriangleColoredPoints</a> with others that sets up the interactive render window.  But the points are all white, unless I call SetColor which gives them all the same color.  What am I missing?<br>


<br><span style="font-family:courier new,monospace">import vtk</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># create a rendering window and renderer</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">ren = vtk.vtkRenderer()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">renWin = vtk.vtkRenderWindow()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">renWin.AddRenderer(ren)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">renWin.SetSize(400,400)</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># create a renderwindowinteractor</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">iren = vtk.vtkRenderWindowInteractor()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">iren.SetRenderWindow(renWin)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#setup points and vertices</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">Points = vtk.vtkPoints()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">Vertices = vtk.vtkCellArray()</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">for i in range(255):</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">  for j in range(255):</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    id = Points.InsertNextPoint(i, j, 1)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    Vertices.InsertNextCell(1)</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    Vertices.InsertCellPoint(id)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    #setup colors</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    Colors = vtk.vtkUnsignedCharArray()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    Colors.SetNumberOfComponents(3)</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">    Colors.SetName(&quot;Colors&quot;)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    Colors.InsertNextTuple3(255,i,j)</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">polydata = vtk.vtkPolyData()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">polydata.SetPoints(Points)</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">polydata.SetVerts(Vertices)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">polydata.GetPointData().SetVectors(Colors)</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">polydata.Modified()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">polydata.Update()</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">######</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">mapper = vtk.vtkPolyDataMapper()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">mapper.SetInput(polydata)</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">actor = vtk.vtkActor()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">actor.SetMapper(mapper)</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">ren.AddActor(actor)</span><br style="font-family:courier new,monospace">


<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"># enable user interface interactor</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">renWin.Render()</span><br style="font-family:courier new,monospace">


<span style="font-family:courier new,monospace">iren.Initialize()</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">iren.Start()</span><br>               <br><br>Replacing SetVectors() with SetScalars produces some point coloring, but the colors seem random.<br>


<br>I&#39;m using vtk 5.4.2 and Python 2.6.6 on Ubuntu.<br><br>Thanks,<br><font color="#888888"><br>Lucas<br>
</font><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>