|
| 1 | +/*====================================================================* |
| 2 | + - Copyright (C) 2001 Leptonica. All rights reserved. |
| 3 | + - |
| 4 | + - Redistribution and use in source and binary forms, with or without |
| 5 | + - modification, are permitted provided that the following conditions |
| 6 | + - are met: |
| 7 | + - 1. Redistributions of source code must retain the above copyright |
| 8 | + - notice, this list of conditions and the following disclaimer. |
| 9 | + - 2. Redistributions in binary form must reproduce the above |
| 10 | + - copyright notice, this list of conditions and the following |
| 11 | + - disclaimer in the documentation and/or other materials |
| 12 | + - provided with the distribution. |
| 13 | + - |
| 14 | + - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 15 | + - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 16 | + - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 17 | + - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY |
| 18 | + - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 | + - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 | + - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 | + - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 | + - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 23 | + - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 24 | + - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 | + *====================================================================*/ |
| 26 | + |
| 27 | +#ifndef LEPTONICA_ARRAY_H |
| 28 | +#define LEPTONICA_ARRAY_H |
| 29 | + |
| 30 | +/* |
| 31 | + * Contains the following structs: |
| 32 | + * struct Numa |
| 33 | + * struct Numaa |
| 34 | + * struct L_Dna |
| 35 | + * struct L_Dnaa |
| 36 | + * struct L_DnaHash |
| 37 | + * struct Sarray |
| 38 | + * struct L_Bytea |
| 39 | + * |
| 40 | + * Contains definitions for: |
| 41 | + * Numa interpolation flags |
| 42 | + * Numa and FPix border flags |
| 43 | + * Numa data type conversion to string |
| 44 | + */ |
| 45 | + |
| 46 | + |
| 47 | +/*------------------------------------------------------------------------* |
| 48 | + * Array Structs * |
| 49 | + *------------------------------------------------------------------------*/ |
| 50 | + |
| 51 | +#define NUMA_VERSION_NUMBER 1 |
| 52 | + |
| 53 | + /* Number array: an array of floats */ |
| 54 | +struct Numa |
| 55 | +{ |
| 56 | + l_int32 nalloc; /* size of allocated number array */ |
| 57 | + l_int32 n; /* number of numbers saved */ |
| 58 | + l_int32 refcount; /* reference count (1 if no clones) */ |
| 59 | + l_float32 startx; /* x value assigned to array[0] */ |
| 60 | + l_float32 delx; /* change in x value as i --> i + 1 */ |
| 61 | + l_float32 *array; /* number array */ |
| 62 | +}; |
| 63 | +typedef struct Numa NUMA; |
| 64 | + |
| 65 | + /* Array of number arrays */ |
| 66 | +struct Numaa |
| 67 | +{ |
| 68 | + l_int32 nalloc; /* size of allocated ptr array */ |
| 69 | + l_int32 n; /* number of Numa saved */ |
| 70 | + struct Numa **numa; /* array of Numa */ |
| 71 | +}; |
| 72 | +typedef struct Numaa NUMAA; |
| 73 | + |
| 74 | +#define DNA_VERSION_NUMBER 1 |
| 75 | + |
| 76 | + /* Double number array: an array of doubles */ |
| 77 | +struct L_Dna |
| 78 | +{ |
| 79 | + l_int32 nalloc; /* size of allocated number array */ |
| 80 | + l_int32 n; /* number of numbers saved */ |
| 81 | + l_int32 refcount; /* reference count (1 if no clones) */ |
| 82 | + l_float64 startx; /* x value assigned to array[0] */ |
| 83 | + l_float64 delx; /* change in x value as i --> i + 1 */ |
| 84 | + l_float64 *array; /* number array */ |
| 85 | +}; |
| 86 | +typedef struct L_Dna L_DNA; |
| 87 | + |
| 88 | + /* Array of double number arrays */ |
| 89 | +struct L_Dnaa |
| 90 | +{ |
| 91 | + l_int32 nalloc; /* size of allocated ptr array */ |
| 92 | + l_int32 n; /* number of L_Dna saved */ |
| 93 | + struct L_Dna **dna; /* array of L_Dna */ |
| 94 | +}; |
| 95 | +typedef struct L_Dnaa L_DNAA; |
| 96 | + |
| 97 | + /* A hash table of Dnas */ |
| 98 | +struct L_DnaHash |
| 99 | +{ |
| 100 | + l_int32 nbuckets; |
| 101 | + l_int32 initsize; /* initial size of each dna that is made */ |
| 102 | + struct L_Dna **dna; |
| 103 | +}; |
| 104 | +typedef struct L_DnaHash L_DNAHASH; |
| 105 | + |
| 106 | +#define SARRAY_VERSION_NUMBER 1 |
| 107 | + |
| 108 | + /* String array: an array of C strings */ |
| 109 | +struct Sarray |
| 110 | +{ |
| 111 | + l_int32 nalloc; /* size of allocated ptr array */ |
| 112 | + l_int32 n; /* number of strings allocated */ |
| 113 | + l_int32 refcount; /* reference count (1 if no clones) */ |
| 114 | + char **array; /* string array */ |
| 115 | +}; |
| 116 | +typedef struct Sarray SARRAY; |
| 117 | + |
| 118 | + /* Byte array (analogous to C++ "string") */ |
| 119 | +struct L_Bytea |
| 120 | +{ |
| 121 | + size_t nalloc; /* number of bytes allocated in data array */ |
| 122 | + size_t size; /* number of bytes presently used */ |
| 123 | + l_int32 refcount; /* reference count (1 if no clones) */ |
| 124 | + l_uint8 *data; /* data array */ |
| 125 | +}; |
| 126 | +typedef struct L_Bytea L_BYTEA; |
| 127 | + |
| 128 | + |
| 129 | +/*------------------------------------------------------------------------* |
| 130 | + * Array flags * |
| 131 | + *------------------------------------------------------------------------*/ |
| 132 | + /* Flags for interpolation in Numa */ |
| 133 | +enum { |
| 134 | + L_LINEAR_INTERP = 1, /* linear */ |
| 135 | + L_QUADRATIC_INTERP = 2 /* quadratic */ |
| 136 | +}; |
| 137 | + |
| 138 | + /* Flags for added borders in Numa and Fpix */ |
| 139 | +enum { |
| 140 | + L_CONTINUED_BORDER = 1, /* extended with same value */ |
| 141 | + L_SLOPE_BORDER = 2, /* extended with constant normal derivative */ |
| 142 | + L_MIRRORED_BORDER = 3 /* mirrored */ |
| 143 | +}; |
| 144 | + |
| 145 | + /* Flags for data type converted from Numa */ |
| 146 | +enum { |
| 147 | + L_INTEGER_VALUE = 1, /* convert to integer */ |
| 148 | + L_FLOAT_VALUE = 2 /* convert to float */ |
| 149 | +}; |
| 150 | + |
| 151 | + |
| 152 | +#endif /* LEPTONICA_ARRAY_H */ |
0 commit comments