1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | #ifndef LOCALMAP_SEEN
|
---|
3 | #define LOCALMAP_SEEN
|
---|
4 |
|
---|
5 | #include "pixelmap.h"
|
---|
6 | #include "sphericalmap.h"
|
---|
7 | #include "ndatablock.h"
|
---|
8 |
|
---|
9 | #include "anydataobj.h"
|
---|
10 | #include "ppersist.h"
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | // ***************** Class LocalMap *****************************
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 | namespace SOPHYA {
|
---|
19 |
|
---|
20 |
|
---|
21 | /* Class LocalMap */
|
---|
22 |
|
---|
23 |
|
---|
24 | template<class T>
|
---|
25 | class LocalMap : public PixelMap<T>
|
---|
26 | {
|
---|
27 |
|
---|
28 | public:
|
---|
29 |
|
---|
30 | LocalMap();
|
---|
31 | LocalMap(int_4 nx, int_4 ny);
|
---|
32 | LocalMap(const LocalMap<T>& lm, bool share);
|
---|
33 | LocalMap(const LocalMap<T>& lm);
|
---|
34 | virtual ~LocalMap();
|
---|
35 |
|
---|
36 | inline virtual bool IsTemp(void) const { return pixels_.IsTemp();}
|
---|
37 |
|
---|
38 | /*! Setting blockdata to temporary (see ndatablock documentation) */
|
---|
39 | inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);};
|
---|
40 |
|
---|
41 |
|
---|
42 | // ---------- Overloading of () to access pixel number k ----
|
---|
43 |
|
---|
44 | inline T& operator()(int_4 k) {return(PixVal(k));}
|
---|
45 | inline T const& operator()(int_4 k) const {return(PixVal(k));}
|
---|
46 | inline T& operator()(int_4 ix, int_4 iy) {return PixVal(iy*nSzX_+ix);};
|
---|
47 | inline T const& operator()(int_4 ix, int_4 iy) const {return PixVal(iy*nSzX_+ix);};
|
---|
48 |
|
---|
49 | // ---------- Definition of PixelMap abstract methods -------
|
---|
50 |
|
---|
51 | virtual int_4 NbPixels() const; // D.Y. int change en int_4 rationalisation Mac
|
---|
52 |
|
---|
53 | virtual T& PixVal(int_4 k);
|
---|
54 | virtual T const& PixVal(int_4 k) const;
|
---|
55 |
|
---|
56 | virtual bool ContainsSph(double theta, double phi) const;
|
---|
57 | virtual int_4 PixIndexSph(double theta,double phi) const;
|
---|
58 |
|
---|
59 | virtual void PixThetaPhi(int_4 k,double& theta,double& phi) const;
|
---|
60 |
|
---|
61 | virtual T SetPixels(T v);
|
---|
62 |
|
---|
63 | virtual double PixSolAngle(int_4 k) const;
|
---|
64 |
|
---|
65 | // ---------- Specific methods ------------------------------
|
---|
66 |
|
---|
67 | void ReSize(int_4 nx, int_4 ny);
|
---|
68 |
|
---|
69 | inline virtual char* TypeOfMap() const {return "LOCAL";};
|
---|
70 |
|
---|
71 | virtual void SetOrigin(double theta=90.,double phi=0.,double angle=0.);
|
---|
72 | virtual void SetOrigin(double theta,double phi,int_4 x0,int_4 y0,double angle=0.);
|
---|
73 |
|
---|
74 | virtual void SetSize(double angleX,double angleY);
|
---|
75 |
|
---|
76 | /*! Check to see if the local mapping is done */
|
---|
77 | inline bool LocalMap_isDone() const {return(originFlag_ && extensFlag_);};
|
---|
78 |
|
---|
79 | virtual void Project(SphericalMap<T>& sphere) const;
|
---|
80 |
|
---|
81 | /* There should be a more complex algorithm somewhere to combine *several* local maps to a full sphere.
|
---|
82 | -> static method, or separate class */
|
---|
83 |
|
---|
84 | /*! provides a integer characterizing the pixelization refinement (here : number of pixels) */
|
---|
85 | inline virtual int_4 SizeIndex() const {return(nPix_);}
|
---|
86 | inline int_4 Size_x() const {return nSzX_;}
|
---|
87 | inline int_4 Size_y() const {return nSzY_;}
|
---|
88 |
|
---|
89 | /* Je rajoute ces 2 fonctions inlines pour compatibilite d'interface
|
---|
90 | avec TArray - Reza 30/8/2000 */
|
---|
91 | inline int_4 SizeX() const {return nSzX_;}
|
---|
92 | inline int_4 SizeY() const {return nSzY_;}
|
---|
93 |
|
---|
94 | inline void Origin(double& theta,double& phi,int_4& x0,int_4& y0,double& angle) const {theta= theta0_; phi= phi0_; x0= x0_; y0= y0_;angle= angle_;}
|
---|
95 |
|
---|
96 | inline void Aperture(double& anglex,double& angley) const {anglex= angleX_; angley= angleY_;}
|
---|
97 |
|
---|
98 |
|
---|
99 | /* Acces to the DataBlock */
|
---|
100 | inline NDataBlock<T>& DataBlock() {return pixels_;}
|
---|
101 | inline const NDataBlock<T>& DataBlock() const {return pixels_;}
|
---|
102 |
|
---|
103 | /* impression */
|
---|
104 | void print(ostream& os) const;
|
---|
105 |
|
---|
106 | // Operations diverses = , +=, ...
|
---|
107 |
|
---|
108 |
|
---|
109 | virtual LocalMap<T>& Set(const LocalMap<T>& a);
|
---|
110 | inline LocalMap<T>& operator = (const LocalMap<T>& a) {return Set(a);}
|
---|
111 |
|
---|
112 | // A += -= *= /= x (ajoute, soustrait, ... x a tous les elements)
|
---|
113 |
|
---|
114 | //! Fill LocalMap with all elements equal to \b x
|
---|
115 | virtual LocalMap<T>& SetT(T a);
|
---|
116 | inline LocalMap<T>& operator = (T a) {return SetT(a);}
|
---|
117 |
|
---|
118 | //! Add \b x to all elements
|
---|
119 | virtual LocalMap<T>& Add(T a);
|
---|
120 | inline LocalMap<T>& operator += (T x) { return Add(x); }
|
---|
121 | //! Substract \b x to all elements
|
---|
122 | virtual LocalMap<T>& Sub(T a);
|
---|
123 | inline LocalMap<T>& operator -= (T x) { return Sub(x); }
|
---|
124 | //! Multiply all elements by \b x
|
---|
125 | virtual LocalMap<T>& Mul(T a);
|
---|
126 | inline LocalMap<T>& operator *= (T x) { return Mul(x); }
|
---|
127 | //! Divide all elements by \b x
|
---|
128 | virtual LocalMap<T>& Div(T a);
|
---|
129 | inline LocalMap<T>& operator /= (T x) { return Div(x); }
|
---|
130 |
|
---|
131 | // A += -= (ajoute, soustrait element par element les deux spheres )
|
---|
132 | //! Operator LocalMap += LocalMap
|
---|
133 | virtual LocalMap<T>& AddElt(const LocalMap<T>& a);
|
---|
134 | inline LocalMap<T>& operator += (const LocalMap<T>& a) { return AddElt(a); }
|
---|
135 |
|
---|
136 |
|
---|
137 |
|
---|
138 | virtual LocalMap<T>& SubElt(const LocalMap<T>& a);
|
---|
139 | //! Operator LocalMap -= LocalMap
|
---|
140 | inline LocalMap<T>& operator -= (const LocalMap<T>& a) { return SubElt(a); }
|
---|
141 | // Multiplication, division element par element les deux LocalMap
|
---|
142 | virtual LocalMap<T>& MulElt(const LocalMap<T>& a);
|
---|
143 | inline LocalMap<T>& operator *= (const LocalMap<T>& a) { return MulElt(a); }
|
---|
144 |
|
---|
145 |
|
---|
146 | void CloneOrShare(const LocalMap<T>& a);
|
---|
147 | void Share(const LocalMap<T>& a);
|
---|
148 | LocalMap<T>& CopyElt(const LocalMap<T>& a);
|
---|
149 |
|
---|
150 |
|
---|
151 | // ---------- Méthodes internes -----------------------------
|
---|
152 |
|
---|
153 | private :
|
---|
154 |
|
---|
155 | void InitNul();
|
---|
156 | void Getij(int_4 k,int_4& i,int_4& j) const;
|
---|
157 | void ReferenceToUser(double& theta,double& phi) const;
|
---|
158 | void UserToReference(double& theta,double& phi) const;
|
---|
159 | void PixProjToAngle(double x,double y,double& theta,double& phi) const;
|
---|
160 | void AngleProjToPix(double theta,double phi,double& x,double& y) const;
|
---|
161 |
|
---|
162 | void recopierVariablesSimples(const LocalMap<T>& lm);
|
---|
163 |
|
---|
164 |
|
---|
165 | // ---------- Variables internes ----------------------------
|
---|
166 |
|
---|
167 | int_4 nSzX_;
|
---|
168 | int_4 nSzY_;
|
---|
169 | int_4 nPix_;
|
---|
170 | bool originFlag_;
|
---|
171 | bool extensFlag_;
|
---|
172 | int_4 x0_;
|
---|
173 | int_4 y0_;
|
---|
174 | double theta0_;
|
---|
175 | double phi0_;
|
---|
176 | double angle_;
|
---|
177 | double cos_angle_;
|
---|
178 | double sin_angle_;
|
---|
179 | double angleX_;
|
---|
180 | double angleY_;
|
---|
181 | double tgAngleX_;
|
---|
182 | double tgAngleY_;
|
---|
183 | NDataBlock<T> pixels_;
|
---|
184 | };
|
---|
185 |
|
---|
186 | ////////////////////////////////////////////////////////////////
|
---|
187 | // Surcharge d'operateurs A (+,-,*,/) (T) x
|
---|
188 | /*! \ingroup SkyMap \fn operator+(const LocalMap<T>&,T)
|
---|
189 | \brief Operator LocalMap = LocalMap + constant */
|
---|
190 | template <class T> inline LocalMap<T> operator + (const LocalMap<T>& a, T b)
|
---|
191 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
192 | result.Add(b); return result;}
|
---|
193 | /*! \ingroup SkyMap \fn operator+(T,const LocalMap<T>&)
|
---|
194 | \brief Operator LocalMap = constant + LocalMap */
|
---|
195 | template <class T> inline LocalMap<T> operator + (T b,const LocalMap<T>& a)
|
---|
196 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
197 | result.Add(b); return result;}
|
---|
198 |
|
---|
199 |
|
---|
200 | /*! \ingroup SkyMap\fn operator-(const LocalMap<T>&,T)
|
---|
201 | \brief Operator LocalMap = LocalMap - constant */
|
---|
202 | template <class T> inline LocalMap<T> operator - (const LocalMap<T>& a, T b)
|
---|
203 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
204 | result.Sub(b); return result;}
|
---|
205 |
|
---|
206 | /*! \ingroup \fn operator-(T,const LocalMap<T>&)
|
---|
207 | \brief Operator LocalMap = constant - LocalMap */
|
---|
208 | template <class T> inline LocalMap<T> operator - (T b,const LocalMap<T>& a)
|
---|
209 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
210 | result.Sub(b,true); return result;}
|
---|
211 |
|
---|
212 | /*! \ingroup SkyMap \fn operator*(const LocalMap<T>&,T)
|
---|
213 | \brief Operator LocalMap = LocalMap * constant */
|
---|
214 | template <class T> inline LocalMap<T> operator * (const LocalMap<T>& a, T b)
|
---|
215 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
216 | result.Mul(b); return result;}
|
---|
217 |
|
---|
218 | /*! \ingroup SkyMap \fn operator*(T,const LocalMap<T>&)
|
---|
219 | \brief Operator LocalMap = constant * LocalMap */
|
---|
220 | template <class T> inline LocalMap<T> operator * (T b,const LocalMap<T>& a)
|
---|
221 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
222 | result.Mul(b); return result;}
|
---|
223 |
|
---|
224 | /*! \ingroup SkyMap \fn operator/(const LocalMap<T>&,T)
|
---|
225 | \brief Operator LocalMap = LocalMap / constant */
|
---|
226 | template <class T> inline LocalMap<T> operator / (const LocalMap<T>& a, T b)
|
---|
227 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
228 | result.Div(b); return result;}
|
---|
229 |
|
---|
230 | /*! \ingroup SkyMap \fn operator/(T,const LocalMap<T>&)
|
---|
231 | \brief Operator LocalMap = constant / LocalMap */
|
---|
232 | template <class T> inline LocalMap<T> operator / (T b, const LocalMap<T>& a)
|
---|
233 | {LocalMap<T> result; result.CloneOrShare(a); result.SetTemp(true);
|
---|
234 | result.Div(b, true); return result;}
|
---|
235 |
|
---|
236 | ////////////////////////////////////////////////////////////////
|
---|
237 | // Surcharge d'operateurs C = A (+,-) B
|
---|
238 |
|
---|
239 | /*! \ingroup SkyMap \fn operator+(const LocalMap<T>&,const LocalMap<T>&)
|
---|
240 | \brief Operator LocalMap = LocalMap + LocalMap */
|
---|
241 | template <class T>
|
---|
242 | inline LocalMap<T> operator + (const LocalMap<T>& a,const LocalMap<T>& b)
|
---|
243 | { LocalMap<T> result; result.SetTemp(true);
|
---|
244 | if (b.IsTemp()) { result.Share(b); result.AddElt(a); }
|
---|
245 | else { result.CloneOrShare(a); result.AddElt(b); }
|
---|
246 | return result; }
|
---|
247 |
|
---|
248 | /*! \ingroup SkyMap \fn operator-(const LocalMap<T>&,const LocalMap<T>&)
|
---|
249 | \brief Operator LocalMap = LocalMap - LocalMap */
|
---|
250 | template <class T>
|
---|
251 | inline LocalMap<T> operator - (const LocalMap<T>& a,const LocalMap<T>& b)
|
---|
252 | { LocalMap<T> result; result.SetTemp(true);
|
---|
253 | if (b.IsTemp()) { result.Share(b); result.SubElt(a, true); }
|
---|
254 | else { result.CloneOrShare(a); result.SubElt(b); }
|
---|
255 | return result; }
|
---|
256 |
|
---|
257 |
|
---|
258 | } // Fin du namespace
|
---|
259 |
|
---|
260 | #endif
|
---|