<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi,<br>
<br>
I'm trying to display cubes with different sizes and each size is
assigned its own color, see code below.<br>
<br>
So far I have managed to correctly,<br>
<br>
Assign the colors but not the sizes ( this case is the code below )<br>
OR<br>
Assign the sizes but not the colors<br>
<br>
I can post the whole code if it helps. Any help on this would be
greatly appreciated.<br>
<br>
Thanks<br>
Alex.<br>
<br>
<small><small><font face="Courier New, Courier, monospace"> <font
color="#33cc00">// Setup scales</font><br>
vtkSmartPointer<vtkFloatArray> scales =
vtkSmartPointer<vtkFloatArray>::New();<br>
scales->SetName("scales");<br>
<font color="#33cc00">// setup colors</font><br>
vtkSmartPointer<vtkUnsignedCharArray> colors =
vtkSmartPointer<vtkUnsignedCharArray>::New();<br>
colors->SetName("colors");<br>
colors->SetNumberOfComponents(3);<br>
<br>
<font color="#3333ff">for</font> (<font color="#3333ff">int</font>
i = 0; i < ca.numCubes; i++)<br>
{<br>
points->InsertNextPoint(ca.cubeCentre[i].x
,ca.cubeCentre[i].y ,ca.cubeCentre[i].z);<br>
scales->InsertNextValue(ca.cubeLength[i]);<br>
<font color="#3333ff">for</font> ( <font
color="#3333ff">int</font> j = 0; j < numLengths; j++)<br>
{<br>
<font color="#3333ff">if</font> (ca.cubeLength[i]
== t_lengths[j])<br>
{<br>
colors->InsertNextTupleValue(rgb[j]);<br>
<font color="#3333ff">break;</font><br>
}<br>
}<br>
<br>
}<br>
<br>
vtkSmartPointer<vtkPolyData> polydata =
vtkSmartPointer<vtkPolyData>::New();<br>
polydata->SetPoints(points);<br>
polydata->GetPointData()->SetScalars(scales);<br>
polydata->GetPointData()->SetScalars(colors);<br>
<br>
vtkSmartPointer<vtkCubeSource> cubeSource =
vtkSmartPointer<vtkCubeSource>::New();<br>
<br>
vtkSmartPointer<vtkGlyph3D> glyph3D =
vtkSmartPointer<vtkGlyph3D>::New();<br>
glyph3D->SetColorModeToColorByScalar();<br>
glyph3D->SetSourceConnection(cubeSource->GetOutputPort());<br>
glyph3D->SetInput(polydata);<br>
glyph3D->Update();<br>
<br>
vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();<br>
mapper->SetInputConnection(glyph3D->GetOutputPort());<br>
<br>
<font color="#33cc00"> // create mapper</font><br>
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();<br>
actor->SetMapper(mapper);</font></small></small><br>
<br>
<br>
<br>
On 2/10/2012 1:01 PM, David Doria wrote:
<blockquote
cite="mid:CABDpjT=gfqvh7rU-d1CJFQrVrUvbKoM_kgqsfwVvWtDbBtn+wA@mail.gmail.com"
type="cite">
<pre wrap="">On Fri, Feb 10, 2012 at 5:34 AM, Alex Southern <a class="moz-txt-link-rfc2396E" href="mailto:mrapsouthern@gmail.com"><mrapsouthern@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Is possible to set the color of each glyph individually?
i.e. i'd like glyph's with different scaling to have different colors.
</pre>
</blockquote>
<pre wrap="">
<a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ColorGlyphs">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/ColorGlyphs</a>
David
</pre>
</blockquote>
<br>
</body>
</html>