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

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

Correction documentation - Reza 5/1/2001

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