KiCad PCB EDA Suite
trace.h File Reference
#include "potracelib.h"
#include "progress.h"
#include "curve.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 1489 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().

1490 {
1491  path_t* p;
1492  double nn = 0, cn = 0;
1493 
1494  if( progress->callback )
1495  {
1496  /* precompute task size for progress estimates */
1497  nn = 0;
1498  list_forall( p, plist ) {
1499  nn += p->priv->len;
1500  }
1501  cn = 0;
1502  }
1503 
1504  /* call downstream function with each path */
1505  list_forall( p, plist ) {
1506  TRY( calc_sums( p->priv ) );
1507  TRY( calc_lon( p->priv ) );
1508  TRY( bestpolygon( p->priv ) );
1509  TRY( adjust_vertices( p->priv ) );
1510 
1511  if( p->sign == '-' ) /* reverse orientation of negative paths */
1512  {
1513  reverse( &p->priv->curve );
1514  }
1515 
1516  smooth( &p->priv->curve, param->alphamax );
1517 
1518  if( param->opticurve )
1519  {
1520  TRY( opticurve( p->priv, param->opttolerance ) );
1521  p->priv->fcurve = &p->priv->ocurve;
1522  }
1523  else
1524  {
1525  p->priv->fcurve = &p->priv->curve;
1526  }
1527 
1528  privcurve_to_curve( p->priv->fcurve, &p->curve );
1529 
1530  if( progress->callback )
1531  {
1532  cn += p->priv->len;
1533  progress_update( cn / nn, progress );
1534  }
1535  }
1536 
1537  progress_update( 1.0, progress );
1538 
1539  return 0;
1540 
1541 try_error:
1542  return 1;
1543 }
static int calc_lon(privpath_t *pp)
Definition: trace.cpp:386
#define TRY(x)
Definition: trace.cpp:1485
static int bestpolygon(privpath_t *pp)
Definition: trace.cpp:628
double alphamax
Definition: potracelib.h:42
privcurve_t curve
Definition: curve.h:62
static int calc_sums(privpath_t *pp)
Definition: trace.cpp:324
privcurve_t ocurve
Definition: curve.h:63
static void smooth(privcurve_t *curve, double alphamax)
Definition: trace.cpp:1036
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:1310
void privcurve_to_curve(privcurve_t *pc, potrace_curve_t *c)
Definition: curve.cpp:122
#define list_forall(elt, list)
Definition: lists.h:42
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:1020
void(* callback)(double progress, void *privdata)
Definition: progress.h:17
static int adjust_vertices(privpath_t *pp)
Definition: trace.cpp:769
potrace_curve_t curve
Definition: potracelib.h:96