From 0a8d61bbd17502da5666220c5ff6eed74a9bb66a Mon Sep 17 00:00:00 2001 From: Jane Tournois Date: Mon, 3 Feb 2025 11:59:04 +0100 Subject: [PATCH] add edge_weight property map --- BGL/include/CGAL/boost/graph/shortest_path.h | 16 +++++++++++++++- .../internal/parameters_interface.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/BGL/include/CGAL/boost/graph/shortest_path.h b/BGL/include/CGAL/boost/graph/shortest_path.h index e48e3256386..a97f89f915d 100644 --- a/BGL/include/CGAL/boost/graph/shortest_path.h +++ b/BGL/include/CGAL/boost/graph/shortest_path.h @@ -18,6 +18,8 @@ #include #include +#include + #include #include @@ -66,6 +68,10 @@ namespace internal { * @param vt target vertex * @param mesh the mesh * @param halfedge_sequence the sequence of halfedges that form the shortest path on `mesh` +* @param np an optional sequence of \ref bgl_namedparameters "Named Parameters" among the ones listed below +* ** edge_weight_map : @todo deal with input mesh with no internal pmap. +* default in boost is `get(boost::edge_weight, mesh)` +* */ template; using Pred_pmap = boost::associative_property_map; + using parameters::get_parameter; + using parameters::choose_parameter; + + const auto w_map = choose_parameter(get_parameter(np, internal_np::edge_weight), + get(boost::edge_weight, mesh)); + Pred_umap predecessor; Pred_pmap pred_pmap(predecessor); @@ -91,7 +103,9 @@ OutputIterator shortest_path_between_two_vertices( try { boost::dijkstra_shortest_paths(mesh, vs, - boost::predecessor_map(pred_pmap).visitor(vis)); + boost::predecessor_map(pred_pmap) + .visitor(vis) + .weight_map(w_map)); } catch (const std::exception& e){} diff --git a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h index c95d2933e89..f35295c32cb 100644 --- a/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h +++ b/STL_Extension/include/CGAL/STL_Extension/internal/parameters_interface.h @@ -28,6 +28,7 @@ CGAL_add_named_parameter(use_binary_mode_t, use_binary_mode, use_binary_mode) CGAL_add_named_parameter(metis_options_t, METIS_options, METIS_options) CGAL_add_named_parameter(vertex_partition_id_t, vertex_partition_id, vertex_partition_id_map) CGAL_add_named_parameter(face_partition_id_t, face_partition_id, face_partition_id_map) +CGAL_add_named_parameter(edge_weight_t, edge_weight, edge_weight_map) CGAL_add_named_parameter(vertex_output_iterator_t, vertex_output_iterator, vertex_output_iterator) CGAL_add_named_parameter(face_output_iterator_t, face_output_iterator, face_output_iterator)