Skip to content

Commit

Permalink
#13 sono state concluse tutte le funzioni
Browse files Browse the repository at this point in the history
  • Loading branch information
lucabeber committed Apr 27, 2021
1 parent 0a17d3e commit 50b1120
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
9 changes: 9 additions & 0 deletions include/meccanismo.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ Meccanismo* meccanismo_init(double hman, double hbiel, double bpist, double ango
**/
std::string meccanismo_svg(Meccanismo* meccanismo, bool misure);

/** Funzione che legge una stringa svg contenente l'immagine del meccanismo
* e ne costruisce un nuova struct
*
* @param s stringa contenente il testo letto da un file svg
*
* @return struttura pistone contenente i dati trovati all'interno del file
*/
Meccanismo* meccanismo_new(std::string file);


/**
* Funzione che libera lo spazio di memoria occupato dall' intero meccanismo
Expand Down
36 changes: 35 additions & 1 deletion src/meccanismo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,44 @@ std::string meccanismo_svg(Meccanismo* meccanismo, bool misure){

// si ottine una stringa contenente l'svg del meccanismo richiamando le funzioni dei vari componenti
std::string s = manovella_svg(meccanismo->manovella,misure) + pist_svg(meccanismo->pistone,misure) + biella_svg(meccanismo->biella,misure);

return s;
}

Meccanismo* meccanismo_new(std::string file){

Meccanismo* ret = new Meccanismo;

// si creano le parti del meccanismo tramite la stringa in ingresso
try {
std::cout << "Creazione della struttura manovella."<< std::endl;
ret->manovella = manovella_new(file);
} catch (std::exception& ex) {
std::cout << "something bad happened!" << ex.what() << std::endl;
std::cout << "I caught the exception, will continue" << std::endl;
ret->manovella = NULL;
};

try {
std::cout << "Creazione della struttura manovella."<< std::endl;
ret->biella = biella_new(file);
} catch (std::exception& ex) {
std::cout << "something bad happened!" << ex.what() << std::endl;
std::cout << "I caught the exception, will continue" << std::endl;
ret->manovella = NULL;
};

try {
std::cout << "Creazione della struttura pistone."<< std::endl;
ret->pistone = pist_new(file);
} catch (std::exception& ex) {
std::cout << "something bad happened!" << ex.what() << std::endl;
std::cout << "I caught the exception, will continue" << std::endl;
ret->pistone = NULL;
};

return ret;
}

void meccanismo_del(Meccanismo* meccanismo){

// si richiamano le funzioni per eliminare gli elementi costituenti il meccanismo
Expand Down

0 comments on commit 50b1120

Please sign in to comment.