MEPP2 Project
Connectivity_encoding.h
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 
14 #include <boost/graph/graph_traits.hpp>
15 #include <boost/graph/properties.hpp>
16 
18 
21 
22 namespace FEVV {
23 namespace Filters {
24 
35 template<
36  typename HalfedgeGraph,
37  typename PointMap,
38  typename halfedge_descriptor =
39  typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor,
40  typename edge_descriptor =
41  typename boost::graph_traits< HalfedgeGraph >::edge_descriptor,
42  typename Geometry = typename FEVV::Geometry_traits< HalfedgeGraph > >
43 void
44 connectivity_encoding(const HalfedgeGraph &g,
45  const PointMap &/*pm*/,
47  edge_descriptor starting_edge,
48  std::list< bool > &edge_bitmask
49  )
50 {
51  // convert edge into halfedge
52  halfedge_descriptor starting_halfedge = halfedge(starting_edge, g);
53  // the current edge starts as the "starting edge" and will turn around its
54  // target using the topology of the mesh
55  halfedge_descriptor current_edge = starting_halfedge;
56 
57  bool first = true;
58  int count = 0;
59  do
60  {
61  if(count > 1)
62  break; // not needed to add the last false
63  if(source(current_edge, g) == mem.get_v3() || source(current_edge, g) == mem.get_v4())
64  {
65  // if v3 goes after v4, we have to reverse our residuals in order to
66  // ensure the proper decompression of our mesh
67  if(source(current_edge, g) == mem.get_v4() && first == true)
68  {
69  mem.record_reverse(true);
70  }
71  edge_bitmask.push_back(true);
72  count++;
73  first = false;
74  }
75  else
76  {
77  edge_bitmask.push_back(false);
78  }
79 
80  current_edge = opposite(next(current_edge, g), g);
81  } while(current_edge != starting_halfedge);
82  if(mem.get_v4() != boost::graph_traits< HalfedgeGraph >::null_vertex() &&
83  mem.get_v3() == boost::graph_traits< HalfedgeGraph >::null_vertex())
84  {
85  mem.record_reverse(false);
86  }
87  if(mem.get_v3() != boost::graph_traits< HalfedgeGraph >::null_vertex() &&
88  mem.get_v4() == boost::graph_traits< HalfedgeGraph >::null_vertex())
89  {
90  mem.record_reverse(true);
91  }
92 }
93 
96 template<
97  typename HalfedgeGraph,
98  typename PointMap,
99  typename halfedge_descriptor =
100  typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor,
101  typename edge_descriptor =
102  typename boost::graph_traits< HalfedgeGraph >::edge_descriptor,
103  typename Geometry = typename FEVV::Geometry_traits< HalfedgeGraph > >
104 void
106  const HalfedgeGraph &g,
107  const PointMap &pm,
108  std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory,
109  std::list< bool > &edge_bitmask,
113  PointMap,
114  Geometry >& spanningtree
115  )
117 {
118  auto mem_it = list_memory.begin(), mem_it_e = list_memory.end();
119  for( ; mem_it != mem_it_e; ++mem_it)
120  {
121  auto min_edge = spanningtree.get_spanning_tree_min_incident_edge((*mem_it).get_vkept());
123  pm,
124  *mem_it,
125  min_edge,
126  edge_bitmask
127  );
128  }
129 }
130 
131 } // namespace Filters
132 } // 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::Filters::Collapse_info< HalfedgeGraph, PointMap >
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::Geometry_traits< HalfedgeGraph >
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
Memory_comparator.h
FEVV::Filters::encode_connectivity_bitmask
void encode_connectivity_bitmask(const HalfedgeGraph &g, const PointMap &pm, std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory, std::list< bool > &edge_bitmask, const FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap, Geometry > &spanningtree)
Encode vertex to split' one-ring edges to expand, for all collapsed edges in the order of the sorted ...
Definition: Connectivity_encoding.h:105
FEVV::Comparator::Spanning_tree_vertex_edge_comparator
Definition: Spanning_tree_vertex_edge_comparator.hpp:258
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
apply_color.h
FEVV::Filters::Collapse_info::get_v4
vertex_descriptor get_v4() const
Definition: Collapse_info.h:94
FEVV::Filters::Collapse_info::get_v3
vertex_descriptor get_v3() const
Definition: Collapse_info.h:89
FEVV::Filters::connectivity_encoding
void connectivity_encoding(const HalfedgeGraph &g, const PointMap &, Collapse_info< HalfedgeGraph, PointMap > &mem, edge_descriptor starting_edge, std::list< bool > &edge_bitmask)
Encode vertex to split' one-ring edges to expand. For a vertex to split (represented by a Collapse_in...
Definition: Connectivity_encoding.h:44
Spanning_tree_vertex_edge_comparator.hpp
FEVV::Filters::Collapse_info::record_reverse
void record_reverse(bool rev)
Definition: Collapse_info.h:114