MEPP2 Project
Refinement_info.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 #pragma push_macro("ERROR")
15 #undef ERROR
16 
17 #include <boost/graph/graph_traits.hpp>
18 #include <boost/graph/properties.hpp>
22 
23 #include <list>
24 #include <vector>
25 #include <map>
26 
27 namespace FEVV {
28 namespace Filters {
29 
36 template<
37  typename HalfedgeGraph,
38  typename PointMap,
41  typename vertex_descriptor =
43  typename vertex_iterator =
44  typename boost::graph_traits< HalfedgeGraph >::vertex_iterator >
46 {
47 public:
49  HalfedgeGraph &g,
50  const std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory)
51  : _g(g), _list_memory(list_memory)
52  {}
53 
55  int get_num_vertices() const
56  {
57  auto iterator_pair = vertices(_g);
58  vertex_iterator vi = iterator_pair.first;
59  vertex_iterator vi_end = iterator_pair.second;
60  auto nb_vertices = std::distance(iterator_pair.first, iterator_pair.second);
61 
62  return static_cast< int >(nb_vertices);
63  }
64 
69  PointMap > &st
70  )
71  {
72  const std::list< vertex_descriptor > &spanning_tree = st.get_spanning_tree_vertices();
73  // Bit optimization stuff (to not encode predictable zeros).
75  bool last_was_1 = false;
76  std::list< vertex_descriptor > remaining_adjacent_vertices_of_last_v, tmp;
77  std::map<vertex_descriptor, bool> processed_vertices;
78 
79  typename std::list< vertex_descriptor >::const_iterator it =
80  spanning_tree.begin(), it_e = spanning_tree.end();
81  auto it_list = _list_memory.begin(), it_list_e = _list_memory.end();
82  for( ; (it != it_e) && (it_list != it_list_e); ++it)
83  {
84  // Bit optimization stuff.
85  processed_vertices[*it] = true;
86  bool is_adjacent_to_former_1 = false;
87  if(last_was_1)
88  {
89  auto it_to_remove = std::find(remaining_adjacent_vertices_of_last_v.begin(),
90  remaining_adjacent_vertices_of_last_v.end(), *it) ;
91  is_adjacent_to_former_1 = (it_to_remove != remaining_adjacent_vertices_of_last_v.end());
92  if(is_adjacent_to_former_1)
93  remaining_adjacent_vertices_of_last_v.erase(it_to_remove);
94  if(remaining_adjacent_vertices_of_last_v.empty())
95  last_was_1 = false;
96  }
97 
98  if(*it == (*it_list).get_vkept()) // Each split vertex must be present in
99  // the bit mask.
100  { // Code by 1 vertex that belongs to the list.
101  _bitMask.push_back(1);
102 
103  ++it_list;
104 
105  // Bit optimization stuff.
106  last_was_1 = true;
107  tmp = FEVV::Comparator::get_not_processed_adjacent_vertices(*it, _g, processed_vertices, st.get_spanning_tree_min_incident_edge(*it));
108  remaining_adjacent_vertices_of_last_v.insert(remaining_adjacent_vertices_of_last_v.end(), tmp.begin(), tmp.end());
109  }
110  else if(!is_adjacent_to_former_1) // Each non-split vertex is present in
111  // the bit mask only when not adjacent
112  // to a previously met split vertex.
113  {
114  _bitMask.push_back(0);
115  }
116  }
117  }
118 
122  PointMap > &st,
123  PointMap &pm,
124  std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory
125  )
130  {
132  pm,
133  list_memory,
134  _connectivity,
135  st
136  );
137  }
138 
141  {
142  if(!_list_memory.empty())
143  {
144  auto it_list = _list_memory.begin(), ite = _list_memory.end();
145  for( ; it_list != ite; ++it_list)
146  {
147  _error_prediction.push_back((*it_list).get_error_prediction());
148  }
149  }
150  }
151 
155  {
156  if(!_list_memory.empty())
157  {
158  auto it_list = _list_memory.begin(), ite = _list_memory.end();
159  for( ; it_list != ite; ++it_list)
160  _reverse_bool.push_back((*it_list).get_reverse());
161  }
162  }
163 
165 public:
166  const std::list< bool >& get_bitmask() const { return _bitMask; }
167  const std::list< bool >& get_connectivity() const { return _connectivity; }
168 
170  const std::list< std::vector< Vector > >& get_error_prediction() const
171  {
172  return _error_prediction;
173  }
174 
175  const std::list< bool >& get_reverse_bool() const { return _reverse_bool; }
176 private:
177  HalfedgeGraph &_g;
178  const std::list< Collapse_info< HalfedgeGraph, PointMap > > &_list_memory;
179  std::list< bool > _bitMask;
182  std::list< bool > _connectivity;
184 
186  std::list< std::vector< Vector > > _error_prediction;
187  std::list< bool > _reverse_bool;
188 };
189 
190 
191 } // namespace Filters
192 } // namespace FEVV
FEVV::Filters::Refinement_info::set_error_prediction
void set_error_prediction()
Creates the residuals array.
Definition: Refinement_info.h:140
FEVV::DataStructures::AIF::vertices
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator > vertices(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the iterator range of the vertices of the mesh.
Definition: Graph_traits_aif.h:172
FEVV::Filters::Refinement_info::_reverse_bool
std::list< bool > _reverse_bool
list of residuals.
Definition: Refinement_info.h:187
FEVV::Filters::Refinement_info::Refinement_info
Refinement_info(HalfedgeGraph &g, const std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory)
Definition: Refinement_info.h:48
FEVV::Filters::Refinement_info::get_bitmask
const std::list< bool > & get_bitmask() const
Definition: Refinement_info.h:166
FEVV::Filters::Collapse_info< HalfedgeGraph, PointMap >
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
FEVV::Filters::Refinement_info::set_connectivity_topology
void set_connectivity_topology(const FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap > &st, PointMap &pm, std::list< Collapse_info< HalfedgeGraph, PointMap > > &list_memory)
Creates the edge bitmask.
Definition: Refinement_info.h:120
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::Filters::Refinement_info::_list_memory
const std::list< Collapse_info< HalfedgeGraph, PointMap > > & _list_memory
Definition: Refinement_info.h:178
FEVV::Comparator::Spanning_tree_vertex_edge_comparator
Definition: Spanning_tree_vertex_edge_comparator.hpp:258
FEVV::Filters::Refinement_info::set_reverse_bool
void set_reverse_bool()
Definition: Refinement_info.h:154
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Filters::Refinement_info::_bitMask
std::list< bool > _bitMask
Definition: Refinement_info.h:181
FEVV::Filters::Refinement_info
Definition: Refinement_info.h:46
Geometry_traits.h
FEVV::Filters::Refinement_info::set_bitMask
void set_bitMask(const FEVV::Comparator::Spanning_tree_vertex_edge_comparator< HalfedgeGraph, PointMap > &st)
Definition: Refinement_info.h:67
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
Connectivity_encoding.h
Collapse_info.h
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::Filters::Refinement_info::get_error_prediction
const std::list< std::vector< Vector > > & get_error_prediction() const
Get the list of residuals.
Definition: Refinement_info.h:170
FEVV::Filters::Refinement_info::_connectivity
std::list< bool > _connectivity
Definition: Refinement_info.h:183
FEVV::Filters::Refinement_info::get_reverse_bool
const std::list< bool > & get_reverse_bool() const
Definition: Refinement_info.h:175
FEVV::Filters::Refinement_info::_g
HalfedgeGraph & _g
Definition: Refinement_info.h:177
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
FEVV::Filters::Refinement_info::_error_prediction
std::list< std::vector< Vector > > _error_prediction
Definition: Refinement_info.h:186
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31
FEVV::Filters::Refinement_info::get_connectivity
const std::list< bool > & get_connectivity() const
Definition: Refinement_info.h:167
FEVV::Filters::Refinement_info::get_num_vertices
int get_num_vertices() const
Get the number of vertices of the halfedge graph.
Definition: Refinement_info.h:55