From b016e556364e4cc28237a818e748fe9e7a2ee962 Mon Sep 17 00:00:00 2001 From: Lingjie Zhu Date: Mon, 19 Jun 2017 10:54:25 +0800 Subject: [PATCH] overload vertex anchor index check --- .../VSA_segmentation.h | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA_segmentation.h b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA_segmentation.h index ec7adaa492b..7d702df357b 100644 --- a/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA_segmentation.h +++ b/Surface_mesh_approximation/include/CGAL/internal/Surface_mesh_approximation/VSA_segmentation.h @@ -631,9 +631,8 @@ private: global_vanchor_map[superv] = 0; global_vtag_map[superv] = 0; BOOST_FOREACH(sg_vertex_descriptor v, vpatch) { - if (global_vanchor_map[v] >= 0) { + if (is_anchor_attached(v, global_vanchor_map)) add_edge(superv, v, FT(0), gmain); - } } vpatch.push_back(superv); } @@ -655,15 +654,12 @@ private: boost::dijkstra_shortest_paths(glocal, source, boost::predecessor_map(&pred[0]).weight_map(local_eweight_map)); - // backtrack to the anchor vertex + // backtrack to the anchor and tag each vertex in the local patch graph BOOST_FOREACH(sg_vertex_descriptor v, vertices(glocal)) { sg_vertex_descriptor curr = v; - int anchor_idx = local_vanchor_map[curr]; - while (anchor_idx < 0) { + while (!is_anchor_attached(curr, local_vanchor_map)) curr = pred[curr]; - anchor_idx = local_vanchor_map[curr]; - } - local_vtag_map[v] = anchor_idx; + local_vtag_map[v] = local_vanchor_map[curr]; } } @@ -882,7 +878,16 @@ private: // check if halfedge target vertex is attached with an anchor bool is_anchor_attached(const halfedge_descriptor &he) { - return vertex_status_pmap[target(he, mesh)] >= 0; + return is_anchor_attached(target(he, mesh), vertex_status_pmap); + } + + // check if a vertex is attached with an anchor + // suppose anchor index starts with 0 + template + bool is_anchor_attached( + const typename boost::property_traits::key_type &v, + const VertexAnchorIndexMap &vertex_anchor_map) { + return vertex_anchor_map[v] >= 0; } // attach anchor to vertex