Compare commits

..

No commits in common. "111f6b57afbc2a6916ea06a329276c84416bf0a9" and "97b946d6c591c23046d79c46460a1bdb8805f9da" have entirely different histories.

3 changed files with 33 additions and 79 deletions

View File

@ -39,7 +39,7 @@ typedef struct arrow_t {
};
int write_one_arrow_vertex (int space_X, int space_Y, int space_Z,
int weight, int site, int x, int y, int z, int print);
int weight, int site, int x, int y, int z);
int write_one_arrow_line(int offset_vertex, int print);
int write_one_arrow_line(int offset_vertex);

View File

@ -34,7 +34,7 @@
*/
int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
int weight, int site, int arrow_x, int arrow_y, int arrow_z, int print)
int weight, int site, int arrow_x, int arrow_y, int arrow_z)
{
float max = fmax(space_X_int, space_Y_int);
@ -46,6 +46,8 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
vy = (2 * j / space_Y_int - 1) * space_Y_int / max + (1 / max),
vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max);
int print = 0;
graphics_write_vertex(vx, vy, vz, print);
graphics_write_color(0.3f, 0.3f, 0.3f);
@ -85,8 +87,9 @@ int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
}
int write_one_arrow_line(int offset_vertex, int print)
int write_one_arrow_line(int offset_vertex)
{
int print = 0;
graphics_write_line (offset_vertex + 0, offset_vertex + 1, print);
return 2;
}

View File

