GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GFitsImage.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GFitsImage.hpp - Abstract FITS image base class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2008-2017 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GFitsImage.hpp
23  * @brief Abstract FITS image base class definition
24  * @author Juergen Knoedlseder
25  */
26 
27 #ifndef GFITSIMAGE_HPP
28 #define GFITSIMAGE_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GFitsHDU.hpp"
34 
35 
36 /***********************************************************************//**
37  * @class GFitsImage
38  *
39  * @brief Abstract FITS image base class
40  *
41  * This class defines the abstract interface for a FITS image.
42  ***************************************************************************/
43 class GFitsImage : public GFitsHDU {
44 
45 public:
46  // Constructors and destructors
47  GFitsImage(void);
48  GFitsImage(const int& bitpix, const int& nx);
49  GFitsImage(const int& bitpix, const int& nx, const int& ny);
50  GFitsImage(const int& bitpix, const int& nx, const int& ny, const int& nz);
51  GFitsImage(const int& bitpix, const int& nx, const int& ny, const int& nz, const int& nt);
52  GFitsImage(const int& bitpix, const std::vector<int>& naxes);
53  GFitsImage(const GFitsImage& image);
54  virtual ~GFitsImage(void);
55 
56  // Operators
57  GFitsImage& operator=(const GFitsImage& image);
58 
59  // Pure virtual methods
60  virtual void clear(void) = 0;
61  virtual GFitsImage* clone(void) const = 0;
62  virtual std::string classname(void) const = 0;
63  virtual void* pixels(void) = 0;
64  virtual double pixel(const int& ix) const = 0;
65  virtual double pixel(const int& ix, const int& iy) const = 0;
66  virtual double pixel(const int& ix, const int& iy, const int& iz) const = 0;
67  virtual double pixel(const int& ix, const int& iy, const int& iz, const int& it) const = 0;
68  virtual int type(void) const = 0;
69 
70  // Implemented pure virtual methods
71  HDUType exttype(void) const;
72 
73  // Base class methods
74  const int& npix(void) const;
75  const int& bitpix(void) const;
76  const int& naxis(void) const;
77  int naxes(const int& axis) const;
78  const int& anynul(void) const;
79  void nulval(const void* value);
80  const void* nulval(void) const;
81  std::string print(const GChatter& chatter = NORMAL) const;
82 
83 protected:
84  // Protected methods
85  void init_members(void);
86  void copy_members(const GFitsImage& image);
87  void free_members(void);
88  void data_open(void* vptr);
89  void data_save(void);
90  void data_close(void);
91  void data_connect(void* vptr);
92  void init_image_header(void);
93  void open_image(void* vptr);
94  void load_image(int datatype, const void* pixels,
95  const void* nulval, int* anynul);
96  void save_image(int datatype, const void* pixels);
97  void fetch_data(void);
98  int offset(const int& ix) const;
99  int offset(const int& ix, const int& iy) const;
100  int offset(const int& ix, const int& iy, const int& iz) const;
101  int offset(const int& ix, const int& iy, const int& iz, const int& it) const;
102 
103  // Pure virtual protected methods
104  virtual void alloc_data(void) = 0;
105  virtual void init_data(void) = 0;
106  virtual void release_data(void) = 0;
107  virtual void alloc_nulval(const void* value) = 0;
108  virtual void* ptr_data(void) = 0;
109  virtual void* ptr_nulval(void) = 0;
110 
111  // Protected data area
112  int m_bitpix; //!< Number of Bits/pixel
113  int m_naxis; //!< Image dimension
114  long* m_naxes; //!< Number of pixels in each dimension
115  int m_num_pixels; //!< Number of image pixels
116  int m_anynul; //!< Number of NULLs encountered
117 };
118 
119 
120 /***********************************************************************//**
121  * @brief Return extension type
122  *
123  * @return Extension type (HT_IMAGE).
124  ***************************************************************************/
125 inline
127 {
128  return (HT_IMAGE);
129 }
130 
131 
132 /***********************************************************************//**
133  * @brief Return size of pixel array
134  ***************************************************************************/
135 inline
136 const int& GFitsImage::npix(void) const
137 {
138  return m_num_pixels;
139 }
140 
141 
142 /***********************************************************************//**
143  * @brief Return number of Bits per pixel (negative=floating point)
144  ***************************************************************************/
145 inline
146 const int& GFitsImage::bitpix(void) const
147 {
148  return m_bitpix;
149 }
150 
151 
152 /***********************************************************************//**
153  * @brief Return dimension of image
154  ***************************************************************************/
155 inline
156 const int& GFitsImage::naxis(void) const
157 {
158  return m_naxis;
159 }
160 
161 
162 /***********************************************************************//**
163  * @brief Return number of nul values encountered during loading
164  ***************************************************************************/
165 inline
166 const int& GFitsImage::anynul(void) const
167 {
168  return m_anynul;
169 }
170 
171 
172 /***********************************************************************//**
173  * @brief Return nul value
174  ***************************************************************************/
175 inline
176 const void* GFitsImage::nulval(void) const
177 {
178  return (const_cast<GFitsImage*>(this)->ptr_nulval());
179 }
180 
181 #endif /* GFITSIMAGE_HPP */
const int & bitpix(void) const
Return number of Bits per pixel (negative=floating point)
Definition: GFitsImage.hpp:146
Abstract FITS image base class.
Definition: GFitsImage.hpp:43
int offset(const int &ix) const
Return pixel offset.
Definition: GFitsImage.cpp:847
const int & naxis(void) const
Return dimension of image.
Definition: GFitsImage.hpp:156
void open_image(void *vptr)
Open Image.
Definition: GFitsImage.cpp:616
Abstract FITS extension base class.
Definition: GFitsHDU.hpp:51
void data_close(void)
Close FITS image.
Definition: GFitsImage.cpp:542
void data_open(void *vptr)
Open FITS image.
Definition: GFitsImage.cpp:507
virtual void * ptr_nulval(void)=0
virtual void init_data(void)=0
virtual void alloc_nulval(const void *value)=0
virtual void alloc_data(void)=0
int m_num_pixels
Number of image pixels.
Definition: GFitsImage.hpp:115
void save_image(int datatype, const void *pixels)
Save FITS image.
Definition: GFitsImage.cpp:721
void data_save(void)
Save FITS image.
Definition: GFitsImage.cpp:522
virtual void clear(void)=0
Clear object.
Abstract FITS extension base class definition.
void init_image_header(void)
Initialise image header.
Definition: GFitsImage.cpp:578
long * m_naxes
Number of pixels in each dimension.
Definition: GFitsImage.hpp:114
virtual void * pixels(void)=0
virtual int type(void) const =0
void data_connect(void *vptr)
Connect FITS image.
Definition: GFitsImage.cpp:564
const void * nulval(void) const
Return nul value.
Definition: GFitsImage.hpp:176
virtual double pixel(const int &ix) const =0
GFitsImage(void)
Void constructor.
Definition: GFitsImage.cpp:66
virtual GFitsImage * clone(void) const =0
Clones object.
GChatter
Definition: GTypemaps.hpp:33
virtual void release_data(void)=0
int m_anynul
Number of NULLs encountered.
Definition: GFitsImage.hpp:116
void fetch_data(void)
Fetch image pixels.
Definition: GFitsImage.cpp:818
void init_members(void)
Initialise class members.
Definition: GFitsImage.cpp:442
int m_naxis
Image dimension.
Definition: GFitsImage.hpp:113
const int & anynul(void) const
Return number of nul values encountered during loading.
Definition: GFitsImage.hpp:166
int naxes(const int &axis) const
Return dimension of an image axis.
Definition: GFitsImage.cpp:344
std::string print(const GChatter &chatter=NORMAL) const
Print column information.
Definition: GFitsImage.cpp:395
virtual ~GFitsImage(void)
Destructor.
Definition: GFitsImage.cpp:284
const int & npix(void) const
Return size of pixel array.
Definition: GFitsImage.hpp:136
void copy_members(const GFitsImage &image)
Copy class members.
Definition: GFitsImage.cpp:461
int m_bitpix
Number of Bits/pixel.
Definition: GFitsImage.hpp:112
void load_image(int datatype, const void *pixels, const void *nulval, int *anynul)
Load FITS image.
Definition: GFitsImage.cpp:674
GFitsImage & operator=(const GFitsImage &image)
Assignment operator.
Definition: GFitsImage.cpp:306
virtual void * ptr_data(void)=0
HDUType exttype(void) const
Return extension type.
Definition: GFitsImage.hpp:126
void free_members(void)
Delete class members.
Definition: GFitsImage.cpp:486
virtual std::string classname(void) const =0
Return class name.