GammaLib
2.0.0
|
Sky region container class. More...
#include <GSkyRegions.hpp>
Public Member Functions | |
GSkyRegions (void) | |
Void constructor. More... | |
GSkyRegions (const GSkyRegions ®ions) | |
Copy constructor. More... | |
GSkyRegions (const GFilename &filename) | |
Load constructor. More... | |
virtual | ~GSkyRegions (void) |
Destructor. More... | |
GSkyRegions & | operator= (const GSkyRegions ®ions) |
Assignment operator. More... | |
GSkyRegion * | operator[] (const int &index) |
Return pointer to region. More... | |
const GSkyRegion * | operator[] (const int &index) const |
Return pointer to region (const version) More... | |
void | clear (void) |
Clear object. More... | |
GSkyRegions * | clone (void) const |
Clone instance. More... | |
std::string | classname (void) const |
Return class name. More... | |
GSkyRegion * | at (const int &index) |
Return pointer to region. More... | |
const GSkyRegion * | at (const int &index) const |
Return pointer to region (const version) More... | |
int | size (void) const |
Return number of regions in container. More... | |
bool | is_empty (void) const |
Signals if there are no regions in container. More... | |
GSkyRegion * | set (const int &index, const GSkyRegion ®ion) |
Set region in container. More... | |
GSkyRegion * | append (const GSkyRegion ®ion) |
Append region to container. More... | |
GSkyRegion * | insert (const int &index, const GSkyRegion ®ion) |
Insert region into container. More... | |
void | remove (const int &index) |
Remove region from container. More... | |
void | reserve (const int &num) |
Reserves space for regions in container. More... | |
void | extend (const GSkyRegions ®ions) |
Append region container. More... | |
bool | contains (const GSkyDir &dir) const |
Check if direction is contained in one of the regions. More... | |
bool | overlaps (const GSkyRegion ®ion) const |
Check if region overlaps one of the regions. More... | |
bool | overlaps (const GSkyRegions ®ions) const |
Check if any of the regions in two containers overlap. More... | |
void | load (const GFilename &filename) |
Load regions from DS9 region file. More... | |
void | save (const GFilename &filename) const |
Save regions into DS9 region file. More... | |
const GFilename & | filename (void) const |
Return regions file name. More... | |
void | filename (const GFilename &filename) |
Set regions file name. More... | |
std::string | print (const GChatter &chatter=NORMAL) const |
Print regions. More... | |
Public Member Functions inherited from GContainer | |
virtual | ~GContainer (void) |
Destructor. More... | |
Public Member Functions inherited from GBase | |
virtual | ~GBase (void) |
Destructor. More... | |
Protected Member Functions | |
void | init_members (void) |
Initialise class members. More... | |
void | copy_members (const GSkyRegions ®ions) |
Copy class members. More... | |
void | free_members (void) |
Delete class members. More... | |
Protected Attributes | |
GFilename | m_filename |
Filename of origin. More... | |
std::vector< GSkyRegion * > | m_regions |
List of regions. More... | |
Sky region container class.
This container class collects sky regions objects derived from the GSkyRegion abstract class. These can be accessed from the access operator[] or through the at() method with index checking. Access to the region can be done from index or name, so the name of each region in the container has to be unique.
The object can be initialised from a DS9 region file, and has load and save methods from/to a DS9 region file.
Definition at line 56 of file GSkyRegions.hpp.
GSkyRegions::GSkyRegions | ( | void | ) |
Void constructor.
Definition at line 70 of file GSkyRegions.cpp.
References init_members().
Referenced by clone().
GSkyRegions::GSkyRegions | ( | const GSkyRegions & | regions | ) |
Copy constructor.
[in] | regions | region container. |
Definition at line 85 of file GSkyRegions.cpp.
References copy_members(), and init_members().
|
explicit |
Load constructor.
[in] | filename | DS9 region file. |
Constructs region container from a DS9 region file.
Definition at line 105 of file GSkyRegions.cpp.
References init_members(), and load().
|
virtual |
GSkyRegion * GSkyRegions::append | ( | const GSkyRegion & | region | ) |
Append region to container.
[in] | region | region. |
GException::invalid_value | Name of region exists already in container. |
Appends region to the container by making a deep copy of the region and storing its pointer.
Definition at line 297 of file GSkyRegions.cpp.
References GSkyRegion::clone(), and m_regions.
Referenced by load(), and GCTAOnOffObservation::set().
GSkyRegion * GSkyRegions::at | ( | const int & | index | ) |
Return pointer to region.
[in] | index | Sky region index [0,...,size()[. |
GException::out_of_range | Sky region index is out of range. |
Returns a pointer to the region with the specified index
.
Definition at line 211 of file GSkyRegions.cpp.
const GSkyRegion * GSkyRegions::at | ( | const int & | index | ) | const |
Return pointer to region (const version)
[in] | index | Sky region index [0,...,size()[. |
GException::out_of_range | Sky region index is out of range. |
Returns a const pointer to the region with the specified index
.
Definition at line 234 of file GSkyRegions.cpp.
|
inlinevirtual |
Return class name.
Implements GBase.
Definition at line 111 of file GSkyRegions.hpp.
|
virtual |
Clear object.
Removes all regions from the container.
Implements GBase.
Definition at line 175 of file GSkyRegions.cpp.
References free_members(), and init_members().
Referenced by GCTAObservation::init_members(), and load().
|
virtual |
Clone instance.
Makes a deep copy of the region container instance.
Implements GBase.
Definition at line 195 of file GSkyRegions.cpp.
References GSkyRegions().
Referenced by extend().
bool GSkyRegions::contains | ( | const GSkyDir & | dir | ) | const |
Check if direction is contained in one of the regions.
[in] | dir | Sky direction. |
Checks if a sky direction is contained in one of the regions of the container.
Definition at line 430 of file GSkyRegions.cpp.
References m_regions, and size().
Referenced by GSkyMap::extract(), GSkyMap::flux(), GCTAOnOffObservation::set(), and GSkyMap::solidangle().
|
protected |
Copy class members.
[in] | regions | region container. |
Makes a copy of all class members. All regions are deep copied.
Definition at line 729 of file GSkyRegions.cpp.
References m_filename, and m_regions.
Referenced by GSkyRegions(), and operator=().
void GSkyRegions::extend | ( | const GSkyRegions & | regions | ) |
Append region container.
[in] | regions | region container. |
Append region container to the container.
Definition at line 392 of file GSkyRegions.cpp.
References clone(), is_empty(), m_regions, reserve(), and size().
|
inline |
Return regions file name.
Returns the file name from which the regions have been loaded or into which the regions have been saved. The returned string will be set if the load(), save() or filename() setter methods were called.
Definition at line 199 of file GSkyRegions.hpp.
References m_filename.
Referenced by filename(), load(), save(), and GCTAObservation::write().
|
inline |
Set regions file name.
[in] | filename | Regions file name. |
Set the regions file name.
Definition at line 213 of file GSkyRegions.hpp.
References filename(), and m_filename.
|
protected |
Delete class members.
Deallocates all regions. The method loops over the region container and deallocates the memory that has been allocated before.
Definition at line 750 of file GSkyRegions.cpp.
References m_regions.
Referenced by clear(), operator=(), and ~GSkyRegions().
|
protected |
Initialise class members.
Definition at line 711 of file GSkyRegions.cpp.
References GFilename::clear(), m_filename, and m_regions.
Referenced by clear(), GSkyRegions(), and operator=().
GSkyRegion * GSkyRegions::insert | ( | const int & | index, |
const GSkyRegion & | region | ||
) |
Insert region into container.
[in] | index | Sky region index [0,...,size()[. |
[in] | region | Sky region. |
GException::out_of_range | Sky region index is out of range. |
GException::invalid_value | Name of region exists already in container. |
Inserts a region
into the container before the region with the specified index
.
Definition at line 325 of file GSkyRegions.cpp.
References GSkyRegion::clone(), G_INSERT1, is_empty(), m_regions, and size().
|
inlinevirtual |
Signals if there are no regions in container.
Signals if the region container does not contain any region.
Implements GContainer.
Definition at line 167 of file GSkyRegions.hpp.
References m_regions.
void GSkyRegions::load | ( | const GFilename & | filename | ) |
Load regions from DS9 region file.
[in] | filename | DS9 region filename. |
GException::file_error | Unable to open file. |
Loads all regions from a DS9 region file.
Definition at line 514 of file GSkyRegions.cpp.
References append(), clear(), filename(), G_LOAD, m_filename, GSkyRegionCircle::read(), GSkyRegionRectangle::read(), and GFilename::url().
Referenced by GSkyRegions().
GSkyRegions & GSkyRegions::operator= | ( | const GSkyRegions & | regions | ) |
Assignment operator.
[in] | regions | region container. |
Definition at line 143 of file GSkyRegions.cpp.
References copy_members(), free_members(), and init_members().
|
inline |
Return pointer to region.
[in] | index | region index [0,...,size()-1]. |
Returns a pointer to the region with the specified index
.
Definition at line 125 of file GSkyRegions.hpp.
References m_regions.
|
inline |
Return pointer to region (const version)
[in] | index | region index [0,...,size()-1]. |
Returns a const pointer to the region with the specified index
.
Definition at line 139 of file GSkyRegions.hpp.
References m_regions.
bool GSkyRegions::overlaps | ( | const GSkyRegion & | region | ) | const |
Check if region overlaps one of the regions.
[in] | region | Sky region. |
region
overlaps with one of the regions in the region container, false otherwiseTells if region overlaps one of the regions
Definition at line 457 of file GSkyRegions.cpp.
References m_regions, and size().
Referenced by overlaps().
bool GSkyRegions::overlaps | ( | const GSkyRegions & | regions | ) | const |
Check if any of the regions in two containers overlap.
[in] | regions | Sky region container. |
regions
container overlaps with one of the regions in the container, false otherwiseTells if all regions in overlaps one of the regions. Note, this method returns true if ANY of the regions in the two containers overlap with each other
Definition at line 486 of file GSkyRegions.cpp.
References m_regions, overlaps(), and size().
Print regions.
[in] | chatter | Chattiness. |
Prints all regions into a string.
Implements GBase.
Definition at line 675 of file GSkyRegions.cpp.
References m_regions, gammalib::parformat(), SILENT, size(), and gammalib::str().
|
virtual |
Remove region from container.
[in] | index | Sky region index [0,...,size()[. |
GException::out_of_range | Sky region index is out of range. |
Remove sky region of specified index
from container.
Implements GContainer.
Definition at line 364 of file GSkyRegions.cpp.
|
inlinevirtual |
Reserves space for regions in container.
[in] | num | Number of regions |
Reserves space for num
regions in the container.
Implements GContainer.
Definition at line 181 of file GSkyRegions.hpp.
References m_regions.
Referenced by extend().
void GSkyRegions::save | ( | const GFilename & | filename | ) | const |
Save regions into DS9 region file.
[in] | filename | DS9 region filename. |
GException::file_error | Unable to open file. |
Saves all regions in the container into a DS9 region file.
Definition at line 627 of file GSkyRegions.cpp.
References filename(), G_SAVE, m_filename, m_regions, size(), and GFilename::url().
GSkyRegion * GSkyRegions::set | ( | const int & | index, |
const GSkyRegion & | region | ||
) |
Set region in container.
[in] | index | Sky region index [0,...,size()[. |
[in] | region | Sky region. |
GException::out_of_range | Sky region index is out of range. |
GException::invalid_value | Name of region exists already in container. |
Set sky region in the container. A deep copy of the region will be made.
Definition at line 261 of file GSkyRegions.cpp.
References GSkyRegion::clone(), G_SET1, m_regions, and size().
|
inlinevirtual |
Return number of regions in container.
Returns the number of regions in the region container.
Implements GContainer.
Definition at line 153 of file GSkyRegions.hpp.
References m_regions.
Referenced by GCTAOnOffObservation::arf_rad_max(), at(), GCTAOnOffObservation::compute_alpha(), GCTAOnOffObservation::compute_arf(), GCTAOnOffObservation::compute_arf_cut(), GCTAOnOffObservation::compute_bgd(), GCTAOnOffObservation::compute_rmf(), contains(), extend(), insert(), overlaps(), print(), remove(), save(), set(), and GCTAOnOffObservation::set().
|
mutableprotected |
Filename of origin.
Definition at line 100 of file GSkyRegions.hpp.
Referenced by copy_members(), filename(), init_members(), load(), and save().
|
protected |
List of regions.
Definition at line 101 of file GSkyRegions.hpp.
Referenced by append(), at(), contains(), copy_members(), extend(), free_members(), init_members(), insert(), is_empty(), operator[](), overlaps(), print(), remove(), reserve(), save(), set(), and size().