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