KiCad PCB EDA Suite
potracelib.h File Reference

Go to the source code of this file.

Classes

struct  potrace_progress_s
 
struct  potrace_param_s
 
struct  potrace_bitmap_s
 
struct  potrace_dpoint_s
 
struct  potrace_curve_s
 
struct  potrace_path_s
 
struct  potrace_state_s
 

Macros

#define POTRACE_TURNPOLICY_BLACK   0
 
#define POTRACE_TURNPOLICY_WHITE   1
 
#define POTRACE_TURNPOLICY_LEFT   2
 
#define POTRACE_TURNPOLICY_RIGHT   3
 
#define POTRACE_TURNPOLICY_MINORITY   4
 
#define POTRACE_TURNPOLICY_MAJORITY   5
 
#define POTRACE_TURNPOLICY_RANDOM   6
 
#define POTRACE_CURVETO   1
 
#define POTRACE_CORNER   2
 
#define POTRACE_STATUS_OK   0
 
#define POTRACE_STATUS_INCOMPLETE   1
 

Typedefs

typedef struct potrace_progress_s potrace_progress_t
 
typedef struct potrace_param_s potrace_param_t
 
typedef unsigned long potrace_word
 
typedef struct potrace_bitmap_s potrace_bitmap_t
 
typedef struct potrace_dpoint_s potrace_dpoint_t
 
typedef struct potrace_curve_s potrace_curve_t
 
typedef struct potrace_path_s potrace_path_t
 
typedef struct potrace_state_s potrace_state_t
 

Functions

potrace_param_tpotrace_param_default (void)
 
void potrace_param_free (potrace_param_t *p)
 
potrace_state_tpotrace_trace (const potrace_param_t *param, const potrace_bitmap_t *bm)
 
void potrace_state_free (potrace_state_t *st)
 
const char * potrace_version (void)
 

Macro Definition Documentation

#define POTRACE_CORNER   2

Definition at line 79 of file potracelib.h.

Referenced by smooth().

#define POTRACE_CURVETO   1

Definition at line 78 of file potracelib.h.

Referenced by opticurve(), and smooth().

#define POTRACE_STATUS_INCOMPLETE   1

Definition at line 111 of file potracelib.h.

Referenced by potrace_trace().

#define POTRACE_STATUS_OK   0

Definition at line 110 of file potracelib.h.

Referenced by potrace_trace().

#define POTRACE_TURNPOLICY_BLACK   0

Definition at line 19 of file potracelib.h.

Referenced by findpath().

#define POTRACE_TURNPOLICY_LEFT   2

Definition at line 21 of file potracelib.h.

#define POTRACE_TURNPOLICY_MAJORITY   5

Definition at line 24 of file potracelib.h.

Referenced by findpath().

#define POTRACE_TURNPOLICY_MINORITY   4

Definition at line 23 of file potracelib.h.

Referenced by findpath().

#define POTRACE_TURNPOLICY_RANDOM   6

Definition at line 25 of file potracelib.h.

Referenced by findpath().

#define POTRACE_TURNPOLICY_RIGHT   3

Definition at line 22 of file potracelib.h.

Referenced by findpath().

#define POTRACE_TURNPOLICY_WHITE   1

Definition at line 20 of file potracelib.h.

Referenced by findpath().

Typedef Documentation

Definition at line 65 of file potracelib.h.

Definition at line 89 of file potracelib.h.

Definition at line 75 of file potracelib.h.

Definition at line 47 of file potracelib.h.

Definition at line 105 of file potracelib.h.

Definition at line 35 of file potracelib.h.

Definition at line 120 of file potracelib.h.

typedef unsigned long potrace_word

Definition at line 53 of file potracelib.h.

Function Documentation

potrace_param_t* potrace_param_default ( void  )

Definition at line 37 of file potracelib.cpp.

38 {
39  potrace_param_t* p;
40 
41  p = (potrace_param_t*) malloc( sizeof(potrace_param_t) );
42 
43  if( !p )
44  {
45  return NULL;
46  }
47 
48  memcpy( p, &param_default, sizeof(potrace_param_t) );
49  return p;
50 }
static const potrace_param_t param_default
Definition: potracelib.cpp:20
void potrace_param_free ( potrace_param_t p)

