src/boxbasic.c
BOX *
boxaGetValidBox(BOXA    *boxa,
                l_int32  index,
                l_int32  accessflag)
{
l_int32  w, h;
BOX     *box;

    PROCNAME("boxaGetValidBox");

    if (!boxa)
        return (BOX *)ERROR_PTR("boxa not defined", procName, NULL);

    if ((box = boxaGetBox(boxa, index, accessflag)) == NULL)
        return (BOX *)ERROR_PTR("box not returned", procName, NULL);
    boxGetGeometry(box, NULL, NULL, &w, &h);
    if (w <= 0 || h <= 0)  /* not valid, but not necessarily an error */
        boxDestroy(&box);
    return box;
}
/*!
 *  boxaGetValidBox()
 *
 *      Input:  boxa
 *              index  (to the index-th box)
 *              accessflag  (L_COPY or L_CLONE)
 *      Return: box, or null if box is not valid or on error
 *
 *  Notes:
 *      (1) This returns NULL for an invalid box in a boxa.
 *          For a box to be valid, both the width and height must be > 0.
 *      (2) We allow invalid boxes, with w = 0 or h = 0, as placeholders
 *          in boxa for which the index of the box in the boxa is important.
 *          This is an atypical situation; usually you want to put only
 *          valid boxes in a boxa.
 */
boxaGetValidBox()
Input:  boxa
index  (to the index-th box)
accessflag  (L_COPY or L_CLONE)
Return: box, or null if box is not valid or on error

(1) This returns NULL for an invalid box in a boxa.
For a box to be valid, both the width and height must be > 0.
(2) We allow invalid boxes, with w = 0 or h = 0, as placeholders
in boxa for which the index of the box in the boxa is important.
This is an atypical situation; usually you want to put only
valid boxes in a boxa.
boxaGetValidBox () Input : boxa index ( to the index - th box ) accessflag ( L_COPY or L_CLONE ) Return : box or null if box is not valid or on error ( 1 ) This returns NULL for an invalid box in a boxa . For a box to be valid both the width and height must be > 0 . ( 2 ) We allow invalid boxes with w = 0 or h = 0 as placeholders in boxa for which the index of the box in the boxa is important . This is an atypical situation ; usually you want to put only valid boxes in a boxa .
BOX *
boxaGetValidBox(BOXA    *boxa,
                l_int32  index,
                l_int32  accessflag)
{
l_int32  w, h;
BOX     *box;
    PROCNAME("boxaGetValidBox");
    if (!boxa)
        return (BOX *)ERROR_PTR("boxa not defined", procName, NULL);
    if ((box = boxaGetBox(boxa, index, accessflag)) == NULL)
        return (BOX *)ERROR_PTR("box not returned", procName, NULL);
    boxGetGeometry(box, NULL, NULL, &w, &h);
    if (w <= 0 || h <= 0)  
        boxDestroy(&box);
    return box;
}
BOX * boxaGetValidBox ( BOXA * boxa , l_int32 index , l_int32 accessflag ) { l_int32 w , h ; BOX * box ; PROCNAME ( " " ) ; if ( ! boxa ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; if ( ( box = boxaGetBox ( boxa , index , accessflag ) ) == NULL ) return ( BOX * ) ERROR_PTR ( " " , procName , NULL ) ; boxGetGeometry ( box , NULL , NULL , & w , & h ) ; if ( w <= 0 || h <= 0 ) boxDestroy ( & box ) ; return box ; }
boxaGetValidBox()
      Input:  boxa
              index  (to the index-th box)
              accessflag  (L_COPY or L_CLONE)
      Return: box, or null if box is not valid or on error
boxaGetValidBox () Input : boxa index ( to the index - th box ) accessflag ( L_COPY or L_CLONE ) Return : box or null if box is not valid or on error
/* not valid, but not necessarily an error */