Krita Source Code Documentation
Loading...
Searching...
No Matches
KarbonSimplifyPath.cpp File Reference
#include "KarbonSimplifyPath.h"
#include <KoCurveFit.h>
#include <KoPathShape.h>
#include <KoPathPoint.h>
#include <QDebug>

Go to the source code of this file.

Namespaces

namespace  KarbonSimplifyPath
 

Functions

bool KarbonSimplifyPath::isSufficientlyFlat (QPointF curve[4])
 
void karbonSimplifyPath (KoPathShape *path, qreal error)
 
void KarbonSimplifyPath::mergeSubpaths (QList< KoSubpath * > subpaths, KoPathShape *path)
 
void KarbonSimplifyPath::removeDuplicates (KoPathShape *path)
 
void KarbonSimplifyPath::simplifySubpath (KoSubpath *subpath, qreal error)
 
void KarbonSimplifyPath::simplifySubpaths (QList< KoSubpath * > *subpaths, qreal error)
 
QList< KoSubpath * > KarbonSimplifyPath::split (const KoPathShape &path)
 
void KarbonSimplifyPath::subdivide (KoSubpath *subpath)
 
KoSubpath KarbonSimplifyPath::subdivideAux (KoPathPoint *p1, KoPathPoint *p2)
 

Variables

const int KarbonSimplifyPath::MAX_RECURSIVE_DEPTH = 1024
 
int KarbonSimplifyPath::recursiveDepth
 
const qreal KarbonSimplifyPath::SUBDIVISION_COEFF = 100
 

Function Documentation

◆ karbonSimplifyPath()

void karbonSimplifyPath ( KoPathShape * path,
qreal error )

Definition at line 58 of file KarbonSimplifyPath.cpp.

59{
60 if (path->pointCount() == 0) {
61 return;
62 }
63
64 removeDuplicates(path);
65
66 bool isClosed = path->isClosedSubpath(0);
67 if (isClosed) {
68 // insert a copy of the first point at the end
69 KoPathPoint *firstPoint = path->pointByIndex(KoPathPointIndex(0, 0));
70 KoPathPointIndex end(0, path->pointCount());
71 path->insertPoint(new KoPathPoint(*firstPoint), end);
72 }
73
74 QList<KoSubpath *> subpaths = split(*path);
75 Q_FOREACH (KoSubpath *subpath, subpaths) {
76 subdivide(subpath);
77 }
78
79 simplifySubpaths(&subpaths, error);
80 mergeSubpaths(subpaths, path);
81
82 while (! subpaths.isEmpty()) {
83 KoSubpath *subpath = subpaths.takeLast();
84 qDeleteAll(*subpath);
85 delete subpath;
86 }
87
88 if (isClosed) {
89 path->closeMerge();
90 }
91}
QPair< int, int > KoPathPointIndex
Definition KoPathShape.h:28
A KoPathPoint represents a point in a path.
QList< KoSubpath * > split(const KoPathShape &path)
void simplifySubpaths(QList< KoSubpath * > *subpaths, qreal error)
void subdivide(KoSubpath *subpath)
void mergeSubpaths(QList< KoSubpath * > subpaths, KoPathShape *path)
void removeDuplicates(KoPathShape *path)

References KarbonSimplifyPath::mergeSubpaths(), KarbonSimplifyPath::removeDuplicates(), KarbonSimplifyPath::simplifySubpaths(), KarbonSimplifyPath::split(), and KarbonSimplifyPath::subdivide().