[vtkusers] Re: Multiple scalars in vtkPolyData

Charles Boivin Charles.Boivin at rwdiwest.com
Tue Aug 24 11:35:53 EDT 2004


Hi Goodwin and Berk,

Thanks a lot to the both of you for your answers. They both made things
much clearer... and yes, it makes a lot more sense that way! :-) 

I will go ahead and work away on this... Should go a lot smoother now
that I know how to do things! :-) 

Thanks again,

Charles

>>> "Goodwin Lawlor" <goodwin.lawlor at ucd.ie> 08/23/04 05:21pm >>>
Hi Charles,

Have a look at the vtkFieldData class

> How do I load multiple scalars?
polydata->GetPointData->AddArray(vtkDataArray *array)
polydata->GetCellData->AddArray(vtkDataArray *array)

> And this also begs another question: how can I select which one I
want
> to display once I have been able to load several ones?
      polydata->GetPointData->SetActiveScalars   ( const char *   name 
)

      polydata->GetCellData->SetActiveScalars   ( const char *   name 
)


make sure to give you vtkDataArray a name...


hth


Goodwin

>>> Berk Geveci <berklist at nycap.rr.com> 08/24/04 06:48am >>>
Here is what you do:

* Create a sub-class of vtkDataArray for each scalar you have
* (optional) Assign them names with SetName()
* Add them to point or cell data with AddArray:
output->GetPointData()->AddArray(array)
* Set one of them to be the default scalars:
output->GetPointData()->SetActiveScalars(array_name)
Alternatively, you can add the default scalars with
output->GetPointData()->SetScalars() 
which internally (sort of) does the following:
output->GetPointData()->AddArray(array)
output->GetPointData()->SetActiveScalars(array)

vtkPLOT3DReader in IO does similar things.

To later set the default scalars in a VTK pipeline, use
vtkAssignAttribute. To set which scalar to color by, use
one of the methods in the mapper:
SetScalarModeToXXX()
ColorByComponent()
SelectColorArray()

There are also special methods in the lookup table.

-Berk




_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at:
<http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list