source: Sophya/trunk/SophyaLib/SkyMap/pixelmap.h@ 1242

Last change on this file since 1242 was 1066, checked in by ansari, 25 years ago

de la doc mal placee cmv 12/7/00

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