summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilrik de Loose <wilrik@wilrik.nl>2008-01-10 22:18:46 (GMT)
committerWilrik de Loose <wilrik@wilrik.nl>2008-01-10 22:18:46 (GMT)
commit398578956e01518523a05d4245a2ce488955cf97 (patch)
tree7adacc47cf4a6b35eac9af0a07a39f790d9dc29e
parentc8c41f2f654c3a5283a299c27fd29fd47aaafe4f (diff)
download2iv35-398578956e01518523a05d4245a2ce488955cf97.zip
2iv35-398578956e01518523a05d4245a2ce488955cf97.tar.gz
2iv35-398578956e01518523a05d4245a2ce488955cf97.tar.bz2
'streamlines'
-rw-r--r--Smoke/Week 2.suobin78336 -> 78336 bytes
-rw-r--r--Smoke/fluids.c7
-rw-r--r--Smoke/gtk_streamlines.c11
-rw-r--r--Smoke/interact.c6
-rw-r--r--Smoke/renderer_gl.c16
-rw-r--r--Smoke/seedpoint.c2
-rw-r--r--Smoke/streamlines.c15
7 files changed, 39 insertions, 18 deletions
diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo
index 90a00dd..0dce0af 100644
--- a/Smoke/Week 2.suo
+++ b/Smoke/Week 2.suo
Binary files differ
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index b339d1e..25c4d84 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -382,8 +382,6 @@ void setup_arrays(struct vis_data_arrays *vis_data)
fftw_real *frame_smoke, *frame_streamlines;
struct fftw_real_xy scalar_frames_glyphs, scalar_frames_streamlines;
int dataset;
- struct fftw_real_xy *test;
-
fftw_real wn = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
fftw_real hn = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell height
@@ -397,8 +395,6 @@ void setup_arrays(struct vis_data_arrays *vis_data)
dataset = streamlines_get_dataset();
scalar_frames_streamlines = get_scalar_frames(vis_data, dataset);
- test = streamlines_get_history_scalars(0);
-
for (j = 0; j < DIM; j++)
{
for (i = 0; i < DIM; i++)
@@ -416,14 +412,11 @@ void setup_arrays(struct vis_data_arrays *vis_data)
vis_data->history_scalars[fluids_hisdex]->x[idx] = scalar_frames_streamlines.x[idx];
vis_data->history_scalars[fluids_hisdex]->y[idx] = scalar_frames_streamlines.y[idx];
- // printf("val copy: %p; val orig: %f; test: %p\n", vis_data->history_scalars[fluids_hisdex]->x, scalar_frames_streamlines.x[idx], test->x);
-
vis_data->height[idx] = calculate_height_plot(heightplots_get_dataset(), idx);
vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j);
if (frame_smoke[idx] < scale_min && frame_smoke[idx] > FLT_MIN) scale_min = frame_smoke[idx];
if (frame_smoke[idx] > scale_max) scale_max = frame_smoke[idx];
-
}
}
diff --git a/Smoke/gtk_streamlines.c b/Smoke/gtk_streamlines.c
index b90d26c..0f1e3c8 100644
--- a/Smoke/gtk_streamlines.c
+++ b/Smoke/gtk_streamlines.c
@@ -30,6 +30,11 @@ static gboolean select_alpha(GtkRange *adjustment, gpointer data)
return TRUE;
}
+static gboolean reset_seedpoints(GtkWidget *button, gpointer data) {
+ streamlines_reset_seedpoints();
+
+ return TRUE;
+}
GtkWidget *create_streamlines_page(void)
@@ -43,6 +48,7 @@ GtkWidget *create_streamlines_page(void)
GtkWidget *combo;
GtkAdjustment *adjustment;
GtkWidget *scale;
+ GtkWidget *button;
page = gtk_vbox_new(FALSE, 0);
@@ -111,6 +117,11 @@ GtkWidget *create_streamlines_page(void)
gtk_box_pack_start(GTK_BOX(page), frame, FALSE, TRUE, 0);
+ button = gtk_button_new_with_label("Delete seedpoints");
+ g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_seedpoints), NULL);
+ gtk_box_pack_start(GTK_BOX(box), button, TRUE, TRUE, 0);
+ gtk_widget_show(button);
+
gtk_widget_show(frame);
diff --git a/Smoke/interact.c b/Smoke/interact.c
index f44e03c..16098a9 100644
--- a/Smoke/interact.c
+++ b/Smoke/interact.c
@@ -4,6 +4,7 @@
#include "funcs.h"
#include "renderer_gl.h"
+#include "streamlines.h"
#include "colormap.h"
#include "seedpoint.h"
@@ -69,7 +70,10 @@ void click(int button, int state, int mx, int my)
prev_rot_mz = mx;
}
- create_seedpoint(mx, my);
+ if (streamlines_get_render())
+ {
+ create_seedpoint(mx, my);
+ }
if (my <25) {
/* Click received on button bar */
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index cd2e5c8..0f91404 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -736,18 +736,16 @@ static void render_streamlines(void)
i = j = k = l = 0;
DIM = fluids_get_dim();
-
-#if 0
for (i = 0; i < get_cur_seedpoint(); i++)
{
p = get_seedpoint(i);
glBegin(GL_LINE_STRIP);
- frame_history = streamlines_get_history_scalars(i);
-
for (j = 0; j < HISTORY_SIZE; j++)
{
+ frame_history = streamlines_get_history_scalars(j);
+
cell_x = (fftw_real)winWidth / (fftw_real)(DIM + 1); // Grid cell width
cell_y = (fftw_real)winHeight / (fftw_real)(DIM + 1); // Grid cell heigh
@@ -756,14 +754,13 @@ static void render_streamlines(void)
idx = (int)(cell_x * cell_y);
- vx = (float)frame_history[j].x[idx];
- vy = (float)frame_history[j].y[idx];
+ vx = (float)frame_history->x[idx];
+ vy = (float)frame_history->y[idx];
- glVertex3f(p.x + vx, winHeight - p.y + vy, 0.0f - j * cell_x);
+ glVertex3f(p.x + (vx * 10000), winHeight - p.y + (vy * 10000), 0.0f - j * cell_x);
}
glEnd();
}
-#endif
}
static void render_flowvis(void)
@@ -965,9 +962,8 @@ void visualize(struct vis_data_arrays *vis_data)
render_glyphs();
}
- render_seedpoints();
-
if (streamlines_get_render()) {
+ render_seedpoints();
render_streamlines();
}
diff --git a/Smoke/seedpoint.c b/Smoke/seedpoint.c
index 359bf03..cf48160 100644
--- a/Smoke/seedpoint.c
+++ b/Smoke/seedpoint.c
@@ -102,6 +102,8 @@ void delete_seedpoint(int seedpoint_nr)
seedpoints[i].z = 0.0f;
}
+ cur_seedpoint--;
+
} // delete_seedpoint
void render_seedpoints(void)
diff --git a/Smoke/streamlines.c b/Smoke/streamlines.c
index 1863439..4f28b83 100644
--- a/Smoke/streamlines.c
+++ b/Smoke/streamlines.c
@@ -11,6 +11,7 @@
#include "palette.h"
#include "streamlines.h"
+#include "seedpoint.h"
static int streamlines_render = FALSE;
static int streamlines_num_colors = PALETTE_MAXCOLORS;
@@ -102,3 +103,17 @@ struct color4f streamlines_get_color(float value)
return return_value;
}
+
+void streamlines_reset_seedpoints(void)
+{
+ int i, nr;
+
+ i = 0;
+ nr = get_cur_seedpoint();
+
+ while (i < nr)
+ {
+ delete_seedpoint(0);
+ i++;
+ }
+} \ No newline at end of file