#include <CGAL/Simple_cartesian.h>
#include <CGAL/Polyhedron_3.h>
#include <CGAL/extract_mean_curvature_flow_skeleton.h>
#include <CGAL/boost/graph/split_graph_into_polylines.h>
#include <fstream>
typedef boost::graph_traits<Polyhedron>::vertex_descriptor vertex_descriptor;
typedef Skeletonization::Skeleton Skeleton;
typedef Skeleton::vertex_descriptor Skeleton_vertex;
typedef Skeleton::edge_descriptor Skeleton_edge;
struct Display_polylines{
const Skeleton& skeleton;
std::ofstream& out;
int polyline_size;
std::stringstream sstr;
Display_polylines(const Skeleton& skeleton, std::ofstream& out)
: skeleton(skeleton), out(out)
{}
void start_new_polyline(){
polyline_size=0;
sstr.str("");
sstr.clear();
}
void add_node(Skeleton_vertex v){
++polyline_size;
sstr << " " << skeleton[v].point;
}
void end_polyline()
{
out << polyline_size << sstr.str() << "\n";
}
};
int main(int argc, char* argv[])
{
Polyhedron tmesh;
input >> tmesh;
{
std::cout << "Input geometry is not triangulated." << std::endl;
return EXIT_FAILURE;
}
Skeleton skeleton;
std::cout << "Number of vertices of the skeleton: " << boost::num_vertices(skeleton) << "\n";
std::cout << "Number of edges of the skeleton: " << boost::num_edges(skeleton) << "\n";
std::ofstream output("skel-poly.polylines.txt");
Display_polylines display(skeleton,output);
output.close();
output.open("correspondance-poly.polylines.txt");
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " "
<< get(CGAL::vertex_point, tmesh, vd) << "\n";
return EXIT_SUCCESS;
}
Function object that enables to extract the mean curvature flow skeleton of a triangulated surface me...
Definition: Mean_curvature_flow_skeletonization.h:169
bool is_triangle_mesh(const FaceGraph &g)
void split_graph_into_polylines(const Graph &graph, Visitor &polyline_visitor, IsTerminal is_terminal)
void extract_mean_curvature_flow_skeleton(const TriangleMesh &tmesh, typename Mean_curvature_flow_skeletonization< TriangleMesh >::Skeleton &skeleton)
extracts a medially centered curve skeleton for the triangle mesh tmesh. This function uses the class...
Definition: extract_mean_curvature_flow_skeleton.h:47
Iterator_range< T > make_range(const T &b, const T &e)
std::string data_file_path(const std::string &filename)