MEPP2 Project
Binary_batch_decoder.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 
18 #include <list>
19 #include <vector>
20 #include <utility>
21 
22 #ifdef _MSC_VER
23 #pragma warning(push)
24 #pragma warning(disable : 4146 26812 26451)
25 #endif
27 #if defined _MSC_VER
28 #pragma warning(pop)
29 #endif
30 
31 namespace FEVV {
32 namespace Filters {
33 
36 template<
37 typename HalfedgeGraph,
38 typename PointMap,
41 {
42 public:
45 Binary_batch_decoder(draco::DecoderBuffer &buffer, int bit_quantization)
46  : _buffer(buffer)
47 {
48  _bit_quantization = bit_quantization;
49 };
50 
51 
56 void decode_bitmask(std::list<bool> &bitmask)
57 {
58  int size_bitmask;
59  draco::RAnsBitDecoder decoder;
60  draco::DecodeVarint(&size_bitmask,&_buffer);
61 
62  decoder.StartDecoding(&_buffer);
63  for(int i = 0; i < size_bitmask; i++)
64  {
65  bool next = decoder.DecodeNextBit();
66  bitmask.push_back(next);
67  }
68  decoder.EndDecoding();
69 }
70 
73 void decode_residuals(std::list<std::vector<Vector>> &residuals, int nb_residuals)
74 {
75  int size_residuals;
76  draco::DecodeVarint(&size_residuals,&_buffer);
77 
78  draco::SymbolBitDecoder symbolBitDecoder;
79 
80  std::vector<uint32_t> residuals_uint;
81  int nb = size_residuals * 3 * nb_residuals;
82  residuals_uint.reserve(nb);
83 
84  symbolBitDecoder.StartDecoding(&_buffer);
85  for(int i = 0; i < nb; i++)
86  {
87  uint32_t temp;
88  symbolBitDecoder.DecodeLeastSignificantBits32(_bit_quantization + 1, &temp);
89  residuals_uint.push_back(temp);
90  }
91  symbolBitDecoder.EndDecoding();
92 
93  std::vector<int32_t> residuals_int;
94  residuals_int.resize(nb);
95  draco::ConvertSymbolsToSignedInts(residuals_uint.data(), nb, residuals_int.data());
96 
97  for(int i = 0; i < size_residuals; i++)
98  {
99  std::vector<Vector> paire;
100  paire.reserve(nb_residuals);
101  for(int j = 0; j < nb_residuals; ++j)
102  {
103  paire.push_back(Vector(residuals_int[3 * (nb_residuals*i + j) + 0],
104  residuals_int[3 * (nb_residuals*i + j) + 1],
105  residuals_int[3 * (nb_residuals*i + j) + 2]));
106  }
107 
108  residuals.push_back(std::move(paire));
109  }
110 }
111 
112  private:
113  draco::DecoderBuffer &_buffer;
115 };
116 
117 
118 } // namespace Filters
119 } // 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
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
FEVV::Filters::Binary_batch_decoder::decode_bitmask
void decode_bitmask(std::list< bool > &bitmask)
Decodes a bit mask encoded with draco's non-adaptive RAns coder (RAnsBitDecoder)....
Definition: Binary_batch_decoder.h:56
FEVV::Filters::Binary_batch_decoder
Definition: Binary_batch_decoder.h:41
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
FEVV::Filters::Binary_batch_decoder::_bit_quantization
int _bit_quantization
Definition: Binary_batch_decoder.h:114
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
Binary_batch_decoder_draco_nowarning.h
FEVV::Filters::Binary_batch_decoder::_buffer
draco::DecoderBuffer & _buffer
Definition: Binary_batch_decoder.h:113
FEVV::Filters::Binary_batch_decoder::Binary_batch_decoder
Binary_batch_decoder()
Definition: Binary_batch_decoder.h:43
FEVV::Filters::Binary_batch_decoder::decode_residuals
void decode_residuals(std::list< std::vector< Vector >> &residuals, int nb_residuals)
Decodes a set of residuals encoded with draco's entropy coder (SymbolBitDecoder).
Definition: Binary_batch_decoder.h:73
FEVV::Filters::Binary_batch_decoder::~Binary_batch_decoder
~Binary_batch_decoder()
Definition: Binary_batch_decoder.h:44
FEVV::Filters::Binary_batch_decoder::Binary_batch_decoder
Binary_batch_decoder(draco::DecoderBuffer &buffer, int bit_quantization)
Definition: Binary_batch_decoder.h:45