KiCad PCB EDA Suite
potracelib.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2017 Peter Selinger.
2  * This file is part of Potrace. It is free software and it is covered
3  * by the GNU General Public License. See the file COPYING for details. */
4 
5 #ifndef POTRACELIB_H
6 #define POTRACELIB_H
7 
8 /* this file defines the API for the core Potrace library. For a more
9  * detailed description of the API, see potracelib.pdf */
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 /* ---------------------------------------------------------------------- */
16 /* tracing parameters */
17 
18 /* turn policies */
19 #define POTRACE_TURNPOLICY_BLACK 0
20 #define POTRACE_TURNPOLICY_WHITE 1
21 #define POTRACE_TURNPOLICY_LEFT 2
22 #define POTRACE_TURNPOLICY_RIGHT 3
23 #define POTRACE_TURNPOLICY_MINORITY 4
24 #define POTRACE_TURNPOLICY_MAJORITY 5
25 #define POTRACE_TURNPOLICY_RANDOM 6
26 
27 /* structure to hold progress bar callback data */
29 {
30  void ( * callback )( double progress, void* privdata ); /* callback fn */
31  void* data; /* callback function's private data */
32  double min, max; /* desired range of progress, e.g. 0.0 to 1.0 */
33  double epsilon; /* granularity: can skip smaller increments */
34 };
36 
37 /* structure to hold tracing parameters */
39 {
40  int turdsize; /* area of largest path to be ignored */
41  int turnpolicy; /* resolves ambiguous turns in path decomposition */
42  double alphamax; /* corner threshold */
43  int opticurve; /* use curve optimization? */
44  double opttolerance; /* curve optimization tolerance */
45  potrace_progress_t progress; /* progress callback function */
46 };
48 
49 /* ---------------------------------------------------------------------- */
50 /* bitmaps */
51 
52 /* native word size */
53 typedef unsigned long potrace_word;
54 
55 /* Internal bitmap format. The n-th scanline starts at scanline(n) =
56  * (map + n*dy). Raster data is stored as a sequence of potrace_words
57  * (NOT bytes). The leftmost bit of scanline n is the most significant
58  * bit of scanline(n)[0]. */
60 {
61  int w, h; /* width and height, in pixels */
62  int dy; /* words per scanline (not bytes) */
63  potrace_word* map; /* raw data, dy*h words */
64 };
66 
67 /* ---------------------------------------------------------------------- */
68 /* curves */
69 
70 /* point */
72 {
73  double x, y;
74 };
76 
77 /* segment tags */
78 #define POTRACE_CURVETO 1
79 #define POTRACE_CORNER 2
80 
81 /* closed curve segment */
83 {
84  int n; /* number of segments */
85  int* tag; /* tag[n]: POTRACE_CURVETO or POTRACE_CORNER */
86  potrace_dpoint_t( *c )[3]; /* c[n][3]: control points.
87  * c[n][0] is unused for tag[n]=POTRACE_CORNER */
88 };
90 
91 /* Linked list of signed curve segments. Also carries a tree structure. */
93 {
94  int area; /* area of the bitmap path */
95  int sign; /* '+' or '-', depending on orientation */
96  potrace_curve_t curve; /* this path's vector data */
97 
98  struct potrace_path_s* next; /* linked list structure */
99 
100  struct potrace_path_s* childlist; /* tree structure */
101  struct potrace_path_s* sibling; /* tree structure */
102 
103  struct potrace_privpath_s* priv; /* private state */
104 };
106 
107 /* ---------------------------------------------------------------------- */
108 /* Potrace state */
109 
110 #define POTRACE_STATUS_OK 0
111 #define POTRACE_STATUS_INCOMPLETE 1
112 
114 {
115  int status;
116  potrace_path_t* plist; /* vector data */
117 
118  struct potrace_privstate_s* priv; /* private state */
119 };
121 
122 /* ---------------------------------------------------------------------- */
123 /* API functions */
124 
125 /* get default parameters */
127 
128 /* free parameter set */
130 
131 /* trace a bitmap */
133 
134 /* free a Potrace state */
136 
137 /* return a static plain text version string identifying this version
138  * of potracelib */
139 const char* potrace_version( void );
140 
141 #ifdef __cplusplus
142 } /* end of extern "C" */
143 #endif
144 
145 #endif /* POTRACELIB_H */
struct potrace_dpoint_s potrace_dpoint_t
Definition: potracelib.h:75
struct potrace_path_s * childlist
Definition: potracelib.h:100
double alphamax
Definition: potracelib.h:42
void potrace_param_free(potrace_param_t *p)
Definition: potracelib.cpp:124
potrace_state_t * potrace_trace(const potrace_param_t *param, const potrace_bitmap_t *bm)
Definition: potracelib.cpp:58
potrace_word * map
Definition: potracelib.h:63
unsigned long potrace_word
Definition: potracelib.h:53
struct potrace_path_s * next
Definition: potracelib.h:98
struct potrace_privpath_s * priv
Definition: potracelib.h:103
potrace_dpoint_t(* c)[3]
Definition: potracelib.h:86
potrace_progress_t progress
Definition: potracelib.h:45
const char * potrace_version(void)
Definition: potracelib.cpp:131
void(* callback)(double progress, void *privdata)
Definition: potracelib.h:30
struct potrace_privstate_s * priv
Definition: potracelib.h:118
void potrace_state_free(potrace_state_t *st)
Definition: potracelib.cpp:116
double opttolerance
Definition: potracelib.h:44
struct potrace_path_s * sibling
Definition: potracelib.h:101
potrace_param_t * potrace_param_default(void)
Definition: potracelib.cpp:36
potrace_path_t * plist
Definition: potracelib.h:116
potrace_curve_t curve
Definition: potracelib.h:96