File: sum_with_holes.cpp

package info (click to toggle)
cgal 4.9-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 85,584 kB
  • sloc: cpp: 640,841; ansic: 140,696; sh: 708; fortran: 131; makefile: 114; python: 92
file content (30 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
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
//! \file examples/Minkowski_sum_2/sum_with_holes.cpp
// Computing the Minkowski sum of two non-convex polygons read from a file.

#include <fstream>

#include <CGAL/basic.h>
#include <CGAL/minkowski_sum_2.h>

#include "bops_linear.h"
#include "pgn_print.h"

int main(int argc, char* argv[])
{
  // Open the input file and read the 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 and print the Minkowski sum.
  Polygon_with_holes_2  sum = CGAL::minkowski_sum_2(P, Q);
  std::cout << "P (+) Q = ";
  print_polygon_with_holes(sum);
  return 0;
}