WIP: version robuste dessine la grille 3D redondances minimales (arêtes espace * 1/2)

This commit is contained in:
Jean Sirmai 2023-07-27 22:50:37 +02:00
parent 3a29f20df7
commit 3d0d739493
Signed by: jean
GPG Key ID: FB3115C340E057E3
14 changed files with 132 additions and 96 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

BIN
4 x 3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

BIN
5 x 3.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

BIN
5 x 4.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

View File

@ -343,128 +343,94 @@ static bool compute_space_3D (long x,
if (P) printf("\n"); if (P) printf("\n");
}; };
long step_z = 1, step_y = z, step_x = y * z, calcul = 0; long step_z = 1, step_y = z, step_x = y * z;
printf("[%ldx%ld=%ld]+[%ldx%ld=%ld]+[%ldx%ld=%ld] = %ld lines [%ldx%ldx%ld] = %ld vertices step_x = %ld step_y = %ld step_z = %ld ",\ printf("[%ldx%ld=%ld]+[%ldx%ld=%ld]+[%ldx%ld=%ld] = %ld lines [%ldx%ldx%ld] = %ld vertices step_x = %ld step_y = %ld step_z = %ld ",\
x,y,x*y, x,z,x*z, y,z,y*z, x*y + x*z + y*z, x,y,z, x*y*z, step_x, step_y, step_z); x,y,x*y, x,z,x*z, y,z,y*z, x*y + x*z + y*z, x,y,z, x*y*z, step_x, step_y, step_z);
for (int u = 0; u < z; u ++){ /* for (int u = 0; u < z; u ++){ */
for (int w = 0; w < x; w ++){ /* for (int w = 0; w < x; w ++){ */
calcul = step_x * w + step_z * u; /* calcul = step_x * w + step_z * u; */
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
*(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size ++; */
} /* } */
} /* } */
for (int u = 0; u < y; u ++){ /* for (int u = 0; u < y; u ++){ */
for (int w = 0; w < x; w ++){ /* for (int w = 0; w < x; w ++){ */
calcul = step_x * w + step_y * u; /* calcul = step_x * w + step_y * u; */
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
*(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul + step_y - step_z; lines_buffer_size ++; */
// printf("(%ld>%ld) ", calcul, calcul + step_y - 1); /* // printf("(%ld>%ld) ", calcul, calcul + step_y - 1); */
} /* } */
} /* } */
for (int u = 0; u < z; u ++){ /* for (int u = 0; u < z; u ++){ */
for (int w = 0; w < y; w ++){ /* for (int w = 0; w < y; w ++){ */
calcul = step_y * w + step_z * u; /* calcul = step_y * w + step_y * u; */
*(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
*(lines_origin + lines_buffer_size) = calcul + step_x * (x - 1); lines_buffer_size += 1; /* *(lines_origin + lines_buffer_size) = calcul + step_x * (x - 1); lines_buffer_size ++; */
} /* } */
} /* } */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 0; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 0; lines_buffer_size ++; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 2; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 2; lines_buffer_size ++; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 0; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 0; lines_buffer_size ++; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 2; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 2; lines_buffer_size ++; */
//------------------------------------------------ //------------------------------------------------
/* for (int u = 0; u < x; u ++){ */ /* for (int u = 0; u < x; u ++){ */
/* for (int w = 0; w < z; w ++){ */ /* for (int w = 0; w < z; w ++){ */
/* calcul = step_z * w + step_x * u; */ /* calcul = step_z * w + step_x * u; */
/* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = calcul; lines_buffer_size ++; */
/* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = calcul + step_x - step_y; lines_buffer_size ++; */
/* } */ /* } */
/* } */ /* } */
/* for (int u = 0; u < x; u ++){ */ /* for (int u = 0; u < x; u ++){ */
/* for (int w = 0; w < z; w ++){ */ /* for (int w = 0; w < z; w ++){ */
/* *(lines_origin + lines_buffer_size) = z * y * u + w; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = z * y * u + w; lines_buffer_size ++; */
/* *(lines_origin + lines_buffer_size) = z * y * u + z * y - z + w; lines_buffer_size += 1; */ /* *(lines_origin + lines_buffer_size) = z * y * u + z * y - z + w; lines_buffer_size ++; */
/* } */ /* } */
/* } */ /* } */
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * (x - 1); lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * 0 + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */ *(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * (y - 1) + step_x * 0; lines_buffer_size ++;
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 4; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 2 + step_y * 2 + step_x * 3; lines_buffer_size += 1; */
/* *(lines_origin + lines_buffer_size) = step_z * 1 + step_y * 3 + step_x * 4; lines_buffer_size += 1; */
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * 0; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * (z - 1) + step_y * 0 + step_x * (x - 1); lines_buffer_size ++;
//if (S3) printf("space 3D buffer_lines (from-to) "); //if (S3) printf("space 3D buffer_lines (from-to) ");
printf("<---> nb lines / nb vertex = %ld/%ld\n", lines_buffer_size / 2, vertex_buffer_size / 3); printf("<---> nb lines / nb vertex = %ld/%ld\n", lines_buffer_size / 2, vertex_buffer_size / 3);
@ -482,7 +448,66 @@ static bool compute_space_3D (long x,
static void draw_a_cube_at(long u, long v, long w,
GLuint *lines_origin,
long size_x,
long size_y,
long size_z,
bool diagonals){
long step_z = 1, step_y = size_z, step_x = size_y * size_z, x = u + 1, y = v + 1, z = w + 1;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
if (diagonals){
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * x; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * z + step_y * v + step_x * u; lines_buffer_size ++;
*(lines_origin + lines_buffer_size) = step_z * w + step_y * y + step_x * x; lines_buffer_size ++;
}
}
@ -671,6 +696,14 @@ bool compute_space_and_arrows(long model_size_x,
pref_style_lines_planes, pref_style_lines_planes,
pref_style_mix_colors); pref_style_mix_colors);
for (long i = 0; i < model_size_x - 1; i++)
for (long j = 0; j < model_size_y - 1; j++)
for (long k = 0; k < model_size_z - 1; k++)
if ((i + j + k) % 2 == 0) draw_a_cube_at (i, j, k,
lines_origin,
model_size_x, model_size_y, model_size_z,
0); // < set to 1 to see the diagonals
compute_space_3D (model_size_x, compute_space_3D (model_size_x,
model_size_y, model_size_y,
model_size_z, model_size_z,

View File

@ -576,9 +576,9 @@ GLuint arrows[] = {
static void get_model_data_and_user_preferences(){ static void get_model_data_and_user_preferences(){
model_space_size_x = 3; // 0 < model_space_size_x model_space_size_x = 16; // 0 < model_space_size_x
model_space_size_y = 3; // 0 < model_space_size_y model_space_size_y = 15; // 0 < model_space_size_y
model_space_size_z = 3; // 0 < model_space_size_z model_space_size_z = 14; // 0 < model_space_size_z
// XXX ONLY space drawed, no arrows // XXX ONLY space drawed, no arrows
model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint model_arrows_nb = 0; // assert : l'emplacement des flèches est contraint
@ -636,12 +636,15 @@ static void compute_buffers_sizes(int model_space_size_x,
// XXX drawing matrix lines ONLY // XXX drawing matrix lines ONLY
// one line per intersection between dimension // one line per intersection between dimension
int invraisemblable_ce_truc = model_space_size_y * 2;
int qq_chose_ad_hoc = model_space_size_x * model_space_size_y;
buffer_lines_size = ((model_space_size_x+1) * (model_space_size_y+1)) buffer_lines_size = ((model_space_size_x+1) * (model_space_size_y+1))
+ ((model_space_size_x+1) * (model_space_size_z+1)) + ((model_space_size_x+1) * (model_space_size_z+1))
+ ((model_space_size_y+1) * (model_space_size_z+1)) + ((model_space_size_y+1) * (model_space_size_z+1));
+ qq_chose_ad_hoc - invraisemblable_ce_truc;
long ad_hoc_bien_sur = 10000000;
buffer_lines_size = ((model_space_size_x+1)
* (model_space_size_y+1)
* (model_space_size_z+1)) * 8 + ad_hoc_bien_sur;
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,\
%4d/2 = %3d lines, %4d/3 = %3d plans.\n", %4d/2 = %3d lines, %4d/3 = %3d plans.\n",
buffer_vertex_size, buffer_vertex_size / 3, buffer_vertex_size, buffer_vertex_size / 3,