src/graphics.c
PTA  *
generatePtaPolyline(PTA     *ptas,
                    l_int32  width,
                    l_int32  closeflag,
                    l_int32  removedups)
{
l_int32  i, n, x1, y1, x2, y2;
PTA     *ptad, *ptat, *pta;

    PROCNAME("generatePtaPolyline");

    if (!ptas)
        return (PTA *)ERROR_PTR("ptas not defined", procName, NULL);

    n = ptaGetCount(ptas);
    ptat = ptaCreate(0);
    if (n < 2)  /* nothing to do */
        return ptat;

    ptaGetIPt(ptas, 0, &x1, &y1);
    for (i = 1; i < n; i++) {
        ptaGetIPt(ptas, i, &x2, &y2);
        pta = generatePtaWideLine(x1, y1, x2, y2, width);
        ptaJoin(ptat, pta, 0, 0);
        ptaDestroy(&pta);
        x1 = x2;
        y1 = y2;
    }

    if (closeflag) {
        ptaGetIPt(ptas, 0, &x2, &y2);
        pta = generatePtaWideLine(x1, y1, x2, y2, width);
        ptaJoin(ptat, pta, 0, 0);
        ptaDestroy(&pta);
    }

    if (removedups)
        ptad = ptaRemoveDuplicates(ptat, 0);
    else
        ptad = ptaClone(ptat);

    ptaDestroy(&ptat);
    return ptad;
}
/*!
 *  generatePtaPolyline()
 *
 *      Input:  pta (vertices of polyline)
 *              width
 *              closeflag (1 to close the contour; 0 otherwise)
 *              removedups  (1 to remove, 0 to leave)
 *      Return: ptad, or null on error
 *
 *  Notes:
 *      (1) If the boxa has overlapping boxes, and if blending will
 *          be used to give a transparent effect, transparency
 *          artifacts at line intersections can be removed using
 *          removedups = 1.
 */
generatePtaPolyline()
Input:  pta (vertices of polyline)
width
closeflag (1 to close the contour; 0 otherwise)
removedups  (1 to remove, 0 to leave)
Return: ptad, or null on error

(1) If the boxa has overlapping boxes, and if blending will
be used to give a transparent effect, transparency
artifacts at line intersections can be removed using
removedups = 1.
generatePtaPolyline () Input : pta ( vertices of polyline ) width closeflag ( 1 to close the contour ; 0 otherwise ) removedups ( 1 to remove 0 to leave ) Return : ptad or null on error ( 1 ) If the boxa has overlapping boxes and if blending will be used to give a transparent effect transparency artifacts at line intersections can be removed using removedups = 1 .
PTA  *
generatePtaPolyline(PTA     *ptas,
                    l_int32  width,
                    l_int32  closeflag,
                    l_int32  removedups)
{
l_int32  i, n, x1, y1, x2, y2;
PTA     *ptad, *ptat, *pta;
    PROCNAME("generatePtaPolyline");
    if (!ptas)
        return (PTA *)ERROR_PTR("ptas not defined", procName, NULL);
    n = ptaGetCount(ptas);
    ptat = ptaCreate(0);
    if (n < 2)  
        return ptat;
    ptaGetIPt(ptas, 0, &x1, &y1);
    for (i = 1; i < n; i++) {
        ptaGetIPt(ptas, i, &x2, &y2);
        pta = generatePtaWideLine(x1, y1, x2, y2, width);
        ptaJoin(ptat, pta, 0, 0);
        ptaDestroy(&pta);
        x1 = x2;
        y1 = y2;
    }
    if (closeflag) {
        ptaGetIPt(ptas, 0, &x2, &y2);
        pta = generatePtaWideLine(x1, y1, x2, y2, width);
        ptaJoin(ptat, pta, 0, 0);
        ptaDestroy(&pta);
    }
    if (removedups)
        ptad = ptaRemoveDuplicates(ptat, 0);
    else
        ptad = ptaClone(ptat);
    ptaDestroy(&ptat);
    return ptad;
}
PTA * generatePtaPolyline ( PTA * ptas , l_int32 width , l_int32 closeflag , l_int32 removedups ) { l_int32 i , n , x1 , y1 , x2 , y2 ; PTA * ptad , * ptat , * pta ; PROCNAME ( " " ) ; if ( ! ptas ) return ( PTA * ) ERROR_PTR ( " " , procName , NULL ) ; n = ptaGetCount ( ptas ) ; ptat = ptaCreate ( 0 ) ; if ( n < 2 ) return ptat ; ptaGetIPt ( ptas , 0 , & x1 , & y1 ) ; for ( i = 1 ; i < n ; i ++ ) { ptaGetIPt ( ptas , i , & x2 , & y2 ) ; pta = generatePtaWideLine ( x1 , y1 , x2 , y2 , width ) ; ptaJoin ( ptat , pta , 0 , 0 ) ; ptaDestroy ( & pta ) ; x1 = x2 ; y1 = y2 ; } if ( closeflag ) { ptaGetIPt ( ptas , 0 , & x2 , & y2 ) ; pta = generatePtaWideLine ( x1 , y1 , x2 , y2 , width ) ; ptaJoin ( ptat , pta , 0 , 0 ) ; ptaDestroy ( & pta ) ; } if ( removedups ) ptad = ptaRemoveDuplicates ( ptat , 0 ) ; else ptad = ptaClone ( ptat ) ; ptaDestroy ( & ptat ) ; return ptad ; }
generatePtaPolyline()
      Input:  pta (vertices of polyline)
              width
              closeflag (1 to close the contour; 0 otherwise)
              removedups  (1 to remove, 0 to leave)
      Return: ptad, or null on error
generatePtaPolyline () Input : pta ( vertices of polyline ) width closeflag ( 1 to close the contour ; 0 otherwise ) removedups ( 1 to remove 0 to leave ) Return : ptad or null on error
/* nothing to do */