1
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
2
#include <CGAL/Polyhedron_3.h>
3
#include <CGAL/IO/Polyhedron_iostream.h>
4
#include <CGAL/mesh_segmentation.h>
6
#include <CGAL/property_map.h>
11
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
12
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
16
// create and read Polyhedron
18
std::ifstream input("data/cactus.off");
19
if ( !input || !(input >> mesh) || mesh.empty() ) {
20
std::cerr << "Not a valid off file." << std::endl;
24
// create a property-map for segment-ids
25
typedef std::map<Polyhedron::Facet_const_handle, std::size_t> Facet_int_map;
26
Facet_int_map internal_segment_map;
27
boost::associative_property_map<Facet_int_map> segment_property_map(internal_segment_map);
29
// calculate SDF values and segment the mesh using default parameters.
30
std::size_t number_of_segments = CGAL::segmentation_via_sdf_values(mesh, segment_property_map);
32
std::cout << "Number of segments: " << number_of_segments << std::endl;
35
for(Polyhedron::Facet_const_iterator facet_it = mesh.facets_begin();
36
facet_it != mesh.facets_end(); ++facet_it) {
37
std::cout << segment_property_map[facet_it] << " ";
39
std::cout << std::endl;