CGAL 5.6.3 - Triangulated Surface Mesh Skeletonization

Loading...
Searching...
No Matches
Surface_mesh_skeletonization/simple_mcfskel_sm_example.cpp
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/extract_mean_curvature_flow_skeleton.h>
#include <fstream>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point;
typedef CGAL::Surface_mesh<Point> Triangle_mesh;
typedef boost::graph_traits<Triangle_mesh>::vertex_descriptor vertex_descriptor;
typedef CGAL::Mean_curvature_flow_skeletonization<Triangle_mesh> Skeletonization;
typedef Skeletonization::Skeleton Skeleton;
typedef Skeleton::vertex_descriptor Skeleton_vertex;
typedef Skeleton::edge_descriptor Skeleton_edge;
// This example extracts a medially centered skeleton from a given mesh.
int main(int argc, char* argv[])
{
std::ifstream input((argc>1)?argv[1]:CGAL::data_file_path("meshes/elephant.off"));
Triangle_mesh tmesh;
input >> tmesh;
if (!CGAL::is_triangle_mesh(tmesh))
{
std::cout << "Input geometry is not triangulated." << std::endl;
return EXIT_FAILURE;
}
Skeleton skeleton;
CGAL::extract_mean_curvature_flow_skeleton(tmesh, 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";
// Output all the edges of the skeleton.
std::ofstream output("skel-sm.polylines.txt");
for(Skeleton_edge e : CGAL::make_range(edges(skeleton)))
{
const Point& s = skeleton[source(e, skeleton)].point;
const Point& t = skeleton[target(e, skeleton)].point;
output << "2 " << s << " " << t << "\n";
}
output.close();
// Output skeleton points and the corresponding surface points
output.open("correspondance-sm.polylines.txt");
for(Skeleton_vertex v : CGAL::make_range(vertices(skeleton)))
for(vertex_descriptor vd : skeleton[v].vertices)
output << "2 " << skeleton[v].point << " " << get(CGAL::vertex_point, tmesh, vd) << "\n";
return EXIT_SUCCESS;
}
CGAL::Mean_curvature_flow_skeletonization
Function object that enables to extract the mean curvature flow skeleton of a triangulated surface me...
Definition: Mean_curvature_flow_skeletonization.h:169
CGAL::Surface_mesh
Kernel::Point_3
CGAL::is_triangle_mesh
bool is_triangle_mesh(const FaceGraph &g)
CGAL::extract_mean_curvature_flow_skeleton
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
Kernel
CGAL::Simple_cartesian