summaryrefslogtreecommitdiff
path: root/src/animate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/animate.cpp')
-rw-r--r--src/animate.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/src/animate.cpp b/src/animate.cpp
index a24f0f2..4f10e0a 100644
--- a/src/animate.cpp
+++ b/src/animate.cpp
@@ -135,22 +135,22 @@ void animate::post_fracture(network &n) {
switch (key) {
case 's' :
for (auto edge : crack) {
- glBegin(GL_TRIANGLES);
glColor3f(1.0f, 0.0f, 0.0f);
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[0].x, n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[0].y);
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[1].x, n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[1].y);
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[2].x, n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon[2].y);
-
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[0].x, n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[0].y);
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[1].x, n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[1].y);
- glVertex2d(n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[2].x, n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon[2].y);
+ glBegin(GL_POLYGON);
+ for (const graph::coordinate &r : n.G.dual_vertices[n.G.dual_edges[edge].v[0]].polygon) {
+ glVertex2d(r.x, r.y);
+ }
+ glEnd();
+ glBegin(GL_POLYGON);
+ for (const graph::coordinate &r : n.G.dual_vertices[n.G.dual_edges[edge].v[1]].polygon) {
+ glVertex2d(r.x, r.y);
+ }
glEnd();
}
glFlush();
break;
case 'c' :
- glBegin(GL_TRIANGLES); // Each set of 3 vertices form a triangle
for (unsigned int i = 0; i < num; i++) {
if (i == crack_component) {
glColor3d(1.0, 0.0, 0.0);
@@ -159,17 +159,17 @@ void animate::post_fracture(network &n) {
}
for (auto it = components[i].begin(); it != components[i].end(); it++) {
- glVertex2d(n.G.dual_vertices[*it].polygon[0].x, n.G.dual_vertices[*it].polygon[0].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[1].x, n.G.dual_vertices[*it].polygon[1].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[2].x, n.G.dual_vertices[*it].polygon[2].y);
+ glBegin(GL_POLYGON); // Each set of 3 vertices form a triangle
+ for (const graph::coordinate &r: n.G.dual_vertices[*it].polygon) {
+ glVertex2d(r.x, r.y);
+ }
+ glEnd();
}
}
- glEnd();
glFlush();
break;
case 'C' :
- glBegin(GL_TRIANGLES); // Each set of 3 vertices form a triangle
for (unsigned int i = 0; i < num; i++) {
if (components[i].size() > 1) {
if (i == crack_component) {
@@ -179,25 +179,26 @@ void animate::post_fracture(network &n) {
}
for (auto it = components[i].begin(); it != components[i].end(); it++) {
- glVertex2d(n.G.dual_vertices[*it].polygon[0].x, n.G.dual_vertices[*it].polygon[0].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[1].x, n.G.dual_vertices[*it].polygon[1].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[2].x, n.G.dual_vertices[*it].polygon[2].y);
+ glBegin(GL_POLYGON); // Each set of 3 vertices form a triangle
+ for (const graph::coordinate &r :n.G.dual_vertices[*it].polygon) {
+ glVertex2d(r.x, r.y);
+ }
+ glEnd();
}
}
}
- glEnd();
glFlush();
break;
case 'm' :
- glBegin(GL_TRIANGLES);
- glColor3d(1.0, 0.0, 0.0);
for (auto it = components[crack_component].begin(); it != components[crack_component].end(); it++) {
- glVertex2d(n.G.dual_vertices[*it].polygon[0].x, n.G.dual_vertices[*it].polygon[0].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[1].x, n.G.dual_vertices[*it].polygon[1].y);
- glVertex2d(n.G.dual_vertices[*it].polygon[2].x, n.G.dual_vertices[*it].polygon[2].y);
- }
+ glBegin(GL_POLYGON);
+ glColor3d(1.0, 0.0, 0.0);
+ for (const graph::coordinate &r :n.G.dual_vertices[*it].polygon) {
+ glVertex2d(r.x, r.y);
+ }
glEnd();
+ }
glFlush();
}
}