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