Exemple #1
0
Bool
miCreateETandAET(int count, DDXPointPtr pts, EdgeTable * ET,
                 EdgeTableEntry * AET, EdgeTableEntry * pETEs,
                 ScanLineListBlock * pSLLBlock)
{
    DDXPointPtr top, bottom;
    DDXPointPtr PrevPt, CurrPt;
    int iSLLBlock = 0;

    int dy;

    if (count < 2)
        return TRUE;

    /*
     *  initialize the Active Edge Table
     */
    AET->next = NULL;
    AET->back = NULL;
    AET->nextWETE = NULL;
    AET->bres.minor = MININT;

    /*
     *  initialize the Edge Table.
     */
    ET->scanlines.next = NULL;
    ET->ymax = MININT;
    ET->ymin = MAXINT;
    pSLLBlock->next = NULL;

    PrevPt = &pts[count - 1];

    /*
     *  for each vertex in the array of points.
     *  In this loop we are dealing with two vertices at
     *  a time -- these make up one edge of the polygon.
     */
    while (count--) {
        CurrPt = pts++;

        /*
         *  find out which point is above and which is below.
         */
        if (PrevPt->y > CurrPt->y) {
            bottom = PrevPt, top = CurrPt;
            pETEs->ClockWise = 0;
        }
        else {
            bottom = CurrPt, top = PrevPt;
            pETEs->ClockWise = 1;
        }

        /*
         * don't add horizontal edges to the Edge table.
         */
        if (bottom->y != top->y) {
            pETEs->ymax = bottom->y - 1;        /* -1 so we don't get last scanline */

            /*
             *  initialize integer edge algorithm
             */
            dy = bottom->y - top->y;
            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);

            if (!miInsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock)) {
                miFreeStorage(pSLLBlock->next);
                return FALSE;
            }

            ET->ymax = max(ET->ymax, PrevPt->y);
            ET->ymin = min(ET->ymin, PrevPt->y);
            pETEs++;
        }

        PrevPt = CurrPt;
    }
    return TRUE;
}
Exemple #2
0
static void
CreateETandAET(
    register int count,
    register XPoint *pts,
    EdgeTable *ET,
    EdgeTableEntry *AET,
    register EdgeTableEntry *pETEs,
    ScanLineListBlock   *pSLLBlock)
{
    register XPoint *top, *bottom;
    register XPoint *PrevPt, *CurrPt;
    int iSLLBlock = 0;
    int dy;

    if (count < 2)  return;

    /*
     *  initialize the Active Edge Table
     */
    AET->next = (EdgeTableEntry *)NULL;
    AET->back = (EdgeTableEntry *)NULL;
    AET->nextWETE = (EdgeTableEntry *)NULL;
    AET->bres.minor_axis = SMALL_COORDINATE;

    /*
     *  initialize the Edge Table.
     */
    ET->scanlines.next = (ScanLineList *)NULL;
    ET->ymax = SMALL_COORDINATE;
    ET->ymin = LARGE_COORDINATE;
    pSLLBlock->next = (ScanLineListBlock *)NULL;

    PrevPt = &pts[count-1];

    /*
     *  for each vertex in the array of points.
     *  In this loop we are dealing with two vertices at
     *  a time -- these make up one edge of the polygon.
     */
    while (count--)
    {
        CurrPt = pts++;

        /*
         *  find out which point is above and which is below.
         */
        if (PrevPt->y > CurrPt->y)
        {
            bottom = PrevPt, top = CurrPt;
            pETEs->ClockWise = 0;
        }
        else
        {
            bottom = CurrPt, top = PrevPt;
            pETEs->ClockWise = 1;
        }

        /*
         * don't add horizontal edges to the Edge table.
         */
        if (bottom->y != top->y)
        {
            pETEs->ymax = bottom->y-1;  /* -1 so we don't get last scanline */

            /*
             *  initialize integer edge algorithm
             */
            dy = bottom->y - top->y;
            BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);

            InsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock);

	    if (PrevPt->y > ET->ymax)
		ET->ymax = PrevPt->y;
	    if (PrevPt->y < ET->ymin)
		ET->ymin = PrevPt->y;
            pETEs++;
        }

        PrevPt = CurrPt;
    }
}
Exemple #3
0
//______________________________________________________________________________
static void CreateETandAET(int count, TPoint *pts, EdgeTable *ET, EdgeTableEntry *AET,
                           EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock)
{
   //     This routine creates the edge table for
   //     scan converting polygons. 
   //     The Edge Table (ET) looks like:
   //
   //    EdgeTable
   //     --------
   //    |  ymax  |        ScanLineLists
   //    |scanline|-->------------>-------------->...
   //     --------   |scanline|   |scanline|
   //                |edgelist|   |edgelist|
   //                ---------    ---------
   //                    |             |
   //                    |             |
   //                    V             V
   //              list of ETEs   list of ETEs
   //
   //     where ETE is an EdgeTableEntry data structure,
   //     and there is one ScanLineList per scanline at
   //     which an edge is initially entered.

   TPoint *top, *bottom;
   TPoint *PrevPt, *CurrPt;
   int iSLLBlock = 0;
   int dy;

   if (count < 2)  return;

    /*
     *  initialize the Active Edge Table
     */
   AET->next = (EdgeTableEntry *)0;
   AET->back = (EdgeTableEntry *)0;
   AET->nextWETE = (EdgeTableEntry *)0;
   AET->bres.minor_axis = SMALL_COORDINATE;

    /*
     *  initialize the Edge Table.
     */
   ET->scanlines.next = (ScanLineList *)0;
   ET->ymax = SMALL_COORDINATE;
   ET->ymin = LARGE_COORDINATE;
   pSLLBlock->next = (ScanLineListBlock *)0;

   PrevPt = &pts[count-1];

    /*
     *  for each vertex in the array of points.
     *  In this loop we are dealing with two vertices at
     *  a time -- these make up one edge of the polygon.
     */
   while (count--) {
      CurrPt = pts++;

        /*
         *  find out which point is above and which is below.
         */
      if (PrevPt->fY > CurrPt->fY) {
         bottom = PrevPt, top = CurrPt;
         pETEs->ClockWise = 0;
      } else {
         bottom = CurrPt, top = PrevPt;
         pETEs->ClockWise = 1;
      }

        /*
         * don't add horizontal edges to the Edge table.
         */
      if (bottom->fY != top->fY) {
         pETEs->ymax = bottom->fY-1;  /* -1 so we don't get last scanline */

            /*
             *  initialize integer edge algorithm
             */
         dy = bottom->fY - top->fY;
         BRESINITPGONSTRUCT(dy, top->fX, bottom->fX, pETEs->bres);

         InsertEdgeInET(ET, pETEs, top->fY, &pSLLBlock, &iSLLBlock);

	      if (PrevPt->fY > ET->ymax) ET->ymax = PrevPt->fY;
	      if (PrevPt->fY < ET->ymin) ET->ymin = PrevPt->fY;
         pETEs++;
      }
      PrevPt = CurrPt;
   }
}