[vtkusers] vtkTable GetValueByName

Luis Vieira luis.vieira at vektore.com
Sun Nov 20 12:16:29 EST 2016


Hello vtkusers,

 

I am trying to get values of some columns in my vtkTable. Below, you could
see my table and how I am setting the values. Works fine. Then, I want get
some values by ColumnName ("ThistheColumn1") instead of to inform row number
and column number as well as vtk examples shows. I know of the existence of
the function vtkVariant vtkTable::GetValueByName         (vtkIdType const
char *            ). However, I don't know how to apply in my particular
case that is vtkDoubleArray and that I have to use this value as double and
not as variant.

 

              tableLine = vtkSmartPointer<vtkTable>::New();

 

              vtkSmartPointer<vtkDoubleArray> ThistheColumn1 =

                      vtkSmartPointer<vtkDoubleArray>::New();

              ThistheColumn1 ->SetName("ThistheColumn1");

              tableLine->AddColumn(ThistheColumn1);

 

              vtkSmartPointer<vtkDoubleArray> ThistheColumn2 =

                      vtkSmartPointer<vtkDoubleArray>::New();

              ThistheColumn2->SetName("ThistheColumn2");

              tableLine->AddColumn(ThistheColumn2);

 

              for (unsigned int r = 0; r < numberRowsLine; r++)

                      {

 

                             for (unsigned int c = 0; c <
modelLine->columnCount(); c++)

                             {

                                    QString sh = modelLine->item(r,
c)->data(Qt::DisplayRole).toString();// .toString();

                                    tableLine->SetValue(r, c,
sh.toLatin1().constData());

 

                             }

                      }

 

vtkDocumentation to get values

 

vtkVariant v = table->GetValue( r,c);

    std::cout << "(r,c) = (" << r << "," << c << ") = " << v << std::endl;

 

Thank you very much for any help.

 

Luis Vieira, 

Consultant, Software Engineer

Vektore Exploration Consulting Corporation

ca.linkedin.com/in/joaoluisvieira

 <mailto:luis.vieira at vektore.com> luis.vieira at vektore.com

 <http://www.vektore.com/> www.vektore.com

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20161120/5fbc8e86/attachment.html>


More information about the vtkusers mailing list