#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polygon_mesh_processing/corefinement.h>
#include <CGAL/Polygon_mesh_processing/IO/polygon_mesh_io.h>
#include <array>
#include <iostream>
#include <string>
#include <tuple>
namespace PMP = CGAL::Polygon_mesh_processing;
int main(int argc, char* argv[])
{
const std::string filename1 = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/blobby.off");
const std::string filename2 = (argc > 2) ? argv[2] : CGAL::data_file_path("meshes/eight.off");
Mesh mesh1, mesh2;
if(!PMP::IO::read_polygon_mesh(filename1, mesh1) || !PMP::IO::read_polygon_mesh(filename2, mesh2))
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
Mesh out_union, out_intersection;
std::array<std::optional<Mesh*>, 4> output;
output[PMP::Corefinement::UNION] = &out_union;
output[PMP::Corefinement::INTERSECTION] = &out_intersection;
std::array<bool, 4> res =
PMP::corefine_and_compute_boolean_operations(
mesh1, mesh2,
output,
params::default_values(),
params::default_values(),
std::make_tuple(
params::vertex_point_map(get(boost::vertex_point, out_union)),
params::vertex_point_map(get(boost::vertex_point, out_intersection)),
params::default_values(),
params::default_values() )
);
if (res[PMP::Corefinement::UNION])
{
std::cout << "Union was successfully computed\n";
}
else
std::cout << "Union could not be computed\n";
if (res[PMP::Corefinement::INTERSECTION])
{
std::cout << "Intersection was successfully computed\n";
}
else
std::cout << "Intersection could not be computed\n";
return 0;
}
bool write_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())