| [295] | 1 | #include "machdefs.h" | 
|---|
|  | 2 | #include <stdlib.h> | 
|---|
|  | 3 | #include <typeinfo> | 
|---|
|  | 4 | #include <iostream.h> | 
|---|
|  | 5 | #include <string> | 
|---|
|  | 6 |  | 
|---|
|  | 7 | #include "nomimagadapter.h" | 
|---|
| [495] | 8 | #ifdef SANS_EVOLPLANCK | 
|---|
| [295] | 9 | #include "fitsimage.h" | 
|---|
| [495] | 10 | #endif | 
|---|
| [295] | 11 | #include "pimgadapter.h" | 
|---|
|  | 12 |  | 
|---|
|  | 13 |  | 
|---|
|  | 14 | //--------------------------------------------------------------- | 
|---|
|  | 15 | // Class Adaptateur d'objet (Pour NamedObjMgr) d'objet Image<T> | 
|---|
|  | 16 | //--------------------------------------------------------------- | 
|---|
|  | 17 |  | 
|---|
|  | 18 |  | 
|---|
|  | 19 | /* --Methode-- */ | 
|---|
|  | 20 | template <class T> | 
|---|
|  | 21 | NOMAdapter_Image<T>::NOMAdapter_Image(Image<T> * o) | 
|---|
|  | 22 | : NObjMgrAdapter(o) | 
|---|
|  | 23 | { | 
|---|
|  | 24 | mImg = o; | 
|---|
|  | 25 | } | 
|---|
|  | 26 |  | 
|---|
|  | 27 | /* --Methode-- */ | 
|---|
|  | 28 | template <class T> | 
|---|
|  | 29 | NOMAdapter_Image<T>::~NOMAdapter_Image() | 
|---|
|  | 30 | { | 
|---|
|  | 31 | } | 
|---|
|  | 32 |  | 
|---|
|  | 33 | /* --Methode-- */ | 
|---|
|  | 34 | template <class T> | 
|---|
|  | 35 | NObjMgrAdapter* NOMAdapter_Image<T>::Clone(AnyDataObj* o) | 
|---|
|  | 36 | { | 
|---|
|  | 37 | Image<T>* im = dynamic_cast<Image<T> *>(o); | 
|---|
|  | 38 | if (im) return ( new NOMAdapter_Image<T>(im) ); | 
|---|
|  | 39 | return ( new NObjMgrAdapter(o) ); | 
|---|
|  | 40 | } | 
|---|
|  | 41 |  | 
|---|
| [463] | 42 | /* --Methode-- */ | 
|---|
|  | 43 | template <class T> | 
|---|
|  | 44 | AnyDataObj* NOMAdapter_Image<T>::GetCopyObj() | 
|---|
|  | 45 | { | 
|---|
| [495] | 46 | #ifdef SANS_EVOLPLANCK | 
|---|
| [463] | 47 | FitsImage<T> * fima = dynamic_cast<FitsImage<T> *>(mImg); | 
|---|
|  | 48 | if (fima == NULL)   return( new Image<T>(*mImg ) ); | 
|---|
|  | 49 | else return ( new FitsImage<T>(*fima) ); | 
|---|
| [495] | 50 | #else | 
|---|
|  | 51 | return( new Image<T>(*mImg ) ); | 
|---|
|  | 52 | #endif | 
|---|
| [463] | 53 | } | 
|---|
| [295] | 54 |  | 
|---|
|  | 55 | /* --Methode-- */ | 
|---|
|  | 56 | template <class T> | 
|---|
|  | 57 | void NOMAdapter_Image<T>::SaveFits(string const & flnm) | 
|---|
|  | 58 | { | 
|---|
|  | 59 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 60 | FitsImage<T> fim(*mImg, 1); | 
|---|
|  | 61 | fim.Save(flnm); | 
|---|
|  | 62 | #else | 
|---|
| [495] | 63 | string s = typeid(*mImg).name(); | 
|---|
| [295] | 64 | cout << "NOMAdapter_Image<T>::SaveFits() - Error : Not supported for " << s << endl; | 
|---|
|  | 65 | #endif | 
|---|
|  | 66 | } | 
|---|
|  | 67 |  | 
|---|
|  | 68 | /* --Methode-- */ | 
|---|
|  | 69 | template <class T> | 
|---|
|  | 70 | void NOMAdapter_Image<T>::SavePPF(POutPersist& pos, string const & nom) | 
|---|
|  | 71 | { | 
|---|
|  | 72 | #ifdef SANS_EVOLPLANCK | 
|---|
|  | 73 | // PEIDA-EROS L'histo est lui-meme PPersist | 
|---|
|  | 74 | string tag = nom;  // A cause de const | 
|---|
|  | 75 | mImg->Write(pos,0,tag); | 
|---|
|  | 76 | #else | 
|---|
|  | 77 | string s = typeid(*mObj).name(); | 
|---|
|  | 78 | cout << "NOMAdapter_Image<T>::SavePPF() - Error : Not supported for " << s << endl; | 
|---|
|  | 79 | #endif | 
|---|
|  | 80 | } | 
|---|
|  | 81 |  | 
|---|
|  | 82 | /* --Methode-- */ | 
|---|
|  | 83 | template <class T> | 
|---|
|  | 84 | void NOMAdapter_Image<T>::Print(ostream& os) | 
|---|
|  | 85 | { | 
|---|
| [344] | 86 | mImg->Print(os); | 
|---|
| [295] | 87 | } | 
|---|
|  | 88 |  | 
|---|
|  | 89 |  | 
|---|
|  | 90 | /* --Methode-- */ | 
|---|
|  | 91 | template <class T> | 
|---|
|  | 92 | P2DArrayAdapter* NOMAdapter_Image<T>::Get2DArray(string &) | 
|---|
|  | 93 | { | 
|---|
|  | 94 | return ( new ImageAdapter<T>(mImg, false) ); | 
|---|
|  | 95 | } | 
|---|
|  | 96 |  | 
|---|
|  | 97 | /* --Methode-- */ | 
|---|
|  | 98 | template <class T> | 
|---|
| [344] | 99 | NTupleInterface* NOMAdapter_Image<T>::GetNTupleInterface(bool& adel) | 
|---|
| [295] | 100 | { | 
|---|
| [344] | 101 | adel = true; | 
|---|
| [295] | 102 | return( new NTupInt_Image<T>(mImg) ); | 
|---|
|  | 103 | } | 
|---|
|  | 104 |  | 
|---|
|  | 105 |  | 
|---|
|  | 106 |  | 
|---|
|  | 107 | // ------------------------------------------------------------- | 
|---|
|  | 108 |  | 
|---|
|  | 109 | /* --Methode-- */ | 
|---|
|  | 110 | template <class T> | 
|---|
|  | 111 | NTupInt_Image<T>::NTupInt_Image(Image<T>* m) | 
|---|
|  | 112 | { | 
|---|
|  | 113 | mImg = m; | 
|---|
|  | 114 | } | 
|---|
|  | 115 |  | 
|---|
|  | 116 | /* --Methode-- */ | 
|---|
|  | 117 | template <class T> | 
|---|
|  | 118 | NTupInt_Image<T>::~NTupInt_Image() | 
|---|
|  | 119 | { | 
|---|
|  | 120 | } | 
|---|
|  | 121 |  | 
|---|
|  | 122 | /* --Methode-- */ | 
|---|
|  | 123 | template <class T> | 
|---|
| [326] | 124 | uint_4 NTupInt_Image<T>::NbLines() const | 
|---|
| [295] | 125 | { | 
|---|
|  | 126 | return( mImg->XSize() * mImg->YSize() ); | 
|---|
|  | 127 | } | 
|---|
|  | 128 |  | 
|---|
|  | 129 | /* --Methode-- */ | 
|---|
|  | 130 | template <class T> | 
|---|
| [326] | 131 | uint_4 NTupInt_Image<T>::NbColumns() const | 
|---|
| [295] | 132 | { | 
|---|
|  | 133 | return(3); | 
|---|
|  | 134 | } | 
|---|
|  | 135 |  | 
|---|
|  | 136 | /* --Methode-- */ | 
|---|
|  | 137 | template <class T> | 
|---|
| [326] | 138 | r_8* NTupInt_Image<T>::GetLineD(int n) const | 
|---|
| [295] | 139 | { | 
|---|
|  | 140 | int i,j; | 
|---|
|  | 141 | if ((n < 0) || (n >= mImg->XSize() * mImg->YSize() )) | 
|---|
|  | 142 | for(i=0; i<3; i++)  mRet[i] = 0.; | 
|---|
|  | 143 | else { | 
|---|
|  | 144 | i = n%mImg->XSize();  j = n/mImg->XSize(); | 
|---|
|  | 145 | mRet[0] = i;  mRet[1] = j;  mRet[2] = (*mImg)(i,j); | 
|---|
|  | 146 | } | 
|---|
|  | 147 | return(mRet); | 
|---|
|  | 148 | } | 
|---|
|  | 149 |  | 
|---|
|  | 150 | /* --Methode-- */ | 
|---|
|  | 151 | template <class T> | 
|---|
| [326] | 152 | string NTupInt_Image<T>::VarList_C(const char* nx) const | 
|---|
| [295] | 153 | { | 
|---|
|  | 154 | string nomx; | 
|---|
|  | 155 | if (nx) nomx = nx; | 
|---|
|  | 156 | else nomx = "_xh_"; | 
|---|
|  | 157 | string vardec = "double x,y,pix,i,j,val; \n"; | 
|---|
|  | 158 | vardec += "x = i = " + nomx + "[0]; y = j = " + nomx + "[1];  pix = val = " + nomx + "[2]; \n"; | 
|---|
|  | 159 | return(vardec); | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
|  | 162 | #ifdef __CXX_PRAGMA_TEMPLATES__ | 
|---|
|  | 163 | #pragma define_template NOMAdapter_Image<uint_2> | 
|---|
|  | 164 | #pragma define_template NOMAdapter_Image<int_2> | 
|---|
|  | 165 | #pragma define_template NOMAdapter_Image<int_4> | 
|---|
|  | 166 | #pragma define_template NOMAdapter_Image<r_4> | 
|---|
|  | 167 | #pragma define_template NTupInt_Image<uint_2> | 
|---|
|  | 168 | #pragma define_template NTupInt_Image<int_2> | 
|---|
|  | 169 | #pragma define_template NTupInt_Image<int_4> | 
|---|
|  | 170 | #pragma define_template NTupInt_Image<r_4> | 
|---|
|  | 171 | #endif | 
|---|
| [506] | 172 | #if defined(ANSI_TEMPLATES) || defined(__ANSI_TEMPLATES__) || defined(__GNU_TEMPLATES__) | 
|---|
| [295] | 173 | template class NOMAdapter_Image<uint_2>; | 
|---|
|  | 174 | template class NOMAdapter_Image<int_2>; | 
|---|
|  | 175 | template class NOMAdapter_Image<int_4>; | 
|---|
|  | 176 | template class NOMAdapter_Image<r_4>; | 
|---|
|  | 177 | template class NTupInt_Image<uint_2>; | 
|---|
|  | 178 | template class NTupInt_Image<int_2>; | 
|---|
|  | 179 | template class NTupInt_Image<int_4>; | 
|---|
|  | 180 | template class NTupInt_Image<r_4>; | 
|---|
|  | 181 | #endif | 
|---|
|  | 182 |  | 
|---|
|  | 183 |  | 
|---|