-
Notifications
You must be signed in to change notification settings - Fork 1
/
edge.h
75 lines (61 loc) · 1.76 KB
/
edge.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
#ifndef _EDGE_H_
#define _EDGE_H_
#include <cassert>
#include <cstdlib>
class Vertex;
class Face;
// ===================================================================
// half-edge data structure
class Edge {
public:
// ========================
// CONSTRUCTORS & DESTRUCTOR
Edge(Vertex *vs, Vertex *ve, Face *f);
~Edge();
// =========
// ACCESSORS
Vertex* getStartVertex() const { assert (start_vertex != NULL); return start_vertex; }
Vertex* getEndVertex() const { assert (end_vertex != NULL); return end_vertex; }
Edge* getNext() const { assert (next != NULL); return next; }
Face* getFace() const { assert (face != NULL); return face; }
Edge* getOpposite() const {
// warning! the opposite edge might be NULL!
return opposite; }
double Length() const;
// =========
// MODIFIERS
void setOpposite(Edge *e) {
assert (opposite == NULL);
assert (e != NULL);
assert (e->opposite == NULL);
opposite = e;
e->opposite = this;
}
void clearOpposite() {
if (opposite == NULL) return;
assert (opposite->opposite == this);
opposite->opposite = NULL;
opposite = NULL;
}
void setNext(Edge *e) {
assert (next == NULL);
assert (e != NULL);
assert (face == e->face);
next = e;
}
private:
Edge(const Edge&) { assert(0); }
Edge& operator=(const Edge&) { assert(0); exit(0); }
// ==============
// REPRESENTATION
// in the half edge data adjacency data structure, the edge stores everything!
// note: it's technically not necessary to store both vertices, but it makes
// dealing with non-closed meshes easier
Vertex *start_vertex;
Vertex *end_vertex;
Face *face;
Edge *opposite;
Edge *next;
};
// ===================================================================
#endif