Compare commits

...

3 Commits

1 changed files with 69 additions and 50 deletions

View File

@ -47,6 +47,11 @@ static volatile int buffer_lines_size = 0;
static volatile int buffer_colors_size = 0;
static volatile int buffer_plans_size = 0;
static volatile int buffer_vertex_0_arrow = 0;
static volatile int buffer_lines_0_arrow = 0;
static volatile int buffer_colors_0_arrow = 0;
static volatile int buffer_plans_0_arrow = 0;
#define TEST 0
/*
@ -593,7 +598,7 @@ static inline int create_arrow (int arrows_nb,
arrows_nb ++;
print_arrows_array (arrows_ptr, arrows_nb, 1);
if (0) print_arrows_array (arrows_ptr, arrows_nb, 1);
return arrows_nb;
}
@ -605,22 +610,38 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
{
arrows_nb --;
if (1)
{
arrows_ptr[address].load = arrows_ptr[arrows_nb].load;
arrows_ptr[address].site = arrows_ptr[arrows_nb].site;
arrows_ptr[address].x = arrows_ptr[arrows_nb].x;
arrows_ptr[address].y = arrows_ptr[arrows_nb].y;
arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
}
arrows_ptr[address].load = arrows_ptr[arrows_nb].load;
arrows_ptr[address].site = arrows_ptr[arrows_nb].site;
arrows_ptr[address].x = arrows_ptr[arrows_nb].x;
arrows_ptr[address].y = arrows_ptr[arrows_nb].y;
arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
for (int i = 0 + address; i < 6 + address; i++)
buffer_vertex_origin [(long) buffer_vertex_0_arrow + i] = buffer_vertex_origin[(long) buffer_vertex_size - 6 + i];
for (int j = 0 + address; j < 4 + address; j++)
buffer_lines_origin [(long) buffer_lines_0_arrow + j] = buffer_lines_origin[(long) buffer_lines_size - 4 + j];
if (arrows_nb > 0) {
void *newptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
if (newptr)
arrows_ptr = newptr;
else
perror("In erase arrow, can't allocate new arrow buffer !\n");
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");
/* long unit = 24 * 3 * sizeof(GLfloat); // 4 * 3 * 4 = 48 sizeof(GLfloat) = 3 * 8 bits */
/* printf(" - erase_arrow() invoked with address = %d buffer_vertex_size - buffer_vertex_0_arrow = %d (for %d arrows)\n",\ */
/* address, (long) buffer_vertex_size - buffer_vertex_0_arrow, arrows_nb + 1); */
/* 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 + 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 + 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");
}
print_arrows_array (arrows_ptr, arrows_nb,0);
@ -658,7 +679,7 @@ static inline int set_arrow (struct arrow_t *arrows_ptr, int arrows_nb,
}
}
}
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
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);
@ -698,9 +719,9 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
int arbitrary = 5;
int space_X = 1 + rand() % arbitrary,
space_Y = 1 + rand() % arbitrary,
space_Z = 1 + rand() % arbitrary;
int space_X = 1,// + rand() % arbitrary,
space_Y = 1,// + rand() % arbitrary,
space_Z = 1;// + rand() % arbitrary;
int density_max = space_X * space_Y * space_Z;
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
@ -713,7 +734,6 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
int print_inter_results = 0;
if (print_inter_results) clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
if (print_inter_results) printf("%10d | ", specif_arrows_nb / 1000);
printf("I N I T I A L D A T A A R E N O W S P E C I F I E D\n");
/*--------------------------------------------------------------------------------*/
@ -728,17 +748,17 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* S P A C E */
if (1) printf("buffer_vertex_size before writing 8 space_ridges_vertex : %3d (x 3 = %d)\n", buffer_vertex_size / 3, buffer_vertex_size);
if (0) printf("buffer_vertex_size before writing 8 space_ridges_vertex : %3d (x 3 = %d)\n", buffer_vertex_size / 3, buffer_vertex_size);
write_space_ridges_vertex (buffer_vertex_size, space_X, space_Y, space_Z);
/* buffer_colors_size = buffer_vertex_size; */
if (1) printf("buffer_vertex_size after writing 8 space_ridges_vertex : %3d (x 3 = %d)\n", buffer_vertex_size / 3, buffer_vertex_size);
if (0) printf("buffer_vertex_size after writing 8 space_ridges_vertex : %3d (x 3 = %d)\n", buffer_vertex_size / 3, buffer_vertex_size);
write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
/* buffer_colors_size = buffer_vertex_size; */
if (1) printf("buffer_vertex_size after writing %3d space_faces_vertex : %3d (x 3 = %4d)\n\n", buffer_vertex_size / 3 - 8, buffer_vertex_size / 3, buffer_vertex_size);
if (0) printf("buffer_vertex_size after writing %3d space_faces_vertex : %3d (x 3 = %4d)\n\n", buffer_vertex_size / 3 - 8, buffer_vertex_size / 3, buffer_vertex_size);
/* if (0) printf("(space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4 = %3d (x 3 = %4d)\n\n",\ */
/* (space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4, ((space_X - 1) * 4 + (space_Y - 1) * 4 + (space_Z - 1) * 4) * 3); */
@ -776,7 +796,16 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
if (0) printf("buffer_lines_size before writing (n) space_faces_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
write_grids_on_space_faces_lines (buffer_lines_size, space_X, space_Y, space_Z);
if (1) printf("buffer_lines_size after writing (n) space_faces_lines : %d (* 2 = %d)\n\n", buffer_lines_size / 2, buffer_lines_size);
if (0) printf("buffer_lines_size after writing (n) space_faces_lines : %d (* 2 = %d)\n\n", buffer_lines_size / 2, buffer_lines_size);
/* Ce programme définit et crée séquentiellement les caractéristiques puis les images de l'espace puis celles des flèches
* Pour pouvoir effacer une flèche (n'importe laquelle),
* il est nécéssaire de connaître la taille des buffers au moment de la création de la première flèche */
buffer_vertex_0_arrow = buffer_vertex_size;
buffer_lines_0_arrow = buffer_lines_size;
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 */
@ -785,32 +814,22 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* while (arrows_nb < specif_arrows_nb){ */
arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z,
rand() % arbitrary + 1, // load / weight
rand() % 6, // site,
rand() % space_X, // x
rand() % space_Y, // y
rand() % space_Z); // z
0,//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,
rand() % arbitrary + 1, // load / weight
rand() % 6, // site,
rand() % space_X, // x
rand() % space_Y, // y
rand() % space_Z); // z
1,//rand() % 6, // site,
0,//rand() % space_X, // x
0,//rand() % space_Y, // y
0);//rand() % space_Z); // z
/* clock_gettime(CLOCK_REALTIME, &ts); < Je n'arrive pas à afficher les temps en cours d'exécutuion */
/* if (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 22 == 0) printf(" %f\n%10d | ", specif_arrows_nb / 1000, ts.tv_sec - t_initial);} */
if (print_inter_results && arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 24 == 0) printf("\n%10d | ", specif_arrows_nb / 1000);}
/* } */
/* } */
/* for (int i = 0; i < arrows_nb; i++) { */
/* load = arrows_ptr[i].load; */
/* site = arrows_ptr[i].site; */
/* x = arrows_ptr[i].x; */
/* y = arrows_ptr[i].y; */
/* z = arrows_ptr[i].z; */
/* buffer_vertex_size += write_one_arrow_line (buffer_vertex_size); */
/* } */
@ -825,17 +844,17 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/*--------------------------------------------------------------------------------*/
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
0,//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);
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
/* 0,//rand() % arbitrary + 1, // load / weight */
/* 0,//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); */
/* arrows_nb = set_arrow (arrows_ptr, arrows_nb, space_X, space_Y, space_Z, */
/* 0,//rand() % arbitrary + 1, // load / weight */
/* 1,//rand() % 6, // site, */