-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcgal.cpp
66 lines (55 loc) · 1.57 KB
/
cgal.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
60
61
62
63
64
65
66
#include "cgal.h"
// computes (overlapping) decimations using CGAL's routines
void decimate_CGAL(
Surface_mesh* surface_mesh,
const float ratio,
const bool adaptive)
{
int index = 0 ;
for( Surface_mesh::Halfedge_iterator eb = (*surface_mesh).halfedges_begin()
, ee = (*surface_mesh).halfedges_end()
; eb != ee
; ++ eb
)
eb->id() = index++;
index = 0 ;
for( Surface_mesh::Vertex_iterator vb = (*surface_mesh).vertices_begin()
, ve = (*surface_mesh).vertices_end()
; vb != ve
; ++ vb
)
vb->id() = index++;
// Decimate to output 10% resolution mesh
SMS::Count_ratio_stop_predicate<Surface_mesh> stop(ratio);
Stats stats ;
My_visitor vis(&stats) ;
// The index maps are not explicitelty passed as in the previous
// example because the surface mesh items have a proper id() field.
// On the other hand, we pass here explicit cost and placement
// function which differ from the default policies, ommited in
// the previous example.
if (adaptive){
int r = SMS::edge_collapse
(*surface_mesh
,stop
#if CGAL_VERSION_NR >= 1040700000
,CGAL::parameters::visitor (vis)
#else
,CGAL::visitor (vis)
#endif
);
} else {
int r = SMS::edge_collapse
(*surface_mesh
,stop
#if CGAL_VERSION_NR >= 1040700000
,CGAL::parameters::get_cost (SMS::Edge_length_cost <Surface_mesh>())
#else
,CGAL::get_cost (SMS::Edge_length_cost <Surface_mesh>())
#endif
.get_placement(SMS::Midpoint_placement<Surface_mesh>())
.visitor (vis)
);
}
return;
}