1 /* spline.h: manipulate the spline representation.
2    Some of macrs are only renamed macros in output.h. */
3 
4 #ifndef SPLINE_H
5 #define SPLINE_H
6 
7 #include <stdio.h>
8 #include "autotrace.h"
9 #include "output.h"
10 
11 typedef at_polynomial_degree polynomial_degree;
12 typedef at_spline_type spline_type;
13 
14 #define LINEARTYPE          AT_LINEARTYPE
15 #define QUADRATICTYPE       AT_QUADRATICTYPE
16 #define CUBICTYPE           AT_CUBICTYPE
17 #define PARALLELELLIPSETYPE AT_PARALLELELLIPSETYPE
18 #define ELLIPSETYPE         AT_ELLIPSETYPE
19 #define CIRCLETYPE          AT_CIRCLETYPE
20 
21 #define START_POINT	    AT_SPLINE_START_POINT_VALUE
22 #define CONTROL1            AT_SPLINE_CONTROL1_VALUE
23 #define CONTROL2            AT_SPLINE_CONTROL2_VALUE
24 #define END_POINT           AT_SPLINE_END_POINT_VALUE
25 #define SPLINE_DEGREE	    AT_SPLINE_DEGREE_VALUE
26 #define SPLINE_LINEARITY(spl)	((spl).linearity)
27 
28 #ifndef _IMPORTING
29 /* Print a spline on the given file.  */
30 extern void print_spline (FILE *, spline_type);
31 
32 /* Evaluate SPLINE at the given T value.  */
33 extern at_real_coord evaluate_spline (spline_type spline, at_real t);
34 #endif
35 
36 /* Each outline in a character is typically represented by many
37    splines.  So, here is a list structure for that:  */
38 typedef at_spline_list_type spline_list_type;
39 
40 
41 /* An empty list will have length zero (and null data).  */
42 #define SPLINE_LIST_LENGTH  AT_SPLINE_LIST_LENGTH_VALUE
43 
44 /* The address of the beginning of the array of data.  */
45 #define SPLINE_LIST_DATA    AT_SPLINE_LIST_DATA_VALUE
46 
47 /* The element INDEX in S_L.  */
48 #define SPLINE_LIST_ELT     AT_SPLINE_LIST_ELT_VALUE
49 
50 /* The last element in S_L.  */
51 #define LAST_SPLINE_LIST_ELT(s_l) \
52   (SPLINE_LIST_DATA (s_l)[SPLINE_LIST_LENGTH (s_l) - 1])
53 
54 /* The previous and next elements to INDEX in S_L.  */
55 #define NEXT_SPLINE_LIST_ELT(s_l, index)				\
56   SPLINE_LIST_ELT (s_l, ((index) + 1) % SPLINE_LIST_LENGTH (s_l))
57 #define PREV_SPLINE_LIST_ELT(s_l, index)				\
58   SPLINE_LIST_ELT (s_l, index == 0					\
59                         ? SPLINE_LIST_LENGTH (s_l) - 1			\
60                         : index - 1)
61 
62 #ifndef _IMPORTING
63 /* Construct and destroy new `spline_list_type' objects.  */
64 extern spline_list_type *new_spline_list (void); /* Allocate new memory */
65 extern spline_list_type empty_spline_list (void); /* No allocation */
66 extern spline_list_type *new_spline_list_with_spline (spline_type);
67 extern void free_spline_list (spline_list_type);
68 
69 /* Append the spline S to the list S_LIST.  */
70 extern void append_spline (spline_list_type *s_list, spline_type s);
71 
72 /* Append the elements in list S2 to S1, changing S1.  */
73 extern void concat_spline_lists (spline_list_type *s1, spline_list_type s2);
74 #endif
75 
76 typedef at_spline_list_array_type spline_list_array_type;
77 
78 /* Turns out we can use the same definitions for lists of lists as for
79    just lists.  But we define the usual names, just in case.  */
80 #define SPLINE_LIST_ARRAY_LENGTH   AT_SPLINE_LIST_ARRAY_LENGTH_VALUE
81 #define SPLINE_LIST_ARRAY_DATA     SPLINE_LIST_DATA
82 #define SPLINE_LIST_ARRAY_ELT      AT_SPLINE_LIST_ARRAY_ELT_VALUE
83 #define LAST_SPLINE_LIST_ARRAY_ELT LAST_SPLINE_LIST_ELT
84 
85 extern spline_list_array_type new_spline_list_array (void);
86 extern void append_spline_list (spline_list_array_type *, spline_list_type);
87 extern void free_spline_list_array (spline_list_array_type *);
88 
89 #endif /* not SPLINE_H */
90 
91