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