From ff1ec0788f5d06584266ae1e658ae742ac87e448 Mon Sep 17 00:00:00 2001 From: Arturs Bekasovs Date: Tue, 28 Jan 2014 16:24:55 +0000 Subject: [PATCH] Refs #8570. Add code for saving the column data. --- .../DataHandling/test/SaveNexusProcessedTest.h | 11 ++++++++++- .../Nexus/inc/MantidNexus/NexusFileIO.h | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Code/Mantid/Framework/DataHandling/test/SaveNexusProcessedTest.h b/Code/Mantid/Framework/DataHandling/test/SaveNexusProcessedTest.h index 6c472287b4f2..4bdf904408ec 100644 --- a/Code/Mantid/Framework/DataHandling/test/SaveNexusProcessedTest.h +++ b/Code/Mantid/Framework/DataHandling/test/SaveNexusProcessedTest.h @@ -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 data; + + savedNexus.getData(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) { diff --git a/Code/Mantid/Framework/Nexus/inc/MantidNexus/NexusFileIO.h b/Code/Mantid/Framework/Nexus/inc/MantidNexus/NexusFileIO.h index 79c3fe7217e8..b5e2a6a127a9 100644 --- a/Code/Mantid/Framework/Nexus/inc/MantidNexus/NexusFileIO.h +++ b/Code/Mantid/Framework/Nexus/inc/MantidNexus/NexusFileIO.h @@ -375,13 +375,26 @@ namespace Mantid maxSize = size; } + // Set-up dimensions int dims[2]; dims[0] = static_cast(rowCount); dims[1] = static_cast(maxSize); - int fakeData[rowCount * maxSize]; + // Create data array + int data[rowCount * maxSize]; + for ( size_t i = 0; i < rowCount; ++i ) + { + std::vector values = column->template cell< std::vector >(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