1 #if !defined( SLAMAP_INCLUDED )  /* Include this file only once */
2 #define SLAMAP_INCLUDED
3 /*
4 *+
5 *  Name:
6 *     slamap.h
7 
8 *  Type:
9 *     C include file.
10 
11 *  Purpose:
12 *     Define the interface to the SlaMap class.
13 
14 *  Invocation:
15 *     #include "slamap.h"
16 
17 *  Description:
18 *     This include file defines the interface to the SlaMap class and
19 *     provides the type definitions, function prototypes and macros,
20 *     etc.  needed to use this class.
21 *
22 *     The SlaMap class encapsulates the conversions provided by the
23 *     SLALIB library (SUN/67) for converting between different sky
24 *     coordinate systems.  Since, typically, a sequence of these
25 *     SLALIB conversions is required, an SlaMap can be used to
26 *     accumulate a series of conversions which it then applies in
27 *     sequence.
28 
29 *  Inheritance:
30 *     The SlaMap class inherits from the Mapping class.
31 
32 *  Attributes Over-Ridden:
33 *     None.
34 
35 *  New Attributes Defined:
36 *     None.
37 
38 *  Methods Over-Ridden:
39 *     Public:
40 *        astTransform
41 *           Use an SlaMap to transform a set of points.
42 
43 *     Protected:
44 *        astMapMerge
45 *           Simplify a sequence of Mappings containing an SlaMap.
46 
47 *  New Methods Defined:
48 *     Public:
49 *        astSlaAdd
50 *           Add a coordinate conversion step to an SlaMap.
51 
52 *     Private:
53 *        None.
54 
55 *  Other Class Functions:
56 *     Public:
57 *        astIsASlaMap
58 *           Test class membership.
59 *        astSlaMap
60 *           Create an SlaMap.
61 
62 *     Protected:
63 *        astCheckSlaMap
64 *           Validate class membership.
65 *        astInitSlaMap
66 *           Initialise an SlaMap.
67 *        astLoadSlaMap
68 *           Load an SlaMap.
69 
70 *  Macros:
71 *     None.
72 
73 *  Type Definitions:
74 *     Public:
75 *        AstSlaMap
76 *           SlaMap object type.
77 
78 *     Protected:
79 *        AstSlaMapVtab
80 *           SlaMap virtual function table type.
81 
82 *  Feature Test Macros:
83 *     astCLASS
84 *        If the astCLASS macro is undefined, only public symbols are
85 *        made available, otherwise protected symbols (for use in other
86 *        class implementations) are defined. This macro also affects
87 *        the reporting of error context information, which is only
88 *        provided for external calls to the AST library.
89 
90 *  Copyright:
91 *     Copyright (C) 1997-2006 Council for the Central Laboratory of the
92 *     Research Councils
93 
94 *  Licence:
95 *     This program is free software: you can redistribute it and/or
96 *     modify it under the terms of the GNU Lesser General Public
97 *     License as published by the Free Software Foundation, either
98 *     version 3 of the License, or (at your option) any later
99 *     version.
100 *
101 *     This program is distributed in the hope that it will be useful,
102 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
103 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
104 *     GNU Lesser General Public License for more details.
105 *
106 *     You should have received a copy of the GNU Lesser General
107 *     License along with this program.  If not, see
108 *     <http://www.gnu.org/licenses/>.
109 
110 *  Authors:
111 *     RFWS: R.F. Warren-Smith (Starlink)
112 *     DSB: David S. Berry (Starlink)
113 
114 *  History:
115 *     26-APR-1996 (RFWS):
116 *        Original version.
117 *     26-SEP-1996 (RFWS):
118 *        Added external interface and I/O facilities.
119 *     23-MAY-1997 (RFWS):
120 *        Over-ride the astMapMerge method.
121 *     15-OCT-2002 (DSB):
122 *        Added astSTPConv, astSTPConv1, and STP coordinate system macros.
123 *     8-JAN-2003 (DSB):
124 *        Added protected astInitSlaMapVtab method.
125 *     22-FEB-2006 (DSB):
126 *        Added cvtextra to the AstSlaMap structure.
127 *-
128 */
129 
130 /* Include files. */
131 /* ============== */
132 /* Interface definitions. */
133 /* ---------------------- */
134 #include "mapping.h"             /* Coordinate mappings (parent class) */
135 
136 #if defined(astCLASS)            /* Protected */
137 #include "pointset.h"            /* Sets of points/coordinates */
138 #include "channel.h"             /* I/O channels */
139 #endif
140 
141 /* C header files. */
142 /* --------------- */
143 #if defined(astCLASS)            /* Protected */
144 #include <stddef.h>
145 #endif
146 
147 
148 /* Macros */
149 /* ====== */
150 #if defined(astCLASS)            /* Protected */
151 #define AST__NOSTP -1 /* An invalid value for an STP coordinate system */
152 #define AST__HAE  0   /* Heliocentric-aries-ecliptic spherical coordinates */
153 #define AST__HAEC 1   /* Heliocentric-aries-ecliptic cartesian coordinates */
154 #define AST__HAQ  2   /* Heliocentric-aries-equatorial spherical coordinates */
155 #define AST__HAQC 3   /* Heliocentric-aries-equatorial cartesian coordinates */
156 #define AST__HG	  4   /* Heliographic spherical coordinates */
157 #define AST__HGC  5   /* Heliographic cartesian coordinates */
158 #define AST__HPC  6   /* Helioprojective-cartesian spherical coordinates */
159 #define AST__HPCC 7   /* Helioprojective-cartesian cartesian coordinates */
160 #define AST__HPR  8   /* Helioprojective-radial spherical coordinates */
161 #define AST__HPRC 9   /* Helioprojective-radial cartesian coordinates */
162 #define AST__GSE  10  /* Geocentric-solar-ecliptic spherical coordinates */
163 #define AST__GSEC 11  /* Geocentric-solar-ecliptic cartesian coordinates */
164 #endif
165 
166 /* One IAU astronomical unit, in metres. */
167 #define AST__AU 1.49597870E11
168 
169 /* One solar radius (top of photosphere?), in metres (from "The Explanatory
170    Supplement to the Astronomical Almanac"). */
171 #define AST__SOLRAD 6.96E8
172 
173 /* Define a dummy __attribute__ macro for use on non-GNU compilers. */
174 #ifndef __GNUC__
175 #  define  __attribute__(x)  /*NOTHING*/
176 #endif
177 
178 /* SlaMap structure. */
179 /* ----------------- */
180 /* This structure contains all information that is unique to each
181    object in the class (e.g. its instance variables). */
182 typedef struct AstSlaMap {
183 
184 /* Attributes inherited from the parent class. */
185    AstMapping mapping;           /* Parent class structure */
186 
187 /* Attributes specific to objects in this class. */
188    int *cvttype;                 /* Pointer to array of conversion types */
189    double **cvtargs;             /* Pointer to argument list pointer array */
190    double **cvtextra;            /* Pointer to intermediate values pointer array */
191    int ncvt;                     /* Number of conversions to perform */
192 } AstSlaMap;
193 
194 /* Virtual function table. */
195 /* ----------------------- */
196 /* This table contains all information that is the same for all
197    objects in the class (e.g. pointers to its virtual functions). */
198 #if defined(astCLASS)            /* Protected */
199 typedef struct AstSlaMapVtab {
200 
201 /* Properties (e.g. methods) inherited from the parent class. */
202    AstMappingVtab mapping_vtab;  /* Parent class virtual function table */
203 
204 /* A Unique identifier to determine class membership. */
205    AstClassIdentifier id;
206 
207 /* Properties (e.g. methods) specific to this class. */
208    void (* SlaAdd)( AstSlaMap *, const char *, const double[], int * );
209 } AstSlaMapVtab;
210 
211 #if defined(THREAD_SAFE)
212 
213 /* Define a structure holding all data items that are global within this
214    class. */
215 typedef struct AstSlaMapGlobals {
216    AstSlaMapVtab Class_Vtab;
217    int Class_Init;
218    double Eq_Cache;
219    double Ep_Cache;
220    double Amprms_Cache[ 21 ];
221 } AstSlaMapGlobals;
222 
223 #endif
224 
225 #endif
226 
227 /* Function prototypes. */
228 /* ==================== */
229 /* Prototypes for standard class functions. */
230 /* ---------------------------------------- */
231 astPROTO_CHECK(SlaMap)           /* Check class membership */
232 astPROTO_ISA(SlaMap)             /* Test class membership */
233 
234 /* Constructor. */
235 #if defined(astCLASS)            /* Protected. */
236 AstSlaMap *astSlaMap_( int, const char *, int *, ...);
237 #else
238 AstSlaMap *astSlaMapId_( int, const char *, ... )__attribute__((format(printf,2,3)));
239 #endif
240 
241 #if defined(astCLASS)            /* Protected */
242 
243 /* Initialiser. */
244 AstSlaMap *astInitSlaMap_( void *, size_t, int, AstSlaMapVtab *,
245                            const char *, int, int * );
246 
247 /* Vtab initialiser. */
248 void astInitSlaMapVtab_( AstSlaMapVtab *, const char *, int * );
249 
250 /* Loader. */
251 AstSlaMap *astLoadSlaMap_( void *, size_t, AstSlaMapVtab *,
252                            const char *, AstChannel *, int * );
253 
254 /* Thread-safe initialiser for all global data used by this module. */
255 #if defined(THREAD_SAFE)
256 void astInitSlaMapGlobals_( AstSlaMapGlobals * );
257 #endif
258 
259 /* Other functions. */
260 void astSTPConv1_( double, int, double[3], double[3], int, double[3], double[3], int * );
261 void astSTPConv_( double, int, int, double[3], double *[3], int, double[3], double *[3], int * );
262 
263 #endif
264 
265 /* Prototypes for member functions. */
266 /* -------------------------------- */
267 void astSlaAdd_( AstSlaMap *, const char *, const double[], int * );
268 
269 /* Function interfaces. */
270 /* ==================== */
271 /* These macros are wrap-ups for the functions defined by this class
272    to make them easier to invoke (e.g. to avoid type mis-matches when
273    passing pointers to objects from derived classes). */
274 
275 /* Interfaces to standard class functions. */
276 /* --------------------------------------- */
277 /* Some of these functions provide validation, so we cannot use them
278    to validate their own arguments. We must use a cast when passing
279    object pointers (so that they can accept objects from derived
280    classes). */
281 
282 /* Check class membership. */
283 #define astCheckSlaMap(this) astINVOKE_CHECK(SlaMap,this,0)
284 #define astVerifySlaMap(this) astINVOKE_CHECK(SlaMap,this,1)
285 
286 /* Test class membership. */
287 #define astIsASlaMap(this) astINVOKE_ISA(SlaMap,this)
288 
289 /* Constructor. */
290 #if defined(astCLASS)            /* Protected. */
291 #define astSlaMap astINVOKE(F,astSlaMap_)
292 #else
293 #define astSlaMap astINVOKE(F,astSlaMapId_)
294 #endif
295 
296 #if defined(astCLASS)            /* Protected */
297 
298 /* Initialiser. */
299 #define astInitSlaMap(mem,size,init,vtab,name,flags) \
300 astINVOKE(O,astInitSlaMap_(mem,size,init,vtab,name,flags,STATUS_PTR))
301 
302 /* Vtab Initialiser. */
303 #define astInitSlaMapVtab(vtab,name) astINVOKE(V,astInitSlaMapVtab_(vtab,name,STATUS_PTR))
304 /* Loader. */
305 #define astLoadSlaMap(mem,size,vtab,name,channel) \
306 astINVOKE(O,astLoadSlaMap_(mem,size,vtab,name,astCheckChannel(channel),STATUS_PTR))
307 #endif
308 
309 /* Interfaces to public member functions. */
310 /* -------------------------------------- */
311 /* Here we make use of astCheckSlaMap to validate SlaMap pointers
312    before use.  This provides a contextual error report if a pointer
313    to the wrong sort of Object is supplied. */
314 #define astSlaAdd(this,cvt,args) \
315 astINVOKE(V,astSlaAdd_(astCheckSlaMap(this),cvt,args,STATUS_PTR))
316 
317 #if defined(astCLASS)            /* Protected */
318 #define astSTPConv astSTPConv_
319 #define astSTPConv1 astSTPConv1_
320 #endif
321 
322 #endif
323 
324 
325 
326 
327 
328