@ -138,8 +138,8 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
buffer_vertex_origin[buffer_vertex_size + 1] = y;
buffer_vertex_origin[buffer_vertex_size + 2] = z;
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2d] [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
buffer_vertex_size / 3, buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
if (print) printf("In graphics_write_vertex() buffer_vertex_size => [%2d > %2d] (%6.3f,%6.3f,%6.3f)\n",\
buffer_vertex_size + 0, buffer_vertex_size + 2, x, y, z);
buffer_vertex_size += 3;
}
@ -182,8 +182,8 @@ void graphics_write_line (GLuint a, GLuint b, int print)
buffer_lines_origin[buffer_lines_size + 0] = a;
buffer_lines_origin[buffer_lines_size + 1] = b;
if (print) printf("In graphics_write_line() buffer_lines_size => [%2d] [%2d > %2d] (%3u > %3u ) (= buffer_vertex_size / 3 - 2 > -1)\n",\
buffer_lines_size / 2, buffer_lines_size + 0, buffer_lines_size + 1, a, b);
if (print) printf("In graphics_write_line() buffer_lines_size => [%2d > %2d] (%2u > %2u)\n",\
buffer_lines_size + 0, buffer_lines_size + 1, a, b);
buffer_lines_size += 2;
}
@ -553,8 +553,7 @@ bool graphics_shutdown(const void *gl_area)
return true;
}
static inline void print_vertex_and_lines_buffers (struct arrow_t *arrows_ptr, int arrows_nb, int address, int requested_weight,
int current_weight, int site, int x, int y, int z);
/*
* Assigns a new load to the arrow at address (address)
*/
@ -588,16 +587,18 @@ static inline int create_arrow (int arrows_nb,
arrows_ptr[arrows_nb].y = y;
arrows_ptr[arrows_nb].z = z;
int print = 1;
if (0) printf("In create_arrow() buffer_vertex_size => [%2d > %2d]\n",\
buffer_vertex_size + 0, buffer_vertex_size + 2);
write_one_arrow_vertex(space_X, space_Y, space_Z,
load, site, x, y, z, print);
load, site, x, y, z);
buffer_colors_size = buffer_vertex_size;
write_one_arrow_line (buffer_vertex_size / 3 - 2, print);
write_one_arrow_line (buffer_vertex_size / 3 - 2);
arrows_nb ++;
if (1) print_arrows_array (arrows_ptr, arrows_nb, 1);
if (0) print_arrows_array (arrows_ptr, arrows_nb, 1);
return arrows_nb;
}
@ -623,8 +624,6 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
if (arrows_nb > 0) {
int some_nb = 12; if (arrows_nb == 1) some_nb = 9;
void *new_arrows_list_ptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
if (new_arrows_list_ptr) arrows_ptr = new_arrows_list_ptr;
else perror("In erase arrow, can't re_allocate for arrow list.\n");
@ -635,24 +634,21 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
/* for (int i = 24; i < 36; i ++) printf(" %5.2f", buffer_vertex_origin[i]); printf("\n"); */
if (0) printf("buffer_vertex_0_arrow = %d arrows_nb * 3 = %d <<<<\n", buffer_vertex_0_arrow, arrows_nb * 3);
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + some_nb * 3 * sizeof(GLfloat));
void *new_arrows_vertex_ptr = g_realloc(buffer_vertex_origin, buffer_vertex_0_arrow + 9 * 3 * sizeof(GLfloat));
if (new_arrows_vertex_ptr) buffer_vertex_origin = new_arrows_vertex_ptr;
else perror("In erase arrow, can't re_allocate for arrow vertex buffer.\n");
if (0) printf("buffer_lines_0_arrow = %d arrows_nb * 2 = %d <<<<\n", buffer_lines_0_arrow, arrows_nb * 2);
void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + some_nb * 2 * sizeof(GLfloat));
void *new_arrows_lines_ptr = g_realloc(buffer_lines_origin, buffer_lines_0_arrow + 9 * 2 * sizeof(GLfloat));
if (new_arrows_lines_ptr) buffer_lines_origin = new_arrows_lines_ptr;
else perror("In erase arrow, can't re_allocate for arrow lines buffer.\n");
}
printf(" >> bf_vrtx = %d bf_ln = %d\n", (buffer_vertex_size - 6) / 3, (buffer_lines_size - 4) / 2);
print_arrows_array (arrows_ptr, arrows_nb,0);
return arrows_nb;
}
static inline void print_vertex_and_lines_buffers(struct arrow_t *arrows_ptr, int arrows_nb, int address, int requested_weight,
int current_weight, int site, int x, int y, int z);
static inline void show_user_action(struct arrow_t *arrows_ptr, int arrows_nb, int address, int requested_weight,
int current_weight, int site, int x, int y, int z);
/*
@ -683,10 +679,7 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb,
}
}
}
// print_vertex_and_lines_buffers (arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
if (requested_weight == 0) printf(" - set_arrow() invoked with requested weight = %2d bf_vrtx = %d bf_ln = %d add: %d",\
requested_weight, buffer_vertex_size / 3, buffer_lines_size / 2, address);
if (requested_weight == 0) printf(" - set_arrow() invoked with requested weight = %2d\n", requested_weight);
if (TEST) show_user_action(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
@ -706,39 +699,6 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb,
return arrows_nb;
}
static inline void print_buffers_array_head () {printf(" [rank] load | site x y z [address] buffer-vertex-1 buffer-vertex-2 buffer-lines\n");}
static inline void print_empty_buffers_array () {printf(" [NULL] ---- | ---- --- --- --- -1 --- --- ---\n");}
static void print_one_arrow_in_buffers (struct arrow_t *arrows, int i, int arrows_nb, int address) {
printf(" [%4d] = %2d | %2d, %2d, %2d, %2d, (%2d) %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f\n",\
i,
arrows[i].load, arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z,
address,
buffer_vertex_origin [buffer_vertex_0_arrow + i * 3 + 0],
buffer_vertex_origin [buffer_vertex_0_arrow + i * 3 + 1],
buffer_lines_origin [buffer_lines_0_arrow + i * 3 + 2],
buffer_vertex_origin [buffer_vertex_0_arrow + i * 3 + 3],
buffer_vertex_origin [buffer_vertex_0_arrow + i * 3 + 4],
buffer_lines_origin [buffer_lines_0_arrow + i * 3 + 5],
buffer_lines_origin [buffer_lines_0_arrow + i * 2 + 0],
buffer_lines_origin [buffer_lines_0_arrow + i * 2 + 1]);
}
static inline void print_vertex_and_lines_buffers (struct arrow_t *arrows_ptr, int arrows_nb, int address, int requested_weight,
int current_weight, int site, int x, int y, int z)
{
/* for (int i = 0; i < 6; i++) printf("%5.2f ", buffer_vertex_origin [buffer_vertex_0_arrow + i]); printf("\n"); */
/* for (int i = 0; i < 6; i++) printf("%5.2f ", buffer_lines_origin [buffer_lines_0_arrow + i]); printf("\n"); */
print_buffers_array_head ();
for (int i = 0; i < arrows_nb; i++)
print_one_arrow_in_buffers(arrows_ptr, i, arrows_nb, address);
if (arrows_nb == 0) print_empty_buffers_array();
}
/*
* Init space and arrows (= initial state)
@ -844,7 +804,7 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
buffer_vertex_0_arrow = buffer_vertex_size;
buffer_lines_0_arrow = buffer_lines_size;
if (1) printf("buffer_vertex_0_arrow = %d (%d points) buffer_lines_0_arrow = %d (%d lines)\n",\
printf("buffer_vertex_0_arrow = %d (%d points) buffer_lines_0_arrow = %d (%d lines)\n",\
buffer_vertex_0_arrow, buffer_vertex_0_arrow / 3, buffer_lines_0_arrow, buffer_lines_0_arrow / 2);
/* A R R O W S */
@ -852,9 +812,6 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* #pragma omp parallel */
/* { */
/* while (arrows_nb < specif_arrows_nb){ */
arrows_nb = 0;
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
rand() % arbitrary + 1, // load / weight
0,//rand() % 6, // site,
@ -879,13 +836,15 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* N E W D A T A W I L L N O W B E S P E C I F I E D */
/* A N D T H E N D R A W N E D */
/*--------------------------------------------------------------------------------*/
/* if (1) print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
if (1) print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0);
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
0,//rand() % arbitrary + 1, // load / weight
@ -894,21 +853,14 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
0,//rand() % space_Y, // y
0);//rand() % space_Z); // z
/* print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0);
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
rand() % arbitrary + 1, // load / weight
2,//rand() % 6, // site,
0,//rand() % space_X, // x
0,//rand() % space_Y, // y
0);//rand() % space_Z); // z
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
0,//rand() % arbitrary + 1, // load / weight
1,//rand() % 6, // site,
0,//rand() % space_X, // x
0,//rand() % space_Y, // y
0);//rand() % space_Z); // z
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
/* 0,//rand() % arbitrary + 1, // load / weight */
/* 1,//rand() % 6, // site, */
/* 0,//rand() % space_X, // x */
/* 0,//rand() % space_Y, // y */
/* 0);//rand() % space_Z); // z */
/* print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
@ -987,4 +939,3 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
arrows_ptr = NULL;
arrows_nb = 0;
}