source: Sophya/trunk/SophyaLib/SkyMap/sphereecp.h@ 3820

Last change on this file since 3820 was 3506, checked in by ansari, 17 years ago

Ajout SphereECP::ExtractPartial() et correction ds SphereECP::PixThetaPhi() - Reza 08/08/2008

File size: 5.9 KB
RevLine 
[2610]1#ifndef SPHEREECP_SEEN
2#define SPHEREECP_SEEN
3
4#include "sphericalmap.h"
5#include "ndatablock.h"
6#include "tvector.h"
7
8
9/* Classe de carte spherique avec decoupage theta-phi
10 (projection cylindique: Equatorial Cylindrical Projection)
[3506]11 avec possibilite de couverture partielle, limitees en theta,phi
[2610]12 R. Ansari - Septembre 2004
13 */
14
15namespace SOPHYA {
16template <class T>
17class FIO_SphereECP;
18
19template <class T>
20class SphereECP : public SphericalMap<T>
21{
22public :
[2973]23
24//! return the size index value corresponding to resolution res (in radian)
25static inline int_4 ResolToSizeIndex(double res)
[2978]26 { return (int_4)((M_PI/res)+0.5); }
[2985]27//! return the pixel resolution (in radian) for the size index \b m
28static inline double SizeIndexToResol(int_4 m)
29 { return (M_PI/(double)m); }
[2973]30
[2610]31 // Constructeur par defaut
32 SphereECP();
33 // Constructeur , couverture complete, m tranches en theta (delta theta = M_PI), 2m en phi (delta phi = 2Pi)
34 SphereECP(int m);
35 // Constructeur , couverture complete, ntet tranches en theta (delta theta = M_PI), nphi en phi (delta phi = 2Pi)
36 SphereECP(int ntet, int nphi);
37 // Constructeur , couverture partielle, ntet tranches en theta , nphi en phi
38 SphereECP(r_8 tet1, r_8 tet2, int ntet, r_8 phi1, r_8 phi2, int nphi);
39 // Constructeur de copie, share=true -> partage des pixels
40 SphereECP(const SphereECP<T>& a, bool share);
41 // Constructeur de copie, partage des pixels
42 SphereECP(const SphereECP<T>& a);
43 virtual ~SphereECP();
44
[3506]45 // Extraction de carte partielle d'une carte ECP complete
46 virtual SphereECP<T> ExtractPartial(r_8 tet1, r_8 tet2, r_8 phi1, r_8 phi2);
47
48
49// Renvoie Type ECP
[2610]50 virtual string TypeOfMap() const;
51 virtual void SetTemp(bool temp=false) const; // A supprimer
52
53// Informations sur carte partielle/complete + zone de couverture
54 inline bool IsPartial() const { return _partial; }
55 inline double MinTheta() const { return _theta1; }
56 inline double MaxTheta() const { return _theta2; }
57 inline double DeltaTheta() const { return _dtheta; }
58 inline double MinPhi() const { return _phi1; }
59 inline double MaxPhi() const { return _phi2; }
60 inline double DeltaPhi() const { return _dphi; }
61
62// Interface de Pixelmap
63/*! Return total number of pixels */
64 virtual int_4 NbPixels() const;
65
66/* retourne la valeur du pixel d'indice k */
67/*! Return value of pixel with index k */
68 virtual T& PixVal(int_4 k);
69 virtual T const& PixVal(int_4 k) const;
70
71/* Return true if teta,phi in map */
72 virtual bool ContainsSph(double theta, double phi) const;
73/* retourne l'indice du pixel a (theta,phi) */
74/* Return index of the pixel corresponding to direction (theta, phi). */
75 virtual int_4 PixIndexSph(double theta, double phi) const;
76
77/* retourne les coordonnees Spheriques du centre du pixel d'indice k */
78/*! Return (theta,phi) coordinates of middle of pixel with index k */
79 virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const;
80
81/*! Setting pixel values to a constant */
82 virtual T SetPixels(T v);
83
84/* retourne/fixe l'angle Solide de Pixel (steradians) */
85/*! Pixel Solid angle (steradians)
86
87 All the pixels have the same solid angle. The dummy argument is
88 for compatibility with eventual pixelizations which would not
89 fulfil this requirement.
90*/
91 virtual double PixSolAngle(int_4 dummy=0) const;
[2623]92
93/* retourne/fixe l'angle Solide couvert par la carte (steradians) */
94 virtual double TotSolAngle(void) const
95 {return fabs((_phi2-_phi1)*(cos(_theta2)-cos(_theta1)));}
96
[2610]97/* retourne/fixe la valeur du parametre de decoupage m */
98 virtual int_4 SizeIndex() const ;
99
100// Interface de SphericalMap
101// index characterizing the size pixelization : m for SphereThetaPhi
102// nside for Gorski sphere...
103 virtual void Resize(int_4 m);
104 virtual uint_4 NbThetaSlices() const;
105
106 // Nb de tranches en Phi
107 inline uint_4 NbPhiSlices() const { return _pixels.SizeX(); }
108
[2968]109 virtual r_8 ThetaOfSlice(int_4 index) const;
[2610]110 virtual void GetThetaSlice(int_4 index,r_8& theta,
111 TVector<r_8>& phi, TVector<T>& value) const ;
112 virtual void GetThetaSlice(int_4 sliceIndex, r_8& theta, r_8& phi0,
113 TVector<int_4>& pixelIndices,TVector<T>& value) const ;
[2990]114 virtual T* GetThetaSliceDataPtr(int_4 index);
[2610]115
116 // Valeur de pixel hors carte
117 inline void SetOutOfMapValue(T v) { _outofmappix = _outofmapval = v; }
118 inline T GetOutOfMapValue(T v) { return _outofmapval; }
119
120 // Impression
[2973]121 virtual void Show(ostream& os) const;
[2995]122 inline void Show() const { Show(cout); }
[2610]123 virtual void Print(ostream& os) const;
124 inline void print(ostream& os) const { Print(os); }
[2973]125 inline void Print() const { Print(cout); }
[2610]126
127 // ---- les operations =, +, - , *
128 // operation = (remplissage avec une valeur ou carte)
129 virtual SphereECP<T>& Set(const SphereECP<T>& a);
130 inline SphereECP<T>& operator = (const SphereECP<T>& a) { return Set(a); }
131 virtual SphereECP<T>& SetCst(T x);
132 inline SphereECP<T>& operator = (T x) { return SetCst(x); }
133 // Operation + , * avec des Constantes
134 virtual SphereECP<T>& AddCst(T x) ;
135 virtual SphereECP<T>& MulCst(T x) ;
136
137 inline SphereECP<T>& operator += (T x) { return AddCst(x); }
138 inline SphereECP<T>& operator -= (T x) { return AddCst(-x); }
139 inline SphereECP<T>& operator *= (T x) { return MulCst(x); }
140
141 // Acces au tableau des pixels
142 inline TArray<T>& GetPixelArray() { return _pixels; }
143 inline TArray<T> GetPixelArray() const { return _pixels; }
144
[3174]145 //! assign a new object Id (or DataRef Id) - useful for PPF write operations
146 inline void RenewObjId() { _pixels.RenewObjId(); }
147
[2610]148 friend class FIO_SphereECP<T>; // Gestion de persistance PPF
149
150protected:
151 bool _partial;
152 r_8 _theta1,_theta2;
153 r_8 _phi1, _phi2;
154 r_8 _dtheta, _dphi;
155 TArray<T> _pixels;
156 int_4 _outofmapidx;
[2621]157 int_4 _outofmapnphi;
158 int_4 _outofmapntet;
[2610]159 T _outofmappix;
160 T _outofmapval;
161};
162
163
164}// Fin du namespace
165
166#endif
Note: See TracBrowser for help on using the repository browser.