curve.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001-2007 Peter Selinger.
00002    This file is part of Potrace. It is free software and it is covered
00003    by the GNU General Public License. See the file COPYING for details. */
00004 
00005 #ifndef CURVE_H
00006 #define CURVE_H
00007 
00008 #include "auxiliary.h"
00009 
00010 /* vertex is c[1] for tag=POTRACE_CORNER, and the intersection of
00011    .c[-1][2]..c[0] and c[1]..c[2] for tag=POTRACE_CURVETO. alpha is only
00012    defined for tag=POTRACE_CURVETO and is the alpha parameter of the curve:
00013    .c[-1][2]..c[0] = alpha*(.c[-1][2]..vertex), and
00014    c[2]..c[1] = alpha*(c[2]..vertex).
00015    Beta is so that (.beta[i])[.vertex[i],.vertex[i+1]] = .c[i][2].
00016 */
00017 
00018 struct privcurve_s {
00019   int n;            /* number of segments */
00020   int *tag;         /* tag[n]: POTRACE_CORNER or POTRACE_CURVETO */
00021   dpoint_t (*c)[3]; /* c[n][i]: control points. 
00022                        c[n][0] is unused for tag[n]=POTRACE_CORNER */
00023   /* the remainder of this structure is special to privcurve, and is
00024      used in EPS debug output and special EPS "short coding". These
00025      fields are valid only if "alphacurve" is set. */
00026   int alphacurve;   /* have the following fields been initialized? */
00027   dpoint_t *vertex; /* for POTRACE_CORNER, this equals c[1] */
00028   double *alpha;    /* only for POTRACE_CURVETO */
00029   double *alpha0;   /* "uncropped" alpha parameter - for debug output only */
00030   double *beta;
00031 };
00032 typedef struct privcurve_s privcurve_t;
00033 
00034 struct sums_s {
00035   double x;
00036   double y;
00037   double x2;
00038   double xy;
00039   double y2;
00040 };
00041 typedef struct sums_s sums_t;
00042 
00043 /* the path structure is filled in with information about a given path
00044    as it is accumulated and passed through the different stages of the
00045    Potrace algorithm. Backends only need to read the fcurve and fm
00046    fields of this data structure, but debugging backends may read
00047    other fields. */
00048 struct potrace_privpath_s {
00049   int len;
00050   point_t *pt;     /* pt[len]: path as extracted from bitmap */
00051   int *lon;        /* lon[len]: (i,lon[i]) = longest straight line from i */
00052 
00053   int x0, y0;      /* origin for sums */
00054   sums_t *sums;    /* sums[len+1]: cache for fast summing */
00055 
00056   int m;           /* length of optimal polygon */
00057   int *po;         /* po[m]: optimal polygon */
00058 
00059   privcurve_t curve;   /* curve[m]: array of curve elements */
00060   privcurve_t ocurve;  /* ocurve[om]: array of curve elements */
00061   privcurve_t *fcurve;  /* final curve: this points to either curve or
00062                        ocurve. Do not free this separately. */
00063 };
00064 typedef struct potrace_privpath_s potrace_privpath_t;
00065 
00066 /* shorter names */
00067 typedef potrace_privpath_t privpath_t;
00068 typedef potrace_path_t path_t;
00069 
00070 path_t *path_new(void);
00071 void path_free(path_t *p);
00072 void pathlist_free(path_t *plist);
00073 int privcurve_init(privcurve_t *curve, int n);
00074 void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c);
00075 
00076 #endif /* CURVE_H */
00077 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


portrait_painter
Author(s): Niklas Meinzer, Ina Baumgarten
autogenerated on Wed Dec 26 2012 16:00:43