Verified Commit decb8ff0 authored by Romain De Laage De Bellefaye's avatar Romain De Laage De Bellefaye 🌳
Browse files

Fix a few mistakes

parent dbfbe957
...@@ -67,14 +67,14 @@ public: ...@@ -67,14 +67,14 @@ public:
class RegleVoisinage{ class RegleVoisinage{
public : public :
virtual void calculVoisinage(Voisinage& v, const Reseau& r) = 0; virtual void calculVoisinage(Voisinage& v, const Reseau& r) const = 0;
}; };
class RegleVoisinageNeumann : public RegleVoisinage { class RegleVoisinageNeumann : public RegleVoisinage {
private: private:
unsigned int rayon; unsigned int rayon;
public: public:
void calculVoisinage(Voisinage& v, const Reseau& r) override; void calculVoisinage(Voisinage& v, const Reseau& r) const override;
void setr(unsigned int r); void setr(unsigned int r);
unsigned int getr() const { return rayon; } unsigned int getr() const { return rayon; }
}; };
...@@ -83,7 +83,7 @@ class RegleVoisinageMoore : public RegleVoisinage { ...@@ -83,7 +83,7 @@ class RegleVoisinageMoore : public RegleVoisinage {
private: private:
unsigned int rayon; unsigned int rayon;
public: public:
void calculVoisinage(Voisinage& v, const Reseau& r) override; void calculVoisinage(Voisinage& v, const Reseau& r) const override;
void setr(unsigned int r); void setr(unsigned int r);
unsigned int getr() const { return rayon; } unsigned int getr() const { return rayon; }
}; };
......
...@@ -170,16 +170,16 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const { ...@@ -170,16 +170,16 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
if(query.isNull("rayon")) if(query.isNull("rayon"))
throw "Error: r can't be undefined here"; throw "Error: r can't be undefined here";
RegleVoisinage *regle = new RegleVoisinageNeumann; RegleVoisinageNeumann *regle = new RegleVoisinageNeumann;
regle->setNbVoisins(query.value("rayon").toInt()); regle->setr(query.value("rayon").toInt());
return regle; return regle;
} else if(type == 2) { } else if(type == 2) {
if(query.isNull("rayon")) if(query.isNull("rayon"))
throw "Error: r can't be undefined here"; throw "Error: r can't be undefined here";
RegleVoisinage *regle = new RegleVoisinageMoore; RegleVoisinageMoore *regle = new RegleVoisinageMoore;
regle->setNbVoisins(query.value("rayon").toInt()); regle->setr(query.value("rayon").toInt());
return regle; return regle;
} else if(type != 3) // n'existe pas } else if(type != 3) // n'existe pas
...@@ -192,7 +192,7 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const { ...@@ -192,7 +192,7 @@ RegleVoisinage* Database::getRegleVoisinage(const QString& name) const {
if(!query.first()) if(!query.first())
throw "There must be at least one coord in this rule"; throw "There must be at least one coord in this rule";
RegleVoisinage *regle = new RegleVoisinage; RegleVoisinageArbitraire *regle = new RegleVoisinageArbitraire;
do { do {
/// @todo voisinage arbitraire /// @todo voisinage arbitraire
...@@ -269,8 +269,8 @@ Reseau& Database::getReseau(int idReseau) const ...@@ -269,8 +269,8 @@ Reseau& Database::getReseau(int idReseau) const
cellule.prepare("SELECT etat FROM Cellules WHERE (reseau = :id AND ensemble = :idE AND x = :i AND y = :j)"); cellule.prepare("SELECT etat FROM Cellules WHERE (reseau = :id AND ensemble = :idE AND x = :i AND y = :j)");
cellule.bindValue(":id", idReseau); cellule.bindValue(":id", idReseau);
cellule.bindValue(":idE", idEnsemble); cellule.bindValue(":idE", idEnsemble);
cellule.bindValue(":i", i); cellule.bindValue(":i", static_cast<int>(i));
cellule.bindValue(":j", j); cellule.bindValue(":j", static_cast<int>(j));
cellule.exec(); cellule.exec();
while(r->getReseau()[i][j].getIndEtat() != cellule.value("etat").toInt()) while(r->getReseau()[i][j].getIndEtat() != cellule.value("etat").toInt())
r->getReseau()[i][j].incrementerEtat(); r->getReseau()[i][j].incrementerEtat();
......
...@@ -17,7 +17,7 @@ void RegleVoisinageMoore::setr(unsigned int r){ ...@@ -17,7 +17,7 @@ void RegleVoisinageMoore::setr(unsigned int r){
throw ("Rayon incorrect !\n"); throw ("Rayon incorrect !\n");
} }
void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) { void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) const {
v.voisinage = std::vector<Cellule*>(); v.voisinage = std::vector<Cellule*>();
int nb = 0; int nb = 0;
unsigned int cellX = v.celluleCentre->abs; unsigned int cellX = v.celluleCentre->abs;
...@@ -31,7 +31,7 @@ void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) { ...@@ -31,7 +31,7 @@ void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) {
v.voisinage.push_back(&r.getReseau()[(cellY+i)%hauteur][(cellX+j)%largeur]); v.voisinage.push_back(&r.getReseau()[(cellY+i)%hauteur][(cellX+j)%largeur]);
} }
void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r) { void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r) const {
v.voisinage = std::vector<Cellule*>(); v.voisinage = std::vector<Cellule*>();
int nb = 0; int nb = 0;
unsigned int cellX = v.celluleCentre->abs; unsigned int cellX = v.celluleCentre->abs;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment