v0.14.0
Classes | Typedefs | Enumerations | Functions | Variables
ClipperLib Namespace Reference

Classes

class  Clipper
 
class  ClipperBase
 
class  clipperException
 
class  ClipperOffset
 
struct  DoublePoint
 
class  Int128
 
struct  IntersectNode
 
struct  IntPoint
 
struct  IntRect
 
struct  Join
 
struct  LocalMinimum
 
struct  LocMinSorter
 
struct  OutPt
 
struct  OutRec
 
class  PolyNode
 
class  PolyTree
 
struct  TEdge
 

Typedefs

typedef signed long long cInt
 
typedef signed long long long64
 
typedef unsigned long long ulong64
 
typedef std::vector< IntPointPath
 
typedef std::vector< PathPaths
 
typedef std::vector< PolyNode * > PolyNodes
 
typedef std::vector< OutRec * > PolyOutList
 
typedef std::vector< TEdge * > EdgeList
 
typedef std::vector< Join * > JoinList
 
typedef std::vector< IntersectNode * > IntersectList
 

Enumerations

enum  ClipType { ctIntersection, ctUnion, ctDifference, ctXor }
 
enum  PolyType { ptSubject, ptClip }
 
enum  PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative }
 
enum  InitOptions { ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4 }
 
enum  JoinType { jtSquare, jtRound, jtMiter }
 
enum  EndType {
  etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare,
  etOpenRound
}
 
enum  EdgeSide { esLeft = 1, esRight = 2 }
 
enum  Direction { dRightToLeft, dLeftToRight }
 
enum  NodeType { ntAny, ntOpen, ntClosed }
 

Functions

Pathoperator<< (Path &poly, const IntPoint &p)
 
Pathsoperator<< (Paths &polys, const Path &p)
 
std::ostream & operator<< (std::ostream &s, const IntPoint &p)
 
std::ostream & operator<< (std::ostream &s, const Path &p)
 
std::ostream & operator<< (std::ostream &s, const Paths &p)
 
bool Orientation (const Path &poly)
 
double Area (const Path &poly)
 
int PointInPolygon (const IntPoint &pt, const Path &path)
 
void SimplifyPolygon (const Path &in_poly, Paths &out_polys, PolyFillType fillType=pftEvenOdd)
 
void SimplifyPolygons (const Paths &in_polys, Paths &out_polys, PolyFillType fillType=pftEvenOdd)
 
void SimplifyPolygons (Paths &polys, PolyFillType fillType=pftEvenOdd)
 
void CleanPolygon (const Path &in_poly, Path &out_poly, double distance=1.415)
 
void CleanPolygon (Path &poly, double distance=1.415)
 
void CleanPolygons (const Paths &in_polys, Paths &out_polys, double distance=1.415)
 
void CleanPolygons (Paths &polys, double distance=1.415)
 
void MinkowskiSum (const Path &pattern, const Path &path, Paths &solution, bool pathIsClosed)
 
void MinkowskiSum (const Path &pattern, const Paths &paths, Paths &solution, bool pathIsClosed)
 
void MinkowskiDiff (const Path &poly1, const Path &poly2, Paths &solution)
 
void PolyTreeToPaths (const PolyTree &polytree, Paths &paths)
 
void ClosedPathsFromPolyTree (const PolyTree &polytree, Paths &paths)
 
void OpenPathsFromPolyTree (PolyTree &polytree, Paths &paths)
 
void ReversePath (Path &p)
 
void ReversePaths (Paths &p)
 
cInt Round (double val)
 
cInt Abs (cInt val)
 
Int128 Int128Mul (long64 lhs, long64 rhs)
 
double Area (const OutPt *op)
 
double Area (const OutRec &outRec)
 
bool PointIsVertex (const IntPoint &Pt, OutPt *pp)
 
int PointInPolygon (const IntPoint &pt, OutPt *op)
 
bool Poly2ContainsPoly1 (OutPt *OutPt1, OutPt *OutPt2)
 
