#ifndef mioREGION_H #define mioREGION_H /********************************************************************************* * MPIA - MIDI project * * "@(#) $Id: $" * * who when what * -------- -------- ---------------------------------------------- * mathar 2004-07-10 re-created from VLTI/MIDI's mio CMM module * * NAME * * mioREGION - Definition of detector pixel regions * * SYNOPSIS * * DESCRPIPTION * * FILES * * ENVIRONMENT * * EXAMPLES * * SEE ALSO * * NOTES * * TODO * * BUGS * ********************************************************************************/ #include #include #include #include #include #include #include #include #include using namespace std ; // a single rectangular detector region class mioREGION { private: void init(const int namlen) ; // return true if the pixel(x,y) is in the full detector region bool pixinfull(const short x, const short y) ; public: short reglow[2] ; // lower left corner of the detector region short regspan[2] ; // size of the detector regions float crpix[2] ; // reference pixel char *regname ; // name of the detector region, not \0-terminated int regcorr ; // correlation :1=photometric, 2=interferometric, 0 =background (no signal) etc // Constructor: input string of the form [,]x0l,y0l,x0h,y0h optionally followed by more bytes to be ignored. // On entry, *pixs is the first character of x0l, on exit, it points to the character after the last digit of y0h mioREGION(char *& pixs, int namlen = 16) ; // Constructor: input parameters are the two (x,y) coordinates of the lower left and upper right pixel mioREGION(const short llx, const short lly, const short urx, const short ury, int corr = -1, int namlen = 16) ; // default constructor: full detector frame implied mioREGION(int namlen = 16) ; // assignment operator mioREGION & operator=(const mioREGION & orig) ; // copy constructor mioREGION (const mioREGION & orig) ; // destructor ~mioREGION() ; // zero if window area is a true subwindow of the full frame int check() ; // return true if the pixel(x,y) is in this region bool pixinregion(const short x, const short y) ; // area (square pixels ) of the window int area() ; // exhibit a string of the form (nx,ny) for use as a TDIMn specifier string tdim() ; // returns 0= background, 1=photometric, 2=interferometric for pixel (x,y) // TODO: should be template function for other than 'short' values int correl(const short x, const short y) ; // returns PA, PB, I1, I2, FULL or an empty string for coordinate (x,y) string nam(const short x, const short y) ; // same result special for the region's center pixel string nam() ; // returns 0= background, 1=photometric, 2=interferometric for the center pixel int correl() ; // create a description of this window number 'n' as ageneralized slice (in the ANSI C++ sense) // that embbeds the window in the full frame // ------------------------------------------ // | ------------- (MI_XPIX,MI_XPIY)| // | | | | // | |(reglow) | | // | ------------- | // | | // |(1,1) (MI_XPIX,1)| // ------------------------------------------- // If the consecutive locations of the full window are stored at (1,1),(2,1),...(MI_XPIX,1),(1,2),.....(MI_XPIX,2),... // ^0 , ^1, ^MI_XPIX-1, ^MI_XPIX,..,^(2*MI_XPIX-1),... // generally speaking (x,y) on x-1+(y-1)*MI_XPIX, (reglow[0],reglow[1]) on 'first', // the small stride (to walk within a row of the embedded window) is 1, and the larger stride (to walk along a row) // is MI_XPIX. // Need indexes first+(0,...,regspan[0]-1)*1+(0,1,..,regspan[1]-1)*MI_XPIX, where regspan[0] is running fastest, // therefore strides[0]=MI_XPIX and strides[1]=1 where strides[1] is running faster. operator gslice() ; // create a comma-separated string representation "llx,lly,urx,ury" of the corner coordinates string coords() ; double rowfrac() const ; } ; ostream & operator <<(ostream &os, const mioREGION & some) ; // comparison operator bool operator== (const mioREGION & first, const mioREGION & secnd) ; // a vector of detector regions class mioREGIONS { private: // define the component 'super' which is the 'super-rectangle' that covers all other regions void createSuper() ; public: mioREGION *wins ; mioREGION *super ; // the smallest rectangular region that covers all wins[0..nregin-1] in the set int nregion ; int * Indx ; // region indeces as in the REGION column of the IMAGING_DETECTOR table of VLT-SPE-ESO-15000-2764 // constructor: Convert an input string of the form x0l,y0l,x0h,y0h,x1l,y1l,x1h,y1h,x2l,y2l,x2h,h2h,... mioREGIONS(char *pixs, int namlen = 16) ; // default constructor: zero (no) regions defined mioREGIONS() ; // copy constructor mioREGIONS (const mioREGIONS & orig) ; ~mioREGIONS() ; // Check whether the two regions have common pixels (do overlap); return true if yes. // If the regions are the same (n1==n2) the result is 'true,' as expected. // This works also, and returns 'true', if one region covers the other one entirely. bool dooverlap(int n1, int n2) ; // check whether some of the regions have common pixels (do overlap); return true if yes bool dooverlap() ; // return true if the pixel(x,y) is in region no 'region' bool pixinregion(const short x, const short y, const int n) ; // area (square pixels ) of window no 'n' int area(const int n) ; // combined area (total number of pixels covered) int area() ; // exhibit a string of the form (nx,ny) for use as a TDIMn specifier string tdim(int n) ; // add a region to the list, specified by lower left and upper right coordinates (pixels, inclusive) int add(const short llx, const short lly, const short urx, const short ury, int indx = -1, int corr = -1, int namlen=16) ; // add a region to the list int add(const mioREGION * somereg, int namlen=16) ; // remove a region from the list, indx=0, indx