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

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

Pb avec doc. doxygen - Reza 16/4/2000

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