1 | /* |
---|
2 | * File: main.cpp |
---|
3 | * Autor: José Orlando Ruiz Hernández (joseph2283@gmail.com) |
---|
4 | * Institución: Fundación CENDITEL |
---|
5 | * |
---|
6 | * Created on 18 de junio de 2012, 10:05 AM |
---|
7 | * Modified on 02 de mayo de 2014 |
---|
8 | * Modified on 15 de septiembre de 2014 |
---|
9 | * |
---|
10 | * Modificación por Alejandro J. Mujica (amujica@cenditel.gob.ve) con la |
---|
11 | * finalidad de adaptar para que genere la visualización estándar definida. |
---|
12 | */ |
---|
13 | |
---|
14 | |
---|
15 | # include <cstdarg> |
---|
16 | # include <svg_sigesic_builder.H> |
---|
17 | |
---|
18 | int buildSvg(const int & levelsup, const int & levelsdown, |
---|
19 | const char * const year, const char * const host, |
---|
20 | const char * const port, const char * const dbname, |
---|
21 | const char * const username, const char * const password, |
---|
22 | const char * const baseName, std::vector<long> & codes) { |
---|
23 | |
---|
24 | int lvsUp = levelsup; |
---|
25 | int lvsDown = levelsdown; |
---|
26 | |
---|
27 | DBProperties & dbProp = DBProperties::getInstance(); |
---|
28 | |
---|
29 | dbProp.setHost(host); |
---|
30 | dbProp.setPort(port); |
---|
31 | dbProp.setDbname(dbname); |
---|
32 | dbProp.setUser(username); |
---|
33 | dbProp.setPassword(password); |
---|
34 | |
---|
35 | DynDlist <long> ids; |
---|
36 | |
---|
37 | for (size_t i = 0; i < codes.size(); ++i) { |
---|
38 | ids.append(codes[i]); |
---|
39 | } |
---|
40 | |
---|
41 | std::string strBaseName = baseName; |
---|
42 | |
---|
43 | std::string dotFileName = strBaseName + ".dot"; |
---|
44 | |
---|
45 | std::string svgOutputFileName = strBaseName + ".svg"; |
---|
46 | |
---|
47 | std::string gvOutputFileName = strBaseName + ".gv"; |
---|
48 | |
---|
49 | const char * const xmlRoots = "temp.xml"; |
---|
50 | |
---|
51 | IOManager ioManager; |
---|
52 | |
---|
53 | ioManager.createXmlRootsFile(year, ids, lvsUp, lvsDown, xmlRoots); |
---|
54 | |
---|
55 | try { |
---|
56 | |
---|
57 | Graph graph; |
---|
58 | |
---|
59 | ioManager.buildGraph(xmlRoots, graph); |
---|
60 | |
---|
61 | remove(xmlRoots); |
---|
62 | |
---|
63 | ioManager.generateDot<IOManager::NodeLabel, IOManager::ArcLabel> |
---|
64 | (graph, dotFileName); |
---|
65 | |
---|
66 | int returnValue = 0; |
---|
67 | |
---|
68 | char const * path = "dot"; |
---|
69 | |
---|
70 | char * args[] = {"dot", "", (char *) dotFileName.c_str(), "-o", "", 0}; |
---|
71 | |
---|
72 | args[1] = "-Tsvg"; |
---|
73 | args[4] = (char *) svgOutputFileName.c_str(); |
---|
74 | |
---|
75 | returnValue = Process::exec(path, args); |
---|
76 | |
---|
77 | if (returnValue != 0) { |
---|
78 | std::cout << "Error generando " << svgOutputFileName << "\n"; |
---|
79 | } |
---|
80 | |
---|
81 | args[1] = "-Txdot"; |
---|
82 | args[4] = (char *) gvOutputFileName.c_str(); |
---|
83 | |
---|
84 | returnValue = Process::exec(path, args); |
---|
85 | |
---|
86 | if (returnValue != 0) { |
---|
87 | std::cout << "Error generando " << gvOutputFileName << "\n"; |
---|
88 | } |
---|
89 | |
---|
90 | } catch (const std::exception & e) { |
---|
91 | std::cout << "Excepción capturada: " << e.what() << std::endl; |
---|
92 | return 1; |
---|
93 | } |
---|
94 | |
---|
95 | return 0; |
---|
96 | } |
---|
97 | |
---|
98 | |
---|