Commit 3d6ae910 authored by Maxime Goret's avatar Maxime Goret
Browse files

Fin Voisinage

parent 928af81b
#include <voisinage.hpp> #include"voisinage.hpp"
#include<math.h> #include<math.h>
void Voisinage::setr(unsigned int rayon){ void Voisinage::setr(unsigned int rayon){
int rayon = -1; rayon = -1;
while (rayon < 0){ while (rayon< 0){
printf("Entrez le ratonde voisinage (0 pour le voisinage arbitraire):\n "); printf("Entrez le ratonde voisinage (0 pour le voisinage arbitraire):\n ");
scanf("%d", &rayon); scanf("%d", &rayon);
...@@ -185,15 +185,15 @@ void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r){ ...@@ -185,15 +185,15 @@ void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r){
} }
Voisinage::~Voisinage() { Voisinage::~Voisinage() {
VoisinageIterator *cellules = voisins.creerIterator(); VoisinageIterator *cellules = creerIterator();
cellules.first(); cellules->first();
int nb = 0; int nb = 0;
while (!cellules.isDone()){ while (!cellules->isDone()){
delete voisinage[nb]; delete voisinage[nb];
nb++; nb++;
} }
delete[] voisinage; delete[] voisinage;
} }
\ No newline at end of file
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
using namespace std; using namespace std;
class Voisinage { class Voisinage {
private : private :
...@@ -38,10 +40,11 @@ public: ...@@ -38,10 +40,11 @@ public:
class RegleVoisinage{ class RegleVoisinage{
private : private :
unsigned int nbVoisin;
public : public :
unsigned int nbVoisin;
void setNbVoisins(unsigned int r); void setNbVoisins(unsigned int r);
unsigned int getNbVoisin() {return nbVoisin;} unsigned int getNbVoisin() {return nbVoisin;}
void calculVoisinage(Voisinage& v, const Reseau& r); void calculVoisinage(Voisinage& v, const Reseau& r);
...@@ -85,10 +88,9 @@ class VoisinageIterator { ...@@ -85,10 +88,9 @@ class VoisinageIterator {
void next(){ void next(){
i++; i++;
} }
bool isDone(){
// bool isDone(){ return (vsn->voisinage.size() <= i);
// return i == vsn->voisinage }
// }
int currentItem(){ int currentItem(){
return vsn->voisinage[i]; return vsn->voisinage[i];
...@@ -96,4 +98,5 @@ class VoisinageIterator { ...@@ -96,4 +98,5 @@ class VoisinageIterator {
} }
}; };
#endif /* voisinnage_hpp */ #endif /* voisinnage_hpp */
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