-
Notifications
You must be signed in to change notification settings - Fork 7
/
LEDomeFace.pde
231 lines (183 loc) · 5.59 KB
/
LEDomeFace.pde
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/**
* The LEDomeFace class represents a face on the LEDome.
* Use xf(), yf(), and zf() to get the coordinates of the center of the face.
*
* Furthermore:
* It knows if it has any lights on it at all (LEDomeFace#hasLights())
* It knows what which lights are on it's face (LEDomeFace#points)
* It knows which faces are nearby (LEDomeFace#neighbors)
* It knows the 3 faces in which it shares an edge (LEDomeFace#nextDoorNeighbors)
* It also has a reference to the face object from the 3d mesh model (LEDomeFace#he_face)
*/
public static class LEDomeFace {
public HE_Face he_face;
public int index;
public List<LXPoint> points;
public List<LEDomeEdge> edges;
private List<Integer> neighbors;
private List<Integer> nextDoorNeighbors;
public LEDomeFace(HE_Face face, int index) {
this.he_face = face;
this.index = index;
}
public LEDomeFace(HE_Face face, List<LXPoint> lxPoints) {
he_face = face;
points = lxPoints;
}
public float xf() {
return he_face.getFaceCenter().xf();
}
public float yf() {
return he_face.getFaceCenter().yf();
}
public float zf() {
return he_face.getFaceCenter().zf();
}
public double xd() {
return he_face.getFaceCenter().xd();
}
public double yd() {
return he_face.getFaceCenter().yd();
}
public double zd() {
return he_face.getFaceCenter().zd();
}
public void setPoints(List<LXPoint> lxPoints) {
this.points = lxPoints;
}
public void setEdges(List<LEDomeEdge> edges) {
this.edges = edges;
}
public List<Integer> getNeighbors() {
if (this.neighbors == null) {
this.neighbors = new ArrayList<Integer>();
for(HE_Vertex he_vertex : this.he_face.getFaceVertices()) {
for(HE_Face he_neighbor : he_vertex.getFaceStar()) {
if (he_neighbor.getLabel() == this.he_face.getLabel()) {
continue;
}
if (!this.neighbors.contains(he_neighbor.getLabel())) {
this.neighbors.add(he_neighbor.getLabel());
}
}
}
}
return this.neighbors;
}
public List<Integer> getNextDoorNeighbors() {
if (this.nextDoorNeighbors == null) {
this.nextDoorNeighbors = new ArrayList<Integer>();
for(HE_Face he_neighbor : this.he_face.getNeighborFaces()) {
if (!this.nextDoorNeighbors.contains(he_neighbor.getLabel())) {
this.nextDoorNeighbors.add(he_neighbor.getLabel());
}
}
}
return this.nextDoorNeighbors;
}
public boolean hasLights() {
return this.points != null && this.points.size() > 0;
}
public boolean onFace(LXPoint point) {
return this.points != null && this.points.contains(point);
}
}
public static class LEDomeEdge {
public HE_Halfedge he_halfedge;
public LEDomeFace ledome_face;
public List<LXPoint> points;
public LEDomeEdge(LEDomeFace face, HE_Halfedge edge) {
setFace(face);
setHalfedge(edge);
}
public LEDomeEdge(LEDomeFace face, HE_Halfedge edge, List<LXPoint> points) {
setFace(face);
setHalfedge(edge);
setPoints(points);
}
public void setFace(LEDomeFace face) {
this.ledome_face = face;
}
public void setHalfedge(HE_Halfedge edge) {
this.he_halfedge = edge;
}
public void setPoints(List<LXPoint> points) {
this.points = points;
}
public void addPoint(LXPoint point) {
if(this.points == null) {
this.points = new ArrayList<LXPoint>();
}
points.add(point);
}
public LXPoint closestPoint(float x, float y, float z) {
float min_dist = 1000 * FEET;
LXPoint retPoint = this.points.get(0);
for(LXPoint p : this.points) {
float curr_dist = dist(p.x, p.y, p.z, x, y, z);
if(curr_dist < min_dist) {
min_dist = curr_dist;
retPoint = p;
}
}
return retPoint;
}
public LXPoint farthestPoint(float x, float y, float z) {
float max_dist = 0;
LXPoint retPoint = this.points.get(0);
for(LXPoint p : this.points) {
float curr_dist = dist(p.x, p.y, p.z, x, y, z);
if(curr_dist > max_dist) {
max_dist = curr_dist;
retPoint = p;
}
}
return retPoint;
}
public LXPoint closestVertexPoint(float x, float y, float z) {
float min_dist = 1000 * FEET;
LXPoint retPoint = this.points.get(0);
LXPoint[] vertexPoints = new LXPoint[] { this.points.get(0), this.points.get(2) };
for(LXPoint p : vertexPoints) {
float curr_dist = dist(p.x, p.y, p.z, x, y, z);
if(curr_dist < min_dist) {
min_dist = curr_dist;
retPoint = p;
}
}
return retPoint;
}
public float vertexXf() {
return he_halfedge.getVertex().xf();
}
public float vertexYf() {
return this.he_halfedge.getVertex().yf();
}
public float vertexZf() {
return this.he_halfedge.getVertex().zf();
}
public float xf() {
return this.he_halfedge.getEdgeCenter().xf();
}
public float yf() {
return this.he_halfedge.getEdgeCenter().yf();
}
public float zf() {
return this.he_halfedge.getEdgeCenter().zf();
}
public double xd() {
return this.he_halfedge.getEdgeCenter().xd();
}
public double yd() {
return this.he_halfedge.getEdgeCenter().yd();
}
public double zd() {
return this.he_halfedge.getEdgeCenter().zd();
}
public boolean hasLights() {
return this.points != null && this.points.size() > 0;
}
public boolean onEdge(LXPoint point) {
return this.points != null && this.points.contains(point);
}
}