WIP: deux listes arrows (init & current)? probable fausse route

This commit is contained in:
Jean Sirmai 2023-09-23 13:08:14 +02:00
parent 7b76a54756
commit babdaca5b7
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 58 additions and 48 deletions

View File

@ -100,67 +100,67 @@ void arrows_write_terminations (long x, long y, long z)
} }
/* /*
* Writes lines for arrow oriented to the east or west into lines buffer * Writes edges for arrows oriented toward east or west into lines buffer
* *
* @param s, * @param offset,
* weight, * weight,
* site * site
* *
* @return void * @return void
*/ */
void write_arrow_lines_east_west (long s, int weight, int site) void write_arrow_lines_east_west (long offset, int weight, int site)
{ {
graphics_write_line (s + 2, s + 6 + site % 2); graphics_write_line (offset + 2, offset + 6 + site % 2);
graphics_write_line (s + 3, s + 6 + site % 2); graphics_write_line (offset + 3, offset + 6 + site % 2);
graphics_write_line (s + 4, s + 6 + site % 2); graphics_write_line (offset + 4, offset + 6 + site % 2);
graphics_write_line (s + 5, s + 6 + site % 2); graphics_write_line (offset + 5, offset + 6 + site % 2);
} }
/* /*
* Writes lines for arrow oriented to the zenith or nadir into lines buffer * Writes edges for arrows oriented toward zenith or nadir into lines buffer
* *
* @param s, * @param offset,
* weight, * weight,
* site * site
* *
* @return void * @return void
*/ */
void write_arrow_lines_zenith_nadir (long s, int weight, int site) void write_arrow_lines_zenith_nadir (long offset, int weight, int site)
{ {
graphics_write_line (s + 0, s + 8 + site % 2); graphics_write_line (offset + 0, offset + 8 + site % 2);
graphics_write_line (s + 1, s + 8 + site % 2); graphics_write_line (offset + 1, offset + 8 + site % 2);
graphics_write_line (s + 4, s + 8 + site % 2); graphics_write_line (offset + 4, offset + 8 + site % 2);
graphics_write_line (s + 5, s + 8 + site % 2); graphics_write_line (offset + 5, offset + 8 + site % 2);
} }
/* /*
* Writes lines for arrow oriented to the south or north into lines buffer * Writes edges for arrows oriented toward south or north into lines buffer
* *
* @param s, * @param offset,
* weight, * weight,
* site * site
* *
* @return void * @return void
*/ */
void write_arrow_lines_south_north (long s, int weight, int site) void write_arrow_lines_south_north (long offset, int weight, int site)
{ {
graphics_write_line (s + 0, s + 10 + site % 2); graphics_write_line (offset + 0, offset + 10 + site % 2);
graphics_write_line (s + 1, s + 10 + site % 2); graphics_write_line (offset + 1, offset + 10 + site % 2);
graphics_write_line (s + 2, s + 10 + site % 2); graphics_write_line (offset + 2, offset + 10 + site % 2);
graphics_write_line (s + 3, s + 10 + site % 2); graphics_write_line (offset + 3, offset + 10 + site % 2);
} }
/* /*
* Writes lines for arrow basis into lines buffer * Writes lines drawing arrows bases into lines buffer
* *
* @param n * @param offset
* *
* @return void * @return void
*/ */
void arrows_write_basis(long n) void arrows_write_basis(long offset)
{ {
graphics_write_line (n + 0, n + 1); graphics_write_line (offset + 0, offset + 1);
graphics_write_line (n + 2, n + 3); graphics_write_line (offset + 2, offset + 3);
graphics_write_line (n + 4, n + 5); graphics_write_line (offset + 4, offset + 5);
} }

View File

