-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFace.cpp
More file actions
128 lines (107 loc) · 2.75 KB
/
Copy pathFace.cpp
File metadata and controls
128 lines (107 loc) · 2.75 KB
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
#include "Face.h"
Face::Face(Vertex_iterator v0, Vertex_iterator v1, Vertex_iterator v2)
{
_vertices[0] = v0; _vertices[1] = v1; _vertices[2] = v2;
}
Face::Face(Face_iterator f0, Face_iterator f1, Face_iterator f2)
{
_neighbor[0] = f0; _neighbor[1] = f1; _neighbor[2] = f2;
}
Face::Face(Vertex_iterator v0, Vertex_iterator v1, Vertex_iterator v2,
Face_iterator f0, Face_iterator f1, Face_iterator f2)
{
_vertices[0] = v0; _vertices[1] = v1; _vertices[2] = v2;
_neighbor[0] = f0; _neighbor[1] = f1; _neighbor[2] = f2;
}
Face::Face(const Face& f)
{
_vertices[0] = f._vertices[0]; _neighbor[0] = f._neighbor[0];
_vertices[1] = f._vertices[1]; _neighbor[1] = f._neighbor[1];
_vertices[2] = f._vertices[2]; _neighbor[2] = f._neighbor[2];
}
Face& Face::operator=(const Face& f)
{
_vertices[0] = f._vertices[0]; _neighbor[0] = f._neighbor[0];
_vertices[1] = f._vertices[1]; _neighbor[1] = f._neighbor[1];
_vertices[2] = f._vertices[2]; _neighbor[2] = f._neighbor[2];
return *this;
}
bool Face::operator==(const Face& f)
{
bool vertices = (_vertices[0] == f._vertices[0] &&
_vertices[1] == f._vertices[1] &&
_vertices[2] == f._vertices[2] );
bool neighbor = (_neighbor[0] == f._neighbor[0] &&
_neighbor[1] == f._neighbor[1] &&
_neighbor[2] == f._neighbor[2] );
return (vertices && neighbor);
}
bool Face::operator!=(const Face& f)
{
return !(*this == f);
}
void Face::vertex(Vertex_iterator v, int i)
{
_vertices[i] = v;
}
void Face::neighbor(Face_iterator neighbor, int i)
{
_neighbor[i] = neighbor;
}
Vertex_iterator Face::vertex(int i)
{
return _vertices[i];
}
Face_iterator Face::neighbor(int i)
{
return _neighbor[i];
}
int Face::index(Face_iterator fc)
{
if(fc == neighbor(0))
return 0;
if(fc == neighbor(1))
return 1;
if(fc == neighbor(2))
return 2;
// If fc is not a neighbor.
std::cerr << "ERROR: face does not have this neighbor. (index function)\n";
return -1;
}
int Face::index(Vertex_iterator vi)
{
if(vi == vertex(0))
return 0;
if(vi == vertex(1))
return 1;
if(vi == vertex(2))
return 2;
// Face does not contain vertex.
std::cerr << "ERROR: face does not have the vertex. (index function)\n";
return -1;
}
bool Face::contains(Vertex_iterator v)
{
if(v == vertex(0) || v == vertex(1) || v == vertex(2))
return true;
return false;
}
bool Face::is_neighbor(Face_iterator fc)
{
if(fc == neighbor(0) || fc == neighbor(1) || fc == neighbor(2))
return true;
return false;
}
bool Face::is_vertex(Vertex_iterator v)
{
if(v == vertex(0) || v == vertex(1) || v == vertex(2))
return true;
return false;
}
void Face::reorient()
{
Vertex_iterator v0 = vertex(0); Vertex_iterator v1 = vertex(1);
Face_iterator n0 = neighbor(0); Face_iterator n1 = neighbor(1);
vertex(v0, 1); vertex(v1, 0);
neighbor(n0, 1); neighbor(n1, 0);
}