75
76
// t=0 means it's at the start of the command's chunk, t=1 it's at the end
78
path_lineto(bool m, NR::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0) {}
79
path_lineto(bool m, NR::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt) {}
79
path_lineto(bool m, Geom::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0), closed(false) {}
80
path_lineto(bool m, Geom::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt), closed(false) {}
86
bool closed; // true if subpath is closed (this point is the last point of a closed subpath)
87
89
std::vector<path_lineto> pts;
98
100
// the commands...
101
int MoveTo ( NR::Point const &ip);
102
int LineTo ( NR::Point const &ip);
103
int CubicTo ( NR::Point const &ip, NR::Point const &iStD, NR::Point const &iEnD);
104
int ArcTo ( NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
105
int IntermBezierTo ( NR::Point const &ip); // add a quadratic bezier spline control point
106
int BezierTo ( NR::Point const &ip); // quadratic bezier spline to this point (control points can be added after this)
103
int MoveTo ( Geom::Point const &ip);
104
int LineTo ( Geom::Point const &ip);
105
int CubicTo ( Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD);
106
int ArcTo ( Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
107
int IntermBezierTo ( Geom::Point const &ip); // add a quadratic bezier spline control point
108
int BezierTo ( Geom::Point const &ip); // quadratic bezier spline to this point (control points can be added after this)
107
109
int TempBezierTo(); // start a quadratic bezier spline (control points can be added after this)
108
110
int EndBezierTo();
109
int EndBezierTo ( NR::Point const &ip); // ends a quadratic bezier spline (for curves started with TempBezierTo)
111
int EndBezierTo ( Geom::Point const &ip); // ends a quadratic bezier spline (for curves started with TempBezierTo)
111
113
// transforms a description in a polyline (for stroking and filling)
112
114
// treshhold is the max length^2 (sort of)
119
121
// creation of the polyline (you can tinker with these function if you want)
120
122
void SetBackData (bool nVal); // has back data?
121
123
void ResetPoints(); // resets to the empty polyline
122
int AddPoint ( NR::Point const &iPt, bool mvto = false); // add point
123
int AddPoint ( NR::Point const &iPt, int ip, double it, bool mvto = false);
124
int AddForcedPoint ( NR::Point const &iPt); // add point
125
int AddForcedPoint ( NR::Point const &iPt, int ip, double it);
126
int ReplacePoint(NR::Point const &iPt); // replace point
124
int AddPoint ( Geom::Point const &iPt, bool mvto = false); // add point
125
int AddPoint ( Geom::Point const &iPt, int ip, double it, bool mvto = false);
126
int AddForcedPoint ( Geom::Point const &iPt); // add point
127
int AddForcedPoint ( Geom::Point const &iPt, int ip, double it);
128
int ReplacePoint(Geom::Point const &iPt); // replace point
128
130
// transform in a polygon (in a graph, in fact; a subsequent call to ConvertToShape is needed)
129
131
// - fills the polyline; justAdd=true doesn't reset the Shape dest, but simply adds the polyline into it
162
164
// piece is a command no in the command list
163
165
// "at" is an abcissis on the path portion associated with this command
164
166
// 0=beginning of portion, 1=end of portion.
165
void PointAt (int piece, double at, NR::Point & pos);
166
void PointAndTangentAt (int piece, double at, NR::Point & pos, NR::Point & tgt);
167
void PointAt (int piece, double at, Geom::Point & pos);
168
void PointAndTangentAt (int piece, double at, Geom::Point & pos, Geom::Point & tgt);
168
170
// last control point before the command i (i included)
169
171
// used when dealing with quadratic bezier spline, cause these can contain arbitrarily many commands
170
const NR::Point PrevPoint (const int i) const;
172
const Geom::Point PrevPoint (const int i) const;
172
174
// dash the polyline
173
175
// the result is stored in the polyline, so you lose the original. make a copy before if needed
176
178
void DashPolylineFromStyle(SPStyle *style, float scale, float min_len);
178
180
//utilitaire pour inkscape
179
void LoadArtBPath(void *iP,NR::Matrix const &tr,bool doTransformation);
180
void* MakeArtBPath();
182
void Transform(const NR::Matrix &trans);
181
void LoadPath(Geom::Path const &path, Geom::Matrix const &tr, bool doTransformation, bool append = false);
182
void LoadPathVector(Geom::PathVector const &pv, Geom::Matrix const &tr, bool doTransformation);
183
void LoadPathVector(Geom::PathVector const &pv);
184
Geom::PathVector* MakePathVector();
186
void Transform(const Geom::Matrix &trans);
184
188
// decompose le chemin en ses sous-chemin
185
189
// killNoSurf=true -> oublie les chemins de surface nulle
186
190
Path** SubPaths(int &outNb,bool killNoSurf);
220
224
// utilitary functions for the path contruction
221
225
void CancelBezier ();
222
226
void CloseSubpath();
223
void InsertMoveTo (NR::Point const &iPt,int at);
227
void InsertMoveTo (Geom::Point const &iPt,int at);
224
228
void InsertForcePoint (int at);
225
void InsertLineTo (NR::Point const &iPt,int at);
226
void InsertArcTo (NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
227
void InsertCubicTo (NR::Point const &ip, NR::Point const &iStD, NR::Point const &iEnD,int at);
228
void InsertBezierTo (NR::Point const &iPt,int iNb,int at);
229
void InsertIntermBezierTo (NR::Point const &iPt,int at);
229
void InsertLineTo (Geom::Point const &iPt,int at);
230
void InsertArcTo (Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
231
void InsertCubicTo (Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD,int at);
232
void InsertBezierTo (Geom::Point const &iPt,int iNb,int at);
233
void InsertIntermBezierTo (Geom::Point const &iPt,int at);
231
235
// creation of dashes: take the polyline given by spP (length spL) and dash it according to head, body, etc. put the result in
232
236
// the polyline of this instance
235
239
// Functions used by the conversion.
236
240
// they append points to the polyline
237
void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
241
void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
238
242
double angle, bool large, bool wise, double tresh);
239
void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
243
void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
240
244
double maxL = -1.0);
241
void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, NR::Point const &iE, double treshhold, int lev, double maxL = -1.0);
245
void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, Geom::Point const &iE, double treshhold, int lev, double maxL = -1.0);
243
void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
247
void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
244
248
double angle, bool large, bool wise, double tresh, int piece);
245
void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
249
void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
246
250
double st, double et, int piece);
247
void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, const NR::Point &iE, double treshhold, int lev, double st, double et,
251
void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, const Geom::Point &iE, double treshhold, int lev, double st, double et,
250
254
// don't pay attention
258
void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
262
void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
259
263
double angle, bool large, bool wise, double tresh, int piece,
260
264
offset_orig & orig);
261
void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
265
void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
262
266
double st, double et, int piece, offset_orig & orig);
263
void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, NR::Point const &iE, double treshhold, int lev, double st, double et,
267
void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, Geom::Point const &iE, double treshhold, int lev, double st, double et,
264
268
int piece, offset_orig & orig);
266
static void ArcAngles ( NR::Point const &iS, NR::Point const &iE, double rx,
270
static void ArcAngles ( Geom::Point const &iS, Geom::Point const &iE, double rx,
267
271
double ry, double angle, bool large, bool wise,
268
272
double &sang, double &eang);
269
static void QuadraticPoint (double t, NR::Point &oPt, NR::Point const &iS, NR::Point const &iM, NR::Point const &iE);
270
static void CubicTangent (double t, NR::Point &oPt, NR::Point const &iS,
271
NR::Point const &iSd, NR::Point const &iE,
272
NR::Point const &iEd);
273
static void QuadraticPoint (double t, Geom::Point &oPt, Geom::Point const &iS, Geom::Point const &iM, Geom::Point const &iE);
274
static void CubicTangent (double t, Geom::Point &oPt, Geom::Point const &iS,
275
Geom::Point const &iSd, Geom::Point const &iE,
276
Geom::Point const &iEd);
274
278
struct outline_callback_data
313
317
Path * dest, outline_callbacks & calls,
314
318
double tolerance, double width, JoinType join,
315
319
ButtType butt, double miter, bool closeIfNeeded,
316
bool skipMoveto, NR::Point & lastP, NR::Point & lastT);
320
bool skipMoveto, Geom::Point & lastP, Geom::Point & lastT);
317
321
void DoStroke(int off, int N, Shape *dest, bool doClose, double width, JoinType join,
318
322
ButtType butt, double miter, bool justAdd = false);
320
static void TangentOnSegAt(double at, NR::Point const &iS, PathDescrLineTo const &fin,
321
NR::Point &pos, NR::Point &tgt, double &len);
322
static void TangentOnArcAt(double at, NR::Point const &iS, PathDescrArcTo const &fin,
323
NR::Point &pos, NR::Point &tgt, double &len, double &rad);
324
static void TangentOnCubAt (double at, NR::Point const &iS, PathDescrCubicTo const &fin, bool before,
325
NR::Point &pos, NR::Point &tgt, double &len, double &rad);
326
static void TangentOnBezAt (double at, NR::Point const &iS,
324
static void TangentOnSegAt(double at, Geom::Point const &iS, PathDescrLineTo const &fin,
325
Geom::Point &pos, Geom::Point &tgt, double &len);
326
static void TangentOnArcAt(double at, Geom::Point const &iS, PathDescrArcTo const &fin,
327
Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
328
static void TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const &fin, bool before,
329
Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
330
static void TangentOnBezAt (double at, Geom::Point const &iS,
327
331
PathDescrIntermBezierTo & mid,
328
332
PathDescrBezierTo & fin, bool before,
329
NR::Point & pos, NR::Point & tgt, double &len, double &rad);
330
static void OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor,
333
Geom::Point & pos, Geom::Point & tgt, double &len, double &rad);
334
static void OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor,
331
335
double width, JoinType join, double miter);
333
static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, NR::Point const &curX);
337
static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX);
335
339
static void RecStdCubicTo (outline_callback_data * data, double tol,
336
340
double width, int lev);
346
350
// fonctions annexes pour le stroke
347
static void DoButt (Shape * dest, double width, ButtType butt, NR::Point pos,
348
NR::Point dir, int &leftNo, int &rightNo);
349
static void DoJoin (Shape * dest, double width, JoinType join, NR::Point pos,
350
NR::Point prev, NR::Point next, double miter, double prevL,
351
static void DoButt (Shape * dest, double width, ButtType butt, Geom::Point pos,
352
Geom::Point dir, int &leftNo, int &rightNo);
353
static void DoJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
354
Geom::Point prev, Geom::Point next, double miter, double prevL,
351
355
double nextL, int *stNo, int *enNo);
352
static void DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos,
353
NR::Point prev, NR::Point next, double miter, double prevL,
356
static void DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
357
Geom::Point prev, Geom::Point next, double miter, double prevL,
354
358
double nextL, int &leftStNo, int &leftEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
355
static void DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos,
356
NR::Point prev, NR::Point next, double miter, double prevL,
359
static void DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
360
Geom::Point prev, Geom::Point next, double miter, double prevL,
357
361
double nextL, int &rightStNo, int &rightEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
358
362
static void RecRound (Shape * dest, int sNo, int eNo,
359
NR::Point const &iS, NR::Point const &iE,
360
NR::Point const &nS, NR::Point const &nE,
361
NR::Point &origine,float width);
363
Geom::Point const &iS, Geom::Point const &iE,
364
Geom::Point const &nS, Geom::Point const &nE,
365
Geom::Point &origine,float width);
364
368
void DoSimplify(int off, int N, double treshhold);
365
369
bool AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &res, int &worstP);
366
static bool FitCubic(NR::Point const &start,
370
static bool FitCubic(Geom::Point const &start,
367
371
PathDescrCubicTo &res,
368
372
double *Xk, double *Yk, double *Qk, double *tk, int nbPt);
380
384
bool AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
381
385
bool ExtendFit(int off, int N, fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
382
double RaffineTk (NR::Point pt, NR::Point p0, NR::Point p1, NR::Point p2, NR::Point p3, double it);
386
double RaffineTk (Geom::Point pt, Geom::Point p0, Geom::Point p1, Geom::Point p2, Geom::Point p3, double it);
383
387
void FlushPendingAddition(Path* dest,PathDescr *lastAddition,PathDescrCubicTo &lastCubic,int lastAD);
390
void AddCurve(Geom::Curve const &c);