@ -50,14 +50,15 @@ static int buffer_plans_size = 0;
// assert : l'emplacement des flèches est contraint // assert : l'emplacement des flèches est contraint
// par model_space_size_x, y, z et le nombre de sites // par model_space_size_x, y, z et le nombre de sites
static GLuint arrows[] = { static GLuint arrows[] = {};
static GLuint arrows_init[] = {
1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
1, 1, 1, 0, 0, 1, 1, 1, 0, 0,
1, 1, 0, 0, 0, /* 1, 1, 0, 0, 0, */
1, 2, 0, 0, 0, /* 1, 2, 0, 0, 0, */
1, 3, 0, 0, 0, /* 1, 3, 0, 0, 0, */
1, 4, 0, 0, 0, /* 1, 4, 0, 0, 0, */
1, 5, 0, 0, 0, /* 1, 5, 0, 0, 0, */
// load, site, x, y, z // load, site, x, y, z
}; };
@ -66,6 +67,11 @@ static int get_arrows_nb(){
else return sizeof(arrows) / sizeof(arrows[0]) / 5; else return sizeof(arrows) / sizeof(arrows[0]) / 5;
} }
static int get_arrows_init_nb(){
if (sizeof(arrows_init) == 0) return 0;
else return sizeof(arrows_init) / sizeof(arrows_init[0]) / 5;
}
static void show_user_choices(int space_size_x, static void show_user_choices(int space_size_x,
int space_size_y, int space_size_y,
int space_size_z, int space_size_z,
@ -95,7 +101,7 @@ static void get_model_data_and_user_preferences()
show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z, show_user_choices(model_space_size_x, model_space_size_y, model_space_size_z,
pref_show_grids); pref_show_grids);
// set_arrow(arrows, 1, 1, 1, 0, 0); // set_arrow(1, 3, 1, 0, 0);
} }
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
@ -120,8 +126,8 @@ static bool create_arrow (int weight, int site, int x, int y, int z)
{ {
int arrows_nb = get_arrows_nb(); int arrows_nb = get_arrows_nb();
arrows_nb ++; arrows_nb ++;
buffer_lines_size += (3 + 4) * 2; buffer_lines_size += (3 + 4) * 8 * sizeof(GLuint);
buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size * 2 * sizeof(GLuint)); buffer_lines_origin = g_realloc(buffer_lines_origin, buffer_lines_size);
if (1) printf("create a new arrow with weight = %d at (%d, %d, %d, %d)\n",\ if (1) printf("create a new arrow with weight = %d at (%d, %d, %d, %d)\n",\
weight, site, x, y, z); weight, site, x, y, z);
@ -190,12 +196,13 @@ static int check_for_arrow (int weight, int site, int x, int y, int z)
static void show_arrows_array (int address, int weight, int site, int x, int y, int z) static void show_arrows_array (int address, int weight, int site, int x, int y, int z)
{ {
int arrows_nb = get_arrows_nb(); int arrows_nb = get_arrows_nb();
int arrows_init_nb = get_arrows_init_nb();
printf("\n [ n] load | site x y z ----- < arrows_nb = %d > ------", arrows_nb); printf("\n [ n] load | site x y z ----- < arrows_nb = %d > ------", arrows_nb);
if (arrows_nb == 0) printf("--------------------------- no arrows\n"); if (arrows_nb == 0) printf("--------------------------- no arrows\n");
else if (address == -1) printf("--------------------------- create new arrow\n"); else if (address == -1) printf("--------------------------- create new arrow\n");
else printf("--------------------------- erase arrow at address = %d / 5\n", address); else printf("--------------------------- erase arrow at address = %d / 5\n", address);
for (int i = 0; i < arrows_nb; i++) for (int i = 0; i < arrows_init_nb; i++)
{ {
printf(" [%2d] = %2d | %2d, %2d, %2d, %2d ",\ printf(" [%2d] = %2d | %2d, %2d, %2d, %2d ",\
i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\ i, *(arrows + i * 5 + 0), *(arrows + i * 5 + 1), *(arrows + i * 5 + 2),\
@ -216,10 +223,10 @@ static void show_arrows_array (int address, int weight, int site, int x, int y,
static int set_arrow (int weight, int site, int x, int y, int z) static int set_arrow (int weight, int site, int x, int y, int z)
{ {
int address = (check_for_arrow (weight, site, x, y, z)); int address = (check_for_arrow (weight, site, x, y, z));
show_arrows_array(address, weight, site, x, y, z); // show_arrows_array(address, weight, site, x, y, z);
if (address == -1 && weight == 0) return 0; if (address == -1 && weight == 0) return 0;
if (address == -1 && weight > 0) return create_arrow (weight, site, x, y, z); // if (address == -1 && weight > 0) return create_arrow (weight, site, x, y, z);
if (address >= 0 && weight == 0) return erase_arrow (address, site, x, y, z); if (address >= 0 && weight == 0) return erase_arrow (address, site, x, y, z);
if (address >= 0 && weight > 0) return rewrite_arrow (address, weight, site, x, y, z); if (address >= 0 && weight > 0) return rewrite_arrow (address, weight, site, x, y, z);
@ -790,16 +797,16 @@ void main_test_graphics (void)
/* ARROWS */ /* ARROWS */
arrows_write_terminations (x, y, z); arrows_write_terminations (x, y, z);
int arrows_nb = get_arrows_nb(), cube_coord = 0; int arrows_init_nb = get_arrows_init_nb(), cube_coord = 0;
for (int i = 0; i < arrows_nb; i++) { for (int i = 0; i < arrows_init_nb; i++) {
weight = arrows[i * 5 + 0]; weight = arrows_init[i * 5 + 0];
site = arrows[i * 5 + 1]; site = arrows_init[i * 5 + 1];
x = arrows[i * 5 + 2]; x = arrows_init[i * 5 + 2];
y = arrows[i * 5 + 3]; y = arrows_init[i * 5 + 3];
z = arrows[i * 5 + 4]; z = arrows_init[i * 5 + 4];
set_arrow (weight, site, x, y, z); // set_arrow (weight, site, x, y, z);
cube_coord = 12 * (stx * x + sty * y + stz * z); cube_coord = 12 * (stx * x + sty * y + stz * z);
arrow_offset = offset_after_grids + cube_coord; arrow_offset = offset_after_grids + cube_coord;
@ -820,7 +827,10 @@ void main_test_graphics (void)
difference, difference, difference / 12); difference, difference, difference / 12);
if (0) printf("main_test_graphics [ok]\n"); if (0) printf("main_test_graphics [ok]\n");
if (1) printf("\n Et maintenant, il faut distinguer les arrows-data des arrows-en-place\n\ if (1) printf("\n Et maintenant, il faut distinguer les arrows-data des arrows-en-place\n\
[to be] vs. [done]\n\n"); [to be] vs. [done]\n");
if (1) printf("\n Et donc... Les flèches sont dessinées dans main_test_graphics()\n\
et pas dans set_arrow (weight, site, x, y, z);\n\
(qui sert à quoi ? au fait ... ) \n\n");
} }