GammaLib 2.1.0.dev
Loading...
Searching...
No Matches
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 ***************************************************************************/
43class GFitsImage : public GFitsHDU {
44
45public:
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
83protected:
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 ***************************************************************************/
125inline
127{
128 return (HT_IMAGE);
129}
130
131
132/***********************************************************************//**
133 * @brief Return size of pixel array
134 ***************************************************************************/
135inline
136const 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 ***************************************************************************/
145inline
146const int& GFitsImage::bitpix(void) const
147{
148 return m_bitpix;
149}
150
151
152/***********************************************************************//**
153 * @brief Return dimension of image
154 ***************************************************************************/
155inline
156const 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 ***************************************************************************/
165inline
166const int& GFitsImage::anynul(void) const
167{
168 return m_anynul;
169}
170
171
172/***********************************************************************//**
173 * @brief Return nul value
174 ***************************************************************************/
175inline
176const void* GFitsImage::nulval(void) const
177{
178 return (const_cast<GFitsImage*>(this)->ptr_nulval());
179}
180
181#endif /* GFITSIMAGE_HPP */
Abstract FITS extension base class definition.
GChatter
Definition GTypemaps.hpp:33
@ NORMAL
Definition GTypemaps.hpp:36
Abstract FITS extension base class.
Definition GFitsHDU.hpp:51
Abstract FITS image base class.
void open_image(void *vptr)
Open Image.
virtual void init_data(void)=0
virtual void * ptr_nulval(void)=0
int m_naxis
Image dimension.
virtual double pixel(const int &ix) const =0
virtual void release_data(void)=0
int naxes(const int &axis) const
Return dimension of an image axis.
const int & bitpix(void) const
Return number of Bits per pixel (negative=floating point)
int offset(const int &ix) const
Return pixel offset.
void free_members(void)
Delete class members.
const int & npix(void) const
Return size of pixel array.
void load_image(int datatype, const void *pixels, const void *nulval, int *anynul)
Load FITS image.
void fetch_data(void)
Fetch image pixels.
long * m_naxes
Number of pixels in each dimension.
const int & naxis(void) const
Return dimension of image.
HDUType exttype(void) const
Return extension type.
virtual void alloc_nulval(const void *value)=0
void data_save(void)
Save FITS image.
virtual void clear(void)=0
Clear object.
void save_image(int datatype, const void *pixels)
Save FITS image.
int m_bitpix
Number of Bits/pixel.
void copy_members(const GFitsImage &image)
Copy class members.
int m_num_pixels
Number of image pixels.
void init_image_header(void)
Initialise image header.
std::string print(const GChatter &chatter=NORMAL) const
Print column information.
void data_open(void *vptr)
Open FITS image.
virtual double pixel(const int &ix, const int &iy, const int &iz) const =0
virtual double pixel(const int &ix, const int &iy) const =0
GFitsImage & operator=(const GFitsImage &image)
Assignment operator.
virtual std::string classname(void) const =0
Return class name.
const int & anynul(void) const
Return number of nul values encountered during loading.
virtual void * ptr_data(void)=0
void data_connect(void *vptr)
Connect FITS image.
GFitsImage(void)
Void constructor.
virtual void alloc_data(void)=0
const void * nulval(void) const
Return nul value.
virtual double pixel(const int &ix, const int &iy, const int &iz, const int &it) const =0
virtual void * pixels(void)=0
int m_anynul
Number of NULLs encountered.
virtual int type(void) const =0
void data_close(void)
Close FITS image.
virtual ~GFitsImage(void)
Destructor.
virtual GFitsImage * clone(void) const =0
Clones object.
void init_members(void)
Initialise class members.