summaryrefslogtreecommitdiff
path: root/src/animate.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-01-24 18:55:36 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-01-24 18:55:36 -0500
commitc83636a1b56b331cf4ea16450dcf637e6e9fae8a (patch)
tree412fb957e177c667213baee2af44d9a2ed01a81b /src/animate.cpp
parent2b9a37884b27e272c48c3c44e4ddd0d091b7f16d (diff)
downloadfuse_networks-c83636a1b56b331cf4ea16450dcf637e6e9fae8a.tar.gz
fuse_networks-c83636a1b56b331cf4ea16450dcf637e6e9fae8a.tar.bz2
fuse_networks-c83636a1b56b331cf4ea16450dcf637e6e9fae8a.zip
added square lattice animation, and fixed the animation library to handle non-triangle cells
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();
}
}