Search code examples
cgal

Find all the faces between a source and a target faces


I've used the CGAL::Surface_mesh_shortest_path before to find the exact shortest path in a topological manner. But now I want something simpler that seem to be missing from the library that is finding the logical path from one face to another, returning a list of the faces in between.

Is there any way to do it without having to implement a tree search from scratch?


Solution

  • CGAL offers a class Dual as a wrapper around a mesh. As the name suggests you obtain a dual graph. If your mesh has boundaries you have to filter them out with a boost::filtered_graph. Now you can run boost::dijkstra_shortest_paths. Now for any vertex the predecessor map will lead you to the source vertex.

    You can find a self contained example here.

    You probably can add a visitor so that you stops by throwing an exception as soon the shortest path algorithm reaches your target vertex.