From d261af09b0694f8e2b92e848dd3da2a7b2dd6f0b Mon Sep 17 00:00:00 2001 From: luca Date: Tue, 27 Apr 2021 22:27:07 +0200 Subject: [PATCH] #16 adesso e' possibile scaricare da file i dati di un meccanismo --- main.cpp | 157 +++++++++++++++++++------------------------------------ 1 file changed, 53 insertions(+), 104 deletions(-) diff --git a/main.cpp b/main.cpp index eb4fcc8..4c7252a 100644 --- a/main.cpp +++ b/main.cpp @@ -8,112 +8,14 @@ #include "meccanismo.h" int main() { - /* - Biella* biella; - - biella = biella_init(100,200,200,50); - - string s=svg_biella(biella); - - s=svg(s); - - svg_to_file("pistone.svg",s); - */ - /* - unsigned int a,b,c; - cout << "Inizializzazione pistone\n Inserire l'area di base del pistone:"; - cin >> a; - cout << "Inserire le coordinate x:"; - cin >> b,c; - cout << "Inserire le coordinate y:"; - cin >> c; - - Pistone* pistone; - - try { - cout << "Creazione della struttura pistone."<< endl; - pistone = pist_init(a,b,c); - } catch (exception& ex) { - cout << "something bad happened!" << ex.what() << endl; - cout << "I caught the exception, will continue" << endl; - }; - - cout << "Pistone inizializzato\n"; - - cout << "Creazione stringa\n"; - - string s=svg_pist(pistone); - - cout << "Eliminazione struttura pistone"; - - cout << s << endl; - - s=svg(s); - - cout << s << endl; - - svg_to_file("pistone.svg",s); - - nuovo_pist(s); - Pistone* pistone2; - try { - cout << "Creazione della struttura pistone."<< endl; - pistone2 = pist_init(a,b,c); - } catch (exception& ex) { - cout << "something bad happened!" << ex.what() << endl; - cout << "I caught the exception, will continue" << endl; - }; - - - cout << "Pistone inizializzato\n"; - - cout << "Creazione nuova stringa\n"; - - string s2=svg_pist(pistone2); - - cout << s2 << endl; - - cout << "Eliminazione struttura pistone"; - - elimina_pist(pistone); - - cout << "\nFine programma\n";*/ - /*double r=10,d=30,h=10,q=20; - cout << "Costruzione del meccanismo"; - Manovella* man = manovella_init(30,200,200, 60); - - double a,b; - - - - Biella* bie = biella_init (90, 200 + 30*sin(-60), 200 - 30*cos(-60), atan2(a,b)); - - Pistone* pist = pist_init(30, 500 ,500); - - string s = manovella_svg(man,1) + biella_svg(bie,1) + pist_svg(pist,1); - - s=svg(s); - - svg_to_file("pistone.svg",s); - - - Manovella* pistone2; - try { - cout << "Creazione della struttura pistone."<< endl; - pistone2 = manovella_new(s); - } catch (exception& ex) { - cout << "something bad happened!" << ex.what() << endl; - cout << "I caught the exception, will continue" << endl; - }; - std::string s2=manovella_svg(pistone2,0); - cout<>misure; + + if (misure != 0 && misure != 1){ + std::cout<<"Inserisci un valore valido"<\n"; + for (int i=0; i\n"; + s += meccanismo_svg(arr[i],1); meccanismo_del(arr[i]); } delete arr; @@ -194,7 +112,38 @@ int main() { break; case 'l': - /* code */ + std::cout<<"Nome del file su cui e' salvato il codice svg"<>nomefile; + + s = svg_read(nomefile); + + p = "Sono presenti "; + + found = s.find(p)+size(p); + found2 = s.find(" ",found); + + new_str = s.substr(found, found2); + + n = atoi(new_str.c_str()); + + arr= new Meccanismo* [n]; + + if (n<0 || n>8) break; + + for (int i=0; i