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