Skip to content

Commit

Permalink
Add a vertex index map using v.getIndex()
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Oct 11, 2024
1 parent c19c648 commit a8cfbed
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
28 changes: 27 additions & 1 deletion BGL/include/CGAL/boost/graph/graph_traits_geometrycentral.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ class GC_point_pmap
const VertexPositionGeometry* vpg_;
};

template <typename K, typename VEF>
template <typename VEF>
class GC_index_pmap
{
public:
Expand Down Expand Up @@ -768,6 +768,32 @@ struct property_map<geometrycentral::surface::ManifoldSurfaceMesh, boost::vertex
typedef geometrycentral::surface::GC_point_pmap type;
typedef type const_type;
};


template <>
struct property_map<geometrycentral::surface::ManifoldSurfaceMesh, boost::vertex_index_t >
{
typedef geometrycentral::surface::ManifoldSurfaceMesh Mesh;
typedef geometrycentral::surface::GC_index_pmap<typename boost::graph_traits<Mesh>::vertex_descriptor> type;
typedef geometrycentral::surface::GC_index_pmap<typename boost::graph_traits<Mesh>::vertex_descriptor> const_type;
};

} // namespace boost


namespace geometrycentral {
namespace surface {


GC_index_pmap<typename boost::graph_traits<ManifoldSurfaceMesh>::vertex_descriptor>
get(const boost::vertex_index_t&, const ManifoldSurfaceMesh&)
{
typedef ManifoldSurfaceMesh Mesh;
return GC_index_pmap<typename boost::graph_traits<Mesh>::vertex_descriptor>();
}

}

}

#endif
3 changes: 2 additions & 1 deletion BGL/test/BGL/graph_concept_geometrycentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ int main()
boost::breadth_first_search(*mesh,
source,
boost::visitor(boost::make_bfs_visitor(boost::record_distances(boost::make_assoc_property_map(distance), boost::on_tree_edge())))
.vertex_index_map(boost::associative_property_map<geometrycentral::surface::VertexData<std::size_t>>(mesh->getVertexIndices())));
// .vertex_index_map(boost::associative_property_map<geometrycentral::surface::VertexData<std::size_t>>(mesh->getVertexIndices()))
);

for(auto v : mesh->vertices()){
std::cout << v << " at distance " << distance[v] << std::endl;
Expand Down

0 comments on commit a8cfbed

Please sign in to comment.