[vtkusers] Setting multiple scalars to a dataset
Berk Geveci
berk.geveci at kitware.com
Fri May 31 08:33:50 EDT 2002
Read your data into 7 different arrays (assuming there are 7 scalar
values, if some are vectors, read them into separate 3 component
arrays). You can freely mark any of those as the active scalars,
vectors (only 3 component arrays) etc. If you are using VTK 4.0 or
later that is. Check my few previous postings, the examples:
VTK/Examples/DataManipulation/Tcl/Arrays.tcl
VTK/Examples/DataManipulation/Tcl/FinancialField.tcl
and the latest User's Guide for more information.
-Berk
On Fri, 2002-05-31 at 08:12, Steve Boyd wrote:
> Hello,
>
> I have made a reader class that reads my FE data results and generates a
> vtkUnstructuredGrid dataset, including associated scalars and vectors
> (from the FE output). For example, I read stress scalar results into a
> vtkFloatArray (7 components), but I'm not sure how to set this data to
> the vtkUnstructuredGrid dataset. In the tidbit of code, only the first
> component becomes 'active' (as expected after reading some e-mails in
> the archive).
>
> My question: What is the best way to set the scalar data? Do I have to
> set a 1 component array in my reader source, or can I set all 7
> components and then 'activate' the component for filters further down
> the pipeline? I don't want to have to re-read my entire input file
> every time I look at a different component...
>
> Thanks for any suggestions.
>
> Steve
>
> vtkUnstructuredGrid *output = this->GetOutput();
>
> ...
>
> vtkFloatArray *elementstresses = vtkFloatArray::New();
> elementstresses->SetNumberOfComponents(7);
> elementstresses->SetNumberOfTuples(nCells); // then read in data
>
> ...
>
> if ( elementstresses != NULL )
> {
> output->GetCellData()->SetScalars(elementstresses);
> }
>
>
>
>
>
> --
> Steven Boyd, PhD
>
> Institute for Biomedical Engineering
> ETH and University Zuerich
> Moussonstrasse 18
> 8044 Zuerich, Switzerland
>
> tel. +41.1.632.4591 fax. +41.1.632.1214 boyd at biomed.ee.ethz.ch
> -------------------------------------------------------------------
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
More information about the vtkusers
mailing list