KiCad PCB EDA Suite
potracelib.cpp File Reference
#include <stdlib.h>
#include <string.h>
#include "curve.h"
#include "decompose.h"
#include "potracelib.h"
#include "progress.h"
#include "trace.h"
#include "potrace_version.h"

Go to the source code of this file.

Functions

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

Variables

static const potrace_param_t param_default
 

Function Documentation

potrace_param_t* potrace_param_default ( void  )

Definition at line 36 of file potracelib.cpp.

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

Definition at line 124 of file potracelib.cpp.

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

Definition at line 116 of file potracelib.cpp.

References pathlist_free(), and potrace_state_s::plist.

117 {
118  pathlist_free( st->plist );
119  free( st );
120 }
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 58 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.

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

Variable Documentation

const potrace_param_t param_default
static
Initial value:
=
{
2,
1.0,
1,
0.2,
{
NULL,
NULL,
0.0, 1.0,
0.0,
},
}
#define POTRACE_TURNPOLICY_MINORITY
Definition: potracelib.h:23

Definition at line 19 of file potracelib.cpp.