~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/trace/potrace/curve.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2001-2007 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. */
 
48
struct potrace_privpath_s {
 
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
};
 
64
typedef struct potrace_privpath_s potrace_privpath_t;
 
65
 
 
66
/* shorter names */
 
67
typedef potrace_privpath_t privpath_t;
 
68
typedef potrace_path_t path_t;
 
69
 
 
70
path_t *path_new(void);
 
71
void path_free(path_t *p);
 
72
void pathlist_free(path_t *plist);
 
73
int privcurve_init(privcurve_t *curve, int n);
 
74
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c);
 
75
 
 
76
#endif /* CURVE_H */
 
77