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

Last change on this file since 2610 was 2322, checked in by cmv, 23 years ago
  • passage xxstream.h en xxstream
  • compile avec gcc_3.2, gcc_2.96 et cxx En 3.2 le seek from ::end semble marcher (voir Eval/COS/pbseekios.cc)

rz+cmv 11/2/2003

File size: 4.0 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>
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 string 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);
98PixelMap<T>& SetT(T v);
99 //inline T operator = (T v) { return(SetPixels(v)); }
100inline PixelMap<T>& operator = (T v) { return(SetT(v)); }
101
102
103
104//++
105DVList& Info()
106//
107// Renvoie une reference sur l''objet DVList Associe
108//--
109 {
110 if (mInfo_ == NULL) mInfo_ = new DVList;
111 return(*mInfo_);
112 }
113
114const DVList* ptrInfo() const
115 {
116 return mInfo_;
117 }
118
119protected :
120 SphereCoordSys *cs_; // Coordinate system used in the map
121 DVList* mInfo_; // Infos (variables) attachees
122};
123
124
125template <class T>
126int_4 PixelMap<T>::PixIndex(const SpherePosition& spos)
127{
128UnitVector v = spos.Transform(*cs_);
129return(PixIndexSph(v.Theta(), v.Phi()));
130}
131
132template <class T>
133bool PixelMap<T>::Contains(const SpherePosition& spos) const
134{
135UnitVector v = spos.Transform(*cs_);
136return(ContainsSph(v.Theta(), v.Phi()));
137}
138template <class T>
139T PixelMap<T>::SetPixels(T v)
140{
141int k;
142for(k=0; k<NbPixels(); k++) PixVal(k) = v;
143return(v);
144}
145template <class T>
146PixelMap<T>& PixelMap<T>::SetT(T v)
147{
148int k;
149for(k=0; k<NbPixels(); k++) PixVal(k) = v;
150return(*this);
151}
152
153
154} // Fin du namespace
155
156#endif
Note: See TracBrowser for help on using the repository browser.