BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
OutputDataReadWriteTiff.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file Device/InputOutput/OutputDataReadWriteTiff.h
6 //! @brief Defines class OutputDataReadWriteTiff
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2018
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifdef SWIG
16 #error no need to expose this header to Swig
17 #endif
18 
19 #ifndef USER_API
20 #ifndef BORNAGAIN_DEVICE_INPUTOUTPUT_OUTPUTDATAREADWRITETIFF_H
21 #define BORNAGAIN_DEVICE_INPUTOUTPUT_OUTPUTDATAREADWRITETIFF_H
22 
23 #ifdef BORNAGAIN_TIFF_SUPPORT
24 
25 #include "Device/Data/OutputData.h"
26 #include <memory>
27 #include <tiffio.h>
28 
29 //! Reads/write tiff files.
30 //! @ingroup input_output_internal
31 
32 class OutputDataReadWriteTiff {
33 public:
34  OutputDataReadWriteTiff();
35  ~OutputDataReadWriteTiff();
36 
37  OutputData<double>* readOutputData(std::istream& input_stream);
38  void writeOutputData(const OutputData<double>& data, std::ostream& output_stream);
39 
40 private:
41  void read(std::istream& input_stream);
42  void read_header();
43  void read_data();
44  void write_header();
45  void write_data();
46  void close();
47  void create_output_data();
48 
49  TIFF* m_tiff;
50  size_t m_width, m_height;
51  uint16 m_bitsPerSample, m_samplesPerPixel, m_sampleFormat;
52  std::unique_ptr<OutputData<double>> m_data;
53 };
54 
55 #endif // BORNAGAIN_TIFF_SUPPORT
56 
57 #endif // BORNAGAIN_DEVICE_INPUTOUTPUT_OUTPUTDATAREADWRITETIFF_H
58 #endif // USER_API
Defines and implements templated class OutputData.