37 #define CLIPPER_VERSION "6.4.2"
62 namespace ClipperLib {
64 enum ClipType { ctIntersection, ctUnion, ctDifference, ctXor };
65 enum PolyType { ptSubject, ptClip };
70 enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
74 static cInt
const loRange = 0x7FFF;
75 static cInt
const hiRange = 0x7FFF;
77 typedef signed long long cInt;
78 static cInt
const loRange = 0x3FFFFFFF;
79 static cInt
const hiRange = 0x3FFFFFFFFFFFFFFFLL;
80 typedef signed long long long64;
81 typedef unsigned long long ulong64;
90 IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
92 IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
97 return a.X == b.X && a.Y == b.Y;
101 return a.X != b.X || a.Y != b.Y;
106 typedef std::vector< IntPoint > Path;
107 typedef std::vector< Path > Paths;
109 inline Path& operator <<(Path& poly,
const IntPoint& p) {poly.push_back(p);
return poly;}
110 inline Paths& operator <<(Paths& polys,
const Path& p) {polys.push_back(p);
return polys;}
112 std::ostream& operator <<(std::ostream &s,
const IntPoint &p);
113 std::ostream& operator <<(std::ostream &s,
const Path &p);
114 std::ostream& operator <<(std::ostream &s,
const Paths &p);
120 DoublePoint(
double x = 0,
double y = 0) : X(x), Y(y) {}
129 enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
130 enum JoinType {jtSquare, jtRound, jtMiter};
131 enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
134 typedef std::vector< PolyNode* > PolyNodes;
147 int ChildCount()
const;
173 bool Orientation(
const Path &poly);
174 double Area(
const Path &poly);
175 int PointInPolygon(
const IntPoint &pt,
const Path &path);
177 void SimplifyPolygon(
const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
178 void SimplifyPolygons(
const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
179 void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
181 void CleanPolygon(
const Path& in_poly, Path& out_poly,
double distance = 1.415);
182 void CleanPolygon(Path& poly,
double distance = 1.415);
183 void CleanPolygons(
const Paths& in_polys, Paths& out_polys,
double distance = 1.415);
184 void CleanPolygons(Paths& polys,
double distance = 1.415);
186 void MinkowskiSum(
const Path& pattern,
const Path& path, Paths& solution,
bool pathIsClosed);
187 void MinkowskiSum(
const Path& pattern,
const Paths& paths, Paths& solution,
bool pathIsClosed);
188 void MinkowskiDiff(
const Path& poly1,
const Path& poly2, Paths& solution);
190 void PolyTreeToPaths(
const PolyTree& polytree, Paths& paths);
191 void ClosedPathsFromPolyTree(
const PolyTree& polytree, Paths& paths);
192 void OpenPathsFromPolyTree(
PolyTree& polytree, Paths& paths);
194 void ReversePath(Path& p);
195 void ReversePaths(Paths& p);
197 struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
200 enum EdgeSide { esLeft = 1, esRight = 2};
204 struct IntersectNode;
210 typedef std::vector < OutRec* > PolyOutList;
211 typedef std::vector < TEdge* > EdgeList;
212 typedef std::vector < Join* > JoinList;
213 typedef std::vector < IntersectNode* > IntersectList;
225 virtual bool AddPath(
const Path &pg, PolyType PolyTyp,
bool Closed);
226 bool AddPaths(
const Paths &ppg, PolyType PolyTyp,
bool Closed);
227 virtual void Clear();
229 bool PreserveCollinear() {
return m_PreserveCollinear;};
230 void PreserveCollinear(
bool value) {m_PreserveCollinear = value;};
232 void DisposeLocalMinimaList();
233 TEdge* AddBoundsToLML(
TEdge *e,
bool IsClosed);
234 virtual void Reset();
235 TEdge* ProcessBound(
TEdge* E,
bool IsClockwise);
236 void InsertScanbeam(
const cInt Y);
237 bool PopScanbeam(cInt &Y);
238 bool LocalMinimaPending();
239 bool PopLocalMinima(cInt Y,
const LocalMinimum *&locMin);
241 void DisposeAllOutRecs();
242 void DisposeOutRec(PolyOutList::size_type index);
243 void SwapPositionsInAEL(
TEdge *edge1,
TEdge *edge2);
244 void DeleteFromAEL(
TEdge *e);
245 void UpdateEdgeIntoAEL(
TEdge *&e);
247 typedef std::vector<LocalMinimum> MinimaList;
248 MinimaList::iterator m_CurrentLM;
249 MinimaList m_MinimaList;
253 bool m_PreserveCollinear;
255 PolyOutList m_PolyOuts;
256 TEdge *m_ActiveEdges;
258 typedef std::priority_queue<cInt> ScanbeamList;
259 ScanbeamList m_Scanbeam;
267 bool Execute(ClipType clipType,
269 PolyFillType fillType = pftEvenOdd);
270 bool Execute(ClipType clipType,
272 PolyFillType subjFillType,
273 PolyFillType clipFillType);
274 bool Execute(ClipType clipType,
276 PolyFillType fillType = pftEvenOdd);
277 bool Execute(ClipType clipType,
279 PolyFillType subjFillType,
280 PolyFillType clipFillType);
281 bool ReverseSolution() {
return m_ReverseOutput; };
282 void ReverseSolution(
bool value) {m_ReverseOutput = value;};
283 bool StrictlySimple() {
return m_StrictSimple;};
284 void StrictlySimple(
bool value) {m_StrictSimple = value;};
287 void ZFillFunction(ZFillCallback zFillFunc);
290 virtual bool ExecuteInternal();
293 JoinList m_GhostJoins;
294 IntersectList m_IntersectList;
296 typedef std::list<cInt> MaximaList;
298 TEdge *m_SortedEdges;
299 bool m_ExecuteLocked;
300 PolyFillType m_ClipFillType;
301 PolyFillType m_SubjFillType;
302 bool m_ReverseOutput;
303 bool m_UsingPolyTree;
306 ZFillCallback m_ZFill;
308 void SetWindingCount(
TEdge& edge);
309 bool IsEvenOddFillType(
const TEdge& edge)
const;
310 bool IsEvenOddAltFillType(
const TEdge& edge)
const;
311 void InsertLocalMinimaIntoAEL(
const cInt botY);
312 void InsertEdgeIntoAEL(
TEdge *edge,
TEdge* startEdge);
313 void AddEdgeToSEL(
TEdge *edge);
314 bool PopEdgeFromSEL(
TEdge *&edge);
316 void DeleteFromSEL(
TEdge *e);
317 void SwapPositionsInSEL(
TEdge *edge1,
TEdge *edge2);
318 bool IsContributing(
const TEdge& edge)
const;
319 bool IsTopHorz(
const cInt XPos);
320 void DoMaxima(
TEdge *e);
321 void ProcessHorizontals();
322 void ProcessHorizontal(
TEdge *horzEdge);
325 OutRec* GetOutRec(
int idx);
330 bool ProcessIntersections(
const cInt topY);
331 void BuildIntersectList(
const cInt topY);
332 void ProcessIntersectList();
333 void ProcessEdgesAtTopOfScanbeam(
const cInt topY);
334 void BuildResult(Paths& polys);
335 void BuildResult2(
PolyTree& polytree);
337 void DisposeIntersectNodes();
338 bool FixupIntersectionOrder();
339 void FixupOutPolygon(
OutRec &outrec);
340 void FixupOutPolyline(
OutRec &outrec);
341 bool IsHole(
TEdge *e);
342 bool FindOwnerFromSplitRecs(
OutRec &outRec,
OutRec *&currOrfl);
343 void FixHoleLinkage(
OutRec &outrec);
346 void ClearGhostJoins();
349 void JoinCommonEdges();
350 void DoSimplePolygons();
351 void FixupFirstLefts1(
OutRec* OldOutRec,
OutRec* NewOutRec);
352 void FixupFirstLefts2(
OutRec* InnerOutRec,
OutRec* OuterOutRec);
353 void FixupFirstLefts3(
OutRec* OldOutRec,
OutRec* NewOutRec);
363 ClipperOffset(
double miterLimit = 2.0,
double roundPrecision = 0.25);
365 void AddPath(
const Path& path, JoinType joinType, EndType endType);
366 void AddPaths(
const Paths& paths, JoinType joinType, EndType endType);
367 void Execute(Paths& solution,
double delta);
368 void Execute(
PolyTree& solution,
double delta);
376 std::vector<DoublePoint> m_normals;
377 double m_delta, m_sinA, m_sin, m_cos;
378 double m_miterLim, m_StepsPerRad;
382 void FixOrientations();
383 void DoOffset(
double delta);
384 void OffsetPoint(
int j,
int& k, JoinType jointype);
385 void DoSquare(
int j,
int k);
386 void DoMiter(
int j,
int k,
double r);
387 void DoRound(
int j,
int k);
396 virtual const char* what()
const throw() {
return m_descr.c_str();}
Definition: clipper.hpp:221
Definition: clipper.hpp:361
Definition: clipper.hpp:264
Definition: clipper.hpp:137
Definition: clipper.hpp:161
Definition: clipper.hpp:392
Definition: clipper.hpp:117
Definition: clipper.hpp:85
Definition: clipper.hpp:197
Definition: clipper.cpp:119
Definition: clipper.cpp:92
Definition: clipper.cpp:112
Definition: clipper.cpp:102
Definition: clipper.cpp:66