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

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

divers nettoyages : const. de copie, surcharge = etc.

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