summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilrik de Loose <wilrik@wilrik.nl>2008-01-09 14:42:19 (GMT)
committerWilrik de Loose <wilrik@wilrik.nl>2008-01-09 14:42:19 (GMT)
commit8e1b200487c1509898a766ce1c3729b8deeba081 (patch)
tree8307c493ba46d5919ba848675fe2302335ee512a
parenta8ce8c6ea988e99570bed36b37a6ec02cf9e2059 (diff)
download2iv35-8e1b200487c1509898a766ce1c3729b8deeba081.zip
2iv35-8e1b200487c1509898a766ce1c3729b8deeba081.tar.gz
2iv35-8e1b200487c1509898a766ce1c3729b8deeba081.tar.bz2
smooth isolines
-rw-r--r--Smoke/Week 2.suobin66560 -> 73728 bytes
-rw-r--r--Smoke/gui_requirements.txt5
-rw-r--r--Smoke/interact.c3
-rw-r--r--Smoke/isolines.c2
-rw-r--r--Smoke/palette.c2
-rw-r--r--Smoke/renderer_gl.c279
6 files changed, 117 insertions, 174 deletions
diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo
index 581e8f3..52b0292 100644
--- a/Smoke/Week 2.suo
+++ b/Smoke/Week 2.suo
Binary files differ
diff --git a/Smoke/gui_requirements.txt b/Smoke/gui_requirements.txt
index 5164a9c..8f258ac 100644
--- a/Smoke/gui_requirements.txt
+++ b/Smoke/gui_requirements.txt
@@ -5,7 +5,7 @@ COLOR MAPPING
+ clamping
+ / - color legend bug (scaling, clamping, negative values)
- saturation and hue
-- scaling
+- autoscaling
GLYPHS
@@ -14,6 +14,7 @@ GLYPHS
+ / - grid resolution (var_dim)
+ / - choose different glyph
- change glyph scaling
+- blending
DIVERGENCE
@@ -33,7 +34,7 @@ HEIGHT PLOTS
+ mouse rotation
+ mouse translation
+ mouse zoom
-- select different scalar field for height
++ / - select different scalar field for height
STREAM TUBES
diff --git a/Smoke/interact.c b/Smoke/interact.c
index c1a83cc..d6a8a16 100644
--- a/Smoke/interact.c
+++ b/Smoke/interact.c
@@ -3,6 +3,7 @@
#include "renderer_gl.h"
#include "colormap.h"
+#include "seedpoint.h"
#define MOUSE_SMOKE 0
#define MOUSE_SCALE_MIN 1
@@ -65,6 +66,8 @@ void click(int button, int state, int mx, int my)
prev_rot_mz = mx;
}
+ //create_seedpoint(mx, my);
+
if (my <25) {
/* Click received on button bar */
float min, max;
diff --git a/Smoke/isolines.c b/Smoke/isolines.c
index 64358eb..45d37b7 100644
--- a/Smoke/isolines.c
+++ b/Smoke/isolines.c
@@ -12,7 +12,7 @@
#include "isolines.h"
-static int isolines_render = TRUE;
+static int isolines_render = FALSE;
static int isolines_num_colors = PALETTE_MAXCOLORS;
static int isolines_colormap = PALETTE_RED;
diff --git a/Smoke/palette.c b/Smoke/palette.c
index 49b0354..91b944f 100644
--- a/Smoke/palette.c
+++ b/Smoke/palette.c
@@ -29,7 +29,7 @@ void HSVtoRGB(float *r, float *g, float *b, float h, float s, float v)
}
h /= 60; // sector 0 to 5
- i = floor(h);
+ i = (int)floor(h);
f = h - i; // factorial part of h
p = v * (1 - s);
q = v * (1 - s * f);
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 1d87640..59489c5 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -26,9 +26,7 @@
#include "streamlines.h"
#include "heightplots.h"
#include "flowvis.h"
-
#include "seedpoint.h"
-
#include "renderer_gl.h"
#define DEFAULT_X_POS 0.0f
@@ -541,59 +539,51 @@ static void render_glyphs(void)
gluDeleteQuadric(qobj);
}
-//#define percentage(h, l, t) ( 1 - ( (t - min(h, l) ) / (max(h, l) - min(h, l) ) ) )
-
-float percentage(float h, float l, float t)
+struct point get_intersection(struct point pi, struct point pj, float fi, float fj, float t)
{
- float perc, delp, deltp;
- float min = min(h, l);
- float max = max(h, l);
+ struct point rp;
+ rp.z = 8.0f;
- delp = max - min;
- deltp = t - min;
- perc = deltp / delp;
+ if (fi == min(fi, fj))
+ {
+ rp.x = (pi.x * (fj - t) + pj.x * (t - fi)) / (fj - fi);
+ rp.y = (pi.y * (fj - t) + pj.y * (t - fi)) / (fj - fi);
+ }
+ else
+ {
+ rp.x = (pj.x * (fi - t) + pi.x * (t - fj)) / (fi - fj);
+ rp.y = (pj.y * (fi - t) + pi.y * (t - fj)) / (fi - fj);
+ }
- return perc;
+ return rp;
}
static void render_isolines(void)
{
- fftw_real wn, hn;
- int count, DIM;
- float iso_scale;
+ int idx, count, i, j, state, DIM;
+ float wn, hn, v0, v1, v2, v3, threshold, iso_scale;
+ float x0, y0, z0, x1, y1, z1, x_offset, y_offset;
+ struct color4f color;
+ struct point p0, p1, p2, p3, e1, e2;
DIM = fluids_get_dim();
wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
- iso_scale = isolines_get_threshold_min();
- iso_scale = isolines_get_threshold_max();
- iso_scale = isolines_get_nr();
+ z0 = z1 = 8.0f;
- if (isolines_get_nr()) {
- iso_scale = (float)(fabs(isolines_get_threshold_min() - isolines_get_threshold_max()) / isolines_get_nr());
- } else {
+ if (isolines_get_nr())
+ {
+ iso_scale = fabs(isolines_get_threshold_min() - isolines_get_threshold_max()) / isolines_get_nr();
+ }
+ else
+ {
iso_scale = 0.0f;
}
for (count = 0; count < isolines_get_nr(); count++)
{
- int idx;
- int i, j;
- float v0, v1, v2, v3;
- float x0, y0, x1, y1, x_offset, y_offset;
- int state = 0;
- static int prev_state = 0;
- struct color4f color;
- float threshold;
-
- static int low = 0;
- static int hig = 0;
-
- v0 = v1 = v2 = v3 = 0.0f;
- x0 = y0 = x1 = y1 = 0.0f;
-
threshold = min(isolines_get_threshold_min(), isolines_get_threshold_max()) + count * iso_scale;
glDisable(GL_LIGHTING);
@@ -608,7 +598,6 @@ static void render_isolines(void)
idx = (j * DIM) + i;
color = isolines_get_color(get_dataset(idx));
glColor4f(color.r, color.g, color.b, color.a);
- //glColor3f(1.0f, 0.0f, 0.0f);
v0 = get_dataset(idx + DIM);
v1 = get_dataset(idx + 1 + DIM);
@@ -620,145 +609,93 @@ static void render_isolines(void)
if (v2 >= threshold) { state += 4; }
if (v3 >= threshold) { state += 8; }
- if (state > 0 && state < 15)
+ x_offset = wn + (fftw_real)i * wn;
+ y_offset = (2 * hn) + (fftw_real)j * hn;
+
+ p0.x = x_offset;
+ p0.y = y_offset + hn;
+ p0.z = z0;
+
+ p1.x = x_offset + wn;
+ p1.y = y_offset + hn;
+ p1.z = z0;
+
+ p2.x = x_offset + wn;
+ p2.y = y_offset;
+ p2.z = z0;
+
+ p3.x = x_offset;
+ p3.y = y_offset;
+ p3.z = z0;
+
+ switch(state)
{
- x_offset = wn + (fftw_real)i * wn;
- y_offset = hn + (fftw_real)j * hn;
-
- switch (state)
- {
- case 1:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
- break;
-
- case 2:
- x0 = percentage(v1, v0, threshold) * wn;
- y0 = hn;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 3:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 4:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 5:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
-
- glVertex3i(x_offset + x0, y_offset + y0, 5.0f);
- glVertex3i(x_offset + x1, y_offset + y1, 5.0f);
-
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 6:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
- break;
-
- case 7:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = 0;
- y1 = percentage(v3, v0, threshold) * hn;
- break;
-
- case 8:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = 0;
- y1 = percentage(v3, v0, threshold) * hn;
- break;
-
- case 9:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
- break;
-
- case 10:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
-
- glVertex3i(x_offset + x0, y_offset + y0, 5.0f);
- glVertex3i(x_offset + x1, y_offset + y1, 5.0f);
-
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 11:
- x0 = percentage(v3, v2, threshold) * wn;
- y0 = 0;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 12:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 13:
- x0 = percentage(v1, v0, threshold) * wn;
- y0 = hn;
- x1 = wn;
- y1 = percentage(v2, v1, threshold) * hn;
- break;
-
- case 14:
- x0 = 0;
- y0 = percentage(v3, v0, threshold) * hn;
- x1 = percentage(v1, v0, threshold) * wn;
- y1 = hn;
- break;
-
- case 0: case 15: default:
- x0 = y0 = x1 = y1 = 0.0f;
- break;
- }
-
- // draw line
- glVertex3i(x_offset + x0, y_offset + y0, 5.0f);
- glVertex3i(x_offset + x1, y_offset + y1, 5.0f);
- }
+ default:
+ state = 0;
+ case 0:
+ case 15:
+ e1.x = e1.y = e1.z = 0.0f;
+ e2.x = e2.y = e2.z = 0.0f;
+ break;
+
+ case 1:
+ case 14:
+ e1 = get_intersection(p0, p3, v0, v3, threshold);
+ e2 = get_intersection(p0, p1, v0, v1, threshold);
+ break;
+
+ case 2:
+ case 13:
+ e1 = get_intersection(p1, p0, v1, v0, threshold);
+ e2 = get_intersection(p1, p2, v1, v2, threshold);
+ break;
+
+ case 3:
+ case 12:
+ e1 = get_intersection(p0, p3, v0, v3, threshold);
+ e2 = get_intersection(p1, p2, v1, v2, threshold);
+ break;
+
+ case 4:
+ case 11:
+ e1 = get_intersection(p2, p3, v2, v3, threshold);
+ e2 = get_intersection(p2, p1, v2, v1, threshold);
+ break;
+
+ case 5:
+ case 10:
+ e1 = get_intersection(p0, p3, v0, v3, threshold);
+ e2 = get_intersection(p0, p1, v0, v1, threshold);
+ glVertex3i(e1.x, e1.y, e1.z);
+ glVertex3i(e2.x, e2.y, e2.z);
+
+ e1 = get_intersection(p2, p3, v2, v3, threshold);
+ e2 = get_intersection(p2, p1, v2, v1, threshold);
+ break;
+
+ case 6:
+ case 9:
+ e1 = get_intersection(p2, p3, v2, v3, threshold);
+ e2 = get_intersection(p1, p0, v1, v0, threshold);
+ break;
+
+ case 7:
+ case 8:
+ e1 = get_intersection(p2, p3, v2, v3, threshold);
+ e2 = get_intersection(p0, p3, v0, v3, threshold);
+ break;
+ } // end switch state
+
+ // draw line
+ glVertex3i(e1.x, e1.y, e1.z);
+ glVertex3i(e2.x, e2.y, e2.z);
}
- }
-
+ } // end for count
glEnd();
}
glEnable(GL_LIGHTING);
}
-
static void render_streamlines(void)
{
int i, j, k, l, idx, DIM;
@@ -785,7 +722,7 @@ static void render_streamlines(void)
cell_y = round(p.y / cell_y);
idx = cell_x + (cell_y * DIM) + (j * DIM * DIM);
- //v = frame_history[idx];
+ v = frame_history[idx];
j++;
}
@@ -994,5 +931,7 @@ void visualize(struct vis_data_arrays *vis_data)
render_normals();
}
+ render_streamlines();
+
render_legend();
}