Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Romain De Laage De Bellefaye
LO21-projet
Commits
8e533605
Commit
8e533605
authored
May 27, 2021
by
Maxime Goret
Browse files
Modif Voisinage
parent
3d6ae910
Changes
3
Hide whitespace changes
Inline
Side-by-side
Reseau_Cellule_Etat/reseau_cellule_etats.h
View file @
8e533605
...
...
@@ -11,6 +11,11 @@ private:
//inline Cellule():indEtat(0), abs(0), ord(0){};
void
initCellule
(
const
unsigned
int
ind
,
const
unsigned
int
&
x
,
const
unsigned
int
&
y
);
friend
class
Reseau
;
friend
class
RegleVoisinage
;
friend
class
RegleVoisinageNeumann
;
friend
class
RegleVoisinageMoore
;
};
class
Etat
{
...
...
@@ -56,6 +61,9 @@ private:
unsigned
int
hauteur
;
unsigned
int
largeur
;
Cellule
**
reseau
;
friend
class
RegleVoisinage
;
friend
class
RegleVoisinageNeumann
;
friend
class
RegleVoisinageMoore
;
public:
/* inline Reseau(const unsigned int &h, const unsigned int &l):hauteur(h),largeur(l){
...
...
Voisinage/voisinage.cpp
View file @
8e533605
...
...
@@ -42,7 +42,7 @@ void RegleVoisinageMoore::setNbVoisins(unsigned int r) {
}
void
RegleVoisinage
::
calculVoisinage
(
Voisinage
&
v
,
const
Reseau
&
r
)
{
v
.
voisinage
=
new
Cellule
*
[
nbVoisin
]
;
v
.
voisinage
=
std
::
vector
<
Cellule
*>
()
;
for
(
int
k
=
0
;
k
<
nbVoisin
;
k
++
)
{
unsigned
int
i
,
j
;
while
(
i
>=
r
.
hauteur
||
j
>=
r
.
largeur
)
{
...
...
@@ -59,7 +59,7 @@ void RegleVoisinage::calculVoisinage(Voisinage& v, const Reseau& r) {
}
void
RegleVoisinageNeumann
::
calculVoisinage
(
Voisinage
&
v
,
const
Reseau
&
r
)
{
v
.
voisinage
=
new
Cellule
*
[
nbVoisin
]
;
v
.
voisinage
=
std
::
vector
<
Cellule
*>
()
;
int
nb
=
0
;
unsigned
int
abs
=
v
.
celluleCentre
->
abs
;
unsigned
int
ord
=
v
.
celluleCentre
->
ord
;
...
...
@@ -122,7 +122,7 @@ void RegleVoisinageNeumann::calculVoisinage(Voisinage& v, const Reseau& r) {
}
void
RegleVoisinageMoore
::
calculVoisinage
(
Voisinage
&
v
,
const
Reseau
&
r
){
v
.
voisinage
=
new
Cellule
*
[
nbVoisin
]
;
v
.
voisinage
=
std
::
vector
<
Cellule
*>
()
;
int
nb
=
0
;
unsigned
int
abs
=
v
.
celluleCentre
->
abs
;
unsigned
int
ord
=
v
.
celluleCentre
->
ord
;
...
...
@@ -185,15 +185,5 @@ void RegleVoisinageMoore::calculVoisinage(Voisinage& v, const Reseau& r){
}
Voisinage
::~
Voisinage
()
{
VoisinageIterator
*
cellules
=
creerIterator
();
cellules
->
first
();
int
nb
=
0
;
while
(
!
cellules
->
isDone
()){
delete
voisinage
[
nb
];
nb
++
;
}
delete
[]
voisinage
;
voisinage
.
clear
();
}
Voisinage/voisinage.hpp
View file @
8e533605
...
...
@@ -10,26 +10,56 @@
#include
<stdio.h>
#include
<iostream>
#include
"../Reseau_Cellule_Etat/reseau_cellule_etats.h"
#include
<string.h>
using
namespace
std
;
#include
<vector>
class
Voisinage
{
private
:
const
Cellule
*
celluleCentre
;
Cellule
*
*
voisinage
;
vector
<
Cellule
*
>
voisinage
;
unsigned
int
r
;
friend
class
RegleVoisinage
;
friend
class
RegleVoisinageMoore
;
friend
class
RegleVoisinageNeumann
;
friend
class
VoisinageIterator
;
public:
class
VoisinageIterator
{
const
Voisinage
*
vsn
;
int
i
;
public
:
VoisinageIterator
(
const
Voisinage
*
v
){
vsn
=
v
;
}
void
first
(){
i
=
0
;
}
void
next
(){
i
++
;
}
bool
isDone
(){
return
(
vsn
->
voisinage
.
size
()
<=
i
);
}
Cellule
*
currentItem
(){
return
vsn
->
voisinage
[
i
];
}
};
Voisinage
();
~
Voisinage
();
Cellule
*
getCelluleCentre
()
const
{
return
celluleCentre
;}
Cellule
getCelluleCentre
()
const
{
return
*
celluleCentre
;}
void
setr
(
unsigned
int
rayon
);
unsigned
int
getr
()
const
{
return
r
;}
VoisinageIterator
*
creerIterator
()
const
{
...
...
@@ -72,31 +102,6 @@ public:
};
class
VoisinageIterator
{
const
Voisinage
*
vsn
;
int
i
;
public
:
VoisinageIterator
(
const
Voisinage
*
v
){
vsn
=
v
;
}
void
first
(){
i
=
0
;
}
void
next
(){
i
++
;
}
bool
isDone
(){
return
(
vsn
->
voisinage
.
size
()
<=
i
);
}
int
currentItem
(){
return
vsn
->
voisinage
[
i
];
}
};
#endif
/* voisinnage_hpp */
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment