MEPP2 Project
collapse_edge.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>
16 
17 namespace FEVV {
18 namespace Operators {
19 
34 template< typename MutableFaceGraph >
35 void
37  MutableFaceGraph &g,
38  typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
39 {
40  typedef boost::graph_traits< MutableFaceGraph > GraphTraits;
41  typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
43  typedef CGAL::Halfedge_around_target_iterator< MutableFaceGraph >
44  halfedge_around_target_iterator;
45 
46  if(h == boost::graph_traits< MutableFaceGraph >::null_halfedge())
47  return;
48 
49  // deal with vertex geometry
50  vertex_descriptor vs = source(h, g);
51  vertex_descriptor vt = target(h, g);
52 
53  halfedge_around_target_iterator hi, he;
54  for(boost::tie(hi, he) = CGAL::halfedges_around_target(h, g); hi != he; ++hi)
55  set_target(*hi, vs, g);
56  remove_vertex(vt, g);
57 
58  // change edge connectivity
59  halfedge_descriptor hn = next(h, g);
60  halfedge_descriptor hp = prev(h, g);
61  halfedge_descriptor ho = opposite(h, g);
62  halfedge_descriptor hon = next(ho, g);
63  halfedge_descriptor hop = prev(ho, g);
64  set_next(hp, hn, g);
65  set_next(hop, hon, g);
66  remove_edge(edge(h, g), g);
67 
68  // remove parallel edges
71 }
72 
87 template< typename MutableFaceGraph >
88 void
90  MutableFaceGraph &g,
91  typename boost::graph_traits< MutableFaceGraph >::halfedge_descriptor &h)
92 {
93  typedef boost::graph_traits< MutableFaceGraph > GraphTraits;
94  typedef typename GraphTraits::halfedge_descriptor halfedge_descriptor;
95 
96  halfedge_descriptor ho = opposite(h, g);
98  // TODO
99  // calling collapse_edge_keep_source(g, opposite(h, g))
100  // doesn't compile. WHY ?
101 }
102 
103 } // namespace Operators
104 } // namespace FEVV
105 
FEVV::DataStructures::AIF::remove_vertex
void remove_vertex(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, FEVV::DataStructures::AIF::AIFMesh &sm)
Removes v from the mesh.
Definition: Graph_traits_aif.h:728
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::Operators::collapse_edge_keep_source
void collapse_edge_keep_source(MutableFaceIncidentGraph &g, typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor &e)
Collapse an edge of the graph. The edge to collapse is given as a non-oriented edge....
Definition: collapse_edge.hpp:45
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::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::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::Operators::collapse_edge_keep_target
void collapse_edge_keep_target(MutableFaceIncidentGraph &g, typename boost::graph_traits< MutableFaceIncidentGraph >::edge_descriptor &e)
Collapse an edge of the graph. The edge to collapse is given as a non-oriented edge....
Definition: collapse_edge.hpp:180
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
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
FEVV::DataStructures::AIF::set_target
void set_target(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, FEVV::DataStructures::AIF::AIFMesh &sm)
Sets the target vertex of h and the source of opposite(h) to v.
Definition: Graph_traits_aif.h:740
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
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
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
delete_edge_if_parallel.hpp