-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCara2D.cpp
72 lines (61 loc) · 1.46 KB
/
Cara2D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Cara2D.cpp: implementation of the Cara2D class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Cara2D.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Cara2D::Cara2D(int n) {
numVertices = n;
numAristas = n;
cont = 0;
cont2 = 0;
}
Cara2D::~Cara2D() { }
void Cara2D::addPunto2D(Punto2D p) {
if (cont < numVertices) {
listaVertices[cont] = p;
cont++;
}
}
bool Cara2D::buscarPunto(Punto2D p) {
bool encontrado = false;
for(int i = 0; ((i < cont) && (!encontrado)); i++) {
if (listaVertices[i] == p) encontrado = true;
}
if (encontrado) return true;
return false;
}
void Cara2D::addArista2D(Arista2D * a) {
if (cont2 < numAristas) {
listaAristas[cont2].copia(a);
cont2++;
if (cont2 == 1) {
addPunto2D(a->cogerPunto1());
addPunto2D(a->cogerPunto2());
}
else {
if (!buscarPunto(a->cogerPunto1())) {
addPunto2D(a->cogerPunto1());
}
if (!buscarPunto(a->cogerPunto2())) {
addPunto2D(a->cogerPunto2());
}
}
}
}
void Cara2D::erase(void) {
cont = 0;
cont2 = 0;
}
int Cara2D::modXmax(int m) {
if (Xmax == m) return -1;
Xmax = m;
return 0;
}
int Cara2D::modXmin(int m) {
if (Xmin == m) return -1;
Xmin = m;
return 0;
}