Пример #1
0
// pa3fwm, 20040113: I didn't "clean" this part yet
int getctydata2(char *checkcall)
{
    extern char cqzone[];
    extern int countrynr;

    char checkbuffer[17] = "";
    char membuffer[17] = "";
    char checkncall[20];

    prefix_data *pfx;
    int pfxmax = prefix_count();
    int i = 0, w = 0, x = 0;
    char portable = '\0';
    int pp = 0;
    size_t loc;

    strncpy(membuffer, checkcall, 16);
    portable = '\0';

    if (strstr(checkcall, "/QRP") != NULL)	//strip the qrp
	checkcall[strlen(checkcall) - 4] = '\0';

    loc = strcspn(checkcall, "/");

    if (loc > 4) {

	strncpy(checkbuffer, (checkcall + loc + 1),
		(strlen(checkcall) + 1) - loc);

	if (strlen(checkbuffer) == 1)
	    checkcall[loc] = '\0';
	if (checkbuffer[0] == 'M' && strlen(checkbuffer) <= 3)
	    checkcall[loc] = '\0';
	if (checkbuffer[0] == 'Q' && strlen(checkbuffer) == 3)	/* /QRP */
	    checkcall[loc] = '\0';
	if (checkbuffer[0] == 'A' && strlen(checkbuffer) <= 3)	/*  /A,  /AM etc */
	    checkcall[loc] = '\0';
	if ((strlen(checkbuffer) <= 3) && (checkbuffer[0] <= 57) && (checkbuffer[0] >= 48))	/*  /3,   etc */
	    portable = checkbuffer[0];

    }
    loc = strcspn(checkcall, "/");

    if (loc != strlen(checkcall)) {

	if (loc < 5)
	    checkcall[loc] = '\0';	/*  "PA/DJ0LN/P   */
	else {			/*  DJ0LN/P       */

	    strncpy(checkcall, checkcall, loc + 1);

	}
    }

    /* ------------------------------------------------------------ */

    if (strlen(checkbuffer) == 1) {	/*  /3 */
	for (pp = strlen(checkcall) - 1; pp > 0; pp--) {

	    if ((checkcall[pp] <= '9') && (checkcall[pp] >= '0'))
		if ((checkbuffer[0] <= '9') && (checkbuffer[0] >= '0')) {
		    checkcall[pp] = checkbuffer[0];
		    break;
		}
	}
    } else if (strlen(checkbuffer) > 1)
	strcpy(checkcall, checkbuffer);

    getpx(checkcall);

    /* ------------------------------------------------------------ */

    w = 0;

    for (pp = 1; pp <= strlen(checkcall); pp++) {

	strncpy(checkncall, checkcall, pp);
	checkncall[pp] = '\0';

	for (i = 0; i < pfxmax; i++) {
		
	    pfx = prefix_by_index(i);

	    if ((strncmp
		 (checkncall, pfx->pfx, strlen(pfx->pfx)) == 0)) {

		if (strlen(checkncall) == strlen(pfx->pfx)) {
		    w = i;
		    x = pfx->dxcc_index;
		    break;
		}

	    }
	}
    }

    sprintf(cqzone, "%02d", prefix_by_index(w) -> cq);

    countrynr = x;

    strcpy(checkcall, membuffer);

    return (x);

}
Пример #2
0
  void BVH4HairBuilder::parallelBinningGlobal(const size_t threadID, const size_t numThreads)
  {
    BuildRecord &current = global_sharedData.rec;

    const unsigned int items = current.items();
    const unsigned int startID = current.begin + ((threadID+0)*items/numThreads);
    const unsigned int endID   = current.begin + ((threadID+1)*items/numThreads);

    const mic_f centroidMin = broadcast4to16f(&current.bounds.centroid2.lower);
    const mic_f centroidMax = broadcast4to16f(&current.bounds.centroid2.upper);

    const mic_f centroidBoundsMin_2 = centroidMin;
    const mic_f centroidDiagonal_2  = centroidMax-centroidMin;
    const mic_f scale = select(centroidDiagonal_2 != 0.0f,rcp(centroidDiagonal_2) * mic_f(16.0f * 0.99f),mic_f::zero());

    Bezier1i  *__restrict__ const tmp_prims = (Bezier1i*)accel;

    fastbin_copy<Bezier1i,false>(prims,tmp_prims,startID,endID,centroidBoundsMin_2,scale,global_bin16[threadID]);    

    LockStepTaskScheduler::syncThreadsWithReduction( threadID, numThreads, reduceBinsParallel, global_bin16 );
    
    if (threadID == 0)
      {
	const float voxelArea = area(current.bounds.geometry);

	global_sharedData.split.cost = items * voxelArea * INTERSECTION_COST;;
	
	const Bin16 &bin16 = global_bin16[0];

	for (size_t dim=0;dim<3;dim++)
	  {
	    if (unlikely(centroidDiagonal_2[dim] == 0.0f)) continue;

	    const mic_f rArea = prefix_area_rl(bin16.min_x[dim],bin16.min_y[dim],bin16.min_z[dim],
					       bin16.max_x[dim],bin16.max_y[dim],bin16.max_z[dim]);
	    const mic_f lArea = prefix_area_lr(bin16.min_x[dim],bin16.min_y[dim],bin16.min_z[dim],
					       bin16.max_x[dim],bin16.max_y[dim],bin16.max_z[dim]);
	    const mic_i lnum  = prefix_count(bin16.count[dim]);

	    const mic_i rnum    = mic_i(items) - lnum;
	    const mic_i lblocks = (lnum + mic_i(3)) >> 2;
	    const mic_i rblocks = (rnum + mic_i(3)) >> 2;
	    const mic_m m_lnum  = lnum == 0;
	    const mic_m m_rnum  = rnum == 0;
	    const mic_f cost    = select(m_lnum|m_rnum,mic_f::inf(),lArea * mic_f(lblocks) + rArea * mic_f(rblocks) + voxelArea );

	    if (lt(cost,mic_f(global_sharedData.split.cost)))
	      {

		const mic_f min_cost    = vreduce_min(cost); 
		const mic_m m_pos       = min_cost == cost;
		const unsigned long pos = bitscan64(m_pos);	    
		
		assert(pos < 15);
		if (pos < 15)
		  {
		    global_sharedData.split.cost    = cost[pos];
		    global_sharedData.split.pos     = pos+1;
		    global_sharedData.split.dim     = dim;	    
		    global_sharedData.split.numLeft = lnum[pos];
		  }
	      }
	  }
      }
  }
