Statismo  0.10.1
 All Classes Namespaces Functions Typedefs
HDF5Utils.hxx
1 /*
2  * This file is part of the statismo library.
3  *
4  * Author: Marcel Luethi (marcel.luethi@unibas.ch)
5  *
6  * Copyright (c) 2011 University of Basel
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in the
18  * documentation and/or other materials provided with the distribution.
19  *
20  * Neither the name of the project's author nor the names of its
21  * contributors may be used to endorse or promote products derived from
22  * this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
30  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
31  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
33  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35  *
36  */
37 
38 #ifndef __HDF5_UTILS_CXX
39 #define __HDF5_UTILS_CXX
40 
41 #include "HDF5Utils.h"
42 
43 #include <algorithm>
44 #include <fstream>
45 #include <iostream>
46 #include <iterator>
47 
48 #include "CommonTypes.h"
49 #include "Exceptions.h"
50 #include "H5Cpp.h"
51 
52 namespace statismo {
53 
54 inline
55 H5::H5File
56 HDF5Utils::openOrCreateFile(const std::string filename) {
57 
58  // check if file exists
59  std::ifstream ifile(filename.c_str());
60  H5::H5File file;
61 
62  if (!ifile) {
63  // create it
64  file = H5::H5File( filename.c_str(), H5F_ACC_EXCL);
65  } else {
66  // open it
67  file = H5::H5File( filename.c_str(), H5F_ACC_RDWR);
68  }
69  return file;
70 }
71 
72 
73 
74 inline
75 H5::Group
76 HDF5Utils::openPath(H5::H5File& file, const std::string& path, bool createPath) {
77  H5::Group group;
78 
79  // take the first part of the path
80  size_t curpos = 1;
81  size_t nextpos = path.find_first_of("/", curpos);
82  H5::Group g = file.openGroup("/");
83 
84  std::string name = path.substr(curpos, nextpos-1);
85 
86  while (curpos != std::string::npos && name != "") {
87 
88  if (existsObjectWithName(g, name)) {
89  g = g.openGroup(name);
90  } else {
91  if (createPath) {
92  g = g.createGroup(name);
93  } else {
94  std::string msg = std::string("the path ") +path +" does not exist";
95  throw StatisticalModelException(msg.c_str());
96  }
97  }
98 
99  curpos = nextpos+1;
100  nextpos = path.find_first_of("/", curpos);
101  if ( nextpos != std::string::npos )
102  name = path.substr(curpos, nextpos-curpos);
103  else
104  name = path.substr(curpos);
105  }
106 
107  return g;
108 }
109 
110 template <class T>
111 inline
112 void HDF5Utils::readMatrixOfType(const H5::CommonFG& fg, const char* name, typename GenericEigenType<T>::MatrixType& matrix) {
113  throw StatisticalModelException("Invalid type proided for writeMatrixOfType");
114 }
115 
116 template <>
117 inline
118 void HDF5Utils::readMatrixOfType<unsigned int>(const H5::CommonFG& fg, const char* name, GenericEigenType<unsigned int>::MatrixType& matrix) {
119  H5::DataSet ds = fg.openDataSet( name );
120  hsize_t dims[2];
121  ds.getSpace().getSimpleExtentDims(dims, NULL);
122 
123  // simply read the whole dataspace
124  matrix.resize(dims[0], dims[1]);
125  ds.read(matrix.data(), H5::PredType::NATIVE_UINT);
126 }
127 
128 template <>
129 inline
130 void HDF5Utils::readMatrixOfType<float>(const H5::CommonFG& fg, const char* name, GenericEigenType<float>::MatrixType& matrix) {
131  H5::DataSet ds = fg.openDataSet( name );
132  hsize_t dims[2];
133  ds.getSpace().getSimpleExtentDims(dims, NULL);
134 
135  // simply read the whole dataspace
136  matrix.resize(dims[0], dims[1]);
137  ds.read(matrix.data(), H5::PredType::NATIVE_FLOAT);
138 }
139 
140 template <>
141 inline
142 void HDF5Utils::readMatrixOfType<double>(const H5::CommonFG& fg, const char* name, GenericEigenType<double>::MatrixType& matrix) {
143  H5::DataSet ds = fg.openDataSet( name );
144  hsize_t dims[2];
145  ds.getSpace().getSimpleExtentDims(dims, NULL);
146 
147  // simply read the whole dataspace
148  matrix.resize(dims[0], dims[1]);
149  ds.read(matrix.data(), H5::PredType::NATIVE_DOUBLE);
150 }
151 
152 
153 inline
154 void HDF5Utils::readMatrix(const H5::CommonFG& fg, const char* name, MatrixType& matrix) {
155  readMatrixOfType<ScalarType>(fg, name, matrix);
156 }
157 
158 
159 inline
160 void HDF5Utils::readMatrix(const H5::CommonFG& fg, const char* name, unsigned maxNumColumns, MatrixType& matrix) {
161  H5::DataSet ds = fg.openDataSet( name );
162  hsize_t dims[2];
163  ds.getSpace().getSimpleExtentDims(dims, NULL);
164 
165  hsize_t nRows = dims[0]; // take the number of rows defined in the hdf5 file
166  hsize_t nCols = std::min(dims[1], static_cast<hsize_t>(maxNumColumns)); // take the number of cols provided by the user
167 
168  hsize_t offset[2] = {0,0}; // hyperslab offset in the file
169  hsize_t count[2];
170  count[0] = nRows;
171  count[1] = nCols;
172 
173  H5::DataSpace dataspace = ds.getSpace();
174  dataspace.selectHyperslab( H5S_SELECT_SET, count, offset );
175 
176  /* Define the memory dataspace. */
177  hsize_t dimsm[2];
178  dimsm[0] = nRows;
179  dimsm[1] = nCols;
180  H5::DataSpace memspace( 2, dimsm );
181 
182  /* Define memory hyperslab. */
183  hsize_t offset_out[2] = {0, 0}; // hyperslab offset in memory
184  hsize_t count_out[2]; // size of the hyperslab in memory
185 
186  count_out[0] = nRows;
187  count_out[1] = nCols;
188  memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out );
189 
190  matrix.resize(nRows, nCols);
191  ds.read(matrix.data(), H5::PredType::NATIVE_FLOAT, memspace, dataspace);
192 
193 }
194 
195 template <class T>
196 inline
197 H5::DataSet HDF5Utils::writeMatrixOfType(const H5::CommonFG& fg, const char* name, const typename GenericEigenType<T>::MatrixType& matrix) {
198  throw StatisticalModelException("Invalid type proided for writeMatrixOfType");
199 }
200 
201 template <>
202 inline
203 H5::DataSet HDF5Utils::writeMatrixOfType<unsigned int>(const H5::CommonFG& fg, const char* name, const GenericEigenType<unsigned int>::MatrixType& matrix) {
204  // HDF5 does not like empty matrices.
205  //
206  if (matrix.rows() == 0 || matrix.cols() == 0) {
207  throw StatisticalModelException("Empty matrix provided to writeMatrix");
208  }
209 
210  hsize_t dims[2] = {matrix.rows(), matrix.cols()};
211  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_UINT, H5::DataSpace(2, dims));
212  ds.write( matrix.data(), H5::PredType::NATIVE_UINT );
213  return ds;
214 }
215 
216 template <>
217 inline
218 H5::DataSet HDF5Utils::writeMatrixOfType<float>(const H5::CommonFG& fg, const char* name, const GenericEigenType<float>::MatrixType& matrix) {
219  // HDF5 does not like empty matrices.
220  //
221  if (matrix.rows() == 0 || matrix.cols() == 0) {
222  throw StatisticalModelException("Empty matrix provided to writeMatrix");
223  }
224 
225  hsize_t dims[2] = {matrix.rows(), matrix.cols()};
226  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_FLOAT, H5::DataSpace(2, dims));
227  ds.write( matrix.data(), H5::PredType::NATIVE_FLOAT );
228  return ds;
229 }
230 
231 template <>
232 inline
233 H5::DataSet HDF5Utils::writeMatrixOfType<double>(const H5::CommonFG& fg, const char* name, const GenericEigenType<double>::MatrixType& matrix) {
234  // HDF5 does not like empty matrices.
235  //
236  if (matrix.rows() == 0 || matrix.cols() == 0) {
237  throw StatisticalModelException("Empty matrix provided to writeMatrix");
238  }
239 
240  hsize_t dims[2] = {matrix.rows(), matrix.cols()};
241  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_DOUBLE, H5::DataSpace(2, dims));
242  ds.write( matrix.data(), H5::PredType::NATIVE_DOUBLE );
243  return ds;
244 }
245 
246 
247 inline
248 H5::DataSet HDF5Utils::writeMatrix(const H5::CommonFG& fg, const char* name, const MatrixType& matrix) {
249  return writeMatrixOfType<ScalarType>(fg, name, matrix);
250 }
251 
252 
253 template <class T>
254 inline
255 void HDF5Utils::readVectorOfType(const H5::CommonFG& fg, const char* name, typename GenericEigenType<T>::VectorType& vector) {
256  throw StatisticalModelException("Invalid type proided for readVectorOfType");
257 }
258 
259 template <>
260 inline
261 void HDF5Utils::readVectorOfType<double>(const H5::CommonFG& fg, const char* name, GenericEigenType<double>::VectorType& vector) {
262  H5::DataSet ds = fg.openDataSet( name );
263  hsize_t dims[1];
264  ds.getSpace().getSimpleExtentDims(dims, NULL);
265  vector.resize(dims[0], 1);
266  ds.read(vector.data(), H5::PredType::NATIVE_DOUBLE);
267 }
268 
269 template <>
270 inline
271 void HDF5Utils::readVectorOfType<float>(const H5::CommonFG& fg, const char* name, GenericEigenType<float>::VectorType& vector) {
272  H5::DataSet ds = fg.openDataSet( name );
273  hsize_t dims[1];
274  ds.getSpace().getSimpleExtentDims(dims, NULL);
275  vector.resize(dims[0], 1);
276  ds.read(vector.data(), H5::PredType::NATIVE_FLOAT);
277 }
278 
279 template <>
280 inline
281 void HDF5Utils::readVectorOfType<int>(const H5::CommonFG& fg, const char* name, GenericEigenType<int>::VectorType& vector) {
282  H5::DataSet ds = fg.openDataSet( name );
283  hsize_t dims[1];
284  ds.getSpace().getSimpleExtentDims(dims, NULL);
285  vector.resize(dims[0], 1);
286  ds.read(vector.data(), H5::PredType::NATIVE_INT);
287 }
288 
289 inline
290 void HDF5Utils::readVector(const H5::CommonFG& fg, const char* name, VectorType& vector) {
291  readVectorOfType<ScalarType>(fg, name, vector);
292 }
293 
294 
295 inline
296 void HDF5Utils::readVector(const H5::CommonFG& fg, const char* name, unsigned maxNumElements, VectorType& vector) {
297  H5::DataSet ds = fg.openDataSet( name );
298  hsize_t dims[1];
299  ds.getSpace().getSimpleExtentDims(dims, NULL);
300 
301  hsize_t nElements = std::min(dims[0], static_cast<hsize_t>(maxNumElements)); // take the number of rows defined in the hdf5 file
302 
303  hsize_t offset[1] = {0}; // hyperslab offset in the file
304  hsize_t count[1];
305  count[0] = nElements;
306 
307  H5::DataSpace dataspace = ds.getSpace();
308  dataspace.selectHyperslab( H5S_SELECT_SET, count, offset );
309 
310  /* Define the memory dataspace. */
311  hsize_t dimsm[1];
312  dimsm[0] = nElements;
313  H5::DataSpace memspace( 1, dimsm );
314 
315  /* Define memory hyperslab. */
316  hsize_t offset_out[1] = {0}; // hyperslab offset in memory
317  hsize_t count_out[1]; // size of the hyperslab in memory
318 
319  count_out[0] = nElements;
320  memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out );
321 
322  vector.resize(nElements);
323  ds.read(vector.data(), H5::PredType::NATIVE_FLOAT, memspace, dataspace);
324 }
325 
326 
327 
328 
329 template <class T>
330 inline
331 H5::DataSet HDF5Utils::writeVectorOfType(const H5::CommonFG& fg, const char* name, const typename GenericEigenType<T>::VectorType& vector) {
332  throw StatisticalModelException("Invalid type provided for writeVectorOfType");
333 }
334 
335 template <>
336 inline
337 H5::DataSet HDF5Utils::writeVectorOfType<double>(const H5::CommonFG& fg, const char* name, const GenericEigenType<double>::VectorType& vector) {
338  hsize_t dims[1] = {vector.size()};
339  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_DOUBLE, H5::DataSpace(1, dims));
340  ds.write( vector.data(), H5::PredType::NATIVE_DOUBLE );
341  return ds;
342 }
343 
344 template <>
345 inline
346 H5::DataSet HDF5Utils::writeVectorOfType<float>(const H5::CommonFG& fg, const char* name, const GenericEigenType<float>::VectorType& vector) {
347  hsize_t dims[1] = {vector.size()};
348  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_FLOAT, H5::DataSpace(1, dims));
349  ds.write( vector.data(), H5::PredType::NATIVE_FLOAT );
350  return ds;
351 }
352 
353 template <>
354 inline
355 H5::DataSet HDF5Utils::writeVectorOfType<int>(const H5::CommonFG& fg, const char* name, const GenericEigenType<int>::VectorType& vector) {
356  hsize_t dims[1] = {vector.size()};
357  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_INT, H5::DataSpace(1, dims));
358  ds.write( vector.data(), H5::PredType::NATIVE_INT );
359  return ds;
360 }
361 
362 inline
363 H5::DataSet HDF5Utils::writeVector(const H5::CommonFG& fg, const char* name, const VectorType& vector) {
364  return writeVectorOfType<ScalarType>(fg, name, vector);
365 }
366 
367 
368 inline
369 H5::DataSet HDF5Utils::writeString(const H5::CommonFG& fg, const char* name, const std::string& s) {
370  H5::StrType fls_type(H5::PredType::C_S1, s.length() + 1); // + 1 for trailing zero
371  H5::DataSet ds = fg.createDataSet(name, fls_type, H5::DataSpace(H5S_SCALAR));
372  ds.write(s, fls_type);
373  return ds;
374 }
375 
376 
377 inline
378 std::string
379 HDF5Utils::readString(const H5::CommonFG& fg, const char* name) {
380  H5std_string outputString;
381  H5::DataSet ds = fg.openDataSet(name);
382  ds.read(outputString, ds.getStrType());
383  return outputString;
384 }
385 
386 inline
387 void HDF5Utils::writeStringAttribute(const H5::H5Object& fg, const char* name, const std::string& s) {
388  H5::StrType strdatatype(H5::PredType::C_S1, s.length() + 1 ); // + 1 for trailing 0
389  H5::Attribute att = fg.createAttribute(name, strdatatype, H5::DataSpace(H5S_SCALAR));
390  att.write(strdatatype, s);
391  att.close();
392 }
393 
394 
395 inline
396 std::string
397 HDF5Utils::readStringAttribute(const H5::H5Object& fg, const char* name) {
398  H5std_string outputString;
399 
400  H5::Attribute myatt_out = fg.openAttribute(name);
401  myatt_out.read(myatt_out.getStrType(), outputString);
402  return outputString;
403 }
404 
405 inline
406 void HDF5Utils::writeIntAttribute(const H5::H5Object& fg, const char* name, int value) {
407  H5::IntType int_type(H5::PredType::NATIVE_INT32);
408  H5::DataSpace att_space(H5S_SCALAR);
409  H5::Attribute att = fg.createAttribute(name, int_type, att_space );
410  att.write( int_type, &value);
411  att.close();
412 }
413 
414 inline
415 int
416 HDF5Utils::readIntAttribute(const H5::H5Object& fg, const char* name) {
417  H5::IntType fls_type(H5::PredType::NATIVE_INT32);
418  int value = 0;
419  H5::Attribute myatt_out = fg.openAttribute(name);
420  myatt_out.read(fls_type, &value);
421  return value;
422 }
423 
424 
425 inline
426 H5::DataSet HDF5Utils::writeInt(const H5::CommonFG& fg, const char* name, int value) {
427  H5::IntType fls_type(H5::PredType::NATIVE_INT32); // 0 is a dummy argument
428  H5::DataSet ds = fg.createDataSet(name, fls_type, H5::DataSpace(H5S_SCALAR));
429  ds.write(&value, fls_type);
430  return ds;
431 }
432 
433 inline
434 int HDF5Utils::readInt(const H5::CommonFG& fg, const char* name) {
435  H5::IntType fls_type(H5::PredType::NATIVE_INT32);
436  H5::DataSet ds = fg.openDataSet( name );
437 
438  int value = 0;
439  ds.read(&value, fls_type);
440  return value;
441 }
442 
443 inline
444 H5::DataSet HDF5Utils::writeFloat(const H5::CommonFG& fg, const char* name, float value) {
445  H5::FloatType fls_type(H5::PredType::NATIVE_FLOAT); // 0 is a dummy argument
446  H5::DataSet ds = fg.createDataSet(name, fls_type, H5::DataSpace(H5S_SCALAR));
447  ds.write(&value, fls_type);
448  return ds;
449 }
450 
451 inline
452 float HDF5Utils::readFloat(const H5::CommonFG& fg, const char* name) {
453  H5::FloatType fls_type(H5::PredType::NATIVE_FLOAT);
454  H5::DataSet ds = fg.openDataSet( name );
455 
456  float value = 0;
457  ds.read(&value, fls_type);
458  return value;
459 }
460 
461 inline
462 void HDF5Utils::getFileFromHDF5(const H5::CommonFG& fg, const char* name, const char* filename) {
463  H5::DataSet ds = fg.openDataSet( name );
464  hsize_t dims[1];
465  ds.getSpace().getSimpleExtentDims(dims, NULL);
466  std::vector<char> buffer(dims[0]);
467  if(!buffer.empty()) ds.read(&buffer[0], H5::PredType::NATIVE_CHAR);
468 
469  typedef std::ostream_iterator<char> ostream_iterator;
470  std::ofstream ofile(filename, std::ios::binary);
471  if (!ofile) {
472  std::string s= std::string("could not open file ") +filename;
473  throw StatisticalModelException(s.c_str());
474  }
475 
476  std::copy(buffer.begin(), buffer.end(), ostream_iterator(ofile));
477  ofile.close();
478 }
479 
480 inline
481 void
482 HDF5Utils::dumpFileToHDF5( const char* filename, const H5::CommonFG& fg, const char* name) {
483 
484  typedef std::istream_iterator<char> istream_iterator;
485 
486  std::ifstream ifile(filename, std::ios::binary);
487  if (!ifile) {
488  std::string s= std::string("could not open file ") +filename;
489  throw StatisticalModelException(s.c_str());
490  }
491 
492  std::vector<char> buffer;
493  ifile >> std::noskipws;
494  std::copy(istream_iterator(ifile), istream_iterator(), std::back_inserter(buffer));
495 
496  ifile.close();
497 
498  hsize_t dims[] = {buffer.size()};
499  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_CHAR, H5::DataSpace(1, dims));
500  ds.write( &buffer[0], H5::PredType::NATIVE_CHAR );
501 
502 }
503 
504 template<typename T>
505 inline
506 void
507 HDF5Utils::readArray(const H5::CommonFG& fg, const char* name, std::vector<T> & array) {
508  throw StatisticalModelException( "not implemented" );
509 }
510 
511 
512 template<typename T>
513 inline
514 H5::DataSet
515 HDF5Utils::writeArray(const H5::CommonFG& fg, const char* name, std::vector<T> const& array) {
516  throw StatisticalModelException( "not implemented" );
517 }
518 
519 template<>
520 inline
521 void
522 HDF5Utils::readArray(const H5::CommonFG& fg, const char* name, std::vector<int> & array) {
523  H5::DataSet ds = fg.openDataSet( name );
524  hsize_t dims[1];
525  ds.getSpace().getSimpleExtentDims(dims, NULL);
526  array.resize(dims[0]);
527  ds.read( &array[0], H5::PredType::NATIVE_INT32);
528 }
529 
530 template<>
531 inline
532 H5::DataSet
533 HDF5Utils::writeArray(const H5::CommonFG& fg, const char* name, std::vector<int> const& array) {
534  hsize_t dims[1] = {array.size()};
535  H5::DataSet ds = fg.createDataSet( name, H5::PredType::NATIVE_INT32, H5::DataSpace(1, dims));
536  ds.write( &array[0], H5::PredType::NATIVE_INT32 );
537  return ds;
538 }
539 
540 inline
541 bool
542 HDF5Utils::existsObjectWithName(const H5::CommonFG& fg, const std::string& name) {
543  for (hsize_t i = 0; i < fg.getNumObjs(); ++i) {
544  std::string objname= fg.getObjnameByIdx(i);
545  if (objname == name) {
546  return true;
547  }
548  }
549  return false;
550 }
551 
552 } //namespace statismo
553 
554 #endif
static bool existsObjectWithName(const H5::CommonFG &fg, const std::string &name)
Definition: HDF5Utils.hxx:542
static H5::DataSet writeArray(const H5::CommonFG &fg, const char *name, std::vector< T > const &array)
Definition: HDF5Utils.hxx:515
static void writeIntAttribute(const H5::H5Object &fg, const char *name, int value)
Definition: HDF5Utils.hxx:406
static H5::H5File openOrCreateFile(const std::string filename)
Definition: HDF5Utils.hxx:56
static void readMatrix(const H5::CommonFG &fg, const char *name, MatrixType &matrix)
Definition: HDF5Utils.hxx:154
static H5::DataSet writeMatrix(const H5::CommonFG &fg, const char *name, const MatrixType &matrix)
Definition: HDF5Utils.hxx:248
static void dumpFileToHDF5(const char *filename, const H5::CommonFG &fg, const char *name)
Definition: HDF5Utils.hxx:482
static std::string readString(const H5::CommonFG &fg, const char *name)
Definition: HDF5Utils.hxx:379
static std::string readStringAttribute(const H5::H5Object &group, const char *name)
Definition: HDF5Utils.hxx:397
static void readArray(const H5::CommonFG &fg, const char *name, std::vector< T > &array)
Definition: HDF5Utils.hxx:507
static void writeStringAttribute(const H5::H5Object &group, const char *name, const std::string &s)
Definition: HDF5Utils.hxx:387
static H5::DataSet writeString(const H5::CommonFG &fg, const char *name, const std::string &s)
Definition: HDF5Utils.hxx:369
static float readFloat(const H5::CommonFG &fg, const char *name)
Definition: HDF5Utils.hxx:452
static H5::DataSet writeInt(const H5::CommonFG &fg, const char *name, int value)
Definition: HDF5Utils.hxx:426
Generic Exception class for the statismo Library.
Definition: Exceptions.h:68
static H5::DataSet writeMatrixOfType(const H5::CommonFG &fg, const char *name, const typename GenericEigenType< T >::MatrixType &matrix)
Definition: HDF5Utils.hxx:197
static H5::Group openPath(H5::H5File &fg, const std::string &path, bool createPath=false)
Definition: HDF5Utils.hxx:76
static void readVector(const H5::CommonFG &fg, const char *name, unsigned nElements, VectorType &vector)
Definition: HDF5Utils.hxx:296
static H5::DataSet writeVector(const H5::CommonFG &fg, const char *name, const VectorType &vector)
Definition: HDF5Utils.hxx:363
static H5::DataSet writeFloat(const H5::CommonFG &fg, const char *name, float value)
Definition: HDF5Utils.hxx:444
static void getFileFromHDF5(const H5::CommonFG &fg, const char *name, const char *filename)
Definition: HDF5Utils.hxx:462
static void readMatrixOfType(const H5::CommonFG &fg, const char *name, typename GenericEigenType< T >::MatrixType &matrix)
Definition: HDF5Utils.hxx:112
static int readInt(const H5::CommonFG &fg, const char *name)
Definition: HDF5Utils.hxx:434
static int readIntAttribute(const H5::H5Object &group, const char *name)
Definition: HDF5Utils.hxx:416