MEPP2 Project
delete_edge_if_parallel.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>
14 #include <CGAL/boost/graph/iterator.h>
15 
16 namespace FEVV {
17 namespace Operators {
18 
37 template< typename MutableFaceGraph >
38 void
40  MutableFaceGraph &g,
41  typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
42 {
43  typedef boost::graph_traits< MutableFaceGraph > GraphTraits;
44  typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
45  typedef typename GraphTraits::face_descriptor face_descriptor;
46 
47  if(h == boost::graph_traits< MutableFaceGraph >::null_halfedge())
48  return;
49 
50  halfedge_descriptor hn = next(h, g);
51  if(next(hn, g) != h)
52  return; // no parallel edge, nothing to do
53 
54  // change edges connections
55  halfedge_descriptor ho = opposite(h, g);
56  halfedge_descriptor hon = next(ho, g);
57  halfedge_descriptor hop = prev(ho, g);
58  set_next(hop, hn, g);
59  set_next(hn, hon, g);
60 
61  // change adjacent face
62  face_descriptor fc = face(ho, g);
63  if(fc != boost::graph_traits< MutableFaceGraph >::null_face())
64  {
65  set_face(hn, fc, g);
66  set_halfedge(fc, hn, g);
67  }
68 
69  // remove ancient adjacent face, if any
70  face_descriptor fd = face(h, g);
71  if(fd != boost::graph_traits< MutableFaceGraph >::null_face())
72  remove_face(fd, g);
73 
74  // remove edge
75  remove_edge(edge(h, g), g);
76 }
77 
78 } // namespace Operators
79 } // namespace FEVV
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::set_halfedge
void set_halfedge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, FEVV::DataStructures::AIF::AIFMesh &sm)
Sets the halfedge of v to h. The target vertex of h must be v.
Definition: Graph_traits_aif.h:775
FEVV::DataStructures::AIF::set_next
void set_next(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h1, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h2, FEVV::DataStructures::AIF::AIFMesh &sm)
Sets the successor of h1 around a face to h2, and the prededecessor of h2 to h1.
Definition: Graph_traits_aif.h:790
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
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::edge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::edge_descriptor edge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the edge corresponding to h and opposite(h).
Definition: Graph_traits_aif.h:345
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::DataStructures::AIF::prev
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor prev(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the previous halfedge around its face.
Definition: Graph_traits_aif.h:612
FEVV::Operators::delete_edge_if_parallel
void delete_edge_if_parallel(MutableFaceGraph &g, typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
Delete the edge provided as argument when it is parallel to another edge of the graph (this is an if ...
Definition: delete_edge_if_parallel.hpp:39
FEVV::DataStructures::AIF::face
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor face(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the face incident to halfedge h.
Definition: Graph_traits_aif.h:664
FEVV::DataStructures::AIF::set_face
void set_face(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor f, FEVV::DataStructures::AIF::AIFMesh &sm)
Sets the corresponding face of h to f.
Definition: Graph_traits_aif.h:983
FEVV::DataStructures::AIF::remove_face
void remove_face(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_descriptor f, FEVV::DataStructures::AIF::AIFMesh &sm)
Removes f from the mesh.
Definition: Graph_traits_aif.h:971