[vtkusers] Coloring PolyDatas depending on various (externally computed) values
Arnaud GELAS
arnaud_gelas at hms.harvard.edu
Tue Oct 26 10:05:04 EDT 2010
On 10/26/2010 10:02 AM, David Doria wrote:
>
> David,
>
> 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).
> Is there a way to proceed with vtkFieldData?
>
> ---
>
> 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:
>
> polydata->GetCellData->SetActiveScalars( "" );
>
> Is there a better way to proceed?
>
> Thanks,
> Arnaud
>
>
> The reason that you can't set active scalars on the FieldData is
> probably that it doesn't always make sense to apply arrays from the
> FieldData to the data because it is not necessarily "aligned" (the
> same length).
>
> Since it is a single color per object/mesh, can you color the actor
> based on the field data value (the 0th value in the array)?
>
> Something like:
>
> vtkFloatArray* colorArray
> = vtkFloatArray::SafeDownCast(polydata->GetFieldData()->GetArray("color1"));
> float color[3];
> colorArray->GetTupleValue(0, color);
>
> actor->GetProperty()->SetColor(color);
>
> ?
>
> David
I have tried to set a color (see attached code), but I still need to
remove the active scalar array ?
Arnaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101026/417d40bc/attachment.htm>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101026/417d40bc/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dataandcolor.cxx
Type: text/x-c++src
Size: 2085 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20101026/417d40bc/attachment.cxx>
More information about the vtkusers
mailing list