#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h>
 
#include <iostream>
#include <sstream>
#include <fstream>
 
 
 
void fill_cube_1(Polyhedron& poly)
{
  std::string input =
"OFF\n\
8 12 0\n\
-1 -1 -1\n\
-1 1 -1\n\
1 1 -1\n\
1 -1 -1\n\
-1 -1 1\n\
-1 1 1\n\
1 1 1\n\
1 -1 1\n\
3  0 1 3\n\
3  3 1 2\n\
3  0 4 1\n\
3  1 4 5\n\
3  3 2 7\n\
3  7 2 6\n\
3  4 0 3\n\
3  7 4 3\n\
3  6 4 7\n\
3  6 5 4\n\
3  1 5 6\n\
3  2 1 6";
 
  std::stringstream ss;
  ss << input;
  ss >> poly;
}
 
void fill_cube_2(Polyhedron& poly)
{
  std::string input =
"OFF\n\
8 12 0\n\
-0.5 -0.5 -0.5\n\
-0.5 0.5 -0.5\n\
0.5 0.5 -0.5\n\
0.5 -0.5 -0.5\n\
-0.5 -0.5 0.5\n\
-0.5 0.5 0.5\n\
0.5 0.5 0.5\n\
0.5 -0.5 0.5\n\
3  0 1 3\n\
3  3 1 2\n\
3  0 4 1\n\
3  1 4 5\n\
3  3 2 7\n\
3  7 2 6\n\
3  4 0 3\n\
3  7 4 3\n\
3  6 4 7\n\
3  6 5 4\n\
3  1 5 6\n\
3  2 1 6";
 
  std::stringstream ss;
  ss << input;
  ss >> poly;
}
 
int main()
{
  
  Polyhedron cube1, cube2;
  fill_cube_1(cube1);
  fill_cube_2(cube2);
 
  Nef_polyhedron nef1(cube1);
  Nef_polyhedron nef2(cube2);
 
  
  Nef_polyhedron nef=nef1-nef2;
 
  
  Surface_mesh output;
  std::ofstream out;
  out.open("out.off");
  out << output;
  out.close();
}
A 3D Nef polyhedron is a subset of the 3-dimensional space that is the result of forming complements ...
Definition: Nef_polyhedron_3.h:55
 
void convert_nef_polyhedron_to_polygon_mesh(const Nef_polyhedron &nef, Polygon_mesh &pm, bool triangulate_all_faces=false)
Converts an object of type Nef_polyhedron_3 into a polygon mesh model of MutableFaceGraph.