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