Changeset 518 in Sophya for trunk/SophyaLib/Samba/pixelmap.h


Ignore:
Timestamp:
Oct 26, 1999, 4:31:44 PM (26 years ago)
Author:
ansari
Message:

Introduction de SpherePosition and SphereCoordSys, and Initiator for module Samba - Reza+I. Grivell 26/10/99

File:
1 edited

Legend:

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

    r473 r518  
     1// This may look like C code, but it is really -*- C++ -*-
    12#ifndef PIXELMAP_SEEN
    23#define PIXELMAP_SEEN
     
    45#include "ppersist.h"
    56#include "dvlist.h"
     7#include "spherepos.h"
    68#include <iostream.h>
    79
     
    2123public:
    2224 
    23 PixelMap():mInfo_(NULL) {};
    24 virtual ~PixelMap() {};
    25  
     25              PixelMap(SphereCoordSys* cs = NULL) : mInfo_(NULL)
     26                    { if (cs) cs_ = cs; else cs = new SphereCoordSys; }
     27virtual       ~PixelMap()
     28                    { if (mInfo_) delete mInfo_; if (cs_) delete cs_; }
     29
     30// Set/Change/Get the coordinate system
     31virtual void  SetCoordSys(SphereCoordSys* cs)
     32                    { if (cs) { delete cs_;  cs_ = cs; } }
     33inline SphereCoordSys* GetCoordSys() const { return(cs_); }
     34
    2635// Number of pixels
    2736virtual int NbPixels() const=0;
     
    3039virtual T& PixVal(int k)=0;
    3140virtual T const& PixVal(int k) const=0;
    32    
     41
     42// Map s coverage
     43virtual bool ContainsSph(double theta, double phi) const=0;
     44virtual bool Contains(const SpherePosition& spos) const;
     45
    3346// Index of pixel at (theta,phi)
    3447virtual int PixIndexSph(double theta, double phi) const=0;
     48// Index of pixel at a sky-position
     49virtual int PixIndex(const SpherePosition& spos);
     50
    3551
    3652// Value of pixel number at (theta,phi)
     
    5571inline T const& operator()(int k) const {return(PixVal(k));}
    5672
     73// Overloading of () to access pixel at a sky position .
     74inline T& operator()(const SpherePosition& spos)
     75                     { return(PixVal(PixIndex(spos))); }
     76inline T const& operator()(const SpherePosition& spos) const
     77                     { return(PixVal(PixIndex(spos))); }
     78
     79
    5780// Note : no overloading of (double,double) to access pixel (theta,phi).
    5881// overloading of (double,double) in SphericalMap
     
    7598
    7699protected :
    77 
     100    SphereCoordSys *cs_;   // Coordinate system used in the map
    78101    DVList* mInfo_;        // Infos (variables) attachees
    79102};
     103
     104
     105template <class T>
     106int PixelMap<T>::PixIndex(const SpherePosition& spos)
     107{
     108UnitVector v = spos.Transform(*cs_);
     109return(PixIndexSph(v.Theta(), v.Phi()));
     110}
     111
     112template <class T>
     113bool PixelMap<T>::Contains(const SpherePosition& spos) const
     114{
     115UnitVector v = spos.Transform(*cs_);
     116return(ContainsSph(v.Theta(), v.Phi()));
     117}
     118
    80119#endif
Note: See TracChangeset for help on using the changeset viewer.