Repository navigation
Expand file tree
/
Copy pathBooleanOperations.h
More file actions
71 lines (61 loc) · 2.54 KB
/
Copy pathBooleanOperations.h
File metadata and controls
71 lines (61 loc) · 2.54 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef BOOLEAN_OPERATIONS_H
#define BOOLEAN_OPERATIONS_H
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <list>
#include <vector>
#include <iostream>
// Define the kernel for exact geometric predicates and constructions
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
namespace BooleanOperations {
/**
* Performs a union operation on two 2D polygons
* @param poly1 First polygon
* @param poly2 Second polygon
* @return A list containing the resulting polygon(s) with holes
*/
std::list<Polygon_with_holes_2> performUnion(const Polygon_2& poly1, const Polygon_2& poly2);
/**
* Performs an intersection operation on two 2D polygons
* @param poly1 First polygon
* @param poly2 Second polygon
* @return A list containing the resulting polygon(s) with holes
*/
std::list<Polygon_with_holes_2> performIntersection(const Polygon_2& poly1, const Polygon_2& poly2);
/**
* Performs a difference operation on two 2D polygons
* @param poly1 First polygon
* @param poly2 Second polygon
* @return A list containing the resulting polygon(s) with holes
*/
std::list<Polygon_with_holes_2> performDifference(const Polygon_2& poly1, const Polygon_2& poly2);
/**
* Performs a symmetric difference operation on two 2D polygons
* @param poly1 First polygon
* @param poly2 Second polygon
* @return A list containing the resulting polygon(s) with holes
*/
std::list<Polygon_with_holes_2> performSymmetricDifference(const Polygon_2& poly1, const Polygon_2& poly2);
/**
* Creates a sample polygon for testing
* @param vertices Vector of points defining the polygon vertices
* @return A polygon constructed from the given vertices
*/
Polygon_2 createPolygon(const std::vector<Point_2>& vertices);
/**
* Prints a polygon with holes, showing the outer boundary and any holes
* @param poly The polygon with holes to print
*/
void printPolygonWithHoles(const Polygon_with_holes_2& poly);
/**
* Prints all polygons in a list of polygons with holes
* @param polys The list of polygons with holes
*/
void printPolygonList(const std::list<Polygon_with_holes_2>& polys);
}
#endif // BOOLEAN_OPERATIONS_H