source: Sophya/trunk/SophyaPI/PIext/nomskymapadapter.cc@ 586

Last change on this file since 586 was 585, checked in by ercodmgr, 26 years ago

Modifs pour SOPHYA , TMatrix, PixelMap, ... - Suite - Reza 17/11/99

File size: 5.6 KB
RevLine 
[585]1#include "machdefs.h"
2#include <stdlib.h>
3#include <typeinfo>
4#include <iostream.h>
5#include <string>
6#include <complex>
7
8#include "nomskymapadapter.h"
9#include "spherethetaphi.h"
10#include "spheregorski.h"
11#include "localmap.h"
12
13
14//----------------------------------------------------------------
15// Class Adaptateur d'objet (Pour NamedObjMgr) d'objet PixelMap<T>
16//----------------------------------------------------------------
17
18
19/* --Methode-- */
20template <class T>
21NOMAdapter_PixelMap<T>::NOMAdapter_PixelMap(PixelMap<T> * o)
22 : NObjMgrAdapter((AnyDataObj *)o)
23{
24mMap = o;
25}
26
27/* --Methode-- */
28template <class T>
29NOMAdapter_PixelMap<T>::~NOMAdapter_PixelMap()
30{
31}
32
33/* --Methode-- */
34template <class T>
35NObjMgrAdapter* NOMAdapter_PixelMap<T>::Clone(AnyDataObj* o)
36{
37PixelMap<T>* m = dynamic_cast<PixelMap<T> *>(o);
38if (m) return ( new NOMAdapter_PixelMap<T>(m) );
39return ( new NObjMgrAdapter(o) );
40}
41
42/* --Methode-- */
43template <class T>
44AnyDataObj* NOMAdapter_PixelMap<T>::GetCopyObj()
45{
46LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap);
47if (lm != NULL) return( new LocalMap<T>(*lm) );
48SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap);
49if (st != NULL) return( new SphereThetaPhi<T>(*st) );
50SphereGorski<T>* sg = dynamic_cast< SphereGorski<T> * >(mMap);
51if (sg != NULL) return( new SphereGorski<T>(*sg) );
52return(NULL);
53}
54
55/* --Methode-- */
56template <class T>
57void NOMAdapter_PixelMap<T>::SavePPF(POutPersist& pos, string const & nom)
58{
59LocalMap<T>* lm = dynamic_cast< LocalMap<T> * >(mMap);
60if (lm != NULL) {
61 FIO_LocalMap<T> fio(lm);
62 fio.Write(pos, nom);
63 return;
64 }
65SphereThetaPhi<T>* st = dynamic_cast< SphereThetaPhi<T> * >(mMap);
66if (st != NULL) {
67 FIO_SphereThetaPhi<T> fio(st);
68 fio.Write(pos, nom);
69 return;
70 }
71SphereGorski<T>* sg = dynamic_cast< SphereGorski<T> * >(mMap);
72if (sg != NULL) {
73 FIO_SphereGorski<T> fio(sg);
74 fio.Write(pos, nom);
75 return;
76 }
77string s = typeid(*mMap).name();
78cout << "NOMAdapter_PixelMap<T>::SavePPF() - Error : Not supported for " << s << endl;
79}
80
81/* --Methode-- */
82template <class T>
83void NOMAdapter_PixelMap<T>::Print(ostream& os)
84{
85string s = typeid(*mMap).name();
86cout << "SkyMap Type: " << s << " NbPixels= " << mMap->NbPixels() << endl;
87}
88
89
90/* --Methode-- */
91template <class T>
92P2DArrayAdapter* NOMAdapter_PixelMap<T>::Get2DArray(string &)
93{
94return(NULL);
95}
96
97/* --Methode-- */
98template <class T>
99NTupleInterface* NOMAdapter_PixelMap<T>::GetNTupleInterface(bool& adel)
100{
101adel = true;
102return( new NTupInt_PixelMap<T>(mMap) );
103}
104
105
106
107// -------------------------------------------------------------
108
109/* --Methode-- */
110template <class T>
111NTupInt_PixelMap<T>::NTupInt_PixelMap(PixelMap<T>* m)
112{
113mMap = m;
114}
115
116/* --Methode-- */
117template <class T>
118NTupInt_PixelMap<T>::~NTupInt_PixelMap()
119{
120}
121
122/* --Methode-- */
123template <class T>
124uint_4 NTupInt_PixelMap<T>::NbLines() const
125{
126return( mMap->NbPixels() );
127}
128
129/* --Methode-- */
130template <class T>
131uint_4 NTupInt_PixelMap<T>::NbColumns() const
132{
133return(8);
134}
135
136/* --Methode-- */
137template <class T>
138r_8* NTupInt_PixelMap<T>::GetLineD(int n) const
139{
140int i;
141if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
142 for(i=0; i<8; i++) mRet[i] = 0.;
143else {
144 double teta,phi;
145 mMap->PixThetaPhi(n, teta, phi);
146 mRet[0] = n; mRet[1] = mMap->PixVal(n);
147 mRet[2] = mRet[1]; mRet[3] = 0.;
148 mRet[4] = mRet[1]; mRet[5] = 0.;
149 mRet[6] = teta; mRet[7] = phi;
150 }
151return(mRet);
152}
153
154/* --Methode-- */
155template <class T>
156string NTupInt_PixelMap<T>::VarList_C(const char* nx) const
157{
158string nomx;
159if (nx) nomx = nx;
160else nomx = "_xh_";
161string vardec = "double i,k,val,real,imag,mod,phas,teta,phi; \n";
162vardec += "i = " + nomx + "[0]; k = " + nomx + "[0]; val = " + nomx + "[1]; \n";
163vardec += "real = " + nomx + "[2]; imag = " + nomx + "[3]; \n";
164vardec += "mod = " + nomx + "[4]; phas = " + nomx + "[5]; \n";
165vardec += "teta = " + nomx + "[6]; phi = " + nomx + "[7]; \n";
166return(vardec);
167}
168
169r_8* NTupInt_PixelMap< complex<float> >::GetLineD(int n) const
170{
171int i;
172if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
173 for(i=0; i<8; i++) mRet[i] = 0.;
174else {
175 double teta,phi;
176 mMap->PixThetaPhi(n, teta, phi);
177 mRet[0] = n;
178 mRet[2] = mMap->PixVal(n).real(); mRet[3] = mMap->PixVal(n).imag();
179 mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]);
180 mRet[5] = atan2(mRet[3], mRet[2]);
181 mRet[6] = teta; mRet[7] = phi;
182 }
183return(mRet);
184}
185
186r_8* NTupInt_PixelMap< complex<double> >::GetLineD(int n) const
187{
188int i;
189if ((n < 0) || (n >= (int)(mMap->NbPixels()) ))
190 for(i=0; i<8; i++) mRet[i] = 0.;
191else {
192 double teta,phi;
193 mMap->PixThetaPhi(n, teta, phi);
194 mRet[0] = n;
195 mRet[2] = mMap->PixVal(n).real(); mRet[3] = mMap->PixVal(n).imag();
196 mRet[1] = mRet[4] = sqrt(mRet[2]*mRet[2]+mRet[3]*mRet[3]);
197 mRet[5] = atan2(mRet[3], mRet[2]);
198 mRet[6] = teta; mRet[7] = phi;
199 }
200return(mRet);
201}
202
203
204#ifdef __CXX_PRAGMA_TEMPLATES__
205#pragma define_template NOMAdapter_PixelMap<r_4>
206#pragma define_template NOMAdapter_PixelMap<r_8>
207#pragma define_template NOMAdapter_PixelMap< complex<float> >
208#pragma define_template NOMAdapter_PixelMap< complex<double> >
209#pragma define_template NTupInt_PixelMap<r_4>
210#pragma define_template NTupInt_PixelMap<r_8>
211#pragma define_template NTupInt_PixelMap< complex<float> >
212#pragma define_template NTupInt_PixelMap< complex<double> >
213#endif
214
215#if defined(ANSI_TEMPLATES)
216template class NOMAdapter_PixelMap<r_4>;
217template class NOMAdapter_PixelMap<r_8>;
218template class NOMAdapter_PixelMap< complex<float> >;
219template class NOMAdapter_PixelMap< complex<double> >;
220template class NTupInt_PixelMap<r_4>;
221template class NTupInt_PixelMap<r_8>;
222template class NTupInt_PixelMap< complex<float> >;
223template class NTupInt_PixelMap< complex<double> >;
224#endif
Note: See TracBrowser for help on using the repository browser.