source: Sophya/trunk/SophyaLib/Samba/pixelmap.h@ 738

Last change on this file since 738 was 727, checked in by ansari, 26 years ago

nouvelle gestion thetaslices

File size: 3.7 KB
RevLine 
[518]1// This may look like C code, but it is really -*- C++ -*-
[228]2#ifndef PIXELMAP_SEEN
3#define PIXELMAP_SEEN
4
5#include "ppersist.h"
6#include "dvlist.h"
[518]7#include "spherepos.h"
[228]8#include <iostream.h>
9
[568]10//! General map of pixels on part of sphere or whole sphere
11/*! Class hierarchy :
12\verbatim
13 PixelMap
14 SphericalMap
15 SphereThetaPhi
16 SphereGorski
17 SphereIco
18 LocalMap
19\endverbatim
20*/
[470]21template<class T>
[592]22class PixelMap : public AnyDataObj
[470]23{
[228]24
25public:
[470]26
[518]27 PixelMap(SphereCoordSys* cs = NULL) : mInfo_(NULL)
[525]28 { if (cs) cs_ = cs; else cs_ = new SphereCoordSys; }
[518]29virtual ~PixelMap()
30 { if (mInfo_) delete mInfo_; if (cs_) delete cs_; }
31
32// Set/Change/Get the coordinate system
33virtual void SetCoordSys(SphereCoordSys* cs)
34 { if (cs) { delete cs_; cs_ = cs; } }
35inline SphereCoordSys* GetCoordSys() const { return(cs_); }
36
[568]37/*! Number of pixels */
[682]38virtual int_4 NbPixels() const=0;
[228]39
[568]40/*! Value of pixel number k */
[682]41virtual T& PixVal(int_4 k)=0;
42virtual T const& PixVal(int_4 k) const=0;
[518]43
44// Map s coverage
45virtual bool ContainsSph(double theta, double phi) const=0;
46virtual bool Contains(const SpherePosition& spos) const;
47
[568]48/*! Index of pixel at (theta,phi) */
[682]49virtual int_4 PixIndexSph(double theta, double phi) const=0;
[518]50// Index of pixel at a sky-position
[682]51virtual int_4 PixIndex(const SpherePosition& spos);
[228]52
[568]53/*! Value of pixel number at (theta,phi) */
[473]54virtual T& PixValSph(double theta, double phi)
[228]55 {return PixVal(PixIndexSph(theta,phi));}
[473]56virtual T const& PixValSph(double theta, double phi) const
[470]57 {return PixVal(PixIndexSph(theta,phi));}
[228]58
[568]59/*! Spherical coordinates of center of pixel number k */
[682]60virtual void PixThetaPhi(int_4 k, double& theta, double& phi) const=0;
[228]61
[568]62/*! provides a integer characterizing the pixelization refinement
63 (depending of the type of the map)
64*/
[682]65virtual int_4 SizeIndex() const=0;
[470]66virtual char* TypeOfMap() const =0;
[228]67
[568]68/*! Pixel (steradians) */
[682]69virtual double PixSolAngle(int_4 k) const =0;
[228]70
[727]71/*! Setting blockdata to temporary (see ndatablock documentation) */
72virtual void SetTemp(bool temp=false) const =0;
73
74
[568]75/*! Overloading of () to access pixel number k. */
[682]76inline T& operator()(int_4 k) {return(PixVal(k));}
77inline T const& operator()(int_4 k) const {return(PixVal(k));}
[470]78
[518]79// Overloading of () to access pixel at a sky position .
80inline T& operator()(const SpherePosition& spos)
81 { return(PixVal(PixIndex(spos))); }
82inline T const& operator()(const SpherePosition& spos) const
83 { return(PixVal(PixIndex(spos))); }
84
85
[473]86// Note : no overloading of (double,double) to access pixel (theta,phi).
87// overloading of (double,double) in SphericalMap
[470]88// overloading of (int,int) in CartesianMap
89
[574]90/*! Setting pixel values to a constant */
91virtual T SetPixels(T v);
92inline T operator = (T v) { return(SetPixels(v)); }
[727]93
94
[574]95
[228]96//++
[470]97DVList& Info()
[228]98//
[470]99// Renvoie une reference sur l''objet DVList Associe
[228]100//--
[470]101 {
102 if (mInfo_ == NULL) mInfo_ = new DVList;
103 return(*mInfo_);
104 }
[228]105
[470]106const DVList* ptrInfo() const
107 {
108 return mInfo_;
109 }
[228]110
[470]111protected :
[518]112 SphereCoordSys *cs_; // Coordinate system used in the map
[470]113 DVList* mInfo_; // Infos (variables) attachees
[228]114};
[518]115
116
117template <class T>
[682]118int_4 PixelMap<T>::PixIndex(const SpherePosition& spos)
[518]119{
120UnitVector v = spos.Transform(*cs_);
121return(PixIndexSph(v.Theta(), v.Phi()));
122}
123
124template <class T>
125bool PixelMap<T>::Contains(const SpherePosition& spos) const
126{
127UnitVector v = spos.Transform(*cs_);
128return(ContainsSph(v.Theta(), v.Phi()));
129}
[574]130template <class T>
131T PixelMap<T>::SetPixels(T v)
132{
133int k;
134for(k=0; k<NbPixels(); k++) PixVal(k) = v;
135return(v);
136}
[518]137
[228]138#endif
Note: See TracBrowser for help on using the repository browser.