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