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

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

Compilation Mac pour CodeWarrior PRO 5

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
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>
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_4 m);
34SphereThetaPhi(const SphereThetaPhi<T>& s, bool share=false);
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_4 NbPixels() const;
42inline void setNbPixels(int_4 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_4 k);
47virtual T const& PixVal(int_4 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_4 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_4 k, double& theta, double& phi) const;
58
59/*! Setting pixel values to a constant */
60virtual T SetPixels(T v);
61
62/* retourne/fixe l'angle Solide de Pixel (steradians) */
63/*! Pixel Solid angle (steradians)
64
65 All the pixels have the same solid angle. The dummy argument is
66 for compatibility with eventual pixelizations which would not
67 fulfil this requirement.
68*/
69virtual double PixSolAngle(int_4 dummy) const;
70inline void setPixSolAngle(double omega) { Omega_= omega; }
71
72/* retourne/fixe la valeur du parametre de decoupage m */
73inline virtual int_4 SizeIndex() const { return( NTheta_); }
74inline void setSizeIndex(int_4 nbindex) { NTheta_= nbindex; }
75
76// ------------- Specific methods ----------------------
77
78/*! re-pixelize the sphere */
79virtual void Resize(int_4 m);
80
81inline virtual char* TypeOfMap() const {return "TETAFI";};
82
83/* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
84/* Return values of theta,phi which limit the pixel with index k */
85virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
86
87/* Nombre de tranches en theta */
88/*! Return number of theta-slices on the sphere */
89int_4 NbThetaSlices() const;
90
91/* Nombre de pixels en phi de la tranche d'indice kt */
92int_4 NPhi(int_4 kt) const;
93
94/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
95/* de la tranche d'indice kt */
96/*! Return theta values which limit the slice kt */
97void Theta(int_4 kt, double& t1, double& t2);
98
99/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
100/* dans la tranche d'indice kt */
101/*! Return values of phi which limit the jp-th pixel of the kt-th slice */
102void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
103
104/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
105/*! Return pixel index with sequence index jp in the slice kt */
106int_4 Index(int_4 kt, int_4 jp) const;
107
108/* Indice kt de la tranche et indice jp du pixel d'indice k */
109/*! Return indices kt (theta) and jp (phi) of pixel with index k */
110void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
111
112/*! achieve the splitting into pixels (m has the same signification
113 as for the constructor)
114
115 Each theta-slice of the north hemisphere will be spitted starting f
116 from phi=0 ...
117
118 South hemisphere is scanned in the same direction according to phi
119 and from equator to the pole (the pixel following the last one of
120 the slice closest to the equator with z>0, is the pixel with lowest
121 phi of the slice closest of the equator with z<0).
122*/
123void Pixelize(int_4);
124
125/*! For a theta-slice with index 'index', return :
126
127 the corresponding "theta"
128
129 a vector containing the phi's of the pixels of the slice
130
131 a vector containing the corresponding values of pixels
132*/
133void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
134
135/*retourne le tableau contenant le nombre de pixels en phi de chacune des bandes en theta */
136inline const int_4* getmNPhi() const { return(NPhi_); }
137void setmNPhi(int_4* array, int_4 m);
138
139/* retourne/remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */
140inline const int_4* getmTNphi() const { return(TNphi_); }
141void setmTNphi(int_4* array, int_4 m);
142
143/* retourne/remplit le tableau contenant les valeurs limites de theta */
144inline const double* getmTheta() const { return(Theta_); }
145void setmTheta(double* array, int_4 m);
146
147/* retourne le pointeur vers/remplit le vecteur des contenus des pixels */
148inline const NDataBlock<T>* getDataBlock() const { return (&pixels_); }
149void setDataBlock(T* data, int_4 m);
150
151/* Acces to the DataBlock */
152inline NDataBlock<T>& DataBlock() {return pixels_;}
153inline const NDataBlock<T>& DataBlock() const {return pixels_;}
154
155/* impression */
156void print(ostream& os) const;
157
158private :
159
160// ------------- méthodes internes ----------------------
161void InitNul();
162void Clear();
163
164// ------------- variables internes ---------------------
165int_4 NTheta_;
166int_4 NPix_;
167double Omega_;
168int_4* NPhi_;
169int_4* TNphi_;
170double* Theta_;
171NDataBlock<T> pixels_;
172};
173
174// ------------- Classe pour la gestion de persistance --
175template <class T>
176class FIO_SphereThetaPhi : public PPersist
177{
178public:
179
180FIO_SphereThetaPhi();
181FIO_SphereThetaPhi(string const & filename);
182FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj);
183FIO_SphereThetaPhi(SphereThetaPhi<T>* obj);
184virtual ~FIO_SphereThetaPhi();
185virtual AnyDataObj* DataObj();
186inline operator SphereThetaPhi<T>() { return(*dobj); }
187//inline SphereThetaPhi<T> getObj() { return(*dobj); }
188
189protected :
190
191virtual void ReadSelf(PInPersist&);
192virtual void WriteSelf(POutPersist&) const;
193SphereThetaPhi<T>* dobj;
194bool ownobj;
195};
196
197#endif
Note: See TracBrowser for help on using the repository browser.