It is almost a sample of CGAL.
That is correcting the input to the OBJ format.
requirements
CGAL The Computational Geometry Algorithms Library
Boost C++ libraries.
Sample Triangulated Surface Mesh Segmentation CGALSurface_mesh_segmentation/extract_segmentation_into_mesh_example.cpp