Beispiel #1
0
void DrawRealHorzPictureLine(LPOINT Point1, LPOINT Point2, int nWidth)
{
    int y1, y2;
    int x, y;
    int nHalfWidth = MAX(1, nWidth / 2);
    int dx, dy;
    LPOINT LocalBegin, LocalEnd;

    // грубо говоря -- если ординаты совпадают с точностью до 16 точек,
    // то "заметаем" линию горизонтальным интервалом сжатой(/16) толщины
    // (но не менее единичной, есно)
    if (XY_COMPRESS(Point1.y) == XY_COMPRESS(Point2.y)) {
        y1 = XY_COMPRESS(MIN(Point1.y, Point2.y) - nHalfWidth) - nExtension;
        y2 = XY_COMPRESS(MAX(Point1.y, Point2.y) + nHalfWidth) + nExtension;

        for (y = y1; y <= y2; y++) {
            fDrawMatrixPictureHorzInterval(y, XY_COMPRESS(Point1.x),
                                           XY_COMPRESS(Point2.x));
        }

        return;
    }

    // else "if (XY_COMPRESS (Point1.y) != XY_COMPRESS (Point2.y))" :
    if (Point1.x > Point2.x) {
        EXCHANGE_INTS(Point1.x, Point2.x);
        EXCHANGE_INTS(Point1.y, Point2.y);
    }

    dx = Point2.x - Point1.x;
    dy = Point2.y - Point1.y;
    LocalEnd.x = XY_UNCOMPRESS(XY_COMPRESS(Point1.x));
#ifndef NO_GEORGE
    //LocalEnd.y = Point1.y + LocalEnd.x * dy / dx;
    LocalEnd.y = Point1.y; //George
    // грубо говоря, закрашивание происходит
    // по каждому вертикальному интервалу
#else
    LocalEnd.y = Point1.y + LocalEnd.x * dy / dx;
#endif

    for (x = LocalEnd.x; x <= Point2.x; x += PAGE_COMP_FACTOR) {
        LocalBegin = LocalEnd;
        LocalEnd.x += PAGE_COMP_FACTOR;
#ifndef NO_GEORGE
        //LocalEnd.y = Point1.y + LocalEnd.x * dy / dx;
        LocalEnd.y = Point1.y + (LocalEnd.x - LocalBegin.x) * dy / dx; //George
        // в общем, при Point1.x=0 это было бы честным закрашиванием парралелограмма.
        // теперь это оно же, но поднятое на высоту, на которую линия бы поднялась
        // в точке Point1.x, выходя из нуля (то есть, в общем, то самое Point1.x * dy/dx)
#else
        LocalEnd.y = Point1.y + LocalEnd.x * dy / dx;
#endif
        y1 = XY_COMPRESS(MIN(LocalBegin.y, LocalEnd.y) - nHalfWidth)
             - nExtension;
        y2 = XY_COMPRESS(MAX(LocalBegin.y, LocalEnd.y) + nHalfWidth)
             + nExtension;
        fDrawMatrixPictureVertInterval(XY_COMPRESS(x), y1, y2);
    }
}
Beispiel #2
0
void DrawMatrixPictureRectangle(RECTANGLE r)
{
    int y;

    if (r.yTop > r.yBottom)
        EXCHANGE_INTS(r.yTop, r.yBottom);

    if (r.xLeft > r.xRight)
        EXCHANGE_INTS(r.xLeft, r.xRight);

    for (y = r.yTop; y <= r.yBottom; y++)
        fDrawMatrixPictureHorzInterval(y, r.xLeft, r.xRight);
}
Beispiel #3
0
void RemoveMatrixPictureVertInterval(int x, int y1, int y2)
{
    uchar *p, *pBegin, *pEnd;

    if (x < 0 || x >= PAGE_MATRIX_WIDTH)
        return;

    if (y1 > y2)
        EXCHANGE_INTS(y1, y2);

    if (y1 >= PAGE_MATRIX_HEIGHT)
        return;

    if (y1 < 0)
        y1 = 0;

    if (y2 >= PAGE_MATRIX_HEIGHT)
        y2 = PAGE_MATRIX_HEIGHT - 1;

    pBegin = PageMatrix + (y1 << PAGE_MATRIX_WIDTH_SHIFT) + x;
    pEnd = PageMatrix + (y2 << PAGE_MATRIX_WIDTH_SHIFT) + x;

    for (p = pBegin; p <= pEnd; p += PAGE_MATRIX_WIDTH)
        * p &= ~PMC_PICTURE;
}
Beispiel #4
0
void RemoveMatrixPictureHorzInterval(int y, int x1, int x2)
{
    uchar *p, *pBegin, *pEnd;

    if (y < 0 || y >= PAGE_MATRIX_HEIGHT)
        return;

    if (x1 > x2)
        EXCHANGE_INTS(x1, x2);

    if (x1 >= PAGE_MATRIX_WIDTH)
        return;

    if (x1 < 0)
        x1 = 0;

    if (x2 >= PAGE_MATRIX_WIDTH)
        x2 = PAGE_MATRIX_WIDTH - 1;

    pBegin = PageMatrix + (y << PAGE_MATRIX_WIDTH_SHIFT) + x1;
    pEnd = PageMatrix + (y << PAGE_MATRIX_WIDTH_SHIFT) + x2;

    for (p = pBegin; p <= pEnd; p++)
        *p &= ~PMC_PICTURE;
}
Beispiel #5
0
void RootStripsGetLoopParameters(int yTop, int yBottom, ROOT **ppBegin,
		ROOT **ppAfter) {
	int iStripBegin;
	int iStripEnd;
	ROOT *pBegin;
	ROOT *pEnd;
	int iStrip;

	if (nRootStripsStep == 0)
		ErrorInternal((char *) "nRootStripsStep == 0");

	iStripBegin = (yTop - nRootStripsOffset) / nRootStripsStep;

	iStripEnd = (yBottom - nRootStripsOffset) / nRootStripsStep;

	if (iStripBegin < 0)
		iStripBegin = 0;
	if (iStripEnd < 0)
		iStripEnd = 0;
	if (iStripBegin >= nRootStrips)
		iStripBegin = nRootStrips - 1;
	if (iStripEnd >= nRootStrips)
		iStripEnd = nRootStrips - 1;

	if (iStripBegin > iStripEnd)
		EXCHANGE_INTS(iStripBegin, iStripEnd);

	pBegin = NULL;
	pEnd = NULL;

	for (iStrip = iStripBegin; iStrip <= iStripEnd; iStrip++) {
		if (pRootStrips[iStrip].pBegin == NULL)
			continue;

		if (pBegin == NULL) {
			pBegin = pRootStrips[iStrip].pBegin;
			pEnd = pRootStrips[iStrip].pEnd;
		} else {
			if (pRootStrips[iStrip].pBegin < pBegin)
				pBegin = pRootStrips[iStrip].pBegin;

			if (pRootStrips[iStrip].pEnd > pEnd)
				pEnd = pRootStrips[iStrip].pEnd;
		}
	}

	if ((pBegin == NULL) != (pEnd == NULL))
		ErrorInternal((char *) "(pBegin == NULL) != (pEnd == NULL)");

	if (pBegin == NULL) {
		*ppBegin = NULL;
		*ppAfter = NULL;
	} else {
		*ppBegin = pBegin;
		*ppAfter = pEnd + 1;
	}
}
Beispiel #6
0
Bool HorizontalBreakingCondition (BLOCK *p, int iBegin, int iEnd)
{
    int i;
    int x1, x2, y;
    int nLength;

    /* Regular case */

    if ((iEnd - iBegin + 1) * 4 >=  p -> nAverageHeight * 5)
        return (TRUE);
//    if ((iEnd - iBegin + 1) >=  p -> nAverageHeight * 5) // Piter
//        return (TRUE);

    /* Irregular case: space and line */

    if ((iEnd - iBegin + 1) * 4 <   p -> nAverageHeight * 3)
        return (FALSE);

    for (i = 0; i < nSeps; i++)
    {
        if (pSeps [i].Type != SEP_HORZ)
            continue;

        x1 = pSeps [i].xBegin;
        x2 = pSeps [i].xEnd;

        if (x1 > x2)
            EXCHANGE_INTS (x1, x2);

        y  = (pSeps [i].yBegin + pSeps [i].yEnd) / 2;

        if (y  < p -> Rect.yTop  + iBegin ||
            y  > p -> Rect.yTop  + iEnd   ||
            x1 > p -> Rect.xRight         ||
            x2 < p -> Rect.xLeft)
        {
            continue;
        }

        nLength = MIN (x2, p -> Rect.xRight) - MAX (x1, p -> Rect.xLeft);

        if (nLength > (p -> Rect.xRight - p -> Rect.xLeft + 1) * 2 / 3)
            return (TRUE);
    }

    return (FALSE);
}