[764] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | #ifndef PIXELMAP_SEEN
|
---|
| 3 | #define PIXELMAP_SEEN
|
---|
| 4 |
|
---|
| 5 | #include "ppersist.h"
|
---|
| 6 | #include "dvlist.h"
|
---|
| 7 | #include "spherepos.h"
|
---|
| 8 | #include <iostream.h>
|
---|
| 9 |
|
---|
[1066] | 10 | namespace SOPHYA {
|
---|
| 11 |
|
---|
[1371] | 12 | /*!
|
---|
[1375] | 13 | \class PixelMap
|
---|
[1371] | 14 | \ingroup SkyMap
|
---|
| 15 | General map of pixels on part of sphere or whole sphere.
|
---|
| 16 |
|
---|
| 17 | Class hierarchy :
|
---|
[764] | 18 | \verbatim
|
---|
| 19 | PixelMap
|
---|
| 20 | SphericalMap
|
---|
| 21 | SphereThetaPhi
|
---|
[1371] | 22 | SphereHEALPix
|
---|
[764] | 23 | SphereIco
|
---|
| 24 | LocalMap
|
---|
| 25 | \endverbatim
|
---|
| 26 | */
|
---|
[908] | 27 |
|
---|
[764] | 28 | template<class T>
|
---|
| 29 | class PixelMap : public AnyDataObj
|
---|
| 30 | {
|
---|
| 31 | public:
|
---|
| 32 |
|
---|
| 33 | PixelMap(SphereCoordSys* cs = NULL) : mInfo_(NULL)
|
---|
| 34 | { if (cs) cs_ = cs; else cs_ = new SphereCoordSys; }
|
---|
| 35 | virtual ~PixelMap()
|
---|
| 36 | { if (mInfo_) delete mInfo_; if (cs_) delete cs_; }
|
---|
| 37 |
|
---|
| 38 | // Set/Change/Get the coordinate system
|
---|
| 39 | virtual void SetCoordSys(SphereCoordSys* cs)
|
---|
| 40 | { if (cs) { delete cs_; cs_ = cs; } }
|
---|
| 41 | inline SphereCoordSys* GetCoordSys() const { return(cs_); }
|
---|
| 42 |
|
---|
| 43 | /*! Number of pixels */
|
---|
| 44 | virtual int_4 NbPixels() const=0;
|
---|
| 45 |
|
---|
| 46 | /*! Value of pixel number k */
|
---|
| 47 | virtual T& PixVal(int_4 k)=0;
|
---|
| 48 | virtual T const& PixVal(int_4 k) const=0;
|
---|
| 49 |
|
---|
| 50 | // Map s coverage
|
---|
| 51 | virtual bool ContainsSph(double theta, double phi) const=0;
|
---|
| 52 | virtual bool Contains(const SpherePosition& spos) const;
|
---|
| 53 |
|
---|
| 54 | /*! Index of pixel at (theta,phi) */
|
---|
| 55 | virtual int_4 PixIndexSph(double theta, double phi) const=0;
|
---|
| 56 | // Index of pixel at a sky-position
|
---|
| 57 | virtual int_4 PixIndex(const SpherePosition& spos);
|
---|
| 58 |
|
---|
| 59 | /*! Value of pixel number at (theta,phi) */
|
---|
| 60 | virtual T& PixValSph(double theta, double phi)
|
---|
| 61 | {return PixVal(PixIndexSph(theta,phi));}
|
---|
| 62 | virtual T const& PixValSph(double theta, double phi) const
|
---|
| 63 | {return PixVal(PixIndexSph(theta,phi));}
|
---|
| 64 |
|
---|
| 65 | /*! Spherical coordinates of center of pixel number k */
|
---|
| 66 | virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const=0;
|
---|
| 67 |
|
---|
| 68 | /*! provides a integer characterizing the pixelization refinement
|
---|
| 69 | (depending of the type of the map)
|
---|
| 70 | */
|
---|
| 71 | virtual int_4 SizeIndex() const=0;
|
---|
| 72 | virtual char* TypeOfMap() const =0;
|
---|
| 73 |
|
---|
| 74 | /*! Pixel (steradians) */
|
---|
| 75 | virtual double PixSolAngle(int_4 k) const =0;
|
---|
| 76 |
|
---|
| 77 | /*! Setting blockdata to temporary (see ndatablock documentation) */
|
---|
| 78 | virtual void SetTemp(bool temp=false) const =0;
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | /*! Overloading of () to access pixel number k. */
|
---|
| 82 | inline T& operator()(int_4 k) {return(PixVal(k));}
|
---|
| 83 | inline T const& operator()(int_4 k) const {return(PixVal(k));}
|
---|
| 84 |
|
---|
| 85 | // Overloading of () to access pixel at a sky position .
|
---|
| 86 | inline T& operator()(const SpherePosition& spos)
|
---|
| 87 | { return(PixVal(PixIndex(spos))); }
|
---|
| 88 | inline T const& operator()(const SpherePosition& spos) const
|
---|
| 89 | { return(PixVal(PixIndex(spos))); }
|
---|
| 90 |
|
---|
| 91 |
|
---|
| 92 | // Note : no overloading of (double,double) to access pixel (theta,phi).
|
---|
| 93 | // overloading of (double,double) in SphericalMap
|
---|
| 94 | // overloading of (int,int) in CartesianMap
|
---|
| 95 |
|
---|
| 96 | /*! Setting pixel values to a constant */
|
---|
| 97 | virtual T SetPixels(T v);
|
---|
| 98 | inline T operator = (T v) { return(SetPixels(v)); }
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | //++
|
---|
| 103 | DVList& Info()
|
---|
| 104 | //
|
---|
| 105 | // Renvoie une reference sur l''objet DVList Associe
|
---|
| 106 | //--
|
---|
| 107 | {
|
---|
| 108 | if (mInfo_ == NULL) mInfo_ = new DVList;
|
---|
| 109 | return(*mInfo_);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | const DVList* ptrInfo() const
|
---|
| 113 | {
|
---|
| 114 | return mInfo_;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | protected :
|
---|
| 118 | SphereCoordSys *cs_; // Coordinate system used in the map
|
---|
| 119 | DVList* mInfo_; // Infos (variables) attachees
|
---|
| 120 | };
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | template <class T>
|
---|
| 124 | int_4 PixelMap<T>::PixIndex(const SpherePosition& spos)
|
---|
| 125 | {
|
---|
| 126 | UnitVector v = spos.Transform(*cs_);
|
---|
| 127 | return(PixIndexSph(v.Theta(), v.Phi()));
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | template <class T>
|
---|
| 131 | bool PixelMap<T>::Contains(const SpherePosition& spos) const
|
---|
| 132 | {
|
---|
| 133 | UnitVector v = spos.Transform(*cs_);
|
---|
| 134 | return(ContainsSph(v.Theta(), v.Phi()));
|
---|
| 135 | }
|
---|
| 136 | template <class T>
|
---|
| 137 | T PixelMap<T>::SetPixels(T v)
|
---|
| 138 | {
|
---|
| 139 | int k;
|
---|
| 140 | for(k=0; k<NbPixels(); k++) PixVal(k) = v;
|
---|
| 141 | return(v);
|
---|
| 142 | }
|
---|
| 143 |
|
---|
[908] | 144 |
|
---|
| 145 | } // Fin du namespace
|
---|
| 146 |
|
---|
[764] | 147 | #endif
|
---|