-
Notifications
You must be signed in to change notification settings - Fork 0
/
Classes.h
173 lines (147 loc) · 2.64 KB
/
Classes.h
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#ifndef FUNCTIONS_H__
#define FUNCTIONS_H__
#include <vector>
#include <assert.h>
#include <set>
using namespace std;
class Point;
class Face;
class Edge;
typedef vector<Point*>::iterator point_vec_it;
typedef vector<Face*>::iterator face_vec_it;
typedef vector<Edge*>::iterator edge_vec_it;
struct Vertex3f
{
Vertex3f()
{
}
Vertex3f(int nid,int nx,int ny,int nz)
{
id = nid;
p[0] = nx;
p[1] = ny;
p[2] = nz;
removed = false;
}
bool operator==(Vertex3f& f)
{
return (id==f.id);
}
bool operator<(Vertex3f& f)
{
return (id<f.id);
}
double p[3];
int id;
bool removed;
};
class Point{
public:
Point(int nid, double nx, double ny, double nz){
id = nid;
x = nx;
y = ny;
z = nz;
removed = false;
}
bool operator==(Point& p)
{
if(id == p.id)
{
return true;
}
return false;
}
bool operator<(Point& p)
{
return (id < p.id);
}
void addFace(Face* f)
{
faces.push_back(f);
}
bool isValid() //Return whether the point has faces assign to it
{
return (faces.size() > 0);
}
int id;
double x;
double y;
double z;
bool removed;
std::vector<Point*>::iterator pointer; //Iterator to the list of points (vertices)
vector<Face*> faces;
vector<Edge*> edges;
vector<Edge*> to;
vector<Edge*> from;
vector<int> i_faces;
vector<int> i_from;
vector<int> i_to;
double Q[4][4];
};
class Edge
{
public:
int id;
double cost;
bool removed;
Point* p1;
Point* p2;
Point* placement;
std::vector<Edge*>::iterator pointer; //Iterator to list of edges
std::vector<Face*> faces;
Edge(Point* pa, Point* pb)
{
p1 = pa;
p2 = pb;
removed = false;
placement = new Point(0, p2->x,p2->y,p2->z);
}
void addFace(Face* f)
{
assert(faces.size() < 2);
faces.push_back(f);
}
bool operator==(Edge& e) const{
if (p1 == e.p1 && p2 == e.p2)
{
return true;
}
else return false;
}
//An edge comes first if its cost is smaller
bool operator<(const Edge e) const
{ //We want higher costs at the top of the priority_queue, that's why we invert operator <
return cost > e.cost;
}
};
class Face{
public:
int id;
vector<Point*> points;
vector<int> f_points;
std::vector<Face*>::iterator pointer; // Iterator to the list of faces
bool removed;
Face(int nid)
{
id = nid;
removed = false;
}
bool operator==(Face& f)
{
if(id == f.id)
{
return true;
}
return false;
}
void addPoint(Point* p)
{
points.push_back(p);
}
bool isValid() //If face has vertices assigned to it
{
return (points.size() > 0);
}
};
#endif