summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-01-10 20:52:19 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-01-10 20:52:19 (GMT)
commita003a02f8ae4f5bc14cbed9249b0fbfefdd2fd07 (patch)
tree8f3f61a0b2371a122c90835466895a45d4f7659a
parentf9e23896d3525e3dfe710585f6a88858cb88f8c6 (diff)
download2iv35-a003a02f8ae4f5bc14cbed9249b0fbfefdd2fd07.zip
2iv35-a003a02f8ae4f5bc14cbed9249b0fbfefdd2fd07.tar.gz
2iv35-a003a02f8ae4f5bc14cbed9249b0fbfefdd2fd07.tar.bz2
fx or vy get/setters added. mem probs fixed
-rw-r--r--Smoke/fluids.c32
-rw-r--r--Smoke/fluids.h9
-rw-r--r--Smoke/glyphs.c6
-rw-r--r--Smoke/glyphs.h4
-rw-r--r--Smoke/renderer_gl.c57
-rwxr-xr-xSmoke/smoke.binbin653473 -> 653837 bytes
-rw-r--r--Smoke/streamlines.c14
-rw-r--r--Smoke/streamlines.h3
8 files changed, 67 insertions, 58 deletions
diff --git a/Smoke/fluids.c b/Smoke/fluids.c
index 89308b0..01ca443 100644
--- a/Smoke/fluids.c
+++ b/Smoke/fluids.c
@@ -75,15 +75,17 @@ void fluids_init_simulation(int n, struct vis_data_arrays *vis_data)
for (i = 0; i < HISTORY_SIZE; i++)
{
vis_data->history_frame[i] = (fftw_real *)malloc(dim1);
- vis_data->history_scalars[i] = (struct fftw_real_xy *)malloc(dim *sizeof(struct fftw_real_xy));
+ vis_data->history_scalars[i].x = (fftw_real *)malloc(dim1);
+ vis_data->history_scalars[i].y = (fftw_real *)malloc(dim1);
}
fluids_reset_simulation();
- vis_data->rho = rho;
+ vis_data->rho = (fftw_real *)malloc(dim2);
vis_data->force = (fftw_real *)malloc(dim2);
vis_data->vel = (fftw_real *)malloc(dim1);
- vis_data->scalars = (struct fftw_real_xy *)malloc(dim *sizeof(struct fftw_real_xy));
+ vis_data->scalars.x = (fftw_real *)malloc(dim1);
+ vis_data->scalars.y = (fftw_real *)malloc(dim1);
vis_data->div_force = (fftw_real *)malloc(dim2);
vis_data->div_vel = (fftw_real *)malloc(dim1);
vis_data->height = (fftw_real *)malloc(dim2);
@@ -354,9 +356,9 @@ float par_der(float vp1, float v, fftw_real cell)
return (vp1 - v / cell);
}
-struct fftw_real_xy_p get_scalar_frames(struct vis_data_arrays *vis_data, int dataset)
+struct fftw_real_xy get_scalar_frames(struct vis_data_arrays *vis_data, int dataset)
{
- struct fftw_real_xy_p return_value;
+ struct fftw_real_xy return_value;
switch(dataset)
{
@@ -423,7 +425,7 @@ void setup_arrays(struct vis_data_arrays *vis_data)
int idx, i, j;
float scale_min, scale_max;
fftw_real *frame_smoke, *frame_streamlines;
- struct fftw_real_xy_p scalar_frames_glyphs, scalar_frames_streamlines;
+ struct fftw_real_xy scalar_frames_glyphs, scalar_frames_streamlines;
int dataset;
@@ -448,16 +450,16 @@ void setup_arrays(struct vis_data_arrays *vis_data)
vis_data->rho[idx] = rho[idx];
vis_data->vel[idx] = vec_len2f(vx[idx], vy[idx]);
vis_data->force[idx] = vec_len2f(fx[idx], fy[idx]);
- vis_data->scalars[idx].x = scalar_frames_glyphs.x[idx];
- vis_data->scalars[idx].y = scalar_frames_glyphs.y[idx];
+ vis_data->scalars.x[idx] = scalar_frames_glyphs.x[idx];
+ vis_data->scalars.y[idx] = scalar_frames_glyphs.y[idx];
vis_data->div_vel[idx] = par_der(vx[idx + 1], vx[idx], wn) + par_der(vy[idx + 1], vy[idx], wn);
vis_data->div_force[idx] = par_der(fx[idx + 1], fx[idx], hn) + par_der(fy[idx + 1], fy[idx], hn);
vis_data->history_frame[fluids_hisdex][idx] = frame_streamlines[idx];
-// 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];
+ 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];
vis_data->height[idx] = calculate_height_plot(heightplots_get_dataset(), idx);
- // vis_data->normals[idx] = calculate_normal_vector(vis_data->height, idx, i, j);
+ 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];
@@ -483,7 +485,6 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data)
{
int dataset;
fftw_real *frame;
- struct fftw_real_xy_p scalar_frames;
if (fluids_calculate) {
set_forces();
@@ -503,20 +504,17 @@ void fluids_calculate_one_simulation_step(struct vis_data_arrays *vis_data)
heightplots_set_frame(vis_data->height);
normals_set_frame(vis_data->normals);
-
dataset = glyphs_get_dataset_color();
frame = get_vector_frame(vis_data, dataset);
glyphs_set_frame_color(frame);
-
- dataset = glyphs_get_dataset_direction();
- scalar_frames = get_scalar_frames(vis_data, dataset);
- glyphs_set_frames_direction(scalar_frames);
+ glyphs_set_frames_direction(vis_data->scalars);
dataset = isolines_get_dataset();
frame = get_vector_frame(vis_data, dataset);
isolines_set_frame(frame);
streamlines_set_history(vis_data->history_frame);
+ streamlines_set_history_scalars(vis_data->history_scalars);
}
//------ VISUALIZATION CODE STARTS HERE -----------------------------------------------------------------
diff --git a/Smoke/fluids.h b/Smoke/fluids.h
index 32082db..d28f176 100644
--- a/Smoke/fluids.h
+++ b/Smoke/fluids.h
@@ -49,11 +49,6 @@ struct point2f {
};
struct fftw_real_xy {
- fftw_real x;
- fftw_real y;
-};
-
-struct fftw_real_xy_p {
fftw_real *x;
fftw_real *y;
};
@@ -62,13 +57,13 @@ struct vis_data_arrays {
fftw_real *rho;
fftw_real *vel;
fftw_real *force;
- struct fftw_real_xy *scalars;
+ struct fftw_real_xy scalars;
fftw_real *div_vel;
fftw_real *div_force;
fftw_real *height;
struct point *normals;
fftw_real *history_frame[HISTORY_SIZE];
- struct fftw_real_xy *history_scalars[HISTORY_SIZE];
+ struct fftw_real_xy history_scalars[HISTORY_SIZE];
};
diff --git a/Smoke/glyphs.c b/Smoke/glyphs.c
index c854e20..c93f9fa 100644
--- a/Smoke/glyphs.c
+++ b/Smoke/glyphs.c
@@ -22,7 +22,7 @@ static int glyphs_dataset_direction = DATASET_RHO;
static float glyphs_alpha = 1.0f;
static fftw_real *glyphs_frame_color;
-struct fftw_real_xy_p glyphs_frame_direction;
+struct fftw_real_xy glyphs_frame_direction;
void glyphs_set_render(int render_glyphs)
@@ -119,12 +119,12 @@ fftw_real *glyphs_get_frame_color(void)
return glyphs_frame_color;
}
-void glyphs_set_frames_direction(struct fftw_real_xy_p frame)
+void glyphs_set_frames_direction(struct fftw_real_xy frame)
{
glyphs_frame_direction = frame;
}
-struct fftw_real_xy_p glyphs_get_frames_direction(void)
+struct fftw_real_xy glyphs_get_frames_direction(void)
{
return glyphs_frame_direction;
}
diff --git a/Smoke/glyphs.h b/Smoke/glyphs.h
index c2eb616..4ef33ad 100644
--- a/Smoke/glyphs.h
+++ b/Smoke/glyphs.h
@@ -31,8 +31,8 @@ int glyphs_get_sort(void);
void glyphs_set_frame_color(fftw_real *frame);
fftw_real *glyphs_get_frame_color(void);
-void glyphs_set_frames_direction(struct fftw_real_xy_p frame);
-struct fftw_real_xy_p glyphs_get_frames_direction(void);
+void glyphs_set_frames_direction(struct fftw_real_xy frame);
+struct fftw_real_xy glyphs_get_frames_direction(void);
struct color4f glyphs_get_color(float value);
#endif
diff --git a/Smoke/renderer_gl.c b/Smoke/renderer_gl.c
index 01205fe..8cc2095 100644
--- a/Smoke/renderer_gl.c
+++ b/Smoke/renderer_gl.c
@@ -572,9 +572,10 @@ static void render_glyphs(void)
float scale, idxcf, idxrf;
struct color4f color;
fftw_real *frame_color;
- struct fftw_real_xy_p frames_direction;
+ struct fftw_real_xy frames_direction;
+ GLUquadricObj *qobj;
- GLUquadricObj *qobj = gluNewQuadric();
+ qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_FILL);
gluQuadricNormals(qobj, GLU_SMOOTH);
@@ -597,7 +598,7 @@ static void render_glyphs(void)
render_glyph(qobj, frames_direction.x[idx], frames_direction.y[idx], i, j);
}
}
-
+
gluDeleteQuadric(qobj);
}
@@ -971,7 +972,6 @@ void visualize(struct vis_data_arrays *vis_data)
if (renderer_render_grid) {
render_grid();
}
-
if (smoke_get_render())
{
if (smoke_get_sort() == SMOKE_FLUID)
@@ -1011,32 +1011,31 @@ void visualize(struct vis_data_arrays *vis_data)
}
render_streamlines();
+ //create an orthographic projection matrix for rendering the legendbar
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+
+ glLoadIdentity();
+
+ //create an orthographic viewing volume with the same dimensions as the
+ //window in front of the previous viewing volume
+ //from znear = 0.0 to zfar = 1.0
+ glOrtho(0.0, (GLfloat)winWidth, 0.0, (GLfloat)winHeight, 0.0, 1.0);
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix(); //save the current modelview matrix
+
+ glLoadIdentity();
+
+ //now render the legendbar
+ render_legend();
+
+ //restore the previous modelview matrix
+ glPopMatrix();
+
+ //restore the previous projection matrix
+ glMatrixMode(GL_PROJECTION);
- //create an orthographic projection matrix for rendering the legendbar
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
-
- glLoadIdentity();
-
- //create an orthographic viewing volume with the same dimensions as the
- //window in front of the previous viewing volume
- //from znear = 0.0 to zfar = 1.0
- glOrtho(0.0, (GLfloat)winWidth, 0.0, (GLfloat)winHeight, 0.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix(); //save the current modelview matrix
-
- glLoadIdentity();
-
- //now render the legendbar
- render_legend();
-
- //restore the previous modelview matrix
- glPopMatrix();
-
- //restore the previous projection matrix
- glMatrixMode(GL_PROJECTION);
-
- glPopMatrix();
+ glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
diff --git a/Smoke/smoke.bin b/Smoke/smoke.bin
index 364abaa..03ad4dd 100755
--- a/Smoke/smoke.bin
+++ b/Smoke/smoke.bin
Binary files differ
diff --git a/Smoke/streamlines.c b/Smoke/streamlines.c
index be3dfe4..3b54a36 100644
--- a/Smoke/streamlines.c
+++ b/Smoke/streamlines.c
@@ -26,6 +26,7 @@ static float streamlines_alpha = 1.0f;
static fftw_real *streamlines_frame;
static fftw_real **streamlines_history;
+struct fftw_real_xy *streamlines_history_scalars;
void streamlines_set_render(int render_streamlines)
@@ -88,16 +89,29 @@ fftw_real *streamlines_get_frame(void)
return streamlines_frame;
}
+/* rename and move to flowvis */
void streamlines_set_history(fftw_real **history)
{
streamlines_history = history;
}
+/* rename and move to flowvis */
fftw_real *streamlines_get_history(int hisdex)
{
return streamlines_history[hisdex];
}
+void streamlines_set_history_scalars(struct fftw_real_xy *history)
+{
+ streamlines_history_scalars = history;
+}
+
+struct fftw_real_xy *streamlines_get_history_scalars(void)
+{
+ return streamlines_history_scalars;
+}
+
+
struct color4f streamlines_get_color(float value)
{
diff --git a/Smoke/streamlines.h b/Smoke/streamlines.h
index f1a3431..14736e3 100644
--- a/Smoke/streamlines.h
+++ b/Smoke/streamlines.h
@@ -19,6 +19,9 @@ int streamlines_get_dataset(void);
void streamlines_set_frame(fftw_real *frame);
fftw_real *streamlines_get_frame(void);
+void streamlines_set_history_scalars(struct fftw_real_xy *history);
+struct fftw_real_xy *streamlines_get_history_scalars(void);
+
void streamlines_set_history(fftw_real **history);
fftw_real *streamlines_get_history(int hisdex);