コード例 #1
0
ファイル: smooth.c プロジェクト: jasminegrosso/zeno
smxptr init_smooth(kdxptr kd, int nsmooth, real slope)
{
    smxptr sm;
    int i, listsize = nsmooth + EXTLIST;

    sm = (smxptr) allocate(sizeof(smcontext));
    sm->kd = kd;
    sm->nsmooth = nsmooth;
    sm->coefs[0] =  1.0 - slope * (14.0/45.0);
    sm->coefs[1] = slope;
    sm->coefs[2] = -1.5 - slope * (31.0/30.0);
    sm->coefs[3] = 0.75 + slope * (7.0/20.0);
    sm->coefs[4] = 0.25 + slope * (1.0/180.0);
    for (i = 0; i < NRPROF; i++)
        sm->rprof[i] = 0;
    sm->pque = (pqnode *) allocate(nsmooth * sizeof(pqnode));
    sm->r2ball = (real *) allocate(kd->ngas * sizeof(real));
    sm->r2list = (real *) allocate(listsize * sizeof(real));
    sm->inlist = (int *) allocate(listsize * sizeof(int));
    PQInit(sm->pque, nsmooth);
    sm->cpustart = cputime();
    return (sm);
}
コード例 #2
0
/*****************************************************************************
* Routine to load a library from given open file.							 *
*****************************************************************************/
PriorQue *LoadLibraryAux(WinEDA_DrawFrame * frame, LibraryStruct * Library, FILE *libfile, int *NumOfParts)
{
int LineNum = 0;
char Line[1024];
PriorQue *PQ = NULL;
EDA_LibComponentStruct *LibEntry;
wxString msg;
	
wxBusyCursor ShowWait;		// Display a Busy Cursor..

	*NumOfParts = 0;

	if ( GetLine(libfile, Line, &LineNum, sizeof(Line) ) == NULL)
		{
		msg = _("File <") + Library->m_Name + _("> is empty!");
		DisplayError(frame, msg);
		return NULL;
		}

	if( strnicmp(Line, LIBFILE_IDENT, 10) != 0)
		{
		msg = _("File <") + Library->m_Name + _("> is NOT EESCHEMA library!");
		DisplayError(frame, msg);
		return NULL;
		}

	if ( Library ) Library->m_Header = CONV_FROM_UTF8(Line);

	PQInit(&PQ);
	PQCompFunc((PQCompFuncType) LibraryEntryCompare);

	while (GetLine(libfile, Line, &LineNum, sizeof(Line)) )
	{
		if (strnicmp(Line, "$HEADER", 7) == 0)
		{
			if ( Library )
			{
				if ( ! Library->ReadHeader(libfile, &LineNum) )
				{
				msg = _("Library <") + Library->m_Name + _("> header read error");
				DisplayError(frame, msg, 30);
				}
			}
			continue;
		}
		
		if (strnicmp(Line, "DEF", 3) == 0)
		{
			/* Read one DEF/ENDDEF part entry from library: */
			LibEntry = Read_Component_Definition(frame, Line, libfile, &LineNum);
			if ( LibEntry )
			{
				/* If we are here, this part is O.k. - put it in: */
				++*NumOfParts; 
				PQInsert(&PQ, LibEntry);
				InsertAlias(&PQ, LibEntry, NumOfParts);
			}
		}
	}

	return PQ;
}