KiCad PCB EDA Suite
trace.h File Reference
#include "curve.h"
#include "potracelib.h"
#include "progress.h"

Go to the source code of this file.

Functions

int process_path (path_t *plist, const potrace_param_t *param, progress_t *progress)
 

Function Documentation

int process_path ( path_t plist,
const potrace_param_t param,
progress_t progress 
)

Definition at line 1499 of file trace.cpp.

References adjust_vertices(), potrace_param_s::alphamax, bestpolygon(), calc_lon(), calc_sums(), progress_s::callback, potrace_privpath_s::curve, potrace_path_s::curve, potrace_privpath_s::fcurve, potrace_privpath_s::len, list_forall, potrace_privpath_s::ocurve, potrace_param_s::opticurve, opticurve(), potrace_param_s::opttolerance, potrace_path_s::priv, privcurve_to_curve(), progress_update(), reverse(), potrace_path_s::sign, smooth(), and TRY.

Referenced by potrace_trace().

1500 {
1501  path_t* p;
1502  double nn = 0, cn = 0;
1503 
1504  if( progress->callback )
1505  {
1506  /* precompute task size for progress estimates */
1507  nn = 0;
1508  list_forall( p, plist ) {
1509  nn += p->priv->len;
1510  }
1511  cn = 0;
1512  }
1513 
1514  /* call downstream function with each path */
1515  list_forall( p, plist ) {
1516  TRY( calc_sums( p->priv ) );
1517  TRY( calc_lon( p->priv ) );
1518  TRY( bestpolygon( p->priv ) );
1519  TRY( adjust_vertices( p->priv ) );
1520 
1521  if( p->sign == '-' )
1522  {
1523  /* reverse orientation of negative paths */
1524  reverse( &p->priv->curve );
1525  }
1526 
1527  smooth( &p->priv->curve, param->alphamax );
1528 
1529  if( param->opticurve )
1530  {
1531  TRY( opticurve( p->priv, param->opttolerance ) );
1532  p->priv->fcurve = &p->priv->ocurve;
1533  }
1534  else
1535  {
1536  p->priv->fcurve = &p->priv->curve;
1537  }
1538 
1539  privcurve_to_curve( p->priv->fcurve, &p->curve );
1540 
1541  if( progress->callback )
1542  {
1543  cn += p->priv->len;
1544  progress_update( cn / nn, progress );
1545  }
1546  }
1547 
1548  progress_update( 1.0, progress );
1549 
1550  return 0;
1551 
1552 try_error:
1553  return 1;
1554 }
static int calc_lon(privpath_t *pp)
Definition: trace.cpp:389
#define TRY(x)
Definition: trace.cpp:1494
static int bestpolygon(privpath_t *pp)
Definition: trace.cpp:631
double alphamax
Definition: potracelib.h:42
privcurve_t curve
Definition: curve.h:62
static int calc_sums(privpath_t *pp)
Definition: trace.cpp:327
privcurve_t ocurve
Definition: curve.h:63
static void smooth(privcurve_t *curve, double alphamax)
Definition: trace.cpp:1041
struct potrace_privpath_s * priv
Definition: potracelib.h:103
privcurve_t * fcurve
Definition: curve.h:64
static int opticurve(privpath_t *pp, double opttolerance)
Definition: trace.cpp:1322
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c)
Definition: curve.cpp:122
#define list_forall(elt, list)
Definition: lists.h:44
double opttolerance
Definition: potracelib.h:44
static void progress_update(double d, progress_t *prog)
Definition: progress.h:29
static void reverse(privcurve_t *curve)
Definition: trace.cpp:1025
static int adjust_vertices(privpath_t *pp)
Definition: trace.cpp:772
potrace_curve_t curve
Definition: potracelib.h:96
void(* callback)(double progress, void *privdata)
Definition: progress.h:17