Changeset 470 in Sophya for trunk/SophyaLib/Samba/localmap.h


Ignore:
Timestamp:
Oct 15, 1999, 5:43:30 PM (26 years ago)
Author:
ansari
Message:

versions templatees, NdataBlocks etc. 15-OCT-99-GLM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Samba/localmap.h

    r228 r470  
    44#include "pixelmap.h"
    55#include "sphericalmap.h"
     6#include "ndatablock.h"
     7
     8#include "anydataobj.h"
     9#include "ppersist.h"
    610
    711// A local map of a region of the sky, in cartesian coordinates.
     
    1317//    indice de colonne et j indice de ligne. La carte est supposee resider
    1418//    dans un plan tangent, dont le point de tangence est repere (x0,y0) dans
    15 //    la carte et (theta0, phi0) sur la sphere celeste. L'extension de la
     19//    la carte et (theta0, phi0) sur la sphere celeste. L extension de la
    1620//    carte est definie par les valeurs de deux angles couverts respectivement
    1721//    par la totalite des pixels en x de la carte et la totalite des pixels
    1822//    en y. (SetSize()).
    1923//    On considere un "plan de reference" : plan tangent a la sphere celeste
    20 //    aux angles theta=Pi/2 et phi=0. Dans ce plan L'origine des coordonnees
    21 //    est le point de tangence. L'axe Ox est la tangente parallele a
    22 //    l'equateur, dirige vers les phi croissants, l'axe Oy est parallele
     24//    aux angles theta=Pi/2 et phi=0. Dans ce plan L origine des coordonnees
     25//    est le point de tangence. L axe Ox est la tangente parallele a
     26//    lequateur, dirige vers les phi croissants, l axe Oy est parallele
    2327//    au meridien, dirige vers le pole nord.
    2428//    De maniere interne a la classe une carte est definie dans ce plan de
    25 //    reference et transportee  jusqu'au point (theta0, phi0) de sorte que les //    axes restent paralleles aux meridiens et paralleles. L'utilisateur peut
     29//    reference et transportee  jusqu au point (theta0, phi0) de sorte que les //    axes restent paralleles aux meridiens et paralleles. L utilisateur peut
    2630//    definir sa carte selon un repere en rotation par rapport au repere de
    27 //    reference (par l'angle entre le parallele et l'axe Ox souhaite --
     31//    reference (par l angle entre le parallele et l axe Ox souhaite --
    2832//    methode SetOrigin(...))
    2933
    3034
     35// ***************** Class LocalMap *****************************
    3136
     37template<class T>
     38class LocalMap : public PixelMap<T>, public AnyDataObj
     39{
    3240
     41public:
    3342
     43LocalMap();
     44LocalMap(int_4 nx, int_4 ny);
     45LocalMap(const LocalMap<T>& lm);
     46virtual ~LocalMap();
    3447
     48// ---------- Overloading of () to access pixel number k ----
    3549
    36 class LocalMap : public PixelMap {
    37 public:
    38    LocalMap();
    39    LocalMap(int_4 nx, int_4 ny);
    40    virtual ~LocalMap();
    41    // Overloading of () to access pixel number k.
    42 inline  r_8&        operator()(int_4 k)
    43                           {return(PixVal(k));}
    44 inline  r_8 const&  operator()(int_4 k) const
    45                           {return(PixVal(k));}
    46 inline  r_8&        operator()(int ix, int iy)
    47                 { return PixVal(iy*mSzX_+ix) ; };
    48 inline  r_8 const&        operator()(int ix, int iy) const
    49                 { return PixVal(iy*mSzX_+ix) ; };
     50inline T& operator()(int_4 k) {return(PixVal(k));}
     51inline T const& operator()(int_4 k) const {return(PixVal(k));}
     52inline T& operator()(int ix, int iy) {return PixVal(iy*nSzX_+ix);};
     53inline T const& operator()(int ix, int iy) const {return PixVal(iy*nSzX_+ix);};
    5054   
    51 // ---------- Persistence handling
     55// ---------- Definition of PixelMap abstract methods -------
     56
     57/* return/set the number of pixels */
     58virtual int_4 NbPixels() const;
     59inline void setNbPixels(int_4 n) {nPix_= n;}
     60 
     61/* return the value of pixel number k */
     62virtual T& PixVal(int_4 k);
     63virtual T const& PixVal(int_4 k) const;
     64
     65/* return the index of pixel at (theta,phi) */
     66virtual int_4 PixIndexSph(float theta, float phi) const;
    5267   
    53    enum {classId = 0xF003 };
    54 int_4               ClassId() const        { return classId; }
     68/* return the spherical coordinates of center of pixel number k */
     69virtual void PixThetaPhi(int_4 k, float& theta, float& phi) const;
    5570
    56 virtual void        WriteSelf(POutPersist&) const;
    57 virtual void        ReadSelf(PInPersist&);
     71/* return the Pixel Solid angle  (steradians) */
     72virtual r_8 PixSolAngle(int_4 k) const;
    5873
    59 // ---------- Definition of PixelMap abstract methods
     74// ---------- Specific methods ------------------------------
    6075
    61    // Number of pixels
    62    virtual int_4       NbPixels() const;
    63    
    64    // Value of pixel number k
    65    virtual r_8&        PixVal(int_4 k);
    66    virtual r_8 const&  PixVal(int_4 k) const;
     76void ReSize(int_4 nx, int_4 ny);
    6777
    68    // Index of pixel at (theta,phi)
    69    virtual int_4       PixIndexSph(float theta, float phi) const;
    70    
    71    // Spherical coordinates of center of pixel number k
    72    virtual void        PixThetaPhi(int_4 k, float& theta, float& phi) const;
    73    // Pixel Solid angle  (steradians)
    74    virtual r_8         PixSolAngle(int_4 k) const;
     78inline virtual char* TypeOfMap() const {return "LOCAL";};
     79 
     80/* Origin (with angle between x axis and phi axis, in degrees)  x0,y0  the default: middle of map*/
     81virtual void SetOrigin(float theta=90., float phi=0., float angle=0.);
     82virtual void SetOrigin(float theta,float phi,int_4 x0,int_4 y0,float angle=0.);
    7583
    76 // ---------- Specific methods
     84/* Pixel size (degres) */
     85virtual void SetSize(float angleX, float angleY);
    7786
    78    // Origin (with angle between x axis and phi axis, in degrees)
    79     virtual void  SetOrigin(float theta0, float phi0, float angle=0.); // x0,y0 default: middle of map
    80   virtual void        SetOrigin(float theta0, float phi0, int_4 x0, int_4 y0, float angle=0.);
    81    // Pixel size (degres)
    82    virtual void        SetSize(float angleX, float angleY);
     87/* Check to see if the local mapping is done */
     88inline bool LocalMap_isDone() const {return(originFlag_ && extensFlag_);};
    8389
    84    // Projection to/from spherical map
    85    //virtual void        Extract(SphericalMap const& sphere);
    86    virtual void        Project(SphericalMap& sphere) const;
     90/* Projection to/from spherical map */
     91virtual void Project(SphericalMap<T>& sphere) const;
    8792 
    88    // There should be a more complex algorithm somewhere to combine *several*
    89    // local maps to a full sphere.
    90    //   -> static method, or separate class
     93/* There should be a more complex algorithm somewhere to combine *several* local maps to a full sphere.
     94      -> static method, or separate class */
     95 
     96/* provides a integer characterizing the pixelization refinement  (here : number of pixels) */
     97inline virtual int_4 SizeIndex() const {return(nPix_);}
     98inline int_4 Size_x() const {return nSzX_;}
     99inline void setSize_x(int_4 n) {nSzX_= n;}
     100inline int_4 Size_y() const {return nSzY_;}
     101inline void setSize_y(int_4 n) {nSzY_= n;}
    91102
    92    void Pixelize(int_4,int_4); // Allocate pixel array
     103inline void Origin(float& theta, float& phi,int& x0, int& y0, float& angle) const {theta= (float)theta0_; phi= (float)phi0_; x0= x0_; y0= y0_;angle= (float)angle_;}
    93104
    94 // ------------- méthodes internes ----------------------
     105inline void Aperture(float& anglex, float& angley) const {anglex= (float)angleX_; angley= (float)angleY_;}
     106
     107/* retourne le pointeur vers/remplit  le vecteur des contenus des pixels */
     108inline const NDataBlock<T>* getDataBlock() const {return (&pixels_);}
     109inline void setDataBlock(T* data, int_4 n) {pixels_.FillFrom(n,data);}
     110
     111/* impression */
     112void print(ostream& os) const;
     113
     114// ---------- Méthodes internes -----------------------------
    95115         
    96116private :
    97117
    98    void      InitNul();
    99    void      Clear();
    100    void      Getij(int k, int& i, int& j) const;
    101    void      ReferenceToUser(float &theta, float &phi) const;
    102    void      UserToReference(float &theta, float &phi) const;
    103    void      PixProjToAngle(float x, float y,float &theta, float &phi) const;
    104    void      AngleProjToPix(float theta, float phi, float& x, float& y) const;
    105 // ------------- variables internes -----------------------
     118void InitNul();
     119void Getij(int k, int& i, int& j) const;
     120void ReferenceToUser(float &theta, float &phi) const;
     121void UserToReference(float &theta, float &phi) const;
     122void PixProjToAngle(float x, float y,float &theta, float &phi) const;
     123void AngleProjToPix(float theta, float phi, float& x, float& y) const;
    106124
    107    int_4   mSzX_, mSzY_;
    108    int_4   mNPix_;
    109    int_4   x0_;
    110    int_4   y0_;
    111    int_4    originFlag_;
    112    int_4    SzFlag_;
    113    r_4   cos_angle_;
    114    r_4   sin_angle_;
    115    r_8     theta0_;
    116    r_8     phi0_;
    117    r_8     omeg_;
    118    r_8     tgAngleX_;
    119    r_8     tgAngleY_;
    120    r_8*    mPix_;
     125// ---------- Variables internes ----------------------------
     126
     127int_4 nSzX_;
     128int_4 nSzY_;
     129int_4 nPix_;
     130bool originFlag_;
     131bool extensFlag_;
     132int_4 x0_;
     133int_4 y0_;
     134r_8 theta0_;
     135r_8 phi0_;
     136r_8 angle_;
     137r_4 cos_angle_;
     138r_4 sin_angle_;
     139r_8 angleX_;
     140r_8 angleY_;
     141r_8 tgAngleX_;
     142r_8 tgAngleY_;
     143NDataBlock<T> pixels_;
     144};
     145
     146// ------------- Classe pour la gestion de persistance --
     147template <class T>
     148class FIO_LocalMap : public PPersist 
     149{
     150
     151public:
     152
     153FIO_LocalMap();
     154FIO_LocalMap(string const & filename);
     155FIO_LocalMap(const LocalMap<T>& obj);
     156FIO_LocalMap(LocalMap<T>* obj);
     157virtual ~FIO_LocalMap();
     158virtual AnyDataObj* DataObj();
     159inline operator LocalMap<T>() { return(*dobj); }
     160inline LocalMap<T> getObj() { return(*dobj); }
     161
     162protected :
     163
     164virtual void ReadSelf(PInPersist&);           
     165virtual void WriteSelf(POutPersist&) const; 
     166LocalMap<T>* dobj;
     167bool ownobj;
    121168};
    122169
Note: See TracChangeset for help on using the changeset viewer.