Skip to content

Commit

Permalink
Refs #8570. Add code for saving the column data.
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Jan 28, 2014
1 parent 692a5d5 commit ff1ec07
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
11 changes: 10 additions & 1 deletion Code/Mantid/Framework/DataHandling/test/SaveNexusProcessedTest.h
Expand Up @@ -436,7 +436,16 @@ class SaveNexusProcessedTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( columnInfo.dims[0], 3);
TS_ASSERT_EQUALS( columnInfo.dims[1], 4);

// TODO: check data
std::vector<int> data;

savedNexus.getData<int>(data);

TS_ASSERT_EQUALS( data.size(), 12 );
TS_ASSERT_EQUALS( data[0], 1 );
TS_ASSERT_EQUALS( data[3], 0 );
TS_ASSERT_EQUALS( data[5], 3 );
TS_ASSERT_EQUALS( data[8], 4 );
TS_ASSERT_EQUALS( data[11], 7 );
}
catch(std::exception& e)
{
Expand Down
17 changes: 15 additions & 2 deletions Code/Mantid/Framework/Nexus/inc/MantidNexus/NexusFileIO.h
Expand Up @@ -375,13 +375,26 @@ namespace Mantid
maxSize = size;
}

// Set-up dimensions
int dims[2];
dims[0] = static_cast<int>(rowCount);
dims[1] = static_cast<int>(maxSize);

int fakeData[rowCount * maxSize];
// Create data array
int data[rowCount * maxSize];
for ( size_t i = 0; i < rowCount; ++i )
{
std::vector<T> values = column->template cell< std::vector<T> >(i);

// So that all the arrays are of the size maxSize
values.resize(maxSize);

// Copy values to the data array
for ( size_t j = 0; j < maxSize; ++j )
data[i*maxSize + j] = values[j];
}

NXwritedata(columnName.c_str(), NX_INT32, 2, dims, (void *)(&fakeData), false);
NXwritedata(columnName.c_str(), NX_INT32, 2, dims, (void *)(&data), false);
}

} // namespace NeXus
Expand Down

0 comments on commit ff1ec07

Please sign in to comment.