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
6956d368
Commit
6956d368
authored
Jun 03, 2021
by
Boris Cazic
Browse files
Ebauche voisinage arbitraire
parent
f0ea0f33
Pipeline
#79104
passed with stage
in 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
includes/voisinage.h
View file @
6956d368
...
...
@@ -8,11 +8,12 @@
#ifndef voisinage_h
#define voisinage_h
#include
"reseau_cellule_etats.h"
#include
<stdio.h>
#include
<iostream>
#include
<string.h>
#include
<vector>
#include
"reseau_cellule_etats.h"
#include
"coordonnees.h"
#include
<stdio.h>
#include
<iostream>
#include
<string>
#include
<vector>
using
namespace
std
;
...
...
@@ -77,17 +78,6 @@ public :
};
/*class RegleVoisinageRayon : public RegleVoisinage { //voisinage rayon hérite de voisinage puisque spécification
protected:
unsigned int rayon;
public:
unsigned int getRayon() const { return rayon; }
explicit RegleVoisinageRayon(unsigned int ray) : rayon(ray) {} //explicit car
};*/
class
RegleVoisinageNeumann
:
public
RegleVoisinage
{
public:
...
...
@@ -97,10 +87,6 @@ public:
};
class
RegleVoisinageMoore
:
public
RegleVoisinage
{
public:
void
setNbVoisins
(
unsigned
int
r
);
...
...
@@ -109,5 +95,17 @@ public:
};
struct
VoisinageFormat
{
//Format possible de voisinage pouvant être renvoyé par RegleVoisinage
std
::
vector
<
Coordonnees
>
positions
;
};
class
RegleVoisinageArbitraire
:
public
RegleVoisinage
{
//définit la règle pour le voisinage arbitraire
public:
Voisinage
getVoisinage
(
const
Reseau
&
reseau
,
Coordonnees
position
)
const
;
std
::
vector
<
VoisinageFormat
>
getFormat
()
const
;
};
#endif
/* voisinage_h */
src/voisinage.cpp
View file @
6956d368
#include
<voisinage.h>
#include
<math.h>
#include
"voisinage.h"
#include
"reseau_cellule_etats.h"
#include
<cmath>
#include
<iostream>
void
Voisinage
::
setr
(
unsigned
int
rayon
){
if
(
rayon
>=
0
){
r
=
rayon
;
}
if
(
rayon
>=
0
)
r
=
rayon
;
else
throw
(
"Rayon incorrect !
\n
"
);
}
void
RegleVoisinage
::
setNbVoisins
(
unsigned
int
r
)
{
if
(
r
==
0
)
{
//voisinage arbitraire
printf
(
"Entrez le nombre de voisins.
\n
"
)
;
scanf
(
"%u"
,
&
nbVoisin
)
;
cout
<<
"Entrez le nombre de voisins.
\n
"
;
cin
>>
nbVoisin
;
}
}
...
...
@@ -39,12 +40,12 @@ void RegleVoisinage::calculVoisinage(Voisinage& v, const Reseau& r) {
for
(
int
k
=
0
;
k
<
nbVoisin
;
k
++
)
{
unsigned
int
i
,
j
;
while
(
i
>=
r
.
getHauteur
()
||
j
>=
r
.
getLargeur
())
{
printf
(
"Entrez l'abscisse de la
%d
ième cellule.
\n
"
,
k
)
;
scanf
(
"%u"
,
&
i
)
;
printf
(
"Entrez l'ordonnée de la
%d
ième cellule.
\n
"
,
k
)
;
scanf
(
"%u"
,
&
j
)
;
cout
<<
"Entrez l'abscisse de la
"
<<
k
<<
"
ième cellule.
\n
"
;
cin
>>
i
;
cout
<<
"Entrez l'ordonnée de la
"
<<
k
<<
"
ième cellule.
\n
"
;
cin
>>
j
;
if
(
i
>=
r
.
getHauteur
()
||
j
>=
r
.
getLargeur
())
printf
(
"Coordonnées incorrecte!
\n
"
)
;
cout
<<
"Coordonnées incorrecte
!
\n
"
;
}
if
(
i
<
r
.
getHauteur
()
&&
j
<
r
.
getLargeur
())
v
.
voisinage
[
k
]
=
&
r
.
getReseau
()[
i
][
j
];
...
...
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