34#ifndef clipper_hpp_kicad
35#define clipper_hpp_kicad
37#define CLIPPER_VERSION_KICAD "6.4.2"
47#define use_lines_kicad
63namespace ClipperLibKiCad {
66 ctIntersection, ctUnion, ctDifference, ctXor
78 pftEvenOdd, pftNonZero, pftPositive, pftNegative
83static cInt
const loRange = 0x7FFF;
84static cInt
const hiRange = 0x7FFF;
86typedef signed long long cInt;
87static cInt
const loRange = 0x3FFFFFFF;
88static cInt
const hiRange = 0x3FFFFFFFFFFFFFFFLL;
89typedef signed long long long64;
90typedef unsigned long long ulong64;
100 IntPoint( cInt x = 0, cInt y = 0, cInt z = 0 ) : X( x ), Y( y ), Z( z ) {};
102 IntPoint( cInt x = 0, cInt y = 0 ) : X( x ), Y( y ) {};
107 return a.X == b.X && a.Y == b.Y;
112 return a.X != b.X || a.Y != b.Y;
117typedef std::vector<IntPoint> Path;
118typedef std::vector<Path> Paths;
120inline Path& operator <<( Path& poly,
const IntPoint& p )
122 poly.push_back( p );
return poly;
126inline Paths& operator <<( Paths& polys,
const Path& p )
128 polys.push_back( p );
return polys;
132std::ostream& operator <<( std::ostream& s,
const IntPoint& p );
133std::ostream& operator <<( std::ostream& s,
const Path& p );
134std::ostream& operator <<( std::ostream& s,
const Paths& p );
140 DoublePoint(
double x = 0,
double y = 0 ) : X( x ), Y( y ) {}
152 ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4
156 jtSquare, jtRound, jtMiter
160 etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound
164typedef std::vector<PolyNode*> PolyNodes;
177 int ChildCount()
const;
206bool Orientation(
const Path& poly );
207double Area(
const Path& poly );
208int PointInPolygon(
const IntPoint& pt,
const Path& path );
210void SimplifyPolygon(
const Path& in_poly, Paths& out_polys,
211 PolyFillType fillType = pftEvenOdd );
212void SimplifyPolygons(
const Paths& in_polys,
214 PolyFillType fillType = pftEvenOdd );
215void SimplifyPolygons( Paths& polys, PolyFillType fillType = pftEvenOdd );
217void CleanPolygon(
const Path& in_poly, Path& out_poly,
double distance = 1.415 );
218void CleanPolygon( Path& poly,
double distance = 1.415 );
219void CleanPolygons(
const Paths& in_polys, Paths& out_polys,
double distance = 1.415 );
220void CleanPolygons( Paths& polys,
double distance = 1.415 );
222void MinkowskiSum(
const Path& pattern,
const Path& path, Paths& solution,
bool pathIsClosed );
223void MinkowskiSum(
const Path& pattern,
const Paths& paths, Paths& solution,
bool pathIsClosed );
224void MinkowskiDiff(
const Path& poly1,
const Path& poly2, Paths& solution );
226void PolyTreeToPaths(
const PolyTree& polytree, Paths& paths );
227void ClosedPathsFromPolyTree(
const PolyTree& polytree, Paths& paths );
228void OpenPathsFromPolyTree(
PolyTree& polytree, Paths& paths );
230void ReversePath( Path& p );
231void ReversePaths( Paths& p );
235 cInt left; cInt top; cInt right; cInt bottom;
241 esLeft = 1, esRight = 2
252typedef std::vector <OutRec*> PolyOutList;
253typedef std::vector <TEdge*> EdgeList;
254typedef std::vector <Join*> JoinList;
255typedef std::vector <IntersectNode*> IntersectList;
267 virtual bool AddPath(
const Path& pg, PolyType PolyTyp,
bool Closed );
268 bool AddPaths(
const Paths& ppg, PolyType PolyTyp,
bool Closed );
269 virtual void Clear();
272 bool PreserveCollinear() {
return m_PreserveCollinear; };
273 void PreserveCollinear(
bool value ) { m_PreserveCollinear = value; };
276 void DisposeLocalMinimaList();
277 TEdge* AddBoundsToLML(
TEdge* e,
bool IsClosed );
278 virtual void Reset();
279 TEdge* ProcessBound(
TEdge* E,
bool IsClockwise );
280 void InsertScanbeam(
const cInt Y );
281 bool PopScanbeam( cInt& Y );
282 bool LocalMinimaPending();
283 bool PopLocalMinima( cInt Y,
const LocalMinimum*& locMin );
285 void DisposeAllOutRecs();
286 void DisposeOutRec( PolyOutList::size_type index );
287 void SwapPositionsInAEL(
TEdge* edge1,
TEdge* edge2 );
288 void DeleteFromAEL(
TEdge* e );
289 void UpdateEdgeIntoAEL(
TEdge*& e );
291 typedef std::vector<LocalMinimum> MinimaList;
292 MinimaList::iterator m_CurrentLM;
293 MinimaList m_MinimaList;
297 bool m_PreserveCollinear;
299 PolyOutList m_PolyOuts;
300 TEdge* m_ActiveEdges;
302 typedef std::priority_queue<cInt> ScanbeamList;
303 ScanbeamList m_Scanbeam;
310 Clipper(
int initOptions = 0 );
311 bool Execute( ClipType clipType,
313 PolyFillType fillType = pftEvenOdd );
314 bool Execute( ClipType clipType,
316 PolyFillType subjFillType,
317 PolyFillType clipFillType );
318 bool Execute( ClipType clipType,
320 PolyFillType fillType = pftEvenOdd );
321 bool Execute( ClipType clipType,
323 PolyFillType subjFillType,
324 PolyFillType clipFillType );
326 bool ReverseSolution() {
return m_ReverseOutput; };
327 void ReverseSolution(
bool value ) { m_ReverseOutput = value; };
328 bool StrictlySimple() {
return m_StrictSimple; };
329 void StrictlySimple(
bool value ) { m_StrictSimple = value; };
332 void ZFillFunction( ZFillCallback zFillFunc );
337 virtual bool ExecuteInternal();
341 JoinList m_GhostJoins;
342 IntersectList m_IntersectList;
344 typedef std::list<cInt> MaximaList;
346 TEdge* m_SortedEdges;
347 bool m_ExecuteLocked;
348 PolyFillType m_ClipFillType;
349 PolyFillType m_SubjFillType;
350 bool m_ReverseOutput;
351 bool m_UsingPolyTree;
354 ZFillCallback m_ZFill;
356 void SetWindingCount(
TEdge& edge );
357 bool IsEvenOddFillType(
const TEdge& edge )
const;
358 bool IsEvenOddAltFillType(
const TEdge& edge )
const;
359 void InsertLocalMinimaIntoAEL(
const cInt botY );
360 void InsertEdgeIntoAEL(
TEdge* edge,
TEdge* startEdge );
361 void AddEdgeToSEL(
TEdge* edge );
362 bool PopEdgeFromSEL(
TEdge*& edge );
364 void DeleteFromSEL(
TEdge* e );
365 void SwapPositionsInSEL(
TEdge* edge1,
TEdge* edge2 );
366 bool IsContributing(
const TEdge& edge )
const;
367 bool IsTopHorz(
const cInt XPos );
368 void DoMaxima(
TEdge* e );
369 void ProcessHorizontals();
370 void ProcessHorizontal(
TEdge* horzEdge );
373 OutRec* GetOutRec(
int idx );
378 bool ProcessIntersections(
const cInt topY );
379 void BuildIntersectList(
const cInt topY );
380 void ProcessIntersectList();
381 void ProcessEdgesAtTopOfScanbeam(
const cInt topY );
382 void BuildResult( Paths& polys );
383 void BuildResult2(
PolyTree& polytree );
385 void DisposeIntersectNodes();
386 bool FixupIntersectionOrder();
387 void FixupOutPolygon(
OutRec& outrec );
388 void FixupOutPolyline(
OutRec& outrec );
389 bool IsHole(
TEdge* e );
390 bool FindOwnerFromSplitRecs(
OutRec& outRec,
OutRec*& currOrfl );
391 void FixHoleLinkage(
OutRec& outrec );
394 void ClearGhostJoins();
397 void JoinCommonEdges();
398 void DoSimplePolygons();
399 void FixupFirstLefts1(
OutRec* OldOutRec,
OutRec* NewOutRec );
400 void FixupFirstLefts2(
OutRec* InnerOutRec,
OutRec* OuterOutRec );
401 void FixupFirstLefts3(
OutRec* OldOutRec,
OutRec* NewOutRec );
413 ClipperOffset(
double miterLimit = 2.0,
double roundPrecision = 0.25 );
415 void AddPath(
const Path& path, JoinType joinType, EndType endType );
416 void AddPaths(
const Paths& paths, JoinType joinType, EndType endType );
417 void Execute( Paths& solution,
double delta );
418 void Execute(
PolyTree& solution,
double delta );
422 JoinType MiterFallback;
429 std::vector<DoublePoint> m_normals;
430 double m_delta, m_sinA, m_sin, m_cos;
431 double m_miterLim, m_StepsPerRad;
435 void FixOrientations();
436 void DoOffset(
double delta );
437 void OffsetPoint(
int j,
int& k, JoinType jointype );
438 void DoSquare(
int j,
int k );
439 void DoMiter(
int j,
int k,
double r );
440 void DoRound(
int j,
int k );
449 virtual const char* what()
const throw()
override {
return m_descr.c_str(); }
Definition clipper.hpp:263
Definition clipper.hpp:411
Definition clipper.hpp:308
Definition clipper.hpp:167
Definition clipper.hpp:193
Definition clipper.hpp:445
Definition clipper.hpp:137
Definition clipper.hpp:95
Definition clipper.hpp:234
Definition clipper.cpp:127
Definition clipper.cpp:97
Definition clipper.cpp:119
Definition clipper.cpp:108
Definition clipper.cpp:69