KiCad PCB EDA Suite
curve.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2015 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 CURVE_H
6 #define CURVE_H
7 
8 #include "auxiliary.h"
9 
10 /* vertex is c[1] for tag=POTRACE_CORNER, and the intersection of
11  * .c[-1][2]..c[0] and c[1]..c[2] for tag=POTRACE_CURVETO. alpha is only
12  * defined for tag=POTRACE_CURVETO and is the alpha parameter of the curve:
13  * .c[-1][2]..c[0] = alpha*(.c[-1][2]..vertex), and
14  * c[2]..c[1] = alpha*(c[2]..vertex).
15  * Beta is so that (.beta[i])[.vertex[i],.vertex[i+1]] = .c[i][2].
16  */
17 
19 {
20  int n; /* number of segments */
21  int* tag; /* tag[n]: POTRACE_CORNER or POTRACE_CURVETO */
22  dpoint_t( *c )[3]; /* c[n][i]: control points.
23  * c[n][0] is unused for tag[n]=POTRACE_CORNER */
24  /* the remainder of this structure is special to privcurve, and is
25  * used in EPS debug output and special EPS "short coding". These
26  * fields are valid only if "alphacurve" is set. */
27  int alphacurve; /* have the following fields been initialized? */
28  dpoint_t* vertex; /* for POTRACE_CORNER, this equals c[1] */
29  double* alpha; /* only for POTRACE_CURVETO */
30  double* alpha0; /* "uncropped" alpha parameter - for debug output only */
31  double* beta;
32 };
33 typedef struct privcurve_s privcurve_t;
34 
35 struct sums_s
36 {
37  double x;
38  double y;
39  double x2;
40  double xy;
41  double y2;
42 };
43 typedef struct sums_s sums_t;
44 
45 /* the path structure is filled in with information about a given path
46  * as it is accumulated and passed through the different stages of the
47  * Potrace algorithm. Backends only need to read the fcurve and fm
48  * fields of this data structure, but debugging backends may read
49  * other fields. */
51 {
52  int len;
53  point_t* pt; /* pt[len]: path as extracted from bitmap */
54  int* lon; /* lon[len]: (i,lon[i]) = longest straight line from i */
55 
56  int x0, y0; /* origin for sums */
57  sums_t* sums; /* sums[len+1]: cache for fast summing */
58 
59  int m; /* length of optimal polygon */
60  int* po; /* po[m]: optimal polygon */
61 
62  privcurve_t curve; /* curve[m]: array of curve elements */
63  privcurve_t ocurve; /* ocurve[om]: array of curve elements */
64  privcurve_t* fcurve; /* final curve: this points to either curve or
65  * ocurve. Do not free this separately. */
66 };
68 
69 /* shorter names */
72 
73 path_t* path_new( void );
74 void path_free( path_t* p );
75 void pathlist_free( path_t* plist );
76 int privcurve_init( privcurve_t* curve, int n );
78 
79 #endif /* CURVE_H */
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c)
Definition: curve.cpp:122
void path_free(path_t *p)
Definition: curve.cpp:58
double * alpha
Definition: curve.h:29
void pathlist_free(path_t *plist)
Definition: curve.cpp:81
privcurve_t curve
Definition: curve.h:62
potrace_path_t path_t
Definition: curve.h:71
potrace_dpoint_t dpoint_t
Definition: auxiliary.h:29
int alphacurve
Definition: curve.h:27
path_t * path_new(void)
Definition: curve.cpp:26
dpoint_t * vertex
Definition: curve.h:28
int privcurve_init(privcurve_t *curve, int n)
Definition: curve.cpp:98
double y2
Definition: curve.h:41
privcurve_t ocurve
Definition: curve.h:63
potrace_privpath_t privpath_t
Definition: curve.h:70
double x
Definition: curve.h:37
privcurve_t * fcurve
Definition: curve.h:64
double xy
Definition: curve.h:40
double y
Definition: curve.h:38
double * beta
Definition: curve.h:31
point_t * pt
Definition: curve.h:53
sums_t * sums
Definition: curve.h:57
double * alpha0
Definition: curve.h:30
int * tag
Definition: curve.h:21
int n
Definition: curve.h:20
Definition: curve.h:35
double x2
Definition: curve.h:39
dpoint_t(* c)[3]
Definition: curve.h:22