overload vertex anchor index check

This commit is contained in:
Lingjie Zhu 2017-06-19 10:54:25 +08:00
parent a8a213ab79
commit b016e55636
1 changed files with 14 additions and 9 deletions

View File

@ -631,10 +631,9 @@ private:
global_vanchor_map[superv] = 0; global_vanchor_map[superv] = 0;
global_vtag_map[superv] = 0; global_vtag_map[superv] = 0;
BOOST_FOREACH(sg_vertex_descriptor v, vpatch) { 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); add_edge(superv, v, FT(0), gmain);
} }
}
vpatch.push_back(superv); vpatch.push_back(superv);
} }
@ -655,15 +654,12 @@ private:
boost::dijkstra_shortest_paths(glocal, source, boost::dijkstra_shortest_paths(glocal, source,
boost::predecessor_map(&pred[0]).weight_map(local_eweight_map)); 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)) { BOOST_FOREACH(sg_vertex_descriptor v, vertices(glocal)) {
sg_vertex_descriptor curr = v; sg_vertex_descriptor curr = v;
int anchor_idx = local_vanchor_map[curr]; while (!is_anchor_attached(curr, local_vanchor_map))
while (anchor_idx < 0) {
curr = pred[curr]; curr = pred[curr];
anchor_idx = local_vanchor_map[curr]; local_vtag_map[v] = local_vanchor_map[curr];
}
local_vtag_map[v] = anchor_idx;
} }
} }
@ -882,7 +878,16 @@ private:
// check if halfedge target vertex is attached with an anchor // check if halfedge target vertex is attached with an anchor
bool is_anchor_attached(const halfedge_descriptor &he) { 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<typename VertexAnchorIndexMap>
bool is_anchor_attached(
const typename boost::property_traits<VertexAnchorIndexMap>::key_type &v,
const VertexAnchorIndexMap &vertex_anchor_map) {
return vertex_anchor_map[v] >= 0;
} }
// attach anchor to vertex // attach anchor to vertex