PathCutting.cpp revision ae9bb17bcf65f0e053c0b292a0b53f4a1435eb5c
3887N/A#include "livarot/path-description.h"
3887N/A#include "libnr/n-art-bpath.h"
3639N/A#include "libnr/nr-point-matrix-ops.h"
#include "libnr/nr-convert2geom.h"
void Path::DashPolyline(float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset)
int curP = 0;
lastMI=i;
curP++;
DashSubPath(orig_pts.size() - lastMI, lastMP, orig_pts, head, tail, body, nbD, dashs, stPlain, stOffset);
void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pts, float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset)
double totLength=0;
lastP=n;
double curLength=0;
double dashPos=0;
int dashInd=0;
bool dashPlain=false;
double lastT=0;
double nT=0;
if ( back ) {
dashInd=0;
dashInd++;
dashPos=0;
dashInd=0;
if ( back ) {
double pT=0;
AddPoint(p,true);
bool nPlain=false;
dashInd++;
dashInd=0;
dashPos=0;
if ( back ) {
double pT=0;
AddPoint(p,true);
if ( back ) {
double pT=0;
AddPoint(p,false);
nl=0;
if ( dashPlain ) {
if ( back ) {
AddPoint(n,false);
dashInd=0;
dashPos=0;
bool nPlain=false;
if ( back ) {
double pT=0;
AddPoint(p,false);
lastP=n;
#include "../display/canvas-bpath.h"
switch ( typ ) {
case descr_close:
if ( lastM >= 0 ) {
nb_cmd++;
case descr_lineto:
nb_cmd++;
case descr_moveto:
nb_cmd++;
case descr_arcto:
case descr_cubicto:
nb_cmd++;
case descr_bezierto:
nb_cmd++;
bezNb=0;
nb_cmd++;
bezNb=0;
case descr_interm_bezier:
if ( bezNb > 0 ) {
nb_cmd++;
bezNb--;
return bpath;
else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast<Geom::QuadraticBezier const *>(c)) {
else if(Geom::EllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::EllipticalArc const *>(&c)) {
/** append is false by default: it means that the path should be resetted. If it is true, the path is not resetted and Geom::Path will be appended as a new path
void Path::LoadPath(Geom::Path const &path, Geom::Matrix const &tr, bool doTransformation, bool append)
if (!append) {
SetBackData (false);
Reset();
// TODO: this can be optimized by not generating a new path here, but doing the transform in AddCurve
Close();
void Path::LoadPathVector(Geom::PathVector const &pv, Geom::Matrix const &tr, bool doTransformation)
SetBackData (false);
Reset();
double len = 0;
lastP = i->p;
return len;
double surf = 0;
lastP = i->p;
return surf;
int nbRes=0;
switch ( typ ) {
case descr_moveto:
if ( curAdd ) {
delete curAdd;
delete curAdd;
case descr_close:
case descr_lineto:
case descr_cubicto:
case descr_arcto:
case descr_bezierto:
case descr_interm_bezier:
if ( curAdd ) {
delete curAdd;
delete curAdd;
return res;
int nbRes=0;
bool increment=false;
switch ( typ ) {
case descr_moveto:
delete curAdd;
delete curAdd;
for (int j=0;j<nbNest;j++) {
for (int k=0;k<nbRes;k++) {
if ( conts[j] > i ) break;
if ( hasDad ) {
increment=true;
increment=false;
case descr_close:
case descr_lineto:
case descr_cubicto:
case descr_arcto:
case descr_bezierto:
case descr_interm_bezier:
delete curAdd;
delete curAdd;
return res;
delete descr_cmd[i];
switch ( typ ) {
case descr_forced:
d->p = lastPos;
case descr_close:
d->p = lastPos;
case descr_moveto:
lastPos = d->p;
case descr_lineto:
lastPos = d->p;
case descr_arcto:
lastPos = d->p;
case descr_cubicto:
lastPos = d->p;
case descr_bezierto:
lastPos = d->p;
case descr_interm_bezier:
lastPos = d->p;
bool hasMoved = false;
switch ( typ ) {
case descr_forced:
delete descr_cmd[i];
hasMoved = true;
case descr_moveto:
hasMoved = true;
case descr_close:
case descr_lineto:
case descr_cubicto:
case descr_arcto:
case descr_bezierto:
case descr_interm_bezier:
return NULL;
nbCut = 0;
int curCv = 0;
double len = 0;
double lastT = 0;
lastT = i->t;
nbCut++;
curCv++;
lastP = i->p;
lastT = i->t;
return res;
Moved from Layout-TNG-OutIter.cpp
template<typename T> inline static T square(T x) {return x*x;}
unsigned bestSeg = 0;
double thisRangeSquared;
nearestY = (localPos[NR::X] - (-1.0 / gradient) * localPos[NR::Y] - intersection) / (gradient - (-1.0 / gradient));
nearestY = (localPos[NR::X] * gradient - (-1.0) * localPos[NR::Y] - intersection * gradient) / (gradient * gradient - (-1.0));
thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]);
bestSeg = i;
bestT = t;
if (bestSeg == 0) {
return result;
return length;
if ( nbPos <= 0 ) {
switch ( typ ) {
case descr_forced:
d->p = lastPos;
case descr_close:
delete descr_cmd[i];
fp--;
if ( fp >= 0 ) {
case descr_bezierto:
case descr_moveto:
lastPos = d->p;
case descr_lineto:
lastPos = d->p;
case descr_arcto:
lastPos = d->p;
case descr_cubicto:
lastPos = d->p;
case descr_interm_bezier:
lastPos = d->p;
if ( ct < 0 ) continue;
double delta=0;
if (clockw) {
curP--;
curP--;
bool hasClose=false;
bool doesClose=false;
hasClose=true;
doesClose=true;
delete res;