Ignore:
Timestamp:
Feb 4, 2016, 6:25:22 PM (9 years ago)
Author:
meunier
Message:
  • Ajout de quelques fonction dans la lib math
  • Déplacement de certaines fonctions de stdlib vers string
File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/applications/rosenfeld/src/ecc_generation.c

    r772 r777  
    5858    generate_granularity_density_float(X, i0, i1, j0, j1, granularity, (float) density, seed);
    5959}
    60 // ---------------------------------------------------------------------------------------------
    61 void generate_granularity_density_name(char *name, int granularity, int density, char *filename)
    62 // ---------------------------------------------------------------------------------------------
    63 {
    64     sprintf(filename, "%s_%02d_%03d.pgm", name, granularity, density);
    65 }
    66 // ------------------------------------------------------------------------------------------------------------------
    67 void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename)
    68 // ------------------------------------------------------------------------------------------------------------------
    69 {
    70     sprintf(filename, "%s_%02d_%03d.%s", name, granularity, density, extension);
    71 }
    72 // ------------------------------------------------------------------------------------------------------------
    73 void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename)
    74 // ------------------------------------------------------------------------------------------------------------
    75 {
    76     sprintf(filename, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
    77 }
    78 // ---------------------------------------------------------------------------------------------------------------------------------
    79 void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename)
    80 // ---------------------------------------------------------------------------------------------------------------------------------
    81 {
    82     sprintf(filename, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
    83 }
    84 // ---------------------------------------------------------------------------------------
    85 void generate_size_granularity_name(char *name, int size, int granularity, char *filename)
    86 // ---------------------------------------------------------------------------------------
    87 {
    88     sprintf(filename, "%s_%d_%02d.pgm", name, size, granularity);
    89 }// ------------------------------------------------------------------------------
    90 void generate_name100(char *name, int granularity, float density, char *filename)
    91 // ------------------------------------------------------------------------------
     60// ---------------------------------------------------------------------------------------------------------
     61void generate_granularity_density_name(char *name, int granularity, int density, char *filename, int maxlen)
     62// ---------------------------------------------------------------------------------------------------------
     63{
     64    snprintf(filename, maxlen, "%s_%02d_%03d.pgm", name, granularity, density);
     65}
     66// ------------------------------------------------------------------------------------------------------------------------------
     67void generate_granularity_density_ext_name(char *name, int granularity, int density, char *extension, char *filename, int maxlen)
     68// ------------------------------------------------------------------------------------------------------------------------------
     69{
     70    snprintf(filename, maxlen, "%s_%02d_%03d.%s", name, granularity, density, extension);
     71}
     72// ------------------------------------------------------------------------------------------------------------------------
     73void generate_size_granularity_density_name(char *name, int size, int granularity, int density, char *filename, int maxlen)
     74// ------------------------------------------------------------------------------------------------------------------------
     75{
     76    snprintf(filename, maxlen, "%s_%d_%02d_%03d.pgm", name, size, granularity, density);
     77}
     78// ---------------------------------------------------------------------------------------------------------------------------------------------
     79void generate_size_granularity_density_ext_name(char *name, int size, int granularity, int density, char *extension, char *filename, int maxlen)
     80// ---------------------------------------------------------------------------------------------------------------------------------------------
     81{
     82    snprintf(filename, maxlen, "%s_%d_%02d_%03d.%s", name, size, granularity, density, extension);
     83}
     84// ---------------------------------------------------------------------------------------------------
     85void generate_size_granularity_name(char *name, int size, int granularity, char *filename, int maxlen)
     86// ---------------------------------------------------------------------------------------------------
     87{
     88    snprintf(filename, maxlen, "%s_%d_%02d.pgm", name, size, granularity);
     89}// -----------------------------------------------------------------------------------------
     90void generate_name100(char *name, int granularity, float density, char *filename, int maxlen)
     91// ------------------------------------------------------------------------------------------
    9292{
    9393    // density en pourcentage: 0:100
    9494    // mais aussi <1, par exe 0.01
    9595    int d = (int) ceil(100 * density);
    96     sprintf(filename, "%s_%02d_%05d.pgm", name, granularity, d);
     96    snprintf(filename, maxlen, "%s_%02d_%05d.pgm", name, granularity, d);
    9797}
    9898// ----------------------------------------
     
    128128        for(d=dmin; d<=dmax; d+=dstep) {
    129129            generate_granularity_density_int(X, 0, n-1, 0, n-1, g, d, seed);
    130             generate_granularity_density_name("I", g, d, filename);
     130            generate_granularity_density_name("I", g, d, filename, 32);
    131131            printf(filename);
    132132            bin2gray_ui8matrix(X, 0, n-1, 0, n-1, X255);
     
    256256    X255 = ui8matrix(0, h-1, 0, w-1);
    257257   
    258     sprintf(filename, "spirale_simple_%d.pgm", n);
     258    snprintf(filename, 128, "spirale_simple_%d.pgm", n);
    259259    spirale_simple(X, h, w);
    260260    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
    261261    SavePGM_ui8matrix(X255, 0, h-1, 0, w-1, filename);
    262262   
    263     sprintf(filename, "spirale_double_%d.pgm", n);
     263    snprintf(filename, 128, "spirale_double_%d.pgm", n);
    264264    spirale_double(X, h, w);
    265265    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
     
    306306
    307307    generate_granularity_density_float(X, 0, h-1, 0, w-1, g, d, seed);
    308     generate_granularity_density_name("HGH", g, d, filename);
     308    generate_granularity_density_name("HGH", g, d, filename, 32);
    309309    printf(filename);
    310310    bin2gray_ui8matrix(X,   0, h-1, 0, w-1, X255);
Note: See TracChangeset for help on using the changeset viewer.