create_arrow() creating in arrows_ptr and drawing
This commit is contained in:
parent
5c8ed2ce06
commit
5c224b20cf
|
@ -38,7 +38,8 @@ typedef struct arrow_t {
|
||||||
GLuint z;
|
GLuint z;
|
||||||
};
|
};
|
||||||
|
|
||||||
int write_one_arrow(int offset_vertex,
|
int write_one_arrow_vertex (int space_X, int space_Y, int space_Z,
|
||||||
int space_X, int space_Y, int space_Z,
|
int weight, int site, int x, int y, int z);
|
||||||
int weight, int site, int x, int y, int z);
|
|
||||||
|
int write_one_arrow_line(int offset_vertex);
|
||||||
|
|
||||||
|
|
|
@ -38,11 +38,13 @@ 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_one_arrow_in_array(struct arrow_t *arrows, int i);
|
||||||
void show_empty_arrows_array();
|
void show_empty_arrows_array();
|
||||||
void show_arrows_array (struct arrow_t *arrows, int arrows_nb, int x, int y, int z);
|
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,
|
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);
|
int current_weight, int site, int x, int y, int z);
|
||||||
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
||||||
int space_size_x, int space_size_y, int space_size_z,
|
int space_size_x, int space_size_y, int space_size_z,
|
||||||
int show_array, int show_space_design);
|
int show_array, int show_space_design);
|
||||||
|
void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int deleted, int show_array);
|
||||||
/*
|
/*
|
||||||
* Prints the initial user choices :
|
* Prints the initial user choices :
|
||||||
* - space dimension size and appearance (grids)
|
* - space dimension size and appearance (grids)
|
||||||
|
|
|
@ -108,7 +108,7 @@ void graphics_init_buffers(const void *gl_area);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_line (GLuint a, GLuint b);
|
void graphics_write_line (GLuint a, GLuint b, int print);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a vertex at (x,y,z) into the vertex buffer
|
* Writes values to describe a vertex at (x,y,z) into the vertex buffer
|
||||||
|
@ -117,7 +117,7 @@ void graphics_write_line (GLuint a, GLuint b);
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z);
|
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a color (r,g,b) into the color buffer
|
* Writes values to describe a color (r,g,b) into the color buffer
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
int write_space_ridges (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
|
* Writes grid lines on space faces
|
||||||
|
@ -43,5 +44,6 @@ int write_space_ridges (long offset_vertex, long offset_colors, long offset_line
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
long write_grids_on_space_faces (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,85 +33,7 @@
|
||||||
* Z - Z = NORTH - SOUTH = bleu - jaune
|
* Z - Z = NORTH - SOUTH = bleu - jaune
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
int write_one_arrow_vertex (int space_X_int, int space_Y_int, int space_Z_int,
|
||||||
* 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(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 weight, int site, int arrow_x, int arrow_y, int arrow_z)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -124,65 +46,52 @@ int write_one_arrow(int offset_vertex,
|
||||||
vy = (2 * j / space_Y_int - 1) * space_Y_int / max + (1 / max),
|
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);
|
vz = (2 * k / space_Z_int - 1) * space_Z_int / max + (1 / max);
|
||||||
|
|
||||||
// arrow_basis_width donne la dimension de l'étoile centrale
|
int print = 0;
|
||||||
GLfloat arrow_basis_width = (1 / max) / 5;
|
|
||||||
|
|
||||||
// décale légèrement les pointes des flèches
|
graphics_write_vertex(vx, vy, vz, print);
|
||||||
// pour qu'elles n'aillent pas jusqu'aux faces des cubes
|
graphics_write_color(0.3f, 0.3f, 0.3f);
|
||||||
|
|
||||||
|
// réduit légèrement les longueurs des flèches
|
||||||
|
// pour qu'elles s'arrêtent avant les faces des cubes
|
||||||
GLfloat arrow_tip_padding = (1 / max) / 10;
|
GLfloat arrow_tip_padding = (1 / max) / 10;
|
||||||
|
|
||||||
// X - X axis - central star (basis)
|
|
||||||
graphics_write_vertex(vx + arrow_basis_width, vy, vz);
|
|
||||||
graphics_write_vertex(vx - arrow_basis_width, vy, vz);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
// Y - Y axis - central star (basis)
|
|
||||||
graphics_write_vertex(vx, vy + arrow_basis_width, vz);
|
|
||||||
graphics_write_vertex(vx, vy - arrow_basis_width, vz);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
// Z - Z axis - central star (basis)
|
|
||||||
graphics_write_vertex(vx, vy, vz + arrow_basis_width);
|
|
||||||
graphics_write_vertex(vx, vy, vz - arrow_basis_width);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
graphics_write_color(0.3f, 0.3f, 0.3f);
|
|
||||||
|
|
||||||
/* graphics_write_line (offset_vertex + 0, offset_vertex + 1); */
|
|
||||||
/* graphics_write_line (offset_vertex + 2, offset_vertex + 3); */
|
|
||||||
/* graphics_write_line (offset_vertex + 4, offset_vertex + 5); */
|
|
||||||
|
|
||||||
|
|
||||||
GLfloat nuance = 0.24f;
|
|
||||||
|
|
||||||
// X - X (EAST - WEST) axis - arrows tips (red - green)
|
|
||||||
graphics_write_vertex (vx + (1 / max) - arrow_tip_padding, vy, vz);
|
|
||||||
graphics_write_vertex (vx - (1 / max) + arrow_tip_padding, vy, vz);
|
|
||||||
graphics_write_color(1.0f - nuance / 3, 0.0f + nuance, 0.0f + nuance);
|
|
||||||
graphics_write_color(0.0f + nuance, 1.0f - nuance, 1.0f - nuance);
|
|
||||||
|
|
||||||
// Y - Y (ZENITH - NADIR) axis - arrows tips (cyan - magenta)
|
|
||||||
graphics_write_vertex (vx, vy + (1 / max) - arrow_tip_padding, vz);
|
|
||||||
graphics_write_vertex (vx, vy - (1 / max) + arrow_tip_padding, vz);
|
|
||||||
graphics_write_color(0.0f + nuance, 1.0f - nuance / 3, 0.0f + nuance);
|
|
||||||
graphics_write_color(1.0f - nuance, 0.0f + nuance, 1.0f - nuance);
|
|
||||||
|
|
||||||
// Z - Z (NORTH - SOUTH) axis - arrows tips (blue - yellow)
|
|
||||||
graphics_write_vertex (vx, vy, vz + (1 / max) - arrow_tip_padding);
|
|
||||||
graphics_write_vertex (vx, vy, vz - (1 / max) + arrow_tip_padding);
|
|
||||||
graphics_write_color(0.0f + nuance * 2, 0.0f + nuance * 2, 1.0f - nuance);
|
|
||||||
graphics_write_color(1.0f - nuance / 3, 1.0f - nuance / 3, 0.0f + nuance);
|
|
||||||
|
|
||||||
|
|
||||||
switch(site){
|
switch(site){
|
||||||
case EAST: case WEST: write_arrow_lines_east_west (offset_vertex, weight, site); break;
|
case EAST:
|
||||||
case ZENITH: case NADIR: write_arrow_lines_zenith_nadir (offset_vertex, weight, site); break;
|
graphics_write_vertex (vx - (site % 2 - 1) * (1 / max) + (site % 2 - 1) * arrow_tip_padding, vy, vz, print);
|
||||||
case SOUTH: case NORTH: write_arrow_lines_south_north (offset_vertex, weight, site); break;
|
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, print);
|
||||||
|
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, print);
|
||||||
|
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, print);
|
||||||
|
graphics_write_color(0.7f, 0.2f, 0.2f);
|
||||||
|
break;
|
||||||
|
case SOUTH:
|
||||||
|
graphics_write_vertex (vx, vy, vz + (site % 2 - 1) * (1 / max) - (site % 2 - 1) * arrow_tip_padding, print);
|
||||||
|
graphics_write_color(0.3f, 0.1f, 0.6f);
|
||||||
|
break;
|
||||||
|
case NORTH:
|
||||||
|
graphics_write_vertex (vx, vy, vz + (site % 2) * (1 / max) - (site % 2) * arrow_tip_padding, print);
|
||||||
|
graphics_write_color(1.0f, 1.0f, 0.0f);
|
||||||
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 12;
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int write_one_arrow_line(int offset_vertex)
|
||||||
|
{
|
||||||
|
int print = 0;
|
||||||
|
graphics_write_line (offset_vertex + 0, offset_vertex + 1, print);
|
||||||
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,18 @@
|
||||||
* - load (or weight)
|
* - load (or weight)
|
||||||
* - coordinates in space (site, x, y, z)
|
* - 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++)
|
for (int i = 0; i < arrows_nb; i++)
|
||||||
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, arrows[i].load,\
|
printf("\n [%4d] = %2d | %2d, %2d, %2d, %2d", i, arrows[i].load,\
|
||||||
arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z);
|
arrows[i].site, arrows[i].x, arrows[i].y, arrows[i].z);
|
||||||
|
@ -58,13 +67,28 @@ void print_user_choices(struct arrow_t *arrows, int arrows_nb,
|
||||||
int space_size_x, int space_size_y, int space_size_z,
|
int space_size_x, int space_size_y, int space_size_z,
|
||||||
int show_array, int show_space_design)
|
int show_array, int show_space_design)
|
||||||
{
|
{
|
||||||
printf("model + user constraints :\tspace size x,y,z = %d,%d,%d\tarrows nb = %d\t",\
|
printf("model + user constraints :\tspace size x,y,z (%3d,%3d,%3d)\tarrows nb : %6d\t",\
|
||||||
space_size_x, space_size_y, space_size_z, arrows_nb);
|
space_size_x, space_size_y, space_size_z, arrows_nb);
|
||||||
|
|
||||||
if (show_space_design) printf("orientations grilles alternées");
|
if (show_space_design) printf(" (grilles alternées)");
|
||||||
printf("\n");
|
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 :
|
||||||
|
* - arrows[] array
|
||||||
|
* NB The space may be empty or saturated with arrows or any value in between
|
||||||
|
* Only one arrow per possible coordinates with a load max equal to ? TODO
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* print_evolution (arrows, added, mem, deleted, print_arrows_data);
|
||||||
|
*/
|
||||||
|
void print_evolution (struct arrow_t *arrows, int arrows_nb, int modified, int deleted, int show_array)
|
||||||
|
{
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -30,11 +30,13 @@
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graphics.h"
|
||||||
#include "../../include/arrows.h"
|
#include "../../include/arrows.h"
|
||||||
#include "../../include/grid.h"
|
#include "../../include/grid.h"
|
||||||
|
// #include <bits/stdc++.h> TODO
|
||||||
|
|
||||||
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
#define VERTEX_SHADER_FILE "src/shaders/shader.vert"
|
||||||
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
#define FRAG_SHADER_FILE "src/shaders/shader.frag"
|
||||||
|
|
||||||
static struct arrow_t *arrows;
|
static struct arrow_t *arrows_ptr; /* nom modifié pour pouvoir plus facilement distinguer le tableau
|
||||||
|
* des autres noms incluant "arrows" (de arrows_nb, par ex.) */
|
||||||
static GLfloat *buffer_vertex_origin = NULL;
|
static GLfloat *buffer_vertex_origin = NULL;
|
||||||
static GLfloat *buffer_colors_origin = NULL;
|
static GLfloat *buffer_colors_origin = NULL;
|
||||||
static GLuint *buffer_lines_origin = NULL;
|
static GLuint *buffer_lines_origin = NULL;
|
||||||
|
@ -114,33 +116,13 @@ static void graphics_debug_callback(GLenum source, GLenum type, GLuint id,
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe a line from a to b into the line buffer
|
* Writes values to describe a vertex at (x,y,z) intoq the vertex buffer
|
||||||
*
|
|
||||||
* @param coords GLuint (a,b)
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
void graphics_write_line (GLuint a, GLuint b)
|
|
||||||
{
|
|
||||||
buffer_lines_origin = g_realloc (buffer_lines_origin,
|
|
||||||
(buffer_lines_size + 2) * sizeof(GLuint));
|
|
||||||
|
|
||||||
assert (buffer_lines_origin);
|
|
||||||
|
|
||||||
buffer_lines_origin[buffer_lines_size + 0] = a;
|
|
||||||
buffer_lines_origin[buffer_lines_size + 1] = b;
|
|
||||||
|
|
||||||
buffer_lines_size += 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Writes values to describe a vertex at (x,y,z) into the vertex buffer
|
|
||||||
*
|
*
|
||||||
* @param coords GLfloat(x,y,z)
|
* @param coords GLfloat(x,y,z)
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
|
void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z, int print)
|
||||||
{
|
{
|
||||||
buffer_vertex_origin = g_realloc (buffer_vertex_origin,
|
buffer_vertex_origin = g_realloc (buffer_vertex_origin,
|
||||||
(buffer_vertex_size + 3) * sizeof(GLfloat));
|
(buffer_vertex_size + 3) * sizeof(GLfloat));
|
||||||
|
@ -151,6 +133,9 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
|
||||||
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
buffer_vertex_origin[buffer_vertex_size + 1] = y;
|
||||||
buffer_vertex_origin[buffer_vertex_size + 2] = z;
|
buffer_vertex_origin[buffer_vertex_size + 2] = 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;
|
buffer_vertex_size += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +160,29 @@ void graphics_write_color (GLfloat r, GLfloat g, GLfloat b)
|
||||||
buffer_colors_size += 3;
|
buffer_colors_size += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Writes values to describe a line from a to b into the line buffer
|
||||||
|
*
|
||||||
|
* @param coords GLuint (a,b)
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
void graphics_write_line (GLuint a, GLuint b, int print)
|
||||||
|
{
|
||||||
|
buffer_lines_origin = g_realloc (buffer_lines_origin,
|
||||||
|
(buffer_lines_size + 2) * sizeof(GLuint));
|
||||||
|
|
||||||
|
assert (buffer_lines_origin);
|
||||||
|
|
||||||
|
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] (%2u > %2u)\n",\
|
||||||
|
buffer_lines_size + 0, buffer_lines_size + 1, a, b);
|
||||||
|
|
||||||
|
buffer_lines_size += 2;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
* Writes values to describe an (a,b,c) plan (triangle) into the plan buffer
|
||||||
*
|
*
|
||||||
|
@ -546,10 +554,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)
|
static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
arrows[address].load = load;
|
arrows_ptr[address].load = load;
|
||||||
|
|
||||||
// if (! TEST)
|
print_arrows_array (arrows_ptr, arrows_nb, 2);
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -558,25 +565,35 @@ static int rewrite_arrow (int arrows_nb, int address, int load, int site, int x,
|
||||||
* Creates a new arrow at address (address)
|
* Creates a new arrow at address (address)
|
||||||
* NB Weights (or loads) are NOT added
|
* NB Weights (or loads) are NOT added
|
||||||
*/
|
*/
|
||||||
static inline int create_arrow (int arrows_nb, int load, int site, int x, int y, int z)
|
static inline int create_arrow (int arrows_nb,
|
||||||
|
int space_X, int space_Y, int space_Z,
|
||||||
|
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(arrows_ptr, (arrows_nb + 1) * sizeof(struct arrow_t));
|
||||||
|
|
||||||
if (newptr)
|
if (newptr)
|
||||||
arrows = newptr;
|
arrows_ptr = newptr;
|
||||||
else
|
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_ptr[arrows_nb].load = load;
|
||||||
arrows[arrows_nb].site = site;
|
arrows_ptr[arrows_nb].site = site;
|
||||||
arrows[arrows_nb].x = x;
|
arrows_ptr[arrows_nb].x = x;
|
||||||
arrows[arrows_nb].y = y;
|
arrows_ptr[arrows_nb].y = y;
|
||||||
arrows[arrows_nb].z = z;
|
arrows_ptr[arrows_nb].z = z;
|
||||||
|
|
||||||
|
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);
|
||||||
|
buffer_colors_size = buffer_vertex_size;
|
||||||
|
|
||||||
|
write_one_arrow_line (buffer_vertex_size / 3 - 2);
|
||||||
|
|
||||||
arrows_nb ++;
|
arrows_nb ++;
|
||||||
|
|
||||||
// if (! TEST)
|
print_arrows_array (arrows_ptr, arrows_nb, 1);
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -588,29 +605,30 @@ static inline int erase_arrow (int arrows_nb, int address, int site, int x, int
|
||||||
{
|
{
|
||||||
arrows_nb --;
|
arrows_nb --;
|
||||||
|
|
||||||
if (arrows_nb > 0)
|
if (1)
|
||||||
{
|
{
|
||||||
arrows[address].load = arrows[arrows_nb].load;
|
arrows_ptr[address].load = arrows_ptr[arrows_nb].load;
|
||||||
arrows[address].site = arrows[arrows_nb].site;
|
arrows_ptr[address].site = arrows_ptr[arrows_nb].site;
|
||||||
arrows[address].x = arrows[arrows_nb].x;
|
arrows_ptr[address].x = arrows_ptr[arrows_nb].x;
|
||||||
arrows[address].y = arrows[arrows_nb].y;
|
arrows_ptr[address].y = arrows_ptr[arrows_nb].y;
|
||||||
arrows[address].z = arrows[arrows_nb].z;
|
arrows_ptr[address].z = arrows_ptr[arrows_nb].z;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *newptr = g_realloc(arrows, arrows_nb * sizeof(struct arrow_t));
|
if (arrows_nb > 0) {
|
||||||
|
void *newptr = g_realloc(arrows_ptr, arrows_nb * sizeof(struct arrow_t));
|
||||||
|
|
||||||
if (newptr)
|
if (newptr)
|
||||||
arrows = newptr;
|
arrows_ptr = newptr;
|
||||||
else
|
else
|
||||||
perror("Can't allocate new arrow buffer!\n");
|
perror("In erase arrow, can't allocate new arrow buffer !\n");
|
||||||
|
}
|
||||||
|
|
||||||
// if (! TEST)
|
print_arrows_array (arrows_ptr, arrows_nb,0);
|
||||||
// print_arrows_array (arrows, arrows_nb);
|
|
||||||
|
|
||||||
return arrows_nb;
|
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 *arrows_ptr, int arrows_nb, int address, int requested_weight,
|
||||||
int current_weight, int site, int x, int y, int z);
|
int current_weight, int site, int x, int y, int z);
|
||||||
/*
|
/*
|
||||||
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
* Calls one of the functions create_arrow(), erase_arrow() or rewrite_arrow()
|
||||||
|
@ -620,28 +638,32 @@ 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
|
* - 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
|
* - 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 *arrows_ptr, int arrows_nb,
|
||||||
|
int space_X, int space_Y, int space_Z,
|
||||||
|
int requested_weight, int site, int x, int y, int z)
|
||||||
{
|
{
|
||||||
int address = -1, current_weight = -1;
|
int address = -1, current_weight = -1;
|
||||||
|
|
||||||
|
#pragma omp parallel schedule(static, 12)
|
||||||
|
{
|
||||||
for (int i = 0; i < arrows_nb; i++) {
|
for (int i = 0; i < arrows_nb; i++) {
|
||||||
if ((site == arrows[i].site)
|
if ((site == arrows_ptr[i].site)
|
||||||
&& (x == arrows[i].x)
|
&& (x == arrows_ptr[i].x)
|
||||||
&& (y == arrows[i].y)
|
&& (y == arrows_ptr[i].y)
|
||||||
&& (z == arrows[i].z))
|
&& (z == arrows_ptr[i].z))
|
||||||
{
|
{
|
||||||
address = i * 5;
|
address = i * 5;
|
||||||
current_weight = arrows[i].load;
|
current_weight = arrows_ptr[i].load;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//printf("\n[%d]set_arrow() invoked with requested weight = %2d + ", arrows_nb, requested_weight);
|
//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(arrows_ptr, arrows_nb, address, requested_weight, current_weight, site, x, y, z);
|
||||||
|
|
||||||
if (address == -1 && requested_weight > 0)
|
if (address == -1 && requested_weight > 0)
|
||||||
return create_arrow (arrows_nb, requested_weight, site, x, y, z);
|
return create_arrow (arrows_nb, space_X, space_Y, space_Z, requested_weight, site, x, y, z);
|
||||||
|
|
||||||
if (address >= 0 && requested_weight == 0)
|
if (address >= 0 && requested_weight == 0)
|
||||||
return erase_arrow (arrows_nb, address, site, x, y, z);
|
return erase_arrow (arrows_nb, address, site, x, y, z);
|
||||||
|
@ -649,9 +671,9 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
|
||||||
if (address >= 0 && current_weight != requested_weight)
|
if (address >= 0 && current_weight != requested_weight)
|
||||||
return rewrite_arrow (arrows_nb, address/5, requested_weight, site, x, y, z);
|
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(arrows_ptr, 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(arrows_ptr, arrows_nb, 4);
|
||||||
|
|
||||||
return arrows_nb;
|
return arrows_nb;
|
||||||
}
|
}
|
||||||
|
@ -665,68 +687,236 @@ static inline int set_arrow (struct arrow_t *arrows, int arrows_nb, int requeste
|
||||||
*/
|
*/
|
||||||
void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
|
||||||
{
|
{
|
||||||
// assert : space dimensions (x,y,z) > 0 TODO NOT checked before init
|
// assert : space dimensions (x,y,z) > 0
|
||||||
// assert : arrows localization within space and sites TODO NOT checked when invoking set_arrow()
|
// assert : arrows localization within space and sites
|
||||||
// assert : no more than one arrow per address TODO NOT checked before init
|
// assert : no more than one arrow per address
|
||||||
// notify : weights are replaced, NOT added (could be !) TODO
|
// notify : weights are replaced, NOT added (could be !)
|
||||||
|
|
||||||
// Initialisation du générateur pseudo-aléatoire
|
struct timespec ts;
|
||||||
srand(time(NULL));
|
srand(time(NULL)); // Initialisation du générateur pseudo-aléatoire
|
||||||
int rand(void);
|
int rand(void);
|
||||||
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
void srand(unsigned int seed); // printf ("Valeur max : %d\n", RAND_MAX); min + rand() % (max+1 - min);
|
||||||
|
|
||||||
int arbitrary = 10;
|
int arbitrary = 5;
|
||||||
int space_X = 1 + rand() % arbitrary,
|
int space_X = 1 + rand() % arbitrary,
|
||||||
space_Y = 1 + rand() % arbitrary,
|
space_Y = 1 + rand() % arbitrary,
|
||||||
space_Z = 1 + rand() % arbitrary;
|
space_Z = 1 + rand() % arbitrary;
|
||||||
int density_max = space_X * space_Y * space_Z;
|
int density_max = space_X * space_Y * space_Z;
|
||||||
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
int max = fmax(space_X, space_Y); max = fmax(max, space_Z);
|
||||||
|
|
||||||
int show_space_design = 0, print_arrows_data = 0;
|
int print_arrows_data = 0;
|
||||||
|
|
||||||
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
int load = 0, site = 0, x = 0, y = 0, z = 0;
|
||||||
int specif_arrows_nb = rand() % density_max / 3;
|
int specif_arrows_nb = rand() % density_max / 2;
|
||||||
int arrows_nb = 0;
|
int arrows_nb = 0, cpt = 0, t_initial = 0;
|
||||||
|
|
||||||
while (arrows_nb < specif_arrows_nb){
|
int print_inter_results = 0;
|
||||||
arrows_nb = set_arrow (arrows, arrows_nb,
|
if (print_inter_results) clock_gettime(CLOCK_REALTIME, &ts); t_initial = ts.tv_sec;
|
||||||
rand() % arbitrary, // load / weight
|
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");
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* 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 */
|
||||||
|
|
||||||
|
/* 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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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("(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); */
|
||||||
|
|
||||||
|
|
||||||
|
/* A R R O W S */
|
||||||
|
|
||||||
|
/* if (1) printf("buffer_vertex_size before writing (%d) arrows_vertex : %d\n", arrows_nb, buffer_vertex_size / 3); */
|
||||||
|
|
||||||
|
/* 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; */
|
||||||
|
|
||||||
|
/* write_one_arrow_vertex(space_X, space_Y, space_Z, */
|
||||||
|
/* load, site, x, y, z); */
|
||||||
|
/* buffer_colors_size = buffer_vertex_size; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* if (1) printf("buffer_vertex_size after writing (%d) arrows_vertex : %d\n", arrows_nb, buffer_vertex_size / 3); */
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------*/
|
||||||
|
|
||||||
|
/* L I N E S S E C O N D */
|
||||||
|
|
||||||
|
// buffer_vertex_size = 0; buffer_colors_size = 0; buffer_lines_size = 0;
|
||||||
|
|
||||||
|
/* S P A C E */
|
||||||
|
|
||||||
|
if (0) printf("buffer_lines_size before writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||||
|
write_space_ridges_lines ();
|
||||||
|
if (0) printf("buffer_lines_size after writing 12 space_ridges_lines : %2d (* 2 = %2d)\n", buffer_lines_size / 2, buffer_lines_size);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* A R R O W S */
|
||||||
|
|
||||||
|
/* #pragma omp parallel */
|
||||||
|
/* { */
|
||||||
|
/* 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() % 6, // site,
|
||||||
rand() % space_X, // x
|
rand() % space_X, // x
|
||||||
rand() % space_Y, // y
|
rand() % space_Y, // y
|
||||||
rand() % space_Z); // z
|
rand() % space_Z); // z
|
||||||
}
|
|
||||||
|
|
||||||
print_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, show_space_design);
|
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
|
||||||
|
|
||||||
/* DATA ARE NOW ALL SPECIFIED - DRAWING CAN START */
|
/* 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; */
|
||||||
|
|
||||||
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
|
/* buffer_vertex_size += write_one_arrow_line (buffer_vertex_size); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
offset_vertex += write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
|
|
||||||
offset_colors = offset_vertex;
|
|
||||||
|
|
||||||
offset_vertex += write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z, show_space_design);
|
|
||||||
offset_colors = offset_vertex;
|
|
||||||
|
|
||||||
/* ARROWS */
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
offset_vertex += write_one_arrow(offset_vertex,
|
|
||||||
space_X, space_Y, space_Z,
|
|
||||||
load, site, x, y, z);
|
|
||||||
offset_colors = offset_vertex;
|
/* 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 */
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
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, */
|
||||||
|
/* 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, */
|
||||||
|
/* 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 (arrows_ptr, 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 */
|
||||||
|
|
||||||
|
/* printf("On devrait avoir deux flèches Y+Y- (Zénith-Nadir) dessinées (au lieu des deux flèches X+X- Est-Ouest)...\n"); */
|
||||||
|
|
||||||
|
/* print_user_choices(arrows_ptr, arrows_nb, space_X, space_Y, space_Z, print_arrows_data, 0); */
|
||||||
|
|
||||||
|
// buffer_vertex_size -= 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 (arrows_ptr, 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 = 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_vertex(space_X, space_Y, space_Z, */
|
||||||
|
/* load, site, x, y, z); */
|
||||||
|
/* buffer_colors_size = buffer_vertex_size; */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* for (int i = 0; i < arrows_nb + modified; 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); */
|
||||||
|
/* } */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* print_evolution (arrows_ptr, arrows_nb, arbitrary, deleted, print_arrows_data); */
|
||||||
|
|
||||||
|
|
||||||
// ? free (space) TODO
|
// ? free (space) TODO
|
||||||
free(arrows);
|
|
||||||
arrows = NULL;
|
free(arrows_ptr);
|
||||||
|
arrows_ptr = NULL;
|
||||||
arrows_nb = 0;
|
arrows_nb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,51 +25,57 @@
|
||||||
#include "../../include/base.h"
|
#include "../../include/base.h"
|
||||||
#include "../../include/graphics.h"
|
#include "../../include/graphics.h"
|
||||||
|
|
||||||
int write_space_ridges (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);
|
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);
|
graphics_write_vertex (offset_vertex - x / max, offset_vertex - y / max, - z / max, 0);
|
||||||
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);
|
|
||||||
|
|
||||||
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, 0);
|
||||||
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, 0);
|
||||||
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, 0);
|
||||||
|
|
||||||
graphics_write_vertex (offset_vertex + x / max, + y / max, + z / max);
|
graphics_write_vertex (offset_vertex + x / max, offset_vertex + y / max, - z / max, 0);
|
||||||
|
graphics_write_vertex (offset_vertex + x / max, offset_vertex - y / max, + z / max, 0);
|
||||||
|
graphics_write_vertex (offset_vertex - x / max, offset_vertex + y / max, + z / max, 0);
|
||||||
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
graphics_write_vertex (offset_vertex + x / max, + y / max, + z / max, 0);
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
graphics_write_color (0.9f, 0.2f, 0.1f);
|
|
||||||
|
|
||||||
graphics_write_line ( 0, 1); graphics_write_line ( 7, 4);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
graphics_write_line ( 0, 2); graphics_write_line ( 7, 5);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
graphics_write_line ( 0, 3); graphics_write_line ( 7, 6);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
graphics_write_line ( 1, 4); graphics_write_line ( 2, 4);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
graphics_write_line ( 1, 5); graphics_write_line ( 3, 5);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
graphics_write_line ( 2, 6); graphics_write_line ( 3, 6);
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
|
graphics_write_color (0.9f, 0.7f, 0.4f);
|
||||||
|
|
||||||
return 8;
|
return 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
long write_grids_on_space_faces (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style)
|
int write_space_ridges_lines ()
|
||||||
|
{
|
||||||
|
graphics_write_line ( 0, 1, 0); graphics_write_line ( 7, 4, 0);
|
||||||
|
graphics_write_line ( 0, 2, 0); graphics_write_line ( 7, 5, 0);
|
||||||
|
graphics_write_line ( 0, 3, 0); graphics_write_line ( 7, 6, 0);
|
||||||
|
|
||||||
|
graphics_write_line ( 1, 4, 0); graphics_write_line ( 2, 4, 0);
|
||||||
|
graphics_write_line ( 1, 5, 0); graphics_write_line ( 3, 5, 0);
|
||||||
|
graphics_write_line ( 2, 6, 0); graphics_write_line ( 3, 6, 0);
|
||||||
|
|
||||||
|
return 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
long write_grids_on_space_faces_vertex (long x, long y, long z)
|
||||||
{
|
{
|
||||||
float i, max = fmax(x, y); max = fmax(max, z);
|
float i, max = fmax(x, y); max = fmax(max, z);
|
||||||
|
|
||||||
for (i = 1; i < x; i++) { // (x - 2) * 4
|
for (i = 1; i < x; i++) {
|
||||||
|
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max);
|
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, - z / max, 0);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max);
|
graphics_write_vertex ((2 * i / x - 1) * x / max, - y / max, z / max, 0);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max);
|
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, z / max, 0);
|
||||||
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max);
|
graphics_write_vertex ((2 * i / x - 1) * x / max, y / max, - z / max, 0);
|
||||||
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
@ -77,74 +83,72 @@ long write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < x - 1; i ++) {
|
/* offset_vertex += (x - 1) * 4; */ /* offset_colors += (x - 1) * 4; */
|
||||||
|
|
||||||
if (style)
|
for (i = 1; i < y; 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_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
||||||
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3);
|
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
||||||
if (style)
|
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max, 0);
|
||||||
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
|
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max, 0);
|
||||||
|
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* offset_vertex += (y - 1) * 4; */ /* offset_colors += (y - 1) * 4; */
|
||||||
|
|
||||||
|
for (i = 1; i < z; i++) {
|
||||||
|
|
||||||
|
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
||||||
|
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
||||||
|
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max, 0);
|
||||||
|
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max, 0);
|
||||||
|
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
graphics_write_color (0.5f, 0.5f, 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (x + y + z - 3) * 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
long write_grids_on_space_faces_lines (long offset_vertex, long x, long y, long z)
|
||||||
|
{
|
||||||
|
offset_vertex = offset_vertex / 3;
|
||||||
|
|
||||||
|
for (int i = 0; i < x - 1; i ++) {
|
||||||
|
|
||||||
|
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
||||||
|
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0);
|
||||||
|
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
||||||
|
/* graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0); */
|
||||||
}
|
}
|
||||||
|
|
||||||
offset_vertex += (x - 1) * 4;
|
offset_vertex += (x - 1) * 4;
|
||||||
offset_colors += (x - 1) * 4;
|
|
||||||
if (style) offset_lines += (x - 1) * 2; else offset_lines += (x - 1) * 4;
|
|
||||||
|
|
||||||
for (i = 1; i < y; i++) { // (y - 2) * 4
|
for (int i = 0; i < y - 1; i ++) {
|
||||||
|
|
||||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, - z / max);
|
/* graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0); */
|
||||||
graphics_write_vertex (- x / max, (2 * i / y - 1) * y / max, z / max);
|
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
||||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, z / max);
|
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0);
|
||||||
graphics_write_vertex ( x / max, (2 * i / y - 1) * y / max, - z / max);
|
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
||||||
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < y - 1; i ++) {
|
|
||||||
|
|
||||||
if (style)
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
|
||||||
if (style)
|
|
||||||
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;
|
offset_vertex += (y - 1) * 4;
|
||||||
offset_colors += (y - 1) * 4;
|
|
||||||
if (style) offset_lines += (y - 1) * 2; else offset_lines += (y - 1) * 4;
|
|
||||||
|
|
||||||
for (i = 1; i < z; i++) { // (z - 2) * 4
|
for (int i = 0; i < z - 1; i ++) {
|
||||||
|
|
||||||
graphics_write_vertex (- x / max, - y / max, (2 * i / z - 1) * z / max);
|
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1, 0);
|
||||||
graphics_write_vertex (- x / max, y / max, (2 * i / z - 1) * z / max);
|
/* graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2, 0); */
|
||||||
graphics_write_vertex ( x / max, y / max, (2 * i / z - 1) * z / max);
|
/* graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3, 0); */
|
||||||
graphics_write_vertex ( x / max, - y / max, (2 * i / z - 1) * z / max);
|
graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0, 0);
|
||||||
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
graphics_write_color (0.5f, 0.5f, 0.5f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < z - 1; i ++) {
|
|
||||||
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 0, offset_vertex + i * 4 + 1);
|
|
||||||
if (style)
|
|
||||||
graphics_write_line (offset_vertex + i * 4 + 1, offset_vertex + i * 4 + 2);
|
|
||||||
if (style)
|
|
||||||
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;
|
return (x + y + z - 3) * 4;
|
||||||
/* if (style) 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