<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
<br>
On 10/25/2010 08:42 PM, David Doria wrote:
<blockquote
cite="mid:AANLkTimtn_8AoSM6PVLE5reiMvfjKq+HaTXsa3cxXw4f@mail.gmail.com"
type="cite">
<div>
<div class="gmail_quote">On Mon, Oct 25, 2010 at 6:04 PM, Arnaud
GELAS <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:arnaud_gelas@hms.harvard.edu">arnaud_gelas@hms.harvard.edu</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"> Hi all,<br>
<br>
I would like to color some PolyData depending on different
kind of information/data.<br>
<br>
For each polydata, I have an initial color (chosen by the
user), and N values (volumes, surface, etc...), and I
would like to efficiently switch from the chosen color, to
a color which represents the value.<br>
<ul>
<li>To store these values (computed externally), which
vtkPolyData's data container should I use? <br>
Note that I have about 10k meshes with ~500 triangles,
and about 10 computed values, and I'd like each
polydata to store its N value.<br>
</li>
<ul>
<li>vtkFieldData?</li>
<li>vtkCellData?</li>
<li>vtkPointData?</li>
</ul>
<li>How can I efficiently switch from rendering with
colors which would represent one value (e.g. volume),
to colors which would represent another one (e.g.
surface), then to the original color (the one chosen
by the user)?<br>
</li>
</ul>
<br>
Thanks in advance,<br>
Arnaud</div>
</blockquote>
<div><br>
</div>
Arnaud,
<div><br>
</div>
<div>The choice of Field,Cell, or Point data depends strictly
on where these colors are defined. Are they defined at the
points of the meshes or the triangles? If its at the points
(i.e. each point has a color), you'll want to use PointData.
If it's at the triangles (i.e. each triangle has a color)
you want to use CellData. FieldData is for "global
information" about the whole data set typically, so you
wouldn't want to use that here.</div>
<div><br>
</div>
<div>Lets go forward assuming that the colors are defined on
the points. You would want to do this</div>
<div><br>
</div>
<div>vtkUnsignedCharArray* colors1
= vtkUnsignedCharArray::New();</div>
<div>colors1->SetName("colors1");</div>
<div>... fill the colors array</div>
<div><br>
</div>
<div>
<div>vtkUnsignedCharArray* colors2
= vtkUnsignedCharArray::New();</div>
<div>colors2->SetName("colors2");</div>
<div>... fill the colors array</div>
</div>
<div><br>
</div>
<div>polydata->GetPointData()->AddArray(colors1);</div>
<div>polydata->GetPointData()->AddArray(colors2);</div>
<div><br>
</div>
<div>Now here is the key. To select which one is used, use
this:</div>
<div><br>
</div>
<div>polydata->GetPointData()->SetActiveScalars("colors1");</div>
<div><br>
</div>
<div>I think that is what you were looking for? Give it a try
and let us know if it wasn't.</div>
<div><br>
</div>
<div>David</div>
</div>
</div>
</blockquote>
<br>
David,<br>
<br>
It works fine with PointData and CellData; however I could not
figure out how to proceed with FieldData (There is no method
SetActive at this level in the hierarchy :-/, and my values are
attributes to one mesh (constant for a single mesh).<br>
Is there a way to proceed with vtkFieldData?<br>
<br>
---<br>
<br>
If not, I can use CellData instead. In this case, I can switch from
active scalar array to original mesh colors by setting it to one
that does not belong to the mesh:<br>
<br>
polydata->GetCellData->SetActiveScalars( "" );<br>
<br>
Is there a better way to proceed?<br>
<br>
Thanks,<br>
Arnaud<br>
<br>
<br>
</body>
</html>