From d2dfa01936d3d6e2a9ce7213ab4471e03b6a62e3 Mon Sep 17 00:00:00 2001 From: Wilrik de Loose Date: Wed, 9 Jan 2008 10:13:09 +0000 Subject: lalala --- Smoke/Week 2.suo | Bin 67072 -> 66560 bytes Smoke/fluids.c | 15 +---- Smoke/fluids.h | 15 +++-- Smoke/glyphs.c | 26 +++++---- Smoke/glyphs.h | 3 + Smoke/gtk_glyphs.c | 128 ++++++++++++++++++++++++++++++++++++------ Smoke/gtk_isolines.c | 29 +++++----- Smoke/gui_requirements.txt | 6 +- Smoke/isolines.c | 7 +-- Smoke/quake.bmp | Bin 43256 -> 43254 bytes Smoke/renderer_gl.c | 37 +++++++----- Smoke/report/2IV35-Report.log | 4 +- Smoke/report/2IV35-Report.pdf | Bin 265585 -> 265587 bytes Smoke/report/chapter9.tex | 1 + 14 files changed, 183 insertions(+), 88 deletions(-) diff --git a/Smoke/Week 2.suo b/Smoke/Week 2.suo index 4e5fc42..d064c06 100644 Binary files a/Smoke/Week 2.suo and b/Smoke/Week 2.suo differ diff --git a/Smoke/fluids.c b/Smoke/fluids.c index c020b2f..2113357 100644 --- a/Smoke/fluids.c +++ b/Smoke/fluids.c @@ -44,7 +44,6 @@ int vis_dataset = DATASET_RHO; int active_slider = 0; int glyph_scalar = SCALAR_RHO; int glyph_vector = VECTOR_VEL; -int glyph_sort = GLYPH_BITMAPS; GLuint startList; float threshold1 = 0.2f; float threshold2 = 2.0f; @@ -576,26 +575,16 @@ void set_glyph_vector(int arg) { glyph_vector = arg; } // getters and setters -int get_var_dims(void) +int fluids_get_var_dim(void) { return var_dims; } -void set_var_dims(int dims) +void fluids_set_var_dim(int dims) { var_dims = dims; } -int get_glyph_sort(void) -{ - return glyph_sort; -} - -void set_glyph_sort(int sort) -{ - glyph_sort = sort; -} - void fluids_set_calculate(int calculate) { fluids_calculate = calculate; diff --git a/Smoke/fluids.h b/Smoke/fluids.h index 4f1fdf6..85e82b5 100644 --- a/Smoke/fluids.h +++ b/Smoke/fluids.h @@ -29,10 +29,11 @@ extern int frame_index; #define VECTOR_VEL 0 #define VECTOR_FORCE 1 -#define GLYPH_ARROWS 0 -#define GLYPH_LINES 1 -#define GLYPH_CONES 2 -#define GLYPH_BITMAPS 3 +#define GLYPH_LINES 0 +#define GLYPH_TRIANGLES 1 +#define GLYPH_CONES 2 +#define GLYPH_ARROWS 3 +#define GLYPH_QUAKE 4 extern int winWidth, winHeight; //size of the graphics window, in pixels extern int color_dir; //use direction color-coding or not @@ -47,10 +48,8 @@ void select_dataset(int arg); void set_glyph_scalar(int arg); void set_glyph_vector(int arg); -int get_var_dims(void); -void set_var_dims(int); -int get_glyph_sort(void); -void set_glyph_sort(int sort); +int fluids_get_var_dim(void); +void fluids_set_var_dim(int); struct point { float x; diff --git a/Smoke/glyphs.c b/Smoke/glyphs.c index 6d562bf..7c46eb0 100644 --- a/Smoke/glyphs.c +++ b/Smoke/glyphs.c @@ -3,7 +3,6 @@ #include #endif - #include #include "funcs.h" @@ -12,17 +11,14 @@ #include "glyphs.h" - -static int glyphs_render = FALSE; - -static int glyphs_num_colors = PALETTE_MAXCOLORS; - -static int glyphs_colormap = PALETTE_BLACKWHITE; +static int glyphs_render = FALSE; +static int glyphs_num_colors = PALETTE_MAXCOLORS; +static int glyphs_colormap = PALETTE_BLACKWHITE; +static int glyphs_sort = GLYPH_ARROWS; +static int glyphs_dataset_color = DATASET_RHO; +static int glyphs_dataset_direction = DATASET_RHO; static float glyphs_alpha = 0.5f; - -static int glyphs_dataset_color = DATASET_RHO; -static int glyphs_dataset_direction = DATASET_RHO; static fftw_real *glyphs_frame; @@ -86,6 +82,16 @@ int glyphs_get_dataset_direction(void) return glyphs_dataset_direction; } +void glyphs_set_sort(int sort) +{ + glyphs_sort = sort; +} + +int glyphs_get_sort(void) +{ + return glyphs_sort; +} + void glyphs_set_frame(fftw_real *frame) { glyphs_frame = frame; diff --git a/Smoke/glyphs.h b/Smoke/glyphs.h index fa97fe6..3bcc9d3 100644 --- a/Smoke/glyphs.h +++ b/Smoke/glyphs.h @@ -19,6 +19,9 @@ int glyphs_get_dataset_color(void); void glyphs_set_dataset_direction(int dataset); int glyphs_get_dataset_direction(void); +void glyphs_set_sort(int sort); +int glyphs_get_sort(void); + void glyphs_set_frame(fftw_real *frame); fftw_real *glyphs_get_frame(void); diff --git a/Smoke/gtk_glyphs.c b/Smoke/gtk_glyphs.c index 9d7a3cb..ca392eb 100644 --- a/Smoke/gtk_glyphs.c +++ b/Smoke/gtk_glyphs.c @@ -51,6 +51,22 @@ static gboolean set_dataset_direction(GtkToggleButton *button, gpointer data) } +static gboolean select_sort(GtkComboBox *combo, gpointer data) +{ + glyphs_set_sort(gtk_combo_box_get_active(combo)); + + return TRUE; +} + + +static gboolean select_var_dim(GtkRange *adjustment, gpointer data) +{ + fluids_set_var_dim((int)gtk_range_get_value(adjustment)); + + return TRUE; +} + + GtkWidget *create_glyphs_page(void) { /* in reality a page is really just a vbox filled with other widgets @@ -60,10 +76,11 @@ GtkWidget *create_glyphs_page(void) GtkWidget *box; GtkWidget *label; GtkWidget *button; - GtkWidget *combo; - GtkAdjustment *color_adjustment; - GtkWidget *color_scale; + GtkWidget *combo; + GtkAdjustment *adjustment; + GtkWidget *scale; GSList *dataset_group; + int j = 0 ; page = gtk_vbox_new(FALSE, 0); @@ -141,7 +158,84 @@ GtkWidget *create_glyphs_page(void) gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); - + + + + //frame = gtk_frame_new("Glyphs"); + + // box = gtk_vbox_new(FALSE, 0); + + // label = gtk_label_new("Parameterize the glyphs"); + + // gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); + // gtk_widget_show(label); + + // combo = gtk_combo_box_new_text(); + + // gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Hedgehogs"); + // gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Triangles"); + // gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "3D Cones"); + // gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Arrow images"); + // gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Quake"); + + // gtk_combo_box_set_active(GTK_COMBO_BOX(combo), glyphs_get_sort()); + // g_signal_connect(combo, "changed", G_CALLBACK(select_sort), (gpointer)NULL); + + // gtk_box_pack_start(GTK_BOX(box), combo, FALSE, TRUE, 0); + // gtk_widget_show(combo); + + //gtk_widget_show(frame); + + + frame = gtk_frame_new("Glyphs"); + + box = gtk_vbox_new(FALSE, 0); + + + label = gtk_label_new("Parameterize the glyphs"); + + gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); + gtk_widget_show(label); + + + combo = gtk_combo_box_new_text(); + + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Hedgehogs"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Triangles"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "3D Cones"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Arrow images"); + gtk_combo_box_append_text(GTK_COMBO_BOX(combo), "Quake"); + + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), glyphs_get_sort()); + g_signal_connect(combo, "changed", G_CALLBACK(select_sort), (gpointer)NULL); + + gtk_box_pack_start(GTK_BOX(box), combo, FALSE, TRUE, 0); + gtk_widget_show(combo); + + + + label = gtk_label_new("Change resolution of glyphs"); + + gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); + gtk_widget_show(label); + + + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(fluids_get_var_dim(), 5, fluids_get_dim() + 25, 0.5, 5, 0)); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_var_dim), NULL); + + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); + + gtk_container_add(GTK_CONTAINER(frame), box); + gtk_widget_show(box); + + gtk_box_pack_start(GTK_BOX(page), frame, FALSE, TRUE, 0); + + gtk_widget_show(frame); + + frame = gtk_frame_new("Colors"); @@ -175,28 +269,27 @@ GtkWidget *create_glyphs_page(void) gtk_widget_show(label); - color_adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( - glyphs_get_num_colors(), 1, PALETTE_MAXCOLORS, 0.5, 5, 0.1)); - color_scale = gtk_hscale_new(color_adjustment); - gtk_scale_set_digits(GTK_SCALE(color_scale), 0); - g_signal_connect(GTK_RANGE(color_scale), "value-changed", G_CALLBACK(select_num_colors), NULL); + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new(glyphs_get_num_colors(), 1, PALETTE_MAXCOLORS, 0.5, 5, 0.1)); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 0); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_num_colors), NULL); - gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); - gtk_widget_show(color_scale); + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); label = gtk_label_new("Alpha"); gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); gtk_widget_show(label); - color_adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( + adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( glyphs_get_alpha(), 0, 1, 0.05, 0.05, 0.01)); - color_scale = gtk_hscale_new(color_adjustment); - gtk_scale_set_digits(GTK_SCALE(color_scale), 1); - g_signal_connect(GTK_RANGE(color_scale), "value-changed", G_CALLBACK(select_alpha), NULL); + scale = gtk_hscale_new(adjustment); + gtk_scale_set_digits(GTK_SCALE(scale), 1); + g_signal_connect(GTK_RANGE(scale), "value-changed", G_CALLBACK(select_alpha), NULL); - gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); - gtk_widget_show(color_scale); + gtk_box_pack_start(GTK_BOX(box), scale, FALSE, TRUE, 0); + gtk_widget_show(scale); gtk_container_add(GTK_CONTAINER(frame), box); gtk_widget_show(box); @@ -205,6 +298,5 @@ GtkWidget *create_glyphs_page(void) gtk_widget_show(frame); - return page; } diff --git a/Smoke/gtk_isolines.c b/Smoke/gtk_isolines.c index d5a6681..1308499 100644 --- a/Smoke/gtk_isolines.c +++ b/Smoke/gtk_isolines.c @@ -43,7 +43,7 @@ GtkWidget *create_isolines_page(void) page = gtk_vbox_new(FALSE, 0); -#if 0 + frame = gtk_frame_new("Scalarset"); box = gtk_hbox_new(FALSE, 0); @@ -71,7 +71,7 @@ GtkWidget *create_isolines_page(void) gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); - + frame = gtk_frame_new("Vectorset"); box = gtk_hbox_new(FALSE, 0); @@ -93,7 +93,7 @@ GtkWidget *create_isolines_page(void) gtk_box_pack_start (GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); - + frame = gtk_frame_new("Colors"); @@ -136,28 +136,27 @@ GtkWidget *create_isolines_page(void) gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); gtk_widget_show(color_scale); - label = gtk_label_new("Alpha"); + //label = gtk_label_new("Alpha"); - gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); - gtk_widget_show(label); + //gtk_box_pack_start(GTK_BOX(box), label, FALSE, TRUE, 0); + //gtk_widget_show(label); - color_adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( - isolines_get_alpha(), 0, 1, 0.05, 0.05, 0.01)); - color_scale = gtk_hscale_new(color_adjustment); - gtk_scale_set_digits(GTK_SCALE(color_scale), 1); - g_signal_connect(GTK_RANGE(color_scale), "value-changed", G_CALLBACK(select_alpha), NULL); + //color_adjustment = GTK_ADJUSTMENT(gtk_adjustment_new( + // isolines_get_alpha(), 0, 1, 0.05, 0.05, 0.01)); + //color_scale = gtk_hscale_new(color_adjustment); + // gtk_scale_set_digits(GTK_SCALE(color_scale), 1); + // g_signal_connect(GTK_RANGE(color_scale), "value-changed", G_CALLBACK(select_alpha), NULL); - gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); - gtk_widget_show(color_scale); + //gtk_box_pack_start(GTK_BOX(box), color_scale, FALSE, TRUE, 0); + //gtk_widget_show(color_scale); gtk_container_add(GTK_CONTAINER(frame), box); gtk_widget_show(box); - + gtk_box_pack_start(GTK_BOX(page), frame, FALSE, TRUE, 0); gtk_widget_show(frame); -#endif return page; } diff --git a/Smoke/gui_requirements.txt b/Smoke/gui_requirements.txt index e887a10..5621ca1 100644 --- a/Smoke/gui_requirements.txt +++ b/Smoke/gui_requirements.txt @@ -3,7 +3,7 @@ COLOR MAPPING + choose between colormaps + select number of colors + clamping -- color legend bug (scaling, clamping, negative values) ++ / - color legend bug (scaling, clamping, negative values) - saturation and hue - scaling @@ -11,8 +11,8 @@ GLYPHS + choose scalar field + choose vector field -- grid resolution (var_dim) -- choose different glyph ++ / - grid resolution (var_dim) ++ / - choose different glyph - change glyph scaling DIVERGENCE diff --git a/Smoke/isolines.c b/Smoke/isolines.c index 883b4b6..882b26a 100644 --- a/Smoke/isolines.c +++ b/Smoke/isolines.c @@ -12,14 +12,11 @@ #include "isolines.h" -static int isolines_render = TRUE; - +static int isolines_render = TRUE; static int isolines_num_colors = PALETTE_MAXCOLORS; - -static int isolines_colormap = PALETTE_BLACKWHITE; +static int isolines_colormap = PALETTE_BLACKWHITE; static float isolines_alpha = 1.0f; - static fftw_real *isolines_frame; diff --git a/Smoke/quake.bmp b/Smoke/quake.bmp index b7891dd..2093ec7 100644 Binary files a/Smoke/quake.bmp and b/Smoke/quake.bmp differ diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c index 3fc3a75..5a33093 100644 --- a/Smoke/renderer_gl.c +++ b/Smoke/renderer_gl.c @@ -45,7 +45,7 @@ #define LEGEND_Y_POS -295.0f #define LEGEND_Z_POS -735.0f -#define BITMAP_SOURCE "arrow.bmp" +#define BITMAP_SOURCE "quake.bmp" #define BITMAP_FILESIZE 0x02 #define BITMAP_OFFSET 0x0a #define BITMAP_HEADERSIZE 0x0e @@ -67,7 +67,7 @@ static GLuint texture; static void render_legend(void) { - int i; + int i, s, c; struct color4f color; glDisable(GL_LIGHTING); @@ -83,8 +83,16 @@ static void render_legend(void) value = (float)((float)i/winWidth); + s = colormap_get_scaling(); + c = colormap_get_clamping(); + + colormap_set_scaling(0); + colormap_set_clamping(0); + color = colormap_get_color(value); + colormap_set_scaling(s); + colormap_set_clamping(c); clamp_scaled_min = colormap_get_clamp_min() *winWidth; clamp_scaled_max = colormap_get_clamp_max() *winWidth; @@ -367,11 +375,11 @@ static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, floa int DIM; DIM = fluids_get_dim(); - scale = (float)((float)DIM / (float)get_var_dims()) / 6; + scale = (float)((float)DIM / (float)fluids_get_var_dim()) / 6; size = quake_root((x_value * x_value * 20) + (y_value * y_value * 20)) * 5 * scale; - wn = (fftw_real)winWidth / (fftw_real)(get_var_dims() + 1); // Grid cell width - hn = (fftw_real)winHeight / (fftw_real)(get_var_dims() + 1); // Grid cell heigh + wn = (fftw_real)winWidth / (fftw_real)(fluids_get_var_dim() + 1); // Grid cell width + hn = (fftw_real)winHeight / (fftw_real)(fluids_get_var_dim() + 1); // Grid cell heigh x0 = wn + (fftw_real)i * wn; y0 = hn + (fftw_real)j * hn; @@ -393,7 +401,7 @@ static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, floa theta = acos(in_prod) * (180/3.141592654); if (x1 > x0) { theta *= -1; } - switch(get_glyph_sort()) + switch(glyphs_get_sort()) { default: case GLYPH_LINES: @@ -403,7 +411,7 @@ static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, floa glEnd(); break; - case GLYPH_ARROWS: + case GLYPH_TRIANGLES: if (size < 0.08f) return; glPushMatrix(); @@ -441,7 +449,8 @@ static void render_glyph(GLUquadricObj *qobj, float x_value, float y_value, floa glPopMatrix(); break; - case GLYPH_BITMAPS: + case GLYPH_ARROWS: + case GLYPH_QUAKE: if (size < 0.08f) return; glPushMatrix(); @@ -480,10 +489,10 @@ static void render_glyphs(void) DIM = fluids_get_dim(); - scale = (float)((float)DIM / (float)get_var_dims()); - for (i = 0; i < get_var_dims(); i++) + scale = (float)((float)DIM / (float)fluids_get_var_dim()); + for (i = 0; i < fluids_get_var_dim(); i++) { - for (j = 0; j < get_var_dims(); j++) + for (j = 0; j < fluids_get_var_dim(); j++) { idxcf = round(j * scale) * DIM; idxrf = round(i * scale); @@ -520,7 +529,7 @@ static void render_glyphs(void) } } } - + gluDeleteQuadric(qobj); } @@ -586,8 +595,8 @@ static void render_isolines(void) state = 0; 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); + 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); diff --git a/Smoke/report/2IV35-Report.log b/Smoke/report/2IV35-Report.log index cb8fe8c..e9e5eff 100644 --- a/Smoke/report/2IV35-Report.log +++ b/Smoke/report/2IV35-Report.log @@ -1,4 +1,4 @@ -This is pdfeTeX, Version 3.141592-1.21a-2.2 (MiKTeX 2.4) (preloaded format=latex 2007.9.5) 8 JAN 2008 14:06 +This is pdfeTeX, Version 3.141592-1.21a-2.2 (MiKTeX 2.4) (preloaded format=latex 2007.9.5) 9 JAN 2008 09:38 entering extended mode **2IV35-Report.tex (2IV35-Report.tex @@ -649,4 +649,4 @@ ts\type1\bluesky\cm\cmsy10.pfb> -Output written on 2IV35-Report.pdf (25 pages, 265585 bytes). +Output written on 2IV35-Report.pdf (25 pages, 265587 bytes). diff --git a/Smoke/report/2IV35-Report.pdf b/Smoke/report/2IV35-Report.pdf index d8c31e4..d512c95 100644 Binary files a/Smoke/report/2IV35-Report.pdf and b/Smoke/report/2IV35-Report.pdf differ diff --git a/Smoke/report/chapter9.tex b/Smoke/report/chapter9.tex index 49a1c86..a9cb4f4 100644 --- a/Smoke/report/chapter9.tex +++ b/Smoke/report/chapter9.tex @@ -27,3 +27,4 @@ useful to be able to mail some of the troubles we had during the implementation. The two practical hours after the theoretical part were a bit to crowded for the teacher to be able to handle all questions from the students. This was a bit of a downside. Because of this we were'nt always able to show our new results or post question during the practical hour. \\ + -- cgit v0.12