Compare commits
2 Commits
e58d86a58f
...
1a7a535f45
Author | SHA1 | Date |
---|---|---|
Jean Sirmai | 1a7a535f45 | |
Jean Sirmai | 6bbc3a3aa8 |
|
@ -42,7 +42,5 @@ int write_one_arrow_vertex (int offset_vertex,
|
|||
int space_X, int space_Y, int space_Z,
|
||||
int weight, int site, int x, int y, int z);
|
||||
|
||||
int write_one_arrow_lines (int offset_vertex,
|
||||
int space_X, int space_Y, int space_Z,
|
||||
int weight, int site, int x, int y, int z);
|
||||
int write_one_arrow_line(int offset_vertex);
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ void show_arrows_array_head(int one_batch_size, long nb_batches_specified, int v
|
|||
void show_one_arrow_in_array(struct arrow_t *arrows, int i);
|
||||
void show_empty_arrows_array();
|
||||
void show_arrows_array (struct arrow_t *arrows, int arrows_nb, int x, int y, int z);
|
||||
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by);
|
||||
void print_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
||||
int current_weight, int site, int x, int y, int z);
|
||||
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
|
||||
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
|
||||
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z);
|
||||
int write_space_ridges_lines ();
|
||||
|
||||
/*
|
||||
* Writes grid lines on space faces
|
||||
|
@ -44,6 +44,6 @@ int write_space_ridges_lines (long offset_vertex, long offset_colors, long offse
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
|
||||
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
|
||||
long write_grids_on_space_faces_vertex (long x, long y, long z);
|
||||
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z);
|
||||
|
||||
|
|
|
@ -33,83 +33,6 @@
|
|||
* Z - Z = NORTH - SOUTH = bleu - jaune
|
||||
*/
|
||||
|
||||
/*
|
||||
* Writes basis and tip for all arrows into vertex and color buffers
|
||||
*
|
||||
* @param dimensions (x,y,z)
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented towards east or west into lines buffer
|
||||
*
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void write_arrow_lines_east_west (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (offset + 2, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 6 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 6 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented towards zenith or nadir into lines buffer
|
||||
*
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void write_arrow_lines_zenith_nadir (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (offset + 0, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 4, offset + 8 + site % 2);
|
||||
graphics_write_line (offset + 5, offset + 8 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow oriented towards south or north into lines buffer
|
||||
*
|
||||
* @param offset,
|
||||
* weight,
|
||||
* site
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void write_arrow_lines_south_north (long offset, int weight, int site)
|
||||
{
|
||||
graphics_write_line (offset + 0, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 1, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 2, offset + 10 + site % 2);
|
||||
graphics_write_line (offset + 3, offset + 10 + site % 2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes lines for arrow basis into lines buffer
|
||||
*
|
||||
* @param offset
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void arrows_write_basis(long offset)
|
||||
{
|
||||
graphics_write_line (offset + 0, offset + 1);
|
||||
graphics_write_line (offset + 2, offset + 3);
|
||||
graphics_write_line (offset + 4, offset + 5);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
int write_one_arrow_vertex (int offset_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)
|
||||
|
@ -136,19 +59,19 @@ int write_one_arrow_vertex (int offset_vertex,
|
|||
|
||||
switch(site){
|
||||
case EAST:
|
||||
graphics_write_vertex (vx + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_color (1.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
case WEST:
|
||||
graphics_write_vertex (vx + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_vertex (vx - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vy, vz);
|
||||
graphics_write_color (0.0f, 1.0f, 1.0f);
|
||||
break;
|
||||
case ZENITH:
|
||||
graphics_write_vertex (vx, vy + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, vz);
|
||||
graphics_write_vertex (vx, vy - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vz);
|
||||
graphics_write_color(0.0f, 1.0f, 0.0f);
|
||||
break;
|
||||
case NADIR:
|
||||
graphics_write_vertex (vx, vy + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, vz);
|
||||
graphics_write_vertex (vx, vy - (site % 2) * (1 / max) + (site % 2) * arrow_tip_padding, vz);
|
||||
graphics_write_color(1.0f, 0.0f, 1.0f);
|
||||
break;
|
||||
case SOUTH:
|
||||
|
@ -166,17 +89,9 @@ int write_one_arrow_vertex (int offset_vertex,
|
|||
}
|
||||
|
||||
|
||||
int write_one_arrow_lines(int offset_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 write_one_arrow_line(int offset_vertex)
|
||||
{
|
||||
switch(site){
|
||||
case EAST: case WEST: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
||||
case ZENITH: case NADIR: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
||||
case SOUTH: case NORTH: graphics_write_line (offset_vertex + 0, offset_vertex + 1); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
graphics_write_line (offset_vertex + 0, offset_vertex + 1);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,18 @@
|
|||
* - load (or weight)
|
||||
* - coordinates in space (site, x, y, z)
|
||||
*/
|
||||
static void print_arrows_array (struct arrow_t *arrows, int arrows_nb)
|
||||
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by)
|
||||
{
|
||||
printf(" [rank] load | site x y z");
|
||||
printf(" [rank] load | site x y z (");
|
||||
switch (invoked_by) {
|
||||
case 0: printf("delete)"); break;
|
||||
case 1: printf("create)"); break;
|
||||
case 2: printf("modify)"); break;
|
||||
case 3: printf("address >= 0 && current_weight == requested_weight)"); break;
|
||||
case 4: printf("address == -1 && requested_weight == 0)"); break;
|
||||
case 5: printf("print_user_choices)"); break;
|
||||
case 6: printf("print_evolution)"); break;
|
||||
}
|
||||
for (int i = 0; i < arrows_nb; i++)
|
||||
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, arrows[i].load,\
|
||||
arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z);
|
||||
|
@ -64,7 +73,7 @@ void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
|||
if (show_space_design) printf(" (grilles alternées)");
|
||||
printf("\n");
|
||||
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb, 5);
|
||||
}
|
||||
|
||||
/* Prints the evolution after adding / removing arrows :
|
||||
|
@ -79,7 +88,7 @@ void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int d
|
|||
{
|
||||
printf("evolution\t\t\t\t\t\t\tarrows nb > %6d\t (%d added / %d deleted) (modified : %d)\n",\
|
||||
arrows_nb + modified - deleted * 2, modified - deleted, deleted, modified);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb);
|
||||
if (show_array) print_arrows_array (arrows, arrows_nb, 6);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||
|
||||
static struct arrow_t *arrows;
|
||||
static struct arrow_t *sworra;
|
||||
static GLfloat *buffer_vertex_origin = NULL;
|
||||
static GLfloat *buffer_colors_origin = NULL;
|
||||
static GLuint *buffer_lines_origin = NULL;
|
||||
|
@ -549,10 +549,9 @@ bool graphics_shutdown(const void *gl_area)
|
|||
*/
|
||||
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z)
|
||||
{
|
||||
arrows[address].load = load;
|
||||
sworra[address].load = load;
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (arrows, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb, 2);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -563,23 +562,22 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
|||
*/
|
||||
static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z)
|
||||
{
|
||||
void *newptr = g_realloc(arrows, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||
void *newptr = g_realloc(sworra, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||
|
||||
if (newptr)
|
||||
arrows = newptr;
|
||||
sworra = newptr;
|
||||
else
|
||||
perror("Can't allocate new arrow buffer!\n");
|
||||
perror("In create arrow, can't allocate new arrow buffer !\n");
|
||||
|
||||
arrows[arrows_nb].load = load;
|
||||
arrows[arrows_nb].site = site;
|
||||
arrows[arrows_nb].x = x;
|
||||
arrows[arrows_nb].y = y;
|
||||
arrows[arrows_nb].z = z;
|
||||
sworra[arrows_nb].load = load;
|
||||
sworra[arrows_nb].site = site;
|
||||
sworra[arrows_nb].x = x;
|
||||
sworra[arrows_nb].y = y;
|
||||
sworra[arrows_nb].z = z;
|
||||
|
||||
arrows_nb ++;
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (arrows, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb, 1);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -593,27 +591,26 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
|||
|
||||
if (arrows_nb > 0)
|
||||
{
|
||||
arrows[address].load = arrows[arrows_nb].load;
|
||||
arrows[address].site = arrows[arrows_nb].site;
|
||||
arrows[address].x = arrows[arrows_nb].x;
|
||||
arrows[address].y = arrows[arrows_nb].y;
|
||||
arrows[address].z = arrows[arrows_nb].z;
|
||||
sworra[address].load = sworra[arrows_nb].load;
|
||||
sworra[address].site = sworra[arrows_nb].site;
|
||||
sworra[address].x = sworra[arrows_nb].x;
|
||||
sworra[address].y = sworra[arrows_nb].y;
|
||||
sworra[address].z = sworra[arrows_nb].z;
|
||||
}
|
||||
|
||||
void *newptr = g_realloc(arrows, arrows_nb * sizeof(struct arrow_t));
|
||||
/* void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t)); */
|
||||
|
||||
if (newptr)
|
||||
arrows = newptr;
|
||||
else
|
||||
perror("Can't allocate new arrow buffer!\n");
|
||||
/* if (newptr) */
|
||||
/* sworra = newptr; */
|
||||
/* else */
|
||||
/* perror("In erase arrow, can't allocate new arrow buffer !\n"); */
|
||||
|
||||
// if (! TEST)
|
||||
// print_arrows_array (arrows, arrows_nb);
|
||||
print_arrows_array (sworra, arrows_nb,0);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
||||
static inline void show_user_action(struct arrow_t *arrows, int arrows_nb, int address, int requested_weight,
|
||||
static inline void show_user_action(struct arrow_t *sworra, int arrows_nb, int address, int requested_weight,
|
||||
int current_weight, int site, int x, int y, int z);
|
||||
/*
|
||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
||||
|
@ -623,27 +620,27 @@ static inline void show_user_action(struct arrow_t *arrows, int arrows_nb, int a
|
|||
* - Current_weight of an arrow located at the requested address == requested_weight
|
||||
* - No arrow was found at the requested addres AND current_weight == requested_weight
|
||||
*/
|
||||
static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requested_weight, int site, int x, int y, int z)
|
||||
static inline int set_arrow (struct arrow_t *sworra, int arrows_nb, int requested_weight, int site, int x, int y, int z)
|
||||
{
|
||||
int address = -1, current_weight = -1;
|
||||
|
||||
#pragma omp parallel schedule(static, 12)
|
||||
{
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
if ((site == arrows[i].site)
|
||||
&& (x == arrows[i].x)
|
||||
&& (y == arrows[i].y)
|
||||
&& (z == arrows[i].z))
|
||||
if ((site == sworra[i].site)
|
||||
&& (x == sworra[i].x)
|
||||
&& (y == sworra[i].y)
|
||||
&& (z == sworra[i].z))
|
||||
{
|
||||
address = i * 5;
|
||||
current_weight = arrows[i].load;
|
||||
current_weight = sworra[i].load;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
|
||||
|
||||
if (TEST) show_user_action(arrows, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
if (TEST) show_user_action(sworra, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||
|
||||
if (address == -1 && requested_weight > 0)
|
||||
return create_arrow (arrows_nb, requested_weight, site, x, y, z);
|
||||
|
@ -654,9 +651,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
|
|||
if (address >= 0 && current_weight != requested_weight)
|
||||
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
||||
|
||||
// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(arrows, arrows_nb, x, y, z);
|
||||
if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(sworra, arrows_nb, 3);
|
||||
|
||||
// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(arrows, arrows_nb, x, y, z);
|
||||
if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, 4);
|
||||
|
||||
return arrows_nb;
|
||||
}
|
||||
|
@ -680,36 +677,44 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
int rand(void);
|
||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||
|
||||
int arbitrary = 200;
|
||||
int space_X = 1 + rand() % arbitrary,
|
||||
space_Y = 1 + rand() % arbitrary,
|
||||
space_Z = 1 + rand() % arbitrary;
|
||||
int arbitrary = 3;
|
||||
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);
|
||||
|
||||
int show_space_design = 1, print_arrows_data = 0;
|
||||
int print_arrows_data = 0;
|
||||
|
||||
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
||||
int specif_arrows_nb = rand() % density_max;
|
||||
int specif_arrows_nb = 1;//rand() % density_max;
|
||||
int arrows_nb = 0, cpt = 0, t_initial = 0;
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
|
||||
printf("%10d | ", specif_arrows_nb / 1000);
|
||||
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);
|
||||
#pragma omp parallel
|
||||
{
|
||||
while (arrows_nb < specif_arrows_nb){
|
||||
arrows_nb = set_arrow (arrows, arrows_nb,
|
||||
rand() % arbitrary + 1, // load / weight
|
||||
rand() % 6, // site,
|
||||
rand() % space_X, // x
|
||||
rand() % space_Y, // y
|
||||
rand() % space_Z); // z
|
||||
/* while (arrows_nb < specif_arrows_nb){ */
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
0,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
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 (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 24 == 0) printf("\n%10d | ", specif_arrows_nb / 1000);}
|
||||
}
|
||||
printf("\n");
|
||||
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);}
|
||||
/* } */
|
||||
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");
|
||||
}
|
||||
// clock_t start, end;
|
||||
|
||||
|
@ -719,13 +724,13 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* arbitrary = 26; */
|
||||
/* space_X = arbitrary; space_Y = arbitrary; space_Z = arbitrary; */
|
||||
/* density_max = space_X * space_Y * space_Z;
|
||||
* C E T T E T R I P L E B O U C L E
|
||||
* C E T T E Q U A D R U P L E B O U C L E
|
||||
* S A T U R E L ' E S P A C E S Y S T É M A T I Q U E M E N T */
|
||||
/* for (int i =0; i < space_X; i++) */
|
||||
/* for (int j =0; j < space_Y; j++) */
|
||||
/* for (int k =0; k < space_Z; k++) */
|
||||
/* for (int u =0; u < 6; u++) */
|
||||
/* arrows_nb = set_arrow (arrows, arrows_nb, */
|
||||
/* arrows_nb = set_arrow (sworra, arrows_nb, */
|
||||
/* 1, // load / weight */
|
||||
/* u,//i % 6, // site, */
|
||||
/* i,//i % space_X, // x */
|
||||
|
@ -734,13 +739,15 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* ); */
|
||||
// end = clock(); printf("Elapsed time %ld\n", end - start);
|
||||
|
||||
print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, show_space_design);
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
/* D A T A A R E N O W A L L S P E C I F I E D */
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
/* D R A W I N G C A N S T A R T */
|
||||
/* I N I T I A L D A T A A R E N O W A L L S P E C I F I E D */
|
||||
|
||||
/*---------------------------------------------------------------*/
|
||||
/* A N D C A N B E D R A W N */
|
||||
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
/* V E R T E X F I R S T */
|
||||
|
||||
|
@ -748,12 +755,13 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
/* S P A C E */
|
||||
|
||||
offset_vertex += write_space_ridges_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
||||
// float max = fmax(x, y); max = fmax(max, z);
|
||||
offset_vertex += write_space_ridges_vertex (offset_vertex, space_X, space_Y, space_Z);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
if (0) printf("offset_vertex after writing_space_ridges_vertex : %d (x 3 = %d)\n\n", offset_vertex, offset_vertex * 3);
|
||||
|
||||
offset_vertex += write_grids_on_space_faces_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
||||
offset_vertex += write_grids_on_space_faces_vertex (space_X, space_Y, space_Z);
|
||||
offset_colors = offset_vertex;
|
||||
|
||||
if (0) printf("offset_vertex after writing_space_faces_vertex = %4d - 8 = %3d (x 3 = %4d)\n", offset_vertex, offset_vertex - 8, (offset_vertex - 8) * 3);
|
||||
|
@ -764,11 +772,11 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
/* A R R O W S */
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
load = arrows[i].load;
|
||||
site = arrows[i].site;
|
||||
x = arrows[i].x;
|
||||
y = arrows[i].y;
|
||||
z = arrows[i].z;
|
||||
load = sworra[i].load;
|
||||
site = sworra[i].site;
|
||||
x = sworra[i].x;
|
||||
y = sworra[i].y;
|
||||
z = sworra[i].z;
|
||||
|
||||
offset_vertex += write_one_arrow_vertex(offset_vertex,
|
||||
space_X, space_Y, space_Z,
|
||||
|
@ -787,46 +795,114 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
|||
|
||||
/* S P A C E */
|
||||
|
||||
offset_vertex += write_space_ridges_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
||||
offset_vertex += write_space_ridges_lines ();
|
||||
|
||||
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
||||
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, space_X, space_Y, space_Z);
|
||||
|
||||
/* A R R O W S */
|
||||
|
||||
for (int i = 0; i < arrows_nb; i++) {
|
||||
load = arrows[i].load;
|
||||
site = arrows[i].site;
|
||||
x = arrows[i].x;
|
||||
y = arrows[i].y;
|
||||
z = arrows[i].z;
|
||||
load = sworra[i].load;
|
||||
site = sworra[i].site;
|
||||
x = sworra[i].x;
|
||||
y = sworra[i].y;
|
||||
z = sworra[i].z;
|
||||
|
||||
offset_vertex += write_one_arrow_lines (offset_vertex, space_X, space_Y, space_Z,
|
||||
load, site, x, y, z);
|
||||
offset_vertex += write_one_arrow_line (offset_vertex);
|
||||
}
|
||||
|
||||
assert : arrows_nb > arbitrary;
|
||||
int random_choice, modified = 0, deleted = 0;
|
||||
/* 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 */
|
||||
|
||||
#pragma omp parallel
|
||||
{
|
||||
while (modified < arbitrary) {
|
||||
/* B E F O R E B E I N G D R A W N E D */
|
||||
|
||||
random_choice = rand() % 6;
|
||||
if (random_choice == 0) deleted++;
|
||||
/*--------------------------------------------------------------------------------*/
|
||||
|
||||
modified = set_arrow (arrows, modified,
|
||||
random_choice, // load / weight
|
||||
rand() % 6, // site,
|
||||
rand() % space_X, // x
|
||||
rand() % space_Y, // y
|
||||
rand() % space_Z); // z
|
||||
}
|
||||
}
|
||||
print_evolution (arrows, arrows_nb, arbitrary, deleted, print_arrows_data);
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
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(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
arrows_nb = set_arrow (sworra, arrows_nb,
|
||||
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 (sworra, arrows_nb,
|
||||
1,//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 (sworra, arrows_nb,
|
||||
1,//rand() % arbitrary + 1, // load / weight
|
||||
3,//rand() % 6, // site,
|
||||
0,//rand() % space_X, // x
|
||||
0,//rand() % space_Y, // y
|
||||
0);//rand() % space_Z); // z
|
||||
|
||||
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||
|
||||
// offset_vertex -= 2;
|
||||
// buffer_vertex_size += 3;
|
||||
|
||||
|
||||
/* assert : arrows_nb > arbitrary; */
|
||||
/* int random_choice, modified = 0, deleted = 0; */
|
||||
|
||||
/* #pragma omp parallel */
|
||||
/* { */
|
||||
/* while (modified < arbitrary) { */
|
||||
|
||||
/* random_choice = rand() % 6; */
|
||||
/* if (random_choice == 0) deleted++; */
|
||||
|
||||
/* modified = set_arrow (sworra, arrows_nb + modified, */
|
||||
/* random_choice, // load / weight */
|
||||
/* rand() % 6, // site, */
|
||||
/* rand() % space_X, // x */
|
||||
/* rand() % space_Y, // y */
|
||||
/* rand() % space_Z); // z */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* #pragma omp parallel */
|
||||
/* { */
|
||||
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||
/* load = sworra[i].load; */
|
||||
/* site = sworra[i].site; */
|
||||
/* x = sworra[i].x; */
|
||||
/* y = sworra[i].y; */
|
||||
/* z = sworra[i].z; */
|
||||
|
||||
/* offset_vertex += write_one_arrow_vertex(offset_vertex, */
|
||||
/* space_X, space_Y, space_Z, */
|
||||
/* load, site, x, y, z); */
|
||||
/* offset_colors = offset_vertex; */
|
||||
/* } */
|
||||
|
||||
/* for (int i = 0; i < arrows_nb + modified; i++) { */
|
||||
/* load = sworra[i].load; */
|
||||
/* site = sworra[i].site; */
|
||||
/* x = sworra[i].x; */
|
||||
/* y = sworra[i].y; */
|
||||
/* z = sworra[i].z; */
|
||||
|
||||
/* offset_vertex += write_one_arrow_line (offset_vertex); */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* print_evolution (sworra, arrows_nb, arbitrary, deleted, print_arrows_data); */
|
||||
|
||||
|
||||
// ? free (space) TODO
|
||||
free(arrows);
|
||||
arrows = NULL;
|
||||
free(sworra);
|
||||
sworra = NULL;
|
||||
arrows_nb = 0;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
#include "../../include/base.h"
|
||||
#include "../../include/graphics.h"
|
||||
|
||||
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
||||
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
|
||||
{
|
||||
float max = fmax(x, y); max = fmax(max, z);
|
||||
|
||||
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max);
|
||||
|
||||
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, - z / max);
|
||||
|
@ -52,7 +53,7 @@ int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offs
|
|||
return 8;
|
||||
}
|
||||
|
||||
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
|
||||
int write_space_ridges_lines ()
|
||||
{
|
||||
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
||||
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
||||
|
@ -65,7 +66,7 @@ int write_space_ridges_lines (long offset_vertex, long offset_colors, long offse
|
|||
return 12;
|
||||
}
|
||||
|
||||
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
|
||||
long write_grids_on_space_faces_vertex (long x, long y, long z)
|
||||
{
|
||||
float i, max = fmax(x, y); max = fmax(max, z);
|
||||
|
||||
|
@ -82,8 +83,7 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
|||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
offset_vertex += (x - 1) * 4;
|
||||
offset_colors += (x - 1) * 4;
|
||||
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
||||
|
||||
for (i = 1; i < y; i++) {
|
||||
|
||||
|
@ -98,8 +98,7 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
|||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
offset_vertex += (y - 1) * 4;
|
||||
offset_colors += (y - 1) * 4;
|
||||
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
||||
|
||||
for (i = 1; i < z; i++) {
|
||||
|
||||
|
@ -118,48 +117,36 @@ long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors,
|
|||
}
|
||||
|
||||
|
||||
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
|
||||
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z)
|
||||
{
|
||||
float i, max = fmax(x, y); max = fmax(max, z);
|
||||
for (int i = 0; i < x - 1; i ++) {
|
||||
|
||||
design = 0;
|
||||
|
||||
for (i = 0; i < x - 1; i ++) {
|
||||
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0); */
|
||||
}
|
||||
|
||||
if (design) offset_vertex += (x - 1) * 2; else offset_vertex += (x - 1) * 4;
|
||||
offset_vertex += (x - 1) * 4;
|
||||
|
||||
for (i = 0; i < y - 1; i ++) {
|
||||
for (int i = 0; i < y - 1; i ++) {
|
||||
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
}
|
||||
|
||||
if (design) offset_vertex += (y - 1) * 2; else offset_vertex += (y - 1) * 4;
|
||||
offset_vertex += (y - 1) * 4;
|
||||
|
||||
for (i = 0; i < z - 1; i ++) {
|
||||
for (int i = 0; i < z - 1; i ++) {
|
||||
|
||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
||||
if (design)
|
||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2); */
|
||||
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); */
|
||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
||||
}
|
||||
|
||||
return (x + y + z - 3) * 4;
|
||||
/* if (design) offset_lines += 2 * (space_X + space_Y + space_Z - 3); */
|
||||
/* else offset_lines += 4 * (space_X + space_Y + space_Z - 3); */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue