Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Shape.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors: see git history
6 *
7 * Copyright (C) 2018 Authors
8 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
9 */
10
11#ifndef my_shape
12#define my_shape
13
14#include <cmath>
15#include <cstdio>
16#include <cstdlib>
17#include <cstring>
18#include <vector>
19#include <2geom/point.h>
20
21#include "livarot/LivarotDefs.h"
22
23class Path;
24class FloatLigne;
25
26class SweepTree;
27class SweepTreeList;
28class SweepEventQueue;
29
30enum {
35};
36
37/*
38 * the Shape class (was the Digraph class, as the header says) stores digraphs (no kidding!) of which
39 * a very interesting kind are polygons.
40 * the main use of this class is the ConvertToShape() (or Booleen(), quite the same) function, which
41 * removes all problems a polygon can present: duplicate points or edges, self-intersection. you end up with a
42 * full-fledged polygon
43 */
44
45// possible values for the "type" field in the Shape class:
46enum
47{
48 shape_graph = 0, // it's just a graph; a bunch of edges, maybe intersections
49 shape_polygon = 1 // a polygon: intersection-free, edges oriented so that the inside is on their left
50};
51
52
64class Shape
65{
66public:
70 struct back_data
71 {
72 int pathID;
73 int pieceID;
74 double tSt;
75 double tEn;
76 };
77
87
92 {
93 sTreeChangeType type; // type of modification to the sweepline:
94 int ptNo; // point at which the modification takes place
95
96 Shape *src; // left edge (or unique edge if not an intersection) involved in the event
97 int bord;
98 Shape *osrc; // right edge (if intersection)
99 int obord;
100 Shape *lSrc; // edge directly on the left in the sweepline at the moment of the event
101 int lBrd;
102 Shape *rSrc; // edge directly on the right
103 int rBrd;
104 };
105
107 {
108 int nextInc; // next incidence in the linked list
109 int pt; // point incident to the edge (there is one list per edge)
110 double theta; // coordinate of the incidence on the edge
111 };
112
113 Shape();
114 ~Shape();
115
116 void MakeBackData(bool nVal);
117
118 void Affiche();
119
120 // insertion/deletion/movement of elements in the graph
121 void Copy(Shape *a);
122 // -reset the graph, and ensure there's room for n points and m edges
123
133 void Reset(int n = 0, int m = 0);
134 // -points:
135 int AddPoint(const Geom::Point x); // as the function name says
136 // returns the index at which the point has been added in the array
137 void SubPoint(int p); // removes the point at index p
138 // nota: this function relocates the last point to the index p
139 // so don't trust point indices if you use SubPoint
140 void SwapPoints(int a, int b); // swaps 2 points at indices a and b
141 void SwapPoints(int a, int b, int c); // swaps 3 points: c <- a <- b <- c
142
143
149 void SortPoints(); // sorts the points if needed (checks the need_points_sorting flag)
150
151 // -edges:
152 // add an edge between points of indices st and en
153 int AddEdge(int st, int en);
154 // return the edge index in the array
155
156 // add an edge between points of indices st and en
157 int AddEdge(int st, int en, int leF, int riF);
158 // return the edge index in the array
159
160 // version for the voronoi (with faces IDs)
161 void SubEdge(int e); // removes the edge at index e (same remarks as for SubPoint)
162 void SwapEdges(int a, int b); // swaps 2 edges
163 void SwapEdges(int a, int b, int c); // swaps 3 edges
164
176 void SortEdges(); // sort the edges if needed (checks the need_edges_sorting falg)
177
178 // primitives for topological manipulations
179
180 // endpoint of edge at index b that is different from the point p
181 inline int Other(int p, int b) const
182 {
183 if (getEdge(b).st == p) {
184 return getEdge(b).en;
185 }
186 return getEdge(b).st;
187 }
188
189 // next edge (after edge b) in the double-linked list at point p
190 inline int NextAt(int p, int b) const
191 {
192 if (p == getEdge(b).st) {
193 return getEdge(b).nextS;
194 }
195 else if (p == getEdge(b).en) {
196 return getEdge(b).nextE;
197 }
198
199 return -1;
200 }
201
202 // previous edge
203 inline int PrevAt(int p, int b) const
204 {
205 if (p == getEdge(b).st) {
206 return getEdge(b).prevS;
207 }
208 else if (p == getEdge(b).en) {
209 return getEdge(b).prevE;
210 }
211
212 return -1;
213 }
214
215 // same as NextAt, but the list is considered circular
216 inline int CycleNextAt(int p, int b) const
217 {
218 if (p == getEdge(b).st) {
219 if (getEdge(b).nextS < 0) {
220 return getPoint(p).incidentEdge[FIRST];
221 }
222 return getEdge(b).nextS;
223 } else if (p == getEdge(b).en) {
224 if (getEdge(b).nextE < 0) {
225 return getPoint(p).incidentEdge[FIRST];
226 }
227
228 return getEdge(b).nextE;
229 }
230
231 return -1;
232 }
233
234 // same as PrevAt, but the list is considered circular
235 inline int CyclePrevAt(int p, int b) const
236 {
237 if (p == getEdge(b).st) {
238 if (getEdge(b).prevS < 0) {
239 return getPoint(p).incidentEdge[LAST];
240 }
241 return getEdge(b).prevS;
242 } else if (p == getEdge(b).en) {
243 if (getEdge(b).prevE < 0) {
244 return getPoint(p).incidentEdge[LAST];
245 }
246 return getEdge(b).prevE;
247 }
248
249 return -1;
250 }
251
252 void ConnectStart(int p, int b); // set the point p as the start of edge b
253 void ConnectEnd(int p, int b); // set the point p as the end of edge b
254 void DisconnectStart(int b); // disconnect edge b from its start point
255 void DisconnectEnd(int b); // disconnect edge b from its end point
256
257 // reverses edge b (start <-> end)
258 void Inverse(int b);
259 // calc bounding box and sets leftX,rightX,topY and bottomY to their values
260 void CalcBBox(bool strict_degree = false);
261
262 // debug function: plots the graph (mac only)
263 void Plot(double ix, double iy, double ir, double mx, double my, bool doPoint,
264 bool edgesNo, bool pointNo, bool doDir, char *fileName);
265
266 // transforms a polygon in a "forme" structure, ie a set of contours, which can be holes (see ShapeUtils.h)
267 // return NULL in case it's not possible
268
279 void ConvertToForme(Path *dest);
280
281 // version to use when conversion was done with ConvertWithBackData(): will attempt to merge segment belonging to
282 // the same curve
283 // nota: apparently the function doesn't like very small segments of arc
284
294 void ConvertToForme(Path *dest, int nbP, Path *const *orig, bool never_split = false);
295 // version trying to recover the nesting of subpaths (ie: holes)
296 void ConvertToFormeNested(Path *dest, int nbP, Path *const *orig, int &nbNest, int *&nesting, int *&contStart, bool never_split = false);
297
298 // sweeping a digraph to produce a intersection-free polygon
299 // return 0 if everything is ok and a return code otherwise (see LivarotDefs.h)
300 // the input is the Shape "a"
301 // directed=true <=> non-zero fill rule
302
336 int ConvertToShape(Shape *a, FillRule directed = fill_nonZero, bool invert = false);
337
338
339 // directed=false <=> even-odd fill rule
340 // invert=true: make as if you inverted all edges in the source
341 int Reoriente(Shape *a); // subcase of ConvertToShape: the input a is already intersection-free
342 // all that's missing are the correct directions of the edges
343 // Reoriented is equivalent to ConvertToShape(a,false,false) , but faster sicne
344 // it doesn't computes interections nor adjacencies
345 void ForceToPolygon(); // force the Shape to believe it's a polygon (eulerian+intersection-free+no
346 // duplicate edges+no duplicate points)
347 // be careful when using this function
348
349 // the coordinate rounding function
350 inline static double Round(double x)
351 {
352 return ldexp(rint(ldexp(x, 9)), -9);
353 }
354
355 // 2 miscannellous variations on it, to scale to and back the rounding grid
356 inline static double HalfRound(double x)
357 {
358 return ldexp(x, -9);
359 }
360
361 inline static double IHalfRound(double x)
362 {
363 return ldexp(x, 9);
364 }
365
366 // boolean operations on polygons (requests intersection-free poylygons)
367 // boolean operation types are defined in LivarotDefs.h
368 // same return code as ConvertToShape
369 int Booleen(Shape *a, Shape *b, BooleanOp mod, int cutPathID = -1);
370
371 // create a graph that is an offseted version of the graph "of"
372 // the offset is dec, with joins between edges of type "join" (see LivarotDefs.h)
373 // the result is NOT a polygon; you need a subsequent call to ConvertToShape to get a real polygon
374 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);
375
376 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);
377
378 int PtWinding(const Geom::Point px) const; // plus rapide
409 int Winding(const Geom::Point px) const;
410
411 // rasterization
412 void BeginRaster(float &pos, int &curPt);
413 void EndRaster();
414
415 void Scan(float &pos, int &curP, float to, float step);
416
417 void Scan(float &pos, int &curP, float to, FloatLigne *line, bool exact, float step);
418
419 void Transform(Geom::Affine const &tr)
420 {for(auto & _pt : _pts) _pt.x*=tr;}
421
422 std::vector<back_data> ebData;
424 std::vector<sTreeChange> chgts;
425 int nbInc;
427
429 // these ones are allocated at the beginning of each sweep and freed at the end of the sweep
433 // bounding box stuff
435
447 struct dg_point
448 {
450 int dI;
451 int dO;
455 int totalDegree() const { return dI + dO; }
456 };
457
461 struct dg_arete
462 {
464 int st;
465 int en;
466 int nextS;
467 int prevS;
468 int nextE;
469 int prevE;
470 };
471
472 // lists of the nodes and edges
473 int maxPt; // [FIXME: remove this]
474 int maxAr; // [FIXME: remove this]
475
476 // flags
477 int type;
478
484 inline int numberOfPoints() const { return _pts.size(); }
485
491 inline bool hasPoints() const { return (_pts.empty() == false); }
492
498 inline int numberOfEdges() const { return _aretes.size(); }
499
505 inline bool hasEdges() const { return (_aretes.empty() == false); }
506
512 inline void needPointsSorting() { _need_points_sorting = true; }
513
519 inline void needEdgesSorting() { _need_edges_sorting = true; }
520
526 inline bool hasBackData() const { return _has_back_data; }
527
537 inline dg_point const &getPoint(int n) const { return _pts[n]; }
538
548 inline dg_arete const &getEdge(int n) const { return _aretes[n]; }
549
550private:
551
552 friend class SweepTree;
553 friend class SweepEvent;
554 friend class SweepEventQueue;
555
560 {
561 int weight;
563 double length; // <-- epic naming here folks
564 double sqlength; // <-- epic naming here too
565 double ilength;
566 double isqlength;
567 double siEd, coEd;
568 edge_data() : weight(0), length(0.0), sqlength(0.0), ilength(0.0), isqlength(0.0), siEd(0.0), coEd(0.0) {}
569 // used to determine the "most horizontal" edge between 2 edges
570 };
571
573 {
574 SweepTree *misc; // pointer to the SweepTree* in the sweepline
575 int firstLinkedPoint; // not used
576 int stPt, enPt; // start- end end- points for this edge in the resulting polygon
577 int ind; // for the GetAdjacencies function: index in the sliceSegs array (for quick deletions)
578 int leftRnd, rightRnd; // leftmost and rightmost points (in the result polygon) that are incident to
579 // the edge, for the current sweep position
580 // not set if the edge doesn't start/end or intersect at the current sweep position
581 Shape *nextSh; // nextSh and nextBo identify the next edge in the list
582 int nextBo; // they are used to maintain a linked list of edge that start/end or intersect at
583 // the current sweep position
585 double curT;
586 };
587
589 {
590 int misc; // used to check if an edge has already been seen during the depth-first search
591 int suivParc, precParc; // previous and current next edge in the depth-first search
592 int leW, riW; // left and right winding numbers for this edge
593 int ind; // order of the edges during the depth-first search
594 };
595
597 {
598 SweepTree *misc; // pointer to the associated SweepTree* in the sweepline
599 double lastX, lastY, curX, curY; // curX;curY is the current intersection of the edge with the sweepline
600 // lastX;lastY is the intersection with the previous sweepline
601 bool sens; // true if the edge goes down, false otherwise
602 double calcX; // horizontal position of the intersection of the edge with the
603 // previous sweepline
604 double dxdy, dydx; // horizontal change per unit vertical move of the intersection with the sweepline
605 int guess;
606 };
607
612 {
613 int oldInd, newInd; // back and forth indices used when sorting the points, to know where they have
614 // been relocated in the array
615 int pending; // number of intersection attached to this edge, and also used when sorting arrays
616 int nextLinkedPoint; // not used
620 };
621
622
627 {
628 int no;
631 };
632
633 void initialisePointData();
634 void initialiseEdgeData();
635 void clearIncidenceData();
636
637 void _countUpDown(int P, int *numberUp, int *numberDown, int *upEdge, int *downEdge) const;
638 void _countUpDownTotalDegree2(int P, int *numberUp, int *numberDown, int *upEdge, int *downEdge) const;
639 void _updateIntersection(int e, int p);
640
641 // activation/deactivation of the temporary data arrays
642
648 void MakePointData(bool nVal);
649
655 void MakeEdgeData(bool nVal);
656
662 void MakeSweepSrcData(bool nVal);
663
669 void MakeSweepDestData(bool nVal);
670
671 void MakeRasterData(bool nVal);
672
692 void SortPoints(int s, int e);
693
709 void SortPointsByOldInd(int s, int e);
710
711 // fonctions annexes pour ConvertToShape et Booleen
712
716 void ResetSweep(); // allocates sweep structures
717
721 void CleanupSweep(); // deallocates them
722
723 // edge sorting function
724
736 void SortEdgesList(edge_list *edges, int s, int e);
737
750 void TesteIntersection(SweepTree *t, Side s, bool onlyDiff); // test if there is an intersection
751
813 bool TesteIntersection(SweepTree *iL, SweepTree *iR, Geom::Point &atx, double &atL, double &atR, bool onlyDiff);
814 bool TesteIntersection(Shape *iL, Shape *iR, int ilb, int irb,
815 Geom::Point &atx, double &atL, double &atR,
816 bool onlyDiff);
817 bool TesteAdjacency(Shape *iL, int ilb, const Geom::Point atx, int nPt,
818 bool push);
819 int PushIncidence(Shape *a, int cb, int pt, double theta);
820 int CreateIncidence(Shape *a, int cb, int pt);
821 void AssemblePoints(Shape *a);
822
839 int AssemblePoints(int st, int en);
840 void AssembleAretes(FillRule directed = fill_nonZero);
841
861 void AddChgt(int lastPointNo, int lastChgtPt, Shape *&shapeHead,
862 int &edgeHead, sTreeChangeType type, Shape *lS, int lB, Shape *rS,
863 int rB);
864
903 void CheckAdjacencies(int lastPointNo, int lastChgtPt, Shape *shapeHead, int edgeHead);
904
916 void CheckEdges(int lastPointNo, int lastChgtPt, Shape *a, Shape *b, BooleanOp mod);
917
951 void Avance(int lastPointNo, int lastChgtPt, Shape *iS, int iB, Shape *a, Shape *b, BooleanOp mod);
952
981 void DoEdgeTo(Shape *iS, int iB, int iTo, bool direct, bool sens);
982
1017 void GetWindings(bool brutal = false);
1018
1019 void Validate();
1020
1026 int Winding(int nPt) const;
1027
1031 void SortPointsRounded();
1032
1042 void SortPointsRounded(int s, int e);
1043
1044 void CreateEdge(int no, float to, float step);
1045 void AvanceEdge(int no, float to, bool exact, float step);
1046 void DestroyEdge(int no, float to, FloatLigne *line);
1047 void AvanceEdge(int no, float to, FloatLigne *line, bool exact, float step);
1048
1058 void AddContour(Path *dest, int num_orig, Path *const *orig, int start_edge, bool never_split = false);
1059
1060 int ReFormeLineTo(int bord, Path *dest, bool never_split);
1061 int ReFormeArcTo(int bord, Path *dest, Path *orig, bool never_split);
1062 int ReFormeCubicTo(int bord, Path *dest, Path *orig, bool never_split);
1063
1073 bool _has_back_data; //< the ebData array is allocated
1075
1076 std::vector<dg_point> _pts;
1077 std::vector<dg_arete> _aretes;
1079 // the arrays of temporary data
1080 // these ones are dynamically kept at a length of maxPt or maxAr
1081 std::vector<edge_data> eData;
1082 std::vector<sweep_src_data> swsData;
1083 std::vector<sweep_dest_data> swdData;
1084 std::vector<raster_data> swrData;
1085 std::vector<point_data> pData;
1087 // edge direction comparison function
1088
1107 static int CmpToVert(const Geom::Point ax, const Geom::Point bx, bool as, bool bs);
1108};
1109
1119bool directedEulerian(Shape const *s);
1120double distance(Shape const *s, Geom::Point const &p);
1121bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2);
1122
1123#endif
Cartesian point / 2D vector and related operations.
TODO: insert short description here.
Side
Definition LivarotDefs.h:86
FillRule
Definition LivarotDefs.h:68
@ fill_nonZero
Definition LivarotDefs.h:70
BooleanOp
Definition LivarotDefs.h:77
@ FIRST
Definition LivarotDefs.h:92
@ LAST
Definition LivarotDefs.h:93
JoinType
Definition LivarotDefs.h:61
bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2)
Returns true iff the L2 distance from thePt to this shape is <= max_l2.
Definition Shape.cpp:2198
double distance(Shape const *s, Geom::Point const &p)
Definition Shape.cpp:2136
@ tweak_mode_repel
Definition Shape.h:33
@ tweak_mode_grow
Definition Shape.h:31
@ tweak_mode_push
Definition Shape.h:32
@ tweak_mode_roughen
Definition Shape.h:34
@ shape_graph
Definition Shape.h:48
@ shape_polygon
Definition Shape.h:49
bool directedEulerian(Shape const *s)
Is the graph Eulerian?
Definition Shape.cpp:2117
Coverage with floating-point boundaries.
Definition float-line.h:69
3x3 matrix representing an affine transformation.
Definition affine.h:70
Two-dimensional point that doubles as a vector.
Definition point.h:66
Path and its polyline approximation.
Definition Path.h:93
A class to store/manipulate directed graphs.
Definition Shape.h:65
bool _has_edges_data
the eData array is allocated
Definition Shape.h:1069
void EndRaster()
void DoEdgeTo(Shape *iS, int iB, int iTo, bool direct, bool sens)
Draw edge to a passed point.
int PushIncidence(Shape *a, int cb, int pt, double theta)
void MakeSweepDestData(bool nVal)
Initialize the sweep destination data cache.
Definition Shape.cpp:149
void AddChgt(int lastPointNo, int lastChgtPt, Shape *&shapeHead, int &edgeHead, sTreeChangeType type, Shape *lS, int lB, Shape *rS, int rB)
Add the event in chgts.
void AddContour(Path *dest, int num_orig, Path *const *orig, int start_edge, bool never_split=false)
Add a contour.
void Affiche()
Definition Shape.cpp:55
std::vector< sweep_src_data > swsData
Definition Shape.h:1082
int Other(int p, int b) const
Definition Shape.h:181
sTreeChangeType
Enum describing all the events that can happen to a sweepline.
Definition Shape.h:82
@ INTERSECTION
Definition Shape.h:85
@ EDGE_INSERTED
Definition Shape.h:83
@ EDGE_REMOVED
Definition Shape.h:84
void CheckAdjacencies(int lastPointNo, int lastChgtPt, Shape *shapeHead, int edgeHead)
If there are points that lie on edges, mark this by modifying leftRnd and rightRnd variables.
void ResetSweep()
Prepare point data cache, edge data cache and sweep source cache.
void CreateEdge(int no, float to, float step)
int maxInc
Definition Shape.h:426
void ConvertToForme(Path *dest)
Extract contours from a directed graph.
Definition ShapeMisc.cpp:42
void AssembleAretes(FillRule directed=fill_nonZero)
void needEdgesSorting()
Do the edges need sorting?
Definition Shape.h:519
int Booleen(Shape *a, Shape *b, BooleanOp mod, int cutPathID=-1)
void _updateIntersection(int e, int p)
void needPointsSorting()
Do the points need sorting?
Definition Shape.h:512
double leftX
Definition Shape.h:434
void Scan(float &pos, int &curP, float to, float step)
void MakeBackData(bool nVal)
Definition Shape.cpp:169
bool _point_data_initialised
the pData array is up to date
Definition Shape.h:1068
int nbInc
Definition Shape.h:425
std::vector< sTreeChange > chgts
Definition Shape.h:424
void SubPoint(int p)
Definition Shape.cpp:298
void MakeSweepSrcData(bool nVal)
Initialize the sweep source data cache.
Definition Shape.cpp:129
void DisconnectStart(int b)
Definition Shape.cpp:1853
incidenceData * iData
Definition Shape.h:428
void SwapEdges(int a, int b)
Definition Shape.cpp:1191
void Plot(double ix, double iy, double ir, double mx, double my, bool doPoint, bool edgesNo, bool pointNo, bool doDir, char *fileName)
Definition ShapeDraw.cpp:26
void _countUpDown(int P, int *numberUp, int *numberDown, int *upEdge, int *downEdge) const
int AddEdge(int st, int en)
Definition Shape.cpp:1052
int CyclePrevAt(int p, int b) const
Definition Shape.h:235
int PtWinding(const Geom::Point px) const
Definition Shape.cpp:2001
bool _has_back_data
Definition Shape.h:1073
bool _has_sweep_src_data
the swsData array is allocated
Definition Shape.h:1070
int PrevAt(int p, int b) const
Definition Shape.h:203
bool hasPoints() const
Do we have points?
Definition Shape.h:491
std::vector< raster_data > swrData
Definition Shape.h:1084
void SortPoints()
Sort the points (all points) only if needed.
Definition Shape.cpp:467
bool TesteAdjacency(Shape *iL, int ilb, const Geom::Point atx, int nPt, bool push)
void SortEdgesList(edge_list *edges, int s, int e)
Sort edges given in a list.
Definition Shape.cpp:1639
bool _bbox_up_to_date
the leftX/rightX/topY/bottomY are up to date
Definition Shape.h:1074
int CycleNextAt(int p, int b) const
Definition Shape.h:216
void CheckEdges(int lastPointNo, int lastChgtPt, Shape *a, Shape *b, BooleanOp mod)
Check if there are edges to draw and draw them.
double topY
Definition Shape.h:434
double rightX
Definition Shape.h:434
bool _need_points_sorting
points have been added or removed: we need to sort the points again
Definition Shape.h:1064
std::vector< back_data > ebData
Definition Shape.h:422
static double IHalfRound(double x)
Definition Shape.h:361
static int CmpToVert(const Geom::Point ax, const Geom::Point bx, bool as, bool bs)
Edge comparison function.
Definition Shape.cpp:1482
void MakePointData(bool nVal)
Initialize the point data cache.
Definition Shape.cpp:71
bool _need_edges_sorting
edges have been added: maybe they are not ordered clockwise
Definition Shape.h:1065
int Reoriente(Shape *a)
void ForceToPolygon()
int maxAr
Definition Shape.h:474
int ReFormeLineTo(int bord, Path *dest, bool never_split)
void Copy(Shape *a)
Copy point and edge data from ‘who’ into this object, discarding any cached data that we have.
Definition Shape.cpp:195
void Avance(int lastPointNo, int lastChgtPt, Shape *iS, int iB, Shape *a, Shape *b, BooleanOp mod)
Do the edge.
static double HalfRound(double x)
Definition Shape.h:356
void CalcBBox(bool strict_degree=false)
Definition Shape.cpp:1963
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.
Definition Shape.h:498
void ConnectEnd(int p, int b)
Definition Shape.cpp:1828
void CleanupSweep()
Clear point data cache, edge data cache and sweep source cache.
static double Round(double x)
Definition Shape.h:350
void BeginRaster(float &pos, int &curPt)
~Shape()
Definition Shape.cpp:49
void Transform(Geom::Affine const &tr)
Definition Shape.h:419
std::vector< edge_data > eData
Definition Shape.h:1081
int NextAt(int p, int b) const
Definition Shape.h:190
int numberOfPoints() const
Returns number of points.
Definition Shape.h:484
bool _has_points_data
the pData array is allocated
Definition Shape.h:1067
bool hasEdges() const
Do we have edges?
Definition Shape.h:505
void SwapPoints(int a, int b)
Definition Shape.cpp:333
void AvanceEdge(int no, float to, bool exact, float step)
dg_arete const & getEdge(int n) const
Get an edge.
Definition Shape.h:548
void SortEdges()
Sort all edges (clockwise) around each point.
Definition Shape.cpp:1393
void SortPointsByOldInd(int s, int e)
Sort the points (take oldInd into account)
Definition Shape.cpp:663
void MakeRasterData(bool nVal)
Definition Shape.cpp:108
int maxPt
Definition Shape.h:473
Shape()
Definition Shape.cpp:26
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)
SweepTreeList * sTree
Definition Shape.h:430
void Inverse(int b)
Definition Shape.cpp:1924
void Reset(int n=0, int m=0)
Clear all data.
Definition Shape.cpp:235
void initialiseEdgeData()
Definition Shape.cpp:2070
void SortPointsRounded()
Sort all points by their rounded coordinates.
Definition Shape.cpp:475
std::vector< dg_point > _pts
Definition Shape.h:1076
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)
void GetWindings(bool brutal=false)
Calculates the winding numbers to the left and right of all edges of this shape.
void _countUpDownTotalDegree2(int P, int *numberUp, int *numberDown, int *upEdge, int *downEdge) const
Version of Shape::_countUpDown optimised for the case when getPoint(P).totalDegree() == 2.
int ConvertToShape(Shape *a, FillRule directed=fill_nonZero, bool invert=false)
Using a given fill rule, find all intersections in the shape given, create a new intersection free sh...
bool _has_raster_data
the swrData array is allocated
Definition Shape.h:1072
int ReFormeArcTo(int bord, Path *dest, Path *orig, bool never_split)
void ConnectStart(int p, int b)
Definition Shape.cpp:1802
int type
Definition Shape.h:477
std::vector< dg_arete > _aretes
Definition Shape.h:1077
int AddPoint(const Geom::Point x)
Definition Shape.cpp:266
void MakeEdgeData(bool nVal)
Initialize the edge data cache.
Definition Shape.cpp:87
void TesteIntersection(SweepTree *t, Side s, bool onlyDiff)
Test if there is an intersection of an edge on a particular side.
void clearIncidenceData()
Definition Shape.cpp:2100
bool _has_sweep_dest_data
the swdData array is allocated
Definition Shape.h:1071
void DestroyEdge(int no, float to, FloatLigne *line)
SweepEventQueue * sEvts
Definition Shape.h:431
int Winding(const Geom::Point px) const
Compute the winding number of the point given.
dg_point const & getPoint(int n) const
Get a point.
Definition Shape.h:537
std::vector< sweep_dest_data > swdData
Definition Shape.h:1083
void initialisePointData()
Definition Shape.cpp:2054
double bottomY
Definition Shape.h:434
bool hasBackData() const
Do we have back data?
Definition Shape.h:526
void AssemblePoints(Shape *a)
void SubEdge(int e)
Definition Shape.cpp:1177
void Validate()
int ReFormeCubicTo(int bord, Path *dest, Path *orig, bool never_split)
void DisconnectEnd(int b)
Definition Shape.cpp:1888
int CreateIncidence(Shape *a, int cb, int pt)
std::vector< point_data > pData
Definition Shape.h:1085
The structure to hold the intersections events encountered during the sweep.
An intersection event structure to record any intersections that are detected (predicted) during the ...
Definition sweep-event.h:25
The sweepline tree to store a linear sequence of edges that intersect with the sweepline in the exact...
One node in the AVL tree of edges.
Definition sweep-tree.h:42
double c[8][4]
Geom::Point orig
int mode
unsigned long bs
Definition quantize.cpp:38
Edges edges(Path const &p, Crossings const &cr, unsigned ix)
Definition sanitize.cpp:36
void invert(const double v[16], double alpha[16])
A structure to store back data for an edge.
Definition Shape.h:71
double tEn
Definition Shape.h:75
double tSt
Definition Shape.h:74
An edge in the directed graph.
Definition Shape.h:462
Geom::Point dx
Definition Shape.h:463
A point or vertex in the directed graph.
Definition Shape.h:448
int incidentEdge[2]
Definition Shape.h:452
Geom::Point x
Definition Shape.h:449
int totalDegree() const
Definition Shape.h:455
Extra data that some algorithms use.
Definition Shape.h:560
double coEd
Definition Shape.h:567
double ilength
Definition Shape.h:565
double length
Definition Shape.h:563
Geom::Point rdx
Definition Shape.h:562
double isqlength
Definition Shape.h:566
double sqlength
Definition Shape.h:564
double siEd
Definition Shape.h:567
A structure to help with sorting edges around a point.
Definition Shape.h:627
Geom::Point x
Definition Shape.h:630
Extra data for points used at various occasions.
Definition Shape.h:612
Geom::Point rx
Definition Shape.h:619
Shape * askForWindingS
Definition Shape.h:617
int nextLinkedPoint
Definition Shape.h:616
SweepTree * misc
Definition Shape.h:598
A structure that represents a change that took place in the sweepline.
Definition Shape.h:92
sTreeChangeType type
Definition Shape.h:93
Shape * src
Definition Shape.h:96
Shape * osrc
Definition Shape.h:98
SweepTree * misc
Definition Shape.h:574