コード例 #1
0
ファイル: hata_cl.c プロジェクト: lichinka/cai
/*
 * Tests memory allocation on the GPU by reading raster data in and,
 * after transfering it to the device, read it back and creating an
 * output raster that should be identical to the input one.
 *
 * int nrows .............. the number of rows in the DEM.
 * int ncols .............. the number of columns in the DEM.
 * int infd ............... file descriptor to read from the DEM.
 * int outfd .............. file descriptor to write to an output raster.
 * RASTER_MAP_TYPE rtype .. DEM element data type.
 *
 */
void test_cl (const int nrows, const int ncols,
              const int infd, const int outfd,
              RASTER_MAP_TYPE rtype)
{
    int row, col;

    CONTEXT * ctx = init_context ( );

    /* load raster DEM data */
    FCELL *dem_device = load_raster (ctx, nrows, ncols, infd, rtype);

    G_message ("Transfering raster data to the device ...");

    clmsync (ctx, 0, dem_device, CL_MEM_DEVICE|CL_EVENT_WAIT);

    G_message ("Transfering data from the device to the host ...");

    clmsync (ctx, 0, dem_device, CL_MEM_HOST|CL_EVENT_WAIT);

    /* save raster data */
    save_raster (dem_device, nrows, ncols, outfd);

    /* free allocated resources */
    clfree (dem_device);
}
コード例 #2
0
ファイル: findiff.c プロジェクト: chadheyne/cuneiform-by
static Bool is_back_slash(cell *c)
 {
 puchar raster;
 int16_t l,i1,i2,i3,j1,j2,j3,k1,k2,k3;

 raster=save_raster(c);
 l=(c->w+7)/8;
 i1=MAX(2,c->h/8);
 for (j1=0; !(raster[i1*l+j1/8]&(128>>(j1%8))); j1++) ;
 if (j1>i1)
  return FALSE;
 i3=c->h-1-i1;
 for (k3=c->w-1; !(raster[i3*l+k3/8]&(128>>(k3%8))); k3--) ;
 if (c->w-1-k3>i1 || abs(c->w-k3-j1)>2)
  return FALSE;
 for (k1=j1+1; k1<c->w && raster[i1*l+k1/8]&(128>>(k1%8)); k1++) ;
 k1--;
 for (j3=k3-1; j3 && raster[i3*l+j3/8]&(128>>(j3%8)); j3--) ;
 j3++;
 i2=c->h/2;
 for (j2=0; !(raster[i2*l+j2/8]&(128>>(j2%8))); j2++) ;
 for (k2=j2+1; k2<c->w && raster[i2*l+k2/8]&(128>>(k2%8)); k2++) ;
 k2--;
 if (abs(k1-j1-(k3-j3))>2 || abs((j1+j3)/2-j2)>2 || abs((k1+k3)/2-k2)>2)
  return FALSE;
 if ((c->font|c->font_new)&c_fp_it && 4*NOMINCL*(j3-j1)>=DENOMINCL*(i3-i1) ||
     (c->font|c->font_new)&c_fp_str && 2*NOMINCL*(j3-j1)>=DENOMINCL*(i3-i1))
  return TRUE;
 return FALSE;
 }
コード例 #3
0
ファイル: hata_cl.c プロジェクト: lichinka/cai
/*
 * Saves raster data pointed by 'rastdata' to a raster map named 'name'.
 * It returns the sum of all elements in 'rastdata'.
 *
 * char *name ............. the name of the raster map to where save to.
 * void *rastdata ......... raster data to be saved.
 * int nrows .............. the number of rows in the raster data.
 * int ncols .............. the number of columns in the raster data.
 *
 */