Definition at line 125 of file potracelib.cpp.

126 {
127  free( p );
128 }
void potrace_state_free ( potrace_state_t st)

Definition at line 117 of file potracelib.cpp.

References pathlist_free(), and potrace_state_s::plist.

118 {
119  pathlist_free( st->plist );
120  free( st );
121 }
void pathlist_free(path_t *plist)
Definition: curve.cpp:81
potrace_path_t * plist
Definition: potracelib.h:116
potrace_state_t* potrace_trace ( const potrace_param_t param,
const potrace_bitmap_t bm 
)

Definition at line 59 of file potracelib.cpp.

References bm_to_pathlist(), progress_s::callback, potrace_progress_s::callback, progress_s::d_prev, progress_s::data, potrace_progress_s::data, progress_s::epsilon, potrace_progress_s::epsilon, progress_s::max, potrace_progress_s::max, progress_s::min, potrace_progress_s::min, potrace_state_s::plist, POTRACE_STATUS_INCOMPLETE, POTRACE_STATUS_OK, potrace_state_s::priv, process_path(), potrace_param_s::progress, progress_subrange_end(), progress_subrange_start(), and potrace_state_s::status.

60 {
61  int r;
62  path_t* plist = NULL;
63  potrace_state_t* st;
64  progress_t prog;
65  progress_t subprog;
66 
67  /* prepare private progress bar state */
68  prog.callback = param->progress.callback;
69  prog.data = param->progress.data;
70  prog.min = param->progress.min;
71  prog.max = param->progress.max;
72  prog.epsilon = param->progress.epsilon;
73  prog.d_prev = param->progress.min;
74 
75  /* allocate state object */
76  st = (potrace_state_t*) malloc( sizeof(potrace_state_t) );
77 
78  if( !st )
79  {
80  return NULL;
81  }
82 
83  progress_subrange_start( 0.0, 0.1, &prog, &subprog );
84 
85  /* process the image */
86  r = bm_to_pathlist( bm, &plist, param, &subprog );
87 
88  if( r )
89  {
90  free( st );
91  return NULL;
92  }
93 
95  st->plist = plist;
96  st->priv = NULL; /* private state currently unused */
97 
98  progress_subrange_end( &prog, &subprog );
99 
100  progress_subrange_start( 0.1, 1.0, &prog, &subprog );
101 
102  /* partial success. */
103  r = process_path( plist, param, &subprog );
104 
105  if( r )
106  {
108  }
109 
110  progress_subrange_end( &prog, &subprog );
111 
112  return st;
113 }
#define POTRACE_STATUS_OK
Definition: potracelib.h:110
static void progress_subrange_start(double a, double b, const progress_t *prog, progress_t *sub)
Definition: progress.h:49
static void progress_subrange_end(progress_t *prog, progress_t *sub)
Definition: progress.h:81
double max
Definition: progress.h:19
int process_path(path_t *plist, const potrace_param_t *param, progress_t *progress)
Definition: trace.cpp:1489
double d_prev
Definition: progress.h:22
int bm_to_pathlist(const potrace_bitmap_t *bm, path_t **plistp, const potrace_param_t *param, progress_t *progress)
Definition: decompose.cpp:555
double min
Definition: progress.h:19
void * data
Definition: progress.h:18
potrace_progress_t progress
Definition: potracelib.h:45
struct potrace_privstate_s * priv
Definition: potracelib.h:118
double epsilon
Definition: progress.h:20
void(* callback)(double progress, void *privdata)
Definition: potracelib.h:30
void(* callback)(double progress, void *privdata)
Definition: progress.h:17
#define POTRACE_STATUS_INCOMPLETE
Definition: potracelib.h:111
potrace_path_t * plist
Definition: potracelib.h:116
const char* potrace_version ( void  )

Definition at line 131 of file potracelib.cpp.

References POTRACELIB_VERSION.

132 {
133  return POTRACELIB_VERSION;
134 }
#define POTRACELIB_VERSION