Skip to content

Instantly share code, notes, and snippets.

@afabri
Created August 27, 2021 15:48
Show Gist options
  • Save afabri/8faea66fd85e5e3efd62a6e2b51494bd to your computer and use it in GitHub Desktop.
Save afabri/8faea66fd85e5e3efd62a6e2b51494bd to your computer and use it in GitHub Desktop.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Nef_polyhedron_3.h>
#include <CGAL/Timer.h>
#include <fstream>
#include <iostream>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
typedef CGAL::Surface_mesh<K::Point_3> Polygon_mesh;
typedef CGAL::Nef_polyhedron_3<K> Nef_polyhedron;
int main(int argc, char* argv[])
{
std::cout << argv[1] << std::endl;
Polygon_mesh A, B;
{
std::ifstream in(argv[1]);
in >> A;
}
{
std::ifstream in(argv[2]);
in >> B;
}
CGAL::Timer t;
t.start();
std::cout << num_vertices(A) << std::endl;
Nef_polyhedron nA(A), nB(B);
std::cout << "A : " << nA.number_of_vertices() << " " << nA.number_of_facets() << " " << t.time() << " sec." << std::endl;
t.reset();
Nef_polyhedron nI = nA.intersection(nB);
std::cout << "intersection(A,B) : " << nI.number_of_vertices() << " " << nI.number_of_facets() << " " << t.time() << " sec." << std::endl;
t.reset();
Nef_polyhedron nD = nA.difference(nB);
std::cout << "A - B : " << nD.number_of_vertices() << " " << nD.number_of_facets() << " " << t.time() << " sec." << std::endl;
t.reset();
Nef_polyhedron nR = nD.join(nI);
std::cout << "(A - B) union with intersection(A,B) : " << nR.number_of_vertices() << " " << nR.number_of_facets() << " " << t.time() << " sec." << std::endl;
t.reset();
Nef_polyhedron nE = nR.difference(nR);
std::cout << "A - A : " << nE.number_of_vertices() << " " << nE.number_of_facets() << " " << t.time() << " sec." << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment