1 /***************************************************************/
2 /*                   REGION STUFF                              */
3 /***************************************************************/
4 
5 #include "fitsio.h"
6 #define myPI  3.1415926535897932385
7 #define RadToDeg 180.0/myPI
8 
9 typedef struct {
10    int    exists;
11    double xrefval, yrefval;
12    double xrefpix, yrefpix;
13    double xinc,    yinc;
14    double rot;
15    char   type[6];
16 } WCSdata;
17 
18 typedef enum {
19    point_rgn,
20    line_rgn,
21    circle_rgn,
22    annulus_rgn,
23    ellipse_rgn,
24    elliptannulus_rgn,
25    box_rgn,
26    boxannulus_rgn,
27    rectangle_rgn,
28    diamond_rgn,
29    sector_rgn,
30    poly_rgn,
31    panda_rgn,
32    epanda_rgn,
33    bpanda_rgn
34 } shapeType;
35 
36 typedef enum { pixel_fmt, degree_fmt, hhmmss_fmt } coordFmt;
37 
38 typedef struct {
39    char      sign;        /*  Include or exclude?        */
40    shapeType shape;       /*  Shape of this region       */
41    int       comp;        /*  Component number for this region */
42 
43    double xmin,xmax;       /*  bounding box    */
44    double ymin,ymax;
45 
46    union {                /*  Parameters - In pixels     */
47 
48       /****   Generic Shape Data   ****/
49 
50       struct {
51 	 double p[11];       /*  Region parameters       */
52 	 double sinT, cosT;  /*  For rotated shapes      */
53 	 double a, b;        /*  Extra scratch area      */
54       } gen;
55 
56       /****      Polygon Data      ****/
57 
58       struct {
59          int    nPts;        /*  Number of Polygon pts   */
60          double *Pts;        /*  Polygon points          */
61       } poly;
62 
63    } param;
64 
65 } RgnShape;
66 
67 typedef struct {
68    int       nShapes;
69    RgnShape  *Shapes;
70    WCSdata   wcs;
71 } SAORegion;
72 
73 /*  SAO region file routines */
74 int  fits_read_rgnfile( const char *filename, WCSdata *wcs, SAORegion **Rgn, int *status );
75 int  fits_in_region( double X, double Y, SAORegion *Rgn );
76 void fits_free_region( SAORegion *Rgn );
77 void fits_set_region_components ( SAORegion *Rgn );
78 void fits_setup_shape ( RgnShape *shape);
79 int fits_read_fits_region ( fitsfile *fptr, WCSdata * wcs, SAORegion **Rgn, int *status);
80 int fits_read_ascii_region ( const char *filename, WCSdata * wcs, SAORegion **Rgn, int *status);
81 
82 
83