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

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

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

File size: 3.2 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2#ifndef PIXELMAP_SEEN
3#define PIXELMAP_SEEN
4
5#include "ppersist.h"
6#include "dvlist.h"
7#include "spherepos.h"
8#include <iostream.h>
9
10// General map of pixels on part of sphere or whole sphere
11// Class hierarchy :
12// PixelMap
13// SphericalMap
14// SphereThetaPhi
15// SphereGorski
16// SphereIco
17// LocalMap
18
19template<class T>
20class PixelMap
21{
22
23public:
24
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
35// Number of pixels
36virtual int NbPixels() const=0;
37
38// Value of pixel number k
39virtual T& PixVal(int k)=0;
40virtual T const& PixVal(int k) const=0;
41
42// Map s coverage
43virtual bool ContainsSph(double theta, double phi) const=0;
44virtual bool Contains(const SpherePosition& spos) const;
45
46// Index of pixel at (theta,phi)
47virtual int PixIndexSph(double theta, double phi) const=0;
48// Index of pixel at a sky-position
49virtual int PixIndex(const SpherePosition& spos);
50
51
52// Value of pixel number at (theta,phi)
53virtual T& PixValSph(double theta, double phi)
54 {return PixVal(PixIndexSph(theta,phi));}
55virtual T const& PixValSph(double theta, double phi) const
56 {return PixVal(PixIndexSph(theta,phi));}
57
58// Spherical coordinates of center of pixel number k
59virtual void PixThetaPhi(int k, double& theta, double& phi) const=0;
60
61// provides a integer characterizing the pixelization refinement
62// (depending of the type of the map)
63virtual int SizeIndex() const=0;
64virtual char* TypeOfMap() const =0;
65
66// Pixel (steradians)
67virtual double PixSolAngle(int k) const =0;
68
69// Overloading of () to access pixel number k.
70inline T& operator()(int k) {return(PixVal(k));}
71inline T const& operator()(int k) const {return(PixVal(k));}
72
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
80// Note : no overloading of (double,double) to access pixel (theta,phi).
81// overloading of (double,double) in SphericalMap
82// overloading of (int,int) in CartesianMap
83
84//++
85DVList& Info()
86//
87// Renvoie une reference sur l''objet DVList Associe
88//--
89 {
90 if (mInfo_ == NULL) mInfo_ = new DVList;
91 return(*mInfo_);
92 }
93
94const DVList* ptrInfo() const
95 {
96 return mInfo_;
97 }
98
99protected :
100 SphereCoordSys *cs_; // Coordinate system used in the map
101 DVList* mInfo_; // Infos (variables) attachees
102};
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
119#endif
Note: See TracBrowser for help on using the repository browser.