source: Sophya/trunk/SophyaLib/SkyMap/fiospherethetaphi.cc@ 1145

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

des NDataBlock<int> changes en NDataBlock<int_4> pour une rationalisation Mac.

Dominique

File size: 4.5 KB
Line 
1// G. Le Meur 04/2000
2
3#include "fiospherethetaphi.h"
4#include "pexceptions.h"
5#include "fiondblock.h"
6
7///////////////////////////////////////////////////////////
8// --------------------------------------------------------
9// Les objets delegues pour la gestion de persistance
10// --------------------------------------------------------
11//////////////////////////////////////////////////////////
12
13template <class T>
14FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi()
15{
16 dobj= new SphereThetaPhi<T>;
17 ownobj= true;
18}
19
20template <class T>
21FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(string const& filename)
22{
23 dobj= new SphereThetaPhi<T>;
24 dobj->pixels_.SetTemp(true);
25 ownobj= true;
26 Read(filename);
27}
28
29template <class T>
30FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(const SphereThetaPhi<T>& obj)
31{
32 dobj= new SphereThetaPhi<T>(obj, true);
33 dobj->pixels_.SetTemp(true);
34 ownobj= true;
35}
36
37template <class T>
38FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(SphereThetaPhi<T>* obj)
39{
40 dobj= obj;
41 ownobj= false;
42}
43
44template <class T>
45FIO_SphereThetaPhi<T>::~FIO_SphereThetaPhi()
46{
47 if (ownobj && dobj) delete dobj;
48}
49
50template <class T>
51AnyDataObj* FIO_SphereThetaPhi<T>::DataObj()
52{
53 return(dobj);
54}
55
56
57template <class T>
58void FIO_SphereThetaPhi<T>::SetDataObj(AnyDataObj & o)
59{
60 SphereThetaPhi<T> * po = dynamic_cast< SphereThetaPhi<T> * >(&o);
61 if (po == NULL) return;
62 if (ownobj && dobj) delete dobj;
63 dobj = po; ownobj = false;
64}
65
66template <class T>
67void FIO_SphereThetaPhi<T>::ReadSelf(PInPersist& is)
68{
69
70 if(dobj == NULL)
71 {
72 dobj= new SphereThetaPhi<T>;
73 dobj->pixels_.SetTemp(true);
74 ownobj= true;
75 }
76
77 // On lit les 3 premiers uint_8
78 uint_8 itab[3];
79 is.Get(itab, 3);
80// Let's Read the SphereCoordSys object -- ATTENTIOn - $CHECK$
81 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
82 fio_scs.Read(is);
83
84 // Pour savoir s'il y avait un DVList Info associe
85 char strg[256];
86 is.GetLine(strg, 255);
87 bool hadinfo= false;
88 if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0) hadinfo= true;
89 if(hadinfo)
90 { // Lecture eventuelle du DVList Info
91 is >> dobj->Info();
92 }
93
94 int_4 mNTheta;
95 is.GetI4(mNTheta);
96 int_4 mNPix;
97 is.GetI4(mNPix);
98 double mOmeg;
99 is.GetR8(mOmeg);
100 dobj->setParameters( mNTheta, mNPix, mOmeg);
101
102 //FIO_NDataBlock<int> fio_nd_nphi( &dobj->NPhi_); // Compatibilite mac. D. Y.
103 FIO_NDataBlock<int_4> fio_nd_nphi( (int_4) &dobj->NPhi_);
104
105 fio_nd_nphi.Read(is);
106 //FIO_NDataBlock<int> fio_nd_Tnphi(&dobj->TNphi_);
107 FIO_NDataBlock<int_4> fio_nd_Tnphi( (int_4) &dobj->TNphi_);
108
109 fio_nd_Tnphi.Read(is);
110 FIO_NDataBlock<r_8> fio_nd_Theta( &dobj->Theta_);
111 fio_nd_Theta.Read(is);
112
113FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
114fio_nd.Read(is);
115}
116
117template <class T>
118void FIO_SphereThetaPhi<T>::WriteSelf(POutPersist& os) const
119{
120
121 if(dobj == NULL)
122 {
123 cout << " WriteSelf:: dobj= null " << endl;
124 return;
125 }
126
127// On ecrit 3 uint_8
128// 0 : Numero de version, 1 : Size index, 2 reserve a l
129uint_8 itab[3];
130itab[0] = 1;
131itab[1] = dobj->SizeIndex();
132itab[2] = 0;
133os.Put(itab, 3);
134// Let's write the SphereCoordSys object
135 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
136 fio_scs.Write(os);
137
138 char strg[256];
139 int_4 mNTheta= dobj->SizeIndex();
140 int_4 mNPix = dobj->NbPixels();
141
142 if(dobj->ptrInfo())
143 {
144 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d HasInfo",mNTheta,mNPix);
145 os.PutLine(strg);
146 os << dobj->Info();
147 }
148 else
149 {
150 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d ",mNTheta,mNPix);
151 os.PutLine(strg);
152 }
153
154 os.PutI4(mNTheta);
155 os.PutI4(mNPix);
156 os.PutR8(dobj->PixSolAngle());
157
158 // FIO_NDataBlock<int> fio_nd_nphi(&dobj->NPhi_); // Compatibilite Coherence Mac. D.Y.
159 FIO_NDataBlock<int_4> fio_nd_nphi( (int_4) &dobj->NPhi_);
160 fio_nd_nphi.Write(os);
161
162 //FIO_NDataBlock<int> fio_nd_Tnphi(&dobj->TNphi_);
163 FIO_NDataBlock<int_4> fio_nd_Tnphi( (int_4) &dobj->TNphi_);
164
165 fio_nd_Tnphi.Write(os);
166 FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_);
167 fio_nd_Theta.Write(os);
168FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
169fio_nd.Write(os);
170}
171
172#ifdef __CXX_PRAGMA_TEMPLATES__
173#pragma define_template FIO_SphereThetaPhi<r_8>
174#pragma define_template FIO_SphereThetaPhi<r_4>
175#pragma define_template FIO_SphereThetaPhi< complex<r_4> >
176#pragma define_template FIO_SphereThetaPhi< complex<r_8> >
177#endif
178#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
179template class FIO_SphereThetaPhi<r_8>;
180template class FIO_SphereThetaPhi<r_4>;
181template class FIO_SphereThetaPhi< complex<r_4> >;
182template class FIO_SphereThetaPhi< complex<r_8> >;
183#endif
Note: See TracBrowser for help on using the repository browser.