/*
9 * Copyright (C) 2018 Authors
10 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
28#define MiscNormalize(v) {\
29 double _l=sqrt(dot(v,v)); \
30 if ( _l < 0.0000001 ) { \
102 while (bestB >= 0 &&
getEdge(bestB).st != fi)
103 bestB =
NextAt (fi, bestB);
117 int curBord = startBord;
119 swdData[curBord].precParc = -1;
120 swdData[curBord].suivParc = -1;
137 if (nb < 0 || nb == curBord)
143 if (nb < 0 || nb == curBord)
151 curBord =
swdData[curBord].precParc;
168 swdData[nb].precParc = curBord;
169 swdData[curBord].suivParc = nb;
248 while (bestB >= 0 &&
getEdge(bestB).st != fi)
249 bestB =
NextAt (fi, bestB);
261 int curBord = startBord;
263 swdData[curBord].precParc = -1;
264 swdData[curBord].suivParc = -1;
281 if (nb < 0 || nb == curBord)
286 if (nb < 0 || nb == curBord)
290 if (curBord == startBord || curBord < 0)
297 swdData[curBord].suivParc = -1;
304 curBord =
swdData[curBord].precParc;
317 if (
getEdge(curBord).en == curStartPt ) {
319 swdData[curBord].suivParc = -1;
326 swdData[nb].precParc = curBord;
327 swdData[curBord].suivParc = nb;
387 int parentContour=-1;
391 bool foundChild =
false;
404 int askTo =
pData[fi].askForWindingB;
409 parentContour =
swdData[askTo].misc;
420 while (bestB >= 0 &&
getEdge(bestB).st != fi)
421 bestB =
NextAt (fi, bestB);
431 swdData[startBord].misc = 1 + nbNest;
432 if (startBord == childEdge) {
436 int curBord = startBord;
438 swdData[curBord].precParc = -1;
439 swdData[curBord].suivParc = -1;
456 if (nb < 0 || nb == curBord)
461 if (nb < 0 || nb == curBord)
465 if (curBord == startBord || curBord < 0)
481 nesting=(
int*)g_realloc(nesting,(nbNest+1)*
sizeof(int));
482 contStart=(
int*)g_realloc(contStart,(nbNest+1)*
sizeof(int));
483 contStart[nbNest]=dest->
descr_cmd.size();
485 nesting[nbNest++]=parentContour;
488 nesting[nbNest++]=-1;
490 swdData[curBord].suivParc = -1;
497 curBord =
swdData[curBord].precParc;
510 if (
getEdge(curBord).en == curStartPt ) {
522 nesting=(
int*)g_realloc(nesting,(nbNest+1)*
sizeof(int));
523 contStart=(
int*)g_realloc(contStart,(nbNest+1)*
sizeof(int));
524 contStart[nbNest]=dest->
descr_cmd.size();
526 nesting[nbNest++]=parentContour;
529 nesting[nbNest++]=-1;
531 swdData[curBord].suivParc = -1;
538 swdData[nb].precParc = curBord;
539 swdData[curBord].suivParc = nb;
541 if (nb == childEdge) {
565 bool done_something =
false;
607 int stB = -1, enB = -1;
620 double stL = sqrt (
dot(stD,stD));
621 double seL = sqrt (
dot(seD,seD));
635 if (do_profile && i2doc) {
641 x = (
Geom::L2(ptP * (*i2doc) -
c)/radius);
652 this_power = power * (0.5 * cos (M_PI * (pow(x, alpha))) + 0.5);
663 done_something =
true;
665 double scaler = 1 / (*i2doc).descrim();
670 tovec[4] = tovec[5] = 0;
672 this_vec = this_power * (vector * tovec) ;
674 this_vec = this_power * scaler * to_center_normalized;
676 double angle = g_random_double_range(0, 2*M_PI);
677 this_vec = g_random_double_range(0, 1) * this_power * scaler *
Geom::Point(sin(angle), cos(angle));
686 usePathID=a->
ebData[i].pathID;
687 usePieceID=a->
ebData[i].pieceID;
690 usePathID=a->
ebData[i].pathID;
697 Path::DoLeftJoin (
this, 0, join, ptP+this_vec, stD+this_vec, seD+this_vec, miter, stL, seL,
698 stNo, enNo,usePathID,usePieceID,useT);
703 Path::DoRightJoin (
this, this_power * scaler, join, ptP, stD, seD, miter, stL, seL,
704 stNo, enNo,usePathID,usePieceID,useT);
708 Path::DoLeftJoin (
this, -this_power * scaler, join, ptP, stD, seD, miter, stL, seL,
709 stNo, enNo,usePathID,usePieceID,useT);
753 bool done_something =
false;
796 int stB = -1, enB = -1;
812 double stL = sqrt (
dot(stD,stD));
813 double seL = sqrt (
dot(seD,seD));
824 if (do_profile && i2doc) {
832 this_dec = dec * (0.5 * cos (M_PI * (pow(x, alpha))) + 0.5);
839 done_something =
true;
847 usePathID=a->
ebData[i].pathID;
848 usePieceID=a->
ebData[i].pieceID;
851 usePathID=a->
ebData[i].pathID;
858 Path::DoRightJoin (
this, this_dec, join, ptP, stD, seD, miter, stL, seL,
859 stNo, enNo,usePathID,usePieceID,useT);
865 Path::DoLeftJoin (
this, -this_dec, join, ptP, stD, seD, miter, stL, seL,
866 stNo, enNo,usePathID,usePieceID,useT);
902 int edge = start_edge;
909 int nPiece =
ebData[edge].pieceID;
910 int nPath =
ebData[edge].pathID;
913 if (nPath < 0 || nPath >= num_orig || !
orig[nPath]) {
920 auto from =
orig[nPath];
923 if (nPiece < 0 || nPiece >= from->descr_cmd.size()) {
930 switch (from->descr_cmd[nPiece]->getType()) {
964 std::swap(prevEdge, nextEdge);
967 if (std::abs(
ebData[prevEdge].tEn -
ebData[nextEdge].tSt) < 0.05) {
986 int nPiece =
ebData[bord].pieceID;
987 int nPath =
ebData[bord].pathID;
988 double te =
ebData[bord].tEn;
997 if (
ebData[bord].pieceID == nPiece &&
ebData[bord].pathID == nPath)
999 if (fabs (te -
ebData[bord].tSt) > 0.0001)
1008 bord =
swdData[bord].suivParc;
1018 int nPiece =
ebData[bord].pieceID;
1019 int nPath =
ebData[bord].pathID;
1022 bord =
swdData[bord].suivParc;
1029 if (
ebData[bord].pieceID == nPiece &&
ebData[bord].pathID == nPath)
1031 if (fabs (te -
ebData[bord].tSt) > 0.0001)
1042 bord =
swdData[bord].suivParc;
1047 bool nLarge = nData->
large;
1049 Path::ArcAngles (from->
PrevPoint (nPiece - 1), nData->
p,nData->
rx,nData->
ry,nData->
angle*M_PI/180.0, nLarge, nClockwise, sang, eang);
1060 double delta = eang - sang;
1061 double ndelta =
delta * (te - ts);
1063 nClockwise = !nClockwise;
1071 dest->
ArcTo (nx, nData->
rx,nData->
ry,nData->
angle, nLarge, nClockwise);
1078 int nPiece =
ebData[bord].pieceID;
1079 int nPath =
ebData[bord].pathID;
1082 bord =
swdData[bord].suivParc;
1089 if (
ebData[bord].pieceID == nPiece &&
ebData[bord].pathID == nPath)
1091 if (fabs (te -
ebData[bord].tSt) > 0.0001)
1102 bord =
swdData[bord].suivParc;
1109 Path::CubicTangent (ts, sDx, prevx,nData->
start,nData->
p,nData->
end);
1110 Path::CubicTangent (te, eDx, prevx,nData->
start,nData->
p,nData->
end);
Cartesian point / 2D vector and related operations.
TODO: insert short description here.
TODO: insert short description here.
3x3 affine transformation matrix.
3x3 matrix representing an affine transformation.
Affine inverse() const
Compute the inverse matrix.
Two-dimensional point that doubles as a vector.
Path and its polyline approximation.
int LineTo(Geom::Point const &ip)
Appends a LineTo path command.
int Close()
Appends a close path command.
int ArcTo(Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise)
Appends an ArcTo path command.
int MoveTo(Geom::Point const &ip)
Appends a MoveTo path command.
const Geom::Point PrevPoint(const int i) const
int CubicTo(Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD)
Appends a CubicBezier path command.
std::vector< PathDescr * > descr_cmd
int ForcePoint()
Appends a forced point path command.
void Reset()
Clears all stored path commands and resets flags that are used by command functions while adding path...
A class to store/manipulate directed graphs.
bool _has_edges_data
the eData array is allocated
void MakeSweepDestData(bool nVal)
Initialize the sweep destination data cache.
void AddContour(Path *dest, int num_orig, Path *const *orig, int start_edge, bool never_split=false)
Add a contour.
std::vector< sweep_src_data > swsData
void ConvertToForme(Path *dest)
Extract contours from a directed graph.
void MakeBackData(bool nVal)
bool _point_data_initialised
the pData array is up to date
void MakeSweepSrcData(bool nVal)
Initialize the sweep source data cache.
int AddEdge(int st, int en)
int CyclePrevAt(int p, int b) const
bool _has_sweep_src_data
the swsData array is allocated
std::vector< raster_data > swrData
bool _bbox_up_to_date
the leftX/rightX/topY/bottomY are up to date
int CycleNextAt(int p, int b) const
std::vector< back_data > ebData
void MakePointData(bool nVal)
Initialize the point data cache.
int ReFormeLineTo(int bord, Path *dest, bool never_split)
void ConvertToFormeNested(Path *dest, int nbP, Path *const *orig, int &nbNest, int *&nesting, int *&contStart, bool never_split=false)
int numberOfEdges() const
Returns number of edges.
static double Round(double x)
std::vector< edge_data > eData
int NextAt(int p, int b) const
int numberOfPoints() const
Returns number of points.
bool _has_points_data
the pData array is allocated
dg_arete const & getEdge(int n) const
Get an edge.
void SortEdges()
Sort all edges (clockwise) around each point.
int MakeTweak(int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Affine *i2doc)
void Reset(int n=0, int m=0)
Clear all data.
std::vector< dg_point > _pts
int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx=0, double cy=0, double radius=0, Geom::Affine *i2doc=nullptr)
bool _has_raster_data
the swrData array is allocated
int ReFormeArcTo(int bord, Path *dest, Path *orig, bool never_split)
std::vector< dg_arete > _aretes
void MakeEdgeData(bool nVal)
Initialize the edge data cache.
bool _has_sweep_dest_data
the swdData array is allocated
dg_point const & getPoint(int n) const
Get a point.
std::vector< sweep_dest_data > swdData
int ReFormeCubicTo(int bord, Path *dest, Path *orig, bool never_split)
std::vector< point_data > pData
SBasis L2(D2< SBasis > const &a, unsigned k)
TODO: insert short description here.
Elliptical Arc path command.
Cubic Bezier path command.
void dot(Cairo::RefPtr< Cairo::Context > &cr, double x, double y)