29 get_vmpeak_vmsize(pid_t pid,
unsigned int &vmpeak_kb,
unsigned int &vmsize_kb)
31 std::string filename =
"/proc/" + std::to_string(pid) +
"/status";
32 std::ifstream file(filename);
35 std::cout <<
"Failed to open file '" << filename <<
"'" << std::endl;
50 else if(word ==
"VmSize:")
59 template<
typename MeshT >
67 std::cout <<
"Load a mesh then apply the Compression Valence filter."
69 std::cout <<
"Usage: " << argv[0]
70 <<
" input_mesh_file [simplified_mesh_file "
71 "[reference_mesh_file]] [-withCompr] [-withQA] [-maxV nnn] "
72 " [-Qbits nnn] [-tolerance relative_tolerance]"
74 std::cout <<
"Example: " << argv[0]
75 <<
" airplane.off airplane.out.obj airplane.ref.obj "
76 "-withCompr -maxV 500 -tolerance 1e-5"
78 std::cout <<
"Example: " << argv[0]
79 <<
" airplane.off airplane.out.obj -withCompr -maxV 500 "
82 std::cout <<
"Example: " << argv[0]
83 <<
" airplane.off -withCompr -maxV 500 -tolerance 1e-5"
88 std::string input_file_path;
89 std::string simplified_mesh_file_path;
90 std::string reference_file_path;
91 bool with_adaptative_quantization =
false;
92 bool with_compression =
false;
93 int quantiz_bits = 10;
94 int max_vertices = 100;
95 float relative_tolerance = 0.0f;
97 input_file_path = argv[1];
99 if(argc >= 3 && argv[2][0] !=
'-')
101 simplified_mesh_file_path = argv[2];
103 if(argc >= 4 && argv[3][0] !=
'-')
105 reference_file_path = argv[3];
110 for(
int i = arg_read + 1; i < argc; i++)
112 std::string argvi(argv[i]);
114 if(argvi ==
"-withQA")
116 with_adaptative_quantization =
true;
118 else if(argvi ==
"-withCompr")
120 with_compression =
true;
122 else if(argvi ==
"-Qbits")
124 quantiz_bits = std::atoi(argv[i + 1]);
127 else if(argvi ==
"-maxV")
129 max_vertices = std::atoi(argv[i + 1]);
132 else if(argvi ==
"-tolerance")
134 relative_tolerance = (float)std::atof(argv[i + 1]);
139 std::cout <<
"unknown option '" << argvi <<
"'. Aborting." << std::endl;
144 std::string p3d_file_path;
145 if(simplified_mesh_file_path.empty())
147 input_file_path.substr(0, input_file_path.find_last_of(
".")) +
".p3d";
149 p3d_file_path = simplified_mesh_file_path.substr(
150 0, simplified_mesh_file_path.find_last_of(
".")) +
154 std::cout <<
"\nParameters summary:" << std::endl;
155 std::cout <<
" - input file: " << input_file_path << std::endl;
156 std::cout <<
" - simplified mesh file: " << simplified_mesh_file_path
158 std::cout <<
" - p3d file: " << p3d_file_path << std::endl;
159 std::cout <<
" - ref. file: " << reference_file_path << std::endl;
160 std::cout <<
" - compression: " << std::boolalpha << with_compression
162 std::cout <<
" - adaptative quantization: " << std::boolalpha
163 << with_adaptative_quantization << std::endl;
164 std::cout <<
" - max vertices: " << max_vertices << std::endl;
165 std::cout <<
" - quantization bits: " << quantiz_bits << std::endl;
169 pid_t pid = getpid();
173 get_vmpeak_vmsize(pid, vmpeak_kb, vmsize_kb);
174 std::cout <<
"before compression vmpeak=" << vmpeak_kb
175 <<
" kB vmsize=" << vmsize_kb <<
" kB" << std::endl;
186 auto pm =
get(boost::vertex_point, m);
189 using VertexColorMap =
192 VertexColorMap *v_cm_ptr =
nullptr;
195 std::cout <<
"using vertex color property map" << std::endl;
207 with_adaptative_quantization,
214 get_vmpeak_vmsize(pid, vmpeak2_kb, vmsize_kb);
215 std::cout <<
"after compression vmpeak=" << vmpeak2_kb
216 <<
" kB vmsize=" << vmsize_kb
217 <<
" kB extra.vmpeak=" << vmpeak2_kb - vmpeak_kb <<
" kB"
222 if(!simplified_mesh_file_path.empty())
226 if(!reference_file_path.empty())
228 std::cout <<
"Comparing output file" << std::endl;
229 std::cout <<
" '" << simplified_mesh_file_path <<
"'" << std::endl;
230 std::cout <<
"with reference file" << std::endl;
231 std::cout <<
" '" << reference_file_path <<
"'" << std::endl;
232 std::cout <<
"..." << std::endl;
244 std::cout <<
"Files are different!" << std::endl;
252 reference_file_path))
254 std::cout <<
"Files are different!" << std::endl;
259 std::cout <<
"Files are identical." << std::endl;