MEPP2 Project
resolve_similar_edges.hpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 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 #pragma once
12 
13 #include <boost/graph/graph_traits.hpp>
15 
16 namespace FEVV {
17 namespace Filters {
18 
27 template< typename MutableFaceIncidentGraph >
28 static void
29 resolve_similar_edges(MutableFaceIncidentGraph &g)
30 {
31  typedef
32  typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor
33  edge_descriptor;
34  std::vector< edge_descriptor > edges_to_remove;
36  auto edges_range_pair = edges(g);
37  auto iter_e = edges_range_pair.first;
38  for(; iter_e != edges_range_pair.second; ++iter_e)
39  {
40  if(std::find(edges_to_remove.begin(), edges_to_remove.end(), *iter_e) !=
41  edges_to_remove.end())
42  continue;
43  auto iter_e_bis = iter_e;
44  ++iter_e_bis;
45  for(; iter_e_bis != edges_range_pair.second; ++iter_e_bis)
46  {
47  if(Operators::are_similar_edges(*iter_e, *iter_e_bis, g))
48  {
49  edges_to_remove.push_back(*iter_e_bis);
50  }
51  }
52  }
54  typename std::vector< edge_descriptor >::iterator it_e(
55  edges_to_remove.begin()),
56  it_ee(edges_to_remove.end());
57  for(; it_e != it_ee; ++it_e)
58  remove_edge(*it_e, g); // REDUNDANT EDGES ARE REMOVED
59  edges_to_remove.clear();
60 }
61 
62 } // namespace Filters
63 } // namespace FEVV
FEVV::DataStructures::AIF::edges
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_iterator > edges(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the iterator range of the edges of the mesh.
Definition: Graph_traits_aif.h:238
FEVV::Filters::resolve_similar_edges
static void resolve_similar_edges(MutableFaceIncidentGraph &g)
Remove/resolve similar edges for the given mesh g.
Definition: resolve_similar_edges.hpp:29
FEVV::DataStructures::AIF::remove_edge
void remove_edge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor e, FEVV::DataStructures::AIF::AIFMesh &sm)
Remove edge e.
Definition: Graph_traits_aif.h:858
topology_predicates.hpp
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Operators::are_similar_edges
static bool are_similar_edges(const typename boost::graph_traits< FaceIncidentGraph >::edge_descriptor edge1, const typename boost::graph_traits< FaceIncidentGraph >::edge_descriptor edge2, const FaceIncidentGraph &g)
Function determining if the arguments are similar edges (parallel edges).
Definition: topology_predicates.hpp:33