/
surface_intersection_sm_poly.cpp
59 lines (47 loc) · 1.78 KB
/
surface_intersection_sm_poly.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/boost/graph/graph_traits_Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_for_bgl_combinatorial_map_helper.h>
#include <CGAL/iterator.h>
#include <CGAL/Polygon_mesh_processing/intersection.h>
#include <CGAL/Timer.h>
namespace PMP=CGAL::Polygon_mesh_processing;
#include <iostream>
#include <fstream>
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Mesh;
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
typedef CGAL::Linear_cell_complex_traits<3, Kernel> MyTraits;
typedef CGAL::Linear_cell_complex_for_bgl_combinatorial_map_helper
<2, 3, MyTraits>::type LCC;
template <class TriangleMesh>
void run(const char* filename1, const char* filename2, const char* msg)
{
TriangleMesh mesh1;
if ( !CGAL::read_off(filename1, mesh1) ) {
std::cerr << filename1 << " is not a valid off file.\n";
exit(1);
}
TriangleMesh mesh2;
if ( !CGAL::read_off(filename2, mesh2) ) {
std::cerr << filename2 << " is not a valid off file.\n";
exit(1);
}
CGAL::Timer time;
time.start();
PMP::surface_intersection(mesh1, mesh2, CGAL::Emptyset_iterator());
time.stop();
std::cout << "Runtime for " << msg << " " << time.time() << "\n";
}
int main(int argc, char* argv[])
{
const char* filename1 = (argc > 1) ? argv[1] : "data/blobby.off";
const char* filename2 = (argc > 2) ? argv[2] : "data/eight.off";
run<Mesh>(filename1,filename2,"Surface_mesh");
run<Polyhedron>(filename1,filename2,"Polyhedron_3");
run<LCC>(filename1,filename2,"Linear_cell_complex");
return 0;
}