MCPcopy Create free account
hub / github.com/creatale/node-dv / sarrayMakeWplsCode

Function sarrayMakeWplsCode

deps/leptonica/src/fmorphauto.c:674–750  ·  view source on GitHub ↗

--------------------------------------------------------------------------* * Helper code for sel * *--------------------------------------------------------------------------*/ ! * \brief sarrayMakeWplsCode() */

Source from the content-addressed store, hash-verified

672 * \brief sarrayMakeWplsCode()
673 */
674static SARRAY *
675sarrayMakeWplsCode(SEL *sel)
676{
677char emptystring[] = "";
678l_int32 i, j, ymax, dely, allvshifts;
679l_int32 vshift[32];
680SARRAY *sa;
681
682 PROCNAME("sarrayMakeWplsCode");
683
684 if (!sel)
685 return (SARRAY *)ERROR_PTR("sel not defined", procName, NULL);
686
687 for (i = 0; i < 32; i++)
688 vshift[i] = 0;
689 ymax = 0;
690 for (i = 0; i < sel->sy; i++) {
691 for (j = 0; j < sel->sx; j++) {
692 if (sel->data[i][j] == 1) {
693 dely = L_ABS(i - sel->cy);
694 if (dely < 32)
695 vshift[dely] = 1;
696 ymax = L_MAX(ymax, dely);
697 }
698 }
699 }
700 if (ymax > 31) {
701 L_WARNING("ymax > 31; truncating to 31\n", procName);
702 ymax = 31;
703 }
704
705 /* Test if this is a vertical brick */
706 allvshifts = TRUE;
707 for (i = 0; i < ymax; i++) {
708 if (vshift[i] == 0) {
709 allvshifts = FALSE;
710 break;
711 }
712 }
713
714 sa = sarrayCreate(0);
715
716 /* Add declarations */
717 if (allvshifts == TRUE) { /* packs them as well as possible */
718 if (ymax > 4)
719 sarrayAddString(sa, wpldecls[2], L_COPY);
720 if (ymax > 8)
721 sarrayAddString(sa, wpldecls[6], L_COPY);
722 if (ymax > 12)
723 sarrayAddString(sa, wpldecls[10], L_COPY);
724 if (ymax > 16)
725 sarrayAddString(sa, wpldecls[14], L_COPY);
726 if (ymax > 20)
727 sarrayAddString(sa, wpldecls[18], L_COPY);
728 if (ymax > 24)
729 sarrayAddString(sa, wpldecls[22], L_COPY);
730 if (ymax > 28)
731 sarrayAddString(sa, wpldecls[26], L_COPY);

Callers 1

fmorphautogen2Function · 0.70

Calls 2

sarrayCreateFunction · 0.85
sarrayAddStringFunction · 0.85

Tested by

no test coverage detected