bool SlopesEqual (const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
 
bool SlopesEqual (const IntPoint pt1, const IntPoint pt2, const IntPoint pt3, bool UseFullInt64Range)
 
bool SlopesEqual (const IntPoint pt1, const IntPoint pt2, const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
 
bool IsHorizontal (TEdge &e)
 
double GetDx (const IntPoint pt1, const IntPoint pt2)
 
void SetDx (TEdge &e)
 
void SwapSides (TEdge &Edge1, TEdge &Edge2)
 
void SwapPolyIndexes (TEdge &Edge1, TEdge &Edge2)
 
cInt TopX (TEdge &edge, const cInt currentY)
 
void IntersectPoint (TEdge &Edge1, TEdge &Edge2, IntPoint &ip)
 
void ReversePolyPtLinks (OutPt *pp)
 
void DisposeOutPts (OutPt *&pp)
 
void InitEdge (TEdge *e, TEdge *eNext, TEdge *ePrev, const IntPoint &Pt)
 
void InitEdge2 (TEdge &e, PolyType Pt)
 
TEdgeRemoveEdge (TEdge *e)
 
void ReverseHorizontal (TEdge &e)
 
void SwapPoints (IntPoint &pt1, IntPoint &pt2)
 
bool GetOverlapSegment (IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
 
bool FirstIsBottomPt (const OutPt *btmPt1, const OutPt *btmPt2)
 
OutPtGetBottomPt (OutPt *pp)
 
bool Pt2IsBetweenPt1AndPt3 (const IntPoint pt1, const IntPoint pt2, const IntPoint pt3)
 
bool HorzSegmentsOverlap (cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
 
void RangeTest (const IntPoint &Pt, bool &useFullRange)
 
TEdgeFindNextLocMin (TEdge *E)
 
OutRecGetLowermostRec (OutRec *outRec1, OutRec *outRec2)
 
bool OutRec1RightOfOutRec2 (OutRec *outRec1, OutRec *outRec2)
 
bool IsMinima (TEdge *e)
 
bool IsMaxima (TEdge *e, const cInt Y)
 
bool IsIntermediate (TEdge *e, const cInt Y)
 
TEdgeGetMaximaPair (TEdge *e)
 
TEdgeGetMaximaPairEx (TEdge *e)
 
TEdgeGetNextInAEL (TEdge *e, Direction dir)
 
void GetHorzDirection (TEdge &HorzEdge, Direction &Dir, cInt &Left, cInt &Right)
 
bool IntersectListSort (IntersectNode *node1, IntersectNode *node2)
 
bool EdgesAdjacent (const IntersectNode &inode)
 
int PointCount (OutPt *Pts)
 
void SwapIntersectNodes (IntersectNode &int1, IntersectNode &int2)
 
bool E2InsertsBeforeE1 (TEdge &e1, TEdge &e2)
 
bool GetOverlap (const cInt a1, const cInt a2, const cInt b1, const cInt b2, cInt &Left, cInt &Right)
 
void UpdateOutPtIdxs (OutRec &outrec)
 
OutPtDupOutPt (OutPt *outPt, bool InsertAfter)
 
bool JoinHorz (OutPt *op1, OutPt *op1b, OutPt *op2, OutPt *op2b, const IntPoint Pt, bool DiscardLeft)
 
static OutRecParseFirstLeft (OutRec *FirstLeft)
 
DoublePoint GetUnitNormal (const IntPoint &pt1, const IntPoint &pt2)
 
double DistanceSqrd (const IntPoint &pt1, const IntPoint &pt2)
 
double DistanceFromLineSqrd (const IntPoint &pt, const IntPoint &ln1, const IntPoint &ln2)
 
bool SlopesNearCollinear (const IntPoint &pt1, const IntPoint &pt2, const IntPoint &pt3, double distSqrd)
 
bool PointsAreClose (IntPoint pt1, IntPoint pt2, double distSqrd)
 
OutPtExcludeOp (OutPt *op)
 
void Minkowski (const Path &poly, const Path &path, Paths &solution, bool isSum, bool isClosed)
 
void TranslatePath (const Path &input, Path &output, const IntPoint delta)
 
void AddPolyNodeToPaths (const PolyNode &polynode, NodeType nodetype, Paths &paths)
 

Variables

static const cInt loRange = 0x3FFFFFFF
 
static const cInt hiRange = 0x3FFFFFFFFFFFFFFFLL
 
static const double pi = 3.141592653589793238
 
static const double two_pi = pi *2
 
static const double def_arc_tolerance = 0.25
 
static const int Unassigned = -1
 
static const int Skip = -2
 

Typedef Documentation

◆ cInt

typedef signed long long ClipperLib::cInt

Definition at line 77 of file clipper.hpp.

◆ EdgeList

typedef std::vector< TEdge* > ClipperLib::EdgeList

Definition at line 209 of file clipper.hpp.

◆ IntersectList

typedef std::vector< IntersectNode* > ClipperLib::IntersectList

Definition at line 211 of file clipper.hpp.

◆ JoinList

typedef std::vector< Join* > ClipperLib::JoinList

Definition at line 210 of file clipper.hpp.

◆ long64

typedef signed long long ClipperLib::long64

Definition at line 80 of file clipper.hpp.

◆ Path

typedef std::vector< IntPoint > ClipperLib::Path

Definition at line 106 of file clipper.hpp.

◆ Paths

typedef std::vector< Path > ClipperLib::Paths

Definition at line 107 of file clipper.hpp.

◆ PolyNodes

typedef std::vector< PolyNode* > ClipperLib::PolyNodes

Definition at line 133 of file clipper.hpp.

◆ PolyOutList

typedef std::vector< OutRec* > ClipperLib::PolyOutList

Definition at line 206 of file clipper.hpp.

◆ ulong64

typedef unsigned long long ClipperLib::ulong64

Definition at line 81 of file clipper.hpp.

Enumeration Type Documentation

◆ ClipType

Enumerator
ctIntersection 
ctUnion 
ctDifference 
ctXor 

Definition at line 64 of file clipper.hpp.

◆ Direction

Enumerator
dRightToLeft 
dLeftToRight 

Definition at line 93 of file clipper.cpp.

102 {

◆ EdgeSide

Enumerator
esLeft 
esRight 

Definition at line 198 of file clipper.hpp.

198 { esLeft = 1, esRight = 2};

◆ EndType

Enumerator
etClosedPolygon 
etClosedLine 
etOpenButt 
etOpenSquare 
etOpenRound 

Definition at line 131 of file clipper.hpp.

◆ InitOptions

Enumerator
ioReverseSolution 
ioStrictlySimple 
ioPreserveCollinear 

Definition at line 129 of file clipper.hpp.

◆ JoinType

Enumerator
jtSquare 
jtRound 
jtMiter 

Definition at line 130 of file clipper.hpp.

◆ NodeType

Enumerator
ntAny 
ntOpen 
ntClosed 

Definition at line 4589 of file clipper.cpp.

◆ PolyFillType

Enumerator
pftEvenOdd 
pftNonZero 
pftPositive 
pftNegative 

Definition at line 70 of file clipper.hpp.

◆ PolyType

Enumerator
ptSubject 
ptClip 

Definition at line 65 of file clipper.hpp.

65 { ptSubject, ptClip };

Function Documentation

◆ Abs()

cInt ClipperLib::Abs ( cInt  val)
inline

Definition at line 179 of file clipper.cpp.

182  : Childs(), Parent(0), Index(0), m_IsOpen(false)

◆ AddPolyNodeToPaths()

void ClipperLib::AddPolyNodeToPaths ( const PolyNode polynode,
NodeType  nodetype,
Paths paths 
)

Definition at line 4591 of file clipper.cpp.

4596 {
4597  s << "(" << p.X << "," << p.Y << ")";
4598  return s;
4599 }
4600 //------------------------------------------------------------------------------
4601 

◆ Area() [1/3]

double ClipperLib::Area ( const OutPt op)

Definition at line 442 of file clipper.cpp.

448  {
449  IntPoint ipNext = (i == cnt ? path[0] : path[i]);
450  if (ipNext.Y == pt.Y)
451  {
452  if ((ipNext.X == pt.X) || (ip.Y == pt.Y &&

◆ Area() [2/3]

double ClipperLib::Area ( const OutRec outRec)

Definition at line 455 of file clipper.cpp.

456  {
457  if (ip.X >= pt.X)
458  {

◆ Area() [3/3]

double ClipperLib::Area ( const Path poly)

Definition at line 427 of file clipper.cpp.

429  {
430  if (pp2->Pt == Pt) return true;
431  pp2 = pp2->Next;
432  }
433  while (pp2 != pp);
434  return false;
435 }
436 //------------------------------------------------------------------------------
437 
438 //See "The Point in Polygon Problem for Arbitrary Polygons" by Hormann & Agathos
439 //http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.88.5498&rep=rep1&type=pdf

◆ CleanPolygon() [1/2]

void ClipperLib::CleanPolygon ( const Path in_poly,
Path out_poly,
double  distance = 1.415 
)

Definition at line 4419 of file clipper.cpp.

4421  {
4422  op = ExcludeOp(op);
4423  size--;
4424  }
4425  else
4426  {
4427  op->Idx = 1;
4428  op = op->Next;
4429  }
4430  }
4431 
4432  if (size < 3) size = 0;
4433  out_poly.resize(size);
4434  for (size_t i = 0; i < size; ++i)
4435  {
4436  out_poly[i] = op->Pt;
4437  op = op->Next;
4438  }
4439  delete [] outPts;
4440 }
4441 //------------------------------------------------------------------------------
4442 
4443 void CleanPolygon(Path& poly, double distance)
4444 {
4445  CleanPolygon(poly, poly, distance);
4446 }
4447 //------------------------------------------------------------------------------
4448 
4449 void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance)
4450 {
4451  out_polys.resize(in_polys.size());
4452  for (Paths::size_type i = 0; i < in_polys.size(); ++i)
4453  CleanPolygon(in_polys[i], out_polys[i], distance);
4454 }
4455 //------------------------------------------------------------------------------
4456 
4457 void CleanPolygons(Paths& polys, double distance)
4458 {
4459  CleanPolygons(polys, polys, distance);
4460 }
4461 //------------------------------------------------------------------------------
4462 
4463 void Minkowski(const Path& poly, const Path& path,
4464  Paths& solution, bool isSum, bool isClosed)
4465 {
4466  int delta = (isClosed ? 1 : 0);
4467  size_t polyCnt = poly.size();
4468  size_t pathCnt = path.size();
4469  Paths pp;
4470  pp.reserve(pathCnt);
4471  if (isSum)
4472  for (size_t i = 0; i < pathCnt; ++i)
4473  {
4474  Path p;
4475  p.reserve(polyCnt);
4476  for (size_t j = 0; j < poly.size(); ++j)

◆ CleanPolygon() [2/2]

void ClipperLib::CleanPolygon ( Path poly,
double  distance = 1.415 
)

Definition at line 4479 of file clipper.cpp.

4482  {

◆ CleanPolygons() [1/2]

void ClipperLib::CleanPolygons ( const Paths in_polys,
Paths out_polys,
double  distance = 1.415 
)

Definition at line 4485 of file clipper.cpp.

4494  {

◆ CleanPolygons() [2/2]

void ClipperLib::CleanPolygons ( Paths polys,
double  distance = 1.415 
)

Definition at line 4493 of file clipper.cpp.

4494  {
4495  Path quad;
4496  quad.reserve(4);

◆ ClosedPathsFromPolyTree()

void ClipperLib::ClosedPathsFromPolyTree ( const PolyTree polytree,
Paths paths 
)

Definition at line 4612 of file clipper.cpp.

4614 {
4615  for (Paths::size_type i = 0; i < p.size(); i++)
4616  s << p[i];
4617  s << "\n";

◆ DisposeOutPts()

void ClipperLib::DisposeOutPts ( OutPt *&  pp)

Definition at line 742 of file clipper.cpp.

746 {
747  //removes e from double_linked_list (but without removing from memory)
748  e->Prev->Next = e->Next;
749  e->Next->Prev = e->Prev;
750  TEdge* result = e->Next;
751  e->Prev = 0; //flag as removed (see ClipperBase.Clear)
752  return result;

◆ DistanceFromLineSqrd()

double ClipperLib::DistanceFromLineSqrd ( const IntPoint pt,
const IntPoint ln1,
const IntPoint ln2 
)

Definition at line 4357 of file clipper.cpp.

4366 {
4367  double Dx = (double)pt1.X - pt2.X;
4368  double dy = (double)pt1.Y - pt2.Y;
4369  return ((Dx * Dx) + (dy * dy) <= distSqrd);
4370 }
4371 //------------------------------------------------------------------------------

◆ DistanceSqrd()

double ClipperLib::DistanceSqrd ( const IntPoint pt1,
const IntPoint pt2 
)
inline

Definition at line 4349 of file clipper.cpp.

4354  {

◆ DupOutPt()

OutPt* ClipperLib::DupOutPt ( OutPt outPt,
bool  InsertAfter 
)

Definition at line 3377 of file clipper.cpp.

3377  {
3378  while (op1->Next->Pt.X <= Pt.X &&
3379  op1->Next->Pt.X >= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
3380  op1 = op1->Next;
3381  if (DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
3382  op1b = DupOutPt(op1, !DiscardLeft);
3383  if (op1b->Pt != Pt)
3384  {
3385  op1 = op1b;
3386  op1->Pt = Pt;
3387  op1b = DupOutPt(op1, !DiscardLeft);
3388  }
3389  }
3390  else
3391  {
3392  while (op1->Next->Pt.X >= Pt.X &&
3393  op1->Next->Pt.X <= op1->Pt.X && op1->Next->Pt.Y == Pt.Y)
3394  op1 = op1->Next;
3395  if (!DiscardLeft && (op1->Pt.X != Pt.X)) op1 = op1->Next;
3396  op1b = DupOutPt(op1, DiscardLeft);
3397  if (op1b->Pt != Pt)

◆ E2InsertsBeforeE1()

bool ClipperLib::E2InsertsBeforeE1 ( TEdge e1,
TEdge e2 
)
inline

Definition at line 3307 of file clipper.cpp.

3313 {
3314  if(!m_ActiveEdges)
3315  {
3316  edge->PrevInAEL = 0;

◆ EdgesAdjacent()

bool ClipperLib::EdgesAdjacent ( const IntersectNode inode)
inline

Definition at line 2959 of file clipper.cpp.

2966  {

◆ ExcludeOp()

OutPt* ClipperLib::ExcludeOp ( OutPt op)

Definition at line 4409 of file clipper.cpp.

4410  {
4411  op = ExcludeOp(op);
4412  size--;
4413  }
4414  else if (PointsAreClose(op->Prev->Pt, op->Next->Pt, distSqrd))
4415  {
4416  ExcludeOp(op->Next);

◆ FindNextLocMin()

TEdge* ClipperLib::FindNextLocMin ( TEdge E)

Definition at line 947 of file clipper.cpp.

951  {
952  if (NextIsForward) Result = E->Next;
953  else Result = E->Prev;
954  }
955  else
956  {
957  //there are more edges in the bound beyond result starting with E
958  if (NextIsForward)
959  E = Result->Next;
960  else
961  E = Result->Prev;

◆ FirstIsBottomPt()

bool ClipperLib::FirstIsBottomPt ( const OutPt btmPt1,
const OutPt btmPt2 
)

Definition at line 834 of file clipper.cpp.

834  {
835  if (p->Pt.X < pp->Pt.X)
836  {
837  dups = 0;
838  pp = p;
839  } else
840  {
841  if (p->Next != pp && p->Prev != pp) dups = p;
842  }
843  }
844  p = p->Next;
845  }
846  if (dups)
847  {
848  //there appears to be at least 2 vertices at BottomPt so ...
849  while (dups != p)
850  {
851  if (!FirstIsBottomPt(p, dups)) pp = dups;
852  dups = dups->Next;
853  while (dups->Pt != pp->Pt) dups = dups->Next;
854  }
855  }

◆ GetBottomPt()

OutPt* ClipperLib::GetBottomPt ( OutPt pp)

Definition at line 858 of file clipper.cpp.

862 {
863  if ((pt1 == pt3) || (pt1 == pt2) || (pt3 == pt2))
864  return false;
865  else if (pt1.X != pt3.X)
866  return (pt2.X > pt1.X) == (pt2.X < pt3.X);
867  else
868  return (pt2.Y > pt1.Y) == (pt2.Y < pt3.Y);
869 }
870 //------------------------------------------------------------------------------
871 
872 bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
873 {
874  if (seg1a > seg1b) std::swap(seg1a, seg1b);
875  if (seg2a > seg2b) std::swap(seg2a, seg2b);
876  return (seg1a < seg2b) && (seg2a < seg1b);
877 }
878 
879 //------------------------------------------------------------------------------
880 // ClipperBase class methods ...
881 //------------------------------------------------------------------------------
882 
883 ClipperBase::ClipperBase() //constructor
884 {
885  m_CurrentLM = m_MinimaList.begin(); //begin() == end() here
886  m_UseFullRange = false;
887 }
888 //------------------------------------------------------------------------------
889 
890 ClipperBase::~ClipperBase() //destructor
891 {
892  Clear();
893 }

◆ GetDx()

double ClipperLib::GetDx ( const IntPoint  pt1,
const IntPoint  pt2 
)
inline

Definition at line 620 of file clipper.cpp.

623 {
624 #ifdef use_xyz

◆ GetHorzDirection()

void ClipperLib::GetHorzDirection ( TEdge HorzEdge,
Direction Dir,
cInt Left,
cInt Right 
)

Definition at line 2646 of file clipper.cpp.

2653  {
2654  //get the first maxima in range (X) ...
2655  if (dir == dLeftToRight)
2656  {
2657  maxIt = m_Maxima.begin();
2658  while (maxIt != m_Maxima.end() && *maxIt <= horzEdge->Bot.X) maxIt++;
2659  if (maxIt != m_Maxima.end() && *maxIt >= eLastHorz->Top.X)

◆ GetLowermostRec()

OutRec* ClipperLib::GetLowermostRec ( OutRec outRec1,
OutRec outRec2 
)

Definition at line 2363 of file clipper.cpp.

2368 {
2369  //get the start and ends of both output polygons ...
2370  OutRec *outRec1 = m_PolyOuts[e1->OutIdx];
2371  OutRec *outRec2 = m_PolyOuts[e2->OutIdx];
2372 
2373  OutRec *holeStateRec;
2374  if (OutRec1RightOfOutRec2(outRec1, outRec2))
2375  holeStateRec = outRec2;
2376  else if (OutRec1RightOfOutRec2(outRec2, outRec1))
2377  holeStateRec = outRec1;
2378  else
2379  holeStateRec = GetLowermostRec(outRec1, outRec2);
2380 

◆ GetMaximaPair()

TEdge* ClipperLib::GetMaximaPair ( TEdge e)

Definition at line 2574 of file clipper.cpp.

2575  {
2576  TEdge* Next = Edge1->NextInSEL;
2577  if( Next ) Next->PrevInSEL = Edge2;
2578  TEdge* Prev = Edge2->PrevInSEL;
2579  if( Prev ) Prev->NextInSEL = Edge1;
2580  Edge1->PrevInSEL = Prev;
2581  Edge1->NextInSEL = Edge2;

◆ GetMaximaPairEx()

TEdge* ClipperLib::GetMaximaPairEx ( TEdge e)

Definition at line 2584 of file clipper.cpp.

2586  {
2587  TEdge* Next = Edge1->NextInSEL;
2588  TEdge* Prev = Edge1->PrevInSEL;
2589  Edge1->NextInSEL = Edge2->NextInSEL;
2590  if( Edge1->NextInSEL ) Edge1->NextInSEL->PrevInSEL = Edge1;
2591  Edge1->PrevInSEL = Edge2->PrevInSEL;

◆ GetNextInAEL()

TEdge* ClipperLib::GetNextInAEL ( TEdge e,
Direction  dir 
)

Definition at line 2640 of file clipper.cpp.

◆ GetOverlap()

bool ClipperLib::GetOverlap ( const cInt  a1,
const cInt  a2,
const cInt  b1,
const cInt  b2,
cInt Left,
cInt Right 
)

Definition at line 3319 of file clipper.cpp.

3321  {
3322  edge->PrevInAEL = 0;
3323  edge->NextInAEL = m_ActiveEdges;
3324  m_ActiveEdges->PrevInAEL = edge;
3325  m_ActiveEdges = edge;
3326  }
3327  else
3328  {
3329  if(!startEdge) startEdge = m_ActiveEdges;
3330  while(startEdge->NextInAEL &&
3331  !E2InsertsBeforeE1(*startEdge->NextInAEL , *edge))
3332  startEdge = startEdge->NextInAEL;
3333  edge->NextInAEL = startEdge->NextInAEL;

◆ GetOverlapSegment()

bool ClipperLib::GetOverlapSegment ( IntPoint  pt1a,
IntPoint  pt1b,
IntPoint  pt2a,
IntPoint  pt2b,
IntPoint pt1,
IntPoint pt2 
)

Definition at line 812 of file clipper.cpp.

823 {
824  OutPt* dups = 0;
825  OutPt* p = pp->Next;
826  while (p != pp)
827  {
828  if (p->Pt.Y > pp->Pt.Y)
829  {
830  pp = p;
831  dups = 0;

◆ GetUnitNormal()

DoublePoint ClipperLib::GetUnitNormal ( const IntPoint pt1,
const IntPoint pt2 
)

Definition at line 3798 of file clipper.cpp.

3803 {
3804  int highI = (int)path.size() - 1;
3805  if (highI < 0) return;
3806  PolyNode* newNode = new PolyNode();
3807  newNode->m_jointype = joinType;
3808  newNode->m_endtype = endType;
3809 

◆ HorzSegmentsOverlap()

bool ClipperLib::HorzSegmentsOverlap ( cInt  seg1a,
cInt  seg1b,
cInt  seg2a,
cInt  seg2b 
)

Definition at line 908 of file clipper.cpp.

912 {
913  for (;;)

◆ InitEdge()

void ClipperLib::InitEdge ( TEdge e,
TEdge eNext,
TEdge ePrev,
const IntPoint Pt 
)
inline

Definition at line 755 of file clipper.cpp.

757 {
758  //swap horizontal edges' Top and Bottom x's so they follow the natural
759  //progression of the bounds - ie so their xbots will align with the
760  //adjoining lower edge. [Helpful in the ProcessHorizontal() method.]
761  std::swap(e.Top.X, e.Bot.X);
762 #ifdef use_xyz

◆ InitEdge2()

void ClipperLib::InitEdge2 ( TEdge e,
PolyType  Pt 
)

Definition at line 765 of file clipper.cpp.

769 {
770  IntPoint tmp = pt1;
771  pt1 = pt2;
772  pt2 = tmp;
773 }
774 //------------------------------------------------------------------------------
775 
776 bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a,
777  IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
778 {

◆ Int128Mul()

Int128 ClipperLib::Int128Mul ( long64  lhs,
long64  rhs 
)

Definition at line 390 of file clipper.cpp.

392 {
393  int size = (int)poly.size();
394  if (size < 3) return 0;
395 
396  double a = 0;
397  for (int i = 0, j = size -1; i < size; ++i)
398  {
399  a += ((double)poly[j].X + poly[i].X) * ((double)poly[j].Y - poly[i].Y);
400  j = i;
401  }
402  return -a * 0.5;
403 }
404 //------------------------------------------------------------------------------
405 
406 double Area(const OutPt *op)
407 {
408  const OutPt *startOp = op;
409  if (!op) return 0;
410  double a = 0;
411  do {
412  a += (double)(op->Prev->Pt.X + op->Pt.X) * (double)(op->Prev->Pt.Y - op->Pt.Y);
413  op = op->Next;
414  } while (op != startOp);

◆ IntersectListSort()

bool ClipperLib::IntersectListSort ( IntersectNode node1,
IntersectNode node2 
)

Definition at line 2953 of file clipper.cpp.

2954 {
2955  TEdge* eMaxPair = GetMaximaPairEx(e);
2956  if (!eMaxPair)

◆ IntersectPoint()

void ClipperLib::IntersectPoint ( TEdge Edge1,
TEdge Edge2,
IntPoint ip 
)

Definition at line 658 of file clipper.cpp.

658  {
659  b1 = Edge1.Bot.X - Edge1.Bot.Y * Edge1.Dx;
660  b2 = Edge2.Bot.X - Edge2.Bot.Y * Edge2.Dx;
661  double q = (b2-b1) / (Edge1.Dx - Edge2.Dx);
662  ip.Y = Round(q);
663  if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
664  ip.X = Round(Edge1.Dx * q + b1);
665  else
666  ip.X = Round(Edge2.Dx * q + b2);
667  }
668 
669  if (ip.Y < Edge1.Top.Y || ip.Y < Edge2.Top.Y)
670  {
671  if (Edge1.Top.Y > Edge2.Top.Y)
672  ip.Y = Edge1.Top.Y;
673  else
674  ip.Y = Edge2.Top.Y;
675  if (std::fabs(Edge1.Dx) < std::fabs(Edge2.Dx))
676  ip.X = TopX(Edge1, ip.Y);
677  else
678  ip.X = TopX(Edge2, ip.Y);
679  }
680  //finally, don't allow 'ip' to be BELOW curr.Y (ie bottom of scanbeam) ...
681  if (ip.Y > Edge1.Curr.Y)
682  {
683  ip.Y = Edge1.Curr.Y;
684  //use the more vertical edge to derive X ...
685  if (std::fabs(Edge1.Dx) > std::fabs(Edge2.Dx))
686  ip.X = TopX(Edge2, ip.Y); else
687  ip.X = TopX(Edge1, ip.Y);
688  }
689 }
690 //------------------------------------------------------------------------------
691 
692 void ReversePolyPtLinks(OutPt *pp)
693 {
694  if (!pp) return;
695  OutPt *pp1, *pp2;
696  pp1 = pp;
697  do {
698  pp2 = pp1->Next;
699  pp1->Next = pp1->Prev;
700  pp1->Prev = pp2;
701  pp1 = pp2;
702  } while( pp1 != pp );
703 }
704 //------------------------------------------------------------------------------
705 
706 void DisposeOutPts(OutPt*& pp)
707 {
708  if (pp == 0) return;
709  pp->Prev->Next = 0;
710  while( pp )
711  {
712  OutPt *tmpPp = pp;
713  pp = pp->Next;
714  delete tmpPp;
715  }
716 }
717 //------------------------------------------------------------------------------
718 
719 inline void InitEdge(TEdge* e, TEdge* eNext, TEdge* ePrev, const IntPoint& Pt)
720 {
721  std::memset(e, 0, sizeof(TEdge));
722  e->Next = eNext;
723  e->Prev = ePrev;
724  e->Curr = Pt;
725  e->OutIdx = Unassigned;

◆ IsHorizontal()

bool ClipperLib::IsHorizontal ( TEdge e)
inline

Definition at line 614 of file clipper.cpp.

616 {
617  return ( currentY == edge.Top.Y ) ?

◆ IsIntermediate()

bool ClipperLib::IsIntermediate ( TEdge e,
const cInt  Y 
)
inline

Definition at line 2568 of file clipper.cpp.

2575  {

◆ IsMaxima()

bool ClipperLib::IsMaxima ( TEdge e,
const cInt  Y 
)
inline

Definition at line 2562 of file clipper.cpp.

2564  {
2565  TEdge* Next = Edge2->NextInSEL;

◆ IsMinima()

bool ClipperLib::IsMinima ( TEdge e)
inline

Definition at line 2556 of file clipper.cpp.

2559 {

◆ JoinHorz()

bool ClipperLib::JoinHorz ( OutPt op1,
OutPt op1b,
OutPt op2,
OutPt op2b,
const IntPoint  Pt,
bool  DiscardLeft 
)

Definition at line 3400 of file clipper.cpp.

3406  {
3407  while (op2->Next->Pt.X <= Pt.X &&
3408  op2->Next->Pt.X >= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
3409  op2 = op2->Next;
3410  if (DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
3411  op2b = DupOutPt(op2, !DiscardLeft);
3412  if (op2b->Pt != Pt)
3413  {
3414  op2 = op2b;
3415  op2->Pt = Pt;
3416  op2b = DupOutPt(op2, !DiscardLeft);
3417  };
3418  } else
3419  {
3420  while (op2->Next->Pt.X >= Pt.X &&
3421  op2->Next->Pt.X <= op2->Pt.X && op2->Next->Pt.Y == Pt.Y)
3422  op2 = op2->Next;
3423  if (!DiscardLeft && (op2->Pt.X != Pt.X)) op2 = op2->Next;
3424  op2b = DupOutPt(op2, DiscardLeft);
3425  if (op2b->Pt != Pt)
3426  {
3427  op2 = op2b;
3428  op2->Pt = Pt;
3429  op2b = DupOutPt(op2, DiscardLeft);
3430  };
3431  };
3432 
3433  if ((Dir1 == dLeftToRight) == DiscardLeft)
3434  {
3435  op1->Prev = op2;
3436  op2->Next = op1;
3437  op1b->Next = op2b;
3438  op2b->Prev = op1b;
3439  }
3440  else
3441  {
3442  op1->Next = op2;
3443  op2->Prev = op1;
3444  op1b->Prev = op2b;
3445  op2b->Next = op1b;
3446  }
3447  return true;
3448 }
3449 //------------------------------------------------------------------------------
3450 
3451 bool Clipper::JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2)
3452 {
3453  OutPt *op1 = j->OutPt1, *op1b;
3454  OutPt *op2 = j->OutPt2, *op2b;
3455 
3456  //There are 3 kinds of joins for output polygons ...
3457  //1. Horizontal joins where Join.OutPt1 & Join.OutPt2 are vertices anywhere
3458  //along (horizontal) collinear edges (& Join.OffPt is on the same horizontal).
3459  //2. Non-horizontal joins where Join.OutPt1 & Join.OutPt2 are at the same
3460  //location at the Bottom of the overlapping segment (& Join.OffPt is above).
3461  //3. StrictSimple joins where edges touch but are not collinear and where
3462  //Join.OutPt1, Join.OutPt2 & Join.OffPt all share the same point.
3463  bool isHorizontal = (j->OutPt1->Pt.Y == j->OffPt.Y);
3464 
3465  if (isHorizontal && (j->OffPt == j->OutPt1->Pt) &&
3466  (j->OffPt == j->OutPt2->Pt))
3467  {
3468  //Strictly Simple join ...
3469  if (outRec1 != outRec2) return false;
3470  op1b = j->OutPt1->Next;
3471  while (op1b != op1 && (op1b->Pt == j->OffPt))
3472  op1b = op1b->Next;
3473  bool reverse1 = (op1b->Pt.Y > j->OffPt.Y);
3474  op2b = j->OutPt2->Next;
3475  while (op2b != op2 && (op2b->Pt == j->OffPt))
3476  op2b = op2b->Next;
3477  bool reverse2 = (op2b->Pt.Y > j->OffPt.Y);
3478  if (reverse1 == reverse2) return false;
3479  if (reverse1)
3480  {
3481  op1b = DupOutPt(op1, false);
3482  op2b = DupOutPt(op2, true);
3483  op1->Prev = op2;
3484  op2->Next = op1;

◆ Minkowski()

void ClipperLib::Minkowski ( const Path poly,
const Path path,
Paths solution,
bool  isSum,
bool  isClosed 
)

Definition at line 4499 of file clipper.cpp.

4508 {
4509  Minkowski(pattern, path, solution, true, pathIsClosed);
4510  Clipper c;
4511  c.AddPaths(solution, ptSubject, true);
4512  c.Execute(ctUnion, solution, pftNonZero, pftNonZero);
4513 }
4514 //------------------------------------------------------------------------------
4515 
4516 void TranslatePath(const Path& input, Path& output, const IntPoint delta)
4517 {
4518  //precondition: input != output
4519  output.resize(input.size());
4520  for (size_t i = 0; i < input.size(); ++i)
4521  output[i] = IntPoint(input[i].X + delta.X, input[i].Y + delta.Y);
4522 }
4523 //------------------------------------------------------------------------------
4524 
4525 void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed)
4526 {
4527  Clipper c;
4528  for (size_t i = 0; i < paths.size(); ++i)
4529  {
4530  Paths tmp;
4531  Minkowski(pattern, paths[i], tmp, true, pathIsClosed);
4532  c.AddPaths(tmp, ptSubject, true);
4533  if (pathIsClosed)
4534  {
4535  Path tmp2;
4536  TranslatePath(paths[i], tmp2, pattern[0]);
4537  c.AddPath(tmp2, ptClip, true);
4538  }
4539  }
4540  c.Execute(ctUnion, solution, pftNonZero, pftNonZero);

◆ MinkowskiDiff()

void ClipperLib::MinkowskiDiff ( const Path poly1,
const Path poly2,
Paths solution 
)

Definition at line 4580 of file clipper.cpp.

4585 {
4586  paths.resize(0);

◆ MinkowskiSum() [1/2]

void ClipperLib::MinkowskiSum ( const Path pattern,
const Path path,
Paths solution,
bool  pathIsClosed 
)

Definition at line 4543 of file clipper.cpp.

4545 {
4546  Minkowski(poly1, poly2, solution, false, true);
4547  Clipper c;
4548  c.AddPaths(solution, ptSubject, true);
4549  c.Execute(ctUnion, solution, pftNonZero, pftNonZero);

◆ MinkowskiSum() [2/2]

void ClipperLib::MinkowskiSum ( const Path pattern,
const Paths paths,
Paths solution,
bool  pathIsClosed 
)

Definition at line 4561 of file clipper.cpp.

4569 {
4570  paths.resize(0);
4571  paths.reserve(polytree.Total());
4572  AddPolyNodeToPaths(polytree, ntAny, paths);
4573 }
4574 //------------------------------------------------------------------------------
4575 
4576 void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths)
4577 {

◆ OpenPathsFromPolyTree()

void ClipperLib::OpenPathsFromPolyTree ( PolyTree polytree,
Paths paths 
)

Definition at line 4620 of file clipper.cpp.

◆ operator<<() [1/5]

Path& ClipperLib::operator<< ( Path poly,
const IntPoint p 
)
inline

Definition at line 109 of file clipper.hpp.

109 {poly.push_back(p); return poly;}

◆ operator<<() [2/5]

Paths& ClipperLib::operator<< ( Paths polys,
const Path p 
)
inline

Definition at line 110 of file clipper.hpp.

110 {polys.push_back(p); return polys;}

◆ operator<<() [3/5]

std::ostream & ClipperLib::operator<< ( std::ostream &  s,
const IntPoint p 
)

Definition at line 4631 of file clipper.cpp.

◆ operator<<() [4/5]

std::ostream & ClipperLib::operator<< ( std::ostream &  s,
const Path p 
)

Definition at line 4638 of file clipper.cpp.

◆ operator<<() [5/5]

std::ostream & ClipperLib::operator<< ( std::ostream &  s,
const Paths p 
)

Definition at line 4649 of file clipper.cpp.

◆ Orientation()

bool ClipperLib::Orientation ( const Path poly)

Definition at line 421 of file clipper.cpp.

426 {

◆ OutRec1RightOfOutRec2()

bool ClipperLib::OutRec1RightOfOutRec2 ( OutRec outRec1,
OutRec outRec2 
)

Definition at line 2383 of file clipper.cpp.

2391  {

◆ ParseFirstLeft()

static OutRec* ClipperLib::ParseFirstLeft ( OutRec FirstLeft)
static

Definition at line 3646 of file clipper.cpp.

◆ PointCount()

int ClipperLib::PointCount ( OutPt Pts)

Definition at line 3213 of file clipper.cpp.

3214 {
3215  polytree.Clear();
3216  polytree.AllNodes.reserve(m_PolyOuts.size());
3217  //add each output polygon/contour to polytree ...
3218  for (PolyOutList::size_type i = 0; i < m_PolyOuts.size(); i++)
3219  {
3220  OutRec* outRec = m_PolyOuts[i];
3221  int cnt = PointCount(outRec->Pts);
3222  if ((outRec->IsOpen && cnt < 2) || (!outRec->IsOpen && cnt < 3)) continue;
3223  FixHoleLinkage(*outRec);
3224  PolyNode* pn = new PolyNode();
3225  //nb: polytree takes ownership of all the PolyNodes

◆ PointInPolygon() [1/2]

int ClipperLib::PointInPolygon ( const IntPoint pt,
const Path path 
)

Definition at line 476 of file clipper.cpp.

485 {
486  //returns 0 if false, +1 if true, -1 if pt ON polygon boundary
487  int result = 0;
488  OutPt* startOp = op;
489  for(;;)
490  {
491  if (op->Next->Pt.Y == pt.Y)
492  {
493  if ((op->Next->Pt.X == pt.X) || (op->Pt.Y == pt.Y &&
494  ((op->Next->Pt.X > pt.X) == (op->Pt.X < pt.X)))) return -1;
495  }
496  if ((op->Pt.Y < pt.Y) != (op->Next->Pt.Y < pt.Y))
497  {
498  if (op->Pt.X >= pt.X)
499  {
500  if (op->Next->Pt.X > pt.X) result = 1 - result;
501  else
502  {
503  double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
504  (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
505  if (!d) return -1;
506  if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
507  }
508  } else
509  {
510  if (op->Next->Pt.X > pt.X)
511  {
512  double d = (double)(op->Pt.X - pt.X) * (op->Next->Pt.Y - pt.Y) -
513  (double)(op->Next->Pt.X - pt.X) * (op->Pt.Y - pt.Y);
514  if (!d) return -1;
515  if ((d > 0) == (op->Next->Pt.Y > op->Pt.Y)) result = 1 - result;
516  }
517  }

◆ PointInPolygon() [2/2]

int ClipperLib::PointInPolygon ( const IntPoint pt,
OutPt op 
)

Definition at line 520 of file clipper.cpp.

527 {
528  OutPt* op = OutPt1;
529  do
530  {
531  //nb: PointInPolygon returns 0 if false, +1 if true, -1 if pt on polygon
532  int res = PointInPolygon(op->Pt, OutPt2);
533  if (res >= 0) return res > 0;
534  op = op->Next;
535  }
536  while (op != OutPt1);
537  return true;
538 }
539 //----------------------------------------------------------------------
540 
541 bool SlopesEqual(const TEdge &e1, const TEdge &e2, bool UseFullInt64Range)
542 {
543 #ifndef use_int32
544  if (UseFullInt64Range)
545  return Int128Mul(e1.Top.Y - e1.Bot.Y, e2.Top.X - e2.Bot.X) ==
546  Int128Mul(e1.Top.X - e1.Bot.X, e2.Top.Y - e2.Bot.Y);
547  else
548 #endif
549  return (e1.Top.Y - e1.Bot.Y) * (e2.Top.X - e2.Bot.X) ==
550  (e1.Top.X - e1.Bot.X) * (e2.Top.Y - e2.Bot.Y);
551 }
552 //------------------------------------------------------------------------------
553 
554 bool SlopesEqual(const IntPoint pt1, const IntPoint pt2,
555  const IntPoint pt3, bool UseFullInt64Range)
556 {
557 #ifndef use_int32
558  if (UseFullInt64Range)
559  return Int128Mul(pt1.Y-pt2.Y, pt2.X-pt3.X) == Int128Mul(pt1.X-pt2.X, pt2.Y-pt3.Y);

◆ PointIsVertex()

bool ClipperLib::PointIsVertex ( const IntPoint Pt,
OutPt pp 
)

Definition at line 461 of file clipper.cpp.

461  {
462  double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -
463  (double)(ipNext.X - pt.X) * (ip.Y - pt.Y);
464  if (!d) return -1;
465  if ((d > 0) == (ipNext.Y > ip.Y)) result = 1 - result;
466  }
467  } else
468  {
469  if (ipNext.X > pt.X)
470  {
471  double d = (double)(ip.X - pt.X) * (ipNext.Y - pt.Y) -

◆ PointsAreClose()

bool ClipperLib::PointsAreClose ( IntPoint  pt1,
IntPoint  pt2,
double  distSqrd 
)

Definition at line 4401 of file clipper.cpp.

4408  {

◆ Poly2ContainsPoly1()

bool ClipperLib::Poly2ContainsPoly1 ( OutPt OutPt1,
OutPt OutPt2 
)

Definition at line 562 of file clipper.cpp.

568 {
569 #ifndef use_int32
570  if (UseFullInt64Range)
571  return Int128Mul(pt1.Y-pt2.Y, pt3.X-pt4.X) == Int128Mul(pt1.X-pt2.X, pt3.Y-pt4.Y);
572  else
573 #endif
574  return (pt1.Y-pt2.Y)*(pt3.X-pt4.X) == (pt1.X-pt2.X)*(pt3.Y-pt4.Y);

◆ PolyTreeToPaths()

void ClipperLib::PolyTreeToPaths ( const PolyTree polytree,
Paths paths 
)

Definition at line 4604 of file clipper.cpp.

◆ Pt2IsBetweenPt1AndPt3()

bool ClipperLib::Pt2IsBetweenPt1AndPt3 ( const IntPoint  pt1,
const IntPoint  pt2,
const IntPoint  pt3 
)

Definition at line 896 of file clipper.cpp.

897 {
898  if (useFullRange)
899  {
900  if (Pt.X > hiRange || Pt.Y > hiRange || -Pt.X > hiRange || -Pt.Y > hiRange)
901  throw clipperException("Coordinate outside allowed range");
902  }
903  else if (Pt.X > loRange|| Pt.Y > loRange || -Pt.X > loRange || -Pt.Y > loRange)
904  {
905  useFullRange = true;

◆ RangeTest()

void ClipperLib::RangeTest ( const IntPoint Pt,
bool useFullRange 
)

Definition at line 932 of file clipper.cpp.

934  {
935  //if edges still remain in the current bound beyond the skip edge then
936  //create another LocMin and call ProcessBound once more
937  if (NextIsForward)
938  {
939  while (E->Top.Y == E->Next->Bot.Y) E = E->Next;
940  //don't include top horizontals when parsing a bound a second time,
941  //they will be contained in the opposite bound ...
942  while (E != Result && IsHorizontal(*E)) E = E->Prev;
943  }
944  else

◆ RemoveEdge()

TEdge* ClipperLib::RemoveEdge ( TEdge e)

Definition at line 781 of file clipper.cpp.

781  {
782  if (pt1a.X > pt1b.X) SwapPoints(pt1a, pt1b);
783  if (pt2a.X > pt2b.X) SwapPoints(pt2a, pt2b);
784  if (pt1a.X > pt2a.X) pt1 = pt1a; else pt1 = pt2a;
785  if (pt1b.X < pt2b.X) pt2 = pt1b; else pt2 = pt2b;
786  return pt1.X < pt2.X;
787  } else
788  {
789  if (pt1a.Y < pt1b.Y) SwapPoints(pt1a, pt1b);

◆ ReverseHorizontal()

void ClipperLib::ReverseHorizontal ( TEdge e)
inline

Definition at line 792 of file clipper.cpp.

799 {
800  OutPt *p = btmPt1->Prev;
801  while ((p->Pt == btmPt1->Pt) && (p != btmPt1)) p = p->Prev;

◆ ReversePath()

void ClipperLib::ReversePath ( Path p)

Definition at line 4312 of file clipper.cpp.

4314 {
4315  double Dx = ((double)pt1.X - pt2.X);

◆ ReversePaths()

void ClipperLib::ReversePaths ( Paths p)

Definition at line 4318 of file clipper.cpp.

4323 {

◆ ReversePolyPtLinks()

void ClipperLib::ReversePolyPtLinks ( OutPt pp)

Definition at line 728 of file clipper.cpp.

730 {
731  if (e.Curr.Y >= e.Next->Curr.Y)
732  {
733  e.Bot = e.Curr;
734  e.Top = e.Next->Curr;
735  } else
736  {
737  e.Top = e.Curr;
738  e.Bot = e.Next->Curr;
739  }

◆ Round()

cInt ClipperLib::Round ( double  val)
inline

Definition at line 172 of file clipper.cpp.

◆ SetDx()

void ClipperLib::SetDx ( TEdge e)
inline

Definition at line 627 of file clipper.cpp.

630  {
631  ip.Y = Edge1.Curr.Y;
632  ip.X = TopX(Edge1, ip.Y);

◆ SimplifyPolygon()

void ClipperLib::SimplifyPolygon ( const Path in_poly,
Paths out_polys,
PolyFillType  fillType = pftEvenOdd 
)

Definition at line 4325 of file clipper.cpp.

4340 {

◆ SimplifyPolygons() [1/2]

void ClipperLib::SimplifyPolygons ( const Paths in_polys,
Paths out_polys,
PolyFillType  fillType = pftEvenOdd 
)

Definition at line 4334 of file clipper.cpp.

4340 {

◆ SimplifyPolygons() [2/2]

void ClipperLib::SimplifyPolygons ( Paths polys,
PolyFillType  fillType = pftEvenOdd 
)

Definition at line 4343 of file clipper.cpp.

4345  {
4346  if ((pt1.X > pt2.X) == (pt1.X < pt3.X))

◆ SlopesEqual() [1/3]

bool ClipperLib::SlopesEqual ( const IntPoint  pt1,
const IntPoint  pt2,
const IntPoint  pt3,
bool  UseFullInt64Range 
)

Definition at line 590 of file clipper.cpp.

592 {
593  cInt dy = (e.Top.Y - e.Bot.Y);
594  if (dy == 0) e.Dx = HORIZONTAL;
595  else e.Dx = (double)(e.Top.X - e.Bot.X) / dy;
596 }
597 //---------------------------------------------------------------------------
598 
599 inline void SwapSides(TEdge &Edge1, TEdge &Edge2)

◆ SlopesEqual() [2/3]

bool ClipperLib::SlopesEqual ( const IntPoint  pt1,
const IntPoint  pt2,
const IntPoint  pt3,
const IntPoint  pt4,
bool  UseFullInt64Range 
)

Definition at line 602 of file clipper.cpp.

608 {
609  int OutIdx = Edge1.OutIdx;
610  Edge1.OutIdx = Edge2.OutIdx;
611  Edge2.OutIdx = OutIdx;

◆ SlopesEqual() [3/3]

bool ClipperLib::SlopesEqual ( const TEdge e1,
const TEdge e2,
bool  UseFullInt64Range 
)

Definition at line 577 of file clipper.cpp.

579 {
580  return e.Dx == HORIZONTAL;
581 }
582 //------------------------------------------------------------------------------
583 
584 inline double GetDx(const IntPoint pt1, const IntPoint pt2)
585 {
586  return (pt1.Y == pt2.Y) ?
587  HORIZONTAL : (double)(pt2.X - pt1.X) / (pt2.Y - pt1.Y);

◆ SlopesNearCollinear()

bool ClipperLib::SlopesNearCollinear ( const IntPoint pt1,
const IntPoint pt2,
const IntPoint pt3,
double  distSqrd 
)

Definition at line 4374 of file clipper.cpp.

4374 {
4375  OutPt* result = op->Prev;
4376  result->Next = op->Next;
4377  op->Next->Prev = result;
4378  result->Idx = 0;
4379  return result;
4380 }
4381 //------------------------------------------------------------------------------
4382 
4383 void CleanPolygon(const Path& in_poly, Path& out_poly, double distance)
4384 {
4385  //distance = proximity in units/pixels below which vertices
4386  //will be stripped. Default ~= sqrt(2).
4387 
4388  size_t size = in_poly.size();
4389 
4390  if (size == 0)
4391  {
4392  out_poly.clear();
4393  return;
4394  }
4395 
4396  OutPt* outPts = new OutPt[size];
4397  for (size_t i = 0; i < size; ++i)
4398  {

◆ SwapIntersectNodes()

void ClipperLib::SwapIntersectNodes ( IntersectNode int1,
IntersectNode int2 
)

Definition at line 3294 of file clipper.cpp.

3294  {Left = std::max(a2,b2); Right = std::min(a1,b1);}
3295  }
3296  return Left < Right;
3297 }
3298 //------------------------------------------------------------------------------
3299 
3300 inline void UpdateOutPtIdxs(OutRec& outrec)
3301 {
3302  OutPt* op = outrec.Pts;
3303  do
3304  {

◆ SwapPoints()

void ClipperLib::SwapPoints ( IntPoint pt1,
IntPoint pt2 
)

Definition at line 804 of file clipper.cpp.

◆ SwapPolyIndexes()

void ClipperLib::SwapPolyIndexes ( TEdge Edge1,
TEdge Edge2 
)
inline

Definition at line 643 of file clipper.cpp.

647  {
648  ip.X = Edge2.Bot.X;

◆ SwapSides()

void ClipperLib::SwapSides ( TEdge Edge1,
TEdge Edge2 
)
inline

Definition at line 635 of file clipper.cpp.

636  {
637  ip.X = Edge1.Bot.X;
638  if (IsHorizontal(Edge2))
639  ip.Y = Edge2.Bot.Y;
640  else

◆ TopX()

cInt ClipperLib::TopX ( TEdge edge,
const cInt  currentY 
)
inline

Definition at line 651 of file clipper.cpp.

652  {
653  b1 = Edge1.Bot.Y - (Edge1.Bot.X / Edge1.Dx);
654  ip.Y = Round(ip.X / Edge1.Dx + b1);
655  }

◆ TranslatePath()

void ClipperLib::TranslatePath ( const Path input,
Path output,
const IntPoint  delta 
)

Definition at line 4552 of file clipper.cpp.

4553  {ntAny, ntOpen, ntClosed};
4554 
4555 void AddPolyNodeToPaths(const PolyNode& polynode, NodeType nodetype, Paths& paths)
4556 {
4557  bool match = true;
4558  if (nodetype == ntClosed) match = !polynode.IsOpen();

◆ UpdateOutPtIdxs()

void ClipperLib::UpdateOutPtIdxs ( OutRec outrec)
inline

Definition at line 3336 of file clipper.cpp.

3342 {
3343  OutPt* result = new OutPt;
3344  result->Pt = outPt->Pt;
3345  result->Idx = outPt->Idx;

Variable Documentation

◆ def_arc_tolerance

const double ClipperLib::def_arc_tolerance = 0.25
static

Definition at line 91 of file clipper.cpp.

◆ hiRange

const cInt ClipperLib::hiRange = 0x3FFFFFFFFFFFFFFFLL
static

Definition at line 79 of file clipper.hpp.

◆ loRange

const cInt ClipperLib::loRange = 0x3FFFFFFF
static

Definition at line 78 of file clipper.hpp.

◆ pi

const double ClipperLib::pi = 3.141592653589793238
static
Examples
elasticity.cpp.

Definition at line 89 of file clipper.cpp.

◆ Skip

const int ClipperLib::Skip = -2
static

Definition at line 96 of file clipper.cpp.

◆ two_pi

const double ClipperLib::two_pi = pi *2
static

Definition at line 90 of file clipper.cpp.

◆ Unassigned

const int ClipperLib::Unassigned = -1
static

Definition at line 95 of file clipper.cpp.

ClipperLib::loRange
static const cInt loRange
Definition: clipper.hpp:78
a2
constexpr double a2
Definition: hcurl_check_approx_in_2d.cpp:39
ClipperLib::Path
std::vector< IntPoint > Path
Definition: clipper.hpp:106
ClipperLib::ioStrictlySimple
@ ioStrictlySimple
Definition: clipper.hpp:129
ClipperLib::Paths
std::vector< Path > Paths
Definition: clipper.hpp:107
ClipperLib::DisposeOutPts
void DisposeOutPts(OutPt *&pp)
Definition: clipper.cpp:742
ClipperLib::jtSquare
@ jtSquare
Definition: clipper.hpp:130
sdf_hertz.d
float d
Definition: sdf_hertz.py:5
ClipperLib::GetLowermostRec
OutRec * GetLowermostRec(OutRec *outRec1, OutRec *outRec2)
Definition: clipper.cpp:2363
ClipperLib::TopX
cInt TopX(TEdge &edge, const cInt currentY)
Definition: clipper.cpp:651
ClipperLib::etClosedPolygon
@ etClosedPolygon
Definition: clipper.hpp:131
ClipperLib::E2InsertsBeforeE1
bool E2InsertsBeforeE1(TEdge &e1, TEdge &e2)
Definition: clipper.cpp:3307
ClipperLib::ctXor
@ ctXor
Definition: clipper.hpp:64
ClipperLib::pftPositive
@ pftPositive
Definition: clipper.hpp:70
ClipperLib::cInt
signed long long cInt
Definition: clipper.hpp:77
E
ClipperLib::PointCount
int PointCount(OutPt *Pts)
Definition: clipper.cpp:3213
ClipperLib::ptSubject
@ ptSubject
Definition: clipper.hpp:65
ClipperLib::Round
cInt Round(double val)
Definition: clipper.cpp:172
ClipperLib::GetMaximaPairEx
TEdge * GetMaximaPairEx(TEdge *e)
Definition: clipper.cpp:2584
ClipperLib::SwapPoints
void SwapPoints(IntPoint &pt1, IntPoint &pt2)
Definition: clipper.cpp:804
Index
Definition: single.cpp:3
ClipperLib::ctUnion
@ ctUnion
Definition: clipper.hpp:64
ClipperLib::CleanPolygon
void CleanPolygon(const Path &in_poly, Path &out_poly, double distance=1.415)
Definition: clipper.cpp:4419
ClipperLib::Minkowski
void Minkowski(const Path &poly, const Path &path, Paths &solution, bool isSum, bool isClosed)
Definition: clipper.cpp:4499
c
const double c
speed of light (cm/ns)
Definition: initial_diffusion.cpp:39
ClipperLib::ctDifference
@ ctDifference
Definition: clipper.hpp:64
ClipperLib::UpdateOutPtIdxs
void UpdateOutPtIdxs(OutRec &outrec)
Definition: clipper.cpp:3336
ClipperLib::ReversePolyPtLinks
void ReversePolyPtLinks(OutPt *pp)
Definition: clipper.cpp:728
ClipperLib::ioPreserveCollinear
@ ioPreserveCollinear
Definition: clipper.hpp:129
ClipperLib::ptClip
@ ptClip
Definition: clipper.hpp:65
ClipperLib::hiRange
static const cInt hiRange
Definition: clipper.hpp:79
ClipperLib::GetOverlapSegment
bool GetOverlapSegment(IntPoint pt1a, IntPoint pt1b, IntPoint pt2a, IntPoint pt2b, IntPoint &pt1, IntPoint &pt2)
Definition: clipper.cpp:812
ClipperLib::ntClosed
@ ntClosed
Definition: clipper.cpp:4589
a1
constexpr double a1
Definition: hcurl_check_approx_in_2d.cpp:38
ClipperLib::MinkowskiSum
void MinkowskiSum(const Path &pattern, const Path &path, Paths &solution, bool pathIsClosed)
Definition: clipper.cpp:4543
a
constexpr double a
Definition: approx_sphere.cpp:30
ClipperLib::etOpenSquare
@ etOpenSquare
Definition: clipper.hpp:131
ClipperLib::HorzSegmentsOverlap
bool HorzSegmentsOverlap(cInt seg1a, cInt seg1b, cInt seg2a, cInt seg2b)
Definition: clipper.cpp:908
delta
static constexpr double delta
Definition: prism_elements_from_surface.cpp:18
double
ClipperLib::ntAny
@ ntAny
Definition: clipper.cpp:4589
ClipperLib::SlopesEqual
bool SlopesEqual(const IntPoint pt1, const IntPoint pt2, const IntPoint pt3, const IntPoint pt4, bool UseFullInt64Range)
Definition: clipper.cpp:602
ClipperLib::dLeftToRight
@ dLeftToRight
Definition: clipper.cpp:93
ClipperLib::PointInPolygon
int PointInPolygon(const IntPoint &pt, OutPt *op)
Definition: clipper.cpp:520
ClipperLib::DupOutPt
OutPt * DupOutPt(OutPt *outPt, bool InsertAfter)
Definition: clipper.cpp:3377
ClipperLib::ClosedPathsFromPolyTree
void ClosedPathsFromPolyTree(const PolyTree &polytree, Paths &paths)
Definition: clipper.cpp:4612
ClipperLib::pftNegative
@ pftNegative
Definition: clipper.hpp:70
ClipperLib::Unassigned
static const int Unassigned
Definition: clipper.cpp:95
ClipperLib::TranslatePath
void TranslatePath(const Path &input, Path &output, const IntPoint delta)
Definition: clipper.cpp:4552
ClipperLib::AddPolyNodeToPaths
void AddPolyNodeToPaths(const PolyNode &polynode, NodeType nodetype, Paths &paths)
Definition: clipper.cpp:4591
ClipperLib::ntOpen
@ ntOpen
Definition: clipper.cpp:4589
ClipperLib::esRight
@ esRight
Definition: clipper.hpp:198
ClipperLib::GetDx
double GetDx(const IntPoint pt1, const IntPoint pt2)
Definition: clipper.cpp:620
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
ClipperLib::etOpenButt
@ etOpenButt
Definition: clipper.hpp:131
ClipperLib::jtMiter
@ jtMiter
Definition: clipper.hpp:130
ClipperLib::Area
double Area(const OutRec &outRec)
Definition: clipper.cpp:455
ClipperLib::CleanPolygons
void CleanPolygons(const Paths &in_polys, Paths &out_polys, double distance=1.415)
Definition: clipper.cpp:4485
ClipperLib::InitEdge
void InitEdge(TEdge *e, TEdge *eNext, TEdge *ePrev, const IntPoint &Pt)
Definition: clipper.cpp:755
ClipperLib::IsHorizontal
bool IsHorizontal(TEdge &e)
Definition: clipper.cpp:614
ClipperLib::pftEvenOdd
@ pftEvenOdd
Definition: clipper.hpp:70
ClipperLib::ioReverseSolution
@ ioReverseSolution
Definition: clipper.hpp:129
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
ClipperLib::pftNonZero
@ pftNonZero
Definition: clipper.hpp:70
ClipperLib::jtRound
@ jtRound
Definition: clipper.hpp:130
ClipperLib::esLeft
@ esLeft
Definition: clipper.hpp:198
ClipperLib::etClosedLine
@ etClosedLine
Definition: clipper.hpp:131
ClipperLib::ctIntersection
@ ctIntersection
Definition: clipper.hpp:64
ClipperLib::OutRec1RightOfOutRec2
bool OutRec1RightOfOutRec2(OutRec *outRec1, OutRec *outRec2)
Definition: clipper.cpp:2383
ClipperLib::SwapSides
void SwapSides(TEdge &Edge1, TEdge &Edge2)
Definition: clipper.cpp:635
convert.int
int
Definition: convert.py:64
ClipperLib::etOpenRound
@ etOpenRound
Definition: clipper.hpp:131
ClipperLib::Int128Mul
Int128 Int128Mul(long64 lhs, long64 rhs)
Definition: clipper.cpp:390
HORIZONTAL
#define HORIZONTAL
Definition: clipper.cpp:98
ClipperLib::NodeType
NodeType
Definition: clipper.cpp:4589
ClipperLib::ExcludeOp
OutPt * ExcludeOp(OutPt *op)
Definition: clipper.cpp:4409
ClipperLib::PointsAreClose
bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd)
Definition: clipper.cpp:4401
ClipperLib::FirstIsBottomPt
bool FirstIsBottomPt(const OutPt *btmPt1, const OutPt *btmPt2)
Definition: clipper.cpp:834