Debian Codegraph @

converter/other/pamtosvg/spline.h

raw symbols SCIP
1 /* spline.h: manipulate the spline representation. */
2
3 #ifndef SPLINE_H
4 #define SPLINE_H
5
6 #include <stdio.h>
7
8 #include "point.h"
9 #include "autotrace.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 BEG_POINT(spl) ((spl).v[0])
22 #define CONTROL1(spl) ((spl).v[1])
23 #define CONTROL2(spl) ((spl).v[2])
24 #define END_POINT(spl) ((spl).v[3])
25 #define SPLINE_DEGREE(spl) ((spl).degree)
26 #define SPLINE_LINEARITY(spl) ((spl).linearity)
27
28 #ifndef _IMPORTING
29 /* Print a spline on the given file. */
30 void print_spline (FILE *, spline_type);
31
32 /* Evaluate SPLINE at the given T value. */
33 Point evaluate_spline (spline_type spline, float 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(spll) ((spll).length)
43
44 /* The address of the beginning of the array of data. */
45 #define SPLINE_LIST_DATA(spll) ((spll).data)
46
47 /* The element with index 'index' in S_L. */
48 #define SPLINE_LIST_ELT(spll, index) ((spll).data[index])
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(spll) ((spll).length)
81 #define SPLINE_LIST_ARRAY_DATA SPLINE_LIST_DATA
82 #define SPLINE_LIST_ARRAY_ELT(spll, index) ((spll).data[index])
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