From 6dcfd38870e212ae8e28eab2d5f83bc468f6487f Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 13 Mar 2015 22:34:37 +0100 Subject: [PATCH] Add contains() method to GModelSpatialDiffuse class. --- include/GModelSpatialDiffuse.hpp | 4 +++- include/GModelSpatialDiffuseConst.hpp | 23 ++++++++++++++++++++++- include/GModelSpatialDiffuseCube.hpp | 4 +++- include/GModelSpatialDiffuseMap.hpp | 4 +++- pyext/GModelSpatialDiffuse.i | 2 ++ pyext/GModelSpatialDiffuseConst.i | 2 ++ pyext/GModelSpatialDiffuseCube.i | 2 ++ pyext/GModelSpatialDiffuseMap.i | 2 ++ src/model/GModelSpatialDiffuseCube.cpp | 20 +++++++++++++++++++- src/model/GModelSpatialDiffuseMap.cpp | 18 ++++++++++++++++++ 10 files changed, 76 insertions(+), 5 deletions(-) diff --git a/include/GModelSpatialDiffuse.hpp b/include/GModelSpatialDiffuse.hpp index 2fd00bc..b8e36d8 100644 --- a/include/GModelSpatialDiffuse.hpp +++ b/include/GModelSpatialDiffuse.hpp @@ -57,7 +57,7 @@ public: // Operators virtual GModelSpatialDiffuse& operator=(const GModelSpatialDiffuse& model); - // Pure virtual base class methods + // Pure virtual methods virtual void clear(void) = 0; virtual GModelSpatialDiffuse* clone(void) const = 0; virtual std::string classname(void) const = 0; @@ -68,6 +68,8 @@ public: GRan& ran) const = 0; virtual double norm(const GSkyDir& dir, const double& radius) const = 0; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const = 0; virtual void read(const GXmlElement& xml) = 0; virtual void write(GXmlElement& xml) const = 0; virtual std::string print(const GChatter& chatter = NORMAL) const = 0; diff --git a/include/GModelSpatialDiffuseConst.hpp b/include/GModelSpatialDiffuseConst.hpp index 7d405fb..dba26b1 100644 --- a/include/GModelSpatialDiffuseConst.hpp +++ b/include/GModelSpatialDiffuseConst.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseConst.hpp - Spatial isotropic model class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2014 by Juergen Knoedlseder * + * copyright (C) 2010-2015 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -69,6 +69,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; @@ -158,4 +160,23 @@ double GModelSpatialDiffuseConst::norm(const GSkyDir& dir, return (value()); } + +/***********************************************************************//** + * @brief Signals whether model contains sky direction + * + * @param[in] dir Sky direction. + * @param[in] margin Margin to be added to sky direction (degrees) + * @return True. + * + * Signals whether a sky direction falls within the diffuse model. As the + * constrant model is defined on the entire sphere, the method returns always + * true. + ***************************************************************************/ +inline +bool GModelSpatialDiffuseConst::contains(const GSkyDir& dir, + const double& margin) const +{ + return (true); +} + #endif /* GMODELSPATIALDIFFUSECONST_HPP */ diff --git a/include/GModelSpatialDiffuseCube.hpp b/include/GModelSpatialDiffuseCube.hpp index ba0001b..4c23443 100644 --- a/include/GModelSpatialDiffuseCube.hpp +++ b/include/GModelSpatialDiffuseCube.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseCube.hpp - Spatial map cube model class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2014 by Juergen Knoedlseder * + * copyright (C) 2010-2015 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -80,6 +80,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; diff --git a/include/GModelSpatialDiffuseMap.hpp b/include/GModelSpatialDiffuseMap.hpp index 9f51675..92dc4f6 100644 --- a/include/GModelSpatialDiffuseMap.hpp +++ b/include/GModelSpatialDiffuseMap.hpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseMap.hpp - Spatial map model class * * ----------------------------------------------------------------------- * - * copyright (C) 2012-2014 by Juergen Knoedlseder * + * copyright (C) 2012-2015 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -75,6 +75,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; virtual std::string print(const GChatter& chatter = NORMAL) const; diff --git a/pyext/GModelSpatialDiffuse.i b/pyext/GModelSpatialDiffuse.i index 170c8fc..3d22b74 100644 --- a/pyext/GModelSpatialDiffuse.i +++ b/pyext/GModelSpatialDiffuse.i @@ -52,6 +52,8 @@ public: GRan& ran) const = 0; virtual double norm(const GSkyDir& dir, const double& radius) const = 0; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const = 0; virtual void read(const GXmlElement& xml) = 0; virtual void write(GXmlElement& xml) const = 0; }; diff --git a/pyext/GModelSpatialDiffuseConst.i b/pyext/GModelSpatialDiffuseConst.i index b0e79e2..124ba90 100644 --- a/pyext/GModelSpatialDiffuseConst.i +++ b/pyext/GModelSpatialDiffuseConst.i @@ -55,6 +55,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpatialDiffuseCube.i b/pyext/GModelSpatialDiffuseCube.i index 79aa774..8ff4545 100644 --- a/pyext/GModelSpatialDiffuseCube.i +++ b/pyext/GModelSpatialDiffuseCube.i @@ -59,6 +59,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/pyext/GModelSpatialDiffuseMap.i b/pyext/GModelSpatialDiffuseMap.i index 52ff990..53f15d6 100644 --- a/pyext/GModelSpatialDiffuseMap.i +++ b/pyext/GModelSpatialDiffuseMap.i @@ -60,6 +60,8 @@ public: GRan& ran) const; virtual double norm(const GSkyDir& dir, const double& radius) const; + virtual bool contains(const GSkyDir& dir, + const double& margin = 0.0) const; virtual void read(const GXmlElement& xml); virtual void write(GXmlElement& xml) const; diff --git a/src/model/GModelSpatialDiffuseCube.cpp b/src/model/GModelSpatialDiffuseCube.cpp index 3b78e8c..1c6d4df 100644 --- a/src/model/GModelSpatialDiffuseCube.cpp +++ b/src/model/GModelSpatialDiffuseCube.cpp @@ -1,7 +1,7 @@ /*************************************************************************** * GModelSpatialDiffuseCube.cpp - Spatial map cube model class * * ----------------------------------------------------------------------- * - * copyright (C) 2010-2014 by Juergen Knoedlseder * + * copyright (C) 2010-2015 by Juergen Knoedlseder * * ----------------------------------------------------------------------- * * * * This program is free software: you can redistribute it and/or modify * @@ -473,6 +473,24 @@ GSkyDir GModelSpatialDiffuseCube::mc(const GEnergy& energy, /***********************************************************************//** + * @brief Signals whether model contains sky direction + * + * @param[in] dir Sky direction. + * @param[in] margin Margin to be added to sky direction (degrees) + * @return True if the model contains the sky direction. + * + * Signals whether a sky direction falls within the diffuse model. + * + * @todo To be implemented. + ***************************************************************************/ +bool GModelSpatialDiffuseCube::contains(const GSkyDir& dir, + const double& margin) const +{ + return (true); +} + + +/***********************************************************************//** * @brief Read model from XML element * * @param[in] xml XML element. diff --git a/src/model/GModelSpatialDiffuseMap.cpp b/src/model/GModelSpatialDiffuseMap.cpp index 0278637..4474a57 100644 --- a/src/model/GModelSpatialDiffuseMap.cpp +++ b/src/model/GModelSpatialDiffuseMap.cpp @@ -393,6 +393,24 @@ GSkyDir GModelSpatialDiffuseMap::mc(const GEnergy& energy, /***********************************************************************//** + * @brief Signals whether model contains sky direction + * + * @param[in] dir Sky direction. + * @param[in] margin Margin to be added to sky direction (degrees) + * @return True if the model contains the sky direction. + * + * Signals whether a sky direction falls within the diffuse model. + * + * @todo To be implemented. + ***************************************************************************/ +bool GModelSpatialDiffuseMap::contains(const GSkyDir& dir, + const double& margin) const +{ + return (true); +} + + +/***********************************************************************//** * @brief Read model from XML element * * @param[in] xml XML element. -- libgit2 0.21.4