1 #if !defined( CIRCLE_INCLUDED ) /* Include this file only once */
2 #define CIRCLE_INCLUDED
3 /*
4 *+
5 *  Name:
6 *     circle.h
7 
8 *  Type:
9 *     C include file.
10 
11 *  Purpose:
12 *     Define the interface to the Circle class.
13 
14 *  Invocation:
15 *     #include "circle.h"
16 
17 *  Description:
18 *     This include file defines the interface to the Circle class and
19 *     provides the type definitions, function prototypes and macros,
20 *     etc.  needed to use this class.
21 *
22 *     The Circle class implement a Region which represents a simple interval
23 *     on each axis of the encapsulated Frame
24 
25 *  Inheritance:
26 *     The Circle class inherits from the Region class.
27 
28 *  Feature Test Macros:
29 *     astCLASS
30 *        If the astCLASS macro is undefined, only public symbols are
31 *        made available, otherwise protected symbols (for use in other
32 *        class implementations) are defined. This macro also affects
33 *        the reporting of error context information, which is only
34 *        provided for external calls to the AST library.
35 
36 *  Copyright:
37 *     Copyright (C) 1997-2006 Council for the Central Laboratory of the
38 *     Research Councils
39 
40 *  Licence:
41 *     This program is free software: you can redistribute it and/or
42 *     modify it under the terms of the GNU Lesser General Public
43 *     License as published by the Free Software Foundation, either
44 *     version 3 of the License, or (at your option) any later
45 *     version.
46 *
47 *     This program is distributed in the hope that it will be useful,
48 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
49 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
50 *     GNU Lesser General Public License for more details.
51 *
52 *     You should have received a copy of the GNU Lesser General
53 *     License along with this program.  If not, see
54 *     <http://www.gnu.org/licenses/>.
55 
56 *  Authors:
57 *     DSB: David S. Berry (Starlink)
58 
59 *  History:
60 *     31-AUG-2004 (DSB):
61 *        Original version.
62 *-
63 */
64 
65 /* Include files. */
66 /* ============== */
67 /* Interface definitions. */
68 /* ---------------------- */
69 #include "region.h"              /* Coordinate regions (parent class) */
70 
71 #if defined(astCLASS)            /* Protected */
72 #include "channel.h"             /* I/O channels */
73 #endif
74 
75 /* C header files. */
76 /* --------------- */
77 #if defined(astCLASS)            /* Protected */
78 #include <stddef.h>
79 #endif
80 
81 /* Macros */
82 /* ====== */
83 
84 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */
85 #ifndef __GNUC__
86 #  define  __attribute__(x)  /*NOTHING*/
87 #endif
88 
89 /* Type Definitions. */
90 /* ================= */
91 /* Circle structure. */
92 /* ------------------ */
93 /* This structure contains all information that is unique to each object in
94    the class (e.g. its instance variables). */
95 typedef struct AstCircle {
96 
97 /* Attributes inherited from the parent class. */
98    AstRegion region;             /* Parent class structure */
99 
100 /* Attributes specific to objects in this class. */
101    double *centre;               /* Circle centre coords */
102    double radius;                /* Circle radius */
103    double *lb;                   /* Lower limits of mesh bounding box */
104    double *ub;                   /* Upper limit of mesh bounding box */
105    int stale;                    /* Is Cached information stale? */
106 
107 } AstCircle;
108 
109 /* Virtual function table. */
110 /* ----------------------- */
111 /* This table contains all information that is the same for all
112    objects in the class (e.g. pointers to its virtual functions). */
113 #if defined(astCLASS)            /* Protected */
114 typedef struct AstCircleVtab {
115 
116 /* Properties (e.g. methods) inherited from the parent class. */
117    AstRegionVtab region_vtab;    /* Parent class virtual function table */
118 
119 /* A Unique identifier to determine class membership. */
120    AstClassIdentifier id;
121 
122 /* Properties (e.g. methods) specific to this class. */
123    void (* CirclePars)( AstCircle *, double *, double *, double *, int * );
124 } AstCircleVtab;
125 
126 #if defined(THREAD_SAFE)
127 
128 /* Define a structure holding all data items that are global within the
129    object.c file. */
130 
131 typedef struct AstCircleGlobals {
132    AstCircleVtab Class_Vtab;
133    int Class_Init;
134 } AstCircleGlobals;
135 
136 
137 /* Thread-safe initialiser for all global data used by this module. */
138 void astInitCircleGlobals_( AstCircleGlobals * );
139 
140 #endif
141 
142 
143 #endif
144 
145 /* Function prototypes. */
146 /* ==================== */
147 /* Prototypes for standard class functions. */
148 /* ---------------------------------------- */
149 astPROTO_CHECK(Circle)          /* Check class membership */
150 astPROTO_ISA(Circle)            /* Test class membership */
151 
152 /* Constructor. */
153 #if defined(astCLASS)            /* Protected. */
154 AstCircle *astCircle_( void *, int, const double[], const double[], AstRegion *, const char *, int *, ...);
155 #else
156 AstCircle *astCircleId_( void *, int, const double[], const double[],
157                          AstRegion *, const char *, ... )__attribute__((format(printf,6,7)));
158 #endif
159 
160 #if defined(astCLASS)            /* Protected */
161 
162 /* Initialiser. */
163 AstCircle *astInitCircle_( void *, size_t, int, AstCircleVtab *,
164                            const char *, AstFrame *, int, const double[],
165                            const double[], AstRegion *, int * );
166 
167 /* Vtab initialiser. */
168 void astInitCircleVtab_( AstCircleVtab *, const char *, int * );
169 
170 /* Loader. */
171 AstCircle *astLoadCircle_( void *, size_t, AstCircleVtab *,
172                            const char *, AstChannel *, int * );
173 
174 #endif
175 
176 /* Prototypes for member functions. */
177 /* -------------------------------- */
178 void astCirclePars_( AstCircle *, double *, double *, double *, int * );
179 
180 # if defined(astCLASS)           /* Protected */
181 AstRegion *astBestCircle_( AstPointSet *, double *, AstRegion *, int * );
182 #endif
183 
184 /* Function interfaces. */
185 /* ==================== */
186 /* These macros are wrap-ups for the functions defined by this class
187    to make them easier to invoke (e.g. to avoid type mis-matches when
188    passing pointers to objects from derived classes). */
189 
190 /* Interfaces to standard class functions. */
191 /* --------------------------------------- */
192 /* Some of these functions provide validation, so we cannot use them
193    to validate their own arguments. We must use a cast when passing
194    object pointers (so that they can accept objects from derived
195    classes). */
196 
197 /* Check class membership. */
198 #define astCheckCircle(this) astINVOKE_CHECK(Circle,this,0)
199 #define astVerifyCircle(this) astINVOKE_CHECK(Circle,this,1)
200 
201 /* Test class membership. */
202 #define astIsACircle(this) astINVOKE_ISA(Circle,this)
203 
204 /* Constructor. */
205 #if defined(astCLASS)            /* Protected. */
206 #define astCircle astINVOKE(F,astCircle_)
207 #else
208 #define astCircle astINVOKE(F,astCircleId_)
209 #endif
210 
211 #if defined(astCLASS)            /* Protected */
212 
213 /* Initialiser. */
214 #define astInitCircle(mem,size,init,vtab,name,frame,form,p1,p2,unc) \
215 astINVOKE(O,astInitCircle_(mem,size,init,vtab,name,frame,form,p1,p2,unc,STATUS_PTR))
216 
217 /* Vtab Initialiser. */
218 #define astInitCircleVtab(vtab,name) astINVOKE(V,astInitCircleVtab_(vtab,name,STATUS_PTR))
219 /* Loader. */
220 #define astLoadCircle(mem,size,vtab,name,channel) \
221 astINVOKE(O,astLoadCircle_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))
222 #endif
223 
224 /* Interfaces to public member functions. */
225 /* -------------------------------------- */
226 /* Here we make use of astCheckCircle to validate Circle pointers
227    before use.  This provides a contextual error report if a pointer
228    to the wrong sort of Object is supplied. */
229 
230 #define astCirclePars(this,centre,radius,p1) \
231 astINVOKE(V,astCirclePars_(astCheckCircle(this),centre,radius,p1,STATUS_PTR))
232 
233 #if defined(astCLASS)            /* Protected */
234 #define astBestCircle(pset,cen,unc) astBestCircle_(pset,cen,unc,STATUS_PTR)
235 #endif
236 #endif
237 
238 
239 
240 
241 
242