Commit 48341cd5 authored by Zack Galbreath's avatar Zack Galbreath

copy row names from R to vtkTable

Since vtkTable does not have a concept of row names, we add a
vtkStringArray containing the names as the first column of the
vtkTable.

Change-Id: I2c9e20ed2c1d9cc21205e137ce9b9cfedd02a816
parent e3a25ff6
......@@ -357,12 +357,23 @@ vtkTable* vtkRAdapter::RToVTKTable(SEXP variable)
nc = Rf_ncols(variable);
nr = Rf_nrows(variable);
result = vtkTable::New();
names = getAttrib(variable, R_DimNamesSymbol);
if(!isNull(names))
{
vtkStringArray* rowNames = vtkStringArray::New();
for (i = 0; i < nr; ++i)
{
std::string rowName = CHAR(STRING_ELT(VECTOR_ELT(names,0),i));
rowNames->InsertNextValue(rowName);
}
result->AddColumn(rowNames);
rowNames->Delete();
}
for(j=0;j<nc;j++)
{
vtkDoubleArray* da = vtkDoubleArray::New();
da->SetNumberOfComponents(1);
names = getAttrib(variable, R_DimNamesSymbol);
if(!isNull(names))
{
da->SetName(CHAR(STRING_ELT(VECTOR_ELT(names,1),j)));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment