source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Samba/pixelmap.h@ 658

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

no message

File size: 3.6 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\verbatim
13 PixelMap
14 SphericalMap
15 SphereThetaPhi
16 SphereGorski
17 SphereIco
18 LocalMap
19\endverbatim
20*/
21template<class T>
22class PixelMap : public AnyDataObj
23{
24
25public:
26
27 PixelMap(SphereCoordSys* cs = NULL) : mInfo_(NULL)
28 { if (cs) cs_ = cs; else cs_ = new SphereCoordSys; }
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
37/*! Number of pixels */
38virtual int NbPixels() const=0;
39
40/*! Value of pixel number k */
41virtual T& PixVal(int k)=0;
42virtual T const& PixVal(int k) const=0;
43
44// Map s coverage
45virtual bool ContainsSph(double theta, double phi) const=0;
46virtual bool Contains(const SpherePosition& spos) const;
47
48/*! Index of pixel at (theta,phi) */
49virtual int PixIndexSph(double theta, double phi) const=0;
50// Index of pixel at a sky-position
51virtual int PixIndex(const SpherePosition& spos);
52
53/*! Value of pixel number at (theta,phi) */
54virtual T& PixValSph(double theta, double phi)
55 {return PixVal(PixIndexSph(theta,phi));}
56virtual T const& PixValSph(double theta, double phi) const
57 {return PixVal(PixIndexSph(theta,phi));}
58
59/*! Spherical coordinates of center of pixel number k */
60virtual void PixThetaPhi(int k, double& theta, double& phi) const=0;
61
62/*! provides a integer characterizing the pixelization refinement
63 (depending of the type of the map)
64*/
65virtual int SizeIndex() const=0;
66virtual char* TypeOfMap() const =0;
67
68/*! Pixel (steradians) */
69virtual double PixSolAngle(int k) const =0;
70
71/*! Overloading of () to access pixel number k. */
72inline T& operator()(int k) {return(PixVal(k));}
73inline T const& operator()(int k) const {return(PixVal(k));}
74
75// Overloading of () to access pixel at a sky position .
76inline T& operator()(const SpherePosition& spos)
77 { return(PixVal(PixIndex(spos))); }
78inline T const& operator()(const SpherePosition& spos) const
79 { return(PixVal(PixIndex(spos))); }
80
81
82// Note : no overloading of (double,double) to access pixel (theta,phi).
83// overloading of (double,double) in SphericalMap
84// overloading of (int,int) in CartesianMap
85
86/*! Setting pixel values to a constant */
87virtual T SetPixels(T v);
88inline T operator = (T v) { return(SetPixels(v)); }
89
90//++
91DVList& Info()
92//
93// Renvoie une reference sur l''objet DVList Associe
94//--
95 {
96 if (mInfo_ == NULL) mInfo_ = new DVList;
97 return(*mInfo_);
98 }
99
100const DVList* ptrInfo() const
101 {
102 return mInfo_;
103 }
104
105protected :
106 SphereCoordSys *cs_; // Coordinate system used in the map
107 DVList* mInfo_; // Infos (variables) attachees
108};
109
110
111template <class T>
112int PixelMap<T>::PixIndex(const SpherePosition& spos)
113{
114UnitVector v = spos.Transform(*cs_);
115return(PixIndexSph(v.Theta(), v.Phi()));
116}
117
118template <class T>
119bool PixelMap<T>::Contains(const SpherePosition& spos) const
120{
121UnitVector v = spos.Transform(*cs_);
122return(ContainsSph(v.Theta(), v.Phi()));
123}
124template <class T>
125T PixelMap<T>::SetPixels(T v)
126{
127int k;
128for(k=0; k<NbPixels(); k++) PixVal(k) = v;
129return(v);
130}
131
132#endif
Note: See TracBrowser for help on using the repository browser.