polaroid-pp

Schlieren and contour plot tool
git clone https://git.0xfab.ch/polaroid-pp.git
Log | Files | Refs | Submodules | README | LICENSE

PhotoHDF5.h (1769B)


      1 // File       : PhotoHDF5.h
      2 // Date       : Tue Apr 26 23:24:00 2016
      3 // Author     : Fabian Wermelinger
      4 // Description: HDF5 Photo Paper
      5 // Copyright 2016 ETH Zurich. All Rights Reserved.
      6 #ifndef PHOTOHDF5_H_VN6WHSEO
      7 #define PHOTOHDF5_H_VN6WHSEO
      8 
      9 #ifdef _USE_HDF_
     10 #include <hdf5.h>
     11 #include <string>
     12 
     13 #include "common.h"
     14 #include "Polaroid.h"
     15 #include "PhotoPaper.h"
     16 
     17 class PhotoHDF5 : public PhotoPaper
     18 {
     19 private:
     20     bool m_open;
     21     Real* m_hdfraw;
     22     Real m_time;
     23 
     24     // HDF 5 types
     25     hid_t m_hdf5_fileid;
     26     hsize_t m_hdf5_count[4];
     27     hsize_t m_hdf5_dims[4];
     28     hsize_t m_hdf5_offset[4];
     29 
     30     // helper
     31     void _open_hdf_file();
     32     void _close_hdf_file();
     33     void _dump_xmf() const;
     34 
     35 public:
     36     PhotoHDF5(const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t) {}
     37     PhotoHDF5(const Polaroid& cam, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t)
     38     {
     39         resize(cam.width(), cam.height());
     40     }
     41     PhotoHDF5(const int width, const int height, const std::string filename="hdf5", const Real t=0) : PhotoPaper(0,0,filename), m_open(false), m_hdfraw(nullptr), m_time(t)
     42     {
     43         resize(width,height);
     44     }
     45     virtual ~PhotoHDF5() { if (m_hdfraw) delete [] m_hdfraw; }
     46 
     47     virtual void make_new(const std::string name, const int width, const int height);
     48     virtual void resize(const int width, const int height);
     49     virtual void write();
     50     virtual void set_pixel(const double phi, const int x, const int y);
     51     virtual std::string suffix() const { return std::string(".h5"); }
     52     inline void set_time(const Real t) { m_time = t; }
     53 };
     54 #endif /* _USE_HDF_ */
     55 
     56 #endif /* PHOTOHDF5_H_VN6WHSEO */