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