[vtkusers] vtkTable
    David Doria 
    daviddoria+vtk at gmail.com
       
    Wed Oct 21 18:02:08 EDT 2009
    
    
  
1) I am confused why you cannot specify the number of columns (there
is no SetNumberOfColumns())? I realize that it stores data as rows,
but if you want to do element at a time type table creation, do you
have to build rows first and then insert them into the table? I was
trying to do something like this:
 Table->SetNumberOfRows(3);
 Table->SetNumberOfColumns(3);
  for(unsigned int r = 0; r < Table->GetNumberOfRows(); r++)
  {
    for(unsigned int c = 0; c < Table->GetNumberOfColumns(); c++)
    {
      Table->SetValue(r,c, vtkVariant(drand48()));
    }
  }
2) Assuming you must do (1), here is what I tried to do - simply
create a 1rowx3column table that looks like:
1.0 2.0 3.0
  vtkSmartPointer<vtkTable> Table = vtkSmartPointer<vtkTable>::New();
  vtkSmartPointer<vtkVariantArray> Row =
vtkSmartPointer<vtkVariantArray>::New();
  Row->SetNumberOfValues(3);
  //Row->SetNumberOfTuples(0);
  Row->SetValue(0, vtkVariant(1.0));
  Row->SetValue(1, vtkVariant(2.0));
  Row->SetValue(2, vtkVariant(3.0));
  Table->SetNumberOfRows(1);
  Table->SetRow(0, Row);
  //Table->InsertNextRow(Row);
  vtkstd::cout << "NumRows: " << Table->GetNumberOfRows() << vtkstd::endl;
  vtkstd::cout << "NumCols: " << Table->GetNumberOfColumns() << vtkstd::endl;
  Table->Dump(3);
I get an error macro that says "Incorrect number of tuples in SetRow"
Can anyone see what is wrong with that?
Thanks,
David
    
    
More information about the vtkusers
mailing list