[vtkusers] Setting multiple scalars to a dataset

Orlando Hernandez orlandomhb at yahoo.com
Tue Jun 4 06:01:19 EDT 2002


--- Steve Boyd <boyd at biomed.ee.ethz.ch> wrote:
> KRS,
> 
> Here's how I used multiple scalar arrays in my
> reader class in case it's
> of any help.  I haven't tried it yet, but I think in
> order to switch
> between the added arrays I type something of the
> sort:
>
myclass->GetPointData()->SetActiveAttribute("VTK_STRESS_VM",vtkDataSetAttributes::SCALARS);
> 
> Hope this helps (and is correct!).
> 
> Sincerely,
> 
> Steve
> 
> 
>     // Declare some variables
>     float   f7tuple[7];
>     int     i, j;
>     vtkFloatArray *stressesAndStrains[7];
> 
>     // Initialize and set the array names
>     for (i=0; i<7; i++) stressesAndStrains[i] =
> vtkFloatArray::New();
>     for (i=0; i<7; i++)
> stressesAndStrains[i]->SetNumberOfComponents(1);
>     for (i=0; i<7; i++)
> stressesAndStrains[i]->SetNumberOfTuples(nCells);
>     stressesAndStrains[0]->SetName("VTK_STRESS_11");
>     stressesAndStrains[1]->SetName("VTK_STRESS_22");
>     stressesAndStrains[2]->SetName("VTK_STRESS_33");
>     stressesAndStrains[3]->SetName("VTK_STRESS_12");
>     stressesAndStrains[4]->SetName("VTK_STRESS_23");
>     stressesAndStrains[5]->SetName("VTK_STRESS_31");
>     stressesAndStrains[6]->SetName("VTK_STRESS_VM");
> 
>     // Read the data from file and set the array
> data
>     for (i=0; i<nCells; i++) {
>       this->ReadLine(line);
>       sscanf(line,"%*d %*d %f %f %f %f %f %f %f %f
> %f",
>        
>
f7tuple,f7tuple+1,f7tuple+2,f7tuple+3,f7tuple+4,f7tuple+5,f7tuple+6);
>       for (j=0; j<7; j++)
>        
> stressesAndStrains[j]->SetTuple(i,f7tuple+j);
>     }
> 
>     // Set the active array, indexed by my class
> variable
> this->ActiveScalar, to the cell data
>     if ( stressesAndStrains[this->ActiveScalar] !=
> NULL ) {
>      
>
output->GetCellData()->SetScalars(stressesAndStrains[this->ActiveScalar]);
>     } else {
>       vtkWarningMacro(<<"\n  Scalar components were
> not successfully
> added.");
>     }
> 
>     // Set all of the arrays (inactive and active)
> to the object for
> later use (????)
>     for (i=0; i<7; i++)
>       if (stressesAndStrains[i] != NULL) 
>        
>
output->GetCellData()->AddArray(stressesAndStrains[i]);
> 
> -- 
> 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


__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com



More information about the vtkusers mailing list