FCELL save_raster_to_file (const char *name,
                          FCELL *rastdata,
                          const int nrows, const int ncols)
{
    FCELL ret_value = (FCELL) 0.0f;

    /* output file descriptor */
    int outfd = G_open_raster_new (name, FCELL_TYPE);

    if (outfd < 0)
    {
        G_fatal_error("Unable to create raster map <%s>", name);
    }
    else
    {
        ret_value = save_raster (rastdata, nrows, ncols, outfd);
        G_close_cell (outfd);
    }

    return ret_value;
}
コード例 #4
0
ファイル: findiff.c プロジェクト: chadheyne/cuneiform-by
static void final_AOU_2dot(cell *c)
 {
 puchar r;
 int16_t l,i,i1,j,j1,j2,j3,j4;
 uchar let,b;

 r=save_raster(c);
 let=c->vers[0].let;
 l=(c->w+7)/8;
 i=MAX(1,(bl.b1-c->row)/2);
 for (j1=0; !(r[i*l+j1/8]&(128>>(j1%8))); j1++) ;
 for (j2=j1+1; j2<c->w && r[i*l+j2/8]&(128>>(j2%8)); j2++) ;
 if (j2==c->w || let!='A' && 2*(j2-1)>=c->w)
  return;
 for (j3=j2; j3<c->w && !(r[i*l+j3/8]&(128>>(j3%8))); j3++) ;
 if (j3==c->w || let!='A' && 2*j3<=c->w)
  return;
 for (j4=j3+1; j4<c->w && r[i*l+j4/8]&(128>>(j4%8)); j4++) ;
 if (abs(j2-j1-(j4-j3))>=MAX(3,bl.ps/6) ||
     j3-j2+1<(j2-j1+j4-j3-2)/4)
  return;
 j=(j2+j3)/2;
 b=128>>(j%8);
 j/=8;
 for (i1=i; i1>=0; i1--)
  if (r[i1*l+j]&b)
   return;
 if (memchr("0O",let,2))
  {
  for (i1=i; i1<c->h/2 && !(r[i1*l+j]&b); i1++) ;
  let=(i1==c->h/2)?'U':'O';
  }
 if (let!='A')
  {
  i=bl.bm-c->row;
  for (j2=0; !(r[i*l+j2/8]&(128>>(j2%8))); j2++) ;
  for (j3=c->w-1; !(r[i*l+j3/8]&(128>>(j3%8))); j3--) ;
  if (j3-j2+1-(j4-j1)<=MAX(2,bl.ps/8) || j4-j1+1<(j3-j2+1)/2)
   return;
  }
コード例 #5
0
ファイル: findiff.c プロジェクト: chadheyne/cuneiform-by
static Bool is_slash(cell *c)
 {
 puchar raster;
 int16_t i1,i2,j1,j2,l;
 int16_t    ginc=erect_get_local();
 if( c->stick_inc==NO_INCLINE || c->stick_inc==0 )
    stick_center_study(c,NULL,1);
if( nIncline<256 && c->stick_inc>700 && (c->flg&c_f_solid))
    return TRUE;
if( c->stick_inc!=NO_INCLINE && ginc<400 && ginc*2<c->stick_inc )
    return TRUE;
 raster=save_raster(c);
 l=(c->w+7)/8;
 i1=c->h/4;
 for (j1=0; !(raster[i1*l+j1/8]&(128>>(j1%8))); j1++) ;
 i2=3*c->h/4;
 for (j2=0; !(raster[i2*l+j2/8]&(128>>(j2%8))); j2++) ;
 if ((c->font|c->font_new)&c_fp_it && NOMINCL*(j1-j2)>=DENOMINCL*(i2-i1) ||
     (c->font|c->font_new)&c_fp_str && 2*NOMINCL*(j1-j2)>=DENOMINCL*(i2-i1))
  return TRUE;
 return FALSE;
 }
コード例 #6
0
ファイル: diff.cpp プロジェクト: nctan/quneiform
//extern uchar pass_cut;
void criteria(cell *c)
{
    uchar let = 0, *raster = 0;
    cf::version *vers = 0;
    int16_t r = 0, flacc = 0, flon = 0, inc = 0;
    cf::version save[VERS_IN_CELL] = { 0 };
    int16_t snvers = 0;

    // #define PROB_V_OK 170
    if (c->nvers > 0)
        memcpy(save, c->vers, c->nvers);
    snvers = c->nvers;
    if (!c->nvers)
        return;
    get_b_lines(c, &bl);
    H = (int16_t) get_size();
    if (c->nvers == 1 && c->vers[0].let == '>')
        test_rq(c);
    if (c->nvers == 1 && ((let = c->vers[0].let) == 'c' || let == 'C') || (c->nvers == 2
            && (c->vers[0].let == 'c' && c->vers[1].let == 'C' || c->vers[0].let == 'C'
                    && c->vers[1].let == 'c')))
        test_c(c);
    if (c->nvers >= 2 && (c->vers[0].let == 'a' && c->vers[1].let == 'o' || c->vers[0].let == 'o'
            && c->vers[1].let == 'a'))
        crit_oa(c);
    for (vers = c->vers, flacc = flon = 0; (let = vers->let) != 0; vers++) {
        { //Andrew
            if ((let = vers->let) == liga_CC || let == liga_CR) {
                raster = save_raster(c);
                inc = AnglesCurve(raster, (int16_t) ((c->w + 7) / 8), c->h);
                inc = (4 - inc) * 40;
                if (3 * c ->w > 4 * c ->h)
                    inc += 150;
                if (3 * c ->w < 2 * c ->h)
                    inc += 150;

                if (c->env && c->env->nl < 4)
                    inc += 100;

                if (vers->prob > inc)
                    vers->prob -= inc;
                else
                    vers->prob = 0;
            }
        }

        if (((language == LANGUAGE_FRENCH || language == LANGUAGE_ITALIAN) && memchr(
                "ACEIOUaceiou", let, 12) || // Включая нижние акценты "c" 05.07.2002 E.P.
                language == LANGUAGE_SPANISH && memchr("AEINOUaeniou", let, 12) || language
                == LANGUAGE_GERMAN && memchr("AOUaou", let, 6) || language == LANGUAGE_RUSSIAN
                && memchr("Ґ…", let, 2) || language == LANGUAGE_CROATIAN
                && memchr("SZCszc", let, 6)
        /*&& !pass_cut*/|| language == LANGUAGE_POLISH && memchr("AESZCNOaeszcno", let, 14) || // Включая нижние акценты a,e 05.07.2002 E.P.
                language == LANGUAGE_PORTUGUESE && memchr("AEOUIaeoui", let, 10) || language
                == LANGUAGE_SWEDISH && memchr("AEOaeo", let, 6)) && !flacc ||

        // 05.09.2000 E.P.
                language == LANGUAGE_CZECH && memchr("AaCcDdEeIiNnOoRrSsTtUuYyZz", let, 26)
                || language == LANGUAGE_ROMANIAN && memchr("AaIiSsTt", let, 8) || // Включая нижние акценты s,t 05.07.2002 E.P.
                language == LANGUAGE_HUNGARIAN && memchr("AaEeIiOoUu", let, 10) || language
                == LANGUAGE_SLOVENIAN && memchr("CcSsZz", let, 6) ||

        // 09.07.2001 E.P.
                language == LANGUAGE_LATVIAN && memchr("AaCcEeGgIiKkLlNnSsUuZz", let, 22)
                || language == LANGUAGE_LITHUANIAN && memchr("AaCcEeIiSsUuZz", let, 14) || language
                == LANGUAGE_ESTONIAN && memchr("AaOoSsUuZz", let, 10) ||

        // 21.05.2002 E.P.
                language == LANGUAGE_TURKISH && (memchr("AaCcIiGgOoSsUu", let, 14) || let
                        == i_sans_accent) || 0) {
            flacc = 1;
            if (accent(c))
                break;
        }

        // Урезание чужих букв из общих таблиц
        if (language == LANGUAGE_POLISH && memchr("qQ", let, 2) ||

        // BULGAR 08.09.2000 E.P.
                language == LANGUAGE_RUSSIAN && langBul && (let == 155 || let == 235 || // Ыы 08.09.2000 E.P.
                        let == 157 || let == 237 || // Ээ 08.09.2000 E.P.
                        let == r_EE_2dot || let == r_e_2dot) ||

        language == LANGUAGE_SLOVENIAN && isnot_slovenian(let) ||

        // 09.07.2001 E.P.
                language == LANGUAGE_LATVIAN && isnot_latvian(let) || language
                == LANGUAGE_LITHUANIAN && isnot_lithuanian(let) || language == LANGUAGE_ESTONIAN
                && isnot_estonian(let) ||

        // 21.05.2002 E.P.
                language == LANGUAGE_TURKISH && isnot_turkish(let) || 0) {
            vers->prob >>= 1;
            if (vers->prob & 1)
                vers->prob--;
            if (!vers->prob)
                vers->prob = 2;
        }

        if (c->isBadLetter()) // Oleg : 02-28-96 04:55pm : letter only
            if (((let = vers->let) == 'i' || let == 'j' || (language == LANGUAGE_TURKISH && let
                    == II_dot_accent) // 17.06.2002 E.P.
            ) && (r = ij_dot(c)) != 0) {
                if (r > 0)
                    break;
                vers--;
                continue;
            }

        // Nick 18.06.2002
        if (language == LANGUAGE_TURKISH && ((let = vers->let) == i_sans_accent || let
                == II_dot_accent) && (r = upper_right_angle(c)) > 0) {
            vers->prob = MAX(2, vers->prob - r);
            continue;
        }

        if ((let = vers->let) == '!' || let == '?') {
            if (excl_dot(c) > 0)
                break;
            vers--;
            continue;
        }
        if (language != LANGUAGE_RUSSIAN) // refuse with  ,Ў
            if ((let = vers->let) == invers_exm || let == invers_qm) {
                if (inv_dot(c) > 0)
                    break;
                vers--;
                continue;
            }

        if ((language == LANGUAGE_FRENCH || language == LANGUAGE_TURKISH // 18.06.2002 E.P.
        ) && (vers->let == 'c' || vers->let == 'C'))
            c_to_ctail(c, 0); // AL 940321
        if (vers->let == liga_rt && not_rt(c)) {
            vers--;
            continue;
        }
        if (is_liga_ff(vers->let) && not_ff(c)) {
            vers--;
            continue;
        }

        if (vers->let == 'n' || vers->let == 'o')
            flon = 1;
    }
コード例 #7
0
ファイル: il1tgh.c プロジェクト: PauloMigAlmeida/cuneiform
static void comptorast (puchar raster, cell *C)
{
    memcpy (raster, save_raster (C), ((C -> w + 7)/8) * C -> h);
}
コード例 #8
0
ファイル: hata_cl.c プロジェクト: lichinka/cai
/*
 * Calculates the path loss matrix for many transmitters and saves the
 * output to one common raster map.
 *
 * int nrows .............. the number of rows in the DEM.
 * int ncols .............. the number of columns in the DEM.
 * int tx_coord_col ....... transmitter column coordinate (in raster cells).
 * int tx_coord_row ....... transmitter row coordinate (in raster cells).
 * int tx_elevation ....... transmitter height above sea level.
 * int anthena_height ..... height of transmitter anthena above ground.
 * float rx_height ........ receiver height above ground.
 * float frequency ........ transmitter frequency in Mhz.
 * int radius ............. calculation radius around to the transmitter
 *                          (in raster cells).
 * int infd ............... file descriptor to read from the DEM.
 * int outfd .............. file descriptor to write resulting raster.
 * RASTER_MAP_TYPE rtype .. DEM element data type.
 *
 */
void hata_cl (const int nrows, const int ncols,
              const int tx_coord_col, const int tx_coord_row,
              const int tx_elevation, const int tx_anthena_height,
              const float rx_height, const float frequency,
              const int radius,
              const int infd, const int outfd, 
              RASTER_MAP_TYPE rtype)
{
    int i;

    /* number of processing tiles needed around each transmitter */
    int ntile = (radius*2) / _HATA_WITEM_PER_DIM_ + 1;

    G_message ("Receiver height above ground is %5.2f mts", rx_height);
    G_message ("Transmitter frequency is %7.2f Mhz", frequency);
    G_message ("Calculation radius is %d raster cells", radius);

    CONTEXT * ctx = init_context ( );

    /* initialize raster data */
    void *dem_in = load_raster (ctx, nrows, ncols, infd, rtype);
    void *dem_out = null_raster (ctx, nrows, ncols, rtype, NULL);

    /* load, compile and link the OpenCL kernel file */
    void* h = clopen (ctx, NULL, CLLD_NOW);
    /* select a kernel function from the loaded file */
    cl_kernel krn = clsym (ctx, h, "hata_urban_kern", CLLD_NOW);

    /* defines a 2D matrix of work groups & work items */
    size_t global_wsize = ntile * _HATA_WITEM_PER_DIM_;
    size_t local_wsize = _HATA_WITEM_PER_DIM_;

    if ((global_wsize % local_wsize) != 0)
        G_fatal_error ("Work group dimensions are incorrect.");
    else
        G_message ("Creating %d work-group(s) of [%d x %d] threads each", 
                   global_wsize/local_wsize,
                   local_wsize, local_wsize);

    clndrange_t ndr = clndrange_init2d (0,global_wsize,local_wsize, 
                                        0,global_wsize,local_wsize);

    // correction factor ahr
    float ahr = (1.1f*log10(frequency) - 0.7f)*rx_height - 
                (1.56f*log10(frequency) - 0.8f);

    /* set kernel parameters and local memory size */
    clarg_set (ctx, krn, 0, ncols);
    clarg_set (ctx, krn, 3, rx_height);
    clarg_set (ctx, krn, 4, frequency);
    clarg_set (ctx, krn, 5, ahr);

    size_t lmem_size = _HATA_WITEM_PER_DIM_*_HATA_WITEM_PER_DIM_*
                       sizeof(cl_float2);

    if (lmem_size > _HATA_MAX_LOCAL_MEM_)
        G_fatal_error ("Allocated local memory (%d) exceeds %d bytes.", lmem_size,
                                                                        _HATA_MAX_LOCAL_MEM_);

    clarg_set_local (ctx, krn, 8, lmem_size);

    /* transfer data to the device */
    clmsync (ctx, 0, dem_in, CL_MEM_DEVICE|CL_EVENT_NOWAIT);
    clmsync (ctx, 0, dem_out, CL_MEM_DEVICE|CL_EVENT_NOWAIT);

    /* set remaining kernel parameters */
    clarg_set_global (ctx, krn, 6, dem_in);
    clarg_set_global (ctx, krn, 7, dem_out);

    G_message ("Simulating ...");

    /* test transmitters

         ASNEBE | 1468 | 1200
         ASKZK  | 1395 | 1180
         ASPAR  | 1400 | 1245
         ASMARG | 1460 | 1203
         ASTARA | 1422 | 1235
         ASKZ   | 1396 | 1181
         ASENTP | 1387 | 1185
         ASISKP | 1399 | 1189
         ASEME  | 1448 | 1262
         ASOSTR | 1498 | 1253
         ASMELT | 1429 | 1196
         ASMART | 1446 | 1213
         ASLOM  | 1425 | 1226
         ASAZU  | 1421 | 1235
         ASONCE | 1433 | 1208
         ASMAR  | 1404 | 1150
         ASTEP  | 1450 | 1235
         ASAVLJ | 1417 | 1182
         ASTOZI | 1436 | 1198
         ASTRAL | 1422 | 1227
         ASTEG  | 1404 | 1193
    */
    const int ntest_tx = 21;
    cl_int2 *test_tx = malloc (ntest_tx * sizeof(cl_int2));

    test_tx[0] = (cl_int2) {1468,1200};
    test_tx[1] = (cl_int2) {1395,1180};
    test_tx[2] = (cl_int2) {1400,1245};
    test_tx[3] = (cl_int2) {1460,1203};
    test_tx[4] = (cl_int2) {1422,1235};
    test_tx[5] = (cl_int2) {1396,1181};
    test_tx[6] = (cl_int2) {1387,1185};
    test_tx[7] = (cl_int2) {1399,1189};
    test_tx[8] = (cl_int2) {1448,1262};
    test_tx[9] = (cl_int2) {1498,1253};
    test_tx[10] = (cl_int2) {1429,1196};
    test_tx[11] = (cl_int2) {1446,1213};
    test_tx[12] = (cl_int2) {1425,1226};
    test_tx[13] = (cl_int2) {1421,1235};
    test_tx[14] = (cl_int2) {1433,1208};
    test_tx[15] = (cl_int2) {1404,1150};
    test_tx[16] = (cl_int2) {1450,1235};
    test_tx[17] = (cl_int2) {1417,1182};
    test_tx[18] = (cl_int2) {1436,1198};
    test_tx[19] = (cl_int2) {1422,1227};
    test_tx[20] = (cl_int2) {1404,1193};

    /* for each transmitter */
    for (i = 0; i < ntest_tx; i++)
    {
        /* display completion percentage */
        G_percent (i, ntest_tx, 1);

        /* Transmitter coordinates */
        cl_int2 tx_coord = test_tx[i];

        //G_message ("The transmitter is located at %d, %d", tx_coord.x,
        //                                                   tx_coord.y);
        /* Transmitter heights */
        //G_message ("Transmitter height above sea level is %d mts", tx_elevation);
        //G_message ("Transmitter anthena height above ground is %d mts", tx_anthena_height);

        /* transmitter data */ 
        cl_int4 tx_data = (cl_int4) {tx_coord.x, tx_coord.y,
                                     tx_elevation, tx_anthena_height};

        /* tile offset within the raster */
        cl_int2 tx_offset = (cl_int2) {tx_coord.x - radius,
                                       tx_coord.y - radius};

        /* set (more) remaining kernel parameters */
        clarg_set (ctx, krn, 1, tx_data);
        clarg_set (ctx, krn, 2, tx_offset);

        /* start kernel execution */
        clfork (ctx, 0, krn, &ndr, CL_EVENT_NOWAIT);

        clwait (ctx, 0, CL_KERNEL_EVENT|CL_MEM_EVENT|CL_EVENT_RELEASE);
    }

    /* sync memory */
    clmsync (ctx, 0, dem_out, CL_MEM_HOST|CL_EVENT_WAIT);

    /* write the calculation output */
    save_raster (dem_out, nrows, ncols, outfd);

    /* free allocated resources */
    free (test_tx);
    clclose (ctx, h);
    clfree (dem_out);
    clfree (dem_in);
}
コード例 #9
0
ファイル: hata_cl.c プロジェクト: lichinka/cai
/*
 * Calculates an interference matrix resulting from the tx power of all
 * transmitters combined with their respective path losses and the thermal
 * noise. The output is saved in one raster map.
 *
 * int nrows .............. the number of rows in the DEM.
 * int ncols .............. the number of columns in the DEM.
 * int tx_coord_col ....... transmitter column coordinate (in raster cells).
 * int tx_coord_row ....... transmitter row coordinate (in raster cells).
 * int tx_elevation ....... transmitter height above sea level.
 * int anthena_height ..... height of transmitter anthena above ground.
 * float rx_height ........ receiver height above ground.
 * float frequency ........ transmitter frequency in Mhz.
 * int radius ............. calculation radius around to the transmitter
 *                          (in raster cells).
 * int infd ............... file descriptor to read from the DEM.
 * int outfd .............. file descriptor to write the interference
 *                          data to.
 * RASTER_MAP_TYPE rtype .. DEM element data type.
 *
 */
void hata_interference_cl (const int nrows, const int ncols,
                           const int tx_coord_col, const int tx_coord_row,
                           const int tx_elevation, const int tx_anthena_height,
                           const float rx_height, const float frequency,
                           const int radius,
                           const int infd, const int outfd, 
                           RASTER_MAP_TYPE rtype)
{
    int i;

    /* number of processing tiles needed around each transmitter */
    int ntile = (radius*2) / _HATA_WITEM_PER_DIM_ + 1;

    G_message ("Receiver height above ground is %5.2f mts", rx_height);
    G_message ("Transmitter frequency is %7.2f Mhz", frequency);
    G_message ("Calculation radius is %d raster cells", radius);

    CONTEXT * ctx = init_context ( );

    /* initialize raster data */
    void *dem_in = load_raster (ctx, nrows, ncols, infd, rtype);

    /* interference matrix */
    void *qrm_out = alloc_raster (ctx, nrows, ncols, rtype, 
                                  (FCELL)_HATA_THERMAL_NOISE_, NULL);

    /* load, compile and link the OpenCL kernel file */
    void* h = clopen (ctx, NULL, CLLD_NOW);

    /* select a kernel function from the loaded file */
    cl_kernel krn = clsym (ctx, h, "hata_urban_interference", CLLD_NOW);

    /* defines a 2D matrix of work groups & work items */
    size_t global_wsize = ntile * _HATA_WITEM_PER_DIM_;
    size_t local_wsize = _HATA_WITEM_PER_DIM_;

    if ((global_wsize % local_wsize) != 0)
        G_fatal_error ("Work group dimensions are incorrect.");
    else
        G_message ("Creating %d work-group(s) of [%d x %d] threads each", 
                   global_wsize/local_wsize,
                   local_wsize, local_wsize);

    clndrange_t ndr = clndrange_init2d (0,global_wsize,local_wsize, 
                                        0,global_wsize,local_wsize);

    // correction factor ahr
    float ahr = (1.1f*log10(frequency) - 0.7f)*rx_height - 
                (1.56f*log10(frequency) - 0.8f);

    /* set kernel parameters and local memory size */
    clarg_set (ctx, krn, 0, ncols);
    clarg_set (ctx, krn, 3, rx_height);
    clarg_set (ctx, krn, 4, frequency);
    clarg_set (ctx, krn, 5, ahr);

    size_t lmem_size = _HATA_WITEM_PER_DIM_*_HATA_WITEM_PER_DIM_*
                       sizeof(cl_float2);

    if (lmem_size > _HATA_MAX_LOCAL_MEM_)
        G_fatal_error ("Allocated local memory (%d) exceeds %d bytes.", lmem_size,
                                                                        _HATA_MAX_LOCAL_MEM_);

    clarg_set_local (ctx, krn, 8, lmem_size);

    /* transfer data to the device */
    clmsync (ctx, 0, dem_in, CL_MEM_DEVICE|CL_EVENT_NOWAIT);
    clmsync (ctx, 0, qrm_out, CL_MEM_DEVICE|CL_EVENT_WAIT);

    /* set remaining kernel parameters */
    clarg_set_global (ctx, krn, 6, dem_in);
    clarg_set_global (ctx, krn, 7, qrm_out);

    G_message ("Simulating ...");

    /**
     * Test transmitters 
     * 
     * ASNEBE  | 1468 | 1200
     * ASKZK   | 1395 | 1180
     * ALEK    | 1408 | 1211
     * ANDREJ  | 1431 | 1212
     * AMALENA | 1462 | 1272
     * APOLJE  | 1483 | 1227
     * AMONS   | 1381 | 1230
     * ANTENA  | 1397 | 1238
     * ATOMAC  | 1443 | 1194
     * ATUNEL  | 1424 | 1239
     * AKOSET  | 1398 | 1206
     * ASPAR   | 1400 | 1245
     * ACHEMO  | 1431 | 1226
     * ALIVAD  | 1423 | 1248
     * ASMARG  | 1460 | 1203
     * ABTC    | 1451 | 1215
     * AZIMA   | 1471 | 1236
     * ASTARA  | 1422 | 1235
     * AVEGAS  | 1434 | 1257
     * APOVSE  | 1436 | 1232
     * ABTCST  | 1449 | 1213
     * AMOBI   | 1429 | 1222
     * APODUT  | 1378 | 1202
     * AOBZEL  | 1444 | 1222
     * AGRIC   | 1385 | 1207
     * ADELO   | 1421 | 1222
     * AJEZA   | 1459 | 1182
     * ASKZ    | 1396 | 1181
     * ATLK    | 1422 | 1225
     * AGR     | 1424 | 1220
     * ADNEVN  | 1426 | 1232
     * AMHOTE  | 1409 | 1212
     * AVIC    | 1414 | 1236
     * AJOZEF  | 1429 | 1234
     * ATVSLO  | 1425 | 1228
     * ACRNUC  | 1445 | 1172
     * ANGEL   | 1508 | 1219
     * AKOSEG  | 1401 | 1210
     * AMSC    | 1429 | 1222
     * AGRAM   | 1421 | 1195
     * ARAKTK  | 1436 | 1249
     * AIMKO   | 1445 | 1179
     * AKOVIN  | 1412 | 1214
     * ADOLGI  | 1388 | 1250
     * APETER  | 1431 | 1231
     * ASENTP  | 1387 | 1185
     * AOBI    | 1443 | 1268
     * AMZS    | 1427 | 1203
     * AVICTK  | 1403 | 1240
     * AZUR    | 1397 | 1238
     * AKAMNA  | 1388 | 1200
     * APOLCE  | 1482 | 1228
     * AKASEL  | 1497 | 1232
     * ASISKP  | 1399 | 1189
     * AKOZAR  | 1373 | 1247
     * ASEME   | 1448 | 1262
     * AURSKA  | 1424 | 1220
     * ABEZIT  | 1427 | 1199
     * AVEROV  | 1416 | 1201
     * ATEGR   | 1419 | 1209
     * ATRUB   | 1423 | 1231
     * AKOLIN  | 1436 | 1221
     * AVELAN  | 1439 | 1218
     * ABEZI   | 1431 | 1216
     * AGAMGD  | 1418 | 1148
     * AGURS   | 1431 | 1237
     * AGPG    | 1419 | 1237
     * AKOSME  | 1397 | 1210
     * AZALOG  | 1500 | 1225
     * ASOSTR  | 1498 | 1253
     * AROZNA  | 1404 | 1235
     * AVRHO   | 1380 | 1242
     * ARAK    | 1430 | 1244
     * AVILA   | 1404 | 1230
     * AKOLEZ  | 1413 | 1241
     * AJEZKZ  | 1427 | 1185
     * AVIZMA  | 1386 | 1173
     * AKOTNI  | 1429 | 1226
     * AMOSTE  | 1443 | 1227
     * ATOPNI  | 1425 | 1212
     * AGZ     | 1429 | 1209
     * APRZAC  | 1386 | 1192
     * ALITIJ  | 1455 | 1235
     * ATEHNO  | 1387 | 1233
     * ASMELT  | 1429 | 1196
     * ACRGMA  | 1439 | 1166
     * AFORD   | 1439 | 1215
     * ADRAVC  | 1396 | 1197
     * ABROD   | 1388 | 1168
     * ATABOR  | 1429 | 1228
     * ATRNOV  | 1421 | 1242
     * AGOLOV  | 1467 | 1263
     * ARESEV  | 1438 | 1228
     * ABTCMI  | 1450 | 1216
     * ASMART  | 1446 | 1213
     * APROGA  | 1382 | 1251
     * ABRDO   | 1382 | 1235
     * AKONEX  | 1387 | 1237
     * AZITO   | 1456 | 1213
     * ASLOM   | 1425 | 1226
     * APLAMA  | 1448 | 1202
     * AGRAD   | 1470 | 1218
     * AFUZIN  | 1463 | 1228
     * ASAZU   | 1421 | 1235
     * ATOTRA  | 1463 | 1233
     * AHALA   | 1414 | 1221
     * ASONCE  | 1433 | 1208
     * ALMLEK  | 1422 | 1202
     * ACERNE  | 1415 | 1212
     * ADRAV   | 1396 | 1201
     * ALGRAD  | 1424 | 1234
     * ALPP    | 1406 | 1205
     * ANAMA   | 1420 | 1231
     * ATIVO   | 1418 | 1226
     * AZAPUZ  | 1392 | 1196
     * ASMAR   | 1404 | 1150
     * ACANK   | 1416 | 1233
     * ATACGD  | 1390 | 1156
     * APOPTV  | 1435 | 1211
     * AFRANK  | 1417 | 1220
     * ASTEP   | 1450 | 1235
     * AEJATA  | 1445 | 1218
     * AZADOB  | 1482 | 1206
     * AELNA   | 1436 | 1177
     * AZELEZ  | 1428 | 1218
     * AMURGL  | 1415 | 1246
     * ACIGO   | 1423 | 1225
     * AIJS    | 1407 | 1241
     * AELOK   | 1459 | 1225
     * ATACBR  | 1385 | 1160
     * AJELSA  | 1416 | 1259
     * AVRHOV  | 1394 | 1242
     * ABIZOV  | 1472 | 1247
     * ACITYP  | 1454 | 1214
     * ASAVLJ  | 1417 | 1182
     * AKLINI  | 1434 | 1228
     * AKODEL  | 1439 | 1236
     * ASTOZI  | 1436 | 1198
     * AKORA   | 1422 | 1226
     * AHLEV   | 1388 | 1163
     * ATOPLA  | 1451 | 1224
     * AMALEN  | 1461 | 1273
     * AVECNA  | 1391 | 1222
     * ANADGO  | 1462 | 1178
     * ABOKAL  | 1379 | 1231
     * AVARNO  | 1404 | 1250
     * ASTRAL  | 1422 | 1227
     * AVEVCE  | 1488 | 1234
     * ARNC    | 1423 | 1225
     * AGEOPL  | 1406 | 1198
     * AMOBLI  | 1415 | 1200
     * AVLADA  | 1415 | 1234
     * ASTEG   | 1404 | 1193
     * AKOSEZ  | 1392 | 1207
     */

    const int ntest_tx = 154;
    cl_int2 *test_tx = malloc (ntest_tx * sizeof(cl_int2));

    test_tx[0] = (cl_int2) {1468,1200};
    test_tx[1] = (cl_int2) {1395,1180};
    test_tx[2] = (cl_int2) {1408,1211};
    test_tx[3] = (cl_int2) {1431,1212};
    test_tx[4] = (cl_int2) {1462,1272};
    test_tx[5] = (cl_int2) {1483,1227};
    test_tx[6] = (cl_int2) {1381,1230};
    test_tx[7] = (cl_int2) {1397,1238};
    test_tx[8] = (cl_int2) {1443,1194};
    test_tx[9] = (cl_int2) {1424,1239};
    test_tx[10] = (cl_int2) {1398,1206};
    test_tx[11] = (cl_int2) {1400,1245};
    test_tx[12] = (cl_int2) {1431,1226};
    test_tx[13] = (cl_int2) {1423,1248};
    test_tx[14] = (cl_int2) {1460,1203};
    test_tx[15] = (cl_int2) {1451,1215};
    test_tx[16] = (cl_int2) {1471,1236};
    test_tx[17] = (cl_int2) {1422,1235};
    test_tx[18] = (cl_int2) {1434,1257};
    test_tx[19] = (cl_int2) {1436,1232};
    test_tx[20] = (cl_int2) {1449,1213};
    test_tx[21] = (cl_int2) {1429,1222};
    test_tx[22] = (cl_int2) {1378,1202};
    test_tx[23] = (cl_int2) {1444,1222};
    test_tx[24] = (cl_int2) {1385,1207};
    test_tx[25] = (cl_int2) {1421,1222};
    test_tx[26] = (cl_int2) {1459,1182};
    test_tx[27] = (cl_int2) {1396,1181};
    test_tx[28] = (cl_int2) {1422,1225};
    test_tx[29] = (cl_int2) {1424,1220};
    test_tx[30] = (cl_int2) {1426,1232};
    test_tx[31] = (cl_int2) {1409,1212};
    test_tx[32] = (cl_int2) {1414,1236};
    test_tx[33] = (cl_int2) {1429,1234};
    test_tx[34] = (cl_int2) {1425,1228};
    test_tx[35] = (cl_int2) {1445,1172};
    test_tx[36] = (cl_int2) {1508,1219};
    test_tx[37] = (cl_int2) {1401,1210};
    test_tx[38] = (cl_int2) {1429,1222};
    test_tx[39] = (cl_int2) {1421,1195};
    test_tx[40] = (cl_int2) {1436,1249};
    test_tx[41] = (cl_int2) {1445,1179};
    test_tx[42] = (cl_int2) {1412,1214};
    test_tx[43] = (cl_int2) {1388,1250};
    test_tx[44] = (cl_int2) {1431,1231};
    test_tx[45] = (cl_int2) {1387,1185};
    test_tx[46] = (cl_int2) {1443,1268};
    test_tx[47] = (cl_int2) {1427,1203};
    test_tx[48] = (cl_int2) {1403,1240};
    test_tx[49] = (cl_int2) {1397,1238};
    test_tx[50] = (cl_int2) {1388,1200};
    test_tx[51] = (cl_int2) {1482,1228};
    test_tx[52] = (cl_int2) {1497,1232};
    test_tx[53] = (cl_int2) {1399,1189};
    test_tx[54] = (cl_int2) {1373,1247};
    test_tx[55] = (cl_int2) {1448,1262};
    test_tx[56] = (cl_int2) {1424,1220};
    test_tx[57] = (cl_int2) {1427,1199};
    test_tx[58] = (cl_int2) {1416,1201};
    test_tx[59] = (cl_int2) {1419,1209};
    test_tx[60] = (cl_int2) {1423,1231};
    test_tx[61] = (cl_int2) {1436,1221};
    test_tx[62] = (cl_int2) {1439,1218};
    test_tx[63] = (cl_int2) {1431,1216};
    test_tx[64] = (cl_int2) {1418,1148};
    test_tx[65] = (cl_int2) {1431,1237};
    test_tx[66] = (cl_int2) {1419,1237};
    test_tx[67] = (cl_int2) {1397,1210};
    test_tx[68] = (cl_int2) {1500,1225};
    test_tx[69] = (cl_int2) {1498,1253};
    test_tx[70] = (cl_int2) {1404,1235};
    test_tx[71] = (cl_int2) {1380,1242};
    test_tx[72] = (cl_int2) {1430,1244};
    test_tx[73] = (cl_int2) {1404,1230};
    test_tx[74] = (cl_int2) {1413,1241};
    test_tx[75] = (cl_int2) {1427,1185};
    test_tx[76] = (cl_int2) {1386,1173};
    test_tx[77] = (cl_int2) {1429,1226};
    test_tx[78] = (cl_int2) {1443,1227};
    test_tx[79] = (cl_int2) {1425,1212};
    test_tx[80] = (cl_int2) {1429,1209};
    test_tx[81] = (cl_int2) {1386,1192};
    test_tx[82] = (cl_int2) {1455,1235};
    test_tx[83] = (cl_int2) {1387,1233};
    test_tx[84] = (cl_int2) {1429,1196};
    test_tx[85] = (cl_int2) {1439,1166};
    test_tx[86] = (cl_int2) {1439,1215};
    test_tx[87] = (cl_int2) {1396,1197};
    test_tx[88] = (cl_int2) {1388,1168};
    test_tx[89] = (cl_int2) {1429,1228};
    test_tx[90] = (cl_int2) {1421,1242};
    test_tx[91] = (cl_int2) {1467,1263};
    test_tx[92] = (cl_int2) {1438,1228};
    test_tx[93] = (cl_int2) {1450,1216};
    test_tx[94] = (cl_int2) {1446,1213};
    test_tx[95] = (cl_int2) {1382,1251};
    test_tx[96] = (cl_int2) {1382,1235};
    test_tx[97] = (cl_int2) {1387,1237};
    test_tx[98] = (cl_int2) {1456,1213};
    test_tx[99] = (cl_int2) {1425,1226};
    test_tx[100] = (cl_int2) {1448,1202};
    test_tx[101] = (cl_int2) {1470,1218};
    test_tx[102] = (cl_int2) {1463,1228};
    test_tx[103] = (cl_int2) {1421,1235};
    test_tx[104] = (cl_int2) {1463,1233};
    test_tx[105] = (cl_int2) {1414,1221};
    test_tx[106] = (cl_int2) {1433,1208};
    test_tx[107] = (cl_int2) {1422,1202};
    test_tx[108] = (cl_int2) {1415,1212};
    test_tx[109] = (cl_int2) {1396,1201};
    test_tx[110] = (cl_int2) {1424,1234};
    test_tx[111] = (cl_int2) {1406,1205};
    test_tx[112] = (cl_int2) {1420,1231};
    test_tx[113] = (cl_int2) {1418,1226};
    test_tx[114] = (cl_int2) {1392,1196};
    test_tx[115] = (cl_int2) {1404,1150};
    test_tx[116] = (cl_int2) {1416,1233};
    test_tx[117] = (cl_int2) {1390,1156};
    test_tx[118] = (cl_int2) {1435,1211};
    test_tx[119] = (cl_int2) {1417,1220};
    test_tx[120] = (cl_int2) {1450,1235};
    test_tx[121] = (cl_int2) {1445,1218};
    test_tx[122] = (cl_int2) {1482,1206};
    test_tx[123] = (cl_int2) {1436,1177};
    test_tx[124] = (cl_int2) {1428,1218};
    test_tx[125] = (cl_int2) {1415,1246};
    test_tx[126] = (cl_int2) {1423,1225};
    test_tx[127] = (cl_int2) {1407,1241};
    test_tx[128] = (cl_int2) {1459,1225};
    test_tx[129] = (cl_int2) {1385,1160};
    test_tx[130] = (cl_int2) {1416,1259};
    test_tx[131] = (cl_int2) {1394,1242};
    test_tx[132] = (cl_int2) {1472,1247};
    test_tx[133] = (cl_int2) {1454,1214};
    test_tx[134] = (cl_int2) {1417,1182};
    test_tx[135] = (cl_int2) {1434,1228};
    test_tx[136] = (cl_int2) {1439,1236};
    test_tx[137] = (cl_int2) {1436,1198};
    test_tx[138] = (cl_int2) {1422,1226};
    test_tx[139] = (cl_int2) {1388,1163};
    test_tx[140] = (cl_int2) {1451,1224};
    test_tx[141] = (cl_int2) {1461,1273};
    test_tx[142] = (cl_int2) {1391,1222};
    test_tx[143] = (cl_int2) {1462,1178};
    test_tx[144] = (cl_int2) {1379,1231};
    test_tx[145] = (cl_int2) {1404,1250};
    test_tx[146] = (cl_int2) {1422,1227};
    test_tx[147] = (cl_int2) {1488,1234};
    test_tx[148] = (cl_int2) {1423,1225};
    test_tx[149] = (cl_int2) {1406,1198};
    test_tx[150] = (cl_int2) {1415,1200};
    test_tx[151] = (cl_int2) {1415,1234};
    test_tx[152] = (cl_int2) {1404,1193};
    test_tx[153] = (cl_int2) {1392,1207};

    /* for each transmitter */
    for (i = 0; i < ntest_tx; i++)
    {
        /* display completion percentage */
        G_percent (i, ntest_tx, 1);

        /* Transmitter coordinates */
        cl_int2 tx_coord = test_tx[i];

        G_message ("The transmitter is located at %d, %d", tx_coord.x,
                                                           tx_coord.y);
        /* Transmitter heights */
        //G_message ("Transmitter height above sea level is %d mts", tx_elevation);
        //G_message ("Transmitter anthena height above ground is %d mts", tx_anthena_height);

        /* transmitter data */ 
        cl_int4 tx_data = (cl_int4) {tx_coord.x, tx_coord.y,
                                     tx_elevation, tx_anthena_height};

        /* tile offset within the raster */
        cl_int2 tx_offset = (cl_int2) {tx_coord.x - radius,
                                       tx_coord.y - radius};

        /* set (more) remaining kernel parameters */
        clarg_set (ctx, krn, 1, tx_data);
        clarg_set (ctx, krn, 2, tx_offset);

        /* start kernel execution */
        clfork (ctx, 0, krn, &ndr, CL_EVENT_NOWAIT);

        clwait (ctx, 0, CL_KERNEL_EVENT|CL_MEM_EVENT|CL_EVENT_RELEASE);
    }

    /* sync memory */
    clmsync (ctx, 0, qrm_out, CL_MEM_HOST|CL_EVENT_WAIT);

    /* write the calculation output */
    save_raster (qrm_out, nrows, ncols, outfd);

    /* free allocated resources */
    free (test_tx);
    clclose (ctx, h);
    clfree (qrm_out);
    clfree (dem_in);

}
コード例 #10
0
//
// incline is TABLE, shave - enable shaving
// not use for back rotating
//
cell * erect_cell_table (cell *c, int16_t tab_angle[], int16_t shave, Bool cutting)
{
int16_t     dx=c->w, dy=c->h, le, ri               ;
int16_t     lminx, lminsx, lminy, lminsy           ;
MN      *sh_mn                                 ;
cell    *sh_cell[MAX_CELLS_IN_LIST+1],res_cell ;
puchar   raster                                 ;
uchar    sh_raster[1024]                        ;
int16_t     i, d_x, n, inc                         ;
cell    *cret = c                              ;

if( !c->env     )              return c;
le = ri = 0;
for (i=0; i<dy; i++)
  tab_angle[i] >>= 2;
inc = (tab_angle[0] != tab_angle[dy-1]);
if( shave || inc)
  {
  raster = save_raster (c);
  le = diff_left_limit_rast(raster,dx,dy,tab_angle);
  d_x = shift_raster (raster, dy, dx, tab_angle,
        (int16_t)(MAX (tab_angle[0], tab_angle[dy-1])), sh_raster, 1);

  if( (sh_mn = c_locomp (sh_raster, (int16_t)bytlen(d_x), dy, 0, 0))==NULL )
    return NULL;

  for(i=0; sh_mn && i<MAX_CELLS_IN_LIST; i++, sh_mn = sh_mn->mnnext)
    {
    if( (sh_cell[i]=create_cell (sh_mn, c, c->bdiff, (char)(c->difflg&0xf0)))==NULL )
      return NULL;
    sh_cell[i]->stick_inc = NO_INCLINE; // rotate disabled
    }
  sh_cell[i] = NULL;
  n = i;

  for(lminx=lminy=c->w,i=0;i<n;i++)
    {
    if( lminx>sh_cell[i]->env->left )
      lminx=sh_cell[i]->env->left;
    if( lminy>sh_cell[i]->env->upper )
      lminy=sh_cell[i]->env->upper;
    }

  for(i=0;i<n;i++)
    pimpleshave( sh_cell[i], shave, inc );

  for(lminsx=lminsy=c->w,i=0;i<n;i++)
    {
    if( lminsx>sh_cell[i]->env->left )
      lminsx=sh_cell[i]->env->left;
    if( lminsy>sh_cell[i]->env->upper )
      lminsy=sh_cell[i]->env->upper;
    }

  memcpy( &res_cell, c , sizeof(cell));
  compose_cell(n, sh_cell, &res_cell);

  if( n<2 )
    c->cg_flag &= 0xFB         ; // clear compose flag for normal comp
  else
    c->cg_flag |= c_cg_comp    ; // set composed flag
  c->env        = res_cell.env ;
  c->env->upper = c->r_row     ;
  c->env->left  = c->r_col     ;
  if( n>1 || c->dens==255 )
    c->dens     = 255          ; // undef
  else
    {
    int32_t dens   = calc_dens(c);
    c->dens     = (dens*32)/(res_cell.w*res_cell.h);
    }
  c->w          = res_cell.w   ;
  c->h          = res_cell.h   ;
  c->recsource  = 0            ; // artifact
  if( lminsx>lminx )
    {
    lminsx -= lminx;
    c->env->left += lminsx;
    c->col       += lminsx;
    c->r_col     += lminsx;
    }
  if( lminsy>lminy )
    {
    lminsy -= lminy;
    c->env->upper += lminsy;
    c->row        += lminsy;
    c->r_row      += lminsy;
    }
  if( c->flg!=c_f_dust && c->w<MAX_DUST_WIDTH && c->h<MAX_DUST_HEIGHT )
    {
    cell *wc;
    c->flg   = c_f_dust;
    c->nvers = 0;
    c->vers[0].let=c->vers[0].prob=0;
    (wc=c->prevl)->nextl = c->nextl;
    c->nextl->prevl      = c->prevl;
    err_pnlet(c);
    }
  if( le<0 && c->col+le>=0 && c->r_col+le>=0 && c->env->left+le>=0 )
    {
    c->env->left += le;
    c->col       += le;
    c->r_col     += le;
    }
  c->pos_inc=erect_rot;
  if( n>1 && cutting)
    cret = convert_to_cells(c);
  }

return cret;
}
コード例 #11
0
//
// incline is VALUE, shave - enable shaving
// use for back rotating too
//
cell * erect_cell_value (cell *c, int16_t inc, int16_t shave, Bool cutting)
{
int16_t     dx=c->w, dy=c->h, le, ri, sinc=inc     ;
int16_t     lminx, lminsx, lminy, lminsy           ;
MN      *sh_mn                                 ;
cell    *sh_cell[MAX_CELLS_IN_LIST+1],res_cell ;
puchar   raster                                 ;
uchar    sh_raster[1024*2]                      ;
int16_t     i, d_x, n                              ;
int16_t     tab_angle[256]                         ;
cell    *cret = c                              ;

if ( dy >= 256 )
	dy = 255;                                        //AK! add for crash steck protection
if( !c->env     )
	return c;

if( c->flg&c_f_dust)  shave = 0; // dust can't shave
ri = le = 0;
if( ((long)(dy-1)*abs(inc))<2048 )
  inc=0;
if( inc!=0 )
  for (i=0; ( i < dy ) && ( i < 256 ); i++)          //AK add c/g 06.03.98
    tab_angle[i] = ((long)(dy-1-i)*inc)/2048;
else
    memset(tab_angle,0,dy*2);

if( shave || inc )
  {
	// если слишком мал буфер - уходим
	// иначе возможен вылет и т.п.  Nick 07.04.2002
	if( (long)dy * ( (dx + (long)(MAX (abs(tab_angle[0]), abs(tab_angle[dy-1]))+7))>>3) >
		sizeof(sh_raster)
	  )
	  return c;

    raster = save_raster (c);

    le = diff_left_limit_rast(raster,dx,dy,tab_angle);

    if( inc<0 ) // inc<0 - clear rotating
      ri = diff_left_limit_cell(c, tab_angle, c->w);

    d_x = shift_raster (raster, dy, dx, tab_angle,
      (int16_t)(MAX (abs(tab_angle[0]), abs(tab_angle[dy-1]))), sh_raster, inc);

/*
	 if( line_number == 16 && c->col == 462)
	 {
		char qq[64];
		MessageBox(GetActiveWindow(),itoa(dx,qq,10),"old",MB_OK);
		MessageBox(GetActiveWindow(),itoa(dy,qq,10),"dy",MB_OK);
		MessageBox(GetActiveWindow(),itoa(inc,qq,10),"inc",MB_OK);
		MessageBox(GetActiveWindow(),itoa(d_x,qq,10),"new",MB_OK);
	 }
*/

  if( (sh_mn = c_locomp (sh_raster, (int16_t)bytlen(d_x), dy, 0, 0))==NULL )
    return c;

  for(i=0; sh_mn && i<MAX_CELLS_IN_LIST; i++, sh_mn = sh_mn->mnnext)
    {
    if( (sh_cell[i]=create_cell (sh_mn, c, c->bdiff, (char)(c->difflg&0xf0)))==NULL )
      return c;
    if( sh_cell[i]->w>RASTER_MAX_WIDTH || sh_cell[i]->h>RASTER_MAX_HEIGHT ||
		!sh_cell[i]->env
	  )
      {
      for(;i>=0;i--)
        del_cell(sh_cell[i]);
      return c;
      }

    sh_cell[i]->stick_inc = NO_INCLINE; // rotate disabled
    }

  sh_cell[i] = NULL;
  n=i;

  for(lminx=lminy=c->w,i=0;i<n;i++)
    {
    if( lminx>sh_cell[i]->env->left )
      lminx=sh_cell[i]->env->left;
    if( lminy>sh_cell[i]->env->upper )
      lminy=sh_cell[i]->env->upper;
    }


  for(i=0;i<n;i++)
    pimpleshave( sh_cell[i], shave, inc );

  for(lminsx=lminsy=c->w,i=0;i<n;i++)
    {
    if( lminsx>sh_cell[i]->env->left )
      lminsx=sh_cell[i]->env->left;
    if( lminsy>sh_cell[i]->env->upper )
      lminsy=sh_cell[i]->env->upper;
    }

  memcpy( &res_cell, c , sizeof(cell));
  compose_cell(n, sh_cell, &res_cell);

  if( n<2 )
    c->cg_flag &= 0xFB         ; // clear compose flag for normal comp
  else
    c->cg_flag |= c_cg_comp    ; // set composed flag
  c->env        = res_cell.env ;
  c->env->upper = c->r_row     ;
  c->env->left  = c->r_col     ;
  if( n>1 || c->dens==255 )
    c->dens     = 255          ; // undef
  else
    {
    int32_t dens   = calc_dens(c);
    c->dens     = (dens*32)/(res_cell.w*res_cell.h);
    }
  c->w          = res_cell.w   ;
  c->h          = res_cell.h   ;
  c->recsource  = 0            ; // artifact


  if( le<0 && c->col+le>=0 && c->r_col+le>=0 && c->env->left+le>=0 )
    {
    c->env->left += le;
    c->col       += le;
    c->r_col     += le;
    }
  if( ri>0 )
    {
    c->env->left += ri;
    c->col       += ri;
    c->r_col     += ri;
    }
  if( lminsx>lminx )
    {
    lminsx -= lminx;
    c->env->left += lminsx;
    c->col       += lminsx;
    c->r_col     += lminsx;
    }
  if( lminsy>lminy )
    {
    lminsy -= lminy;
    c->env->upper += lminsy;
    c->row        += lminsy;
    c->r_row      += lminsy;
    }
  if( (c->flg&(c_f_bad|c_f_let)) && c->w<MAX_DUST_WIDTH && c->h<MAX_DUST_HEIGHT )
    {
    cell *wc;
    c->flg   = c_f_dust;
    c->nvers = 0;
    c->vers[0].let=c->vers[0].prob=0;
    (wc=c->prevl)->nextl = c->nextl;
    c->nextl->prevl      = c->prevl;
    err_pnlet(c);
    }

  if( !(inc==0 && shave!=0) )    // not shaving without erection
    c->stick_inc  = inc;
  if( inc!=0 )
    c->pos_inc=erect_rot;

  if( n>1 && cutting)
    cret = convert_to_cells(c);

  }

// Nick 7.04.2002 c->cret - с может быть удален в convert_to_cells!
if( !inc &&  (cret->flg&c_f_dust) )
  {
  cret->stick_inc  = sinc;
  cret->pos_inc=erect_rot;
  }

return cret;
}