GammaLib  1.7.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GSkyRegionMap.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GSkyRegionMap.hpp - Sky region map class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2017-2018 by Pierrick Martin *
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 GSkyRegionMap.hpp
23  * @brief Sky region map class interface definition
24  * @author Pierrick Martin
25  */
26 
27 #ifndef GSKYREGIONMAP_HPP
28 #define GSKYREGIONMAP_HPP
29 
30 /* __ Includes ___________________________________________________________ */
31 #include <vector>
32 #include <string>
33 #include "GSkyRegion.hpp"
34 #include "GSkyMap.hpp"
35 #include "GFilename.hpp"
36 
37 /* __ Forward declarations _______________________________________________ */
38 class GSkyDir;
39 class GSkyRegionMap;
40 
41 
42 /***********************************************************************//**
43  * @class GSkyRegionMap
44  *
45  * @brief Interface for a sky region map
46  *
47  * This class provides an implementation for a sky region defined by a
48  * sky map. The map is provided as a FITS file. Pixels with non-zero values
49  * are within the region, pixels with zero values outside the region.
50  ***************************************************************************/
51 class GSkyRegionMap : public GSkyRegion {
52 
53 public:
54  // Constructors and destructors
55  GSkyRegionMap(void);
56  explicit GSkyRegionMap(const GFilename& filename);
57  explicit GSkyRegionMap(const GSkyMap& map);
58  explicit GSkyRegionMap(const GSkyRegion* region);
59  GSkyRegionMap(const GSkyRegionMap& region);
60  virtual ~GSkyRegionMap(void);
61 
62  // Operators
63  GSkyRegionMap& operator=(const GSkyRegionMap& region);
64 
65  // Implemented pure virtual methods
66  void clear(void);
67  GSkyRegionMap* clone(void) const;
68  std::string classname(void) const;
69  void read(const std::string& line);
70  std::string write(void) const;
71  bool contains(const GSkyDir& dir) const;
72  bool contains(const GSkyRegion& reg) const;
73  bool overlaps(const GSkyRegion& reg) const;
74  std::string print(const GChatter& chatter = NORMAL) const;
75 
76  // Other methods
77  void load(const GFilename& filename);
78  void map(const GSkyMap& map);
79  const GSkyMap& map(void) const;
80  const std::vector<int>& nonzero_indices(void) const;
81 
82 protected:
83  // Protected methods
84  void init_members(void);
85  void copy_members(const GSkyRegionMap& region);
86  void free_members(void);
87  void compute_solid_angle(void);
88  void set_nonzero_indices(void);
89  void set_region_circle(const GSkyRegionCircle* circle);
90 
91  // Protected members
92  GSkyMap m_map; //!< The region map
93  std::vector<int> m_nonzero_indices; //!< Vector of non-zero pixel indices
94 };
95 
96 
97 /***********************************************************************//**
98  * @brief Return class name
99  *
100  * @return String containing the class name ("GSkyRegionMap").
101  ***************************************************************************/
102 inline
103 std::string GSkyRegionMap::classname(void) const
104 {
105  return ("GSkyRegionMap");
106 }
107 
108 
109 /***********************************************************************//**
110  * @brief Return sky map
111  *
112 * @return region sky map.
113  ***************************************************************************/
114 inline
115 const GSkyMap& GSkyRegionMap::map(void) const
116 {
117  return (m_map);
118 }
119 
120 
121 /***********************************************************************//**
122  * @brief Get non-zero index vector
123  *
124  * @return Reference to non-zero pixel indices vector.
125  ***************************************************************************/
126 inline
127 const std::vector<int>& GSkyRegionMap::nonzero_indices(void) const
128 {
129  return (m_nonzero_indices);
130 }
131 
132 
133 /***********************************************************************//**
134  * @brief Return file name
135  *
136  * @return File name from which the region was loaded or into which
137  * the region was saved.
138  *
139  * Returns the file name from which the region was loaded or into
140  * which the region was saved. The returned string will be empty if
141  * no load() or save() method has been called before.
142  ***************************************************************************/
143 /*
144 inline
145 const GFilename& GSkyRegionMap::filename(void) const
146 {
147  return (m_filename);
148 }
149 */
150 
151 #endif /* GSKYREGIONMAP_HPP */
void set_nonzero_indices(void)
Create an array of non-zero pixel indices.
GSkyRegionMap(void)
Void constructor.
Sky map class.
Definition: GSkyMap.hpp:89
void copy_members(const GSkyRegionMap &region)
Copy class members.
const GSkyMap & map(void) const
Return sky map.
void compute_solid_angle(void)
Compute solid angle.
bool contains(const GSkyDir &dir) const
Check if a given direction is contained in this region.
Interface for the circular sky region class.
Sky map class definition.
GSkyRegionMap & operator=(const GSkyRegionMap &region)
Assignment operator.
void clear(void)
Clear instance.
const std::vector< int > & nonzero_indices(void) const
Get non-zero index vector.
Abstract interface for the sky region class.
Definition: GSkyRegion.hpp:57
GSkyRegionMap * clone(void) const
Clone sky region map.
bool overlaps(const GSkyRegion &reg) const
Checks if a given region is overlapping with this region.
Filename class.
Definition: GFilename.hpp:62
virtual ~GSkyRegionMap(void)
Destructor.
void init_members(void)
Initialise class members.
GChatter
Definition: GTypemaps.hpp:33
Interface for a sky region map.
void free_members(void)
Delete class members.
void read(const std::string &line)
Create region from a string in DS9 format.
std::vector< int > m_nonzero_indices
Vector of non-zero pixel indices.
void set_region_circle(const GSkyRegionCircle *circle)
Set region map from region circle.
std::string write(void) const
Write string describing region in DS9 region format.
GSkyMap m_map
The region map.
std::string print(const GChatter &chatter=NORMAL) const
Print region description.
void load(const GFilename &filename)
Load region map from FITS file.
std::string classname(void) const
Return class name.
Sky direction class.
Definition: GSkyDir.hpp:62
Abstract sky region base class interface definition.
Filename class interface definition.