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

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

Simplification code ecriture PPersist localmap - Introduction methodes LocalMap<T>::SizeX() SizeY() pour garder une harmonie avec TArray Correction problemes introduit par DY - R. Ansari 30/8/2000

File size: 4.6 KB
RevLine 
[842]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);
[1145]101
[1163]102 // FIO_NDataBlock<int_4> fio_nd_nphi( &dobj->NPhi_);
103 // fio_nd_nphi.Read(is);
104 // FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
105 // fio_nd_Tnphi.Read(is);
106 // FIO_NDataBlock<r_8> fio_nd_Theta( &dobj->Theta_);
107 // fio_nd_Theta.Read(is);
108 // FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
109 // fio_nd.Read(is);
[842]110
[1163]111 // Reza 30/8/2000 , - Methode de lecture plus facile
112
113 is >> dobj->NPhi_ ;
114 is >> dobj->TNphi_ ;
115 is >> dobj->Theta_;
116 is >> dobj->pixels_;
[842]117}
118
119template <class T>
120void FIO_SphereThetaPhi<T>::WriteSelf(POutPersist& os) const
121{
122
123 if(dobj == NULL)
124 {
125 cout << " WriteSelf:: dobj= null " << endl;
126 return;
127 }
128
129// On ecrit 3 uint_8
130// 0 : Numero de version, 1 : Size index, 2 reserve a l
131uint_8 itab[3];
132itab[0] = 1;
133itab[1] = dobj->SizeIndex();
134itab[2] = 0;
135os.Put(itab, 3);
136// Let's write the SphereCoordSys object
137 FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
138 fio_scs.Write(os);
139
140 char strg[256];
141 int_4 mNTheta= dobj->SizeIndex();
142 int_4 mNPix = dobj->NbPixels();
143
144 if(dobj->ptrInfo())
145 {
146 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d HasInfo",mNTheta,mNPix);
147 os.PutLine(strg);
148 os << dobj->Info();
149 }
150 else
151 {
152 sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d ",mNTheta,mNPix);
153 os.PutLine(strg);
154 }
155
156 os.PutI4(mNTheta);
157 os.PutI4(mNPix);
158 os.PutR8(dobj->PixSolAngle());
[1145]159
[1163]160 // FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_);
161 // fio_nd_nphi.Write(os);
162 // FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
163 // fio_nd_Tnphi.Write(os);
164 // FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_);
165 // fio_nd_Theta.Write(os);
166 // FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
167 // fio_nd.Write(os);
168
169 // Reza 30/8/2000 , - Methode d'ecriture plus facile
170
171 os << dobj->NPhi_;
172 os << dobj->TNphi_;
173 os << dobj->Theta_;
174 os << dobj->pixels_;
[842]175}
176
177#ifdef __CXX_PRAGMA_TEMPLATES__
178#pragma define_template FIO_SphereThetaPhi<r_8>
179#pragma define_template FIO_SphereThetaPhi<r_4>
180#pragma define_template FIO_SphereThetaPhi< complex<r_4> >
181#pragma define_template FIO_SphereThetaPhi< complex<r_8> >
182#endif
183#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
184template class FIO_SphereThetaPhi<r_8>;
185template class FIO_SphereThetaPhi<r_4>;
186template class FIO_SphereThetaPhi< complex<r_4> >;
187template class FIO_SphereThetaPhi< complex<r_8> >;
188#endif
Note: See TracBrowser for help on using the repository browser.