[vtkusers] Getting Scalar Values

Hamp Donald hampdonald at yahoo.com
Fri Mar 12 12:28:17 EST 2004


Hi
      I try to get the scalar value associated with
each point of cube example given below. I failed. 
Please help me how to do that. 
If I use
Cube->GetPointData()->GetScalars()->GetScalar(2), to
get the scalar value of the point with ID 2, it is
giving the compilation error. 

Regards
Donald  
 


 int i;
  static float x[8][3]={{0,0,0}, {1,0,0}, {1,1,0},
{0,1,0},
                        {0,0,1}, {1,0,1}, {1,1,1},
{0,1,1}};
  static vtkIdType pts[6][4]={{0,1,2,3}, {4,5,6,7},
{0,1,5,4},
                        {1,2,6,5},
{2,3,7,6},{3,0,4,7}};


  vtkPolyData *cube = vtkPolyData::New();
  vtkPoints *points = vtkPoints::New();
  vtkCellArray *polys = vtkCellArray::New();
  vtkFloatArray *scalars = vtkFloatArray::New();
                                                      
                                
  // Load the point, cell, and data attributes.
  for (i=0; i<8; i++) points->InsertPoint(i,x[i]);
  for (i=0; i<6; i++) polys->InsertNextCell(4,pts[i]);
  for (i=0; i<8; i++) scalars->InsertTuple1(i,i);
                                                      
                                
                                                      
                                
  // We now assign the pieces to the vtkPolyData.
  cube->SetPoints(points);
  //points->Delete();
  cube->SetPolys(polys);
  polys->Delete();
  cube->GetPointData()->SetScalars(scalars);
  // cube->GetPointData()->GetScalars();
  scalars->Delete();


__________________________________
Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster
http://search.yahoo.com



More information about the vtkusers mailing list