#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <fstream>
#include <iostream>
int main(int argc, char** argv)
{
std::ifstream in((argc>1) ? argv[1] : "data/blobby.off");
int number_of_parts = (argc>2) ? atoi(argv[2]) : 8;
if(!in) {
std::cerr << "Error: could not read input file" << std::endl;
return EXIT_FAILURE;
}
SM sm;
typedef SM::Property_map<SM::Vertex_index, std::size_t> Vertex_id_map;
Vertex_id_map vertex_pid_map = sm.add_property_map<SM::Vertex_index, std::size_t>("v:pid").first;
typedef SM::Property_map<SM::Face_index, std::size_t> Face_id_map;
Face_id_map face_pid_map = sm.add_property_map<SM::Face_index, std::size_t>("f:pid").first;
CGAL::parameters::vertex_partition_id_map(vertex_pid_map)
.face_partition_id_map(face_pid_map));
Filtered_graph filtered_sm(sm, 0 , face_pid_map);
CGAL_assertion(filtered_sm.is_selection_valid());
SM part_sm;
std::ofstream out("sm_part_0.off");
std::ofstream outxyz("out.xyz");
boost::graph_traits<SM>::vertex_iterator vit, ve;
for(; vit!=ve; ++vit)
{
if(get(vertex_pid_map, *vit) == 0)
outxyz << sm.point(*vit) << std::endl;
}
return EXIT_SUCCESS;
}