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

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

mise a jour de persistances par objets delegues

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// ------------- Specific methods ----------------------
80
81/*! re-pixelize the sphere */
82virtual void Resize(int_4 m);
83
84inline virtual char* TypeOfMap() const {return "TETAFI";};
85
86/* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */
87/* Return values of theta,phi which limit the pixel with index k */
88virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2);
89
90/* Nombre de tranches en theta */
91/*! Return number of theta-slices on the sphere */
92int_4 NbThetaSlices() const;
93
94/* Nombre de pixels en phi de la tranche d'indice kt */
95int_4 NPhi(int_4 kt) const;
96
97/* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */
98/* de la tranche d'indice kt */
99/*! Return theta values which limit the slice kt */
100void Theta(int_4 kt, double& t1, double& t2);
101
102/* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */
103/* dans la tranche d'indice kt */
104/*! Return values of phi which limit the jp-th pixel of the kt-th slice */
105void Phi(int_4 kt, int_4 jp, double& p1, double& p2);
106
107/* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */
108/*! Return pixel index with sequence index jp in the slice kt */
109int_4 Index(int_4 kt, int_4 jp) const;
110
111/* Indice kt de la tranche et indice jp du pixel d'indice k */
112/*! Return indices kt (theta) and jp (phi) of pixel with index k */
113void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp);
114
115/*! achieve the splitting into pixels (m has the same signification
116 as for the constructor)
117
118 Each theta-slice of the north hemisphere will be spitted starting f
119 from phi=0 ...
120
121 South hemisphere is scanned in the same direction according to phi
122 and from equator to the pole (the pixel following the last one of
123 the slice closest to the equator with z>0, is the pixel with lowest
124 phi of the slice closest of the equator with z<0).
125*/
126void Pixelize(int_4);
127
128/*! For a theta-slice with index 'index', return :
129
130 the corresponding "theta"
131
132 a vector containing the phi's of the pixels of the slice
133
134 a vector containing the corresponding values of pixels
135*/
136void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
137
138
139
140
141/* impression */
142void print(ostream& os) const;
143
144private :
145
146// ------------- méthodes internes ----------------------
147void InitNul();
148void Clear();
149inline void setParameters(int nbpix, double omega, int nbThetaIndex)
150 {
151 NPix_= nbpix;
152 Omega_= omega;
153 NTheta_= nbThetaIndex;
154 }
155void setmNPhi(int* array, int m);
156void setmTNphi(int* array, int m);
157void setmTheta(double* array, int m);
158 /*retourne l'adresse du tableau contenant le nombre de pixels en phi de chacune des bandes en theta */
159inline const int* getmNPhi() const { return(NPhi_); }
160
161/* retourne le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */
162inline const int* getmTNphi() const { return(TNphi_); }
163
164/* retourne le tableau contenant les valeurs limites de theta */
165inline const double* getmTheta() const { return(Theta_); }
166
167/* Acces to the DataBlock */
168//inline NDataBlock<T>& DataBlock() {return pixels_;}
169//inline const NDataBlock<T>& DataBlock() const {return pixels_;}
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.