MEPP2 Project
Spanning_tree_vertex_edge_comparator.hpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2022 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 
12 #pragma once
13 
15 
16 #include <limits>
17 #include <iterator>
18 #include <map>
19 #include <set>
20 
21 #include <stack>
22 
23 namespace FEVV {
24 namespace Comparator
25 {
26  template<>
30  {
32  auto res = Helpers::adjacent_vertices(v);
34  }
35 
36  template<>
40  std::map<typename boost::graph_traits<FEVV::DataStructures::AIF::AIFMesh>::vertex_descriptor, bool>& processed_vertices,
42  {
45 
46  std::list<vertex_descriptor> adjacent_vertices;
47 
48  if (min_e != GraphTraits::null_edge())
49  { // works in 2-manifold (thus to avoid when locally non-manifold)
50  typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
51 
52  // find the (second) edge that separates old region and new region
53  halfedge_descriptor h = halfedge(min_e, g);
54  if (target(h, g) != v)
55  h = opposite(h, g);
56 
57  size_t cpt = 0; // needed because sometimes the condition !(h == h_end) may
58  // rise an issue when h_end value is never met again (due to
59  // fact that we may have a locally non-manifold situation)
60  halfedge_descriptor h_end = h;
61  do
62  {
63  vertex_descriptor v_adj = source(h, g);
64  auto it_res = processed_vertices.find(v_adj);
65  if ((it_res == processed_vertices.end()) || !it_res->second)
66  { // not yet processed
67  if (it_res != processed_vertices.end())
68  it_res->second = true;
69  else
70  processed_vertices[v_adj] = true;
71  adjacent_vertices.push_back(source(h, g));
72  }
73 
74  h = opposite(next(h, g), g);
75  ++cpt;
76  } while (!(h == h_end) && (cpt<= degree(v, g)));
77  }
78  else
79  { // works in 2-manifold and non-manifold
81 
82  auto res = Helpers::adjacent_vertices(v);
83 
84  auto iter_v = res.begin(), iter_v_e = res.end();
85  for (; iter_v != iter_v_e; ++iter_v) {
86  auto it_res = processed_vertices.find(*iter_v);
87  if ((it_res != processed_vertices.end()) && it_res->second)
88  continue;
89  else {
90  if (it_res != processed_vertices.end())
91  it_res->second = true;
92  else
93  processed_vertices[*iter_v] = true;
94  adjacent_vertices.push_back(*iter_v);
95  }
96  }
97  }
98  return adjacent_vertices;
99  }
100 
101 } // namespace Comparator
102 } // namespace FEVV
103 
FEVV::DataStructures::AIF::next
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor next(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the next halfedge around its face.
Definition: Graph_traits_aif.h:599
FEVV::DataStructures::AIF::degree
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::degree_size_type degree(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor u, const FEVV::DataStructures::AIF::AIFMesh &)
Definition: Graph_traits_aif.h:548
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor
AIFMeshT::edge_type::ptr edge_descriptor
Definition: Graph_traits_aif.h:61
FEVV::Comparator::get_adjacent_vertices
std::list< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor > get_adjacent_vertices(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &)
Definition: Spanning_tree_vertex_edge_comparator.hpp:28
FEVV::DataStructures::AIF::opposite
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor opposite(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the halfedge with source and target swapped.
Definition: Graph_traits_aif.h:625
FEVV::DataStructures::AIF::source
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor source(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the source vertex of e.
Definition: Graph_traits_aif.h:387
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::halfedge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor halfedge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns a halfedge with target v.
Definition: Graph_traits_aif.h:296
FEVV::DataStructures::AIF::target
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor target(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the target vertex of e.
Definition: Graph_traits_aif.h:400
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >
Definition: Graph_traits_aif.h:56
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::DataStructures::AIF::adjacent_vertices
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::adjacency_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::adjacency_iterator > adjacent_vertices(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &)
Definition: Graph_traits_aif.h:217
FEVV::DataStructures::AIF::AIFTopologyHelpers
This class is an helper class associated to the AIFMesh structure. AIFTopologyHelpers implements all ...
Definition: AIFTopologyHelpers.h:57
FEVV::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
Spanning_tree_vertex_edge_comparator.hpp
FEVV::Comparator::get_not_processed_adjacent_vertices
std::list< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor > get_not_processed_adjacent_vertices(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &g, std::map< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor, bool > &processed_vertices, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor min_e)
Definition: Spanning_tree_vertex_edge_comparator.hpp:38
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor
AIFMeshT::vertex_type::ptr vertex_descriptor
Definition: Graph_traits_aif.h:59