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

Fix warnings

parent 0d8ac8be
......@@ -75,4 +75,5 @@ public:
Reseau(const unsigned int &h, const unsigned int &l);
Reseau(const Reseau&);
~Reseau();
Reseau& operator=(const Reseau& r);
};
......@@ -78,7 +78,7 @@ class RegleVoisinageNeumann : public RegleVoisinage {
unsigned int rayon;
public:
void calculVoisinage(Voisinage& v, const Reseau& r) const override;
void setr(unsigned int r);
void setr(unsigned int r) { rayon = r; }
unsigned int getr() const { return rayon; }
int getType() const { return 1; }
};
......@@ -88,7 +88,7 @@ class RegleVoisinageMoore : public RegleVoisinage {
unsigned int rayon;
public:
void calculVoisinage(Voisinage& v, const Reseau& r) const override;
void setr(unsigned int r);
void setr(unsigned int r) { rayon = r; }
unsigned int getr() const { return rayon; }
int getType() const { return 2; }
};
......
......@@ -247,7 +247,7 @@ Reseau& Database::getReseau(int idReseau) const {
cellule.bindValue(":i", static_cast<int>(i));
cellule.bindValue(":j", static_cast<int>(j));
cellule.exec();
while(r->getReseau()[i][j].getIndEtat() != cellule.value("etat").toInt())
while(static_cast<int>(r->getReseau()[i][j].getIndEtat()) != cellule.value("etat").toInt())
r->getReseau()[i][j].incrementerEtat();
}
}
......
......@@ -111,4 +111,21 @@ Reseau::Reseau(const Reseau& init_grille){
reseau[i][j].initCellule(init_grille.reseau[i][j].getIndEtat(),i,j);
}
};
}
Reseau& Reseau::operator=(const Reseau& init_grille) {
for(unsigned int i=0; i<hauteur; i++)
delete[] reseau[i];
delete[] reseau;
hauteur = init_grille.hauteur;
largeur = init_grille.largeur;
reseau = new Cellule* [hauteur];
for(unsigned int i=0; i<hauteur; i++)
reseau[i] = new Cellule [largeur];
for(unsigned int i=0; i<hauteur; i++)
for(unsigned int j=0; j<largeur; j++)
reseau[i][j].initCellule(init_grille.reseau[i][j].getIndEtat(),i,j);
return *this;
}
......@@ -3,45 +3,29 @@
#include<cmath>
#include<iostream>
void RegleVoisinageNeumann::setr(unsigned int r){
if(r >= 0)
rayon = r;
else
throw ("Rayon incorrect !\n");
}
void RegleVoisinageMoore::setr(unsigned int r){
if(r >= 0)
rayon = r;
else
throw ("Rayon incorrect !\n");
}
void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) const {
v.voisinage = std::vector<Cellule*>();
int nb = 0;
unsigned int cellX = v.celluleCentre->abs;
unsigned int cellY = v.celluleCentre->ord;
unsigned int hauteur = r.getHauteur();
unsigned int largeur = r.getLargeur();
for (int i = -rayon; i <= rayon; i++)
for (int j = -rayon; j <= rayon; j++)
if (abs(i) + abs(j) <= rayon && i != 0 && j != 0)
for (int i = -static_cast<int>(rayon); i <= static_cast<int>(rayon); i++)
for (int j = -static_cast<int>(rayon); j <= static_cast<int>(rayon); j++)
if (abs(i) + abs(j) <= static_cast<int>(rayon) && i != 0 && j != 0)
v.voisinage.push_back(&r.getReseau()[(cellY+i)%hauteur][(cellX+j)%largeur]);
}
void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r) const {
v.voisinage = std::vector<Cellule*>();
int nb = 0;
unsigned int cellX = v.celluleCentre->abs;
unsigned int cellY = v.celluleCentre->ord;
unsigned int hauteur = r.getHauteur();
unsigned int largeur = r.getLargeur();
for (int i = -rayon; i <= rayon; i++)
for (int j = -rayon; j <= rayon; j++)
if (abs(i) <= rayon && abs(j) <= rayon && i != 0 && j != 0)
for (int i = -static_cast<int>(rayon); i <= static_cast<int>(rayon); i++)
for (int j = -static_cast<int>(rayon); j <= static_cast<int>(rayon); j++)
if (abs(i) <= static_cast<int>(rayon) && abs(j) <= static_cast<int>(rayon) && i != 0 && j != 0)
v.voisinage.push_back(&r.getReseau()[(cellY+i)%hauteur][(cellX+j)%largeur]);
}
......
Markdown is supported
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