Compare commits

..

No commits in common. "1a7a535f4590c63059b9f10f5649a940d18f4db8" and "e58d86a58f63804811ea52edaf26bdb6e6dce5e7" have entirely different histories.

7 changed files with 238 additions and 224 deletions

View File

@ -42,5 +42,7 @@ 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_line(int offset_vertex);
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);

View File

@ -38,7 +38,6 @@ 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,

View File

@ -34,8 +34,8 @@
*
* @return void
*/
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z);
int write_space_ridges_lines ();
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);
/*
* Writes grid lines on space faces
@ -44,6 +44,6 @@ int write_space_ridges_lines ();
*
* @return void
*/
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);
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);

View File

@ -33,6 +33,83 @@
* 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)
@ -59,19 +136,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:
@ -89,9 +166,17 @@ int write_one_arrow_vertex (int offset_vertex,
}
int write_one_arrow_line(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)
{
graphics_write_line (offset_vertex + 0, offset_vertex + 1);
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;
}
return 2;
}

View File

@ -37,18 +37,9 @@
* - load (or weight)
* - coordinates in space (site, x, y, z)
*/
void print_arrows_array (struct arrow_t *arrows, int arrows_nb, int invoked_by)
static void print_arrows_array (struct arrow_t *arrows, int arrows_nb)
{
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;
}
printf(" [rank] load | site x y z");
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);
@ -73,7 +64,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, 5);
if (show_array) print_arrows_array (arrows, arrows_nb);
}
/* Prints the evolution after adding / removing arrows :
@ -88,7 +79,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, 6);
if (show_array) print_arrows_array (arrows, arrows_nb);
}
/*

View File

@ -35,7 +35,7 @@
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
static struct arrow_t *sworra;
static struct arrow_t *arrows;
static GLfloat *buffer_vertex_origin = NULL;
static GLfloat *buffer_colors_origin = NULL;
static GLuint *buffer_lines_origin = NULL;
@ -549,9 +549,10 @@ 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)
{
sworra[address].load = load;
arrows[address].load = load;
print_arrows_array (sworra, arrows_nb, 2);
// if (! TEST)
// print_arrows_array (arrows, arrows_nb);
return arrows_nb;
}
@ -562,22 +563,23 @@ 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(sworra, (arrows_nb + 1) * sizeof(struct arrow_t));
void *newptr = g_realloc(arrows, (arrows_nb + 1) * sizeof(struct arrow_t));
if (newptr)
sworra = newptr;
arrows = newptr;
else
perror("In create arrow, can't allocate new arrow buffer !\n");
perror("Can't allocate new arrow buffer!\n");
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[arrows_nb].load = load;
arrows[arrows_nb].site = site;
arrows[arrows_nb].x = x;
arrows[arrows_nb].y = y;
arrows[arrows_nb].z = z;
arrows_nb ++;
print_arrows_array (sworra, arrows_nb, 1);
// if (! TEST)
// print_arrows_array (arrows, arrows_nb);
return arrows_nb;
}
@ -591,26 +593,27 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
if (arrows_nb > 0)
{
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;
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;
}
/* void *newptr = g_realloc(sworra, arrows_nb * sizeof(struct arrow_t)); */
void *newptr = g_realloc(arrows, arrows_nb * sizeof(struct arrow_t));
/* if (newptr) */
/* sworra = newptr; */
/* else */
/* perror("In erase arrow, can't allocate new arrow buffer !\n"); */
if (newptr)
arrows = newptr;
else
perror("Can't allocate new arrow buffer!\n");
print_arrows_array (sworra, arrows_nb,0);
// if (! TEST)
// print_arrows_array (arrows, arrows_nb);
return arrows_nb;
}
static inline void show_user_action(struct arrow_t *sworra, int arrows_nb, int address, int requested_weight,
static inline void show_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);
/*
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
@ -620,27 +623,27 @@ static inline void show_user_action(struct arrow_t *sworra, 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 *sworra, int arrows_nb, int requested_weight, int site, int x, int y, int z)
static inline int set_arrow (struct arrow_t *arrows, 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 == sworra[i].site)
&& (x == sworra[i].x)
&& (y == sworra[i].y)
&& (z == sworra[i].z))
if ((site == arrows[i].site)
&& (x == arrows[i].x)
&& (y == arrows[i].y)
&& (z == arrows[i].z))
{
address = i * 5;
current_weight = sworra[i].load;
current_weight = arrows[i].load;
break;
}
}
}
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
if (TEST) show_user_action(sworra, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
if (TEST) show_user_action(arrows, 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);
@ -651,9 +654,9 @@ static inline int set_arrow (struct arrow_t *sworra, 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(sworra, arrows_nb, 3);
// if (! TEST && address >= 0 && current_weight == requested_weight) print_arrows_array(arrows, arrows_nb, x, y, z);
if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(sworra, arrows_nb, 4);
// if (! TEST && address == -1 && requested_weight == 0) print_arrows_array(arrows, arrows_nb, x, y, z);
return arrows_nb;
}
@ -677,44 +680,36 @@ 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 = 3;
int space_X = 1,// + rand() % arbitrary,
space_Y = 1,// + rand() % arbitrary,
space_Z = 1;// + rand() % arbitrary;
int arbitrary = 200;
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 print_arrows_data = 0;
int show_space_design = 1, print_arrows_data = 0;
int load = 0, site = 0, x = 0, y = 0, z = 0;
int specif_arrows_nb = 1;//rand() % density_max;
int specif_arrows_nb = rand() % density_max;
int arrows_nb = 0, cpt = 0, t_initial = 0;
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);
clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
printf("%10d | ", specif_arrows_nb / 1000);
#pragma omp parallel
{
/* 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
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
/* 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);}
/* } */
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");
if (arrows_nb % 1000 == 0) {cpt++; printf("%8d", arrows_nb / 1000); if (cpt % 24 == 0) printf("\n%10d | ", specif_arrows_nb / 1000);}
}
printf("\n");
}
// clock_t start, end;
@ -724,13 +719,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 Q U A D R U P L E B O U C L E
* C E T T E T R I 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 (sworra, arrows_nb, */
/* arrows_nb = set_arrow (arrows, arrows_nb, */
/* 1, // load / weight */
/* u,//i % 6, // site, */
/* i,//i % space_X, // x */
@ -739,29 +734,26 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* ); */
// end = clock(); printf("Elapsed time %ld\n", end - start);
/* print_user_choices(sworra, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, show_space_design);
/*--------------------------------------------------------------------------------*/
/* D A T A A R E N O W A L L S P E C I F I E D */
/* 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 */
/* D R A W I N G C A N S T A R T */
/* A N D C A N B E D R A W N */
/*---------------------------------------------------------------*/
/*--------------------------------------------------------------------------------*/
/* V E R T E X F I R S T */
/* V E R T E X F I R S T */
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
/* S P A C E */
// float max = fmax(x, y); max = fmax(max, z);
offset_vertex += write_space_ridges_vertex (offset_vertex, space_X, space_Y, space_Z);
offset_vertex += write_space_ridges_vertex (offset_vertex, offset_colors, offset_lines, 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 (space_X, space_Y, space_Z);
offset_vertex += write_grids_on_space_faces_vertex (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
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);
@ -772,11 +764,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 = sworra[i].load;
site = sworra[i].site;
x = sworra[i].x;
y = sworra[i].y;
z = sworra[i].z;
load = arrows[i].load;
site = arrows[i].site;
x = arrows[i].x;
y = arrows[i].y;
z = arrows[i].z;
offset_vertex += write_one_arrow_vertex(offset_vertex,
space_X, space_Y, space_Z,
@ -795,114 +787,46 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
/* S P A C E */
offset_vertex += write_space_ridges_lines ();
offset_vertex += write_space_ridges_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, space_X, space_Y, space_Z);
offset_vertex += write_grids_on_space_faces_lines (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
/* A R R O W S */
for (int i = 0; i < arrows_nb; i++) {
load = sworra[i].load;
site = sworra[i].site;
x = sworra[i].x;
y = sworra[i].y;
z = sworra[i].z;
load = arrows[i].load;
site = arrows[i].site;
x = arrows[i].x;
y = arrows[i].y;
z = arrows[i].z;
offset_vertex += write_one_arrow_line (offset_vertex);
offset_vertex += write_one_arrow_lines (offset_vertex, space_X, space_Y, space_Z,
load, site, x, y, z);
}
/* 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 */
assert : arrows_nb > arbitrary;
int random_choice, modified = 0, deleted = 0;
/* B E F O R E B E I N G D R A W N E D */
#pragma omp parallel
{
while (modified < arbitrary) {
/*--------------------------------------------------------------------------------*/
random_choice = rand() % 6;
if (random_choice == 0) deleted++;
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); */
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);
// ? free (space) TODO
free(sworra);
sworra = NULL;
free(arrows);
arrows = NULL;
arrows_nb = 0;
}

View File

@ -25,10 +25,9 @@
#include "../../include/base.h"
#include "../../include/graphics.h"
int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
int write_space_ridges_vertex (long offset_vertex, long offset_colors, long offset_lines, 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);
@ -53,7 +52,7 @@ int write_space_ridges_vertex (long offset_vertex, long x, long y, long z)
return 8;
}
int write_space_ridges_lines ()
int write_space_ridges_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z)
{
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
@ -66,7 +65,7 @@ int write_space_ridges_lines ()
return 12;
}
long write_grids_on_space_faces_vertex (long x, long y, long z)
long write_grids_on_space_faces_vertex (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
{
float i, max = fmax(x, y); max = fmax(max, z);
@ -83,7 +82,8 @@ long write_grids_on_space_faces_vertex (long x, long y, long z)
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,7 +98,8 @@ long write_grids_on_space_faces_vertex (long x, long y, long z)
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++) {
@ -117,36 +118,48 @@ 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)
long write_grids_on_space_faces_lines (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int design)
{
for (int i = 0; i < x - 1; i ++) {
float i, max = fmax(x, y); max = fmax(max, z);
/* 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); */
}
design = 0;
offset_vertex += (x - 1) * 4;
for (int i = 0; i < y - 1; i ++) {
/* 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);
}
offset_vertex += (y - 1) * 4;
for (int i = 0; i < z - 1; i ++) {
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 + 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 + 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);
}
if (design) offset_vertex += (x - 1) * 2; else offset_vertex += (x - 1) * 4;
for (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 + 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;
for (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 + 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); */
}