Dessin 'économe' (espace et flèches) OK pour de petits nombres (avant nettoyage)

This commit is contained in:
Jean Sirmai 2023-10-16 09:48:12 +02:00
parent 9347d71dd8
commit 98c22b4fb6
Signed by: jean
GPG Key ID: FB3115C340E057E3
5 changed files with 41 additions and 39 deletions

View File

@ -89,7 +89,7 @@ void write_arrow_lines_south_north (long s, int weight, int site);
*/ */
void arrows_write_basis (long n); void arrows_write_basis (long n);
void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines,
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);

View File

@ -27,9 +27,9 @@
#include <stdbool.h> #include <stdbool.h>
#include <GL/glu.h> #include <GL/glu.h>
void write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z); int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z);
void 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 (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style);
/* /*
* Writes grid lines intersections to vertex and color buffers * Writes grid lines intersections to vertex and color buffers

View File

@ -167,7 +167,7 @@ void arrows_write_basis(long offset)
/******************************************************************************/ /******************************************************************************/
void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines, int write_one_arrow(int offset_vertex, int offset_colors, int offset_lines,
int space_X_int, int space_Y_int, int space_Z_int, 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)
{ {
@ -248,7 +248,7 @@ void write_one_arrow(int offset_vertex, int offset_colors, int offset_lines,
default: break; default: break;
} }
/* offset_lines += 4; // inutile... */ return 12;
} }

View File

@ -152,8 +152,6 @@ void graphics_write_vertex (GLfloat x, GLfloat y, GLfloat z)
buffer_vertex_origin[buffer_vertex_size + 2] = z; buffer_vertex_origin[buffer_vertex_size + 2] = z;
buffer_vertex_size += 3; buffer_vertex_size += 3;
printf("new vertex : (%9.6f, %9.6f, %9.6f) <> buffer size : %3d\n", x,y,z, buffer_vertex_size);
} }
/* /*
@ -599,8 +597,8 @@ static void show_user_choices(struct arrow_t *arrows, int arrows_nb,
printf("\n"); printf("\n");
if (show_all) printf("\n\ if (show_all) printf("\
initial arrows data with arrows_nb = %d", arrows_nb); initial arrows data with arrows_nb = %d\n", arrows_nb);
if (show_array) show_arrows_array (arrows, arrows_nb); if (show_array) show_arrows_array (arrows, arrows_nb);
} }
@ -875,30 +873,19 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
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 = 7; int arbitrary = 10;
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 specif_arrows_nb = 1;//rand() % density_max;
int arrows_nb = 0;
int pref_show_grids = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc int pref_show_grids = 1; // 0, 1, 2, 3, 5, 6, 10, 15, 30, etc
// xyz, 0, x, y, z, xy, xz, yz, xyz // xyz, 0, x, y, z, xy, xz, yz, xyz
int weight = 0, site = 0, x = 0, y = 0, z = 0;// stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0; int weight = 0, site = 0, x = 0, y = 0, z = 0;// stx = space_Z * space_Y, sty = space_Z, stz = 1, arrow_offset = 0;
int style = 0; int style = 0;
show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 0, 0, style); int specif_arrows_nb = rand() % density_max / 3;
int arrows_nb = 0;
int offset_vertex = 0, offset_colors = 0, offset_lines = 0; // if this function is called first
write_space_ridges (offset_vertex, offset_colors, offset_lines, space_X, space_Y, space_Z);
offset_vertex = 8, offset_colors = 8, offset_lines = 12; // if space edges are drawn
write_grids_on_space_faces (offset_vertex, offset_colors, offset_lines,
space_X, space_Y, space_Z, style);
/* ARROWS */
while (arrows_nb < specif_arrows_nb){ while (arrows_nb < specif_arrows_nb){
arrows_nb = set_arrow (arrows, arrows_nb, arrows_nb = set_arrow (arrows, arrows_nb,
@ -908,12 +895,21 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
rand() % space_Y, // y rand() % space_Y, // y
rand() % space_Z); // z rand() % space_Z); // z
} }
show_arrows_array (arrows, arrows_nb);
offset_vertex += (space_X + space_Y + space_Z - 3) * 4; show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 1, 0, style);
offset_colors += (space_X + space_Y + space_Z - 3) * 4; if (0) show_arrows_array (arrows, arrows_nb);
/* if (style) offset_lines += 2 * (space_X + space_Y + space_Z - 3); */
/* else offset_lines += 4 * (space_X + space_Y + space_Z - 3); */ /* DATA ARE NOW ALL SPECIFIED - DRAWING CAN START */
int offset_vertex = 0, offset_colors = 0, offset_lines = 0;
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, style);
offset_colors = offset_vertex;
/* ARROWS */
for (int i = 0; i < arrows_nb; i++) { for (int i = 0; i < arrows_nb; i++) {
weight = arrows[i].load; weight = arrows[i].load;
@ -922,18 +918,16 @@ void __attribute__((optimize("no-unroll-loops"))) main_test_graphics (void)
y = arrows[i].y; y = arrows[i].y;
z = arrows[i].z; z = arrows[i].z;
write_one_arrow(offset_vertex, offset_colors, offset_lines, offset_vertex += write_one_arrow(offset_vertex, offset_colors, offset_lines,
space_X, space_Y, space_Z, space_X, space_Y, space_Z,
weight, site, x, y, z); weight, site, x, y, z);
offset_colors = offset_vertex;
} }
show_user_choices(arrows, arrows_nb, space_X, space_Y, space_Z, pref_show_grids, 0, 0, style); free(arrows); // ? free (space)
free(arrows);
arrows = NULL; arrows = NULL;
arrows_nb = 0; arrows_nb = 0;
/* show_buffers_states(space_X, space_Y, space_Z, arrows_nb, */ /* show_buffers_states(space_X, space_Y, space_Z, arrows_nb, */
/* offset_after_grids, buffer_vertex_size, */ /* offset_after_grids, buffer_vertex_size, */
/* buffer_lines_size_after_cubes, buffer_lines_size); */ /* buffer_lines_size_after_cubes, buffer_lines_size); */

View File

@ -35,7 +35,7 @@
/* } */ /* } */
void write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z) int write_space_ridges (long offset_vertex, long offset_colors, long offset_lines, 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);
@ -66,9 +66,11 @@ void write_space_ridges (long offset_vertex, long offset_colors, long offset_lin
graphics_write_line ( 1, 4); graphics_write_line ( 2, 4); graphics_write_line ( 1, 4); graphics_write_line ( 2, 4);
graphics_write_line ( 1, 5); graphics_write_line ( 3, 5); graphics_write_line ( 1, 5); graphics_write_line ( 3, 5);
graphics_write_line ( 2, 6); graphics_write_line ( 3, 6); graphics_write_line ( 2, 6); graphics_write_line ( 3, 6);
return 8;
} }
void 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 (long offset_vertex, long offset_colors, long offset_lines, long x, long y, long z, int style)
{ {
float i, max = fmax(x, y); max = fmax(max, z); float i, max = fmax(x, y); max = fmax(max, z);
@ -148,6 +150,12 @@ void write_grids_on_space_faces (long offset_vertex, long offset_colors, long of
graphics_write_line (offset_vertex + i * 4 + 2, offset_vertex + i * 4 + 3); 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); graphics_write_line (offset_vertex + i * 4 + 3, offset_vertex + i * 4 + 0);
} }
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); */
} }