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

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

Remis methode acces aux pixels - Reza 21/01/2000

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