/
EdgeInstance.h
62 lines (49 loc) · 1.49 KB
/
EdgeInstance.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
#ifndef EDGEINSTANCE_H_
#define EDGEINSTANCE_H_
#include "FaceInstance.h"
class EdgeInstance : public ISelectable {
FaceInstances& m_faceInstances;
SelectableEdge* m_edge;
void select_edge(bool select) {
FaceVertexId faceVertex = m_edge->m_faceVertex;
m_faceInstances[faceVertex.getFace()].select_edge(faceVertex.getVertex(), select);
faceVertex = next_edge(m_edge->m_faces, faceVertex);
m_faceInstances[faceVertex.getFace()].select_edge(faceVertex.getVertex(), select);
}
bool selected_edge() const {
FaceVertexId faceVertex = m_edge->m_faceVertex;
if (!m_faceInstances[faceVertex.getFace()].selected_edge(faceVertex.getVertex())) {
return false;
}
faceVertex = next_edge(m_edge->m_faces, faceVertex);
if (!m_faceInstances[faceVertex.getFace()].selected_edge(faceVertex.getVertex())) {
return false;
}
return true;
}
public:
EdgeInstance(FaceInstances& faceInstances, SelectableEdge& edge)
: m_faceInstances(faceInstances), m_edge(&edge) {}
EdgeInstance& operator=(const EdgeInstance& other) {
m_edge = other.m_edge;
return *this;
}
virtual ~EdgeInstance() {}
void setSelected(bool select) {
select_edge(select);
}
bool isSelected() const {
return selected_edge();
}
void invertSelected() {
setSelected(!isSelected());
}
void testSelect(Selector& selector, SelectionTest& test) {
SelectionIntersection best;
m_edge->testSelect(test, best);
if (best.isValid()) {
selector.addWithIntersection(*this, best);
}
}
};
#endif /*EDGEINSTANCE_H_*/