It should be possible to modify the scalars the same way as the points:<div><br></div><div>points-&gt;SetPoint(idx, point);</div><div>colors-&gt;SetTupleValue(idx, color);</div><div>glypher-&gt;Modified();</div><div><br></div>

<div>The vtkCellArray isn&#39;t necessary (but somehow polydata with no cells goes against my sense of aesthetics).</div><div><br></div><div>  David<br><br><div class="gmail_quote">On Thu, Nov 25, 2010 at 7:07 PM, Gib Bogle <span dir="ltr">&lt;<a href="mailto:g.bogle@auckland.ac.nz">g.bogle@auckland.ac.nz</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">It turns out there was a difference between what I was doing and the wiki example code, one of those seemingly insignificant details that are actually important.<br>


<br>
I had<br>
  glypher-&gt;SetScaleFactor(1.0);<br>
and the wiki code has<br>
  glypher-&gt;ScalingOff();<br>
With that change it works (although I don&#39;t know why).<br>
<br>
I have a final (I hope!) question.  I now want to selectively change the color of glyphs.  I know how to change the position of the point indexed by idx:<br>
  points-&gt;SetPoint(idx,x,y,z);<br>
  glypher-&gt;Modified();<br>
<br>
Presumably something very similar is needed to change the color of this glyph, but I don&#39;t know how to access the array that holds the colors, which was initialized with:<br>
  input-&gt;GetPointData()-&gt;SetScalars(colors);<br>
<br>
Can someone help me over this last hurdle?<div><div></div><div class="h5"><br>
<br>
<br>
On 26/11/2010 12:42 p.m., Gib Bogle wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;ve been trying to follow David Gobbi&#39;s suggestion about coloring the glyphs<br>
that I am now using to render my squares with. The hints he provided were not<br>
enough for me to get it working, so I hunted around and found the wiki example<br>
<a href="http://www.itk.org/Wiki/VTK/Examples/Cxx/Visualization/ColorGlyphs" target="_blank">http://www.itk.org/Wiki/VTK/Examples/Cxx/Visualization/ColorGlyphs</a><br>
This works fine, so I thought I could just follow the same path. It doesn&#39;t work<br>
for me, and I&#39;m guessing that it&#39;s because I&#39;m using a vtkPolyData that contains<br>
both vtkPoints and vtkCellArray. David advised me to use<br>
input-&gt;GetPointData()-&gt;AddArray(...)<br>
but I couldn&#39;t see how to implement this. My code is shown below. What am I<br>
missing? (This code doesn&#39;t display the squares at all, unless I comment out<br>
input-&gt;GetPointData()-&gt;SetScalars(colors).)<br>
I apologize for the ignorance I&#39;m displaying - I don&#39;t understand why it&#39;s<br>
necessary to use the vtkCellArray, for example.<br>
<br>
points = vtkSmartPointer&lt;vtkPoints&gt;::New();<br>
vtkSmartPointer&lt;vtkCellArray&gt; dummycells = vtkSmartPointer&lt;vtkCellArray&gt;::New();<br>
points-&gt;SetNumberOfPoints(npos); // number of squares<br>
dummycells-&gt;InsertNextCell(npos);<br>
colors = vtkSmartPointer&lt;vtkUnsignedCharArray&gt;::New();<br>
colors-&gt;SetName(&quot;colors&quot;);<br>
colors-&gt;SetNumberOfComponents(3);<br>
unsigned char g[3] = {0,255,0};<br>
for (int ipos=0; ipos&lt;npos; ipos++) {<br>
points-&gt;SetPoint(ipos, x, y, z);<br>
dummycells-&gt;InsertCellPoint(ipos);<br>
colors-&gt;InsertNextTupleValue(g);<br>
}<br>
input = vtkSmartPointer&lt;vtkPolyData&gt;::New();<br>
input-&gt;SetPoints(points);<br>
input-&gt;SetVerts(dummycells);<br>
input-&gt;GetPointData()-&gt;SetScalars(colors);<br>
glypher = vtkSmartPointer&lt;vtkGlyph3D&gt;::New();<br>
glypher-&gt;SetInput(input);<br>
glypher-&gt;SetSource(polygonPolyData);<br>
glypher-&gt;SetScaleFactor(1.0);<br>
glypher-&gt;SetColorModeToColorByScalar();<br>
// glypher-&gt;SetInputArrayToProcess(3, 0, 0, 0, &quot;colors&quot;);<br>
glypher-&gt;Update();<br>
squareMapper = vtkPolyDataMapper::New();<br>
squareMapper-&gt;SetInputConnection(glypher-&gt;GetOutputPort());<br>
glactor = vtkActor::New();<br>
glactor-&gt;SetMapper(squareMapper);<br>
glactor-&gt;GetProperty()-&gt;SetAmbient(0.5);<br>
glactor-&gt;GetProperty()-&gt;SetDiffuse(0.2);<br>
glactor-&gt;GetProperty()-&gt;SetSpecular(0.5);<br>
ren-&gt;AddActor(glactor);<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<br>
<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:<br>
<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>
</blockquote>
_______________________________________________<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>
</div></div></blockquote></div><br></div>