00001 /*====================================================================* 00002 - Copyright (C) 2001 Leptonica. All rights reserved. 00003 - This software is distributed in the hope that it will be 00004 - useful, but with NO WARRANTY OF ANY KIND. 00005 - No author or distributor accepts responsibility to anyone for the 00006 - consequences of using this software, or for whether it serves any 00007 - particular purpose or works at all, unless he or she says so in 00008 - writing. Everyone is granted permission to copy, modify and 00009 - redistribute this source code, for commercial or non-commercial 00010 - purposes, with the following restrictions: (1) the origin of this 00011 - source code must not be misrepresented; (2) modified versions must 00012 - be plainly marked as such; and (3) this notice may not be removed 00013 - or altered from any source or modified source distribution. 00014 *====================================================================*/ 00015 00016 #ifndef LEPTONICA_ARRAY_H 00017 #define LEPTONICA_ARRAY_H 00018 00019 /* 00020 * Contains the following structs: 00021 * struct Numa 00022 * struct Numaa 00023 * struct Numa2d 00024 * struct NumaHash 00025 * struct Sarray 00026 * 00027 * Contains definitions for: 00028 * Numa interpolation flags 00029 */ 00030 00031 00032 /*------------------------------------------------------------------------* 00033 * Array Structs * 00034 *------------------------------------------------------------------------*/ 00035 00036 #define NUMA_VERSION_NUMBER 1 00037 00038 /* Number array: an array of floats */ 00039 struct Numa 00040 { 00041 l_int32 nalloc; /* size of allocated number array */ 00042 l_int32 n; /* number of numbers saved */ 00043 l_int32 refcount; /* reference count (1 if no clones) */ 00044 l_float32 startx; /* x value assigned to array[0] */ 00045 l_float32 delx; /* change in x value as i --> i + 1 */ 00046 l_float32 *array; /* number array */ 00047 }; 00048 typedef struct Numa NUMA; 00049 00050 00051 /* Array of number arrays */ 00052 struct Numaa 00053 { 00054 l_int32 nalloc; /* size of allocated ptr array */ 00055 l_int32 n; /* number of Numa saved */ 00056 struct Numa **numa; /* array of Numa */ 00057 }; 00058 typedef struct Numaa NUMAA; 00059 00060 00061 00062 /* Sparse 2-dimensional array of number arrays */ 00063 struct Numa2d 00064 { 00065 l_int32 nrows; /* number of rows allocated for ptr array */ 00066 l_int32 ncols; /* number of cols allocated for ptr array */ 00067 l_int32 initsize; /* initial size of each numa that is made */ 00068 struct Numa ***numa; /* 2D array of Numa */ 00069 }; 00070 typedef struct Numa2d NUMA2D; 00071 00072 00073 /* A hash table of Numas */ 00074 struct NumaHash 00075 { 00076 l_int32 nbuckets; 00077 l_int32 initsize; /* initial size of each numa that is made */ 00078 struct Numa **numa; 00079 }; 00080 typedef struct NumaHash NUMAHASH; 00081 00082 00083 #define SARRAY_VERSION_NUMBER 1 00084 00085 /* String array: an array of C strings */ 00086 struct Sarray 00087 { 00088 l_int32 nalloc; /* size of allocated ptr array */ 00089 l_int32 n; /* number of strings allocated */ 00090 l_int32 refcount; /* reference count (1 if no clones) */ 00091 char **array; /* string array */ 00092 }; 00093 typedef struct Sarray SARRAY; 00094 00095 00096 /*------------------------------------------------------------------------* 00097 * Array flags * 00098 *------------------------------------------------------------------------*/ 00099 00100 /* Flags for interpolation in Numa */ 00101 enum { 00102 L_LINEAR_INTERP = 1, /* linear */ 00103 L_QUADRATIC_INTERP = 2 /* quadratic */ 00104 }; 00105 00106 00107 #endif /* LEPTONICA_ARRAY_H */