Пример #3
0
int getpfxindex(char *checkcallptr)
{
    char checkbuffer[17] = "";
    char checkncall[17] = "";
    char checkcall[17] = "";
    char findcall[17] = "";

    prefix_data *pfx;
    int pfxmax = prefix_count();

    int i = 0, w = 0, abnormal_call = 0;
    char portable = '\0';
    int pp = 0;
    size_t loc;

    g_strlcpy(checkcall, checkcallptr, 17);

    portable = '\0';

    if (strstr(checkcall, "/QRP") != NULL)	/* drop QRP suffix */
	checkcall[strlen(checkcall) - 4] = '\0';

    if (strstr(checkcall, "/AM") != NULL)	// airborne mobile, no country (0), no zone (0)
	checkcall[0] = '\0';

    if (strstr(checkcall, "/MM") != NULL)	// maritime mobile, no country, no zone
	checkcall[0] = '\0';

    strncpy(findcall, checkcall, 16);

    loc = strcspn(checkcall, "/");

    if (loc != strlen(checkcall)) {
	char call1[17];
	char call2[17];


	strncpy(call1, checkcall, loc);		/* 1st part before '/' */
	call1[loc] = '\0';
	strcpy(call2, checkcall + loc + 1);	/* 2nd part after '/' */

	if (strlen(call2) < strlen(call1)
	    && strlen(call2) > 1) {
	    sprintf(checkcall, "%s/%s", call2, call1);
	    abnormal_call = 1;
	    loc = strcspn(checkcall, "/");
	}

	if (loc > 3) {

	    strncpy(checkbuffer, (checkcall + loc + 1),
		    (strlen(checkcall) + 1) - loc);

	    if (strlen(checkbuffer) == 1)
		checkcall[loc] = '\0';
	    if (checkbuffer[0] == 'M' && strlen(checkbuffer) <= 3)
		checkcall[loc] = '\0';
	    if (checkbuffer[0] == 'Q' && strlen(checkbuffer) == 3)	/* /QRP */
		checkcall[loc] = '\0';
	    if (checkbuffer[0] == 'A' && strlen(checkbuffer) <= 3)	/*  /A,  /AM etc */
		checkcall[loc] = '\0';
	    if ((strlen(checkbuffer) <= 3) && (checkbuffer[0] <= '9') && (checkbuffer[0] >= '0'))	/*  /3,   etc */
		portable = checkbuffer[0];
	    loc = strcspn(checkcall, "/");
	}

	if (loc != strlen(checkcall)) {

	    if (loc < 5)
		checkcall[loc] = '\0';	/*  "PA/DJ0LN/P   */
	    else {		/*  DJ0LN/P       */
		strncpy(checkcall, checkcall, loc + 1);
	    }
	}

	/* ------------------------------------------------------------ */

	if ((strlen(checkbuffer) == 1) && isdigit(checkbuffer[0])) {	/*  /3 */
	    for (pp = strlen(checkcall) - 1; pp > 0; pp--) {
		if (isdigit(checkcall[pp])) {
		    checkcall[pp] = checkbuffer[0];
		    break;
		}
	    }
	} else if (strlen(checkbuffer) > 1)
	    strcpy(checkcall, checkbuffer);

    }

    /* -------------check full call exceptions first...--------------------- */

    w = -1;
    if (abnormal_call == 1) {
	// pa3fwm 20040111: is pp guaranteed to be properly initialized 
	// if/when we get here??
	// pa0r 20040117: It is not. Code changed...
	//      strncpy(checkncall , findcall, pp);
	strncpy(checkncall, findcall, sizeof(checkncall) - 1);

	for (i = 0; i < pfxmax; i++) {
	    pfx = prefix_by_index(i);
	    if (strcmp(checkncall, pfx->pfx) == 0) {
		w = i;
		break;
	    }
	}

    } else {
	int bestlen = 0;
	for (i = 0; i < pfxmax; i++) {
	    int l;
	    pfx = prefix_by_index(i);
	    if (*pfx->pfx != findcall[0])
		continue;

	    l = strlen(pfx->pfx);
	    if (l <= bestlen)
		continue;

	    if (strncmp(pfx->pfx, findcall, l) == 0) {
		bestlen = l;
		w = i;
	    }
	}
    }

    if (w < 0 && 0 != strcmp(findcall, checkcall)) {
	// only if not found in prefix full call exception list
	int bestlen = 0;
	for (i = 0; i < pfxmax; i++) {
	    int l;
	    pfx = prefix_by_index(i);
	    if (*pfx->pfx != checkcall[0])
		continue;
	    l = strlen(pfx->pfx);
	    if (l <= bestlen)
		continue;
	    if (strncmp(pfx->pfx, checkcall, l) == 0) {
		bestlen = l;
		w = i;
	    }
	}
    }

    return w;
}