Beispiel #1
0
static void filterCurveToLine(int* pCurve, int nMax, double x0, double y0,
		double x1, double y1, double x2, double y2,
		double x3, double y3)
{
	double x01,y01,x32,y32,xm,ym;
	double c1,d1,c2,d2,e,f;

	/* check if control points are on line */
	if (filterOnLine(x0,y0,x3,y3,x1,y1) && filterOnLine(x0,y0,x3,y3,x2,y2))
	{
		filterLine(pCurve,nMax,
			(int)(x0*nMax),(int)(y0*nMax),
			(int)(x3*nMax),(int)(y3*nMax));
		return;
	}

	/* calculate midpoints */
	x01 = (x0 + x1) / 2; y01 = (y0 + y1) / 2;
	x32 = (x3 + x2) / 2; y32 = (y3 + y2) / 2;

	/* calc split point */
	xm = (x1 + x2) / 2; ym = (y1 + y2) / 2;
	
	/* calc control points and midpoint */
	c1 = (x01 + xm) / 2; d1 = (y01 + ym) / 2;
	c2 = (x32 + xm) / 2; d2 = (y32 + ym) / 2;
	e = (c1 + c2) / 2; f = (d1 + d2) / 2;

	/* do each side */
	filterCurveToLine(pCurve,nMax,x0,y0,x01,y01,c1,d1,e,f);
	filterCurveToLine(pCurve,nMax,e,f,c2,d2,x32,y32,x3,y3);
}
Beispiel #2
0
void MGClassTester::logFilter(std::string logFileName)
{
	std::string filteredFN = std::string(logFileName) + std::string(".filtered");
	
	FILE *logf = fopen(logFileName.c_str(), "rt");
	if(logf == NULL)
	{
		std::cout << "ERROR: logFilter failed to open log file " << logFileName << std::endl;
		return;
	}
	FILE *filteredlf = fopen(filteredFN.c_str(), "w");
	if(filteredlf == NULL)
	{
		std::cout << "ERROR: logFilter failed to open log file " << filteredFN.c_str() << std::endl;
		return;
	}

	std::cout << "Filtering " << logFileName << " ... ";
	char logLine[MGCLASSTESTER_LOGLINE_MAXLENGTH] = "";
	char *neof = NULL;

	while(true)
	{
		// Read until new line or end of file, whichever happens first..
		neof = fgets(logLine, MGCLASSTESTER_LOGLINE_MAXLENGTH, logf);
		if(neof == NULL)
		{
			break;
		}
		else
		{
			std::string line(logLine);
			std::string infoSubstr(" INFO: ");

			std::size_t foundInfo = line.find(infoSubstr);

			if (foundInfo != std::string::npos)
			{
				// Ignore all info prints - result should not depend on logging settings
			}
			else
			{
				fputs(filterLine(logLine).c_str(), filteredlf);
			}
		}
	}


	if(logf != NULL)
	{
		fclose(logf);
	}

	if(filteredlf != NULL)
	{
		fclose(filteredlf);
	}

	std::cout << "<b>DONE</b><br>" << std::endl;
}