-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.cpp
More file actions
55 lines (43 loc) · 1.03 KB
/
example.cpp
File metadata and controls
55 lines (43 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "clipper.hpp"
using namespace ClipperLib;
Paths subj;
Paths clip;
Paths solution;
void addPoint(int x, int y, Path *path)
{
IntPoint ip;
ip.X = x;
ip.Y = y;
path->push_back(ip);
}
int main()
{
Paths subj;
Path p;
addPoint(100,100, &p);
addPoint(200,100, &p);
addPoint(200,200, &p);
addPoint(100,200, &p);
subj.push_back(p);
Path p2;
addPoint(150,50, &p2);
addPoint(175,50, &p2);
addPoint(175,250, &p2);
addPoint(150,250, &p2);
clip.push_back(p2);
Clipper c;
c.AddPaths(subj, ptSubject, true);
c.AddPaths(clip, ptClip, true);
c.Execute(ctIntersection, solution, pftNonZero, pftNonZero);
printf("solution size = %d\n",(int)solution.size());
for (unsigned i=0; i<solution.size(); i++)
{
Path p3 = solution.at(i);
for (unsigned j=0; j<p3.size(); j++)
{
IntPoint ip = p3.at(j);
printf("%d = %lld, %lld\n",j, ip.X,ip.Y);
}
}
return 0;
}