[vtkusers] Setting multiple scalars to a dataset

Steve Boyd boyd at biomed.ee.ethz.ch
Fri May 31 08:12:04 EDT 2002


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
-------------------------------------------------------------------



More information about the vtkusers mailing list