MEPP2 Project
initializer_decompression.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 #pragma once
12 
14 
16 
24 template< typename MeshT >
25 int
26 progressive_decompression_main(int argc, const char **argv)
27 {
28  if(argc < 2 || argc > 4)
29  {
30  std::cout << "Open a binary compressed 3D mesh " << std::endl;
31  std::cout << "Usage: " << argv[0] << " input_binary_file_name [output_mesh_filename [nb_max_batches]]" << std::endl;
32  std::cout << "Example: " << argv[0]
33  << " binarymesh.bin" << std::endl;
34  return EXIT_FAILURE;
35  }
36  int nb_max_batches = 10000;
37  if (argc == 4){
38  nb_max_batches = atoi(argv[3]);
39  }
40  // Input and output files.
41  std::string input_file_path = argv[1];
42  std::string output_file_path = (argc >= 3)?argv[2]:
43  "progressive_decompression_filter_output.obj";
44 
45  // Read mesh from file.
46  MeshT m;
47  FEVV::PMapsContainer pmaps_bag;
48 
49  // Note: the property maps must be extracted from the
50  // property maps bag, and explicitely passed as
51  // parameters to the filter, in order to make
52  // clear what property is used by the filter.
53 
54  // Retrieve or create vertex-color property map.
55  using VertexColorMap =
57  VertexColorMap v_cm;
58  if(has_map(pmaps_bag, FEVV::vertex_color))
59  {
60  std::cout << "use existing vertex-color map" << std::endl;
61  v_cm = get_property_map(FEVV::vertex_color, m, pmaps_bag);
62  }
63  else
64  {
65  std::cout << "create vertex-color map" << std::endl;
67  // Store property map in property maps bag.
68  put_property_map(FEVV::vertex_color, m, pmaps_bag, v_cm);
69  }
70  // Retrieve or create edge color property map.
72  if (has_map(pmaps_bag, FEVV::edge_color))
73  {
74  std::cout << "using edge color property map" << std::endl;
75  e_cm = get_property_map(FEVV::edge_color, m, pmaps_bag);
76  }
77  else
78  {
79  std::cout << "create vertex-color map" << std::endl;
81  // Store property map in property maps bag.
82  put_property_map(FEVV::edge_color, m, pmaps_bag, e_cm);
83  }
84 
85  // Retrieve or create vertex-normal property map.
86  using VertexNormalMap =
88  VertexNormalMap v_nm;
89  if(has_map(pmaps_bag, FEVV::vertex_normal))
90  {
91  std::cout << "use existing vertex-normal map" << std::endl;
92  v_nm = get_property_map(FEVV::vertex_normal, m, pmaps_bag);
93  }
94  else
95  {
96  std::cout << "create vertex-normal map" << std::endl;
98  // Store property map in property maps bag.
99  put_property_map(FEVV::vertex_normal, m, pmaps_bag, v_nm);
100  }
101 
102  // Retrieve point property map (aka geometry).
103  auto pm = get(boost::vertex_point, m);
104 
106  // Decompression algorithm call (Algorithm 2) //
109  pm,
110  v_cm,
111  //v_nm,
112  e_cm,
113  input_file_path,
114  true,
115  nb_max_batches);
116  // Write mesh to file.
117  FEVV::Filters::write_mesh(output_file_path, m, pmaps_bag);
118 
119  return 0;
120 }
FEVV::put_property_map
void put_property_map(PropertyT p, const MeshT &, PMapsContainer &pmaps, const typename PMap_traits< PropertyT, MeshT >::pmap_type &pmap)
Definition: properties.h:664
progressive_decompression_main
int progressive_decompression_main(int argc, const char **argv)
A mesh type templated main(argc, argv) function that.
Definition: initializer_decompression.h:26
FEVV::get_property_map
PMap_traits< PropertyT, MeshT >::pmap_type get_property_map(PropertyT p, const MeshT &, const PMapsContainer &pmaps)
Definition: properties.h:646
progressive_decompression_filter.hpp
FEVV::has_map
bool has_map(const PMapsContainer &pmaps, const std::string &map_name)
(refer to Property Maps API)
Definition: properties.h:103
FEVV::PMapsContainer
std::map< std::string, boost::any > PMapsContainer
Definition: properties.h:99
FEVV::edge_color
@ edge_color
Definition: properties.h:73
FEVV::vertex_color
@ vertex_color
Definition: properties.h:47
FEVV::Filters::write_mesh
void write_mesh(const std::string &filename, FEVV::CGALPointSet &g, PMapsContainer &pmaps)
Write mesh to file.
Definition: cgal_point_set_writer.hpp:42
generic_writer.hpp
boost::get
boost::property_map< FEVV::DataStructures::AIF::AIFMesh, boost::vertex_index_t >::const_type get(const boost::vertex_index_t &, const FEVV::DataStructures::AIF::AIFMesh &)
Returns the vertex index property map of the mesh.
Definition: Graph_properties_aif.h:108
FEVV::DataStructures::AIF::AIFMesh
This class represents an AIF structure. AIF structure can deal with both manifold and non-manifold su...
Definition: AIFMesh.hpp:47
FEVV::Filters::progressive_decompression_filter
void progressive_decompression_filter(HalfedgeGraph &g, PointMap &pm, VertexColorMap &v_cm, const GeometryTraits &, draco::DecoderBuffer &buffer, bool dequantize=true, unsigned int nb_max_batches=10000)
Takes a buffer as an input, will decode the compression settings, the coarse mesh and refine the mesh...
Definition: progressive_decompression_filter.hpp:67
FEVV::_PMap_traits
Definition: properties.h:376
FEVV::vertex_normal
@ vertex_normal
Definition: properties.h:35
FEVV::make_property_map
PMap_traits< PropertyT, MeshT >::pmap_type make_property_map(PropertyT, const MeshT &m)
Definition: properties.h:630