[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 |
|
---|
| 13 | template <class T>
|
---|
| 14 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi()
|
---|
| 15 | {
|
---|
| 16 | dobj= new SphereThetaPhi<T>;
|
---|
| 17 | ownobj= true;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | template <class T>
|
---|
| 21 | FIO_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 |
|
---|
| 29 | template <class T>
|
---|
| 30 | FIO_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 |
|
---|
| 37 | template <class T>
|
---|
| 38 | FIO_SphereThetaPhi<T>::FIO_SphereThetaPhi(SphereThetaPhi<T>* obj)
|
---|
| 39 | {
|
---|
| 40 | dobj= obj;
|
---|
| 41 | ownobj= false;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | template <class T>
|
---|
| 45 | FIO_SphereThetaPhi<T>::~FIO_SphereThetaPhi()
|
---|
| 46 | {
|
---|
| 47 | if (ownobj && dobj) delete dobj;
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | template <class T>
|
---|
| 51 | AnyDataObj* FIO_SphereThetaPhi<T>::DataObj()
|
---|
| 52 | {
|
---|
| 53 | return(dobj);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | template <class T>
|
---|
| 58 | void 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 |
|
---|
| 66 | template <class T>
|
---|
| 67 | void 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 | FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_);
|
---|
| 102 | fio_nd_nphi.Read(is);
|
---|
| 103 | FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
|
---|
| 104 | fio_nd_Tnphi.Read(is);
|
---|
| 105 | FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_);
|
---|
| 106 | fio_nd_Theta.Read(is);
|
---|
| 107 |
|
---|
| 108 | FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
|
---|
| 109 | fio_nd.Read(is);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | template <class T>
|
---|
| 113 | void FIO_SphereThetaPhi<T>::WriteSelf(POutPersist& os) const
|
---|
| 114 | {
|
---|
| 115 |
|
---|
| 116 | if(dobj == NULL)
|
---|
| 117 | {
|
---|
| 118 | cout << " WriteSelf:: dobj= null " << endl;
|
---|
| 119 | return;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | // On ecrit 3 uint_8
|
---|
| 123 | // 0 : Numero de version, 1 : Size index, 2 reserve a l
|
---|
| 124 | uint_8 itab[3];
|
---|
| 125 | itab[0] = 1;
|
---|
| 126 | itab[1] = dobj->SizeIndex();
|
---|
| 127 | itab[2] = 0;
|
---|
| 128 | os.Put(itab, 3);
|
---|
| 129 | // Let's write the SphereCoordSys object
|
---|
| 130 | FIO_SphereCoordSys fio_scs( dobj->GetCoordSys());
|
---|
| 131 | fio_scs.Write(os);
|
---|
| 132 |
|
---|
| 133 | char strg[256];
|
---|
| 134 | int_4 mNTheta= dobj->SizeIndex();
|
---|
| 135 | int_4 mNPix = dobj->NbPixels();
|
---|
| 136 |
|
---|
| 137 | if(dobj->ptrInfo())
|
---|
| 138 | {
|
---|
| 139 | sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d HasInfo",mNTheta,mNPix);
|
---|
| 140 | os.PutLine(strg);
|
---|
| 141 | os << dobj->Info();
|
---|
| 142 | }
|
---|
| 143 | else
|
---|
| 144 | {
|
---|
| 145 | sprintf(strg,"SphereThetaPhi: NSlices=%6d NPix=%9d ",mNTheta,mNPix);
|
---|
| 146 | os.PutLine(strg);
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | os.PutI4(mNTheta);
|
---|
| 150 | os.PutI4(mNPix);
|
---|
| 151 | os.PutR8(dobj->PixSolAngle());
|
---|
| 152 | FIO_NDataBlock<int_4> fio_nd_nphi(&dobj->NPhi_);
|
---|
| 153 | fio_nd_nphi.Write(os);
|
---|
| 154 | FIO_NDataBlock<int_4> fio_nd_Tnphi(&dobj->TNphi_);
|
---|
| 155 | fio_nd_Tnphi.Write(os);
|
---|
| 156 | FIO_NDataBlock<r_8> fio_nd_Theta(&dobj->Theta_);
|
---|
| 157 | fio_nd_Theta.Write(os);
|
---|
| 158 | FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
|
---|
| 159 | fio_nd.Write(os);
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | #ifdef __CXX_PRAGMA_TEMPLATES__
|
---|
| 163 | #pragma define_template FIO_SphereThetaPhi<r_8>
|
---|
| 164 | #pragma define_template FIO_SphereThetaPhi<r_4>
|
---|
| 165 | #pragma define_template FIO_SphereThetaPhi< complex<r_4> >
|
---|
| 166 | #pragma define_template FIO_SphereThetaPhi< complex<r_8> >
|
---|
| 167 | #endif
|
---|
| 168 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
|
---|
| 169 | template class FIO_SphereThetaPhi<r_8>;
|
---|
| 170 | template class FIO_SphereThetaPhi<r_4>;
|
---|
| 171 | template class FIO_SphereThetaPhi< complex<r_4> >;
|
---|
| 172 | template class FIO_SphereThetaPhi< complex<r_8> >;
|
---|
| 173 | #endif
|
---|