source: Sophya/trunk/SophyaLib/SkyMap/spherethetaphi.h@ 917

Last change on this file since 917 was 908, checked in by ansari, 25 years ago

divers nettoyages : const. de copie, surcharge = etc.

File size: 6.9 KB
Line 
1#ifndef SPHERETHETAPHI_SEEN
2#define SPHERETHETAPHI_SEEN
3
4#include "sphericalmap.h"
5#include "ndatablock.h"
6#include "tvector.h"
7
8#include "anydataobj.h"
9#include "ppersist.h"
10
11namespace SOPHYA {
12
13
14
15template <class T>
16class FIO_SphereThetaPhi;
17
18
19// ***************** Class SphereThetaPhi *****************************
20/*! sphere splitted with respect to theta, phi : each hemisphere is
21 splitted into (m-1) parallels (equator does not enter into account).
22 This operation defines m slices, each of which is splitted into
23 equidistant meridians. This splitting is realized in such a way that
24 all pixels have the same area and are as square as possible.
25
26 One begins with the hemisphere with positive z, starting from the pole
27 toward the equator. The first pixel is the polar cap ; it is circular
28 and centered on theta=0.
29*/
30template <class T>
31class SphereThetaPhi : public SphericalMap<T>
32{
33
34 friend class FIO_SphereThetaPhi<T>;
35
36public :
37
38SphereThetaPhi();
39/*! m is the number of slices in theta on an hemisphere (the polar cap
40 forms the first slice).
41 pet is a dummy parameter at the moment.
42*/
43SphereThetaPhi(int_4 m);
44SphereThetaPhi(const SphereThetaPhi<T>& s, bool share);
45SphereThetaPhi(const SphereThetaPhi<T>& s);
46virtual ~SphereThetaPhi();
47
48 // Temporaire?
49inline virtual bool IsTemp(void) const {
50
51 if ( NPhi_.IsTemp() != pixels_.IsTemp() ||
52 TNphi_.IsTemp() != pixels_.IsTemp()||
53 Theta_.IsTemp() != pixels_.IsTemp() )
54 throw PException(" l'etat 'temporaire' de la spherethetaphi est incoherent");
55 return pixels_.IsTemp();
56}
57/*! Setting blockdata to temporary (see ndatablock documentation) */
58inline virtual void SetTemp(bool temp=false) const
59 {
60 NPhi_.SetTemp(temp);
61 TNphi_.SetTemp(temp);
62 Theta_.SetTemp(temp);
63 pixels_.SetTemp(temp);
64 };
65
66// ------------ Definition of PixelMap abstract methods -
67
68/* retourne le nombre de pixels */
69/*! Return total number of pixels */
70virtual int_4 NbPixels() const;
71
72/* retourne la valeur du pixel d'indice k */
73/*! Return value of pixel with index k */
74virtual T& PixVal(int_4 k);
75virtual T const& PixVal(int_4 k) const;
76
77/* Return true if teta,phi in map */
78virtual bool ContainsSph(double theta, double phi) const;
79/* retourne l'indice du pixel a (theta,phi) */
80/* Return index of the pixel corresponding to direction (theta, phi). */
81virtual int_4 PixIndexSph(double theta, double phi) const;
82
83/* retourne les coordonnees Spheriques du centre du pixel d'indice k */
84/*! Return (theta,phi) coordinates of middle of pixel with index k */
85virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
86
87/*! Setting pixel values to a constant */
88virtual T SetPixels(T v);
89
90/* retourne/fixe l'angle Solide de Pixel (steradians) */
91/*! Pixel Solid angle (steradians)
92
93 All the pixels have the same solid angle. The dummy argument is
94 for compatibility with eventual pixelizations which would not
95 fulfil this requirement.
96*/
97virtual double PixSolAngle(int_4 dummy=0) const;
98
99/* retourne/fixe la valeur du parametre de decoupage m */
100inline virtual int_4 SizeIndex() const { return( NTheta_); }
101
102/* Acces to the DataBlock */
103inline NDataBlock<T>& DataBlock() {return pixels_;}
104inline const NDataBlock<T>& DataBlock() const {return pixels_;}
105
106// ------------- Specific methods ----------------------
107
108/*! re-pixelize the sphere */
109virtual void Resize(int_4 m);
110
111inline virtual char* TypeOfMap() const {return "TETAFI";};
112
113/* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
114/* Return values of theta,phi which limit the pixel with index k */
115virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
116
117/* Nombre de tranches en theta */
118/*! Return number of theta-slices on the sphere */
119uint_4 NbThetaSlices() const;
120
121/* Nombre de pixels en phi de la tranche d'indice kt */
122int_4 NPhi(int_4 kt) const;
123
124/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
125/* de la tranche d'indice kt */
126/*! Return theta values which limit the slice kt */
127void Theta(int_4 kt, double& t1, double& t2);
128
129/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
130/* dans la tranche d'indice kt */
131/*! Return values of phi which limit the jp-th pixel of the kt-th slice */
132void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
133
134/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
135/*! Return pixel index with sequence index jp in the slice kt */
136int_4 Index(int_4 kt, int_4 jp) const;
137
138/* Indice kt de la tranche et indice jp du pixel d'indice k */
139/*! Return indices kt (theta) and jp (phi) of pixel with index k */
140void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
141
142/*! achieve the splitting into pixels (m has the same signification
143 as for the constructor)
144
145 Each theta-slice of the north hemisphere will be spitted starting f
146 from phi=0 ...
147
148 South hemisphere is scanned in the same direction according to phi
149 and from equator to the pole (the pixel following the last one of
150 the slice closest to the equator with z>0, is the pixel with lowest
151 phi of the slice closest of the equator with z<0).
152*/
153void Pixelize(int_4);
154
155/*! For a theta-slice with index 'index', return :
156
157 the corresponding "theta"
158
159 a vector containing the phi's of the pixels of the slice
160
161 a vector containing the corresponding values of pixels
162*/
163virtual void GetThetaSlice(int_4 index,r_8& theta,TVector<r_8>& phi,TVector<T>& value) const;
164
165/*! For a theta-slice with index 'index', return :
166
167 the corresponding "theta"
168
169 the corresponding "phi" for first pixel of the slice
170
171 a vector containing indices of the pixels of the slice
172
173 (equally distributed in phi)
174
175 a vector containing the corresponding values of pixels
176*/
177virtual void GetThetaSlice(int_4 index, r_8& theta, r_8& phi0,TVector<int_4>& pixelIndices, TVector<T>& value) const ;
178
179
180/* impression */
181void print(ostream& os) const;
182
183inline SphereThetaPhi<T>& operator = (const SphereThetaPhi<T>& a)
184 {return Set(a);}
185
186
187private :
188
189// ------------- méthodes internes ----------------------
190void InitNul();
191inline void setParameters( int nbThetaIndex, int nbpix, double omega)
192 {
193 NPix_= nbpix;
194 Omega_= omega;
195 NTheta_= nbThetaIndex;
196 }
197void CloneOrShare(const SphereThetaPhi<T>& a);
198
199SphereThetaPhi<T>& Set(const SphereThetaPhi<T>& a);
200
201// ------------- variables internes ---------------------
202 int_4 NTheta_; // nombre de tranches en theta, pour une demi-sphere
203 int_4 NPix_; // nombre total de pixels
204 double Omega_; // angle solide constant pour chaque pixel
205 NDataBlock<int_4> NPhi_; // tableau donnant, pour chaque bande en theta,
206 //le nombre de pixels selon phi
207 NDataBlock<int_4> TNphi_;
208 NDataBlock<r_8> Theta_;
209 NDataBlock<T> pixels_;
210};
211
212
213
214} // Fin du namespace
215
216#endif
Note: See TracBrowser for help on using the repository browser.