OK indépendance space (2D/3D) and arrows (2D/3D). ROBUST (5 parameters)

This commit is contained in:
Jean Sirmai 2023-07-05 11:35:31 +02:00
parent 438b83a173
commit d3c84a635b
Signed by: jean
GPG Key ID: FB3115C340E057E3
2 changed files with 57 additions and 48 deletions

View File

@ -54,9 +54,10 @@ int plans_ndx = 0;
#define S 0 #define S 0
#define S3 0 #define S3 0
#define SA 1 #define SA 1
#define A3 0
#define L 1 #define L 0
#define V 1 #define V 0
#define C 0 #define C 0
#define P 0 #define P 0
@ -420,7 +421,6 @@ static bool compute_space_3D (int space_size_x,
return 1; return 1;
} }
#define A3 1
static bool compute_arrow_3D(int space_size_x, static bool compute_arrow_3D(int space_size_x,
int space_size_y, int space_size_y,
int space_size_z, int space_size_z,
@ -472,52 +472,50 @@ static bool compute_arrow_3D(int space_size_x,
if (pref_style_lines_planes == 0) { if (pref_style_lines_planes == 0) {
*(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 5;//+ 0; *(line_origin + lines_ndx + 0) = vertex_ndx / 3 - 5;
*(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 4;//+ 1; *(line_origin + lines_ndx + 1) = vertex_ndx / 3 - 4;
*(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 5;//+ 0; *(line_origin + lines_ndx + 2) = vertex_ndx / 3 - 5;
*(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 3;//+ 2; *(line_origin + lines_ndx + 3) = vertex_ndx / 3 - 3;
/* *(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 5;// + 0; */ *(line_origin + lines_ndx + 4) = vertex_ndx / 3 - 5;
/* *(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 2;// + 3; */ *(line_origin + lines_ndx + 5) = vertex_ndx / 3 - 2;
/* *(line_origin + lines_ndx + 6) = vertex_ndx / 3 - 5;// + 0; */ *(line_origin + lines_ndx + 6) = vertex_ndx / 3 - 5;
/* *(line_origin + lines_ndx + 7) = vertex_ndx / 3 - 1;// + 4; */ *(line_origin + lines_ndx + 7) = vertex_ndx / 3 - 1;
/* *(line_origin + lines_ndx + 8) = vertex_ndx / 3 - 4;// + 1; */ *(line_origin + lines_ndx + 8) = vertex_ndx / 3 - 4;
/* *(line_origin + lines_ndx + 9) = vertex_ndx / 3 - 3;// + 2; */ *(line_origin + lines_ndx + 9) = vertex_ndx / 3 - 3;
/* *(line_origin + lines_ndx + 10) = vertex_ndx / 3 - 3;// + 2; */ *(line_origin + lines_ndx + 10) = vertex_ndx / 3 - 3;
/* *(line_origin + lines_ndx + 11) = vertex_ndx / 3 - 2;// + 3; */ *(line_origin + lines_ndx + 11) = vertex_ndx / 3 - 2;
/* *(line_origin + lines_ndx + 12) = vertex_ndx / 3 - 2;// + 3; */ *(line_origin + lines_ndx + 12) = vertex_ndx / 3 - 2;
/* *(line_origin + lines_ndx + 13) = vertex_ndx / 3 - 1;// + 4; */ *(line_origin + lines_ndx + 13) = vertex_ndx / 3 - 1;
/* *(line_origin + lines_ndx + 14) = vertex_ndx / 3 - 1;// + 4; */ *(line_origin + lines_ndx + 14) = vertex_ndx / 3 - 1;
/* *(line_origin + lines_ndx + 15) = vertex_ndx / 3 - 4;// + 1; */ *(line_origin + lines_ndx + 15) = vertex_ndx / 3 - 4;
lines_ndx += 16; if (L) printf("|=> lines_ndx = %3d arrow_3D\n", lines_ndx); lines_ndx += 16; if (L) printf("|=> lines_ndx = %3d arrow_3D\n", lines_ndx);
} }
if (pref_style_lines_planes == 1) { if (pref_style_lines_planes == 1) {
int pgap = 0; // ?? TODO (REMOVE) *(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0;
*(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1;
*(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 2;
*(plan_origin + pgap + 0) = space_size_x * 12 / 3 + 0; *(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0;
*(plan_origin + pgap + 1) = space_size_x * 12 / 3 + 1; *(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 3;
*(plan_origin + pgap + 2) = space_size_x * 12 / 3 + 2; *(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4;
*(plan_origin + pgap + 3) = space_size_x * 12 / 3 + 0; *(plan_origin + plans_ndx + 0) = space_size_x * 12 / 3 + 0;
*(plan_origin + pgap + 4) = space_size_x * 12 / 3 + 3; *(plan_origin + plans_ndx + 1) = space_size_x * 12 / 3 + 1;
*(plan_origin + pgap + 5) = space_size_x * 12 / 3 + 4; *(plan_origin + plans_ndx + 2) = space_size_x * 12 / 3 + 3;
*(plan_origin + pgap + 0) = space_size_x * 12 / 3 + 0; *(plan_origin + plans_ndx + 3) = space_size_x * 12 / 3 + 0;
*(plan_origin + pgap + 1) = space_size_x * 12 / 3 + 1; *(plan_origin + plans_ndx + 4) = space_size_x * 12 / 3 + 2;
*(plan_origin + pgap + 2) = space_size_x * 12 / 3 + 3; *(plan_origin + plans_ndx + 5) = space_size_x * 12 / 3 + 4;
*(plan_origin + pgap + 3) = space_size_x * 12 / 3 + 0;
*(plan_origin + pgap + 4) = space_size_x * 12 / 3 + 2;
*(plan_origin + pgap + 5) = space_size_x * 12 / 3 + 4;
plans_ndx += 12; if (P) printf("|=> plans_ndx = %3d arrow_3D\n", plans_ndx); plans_ndx += 12; if (P) printf("|=> plans_ndx = %3d arrow_3D\n", plans_ndx);
} }
@ -552,8 +550,8 @@ static void show_user_choices(int model_space_size_x,
if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes); if (pref_style_lines_planes > 0)printf("style_lines_planes = %d ", pref_style_lines_planes);
if (! pref_style_mix_colors) printf("style_mix_colors = 0 "); if (! pref_style_mix_colors) printf("style_mix_colors = 0 ");
if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors); if (pref_style_mix_colors > 0) printf("style_mix_colors = %d ", pref_style_mix_colors);
printf("\n[ n] load site x ---- < arrows array >\ if (model_arrows_nb > 0) printf("\n[ n] load site x ---- < arrows array >\
----------------------------------------------------------------------\n"); ---------------------------------------------------------------------\n");
// arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 } // arrows = { 1, 1, 0, 1, 2, 1, 1, 1, 10, 1, 2, 11, 1, 1, 20, 1, 2, 21 }
if (SA) for (int i = 0; i < model_arrows_nb; i++) if (SA) for (int i = 0; i < model_arrows_nb; i++)
printf("[%2d] = %2d, %2d, %2d \n",\ printf("[%2d] = %2d, %2d, %2d \n",\
@ -626,7 +624,7 @@ bool compute_space_and_arrows(int model_space_size_x,
model_space_size_y, model_space_size_y,
model_space_size_z, model_space_size_z,
*(arrows + i * 3 + 0), // weight *(arrows + i * 3 + 0), // weight (load)
*(arrows + i * 3 + 1), // site *(arrows + i * 3 + 1), // site
*(arrows + i * 3 + 2), // x *(arrows + i * 3 + 2), // x
0, // y 0, // y
@ -645,7 +643,7 @@ bool compute_space_and_arrows(int model_space_size_x,
model_space_size_y, model_space_size_y,
model_space_size_z, model_space_size_z,
*(arrows + i * 3 + 0), // weight *(arrows + i * 3 + 0), // weight (load)
*(arrows + i * 3 + 1), // site *(arrows + i * 3 + 1), // site
*(arrows + i * 3 + 2), // x *(arrows + i * 3 + 2), // x
0, // y 0, // y

View File

@ -527,11 +527,11 @@ GLubyte arrows[] = { 1, 1, 0, 1, 0, 1, 1, 1, 4, 1, 0, 5, 1, 1, 8, 1, 0, 9
static void get_model_data_and_user_preferences(){ static void get_model_data_and_user_preferences(){
model_space_size_x = 11; // 2 < model_space_size_x < 32 model_space_size_x = 11; // 2 < model_space_size_x < 32
model_arrows_nb = 1; // assert : l'emplacement des flèches est contraint model_arrows_nb = 6; // 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
pref_3D_xor_2D_space = 1; // 0 = 3D 1 = 2D pref_3D_xor_2D_space = 0; // 0 = 3D 1 = 2D
pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D pref_3D_xor_2D_arrows = 0; // 0 = 3D 1 = 2D
pref_mark_unit_space = 2; // 0 = no marks, 1 = 1st, 2 = last, 3 = both pref_mark_unit_space = 3; // 0 = no marks, 1 = 1st, 2 = last, 3 = both
pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix pref_style_lines_planes = 0; // 0 = arrows as lines, 1 = as planes, 2 = mix
pref_style_mix_colors = 0; // TODO pref_style_mix_colors = 0; // TODO
} }
@ -573,24 +573,35 @@ static void compute_buffers_sizes(int model_space_size_x,
int two_ladder_amounts = 4; // 2 parallels to connect 4 vertices int two_ladder_amounts = 4; // 2 parallels to connect 4 vertices
if (pref_3D_xor_2D_space) { // 2D the ladder has 2 amounts if (pref_3D_xor_2D_space) { // 2D the ladder has 2 amounts
buffer_vertex_size = model_space_size_x * 6 + model_arrows_nb * 9; buffer_vertex_size = model_space_size_x * 6;
buffer_colors_size = model_space_size_x * 6 + model_arrows_nb * 9; buffer_colors_size = model_space_size_x * 6;
buffer_plans_size = 0; buffer_plans_size = 0;
buffer_lines_size = model_space_size_x * 2 + model_arrows_nb * 6 buffer_lines_size = model_space_size_x * 2 + two_ladder_amounts;
+ two_ladder_amounts;
} else { // 3D the ladder has 4 amounts, now } else { // 3D the ladder has 4 amounts, now
buffer_vertex_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15; buffer_vertex_size = (model_space_size_x + 1) * 12;
buffer_colors_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15; buffer_colors_size = (model_space_size_x + 1) * 12;
buffer_plans_size = 0; buffer_plans_size = 0;
buffer_lines_size = (model_space_size_x + 1) * 12 + model_arrows_nb * 15 buffer_lines_size = (model_space_size_x + 1) * 12 + 2 * two_ladder_amounts;
+ 2 * two_ladder_amounts;
} }
/* Increment in buffer_lines_size is the same for 2D & 3D */ /* Increment in buffer_lines_size is the same for 2D & 3D */
if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines if (pref_mark_unit_space == 1 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines if (pref_mark_unit_space == 2 || pref_mark_unit_space == 3) buffer_lines_size += 4; // 2 diagonal lines
if (pref_3D_xor_2D_arrows) { // 2D
buffer_vertex_size += model_arrows_nb * 9;
buffer_colors_size += model_arrows_nb * 9;
buffer_plans_size += 0;
buffer_lines_size += model_arrows_nb * 6;
} else { // 3D
buffer_vertex_size += model_arrows_nb * 15;
buffer_colors_size += model_arrows_nb * 15;
buffer_plans_size += 0;
buffer_lines_size += model_arrows_nb * 16;
}
/* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */ /* buffer_plans_size est fonction de : model_space_size_x, model_arrows_nb et de pref_style_lines_planes */
if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\ if (S) printf("allocated buffers sizes :%4d/3 = %3d vertices, %4d/3 = %3d colors,\