| 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 possibilite de couverture partielle, limitees en theta,phi
 | 
|---|
| 12 |   R. Ansari  - Septembre 2004 
 | 
|---|
| 13 |  */
 | 
|---|
| 14 | 
 | 
|---|
| 15 | namespace SOPHYA {
 | 
|---|
| 16 | template <class T>
 | 
|---|
| 17 | class FIO_SphereECP;  
 | 
|---|
| 18 | 
 | 
|---|
| 19 | template <class T> 
 | 
|---|
| 20 | class SphereECP : public SphericalMap<T>
 | 
|---|
| 21 | {
 | 
|---|
| 22 | public :
 | 
|---|
| 23 | 
 | 
|---|
| 24 | //! return the size index value corresponding to resolution res (in radian)
 | 
|---|
| 25 | static inline int_4 ResolToSizeIndex(double res)
 | 
|---|
| 26 |   { return (int_4)((M_PI/res)+0.5); }
 | 
|---|
| 27 | //! return the pixel resolution (in radian) for the size index \b m 
 | 
|---|
| 28 | static inline double  SizeIndexToResol(int_4 m) 
 | 
|---|
| 29 |   { return  (M_PI/(double)m); }
 | 
|---|
| 30 | 
 | 
|---|
| 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 | 
 | 
|---|
| 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 
 | 
|---|
| 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;
 | 
|---|
| 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 | 
 | 
|---|
| 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 | 
 | 
|---|
| 109 |   virtual r_8           ThetaOfSlice(int_4 index) const;
 | 
|---|
| 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 ;
 | 
|---|
| 114 |   virtual T*            GetThetaSliceDataPtr(int_4 index);
 | 
|---|
| 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 
 | 
|---|
| 121 |   virtual void          Show(ostream& os) const;
 | 
|---|
| 122 |   inline void           Show() const { Show(cout); }
 | 
|---|
| 123 |   virtual void          Print(ostream& os) const;
 | 
|---|
| 124 |   inline void           print(ostream& os) const { Print(os); }
 | 
|---|
| 125 |   inline void           Print() const { Print(cout); }
 | 
|---|
| 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 | 
 | 
|---|
| 145 |   //! assign a new object Id (or DataRef Id) - useful for PPF write operations
 | 
|---|
| 146 |   inline void RenewObjId() { _pixels.RenewObjId(); }
 | 
|---|
| 147 | 
 | 
|---|
| 148 |   friend class  FIO_SphereECP<T>;   // Gestion de persistance PPF
 | 
|---|
| 149 | 
 | 
|---|
| 150 | protected:
 | 
|---|
| 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;
 | 
|---|
| 157 |   int_4 _outofmapnphi;
 | 
|---|
| 158 |   int_4 _outofmapntet;
 | 
|---|
| 159 |   T _outofmappix;
 | 
|---|
| 160 |   T _outofmapval;
 | 
|---|
| 161 | };
 | 
|---|
| 162 | 
 | 
|---|
| 163 | 
 | 
|---|
| 164 | }// Fin du namespace
 | 
|---|
| 165 | 
 | 
|---|
| 166 | #endif
 | 
|---|