MEPP2 Project
Uniform_dequantization.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>
17 #include <iostream>
18 #include <fstream>
19 #include <iomanip>
20 #include <set>
21 #include <list>
22 #include <vector>
23 #include <utility>
24 #include <chrono>
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <sys/stat.h>
28 
29 namespace FEVV {
30 namespace Filters {
31 
36 template<typename HalfedgeGraph,
37  typename PointMap,
40  typename vertex_descriptor =
42  typename vertex_iterator =
43  typename boost::graph_traits< HalfedgeGraph >::vertex_iterator >
44 
46 {
47 
48  public:
49  Uniform_dequantization(const HalfedgeGraph &g,
50  PointMap &pm,
51  int nb_bits_quantization,
52  const std::vector< double > &bb_dimension,
53  const std::vector< double > &init_point)
54  : _g(g), _pm(pm), _nb_bits_quantization(nb_bits_quantization),
55  _bb_dimension(bb_dimension), _init_point(init_point)
56  {
57  this->set_max_length();
58  this->set_quantization_step();
59  }
60  protected:
62  {
64  if(_max_length < _bb_dimension[1])
66  if(_max_length < _bb_dimension[2])
68  }
69 
71  {
73 #if(DEBUG)
74  std::cout << "Uniform_dequantization: quantization step : " << _quantization_step << std::endl;
75 #endif
76  }
77  public:
83  {
84  const Point& pq = get(_pm, v);
85 
86  return dequantize(pq);
87  }
91  Point dequantize(const Point& pq)
92  {
93  double p_min_x = _init_point[0];
94  double p_min_y = _init_point[1];
95  double p_min_z = _init_point[2];
96 
98  uint32_t pq_x = static_cast<uint32_t>(gt.get_x(pq));
99  uint32_t pq_y = static_cast<uint32_t>(gt.get_y(pq));
100  uint32_t pq_z = static_cast<uint32_t>(gt.get_z(pq));
101 
102  // Reconstruction
103  double p_x = (double)pq_x * _quantization_step + p_min_x;
104  double p_y = (double)pq_y * _quantization_step + p_min_y;
105  double p_z = (double)pq_z * _quantization_step + p_min_z;
106 
107  Point new_position(p_x, p_y, p_z);
108  return new_position;
109  }
112  {
113 
115  double p_min_x = _init_point[0];
116  double p_min_y = _init_point[1];
117  double p_min_z = _init_point[2];
118 
119  vertex_iterator vi = vertices(_g).first;
120 
121  for( ; vi != vertices(_g).second; ++vi)
122  {
123  const Point& pq = get(_pm, *vi);
124 
125  uint32_t pq_x = static_cast<uint32_t>(gt.get_x(pq));
126  uint32_t pq_y = static_cast<uint32_t>(gt.get_y(pq));
127  uint32_t pq_z = static_cast<uint32_t>(gt.get_z(pq));
128 
129  // Left reconstruction: why do no use instead the centered reconstruction?
130  double p_x = (double)pq_x * _quantization_step + p_min_x;
131  double p_y = (double)pq_y * _quantization_step + p_min_y;
132  double p_z = (double)pq_z * _quantization_step + p_min_z;
133 
134  Point new_position = Point(p_x, p_y, p_z);
135 
136  put(_pm, *vi, new_position);
137  }
138  }
139 
141  private:
142  const HalfedgeGraph &_g;
143  PointMap &_pm;
145  const std::vector< double > _bb_dimension;
146  const std::vector< double > _init_point;
147  double _max_length;
149 };
150 
151 } // namespace Filters
152 } // namespace FEVV
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::Uniform_dequantization::set_quantization_step
void set_quantization_step()
Definition: Uniform_dequantization.h:70
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::Filters::Uniform_dequantization::dequantize
Point dequantize(vertex_descriptor v)
Definition: Uniform_dequantization.h:82
FEVV::Filters::Uniform_dequantization::point_dequantization
void point_dequantization()
Dequantizes all vertex positions stored in the point map.
Definition: Uniform_dequantization.h:111
FEVV::Filters::Uniform_dequantization::get_nb_bits_quantization
int get_nb_bits_quantization() const
Definition: Uniform_dequantization.h:140
FEVV::Filters::Uniform_dequantization::_pm
PointMap & _pm
Topology remains the same.
Definition: Uniform_dequantization.h:143
FEVV::get
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:117
FEVV::Filters::Uniform_dequantization::Uniform_dequantization
Uniform_dequantization(const HalfedgeGraph &g, PointMap &pm, int nb_bits_quantization, const std::vector< double > &bb_dimension, const std::vector< double > &init_point)
Definition: Uniform_dequantization.h:49
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Filters::Uniform_dequantization::_nb_bits_quantization
const int _nb_bits_quantization
Point map changes.
Definition: Uniform_dequantization.h:144
FEVV::Filters::Uniform_dequantization::_bb_dimension
const std::vector< double > _bb_dimension
Definition: Uniform_dequantization.h:145
FEVV::Filters::Uniform_dequantization::_quantization_step
double _quantization_step
Definition: Uniform_dequantization.h:148
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::Filters::Uniform_dequantization::_max_length
double _max_length
Definition: Uniform_dequantization.h:147
FEVV::Filters::Uniform_dequantization
Uniform_dequantization is a class dedicated to the XYZ uniform dequantization of vertex coordinates s...
Definition: Uniform_dequantization.h:46
FEVV::Filters::Uniform_dequantization::dequantize
Point dequantize(const Point &pq)
Definition: Uniform_dequantization.h:91
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::Filters::Uniform_dequantization::_init_point
const std::vector< double > _init_point
Definition: Uniform_dequantization.h:146
FEVV::put
void put(FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key, const FEVV::PCLPointCloudPointMap::value_type &value)
Specialization of put(point_map, key, value) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:126
FEVV::Filters::Uniform_dequantization::set_max_length
void set_max_length()
Definition: Uniform_dequantization.h:61
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31
FEVV::Filters::Uniform_dequantization::_g
const HalfedgeGraph & _g
Definition: Uniform_dequantization.h:142