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