#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/boost/graph/Face_filtered_graph.h>
#include <CGAL/IO/polygon_mesh_io.h>
#include <fstream>
#include <iostream>
#include <cassert>
int main(int argc, char** argv)
{
const std::string filename = (argc>1) ? argv[1] : CGAL::data_file_path("meshes/blobby.off");
int number_of_parts = (argc>2) ? atoi(argv[2]) : 8;
SM sm;
{
std::cerr << "Invalid input." << std::endl;
return 1;
}
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);
assert(filtered_sm.is_selection_valid());
SM part_sm;
std::ofstream outxyz("out.xyz");
outxyz.precision(17);
boost::graph_traits<SM>::vertex_iterator vit, ve;
boost::tie(vit, ve) = vertices(sm);
for(; vit!=ve; ++vit)
{
if(get(vertex_pid_map, *vit) == 0)
outxyz << sm.point(*vit) << std::endl;
}
return EXIT_SUCCESS;
}
std::pair< Property_map< I, T >, bool > add_property_map(std::string name=std::string(), const T t=T())
void copy_face_graph(const SourceMesh &sm, TargetMesh &tm, const NamedParameters1 &np1=parameters::default_values(), const NamedParameters2 &np2=parameters::default_values())
copies a source model of FaceListGraph into a target model of a FaceListGraph.
Definition: copy_face_graph.h:328
bool read_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
reads a polygon mesh from a file.
Definition: polygon_mesh_io.h:123
bool write_polygon_mesh(const std::string &fname, Graph &g, const NamedParameters &np=parameters::default_values())
writes a polygon mesh in a file.
Definition: polygon_mesh_io.h:223
void partition_dual_graph(const TriangleMesh &tm, int nparts, const NamedParameters &np=parameters::default_values())
computes a partition of the input triangular mesh into nparts parts, based on the mesh's dual graph.
Definition: partition_dual_graph.h:192
Convenience header file including the headers for all the partitioning-related free functions of this...
The class Face_filtered_graph is an adaptor that creates a filtered view of a graph by restricting it...
Definition: Face_filtered_graph.h:78