<div><div class="gmail_quote">On Mon, Oct 25, 2010 at 6:04 PM, Arnaud GELAS <span dir="ltr"><<a href="mailto:arnaud_gelas@hms.harvard.edu">arnaud_gelas@hms.harvard.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;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>