Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
87 lines (71 loc) · 3.18 KB
/
Copy pathmain.cpp
File metadata and controls
87 lines (71 loc) · 3.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <stdio.h>
#include <string>
#include <iostream> // <--- Añadido para std::cout
#include "src/triangulation.h" // Tu nueva clase Triangulation
#include "src/mpolylla_omp.h" // La clase Polylla convertida (nombre de archivo original)
int main(int argc, char* argv[])
{
#ifdef DEBUG
std::cout << "[DEBUG] main: Inicio de main." << std::endl;
#endif
if (argc < 2){
printf("Error: Archivo de entrada no especificado.\n");
printf("Uso: ./MPolylla_OMP <archivo_entrada.off> [archivo_salida_base]\n");
printf("Ej: ./MPolylla_OMP data/mesh.off resultados/mesh_out\n");
printf(" Generará: resultados/mesh_out.off y resultados/mesh_out.json\n");
return 0;
}
std::string input_file_name(argv[1]);
std::string output_file_name("output"); // Nombre base, sin extensión
if (argc > 2)
output_file_name = std::string(argv[2]);
#ifdef DEBUG
std::cout << "[DEBUG] main: Archivo de entrada: " << input_file_name << std::endl;
std::cout << "[DEBUG] main: Nombre base de salida: " << output_file_name << std::endl;
#endif
// ---------------------------------------------------
// INICIO DE SECCIÓN MODIFICADA
// ---------------------------------------------------
std::string off_file = input_file_name;
std::string output = output_file_name;
std::string output_off_file = output + ".off";
std::string output_json_file = output + ".json";
printf("Ejecutando MPolylla (OpenMP) con %i cores...\n", omp_get_max_threads());
#ifdef DEBUG
std::cout << "[DEBUG] main: Llamando constructor Polylla(" << off_file << ")..." << std::endl;
#endif
// 1. Crear y ejecutar Polylla (el constructor hace todo el trabajo)
Polylla mesh(off_file);
#ifdef DEBUG
std::cout << "[DEBUG] main: Constructor Polylla finalizado." << std::endl;
#endif
printf("Ejecución de MPolylla finalizada.\n");
// 2. Escribir el resultado a un nuevo archivo .off
printf("Escribiendo archivo de salida .off...\n");
#ifdef DEBUG
std::cout << "[DEBUG] main: Llamando print_OFF(" << output_off_file << ")..." << std::endl;
#endif
//mesh.print_OFF(output_off_file);
#ifdef DEBUG
std::cout << "[DEBUG] main: print_OFF finalizado." << std::endl;
#endif
printf("Archivo de salida escrito en: %s\n", output_off_file.c_str());
// 3. Escribir las estadísticas a un archivo .json
printf("Escribiendo archivo de stats .json...\n");
#ifdef DEBUG
std::cout << "[DEBUG] main: Llamando print_stats(" << output_json_file << ")..." << std::endl;
#endif
mesh.print_stats(output_json_file);
#ifdef DEBUG
std::cout << "[DEBUG] main: print_stats finalizado." << std::endl;
#endif
printf("Archivo de stats escrito en: %s\n", output_json_file.c_str());
// 4. Liberar memoria (El destructor de 'mesh' se llama automáticamente al salir de main)
#ifdef DEBUG
std::cout << "[DEBUG] main: Fin de main. El destructor de Polylla se llamará ahora." << std::endl;
#endif
// ---------------------------------------------------
// FIN DE SECCIÓN MODIFICADA
// ---------------------------------------------------
return 0;
}