44 #ifndef _INCLUDED_Field3D_SparseDataReader_H_
45 #define _INCLUDED_Field3D_SparseDataReader_H_
67 template <
class Data_T>
86 void readBlockList(
int idx,
const std::vector<Data_T*>& memoryList);
106 template <
class Data_T>
109 : m_valuesPerBlock(valuesPerBlock),
112 using namespace Hdf5Util;
121 throw OpenDataSetException(
"Couldn't open data set: " +
k_dataStr);
127 throw GetDataSpaceException(
"Couldn't get data space");
129 throw GetDataTypeException(
"Couldn't get data type");
139 throw FileIntegrityException(
"Block length mismatch in "
142 if (dims[0] != static_cast<hsize_t>(occupiedBlocks))
143 throw FileIntegrityException(
"Block count mismatch in "
149 template <
class Data_T>
152 using namespace Hdf5Util;
165 offset, NULL, count, NULL);
167 throw ReadHyperSlabException(
"Couldn't select slab " +
168 boost::lexical_cast<std::string>(idx));
173 H5P_DEFAULT, &result);
178 template <
class Data_T>
180 (
int idxLo,
const std::vector<Data_T*>& memoryList)
182 using namespace Hdf5Util;
191 count[0] = memoryList.size();
195 offset, NULL, count, NULL);
197 throw ReadHyperSlabException(
"Couldn't select slab " +
198 boost::lexical_cast<std::string>(idxLo));
205 memDims[0] = memoryList.size();
207 localMemDataSpace.create(H5S_SIMPLE);
208 H5Sset_extent_simple(localMemDataSpace.id(), 2, memDims, NULL);
212 int bytesPerValue = 0;
215 if (t == H5T_NATIVE_CHAR)
217 else if (t == H5T_NATIVE_SHORT)
219 else if (t == H5T_NATIVE_FLOAT)
221 else if (t == H5T_NATIVE_DOUBLE)
225 int dim =
sizeof(Data_T) / bytesPerValue;
230 localMemDataSpace.id(),
232 H5P_DEFAULT, &bigblock[0]);
235 throw Hdf5DataReadException(
"Couldn't read slab " +
236 boost::lexical_cast<std::string>(idxLo));
240 for (
size_t i = 0; i < memoryList.size(); ++i) {
241 memcpy(memoryList[i],