The Computational Geometry Algorithms Library (CGAL) is a C++ library that aims to provide easy access to efficient and reliable algorithms in computational geometry.
I have added a function called close_path()
in file Surface_mesh_topology/include/CGAL/Path_on_surface.h ,
as well as an example illustrating the function's use : Surface_mesh_topology/examples/Surface_mesh_topology/path_completion_example.cpp .
(I have also modified the respective CMakeLists.txt file to reflect this addition).
The function can handle the creation of simple and non-simple paths. I chose not to use any external libraries in order to keep the code "dependence-free", even though I am aware that functions provided by boost would simplify implementation (ex. spanning tree construction).
The function does not build the whole spanning tree, it terminates the tree's construction when the respective endpoint of the initial path is found. Spanning tree construction starts from the front of the existing path, instead of the end, as it simplifies path tree construction. The possible paths are maintained in a tree-like data structure created using std::map. Once the desired endpoint is found, the data structure allows easy back-tracking and path compositing.
Link to commit: https://github.com/alexdkeros/cgal/commit/b2d94fac8e88e9635c374428d2a419ebaf1d0ca1