source: Sophya/trunk/SophyaLib/Samba/spherethetaphi.h@ 568

Last change on this file since 568 was 565, checked in by ansari, 26 years ago

ajout doc GLM

File size: 6.3 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
11// ***************** Class SphereThetaPhi *****************************
12/*! sphere splitted with respect to theta, phi : each hemisphere is
13 splitted into (m-1) parallels (equator does not enter into account).
14 This operation defines m slices, each of which is splitted into
15 equidistant meridians. This splitting is realized in such a way that
16 all pixels have the same area and are as square as possible.
17
18 One begins with the hemisphere with positive z, starting from the pole
19 toward the equator. The first pixel is the polar cap ; it is circular
20 and centered on theta=0.
21*/
22template <class T>
23class SphereThetaPhi : public SphericalMap<T>, public AnyDataObj
24{
25
26public :
27
28SphereThetaPhi();
29/*! m is the number of slices in theta on an hemisphere (the polar cap
30 forms the first slice).
31 pet is a dummy parameter at the moment.
32*/
33SphereThetaPhi(int m);
34SphereThetaPhi(const SphereThetaPhi<T>& s);
35virtual ~SphereThetaPhi();
36
37// ------------ Definition of PixelMap abstract methods -
38
39/* retourne/fixe le nombre de pixels */
40/*! Return total number of pixels */
41virtual int NbPixels() const;
42inline void setNbPixels(int nbpix) { NPix_= nbpix; }
43
44/* retourne la valeur du pixel d'indice k */
45/*! Return value of pixel with index k */
46virtual T& PixVal(int k);
47virtual T const& PixVal(int k) const;
48
49/* Return true if teta,phi in map */
50virtual bool ContainsSph(double theta, double phi) const;
51/* retourne l'indice du pixel a (theta,phi) */
52/* Return index of the pixel corresponding to direction (theta, phi). */
53virtual int PixIndexSph(double theta, double phi) const;
54
55/* retourne les coordonnees Spheriques du centre du pixel d'indice k */
56/*! Return (theta,phi) coordinates of middle of pixel with index k */
57virtual void PixThetaPhi(int k, double& theta, double& phi) const;
58
59/* retourne/fixe l'angle Solide de Pixel (steradians) */
60/*! Pixel Solid angle (steradians)
61
62 All the pixels have the same solid angle. The dummy argument is
63 for compatibility with eventual pixelizations which would not
64 fulfil this requirement.
65*/
66virtual double PixSolAngle(int dummy) const;
67inline void setPixSolAngle(double omega) { Omega_= omega; }
68
69/* retourne/fixe la valeur du parametre de decoupage m */
70inline virtual int SizeIndex() const { return( NTheta_); }
71inline void setSizeIndex(int nbindex) { NTheta_= nbindex; }
72
73// ------------- Specific methods ----------------------
74
75/*! re-pixelize the sphere */
76virtual void Resize(int m);
77
78inline virtual char* TypeOfMap() const {return "TETAFI";};
79
80/* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
81/* Return values of theta,phi which limit the pixel with index k */
82virtual void Limits(int k,double& th1,double& th2,double& phi1,double& phi2);
83
84/* Nombre de tranches en theta */
85/*! Return number of theta-slices on the sphere */
86int NbThetaSlices() const;
87
88/* Nombre de pixels en phi de la tranche d'indice kt */
89int NPhi(int kt) const;
90
91/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
92/* de la tranche d'indice kt */
93/*! Return theta values which limit the slice kt */
94void Theta(int kt, double& t1, double& t2);
95
96/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
97/* dans la tranche d'indice kt */
98/*! Return values of phi which limit the jp-th pixel of the kt-th slice */
99void Phi(int kt, int jp, double& p1, double& p2);
100
101/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
102/*! Return pixel index with sequence index jp in the slice kt */
103int Index(int kt, int jp) const;
104
105/* Indice kt de la tranche et indice jp du pixel d'indice k */
106/*! Return indices kt (theta) and jp (phi) of pixel with index k */
107void ThetaPhiIndex(int k,int& kt,int& jp);
108
109/*! achieve the splitting into pixels (m has the same signification
110 as for the constructor)
111
112 Each theta-slice of the north hemisphere will be spitted starting f
113 from phi=0 ...
114
115 South hemisphere is scanned in the same direction according to phi
116 and from equator to the pole (the pixel following the last one of
117 the slice closest to the equator with z>0, is the pixel with lowest
118 phi of the slice closest of the equator with z<0).
119*/
120void Pixelize(int);
121
122/*! For a theta-slice with index 'index', return :
123
124 the corresponding "theta"
125
126 a vector containing the phi's of the pixels of the slice
127
128 a vector containing the corresponding values of pixels
129*/
130void GetThetaSlice(int index,double& theta,TVector<double>& phi,TVector<T>& value) const;
131
132/*retourne le tableau contenant le nombre de pixels en phi de chacune des bandes en theta */
133inline const int* getmNPhi() const { return(NPhi_); }
134void setmNPhi(int* array, int m);
135
136/* retourne/remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */
137inline const int* getmTNphi() const { return(TNphi_); }
138void setmTNphi(int* array, int m);
139
140/* retourne/remplit le tableau contenant les valeurs limites de theta */
141inline const double* getmTheta() const { return(Theta_); }
142void setmTheta(double* array, int m);
143
144/* retourne le pointeur vers/remplit le vecteur des contenus des pixels */
145inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
146void setDataBlock(T* data, int m);
147
148/* impression */
149void print(ostream& os) const;
150
151private :
152
153// ------------- méthodes internes ----------------------
154void InitNul();
155void Clear();
156
157// ------------- variables internes ---------------------
158int NTheta_;
159int NPix_;
160double Omega_;
161int* NPhi_;
162int* TNphi_;
163double* Theta_;
164NDataBlock<T> pixels_;
165};
166
167// ------------- Classe pour la gestion de persistance --
168template <class T>
169class FIO_SphereThetaPhi : public PPersist
170{
171public:
172
173FIO_SphereThetaPhi();
174FIO_SphereThetaPhi(string const & filename);
175FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj);
176FIO_SphereThetaPhi(SphereThetaPhi<T>* obj);
177virtual ~FIO_SphereThetaPhi();
178virtual AnyDataObj* DataObj();
179inline operator SphereThetaPhi<T>() { return(*dobj); }
180//inline SphereThetaPhi<T> getObj() { return(*dobj); }
181
182protected :
183
184virtual void ReadSelf(PInPersist&);
185virtual void WriteSelf(POutPersist&) const;
186SphereThetaPhi<T>* dobj;
187bool ownobj;
188};
189
190#endif
Note: See TracBrowser for help on using the repository browser.