}
-__global__ void genere_snake_rectangle_Nnodes_gpu(snake_node_gpu * d_snake, int dist_bords, int i_dim, int j_dim){
- int nb_node_seg = 9 ;
- int limite = 64 ;
-
- int i , h= i_dim-2*dist_bords, l= j_dim-2*dist_bords ;
- int inch = h/(nb_node_seg+1), incl= l/(nb_node_seg+1) ;
- if (threadIdx.x == 0){
- int n = 0;
- /* n0 */
- d_snake[n].posi = dist_bords ;
- d_snake[n].posj = dist_bords ;
- n++ ;
- /*entre sommet 0 et 1*/
- i = 0 ;
- while (i < nb_node_seg)
- {
- if ( (d_snake[n-1].posi + inch)-(i_dim - dist_bords) > limite )
- d_snake[n].posi = d_snake[n-1].posi + inch ;
- else
- d_snake[n].posi = d_snake[n-1].posi + inch/2 ;
- d_snake[n].posj = dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n].posi - d_snake[n-1].posi ;
- n++ ; i++ ;
- }
- /* n1 */
- d_snake[n].posi = i_dim - dist_bords ;
- d_snake[n].posj = dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n].posi - d_snake[n-1].posi ;
- n++ ;
- /*entre S1 et S2*/
- i = 0 ;
- while (i< nb_node_seg)
- {
- if ( (j_dim - dist_bords) - (d_snake[n-1].posj + incl) > limite )
- d_snake[n].posj = d_snake[n-1].posj + incl ;
- else
- d_snake[n].posj = d_snake[n-1].posj + incl/2 ;
- d_snake[n].posi = i_dim - dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n].posj - d_snake[n-1].posj ;
- n++ ; i++ ;
- }
- /* n2 */
- d_snake[n].posi = i_dim - dist_bords ;
- d_snake[n].posj = j_dim - dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n].posj - d_snake[n-1].posj ;
- n++ ;
- /*entre S2 et S3*/
- i = 0 ;
- while (i< nb_node_seg)
- {
- if ( (d_snake[n-1].posi - inch) - dist_bords > limite )
- d_snake[n].posi = d_snake[n-1].posi - inch ;
- else
- d_snake[n].posi = d_snake[n-1].posi - inch/2 ;
- d_snake[n].posj = j_dim - dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n-1].posi - d_snake[n].posi ;
- n++ ; i++ ;
- }
- /* n3 */
- d_snake[n].posi = dist_bords ;
- d_snake[n].posj = j_dim - dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n-1].posi - d_snake[n].posi ;
- n++ ;
- /*entre S3 et S0*/
- i = 0 ;
- while (i< nb_node_seg)
- {
- if ( (d_snake[n-1].posj - incl) - dist_bords > limite)
- d_snake[n].posj = d_snake[n-1].posj - incl ;
- else
- d_snake[n].posj = d_snake[n-1].posj - incl/2 ;
- d_snake[n].posi = dist_bords ;
- d_snake[n-1].nb_pixels = d_snake[n-1].posj - d_snake[n].posj ;
- n++ ; i++ ;
- }
- d_snake[n-1].nb_pixels = d_snake[n-1].posj - d_snake[0].posj ;
- for (i=0; i<n; i++)
- {
- d_snake[i].freeman_in = 0;
- d_snake[i].freeman_out = 0;
- d_snake[i].centre_i = 0;
- d_snake[i].centre_j = 0;
- d_snake[i].last_move = 1;
- d_snake[i].code_segment = 0;
-
- }
- }
-}
-
__global__ void calcul_contribs_segments_snake(snake_node_gpu * d_snake, int nb_nodes,
t_cumul_x * cumul_x, t_cumul_x2 * cumul_x2,
int l, uint2 * liste_pix, t_sum_x2 * gsombloc, int * d_table_freeman)