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