#ifndef SPHERETHETAPHI_SEEN #define SPHERETHETAPHI_SEEN #include "sphericalmap.h" #include "ndatablock.h" #include "tvector.h" #include "anydataobj.h" #include "ppersist.h" // ***************** Class SphereThetaPhi ***************************** /*! sphere splitted with respect to theta, phi : each hemisphere is splitted into (m-1) parallels (equator does not enter into account). This operation defines m slices, each of which is splitted into equidistant meridians. This splitting is realized in such a way that all pixels have the same area and are as square as possible. One begins with the hemisphere with positive z, starting from the pole toward the equator. The first pixel is the polar cap ; it is circular and centered on theta=0. */ template class SphereThetaPhi : public SphericalMap { public : SphereThetaPhi(); /*! m is the number of slices in theta on an hemisphere (the polar cap forms the first slice). pet is a dummy parameter at the moment. */ SphereThetaPhi(int_4 m); SphereThetaPhi(const SphereThetaPhi& s, bool share=false); virtual ~SphereThetaPhi(); // ------------ Definition of PixelMap abstract methods - /* retourne/fixe le nombre de pixels */ /*! Return total number of pixels */ virtual int_4 NbPixels() const; inline void setNbPixels(int_4 nbpix) { NPix_= nbpix; } /* retourne la valeur du pixel d'indice k */ /*! Return value of pixel with index k */ virtual T& PixVal(int_4 k); virtual T const& PixVal(int_4 k) const; /* Return true if teta,phi in map */ virtual bool ContainsSph(double theta, double phi) const; /* retourne l'indice du pixel a (theta,phi) */ /* Return index of the pixel corresponding to direction (theta, phi). */ virtual int_4 PixIndexSph(double theta, double phi) const; /* retourne les coordonnees Spheriques du centre du pixel d'indice k */ /*! Return (theta,phi) coordinates of middle of pixel with index k */ virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const; /*! Setting pixel values to a constant */ virtual T SetPixels(T v); /* retourne/fixe l'angle Solide de Pixel (steradians) */ /*! Pixel Solid angle (steradians) All the pixels have the same solid angle. The dummy argument is for compatibility with eventual pixelizations which would not fulfil this requirement. */ virtual double PixSolAngle(int_4 dummy) const; inline void setPixSolAngle(double omega) { Omega_= omega; } /* retourne/fixe la valeur du parametre de decoupage m */ inline virtual int_4 SizeIndex() const { return( NTheta_); } inline void setSizeIndex(int_4 nbindex) { NTheta_= nbindex; } // ------------- Specific methods ---------------------- /*! re-pixelize the sphere */ virtual void Resize(int_4 m); inline virtual char* TypeOfMap() const {return "TETAFI";}; /* Valeurs de theta des paralleles et phi des meridiens limitant le pixel d'indice k */ /* Return values of theta,phi which limit the pixel with index k */ virtual void Limits(int_4 k,double& th1,double& th2,double& phi1,double& phi2); /* Nombre de tranches en theta */ /*! Return number of theta-slices on the sphere */ int_4 NbThetaSlices() const; /* Nombre de pixels en phi de la tranche d'indice kt */ int_4 NPhi(int_4 kt) const; /* Renvoie dans t1,t2 les valeurs respectives de theta min et theta max */ /* de la tranche d'indice kt */ /*! Return theta values which limit the slice kt */ void Theta(int_4 kt, double& t1, double& t2); /* Renvoie dans p1,p2 les valeurs phimin et phimax du pixel d'indice jp */ /* dans la tranche d'indice kt */ /*! Return values of phi which limit the jp-th pixel of the kt-th slice */ void Phi(int_4 kt, int_4 jp, double& p1, double& p2); /* Renvoie l'indice k du pixel d'indice jp dans la tranche d'indice kt */ /*! Return pixel index with sequence index jp in the slice kt */ int_4 Index(int_4 kt, int_4 jp) const; /* Indice kt de la tranche et indice jp du pixel d'indice k */ /*! Return indices kt (theta) and jp (phi) of pixel with index k */ void ThetaPhiIndex(int_4 k,int_4& kt,int_4& jp); /*! achieve the splitting into pixels (m has the same signification as for the constructor) Each theta-slice of the north hemisphere will be spitted starting f from phi=0 ... South hemisphere is scanned in the same direction according to phi and from equator to the pole (the pixel following the last one of the slice closest to the equator with z>0, is the pixel with lowest phi of the slice closest of the equator with z<0). */ void Pixelize(int_4); /*! For a theta-slice with index 'index', return : the corresponding "theta" a vector containing the phi's of the pixels of the slice a vector containing the corresponding values of pixels */ void GetThetaSlice(int_4 index,double& theta,TVector& phi,TVector& value) const; /*retourne le tableau contenant le nombre de pixels en phi de chacune des bandes en theta */ inline const int_4* getmNPhi() const { return(NPhi_); } void setmNPhi(int_4* array, int_4 m); /* retourne/remplit le tableau contenant le nombre/Deuxpi total des pixels contenus dans les bandes */ inline const int_4* getmTNphi() const { return(TNphi_); } void setmTNphi(int_4* array, int_4 m); /* retourne/remplit le tableau contenant les valeurs limites de theta */ inline const double* getmTheta() const { return(Theta_); } void setmTheta(double* array, int_4 m); /* retourne le pointeur vers/remplit le vecteur des contenus des pixels */ inline const NDataBlock* getDataBlock() const { return (&pixels_); } void setDataBlock(T* data, int_4 m); /* Acces to the DataBlock */ inline NDataBlock& DataBlock() {return pixels_;} inline const NDataBlock& DataBlock() const {return pixels_;} /* impression */ void print(ostream& os) const; private : // ------------- méthodes internes ---------------------- void InitNul(); void Clear(); // ------------- variables internes --------------------- int_4 NTheta_; int_4 NPix_; double Omega_; int_4* NPhi_; int_4* TNphi_; double* Theta_; NDataBlock pixels_; }; // ------------- Classe pour la gestion de persistance -- template class FIO_SphereThetaPhi : public PPersist { public: FIO_SphereThetaPhi(); FIO_SphereThetaPhi(string const & filename); FIO_SphereThetaPhi(const SphereThetaPhi& obj); FIO_SphereThetaPhi(SphereThetaPhi* obj); virtual ~FIO_SphereThetaPhi(); virtual AnyDataObj* DataObj(); inline operator SphereThetaPhi() { return(*dobj); } //inline SphereThetaPhi getObj() { return(*dobj); } protected : virtual void ReadSelf(PInPersist&); virtual void WriteSelf(POutPersist&) const; SphereThetaPhi* dobj; bool ownobj; }; #endif