| [842] | 1 | // G. Le Meur 04/2000 | 
|---|
|  | 2 |  | 
|---|
|  | 3 | #include "fiolocalmap.h" | 
|---|
|  | 4 | #include "pexceptions.h" | 
|---|
|  | 5 | #include "fiondblock.h" | 
|---|
|  | 6 |  | 
|---|
|  | 7 | //******************************************************************* | 
|---|
|  | 8 | // class FIO_LocalMap<T> | 
|---|
|  | 9 | //  Les objets delegues pour la gestion de persistance | 
|---|
|  | 10 | //******************************************************************* | 
|---|
|  | 11 |  | 
|---|
|  | 12 | //++ | 
|---|
|  | 13 | template <class T> | 
|---|
|  | 14 | FIO_LocalMap<T>::FIO_LocalMap() | 
|---|
|  | 15 | // | 
|---|
|  | 16 | //-- | 
|---|
|  | 17 | { | 
|---|
|  | 18 | dobj= new LocalMap<T>; | 
|---|
|  | 19 | ownobj= true; | 
|---|
|  | 20 | } | 
|---|
|  | 21 | //++ | 
|---|
|  | 22 | template <class T> | 
|---|
|  | 23 | FIO_LocalMap<T>::FIO_LocalMap(string const& filename) | 
|---|
|  | 24 | // | 
|---|
|  | 25 | //-- | 
|---|
|  | 26 | { | 
|---|
|  | 27 | dobj= new LocalMap<T>; | 
|---|
|  | 28 | dobj->DataBlock().SetTemp(true); | 
|---|
|  | 29 | ownobj= true; | 
|---|
|  | 30 | Read(filename); | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | //++ | 
|---|
|  | 34 | template <class T> | 
|---|
|  | 35 | FIO_LocalMap<T>::FIO_LocalMap(const LocalMap<T>& obj) | 
|---|
|  | 36 | // | 
|---|
|  | 37 | //-- | 
|---|
|  | 38 | { | 
|---|
|  | 39 | dobj= new LocalMap<T>(obj, true); | 
|---|
|  | 40 | dobj->DataBlock().SetTemp(true); | 
|---|
|  | 41 | ownobj= true; | 
|---|
|  | 42 | } | 
|---|
|  | 43 |  | 
|---|
|  | 44 | template <class T> | 
|---|
|  | 45 | FIO_LocalMap<T>::FIO_LocalMap(LocalMap<T>* obj) | 
|---|
|  | 46 | { | 
|---|
|  | 47 | dobj= obj; | 
|---|
|  | 48 | ownobj= false; | 
|---|
|  | 49 | } | 
|---|
|  | 50 |  | 
|---|
|  | 51 | //++ | 
|---|
|  | 52 | template <class T> | 
|---|
|  | 53 | FIO_LocalMap<T>::~FIO_LocalMap() | 
|---|
|  | 54 | // | 
|---|
|  | 55 | //-- | 
|---|
|  | 56 | { | 
|---|
|  | 57 | if (ownobj && dobj) delete dobj; | 
|---|
|  | 58 | } | 
|---|
|  | 59 |  | 
|---|
|  | 60 | //++ | 
|---|
|  | 61 | template <class T> | 
|---|
|  | 62 | AnyDataObj* FIO_LocalMap<T>::DataObj() | 
|---|
|  | 63 | // | 
|---|
|  | 64 | //-- | 
|---|
|  | 65 | { | 
|---|
|  | 66 | return(dobj); | 
|---|
|  | 67 | } | 
|---|
|  | 68 |  | 
|---|
|  | 69 | //++ | 
|---|
|  | 70 | template <class T> | 
|---|
|  | 71 | void FIO_LocalMap<T>::SetDataObj(AnyDataObj & o) | 
|---|
|  | 72 | // | 
|---|
|  | 73 | //-- | 
|---|
|  | 74 | { | 
|---|
|  | 75 | LocalMap<T> * po = dynamic_cast< LocalMap<T> * >(&o); | 
|---|
|  | 76 | if (po == NULL) return; | 
|---|
|  | 77 | if (ownobj && dobj) delete dobj; | 
|---|
|  | 78 | dobj = po; ownobj = false; | 
|---|
|  | 79 | } | 
|---|
|  | 80 |  | 
|---|
|  | 81 | //++ | 
|---|
|  | 82 | template <class T> | 
|---|
|  | 83 | void FIO_LocalMap<T>::ReadSelf(PInPersist& is) | 
|---|
|  | 84 | // | 
|---|
|  | 85 | //-- | 
|---|
|  | 86 | { | 
|---|
|  | 87 |  | 
|---|
|  | 88 | if(dobj == NULL) | 
|---|
|  | 89 | { | 
|---|
|  | 90 | dobj= new LocalMap<T>; | 
|---|
|  | 91 | dobj->DataBlock().SetTemp(true); | 
|---|
|  | 92 | ownobj= true; | 
|---|
|  | 93 | } | 
|---|
|  | 94 |  | 
|---|
|  | 95 | // Pour savoir s'il y avait un DVList Info associe | 
|---|
|  | 96 | char strg[256]; | 
|---|
|  | 97 | is.GetLine(strg, 255); | 
|---|
|  | 98 | bool hadinfo= false; | 
|---|
|  | 99 | if(strncmp(strg+strlen(strg)-7, "HasInfo", 7) == 0)  hadinfo= true; | 
|---|
|  | 100 | if(hadinfo) | 
|---|
|  | 101 | {    // Lecture eventuelle du DVList Info | 
|---|
|  | 102 | is >> dobj->Info(); | 
|---|
|  | 103 | } | 
|---|
|  | 104 |  | 
|---|
|  | 105 | int_4 nSzX; | 
|---|
|  | 106 | is.GetI4(nSzX); | 
|---|
|  | 107 | //  dobj->setSize_x(nSzX); | 
|---|
|  | 108 |  | 
|---|
|  | 109 | int_4 nSzY; | 
|---|
|  | 110 | is.GetI4(nSzY); | 
|---|
|  | 111 | //  dobj->setSize_y(nSzY); | 
|---|
|  | 112 |  | 
|---|
|  | 113 | int_4 nPix; | 
|---|
|  | 114 | is.GetI4(nPix); | 
|---|
|  | 115 | //  dobj->setNbPixels(nPix); | 
|---|
|  | 116 | dobj->ReSize(nSzX, nSzY); | 
|---|
|  | 117 | string ss("local mapping is done"); | 
|---|
|  | 118 | string sso; | 
|---|
|  | 119 | is.GetStr(sso); | 
|---|
|  | 120 | if(sso == ss) | 
|---|
|  | 121 | { | 
|---|
|  | 122 | cout<<" ReadSelf:: local mapping"<<endl; | 
|---|
|  | 123 | int_4 x0, y0; | 
|---|
|  | 124 | double theta, phi, angle; | 
|---|
|  | 125 | is.GetI4(x0); | 
|---|
|  | 126 | is.GetI4(y0); | 
|---|
|  | 127 | is.GetR8(theta); | 
|---|
|  | 128 | is.GetR8(phi); | 
|---|
|  | 129 | is.GetR8(angle); | 
|---|
|  | 130 | dobj->SetOrigin(theta, phi, x0, y0, angle); | 
|---|
|  | 131 |  | 
|---|
|  | 132 | double angleX, angleY; | 
|---|
|  | 133 | is.GetR8(angleX); | 
|---|
|  | 134 | is.GetR8(angleY); | 
|---|
|  | 135 | dobj->SetSize(angleX, angleY); | 
|---|
|  | 136 | } | 
|---|
|  | 137 |  | 
|---|
|  | 138 | // On lit le DataBlock; | 
|---|
|  | 139 | FIO_NDataBlock<T> fio_nd(&dobj->DataBlock()); | 
|---|
|  | 140 | fio_nd.Read(is); | 
|---|
|  | 141 | } | 
|---|
|  | 142 |  | 
|---|
|  | 143 | //++ | 
|---|
|  | 144 | template <class T> | 
|---|
|  | 145 | void FIO_LocalMap<T>::WriteSelf(POutPersist& os) const | 
|---|
|  | 146 | // | 
|---|
|  | 147 | //-- | 
|---|
|  | 148 | { | 
|---|
|  | 149 | if(dobj == NULL) | 
|---|
|  | 150 | { | 
|---|
|  | 151 | cout << " FIO_LocalMap::WriteSelf:: dobj= null " << endl; | 
|---|
|  | 152 | return; | 
|---|
|  | 153 | } | 
|---|
|  | 154 |  | 
|---|
|  | 155 | char strg[256]; | 
|---|
|  | 156 | int_4 nSzX= dobj->Size_x(); | 
|---|
|  | 157 | int_4 nSzY= dobj->Size_y(); | 
|---|
|  | 158 | int_4 nPix= dobj->NbPixels(); | 
|---|
|  | 159 |  | 
|---|
|  | 160 | if(dobj->ptrInfo()) | 
|---|
|  | 161 | { | 
|---|
|  | 162 | sprintf(strg,"LocalMap: NPixX=%6d  NPixY=%9d HasInfo",nSzX,nSzY); | 
|---|
|  | 163 | os.PutLine(strg); | 
|---|
|  | 164 | os << dobj->Info(); | 
|---|
|  | 165 | } | 
|---|
|  | 166 | else | 
|---|
|  | 167 | { | 
|---|
|  | 168 | sprintf(strg,"LocalMap: NPixX=%6d  NPixY=%9d ",nSzX,nSzY); | 
|---|
|  | 169 | os.PutLine(strg); | 
|---|
|  | 170 | } | 
|---|
|  | 171 |  | 
|---|
|  | 172 | os.PutI4(nSzX); | 
|---|
|  | 173 | os.PutI4(nSzY); | 
|---|
|  | 174 | os.PutI4(nPix); | 
|---|
|  | 175 |  | 
|---|
|  | 176 | if(dobj->LocalMap_isDone()) | 
|---|
|  | 177 | { | 
|---|
|  | 178 | string ss("local mapping is done"); | 
|---|
|  | 179 | os.PutStr(ss); | 
|---|
|  | 180 | int_4 x0, y0; | 
|---|
|  | 181 | double theta, phi, angle; | 
|---|
|  | 182 | dobj->Origin(theta, phi, x0, y0, angle); | 
|---|
|  | 183 | os.PutI4(x0); | 
|---|
|  | 184 | os.PutI4(y0); | 
|---|
|  | 185 | os.PutR8(theta); | 
|---|
|  | 186 | os.PutR8(phi); | 
|---|
|  | 187 | os.PutR8(angle); | 
|---|
|  | 188 |  | 
|---|
|  | 189 | double angleX, angleY; | 
|---|
|  | 190 | dobj->Aperture(angleX, angleY); | 
|---|
|  | 191 | os.PutR8(angleX); | 
|---|
|  | 192 | os.PutR8(angleY); | 
|---|
|  | 193 | } | 
|---|
|  | 194 | else | 
|---|
|  | 195 | { | 
|---|
|  | 196 | string ss("no local mapping"); | 
|---|
|  | 197 | os.PutStr(ss); | 
|---|
|  | 198 | } | 
|---|
|  | 199 |  | 
|---|
|  | 200 | // On ecrit le dataBlock | 
|---|
|  | 201 | FIO_NDataBlock<T> fio_nd(&dobj->DataBlock()); | 
|---|
|  | 202 | fio_nd.Write(os); | 
|---|
|  | 203 | } | 
|---|
|  | 204 |  | 
|---|
|  | 205 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 206 | #pragma define_template FIO_LocalMap<r_8> | 
|---|
|  | 207 | #pragma define_template FIO_LocalMap<r_4> | 
|---|
|  | 208 | #pragma define_template FIO_LocalMap< complex<r_4> > | 
|---|
|  | 209 | #pragma define_template FIO_LocalMap< complex<r_8> > | 
|---|
|  | 210 | #endif | 
|---|
|  | 211 | #if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES) | 
|---|
|  | 212 | template class FIO_LocalMap<r_8>; | 
|---|
|  | 213 | template class FIO_LocalMap<r_4>; | 
|---|
|  | 214 | template class FIO_LocalMap< complex<r_4> >; | 
|---|
|  | 215 | template class FIO_LocalMap< complex<r_8> >; | 
|---|
|  | 216 | #endif | 
|---|