#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/AABB_face_graph_triangle_primitive.h>
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h>
#include <boost/lexical_cast.hpp>
#include <cstdlib>
#include <iostream>
#include <fstream>
typedef boost::graph_traits<Triangle_mesh> Graph_traits;
typedef Graph_traits::vertex_iterator vertex_iterator;
typedef Graph_traits::face_iterator face_iterator;
typedef typename Surface_mesh_shortest_path::Barycentric_coordinates Barycentric_coordinates;
typedef typename Surface_mesh_shortest_path::Face_location Face_location;
int main(int argc, char** argv)
{
const char* filename = (argc>1) ? argv[1] : "data/elephant.off";
Triangle_mesh tmesh;
{
std::cerr << "Invalid input file." << std::endl;
return EXIT_FAILURE;
}
Surface_mesh_shortest_path shortest_paths(tmesh);
const Point_3 source_pt(-0.06, -0.145, 0.182);
Face_location source_loc = shortest_paths.locate<AABB_face_graph_traits>(source_pt);
shortest_paths.add_source_point(source_loc.first, source_loc.second);
const Ray_3 ray(Point_3(0.126, 0.387, 0.324), Point_3(0.126, 0.387, 0.124));
AABB_tree tree;
shortest_paths.build_aabb_tree(tree);
Face_location target_loc = shortest_paths.locate<AABB_face_graph_traits>(ray, tree);
if(target_loc.first == boost::graph_traits<Triangle_mesh>::null_face())
{
std::cerr << "They ray does not intersect the mesh!" << std::endl;
return EXIT_FAILURE;
}
std::vector<Point_3> points;
shortest_paths.shortest_path_points_to_source_points(target_loc.first, target_loc.second,
std::back_inserter(points));
std::cout << points.size() << " ";
for (std::size_t i = 0; i < points.size(); ++i)
std::cout << " " << points[i];
std::cout << std::endl;
return EXIT_SUCCESS;
}