Changeset 1507 in Sophya for trunk/SophyaExt/FitsIOServer
- Timestamp:
- May 22, 2001, 12:22:18 PM (24 years ago)
- Location:
- trunk/SophyaExt/FitsIOServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaExt/FitsIOServer/fbtntintf.cc
r1505 r1507 7 7 8 8 ////////////////////////////////////////////////////////////// 9 FitsBTNtuIntf::FitsBTNtuIntf(string fname,int ihdu ,uint_4 blen,uint_2 lp)10 { 11 BuffLen = (blen==0) ? 100 : blen; 9 FitsBTNtuIntf::FitsBTNtuIntf(string fname,int ihdu 10 ,int_4 blen,int_4 bsens,uint_2 lp) 11 { 12 12 DbgLevel = lp; 13 13 SetNulVal(); 14 SetBuffer(blen,bsens); 14 15 FitsFN = fname; 15 16 IHdu = ihdu; … … 17 18 } 18 19 19 FitsBTNtuIntf::FitsBTNtuIntf(char * cfname,int ihdu ,uint_4 blen,uint_2 lp)20 { 21 BuffLen = (blen==0) ? 100 : blen; 20 FitsBTNtuIntf::FitsBTNtuIntf(char * cfname,int ihdu 21 ,int_4 blen,int_4 bsens,uint_2 lp) 22 { 22 23 DbgLevel = lp; 23 24 SetNulVal(); 25 SetBuffer(blen,bsens); 24 26 FitsFN = cfname; 25 27 IHdu = ihdu; … … 29 31 FitsBTNtuIntf::FitsBTNtuIntf(FitsBTNtuIntf& fbtnt) 30 32 { 31 BuffLen = fbtnt.BuffLen;32 33 DbgLevel = fbtnt.DbgLevel; 33 NulVal = fbtnt.NulVal; 34 SetNulVal(fbtnt.NulVal); 35 SetBuffer(fbtnt.BuffLen,fbtnt.BuffSens); 34 36 FitsFN = fbtnt.FitsFN; 35 37 IHdu = fbtnt.IHdu; … … 39 41 FitsBTNtuIntf::FitsBTNtuIntf() 40 42 { 41 BuffLen = 100;42 43 DbgLevel = 0; 43 44 SetNulVal(); 45 SetBuffer(); 44 46 FitsFN = ""; 45 47 IHdu = -1; … … 52 54 } 53 55 56 54 57 ////////////////////////////////////////////////////////////// 58 void FitsBTNtuIntf::ChangeBuffer(int_4 blen,int_4 bsens) 59 { 60 SetBuffer(blen,bsens); 61 DeAllocBuff(); 62 AllocBuff(); 63 } 64 65 void FitsBTNtuIntf::AllocBuff(void) 66 { 67 if(Buffer==NULL || NBcol<=0) return; 68 int_4 n = BuffLen; if(BuffSens==0) n++; 69 for(int icol=0;icol<NBcol;icol++) 70 if(ColReadable[icol]) Buffer[icol] = new double[n]; 71 else Buffer[icol] = NULL; 72 } 73 74 void FitsBTNtuIntf::DeAllocBuff(void) 75 { 76 if(Buffer==NULL || NBcol<=0) return; 77 for(int icol=0;icol<NBcol;icol++) 78 if(Buffer[icol]!=NULL) 79 {delete [] Buffer[icol]; Buffer[icol] = NULL;} 80 LineDeb = LineFin = -1; 81 } 82 83 void FitsBTNtuIntf::Delete() 84 { 85 DeAllocBuff(); 86 delete [] Buffer; Buffer=NULL; 87 if(mRet!=NULL) delete [] mRet; 88 if(ColReadable!=NULL) delete [] ColReadable; 89 90 int sta = 0; 91 if(fits_close_file(FitsPtr,&sta)) printerror(sta); 92 FitsPtr = NULL; 93 } 94 55 95 void FitsBTNtuIntf::Init() 56 96 { … … 134 174 <<" typecode="<<typecode<<" (readable=" 135 175 <<ColReadable[icol]<<")"<<endl; 136 // Prepare buffer 137 if(ColReadable[icol]) Buffer[icol] = new double[BuffLen]; 138 } 139 140 } 141 142 void FitsBTNtuIntf::Delete() 143 { 144 if(Buffer!=NULL) { 145 for(int i=0;i<NBcol;i++) 146 if(Buffer[i]!=NULL) delete [] Buffer[i]; 147 delete [] Buffer; 148 } 149 if(mRet!=NULL) delete [] mRet; 150 if(ColReadable!=NULL) delete [] ColReadable; 151 152 int sta = 0; 153 if(fits_close_file(FitsPtr,&sta)) printerror(sta); 154 FitsPtr = NULL; 176 } 177 // Prepare buffer 178 AllocBuff(); 179 155 180 } 156 181 … … 185 210 186 211 // Gestion avec bufferisation 212 if(!Buffer) { 213 cout<<"FitsBTNtuIntf::GetLineD Buffer not allocated"<<endl; 214 return NULL; 215 } 187 216 if(n<LineDeb || n>LineFin) { 188 217 NFitsRead++; 189 long row1 = n+1; 190 long row2 = row1+BuffLen-1; if(row2>NBline) row2 = NBline; 191 long nrow = row2 - row1 + 1; 192 LineDeb = n; LineFin = row2-1; 218 long row1,row2,nrow; 219 if(BuffSens>0) { // Cas remplissage forward 220 row1 = n+1; 221 row2 = row1+BuffLen-1; if(row2>NBline) row2 = NBline; 222 } else if(BuffSens<0) { // Cas remplissage forward 223 row2 = n+1; 224 row1 = row2-BuffLen+1; if(row1<1) row1 = 1; 225 } else { // Cas remplissage centre 226 row1 = n+1 - BuffLen/2; if(row1<1) row1 = 1; 227 row2 = n+1 + BuffLen/2; if(row2>NBline) row2 = NBline; 228 } 229 nrow = row2 - row1 + 1; 230 LineDeb = row1-1; LineFin = row2-1; 231 //cout<<"DBG-FitsRead: row1="<<row1<<" row2="<<row2<<" nrow="<<nrow 232 // <<" LineDeb,Fin="<<LineDeb<<","<<LineFin<<endl; 193 233 for(int icol=0;icol<NBcol;icol++) { 194 234 if(!ColReadable[icol]) continue; … … 198 238 } 199 239 240 int_4 ibuf = n-LineDeb; 200 241 for(int icol=0;icol<NBcol;icol++) 201 if(ColReadable[icol]) mRet[icol] = (Buffer[icol])[ n-LineDeb];242 if(ColReadable[icol]) mRet[icol] = (Buffer[icol])[ibuf]; 202 243 else mRet[icol] = 0.; 203 244 -
trunk/SophyaExt/FitsIOServer/fbtntintf.h
r1505 r1507 18 18 class FitsBTNtuIntf : public AnyDataObj, public NTupleInterface { 19 19 public: 20 FitsBTNtuIntf(string fname,int ihdu=0, uint_4 blen=100,uint_2 lp=0);21 FitsBTNtuIntf(char *cfname,int ihdu=0, uint_4 blen=100,uint_2 lp=0);22 FitsBTNtuIntf(FitsBTNtuIntf& fbtnt); 20 FitsBTNtuIntf(string fname,int ihdu=0,int_4 blen=100,int_4 bsens=1,uint_2 lp=0); 21 FitsBTNtuIntf(char *cfname,int ihdu=0,int_4 blen=100,int_4 bsens=1,uint_2 lp=0); 22 FitsBTNtuIntf(FitsBTNtuIntf& fbtnt); 23 23 FitsBTNtuIntf(); 24 24 virtual ~FitsBTNtuIntf(); 25 25 26 26 void SetNulVal(r_8 nulval=0.) {NulVal = nulval;} 27 void ChangeBuffer(int_4 blen,int_4 bsens=1); 27 28 virtual void Print(ostream& os,int lp=1) const; 28 29 inline void Print(int lp=1) const {Print(cout,lp);} … … 35 36 36 37 protected: 38 inline void SetBuffer(int_4 blen=100,int_4 bsens=1) 39 {BuffLen = (blen<=0)?1:blen; BuffSens = bsens;} 40 void DeAllocBuff(void); 41 void AllocBuff(void); 37 42 void Init(void); 38 43 void Delete(void); … … 46 51 int NBcol; 47 52 r_8 NulVal; 48 uint_4 BuffLen;53 int_4 BuffLen, BuffSens; 49 54 mutable uint_4 NFitsRead; 50 55 mutable long LineDeb, LineFin;
Note:
See TracChangeset
for help on using the changeset viewer.