CGAL 6.0 - 2D Minkowski Sums
Loading...
Searching...
No Matches
Minkowski_sum_2/sum_by_decomposition.cpp
// Computing the Minkowski sum of two non-convex polygons read from a file
// using the small-side angle-bisector decomposition strategy.
#include <fstream>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/minkowski_sum_2.h>
#include <CGAL/Small_side_angle_bisector_decomposition_2.h>
#include "pgn_print.h"
typedef Kernel::Point_2 Point;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
int main(int argc, char* argv[])
{
// Open the input file and read two polygons from it.
const char* filename = (argc > 1) ? argv[1] : "rooms_star.dat";
std::ifstream in_file(filename);
if (! in_file.is_open()) {
std::cerr << "Failed to open the input file." << std::endl;
return -1;
}
Polygon_2 P, Q;
in_file >> P >> Q;
in_file.close();
// Compute the Minkowski sum using the decomposition approach.
Polygon_with_holes_2 sum = CGAL::minkowski_sum_2(P, Q, ssab_decomp);
std::cout << "P (+) Q = "; print_polygon_with_holes(sum);
return 0;
}
The Small_side_angle_bisector_decomposition_2 class implements a simple yet efficient heuristic for d...
Definition: Small_side_angle_bisector_decomposition_2.h:22
Polygon_with_holes_2< Kernel, Container > minkowski_sum_2(const PolygonType1< Kernel, Container > &P, const PolygonType2< Kernel, Container > &Q)
Computes the Minkowski sum of two given polygons (which may have holes).