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