tesseract_bin 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (612) hide show
  1. data/.document +5 -0
  2. data/Gemfile +14 -0
  3. data/Gemfile.lock +23 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +19 -0
  6. data/Rakefile +46 -0
  7. data/VERSION +1 -0
  8. data/ext/tesseract_bin/extconf.rb +17 -0
  9. data/lib/tesseract_bin.rb +12 -0
  10. data/tesseract_bin.gemspec +660 -0
  11. data/test/helper.rb +18 -0
  12. data/test/test_tesseract_bin.rb +7 -0
  13. data/vendor/tesseract-2.04/AUTHORS +8 -0
  14. data/vendor/tesseract-2.04/COPYING +23 -0
  15. data/vendor/tesseract-2.04/ChangeLog +71 -0
  16. data/vendor/tesseract-2.04/INSTALL +229 -0
  17. data/vendor/tesseract-2.04/Makefile.am +20 -0
  18. data/vendor/tesseract-2.04/Makefile.in +641 -0
  19. data/vendor/tesseract-2.04/NEWS +1 -0
  20. data/vendor/tesseract-2.04/README +138 -0
  21. data/vendor/tesseract-2.04/ReleaseNotes +213 -0
  22. data/vendor/tesseract-2.04/StdAfx.cpp +8 -0
  23. data/vendor/tesseract-2.04/StdAfx.h +24 -0
  24. data/vendor/tesseract-2.04/ccmain/Makefile.am +63 -0
  25. data/vendor/tesseract-2.04/ccmain/Makefile.in +735 -0
  26. data/vendor/tesseract-2.04/ccmain/adaptions.cpp +1082 -0
  27. data/vendor/tesseract-2.04/ccmain/adaptions.h +109 -0
  28. data/vendor/tesseract-2.04/ccmain/applybox.cpp +891 -0
  29. data/vendor/tesseract-2.04/ccmain/applybox.h +73 -0
  30. data/vendor/tesseract-2.04/ccmain/baseapi.cpp +1105 -0
  31. data/vendor/tesseract-2.04/ccmain/baseapi.h +256 -0
  32. data/vendor/tesseract-2.04/ccmain/blobcmp.cpp +76 -0
  33. data/vendor/tesseract-2.04/ccmain/blobcmp.h +29 -0
  34. data/vendor/tesseract-2.04/ccmain/callnet.cpp +93 -0
  35. data/vendor/tesseract-2.04/ccmain/callnet.h +32 -0
  36. data/vendor/tesseract-2.04/ccmain/charcut.cpp +704 -0
  37. data/vendor/tesseract-2.04/ccmain/charcut.h +120 -0
  38. data/vendor/tesseract-2.04/ccmain/charsample.cpp +699 -0
  39. data/vendor/tesseract-2.04/ccmain/control.cpp +1842 -0
  40. data/vendor/tesseract-2.04/ccmain/control.h +198 -0
  41. data/vendor/tesseract-2.04/ccmain/docqual.cpp +1481 -0
  42. data/vendor/tesseract-2.04/ccmain/docqual.h +155 -0
  43. data/vendor/tesseract-2.04/ccmain/expandblob.cpp +82 -0
  44. data/vendor/tesseract-2.04/ccmain/expandblob.h +13 -0
  45. data/vendor/tesseract-2.04/ccmain/fixspace.cpp +989 -0
  46. data/vendor/tesseract-2.04/ccmain/fixspace.h +72 -0
  47. data/vendor/tesseract-2.04/ccmain/fixxht.cpp +825 -0
  48. data/vendor/tesseract-2.04/ccmain/fixxht.h +93 -0
  49. data/vendor/tesseract-2.04/ccmain/imgscale.cpp +154 -0
  50. data/vendor/tesseract-2.04/ccmain/imgscale.h +32 -0
  51. data/vendor/tesseract-2.04/ccmain/matmatch.cpp +391 -0
  52. data/vendor/tesseract-2.04/ccmain/matmatch.h +48 -0
  53. data/vendor/tesseract-2.04/ccmain/output.cpp +1273 -0
  54. data/vendor/tesseract-2.04/ccmain/output.h +116 -0
  55. data/vendor/tesseract-2.04/ccmain/pagewalk.cpp +666 -0
  56. data/vendor/tesseract-2.04/ccmain/pagewalk.h +155 -0
  57. data/vendor/tesseract-2.04/ccmain/paircmp.cpp +107 -0
  58. data/vendor/tesseract-2.04/ccmain/paircmp.h +43 -0
  59. data/vendor/tesseract-2.04/ccmain/pgedit.cpp +1867 -0
  60. data/vendor/tesseract-2.04/ccmain/pgedit.h +181 -0
  61. data/vendor/tesseract-2.04/ccmain/reject.cpp +1775 -0
  62. data/vendor/tesseract-2.04/ccmain/reject.h +181 -0
  63. data/vendor/tesseract-2.04/ccmain/scaleimg.cpp +366 -0
  64. data/vendor/tesseract-2.04/ccmain/scaleimg.h +35 -0
  65. data/vendor/tesseract-2.04/ccmain/tessbox.cpp +375 -0
  66. data/vendor/tesseract-2.04/ccmain/tessbox.h +110 -0
  67. data/vendor/tesseract-2.04/ccmain/tessedit.cpp +278 -0
  68. data/vendor/tesseract-2.04/ccmain/tessedit.h +49 -0
  69. data/vendor/tesseract-2.04/ccmain/tessembedded.cpp +110 -0
  70. data/vendor/tesseract-2.04/ccmain/tessembedded.h +38 -0
  71. data/vendor/tesseract-2.04/ccmain/tesseractfull.cc +37 -0
  72. data/vendor/tesseract-2.04/ccmain/tesseractmain.cpp +387 -0
  73. data/vendor/tesseract-2.04/ccmain/tesseractmain.h +58 -0
  74. data/vendor/tesseract-2.04/ccmain/tessio.h +110 -0
  75. data/vendor/tesseract-2.04/ccmain/tessvars.cpp +38 -0
  76. data/vendor/tesseract-2.04/ccmain/tessvars.h +48 -0
  77. data/vendor/tesseract-2.04/ccmain/tfacep.h +62 -0
  78. data/vendor/tesseract-2.04/ccmain/tfacepp.cpp +443 -0
  79. data/vendor/tesseract-2.04/ccmain/tfacepp.h +85 -0
  80. data/vendor/tesseract-2.04/ccmain/tstruct.cpp +549 -0
  81. data/vendor/tesseract-2.04/ccmain/tstruct.h +108 -0
  82. data/vendor/tesseract-2.04/ccmain/varabled.cpp +346 -0
  83. data/vendor/tesseract-2.04/ccmain/varabled.h +125 -0
  84. data/vendor/tesseract-2.04/ccmain/werdit.cpp +193 -0
  85. data/vendor/tesseract-2.04/ccmain/werdit.h +67 -0
  86. data/vendor/tesseract-2.04/ccstruct/Makefile.am +25 -0
  87. data/vendor/tesseract-2.04/ccstruct/Makefile.in +650 -0
  88. data/vendor/tesseract-2.04/ccstruct/blckerr.h +29 -0
  89. data/vendor/tesseract-2.04/ccstruct/blobbox.cpp +778 -0
  90. data/vendor/tesseract-2.04/ccstruct/blobbox.h +381 -0
  91. data/vendor/tesseract-2.04/ccstruct/blobs.cpp +247 -0
  92. data/vendor/tesseract-2.04/ccstruct/blobs.h +119 -0
  93. data/vendor/tesseract-2.04/ccstruct/blread.cpp +537 -0
  94. data/vendor/tesseract-2.04/ccstruct/blread.h +63 -0
  95. data/vendor/tesseract-2.04/ccstruct/callcpp.cpp +252 -0
  96. data/vendor/tesseract-2.04/ccstruct/coutln.cpp +650 -0
  97. data/vendor/tesseract-2.04/ccstruct/coutln.h +186 -0
  98. data/vendor/tesseract-2.04/ccstruct/crakedge.h +39 -0
  99. data/vendor/tesseract-2.04/ccstruct/genblob.cpp +133 -0
  100. data/vendor/tesseract-2.04/ccstruct/genblob.h +52 -0
  101. data/vendor/tesseract-2.04/ccstruct/hpddef.h +39 -0
  102. data/vendor/tesseract-2.04/ccstruct/hpdsizes.h +8 -0
  103. data/vendor/tesseract-2.04/ccstruct/ipoints.h +479 -0
  104. data/vendor/tesseract-2.04/ccstruct/labls.cpp +188 -0
  105. data/vendor/tesseract-2.04/ccstruct/labls.h +38 -0
  106. data/vendor/tesseract-2.04/ccstruct/linlsq.cpp +249 -0
  107. data/vendor/tesseract-2.04/ccstruct/linlsq.h +102 -0
  108. data/vendor/tesseract-2.04/ccstruct/lmedsq.cpp +453 -0
  109. data/vendor/tesseract-2.04/ccstruct/lmedsq.h +84 -0
  110. data/vendor/tesseract-2.04/ccstruct/mod128.cpp +100 -0
  111. data/vendor/tesseract-2.04/ccstruct/mod128.h +85 -0
  112. data/vendor/tesseract-2.04/ccstruct/normalis.cpp +176 -0
  113. data/vendor/tesseract-2.04/ccstruct/normalis.h +108 -0
  114. data/vendor/tesseract-2.04/ccstruct/ocrblock.cpp +369 -0
  115. data/vendor/tesseract-2.04/ccstruct/ocrblock.h +235 -0
  116. data/vendor/tesseract-2.04/ccstruct/ocrrow.cpp +216 -0
  117. data/vendor/tesseract-2.04/ccstruct/ocrrow.h +133 -0
  118. data/vendor/tesseract-2.04/ccstruct/pageblk.cpp +879 -0
  119. data/vendor/tesseract-2.04/ccstruct/pageblk.h +318 -0
  120. data/vendor/tesseract-2.04/ccstruct/pageres.cpp +330 -0
  121. data/vendor/tesseract-2.04/ccstruct/pageres.h +313 -0
  122. data/vendor/tesseract-2.04/ccstruct/pdblock.cpp +361 -0
  123. data/vendor/tesseract-2.04/ccstruct/pdblock.h +181 -0
  124. data/vendor/tesseract-2.04/ccstruct/pdclass.h +54 -0
  125. data/vendor/tesseract-2.04/ccstruct/points.cpp +102 -0
  126. data/vendor/tesseract-2.04/ccstruct/points.h +299 -0
  127. data/vendor/tesseract-2.04/ccstruct/polyaprx.cpp +588 -0
  128. data/vendor/tesseract-2.04/ccstruct/polyaprx.h +51 -0
  129. data/vendor/tesseract-2.04/ccstruct/polyblk.cpp +398 -0
  130. data/vendor/tesseract-2.04/ccstruct/polyblk.h +122 -0
  131. data/vendor/tesseract-2.04/ccstruct/polyblob.cpp +357 -0
  132. data/vendor/tesseract-2.04/ccstruct/polyblob.h +102 -0
  133. data/vendor/tesseract-2.04/ccstruct/polyvert.cpp +23 -0
  134. data/vendor/tesseract-2.04/ccstruct/polyvert.h +58 -0
  135. data/vendor/tesseract-2.04/ccstruct/poutline.cpp +441 -0
  136. data/vendor/tesseract-2.04/ccstruct/poutline.h +125 -0
  137. data/vendor/tesseract-2.04/ccstruct/quadlsq.cpp +147 -0
  138. data/vendor/tesseract-2.04/ccstruct/quadlsq.h +67 -0
  139. data/vendor/tesseract-2.04/ccstruct/quadratc.cpp +21 -0
  140. data/vendor/tesseract-2.04/ccstruct/quadratc.h +63 -0
  141. data/vendor/tesseract-2.04/ccstruct/quspline.cpp +382 -0
  142. data/vendor/tesseract-2.04/ccstruct/quspline.h +113 -0
  143. data/vendor/tesseract-2.04/ccstruct/ratngs.cpp +372 -0
  144. data/vendor/tesseract-2.04/ccstruct/ratngs.h +198 -0
  145. data/vendor/tesseract-2.04/ccstruct/rect.cpp +229 -0
  146. data/vendor/tesseract-2.04/ccstruct/rect.h +320 -0
  147. data/vendor/tesseract-2.04/ccstruct/rejctmap.cpp +545 -0
  148. data/vendor/tesseract-2.04/ccstruct/rejctmap.h +284 -0
  149. data/vendor/tesseract-2.04/ccstruct/rwpoly.cpp +89 -0
  150. data/vendor/tesseract-2.04/ccstruct/rwpoly.h +45 -0
  151. data/vendor/tesseract-2.04/ccstruct/statistc.cpp +905 -0
  152. data/vendor/tesseract-2.04/ccstruct/statistc.h +135 -0
  153. data/vendor/tesseract-2.04/ccstruct/stepblob.cpp +296 -0
  154. data/vendor/tesseract-2.04/ccstruct/stepblob.h +88 -0
  155. data/vendor/tesseract-2.04/ccstruct/txtregn.cpp +230 -0
  156. data/vendor/tesseract-2.04/ccstruct/txtregn.h +155 -0
  157. data/vendor/tesseract-2.04/ccstruct/vecfuncs.cpp +63 -0
  158. data/vendor/tesseract-2.04/ccstruct/vecfuncs.h +91 -0
  159. data/vendor/tesseract-2.04/ccstruct/werd.cpp +967 -0
  160. data/vendor/tesseract-2.04/ccstruct/werd.h +277 -0
  161. data/vendor/tesseract-2.04/ccutil/Makefile.am +19 -0
  162. data/vendor/tesseract-2.04/ccutil/Makefile.in +626 -0
  163. data/vendor/tesseract-2.04/ccutil/basedir.cpp +118 -0
  164. data/vendor/tesseract-2.04/ccutil/basedir.h +32 -0
  165. data/vendor/tesseract-2.04/ccutil/bits16.cpp +30 -0
  166. data/vendor/tesseract-2.04/ccutil/bits16.h +61 -0
  167. data/vendor/tesseract-2.04/ccutil/boxread.cpp +105 -0
  168. data/vendor/tesseract-2.04/ccutil/boxread.h +44 -0
  169. data/vendor/tesseract-2.04/ccutil/clst.cpp +626 -0
  170. data/vendor/tesseract-2.04/ccutil/clst.h +1085 -0
  171. data/vendor/tesseract-2.04/ccutil/debugwin.cpp +500 -0
  172. data/vendor/tesseract-2.04/ccutil/debugwin.h +103 -0
  173. data/vendor/tesseract-2.04/ccutil/elst.cpp +593 -0
  174. data/vendor/tesseract-2.04/ccutil/elst.h +1125 -0
  175. data/vendor/tesseract-2.04/ccutil/elst2.cpp +606 -0
  176. data/vendor/tesseract-2.04/ccutil/elst2.h +1121 -0
  177. data/vendor/tesseract-2.04/ccutil/errcode.cpp +104 -0
  178. data/vendor/tesseract-2.04/ccutil/errcode.h +104 -0
  179. data/vendor/tesseract-2.04/ccutil/fileerr.h +34 -0
  180. data/vendor/tesseract-2.04/ccutil/globaloc.cpp +115 -0
  181. data/vendor/tesseract-2.04/ccutil/globaloc.h +40 -0
  182. data/vendor/tesseract-2.04/ccutil/hashfn.cpp +57 -0
  183. data/vendor/tesseract-2.04/ccutil/hashfn.h +30 -0
  184. data/vendor/tesseract-2.04/ccutil/host.h +180 -0
  185. data/vendor/tesseract-2.04/ccutil/hosthplb.h +1 -0
  186. data/vendor/tesseract-2.04/ccutil/lsterr.h +43 -0
  187. data/vendor/tesseract-2.04/ccutil/mainblk.cpp +126 -0
  188. data/vendor/tesseract-2.04/ccutil/mainblk.h +39 -0
  189. data/vendor/tesseract-2.04/ccutil/memblk.cpp +1106 -0
  190. data/vendor/tesseract-2.04/ccutil/memblk.h +189 -0
  191. data/vendor/tesseract-2.04/ccutil/memry.cpp +532 -0
  192. data/vendor/tesseract-2.04/ccutil/memry.h +192 -0
  193. data/vendor/tesseract-2.04/ccutil/memryerr.h +38 -0
  194. data/vendor/tesseract-2.04/ccutil/mfcpch.cpp +5 -0
  195. data/vendor/tesseract-2.04/ccutil/mfcpch.h +37 -0
  196. data/vendor/tesseract-2.04/ccutil/ndminx.h +31 -0
  197. data/vendor/tesseract-2.04/ccutil/notdll.h +28 -0
  198. data/vendor/tesseract-2.04/ccutil/nwmain.h +176 -0
  199. data/vendor/tesseract-2.04/ccutil/ocrclass.h +345 -0
  200. data/vendor/tesseract-2.04/ccutil/ocrshell.cpp +772 -0
  201. data/vendor/tesseract-2.04/ccutil/ocrshell.h +191 -0
  202. data/vendor/tesseract-2.04/ccutil/platform.h +18 -0
  203. data/vendor/tesseract-2.04/ccutil/scanutils.cpp +543 -0
  204. data/vendor/tesseract-2.04/ccutil/scanutils.h +55 -0
  205. data/vendor/tesseract-2.04/ccutil/secname.h +9 -0
  206. data/vendor/tesseract-2.04/ccutil/serialis.cpp +117 -0
  207. data/vendor/tesseract-2.04/ccutil/serialis.h +93 -0
  208. data/vendor/tesseract-2.04/ccutil/stderr.h +26 -0
  209. data/vendor/tesseract-2.04/ccutil/strngs.cpp +495 -0
  210. data/vendor/tesseract-2.04/ccutil/strngs.h +138 -0
  211. data/vendor/tesseract-2.04/ccutil/tessclas.h +135 -0
  212. data/vendor/tesseract-2.04/ccutil/tessopt.cpp +61 -0
  213. data/vendor/tesseract-2.04/ccutil/tessopt.h +30 -0
  214. data/vendor/tesseract-2.04/ccutil/tprintf.cpp +122 -0
  215. data/vendor/tesseract-2.04/ccutil/tprintf.h +35 -0
  216. data/vendor/tesseract-2.04/ccutil/unichar.cpp +144 -0
  217. data/vendor/tesseract-2.04/ccutil/unichar.h +84 -0
  218. data/vendor/tesseract-2.04/ccutil/unicharmap.cpp +172 -0
  219. data/vendor/tesseract-2.04/ccutil/unicharmap.h +82 -0
  220. data/vendor/tesseract-2.04/ccutil/unicharset.cpp +307 -0
  221. data/vendor/tesseract-2.04/ccutil/unicharset.h +267 -0
  222. data/vendor/tesseract-2.04/ccutil/varable.cpp +672 -0
  223. data/vendor/tesseract-2.04/ccutil/varable.h +419 -0
  224. data/vendor/tesseract-2.04/classify/Makefile.am +24 -0
  225. data/vendor/tesseract-2.04/classify/Makefile.in +647 -0
  226. data/vendor/tesseract-2.04/classify/adaptive.cpp +535 -0
  227. data/vendor/tesseract-2.04/classify/adaptive.h +199 -0
  228. data/vendor/tesseract-2.04/classify/adaptmatch.cpp +2958 -0
  229. data/vendor/tesseract-2.04/classify/adaptmatch.h +86 -0
  230. data/vendor/tesseract-2.04/classify/baseline.cpp +58 -0
  231. data/vendor/tesseract-2.04/classify/baseline.h +91 -0
  232. data/vendor/tesseract-2.04/classify/blobclass.cpp +123 -0
  233. data/vendor/tesseract-2.04/classify/blobclass.h +49 -0
  234. data/vendor/tesseract-2.04/classify/chartoname.cpp +74 -0
  235. data/vendor/tesseract-2.04/classify/chartoname.h +21 -0
  236. data/vendor/tesseract-2.04/classify/cluster.cpp +2834 -0
  237. data/vendor/tesseract-2.04/classify/cluster.h +158 -0
  238. data/vendor/tesseract-2.04/classify/clusttool.cpp +507 -0
  239. data/vendor/tesseract-2.04/classify/clusttool.h +70 -0
  240. data/vendor/tesseract-2.04/classify/cutoffs.cpp +73 -0
  241. data/vendor/tesseract-2.04/classify/cutoffs.h +49 -0
  242. data/vendor/tesseract-2.04/classify/extern.h +32 -0
  243. data/vendor/tesseract-2.04/classify/extract.cpp +100 -0
  244. data/vendor/tesseract-2.04/classify/extract.h +36 -0
  245. data/vendor/tesseract-2.04/classify/featdefs.cpp +244 -0
  246. data/vendor/tesseract-2.04/classify/featdefs.h +71 -0
  247. data/vendor/tesseract-2.04/classify/flexfx.cpp +87 -0
  248. data/vendor/tesseract-2.04/classify/flexfx.h +34 -0
  249. data/vendor/tesseract-2.04/classify/float2int.cpp +126 -0
  250. data/vendor/tesseract-2.04/classify/float2int.h +65 -0
  251. data/vendor/tesseract-2.04/classify/fpoint.cpp +73 -0
  252. data/vendor/tesseract-2.04/classify/fpoint.h +63 -0
  253. data/vendor/tesseract-2.04/classify/fxdefs.cpp +74 -0
  254. data/vendor/tesseract-2.04/classify/fxdefs.h +93 -0
  255. data/vendor/tesseract-2.04/classify/fxid.h +69 -0
  256. data/vendor/tesseract-2.04/classify/hideedge.cpp +35 -0
  257. data/vendor/tesseract-2.04/classify/hideedge.h +76 -0
  258. data/vendor/tesseract-2.04/classify/intfx.cpp +608 -0
  259. data/vendor/tesseract-2.04/classify/intfx.h +63 -0
  260. data/vendor/tesseract-2.04/classify/intmatcher.cpp +1524 -0
  261. data/vendor/tesseract-2.04/classify/intmatcher.h +199 -0
  262. data/vendor/tesseract-2.04/classify/intproto.cpp +1823 -0
  263. data/vendor/tesseract-2.04/classify/intproto.h +320 -0
  264. data/vendor/tesseract-2.04/classify/kdtree.cpp +884 -0
  265. data/vendor/tesseract-2.04/classify/kdtree.h +118 -0
  266. data/vendor/tesseract-2.04/classify/mf.cpp +106 -0
  267. data/vendor/tesseract-2.04/classify/mf.h +43 -0
  268. data/vendor/tesseract-2.04/classify/mfdefs.cpp +58 -0
  269. data/vendor/tesseract-2.04/classify/mfdefs.h +60 -0
  270. data/vendor/tesseract-2.04/classify/mfoutline.cpp +1087 -0
  271. data/vendor/tesseract-2.04/classify/mfoutline.h +277 -0
  272. data/vendor/tesseract-2.04/classify/mfx.cpp +436 -0
  273. data/vendor/tesseract-2.04/classify/mfx.h +52 -0
  274. data/vendor/tesseract-2.04/classify/normfeat.cpp +132 -0
  275. data/vendor/tesseract-2.04/classify/normfeat.h +63 -0
  276. data/vendor/tesseract-2.04/classify/normmatch.cpp +305 -0
  277. data/vendor/tesseract-2.04/classify/normmatch.h +38 -0
  278. data/vendor/tesseract-2.04/classify/ocrfeatures.cpp +310 -0
  279. data/vendor/tesseract-2.04/classify/ocrfeatures.h +148 -0
  280. data/vendor/tesseract-2.04/classify/outfeat.cpp +262 -0
  281. data/vendor/tesseract-2.04/classify/outfeat.h +76 -0
  282. data/vendor/tesseract-2.04/classify/picofeat.cpp +297 -0
  283. data/vendor/tesseract-2.04/classify/picofeat.h +65 -0
  284. data/vendor/tesseract-2.04/classify/protos.cpp +472 -0
  285. data/vendor/tesseract-2.04/classify/protos.h +258 -0
  286. data/vendor/tesseract-2.04/classify/sigmenu.cpp +225 -0
  287. data/vendor/tesseract-2.04/classify/sigmenu.h +39 -0
  288. data/vendor/tesseract-2.04/classify/speckle.cpp +127 -0
  289. data/vendor/tesseract-2.04/classify/speckle.h +69 -0
  290. data/vendor/tesseract-2.04/classify/xform2d.cpp +120 -0
  291. data/vendor/tesseract-2.04/classify/xform2d.h +60 -0
  292. data/vendor/tesseract-2.04/config/config.guess +1466 -0
  293. data/vendor/tesseract-2.04/config/config.h.in +188 -0
  294. data/vendor/tesseract-2.04/config/config.sub +1579 -0
  295. data/vendor/tesseract-2.04/config/depcomp +530 -0
  296. data/vendor/tesseract-2.04/config/install-sh +269 -0
  297. data/vendor/tesseract-2.04/config/missing +198 -0
  298. data/vendor/tesseract-2.04/config/mkinstalldirs +40 -0
  299. data/vendor/tesseract-2.04/config/stamp-h.in +0 -0
  300. data/vendor/tesseract-2.04/configure +10424 -0
  301. data/vendor/tesseract-2.04/cutil/Makefile.am +14 -0
  302. data/vendor/tesseract-2.04/cutil/Makefile.in +612 -0
  303. data/vendor/tesseract-2.04/cutil/bitvec.cpp +115 -0
  304. data/vendor/tesseract-2.04/cutil/bitvec.h +100 -0
  305. data/vendor/tesseract-2.04/cutil/callcpp.h +190 -0
  306. data/vendor/tesseract-2.04/cutil/const.h +108 -0
  307. data/vendor/tesseract-2.04/cutil/cutil.cpp +92 -0
  308. data/vendor/tesseract-2.04/cutil/cutil.h +159 -0
  309. data/vendor/tesseract-2.04/cutil/danerror.cpp +144 -0
  310. data/vendor/tesseract-2.04/cutil/danerror.h +41 -0
  311. data/vendor/tesseract-2.04/cutil/debug.cpp +97 -0
  312. data/vendor/tesseract-2.04/cutil/debug.h +348 -0
  313. data/vendor/tesseract-2.04/cutil/efio.cpp +62 -0
  314. data/vendor/tesseract-2.04/cutil/efio.h +32 -0
  315. data/vendor/tesseract-2.04/cutil/emalloc.cpp +91 -0
  316. data/vendor/tesseract-2.04/cutil/emalloc.h +44 -0
  317. data/vendor/tesseract-2.04/cutil/freelist.cpp +75 -0
  318. data/vendor/tesseract-2.04/cutil/freelist.h +45 -0
  319. data/vendor/tesseract-2.04/cutil/funcdefs.h +35 -0
  320. data/vendor/tesseract-2.04/cutil/general.h +33 -0
  321. data/vendor/tesseract-2.04/cutil/globals.cpp +69 -0
  322. data/vendor/tesseract-2.04/cutil/globals.h +70 -0
  323. data/vendor/tesseract-2.04/cutil/listio.cpp +68 -0
  324. data/vendor/tesseract-2.04/cutil/listio.h +43 -0
  325. data/vendor/tesseract-2.04/cutil/minmax.h +40 -0
  326. data/vendor/tesseract-2.04/cutil/oldheap.cpp +337 -0
  327. data/vendor/tesseract-2.04/cutil/oldheap.h +126 -0
  328. data/vendor/tesseract-2.04/cutil/oldlist.cpp +393 -0
  329. data/vendor/tesseract-2.04/cutil/oldlist.h +350 -0
  330. data/vendor/tesseract-2.04/cutil/structures.cpp +66 -0
  331. data/vendor/tesseract-2.04/cutil/structures.h +112 -0
  332. data/vendor/tesseract-2.04/cutil/tessarray.cpp +115 -0
  333. data/vendor/tesseract-2.04/cutil/tessarray.h +166 -0
  334. data/vendor/tesseract-2.04/cutil/tordvars.cpp +95 -0
  335. data/vendor/tesseract-2.04/cutil/tordvars.h +61 -0
  336. data/vendor/tesseract-2.04/cutil/variables.cpp +317 -0
  337. data/vendor/tesseract-2.04/cutil/variables.h +170 -0
  338. data/vendor/tesseract-2.04/dict/Makefile.am +13 -0
  339. data/vendor/tesseract-2.04/dict/Makefile.in +609 -0
  340. data/vendor/tesseract-2.04/dict/choicearr.h +96 -0
  341. data/vendor/tesseract-2.04/dict/choices.cpp +210 -0
  342. data/vendor/tesseract-2.04/dict/choices.h +241 -0
  343. data/vendor/tesseract-2.04/dict/context.cpp +270 -0
  344. data/vendor/tesseract-2.04/dict/context.h +82 -0
  345. data/vendor/tesseract-2.04/dict/dawg.cpp +363 -0
  346. data/vendor/tesseract-2.04/dict/dawg.h +394 -0
  347. data/vendor/tesseract-2.04/dict/hyphen.cpp +84 -0
  348. data/vendor/tesseract-2.04/dict/hyphen.h +125 -0
  349. data/vendor/tesseract-2.04/dict/lookdawg.cpp +228 -0
  350. data/vendor/tesseract-2.04/dict/lookdawg.h +76 -0
  351. data/vendor/tesseract-2.04/dict/makedawg.cpp +449 -0
  352. data/vendor/tesseract-2.04/dict/makedawg.h +83 -0
  353. data/vendor/tesseract-2.04/dict/matchdefs.h +145 -0
  354. data/vendor/tesseract-2.04/dict/permdawg.cpp +415 -0
  355. data/vendor/tesseract-2.04/dict/permdawg.h +98 -0
  356. data/vendor/tesseract-2.04/dict/permngram.cpp +358 -0
  357. data/vendor/tesseract-2.04/dict/permngram.h +33 -0
  358. data/vendor/tesseract-2.04/dict/permnum.cpp +522 -0
  359. data/vendor/tesseract-2.04/dict/permnum.h +83 -0
  360. data/vendor/tesseract-2.04/dict/permute.cpp +1704 -0
  361. data/vendor/tesseract-2.04/dict/permute.h +93 -0
  362. data/vendor/tesseract-2.04/dict/reduce.cpp +424 -0
  363. data/vendor/tesseract-2.04/dict/reduce.h +112 -0
  364. data/vendor/tesseract-2.04/dict/states.cpp +382 -0
  365. data/vendor/tesseract-2.04/dict/states.h +111 -0
  366. data/vendor/tesseract-2.04/dict/stopper.cpp +1458 -0
  367. data/vendor/tesseract-2.04/dict/stopper.h +103 -0
  368. data/vendor/tesseract-2.04/dict/trie.cpp +683 -0
  369. data/vendor/tesseract-2.04/dict/trie.h +190 -0
  370. data/vendor/tesseract-2.04/dlltest/Makefile.am +2 -0
  371. data/vendor/tesseract-2.04/dlltest/Makefile.in +388 -0
  372. data/vendor/tesseract-2.04/dlltest/dlltest.cpp +163 -0
  373. data/vendor/tesseract-2.04/dlltest/dlltest.dsp +186 -0
  374. data/vendor/tesseract-2.04/dlltest/dlltest.vcproj +637 -0
  375. data/vendor/tesseract-2.04/eurotext.tif +0 -0
  376. data/vendor/tesseract-2.04/image/Makefile.am +10 -0
  377. data/vendor/tesseract-2.04/image/Makefile.in +596 -0
  378. data/vendor/tesseract-2.04/image/bitstrm.cpp +157 -0
  379. data/vendor/tesseract-2.04/image/bitstrm.h +73 -0
  380. data/vendor/tesseract-2.04/image/img.h +336 -0
  381. data/vendor/tesseract-2.04/image/imgbmp.cpp +223 -0
  382. data/vendor/tesseract-2.04/image/imgbmp.h +50 -0
  383. data/vendor/tesseract-2.04/image/imgerrs.h +35 -0
  384. data/vendor/tesseract-2.04/image/imgio.cpp +321 -0
  385. data/vendor/tesseract-2.04/image/imgio.h +22 -0
  386. data/vendor/tesseract-2.04/image/imgs.cpp +1764 -0
  387. data/vendor/tesseract-2.04/image/imgs.h +102 -0
  388. data/vendor/tesseract-2.04/image/imgtiff.cpp +723 -0
  389. data/vendor/tesseract-2.04/image/imgtiff.h +89 -0
  390. data/vendor/tesseract-2.04/image/imgunpk.h +1377 -0
  391. data/vendor/tesseract-2.04/image/svshowim.cpp +40 -0
  392. data/vendor/tesseract-2.04/image/svshowim.h +25 -0
  393. data/vendor/tesseract-2.04/java/Makefile.am +4 -0
  394. data/vendor/tesseract-2.04/java/Makefile.in +473 -0
  395. data/vendor/tesseract-2.04/java/com/Makefile.am +1 -0
  396. data/vendor/tesseract-2.04/java/com/Makefile.in +470 -0
  397. data/vendor/tesseract-2.04/java/com/google/Makefile.am +1 -0
  398. data/vendor/tesseract-2.04/java/com/google/Makefile.in +470 -0
  399. data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.am +4 -0
  400. data/vendor/tesseract-2.04/java/com/google/scrollview/Makefile.in +473 -0
  401. data/vendor/tesseract-2.04/java/com/google/scrollview/ScrollView.java +421 -0
  402. data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.am +5 -0
  403. data/vendor/tesseract-2.04/java/com/google/scrollview/events/Makefile.in +474 -0
  404. data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEvent.java +87 -0
  405. data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventHandler.java +296 -0
  406. data/vendor/tesseract-2.04/java/com/google/scrollview/events/SVEventType.java +31 -0
  407. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.am +7 -0
  408. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/Makefile.in +476 -0
  409. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVAbstractMenuItem.java +58 -0
  410. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVCheckboxMenuItem.java +60 -0
  411. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVEmptyMenuItem.java +48 -0
  412. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVImageHandler.java +228 -0
  413. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuBar.java +130 -0
  414. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVMenuItem.java +61 -0
  415. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVPopupMenu.java +142 -0
  416. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVSubMenuItem.java +41 -0
  417. data/vendor/tesseract-2.04/java/com/google/scrollview/ui/SVWindow.java +643 -0
  418. data/vendor/tesseract-2.04/java/makefile +55 -0
  419. data/vendor/tesseract-2.04/pageseg/Makefile.am +13 -0
  420. data/vendor/tesseract-2.04/pageseg/Makefile.in +596 -0
  421. data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.cpp +363 -0
  422. data/vendor/tesseract-2.04/pageseg/leptonica_pageseg.h +90 -0
  423. data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.cpp +82 -0
  424. data/vendor/tesseract-2.04/pageseg/leptonica_pageseg_interface.h +30 -0
  425. data/vendor/tesseract-2.04/pageseg/pageseg.cpp +170 -0
  426. data/vendor/tesseract-2.04/pageseg/pageseg.h +29 -0
  427. data/vendor/tesseract-2.04/phototest.tif +0 -0
  428. data/vendor/tesseract-2.04/tessdata/Makefile.am +31 -0
  429. data/vendor/tesseract-2.04/tessdata/Makefile.in +529 -0
  430. data/vendor/tesseract-2.04/tessdata/configs/Makefile.am +3 -0
  431. data/vendor/tesseract-2.04/tessdata/configs/Makefile.in +344 -0
  432. data/vendor/tesseract-2.04/tessdata/configs/api_config +1 -0
  433. data/vendor/tesseract-2.04/tessdata/configs/box.train +19 -0
  434. data/vendor/tesseract-2.04/tessdata/configs/box.train.stderr +18 -0
  435. data/vendor/tesseract-2.04/tessdata/configs/inter +4 -0
  436. data/vendor/tesseract-2.04/tessdata/configs/kannada +4 -0
  437. data/vendor/tesseract-2.04/tessdata/configs/makebox +1 -0
  438. data/vendor/tesseract-2.04/tessdata/configs/unlv +3 -0
  439. data/vendor/tesseract-2.04/tessdata/confsets +3 -0
  440. data/vendor/tesseract-2.04/tessdata/eng.DangAmbigs +39 -0
  441. data/vendor/tesseract-2.04/tessdata/eng.freq-dawg +0 -0
  442. data/vendor/tesseract-2.04/tessdata/eng.inttemp +0 -0
  443. data/vendor/tesseract-2.04/tessdata/eng.normproto +1247 -0
  444. data/vendor/tesseract-2.04/tessdata/eng.pffmtable +111 -0
  445. data/vendor/tesseract-2.04/tessdata/eng.unicharset +113 -0
  446. data/vendor/tesseract-2.04/tessdata/eng.user-words +921 -0
  447. data/vendor/tesseract-2.04/tessdata/eng.word-dawg +0 -0
  448. data/vendor/tesseract-2.04/tessdata/makedummies +8 -0
  449. data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.am +3 -0
  450. data/vendor/tesseract-2.04/tessdata/tessconfigs/Makefile.in +344 -0
  451. data/vendor/tesseract-2.04/tessdata/tessconfigs/batch +2 -0
  452. data/vendor/tesseract-2.04/tessdata/tessconfigs/batch.nochop +2 -0
  453. data/vendor/tesseract-2.04/tessdata/tessconfigs/matdemo +7 -0
  454. data/vendor/tesseract-2.04/tessdata/tessconfigs/msdemo +13 -0
  455. data/vendor/tesseract-2.04/tessdata/tessconfigs/nobatch +2 -0
  456. data/vendor/tesseract-2.04/tessdata/tessconfigs/segdemo +9 -0
  457. data/vendor/tesseract-2.04/tessdll.cpp +351 -0
  458. data/vendor/tesseract-2.04/tessdll.dsp +2050 -0
  459. data/vendor/tesseract-2.04/tessdll.h +143 -0
  460. data/vendor/tesseract-2.04/tessdll.vcproj +5495 -0
  461. data/vendor/tesseract-2.04/tesseract.dsp +2124 -0
  462. data/vendor/tesseract-2.04/tesseract.dsw +116 -0
  463. data/vendor/tesseract-2.04/tesseract.sln +59 -0
  464. data/vendor/tesseract-2.04/tesseract.spec +188 -0
  465. data/vendor/tesseract-2.04/tesseract.vcproj +5859 -0
  466. data/vendor/tesseract-2.04/testing/Makefile.am +2 -0
  467. data/vendor/tesseract-2.04/testing/Makefile.in +312 -0
  468. data/vendor/tesseract-2.04/testing/README +43 -0
  469. data/vendor/tesseract-2.04/testing/counttestset.sh +61 -0
  470. data/vendor/tesseract-2.04/testing/reorgdata.sh +44 -0
  471. data/vendor/tesseract-2.04/testing/reports/1995.bus.3B.sum +1 -0
  472. data/vendor/tesseract-2.04/testing/reports/1995.doe3.3B.sum +1 -0
  473. data/vendor/tesseract-2.04/testing/reports/1995.mag.3B.sum +1 -0
  474. data/vendor/tesseract-2.04/testing/reports/1995.news.3B.sum +1 -0
  475. data/vendor/tesseract-2.04/testing/reports/2.03.summary +9 -0
  476. data/vendor/tesseract-2.04/testing/reports/2.04.summary +9 -0
  477. data/vendor/tesseract-2.04/testing/runalltests.sh +110 -0
  478. data/vendor/tesseract-2.04/testing/runtestset.sh +61 -0
  479. data/vendor/tesseract-2.04/textord/Makefile.am +20 -0
  480. data/vendor/tesseract-2.04/textord/Makefile.in +624 -0
  481. data/vendor/tesseract-2.04/textord/blkocc.cpp +809 -0
  482. data/vendor/tesseract-2.04/textord/blkocc.h +327 -0
  483. data/vendor/tesseract-2.04/textord/blobcmpl.h +31 -0
  484. data/vendor/tesseract-2.04/textord/drawedg.cpp +77 -0
  485. data/vendor/tesseract-2.04/textord/drawedg.h +34 -0
  486. data/vendor/tesseract-2.04/textord/drawtord.cpp +469 -0
  487. data/vendor/tesseract-2.04/textord/drawtord.h +107 -0
  488. data/vendor/tesseract-2.04/textord/edgblob.cpp +412 -0
  489. data/vendor/tesseract-2.04/textord/edgblob.h +100 -0
  490. data/vendor/tesseract-2.04/textord/edgloop.cpp +211 -0
  491. data/vendor/tesseract-2.04/textord/edgloop.h +66 -0
  492. data/vendor/tesseract-2.04/textord/fpchop.cpp +1641 -0
  493. data/vendor/tesseract-2.04/textord/fpchop.h +238 -0
  494. data/vendor/tesseract-2.04/textord/gap_map.cpp +166 -0
  495. data/vendor/tesseract-2.04/textord/gap_map.h +40 -0
  496. data/vendor/tesseract-2.04/textord/makerow.cpp +2628 -0
  497. data/vendor/tesseract-2.04/textord/makerow.h +295 -0
  498. data/vendor/tesseract-2.04/textord/oldbasel.cpp +1761 -0
  499. data/vendor/tesseract-2.04/textord/oldbasel.h +195 -0
  500. data/vendor/tesseract-2.04/textord/pithsync.cpp +696 -0
  501. data/vendor/tesseract-2.04/textord/pithsync.h +134 -0
  502. data/vendor/tesseract-2.04/textord/pitsync1.cpp +425 -0
  503. data/vendor/tesseract-2.04/textord/pitsync1.h +135 -0
  504. data/vendor/tesseract-2.04/textord/scanedg.cpp +452 -0
  505. data/vendor/tesseract-2.04/textord/scanedg.h +74 -0
  506. data/vendor/tesseract-2.04/textord/sortflts.cpp +80 -0
  507. data/vendor/tesseract-2.04/textord/sortflts.h +64 -0
  508. data/vendor/tesseract-2.04/textord/tessout.h +76 -0
  509. data/vendor/tesseract-2.04/textord/topitch.cpp +2019 -0
  510. data/vendor/tesseract-2.04/textord/topitch.h +195 -0
  511. data/vendor/tesseract-2.04/textord/tordmain.cpp +907 -0
  512. data/vendor/tesseract-2.04/textord/tordmain.h +132 -0
  513. data/vendor/tesseract-2.04/textord/tospace.cpp +1939 -0
  514. data/vendor/tesseract-2.04/textord/tospace.h +193 -0
  515. data/vendor/tesseract-2.04/textord/tovars.cpp +87 -0
  516. data/vendor/tesseract-2.04/textord/tovars.h +94 -0
  517. data/vendor/tesseract-2.04/textord/underlin.cpp +312 -0
  518. data/vendor/tesseract-2.04/textord/underlin.h +53 -0
  519. data/vendor/tesseract-2.04/textord/wordseg.cpp +620 -0
  520. data/vendor/tesseract-2.04/textord/wordseg.h +70 -0
  521. data/vendor/tesseract-2.04/training/Makefile.am +54 -0
  522. data/vendor/tesseract-2.04/training/Makefile.in +720 -0
  523. data/vendor/tesseract-2.04/training/cnTraining.cpp +855 -0
  524. data/vendor/tesseract-2.04/training/cntraining.dsp +243 -0
  525. data/vendor/tesseract-2.04/training/cntraining.vcproj +950 -0
  526. data/vendor/tesseract-2.04/training/mergenf.cpp +451 -0
  527. data/vendor/tesseract-2.04/training/mergenf.h +106 -0
  528. data/vendor/tesseract-2.04/training/mfTraining.cpp +1341 -0
  529. data/vendor/tesseract-2.04/training/mftraining.dsp +285 -0
  530. data/vendor/tesseract-2.04/training/mftraining.vcproj +1055 -0
  531. data/vendor/tesseract-2.04/training/name2char.cpp +166 -0
  532. data/vendor/tesseract-2.04/training/name2char.h +38 -0
  533. data/vendor/tesseract-2.04/training/training.cpp +190 -0
  534. data/vendor/tesseract-2.04/training/training.h +130 -0
  535. data/vendor/tesseract-2.04/training/unicharset_extractor.cpp +140 -0
  536. data/vendor/tesseract-2.04/training/unicharset_extractor.dsp +335 -0
  537. data/vendor/tesseract-2.04/training/unicharset_extractor.vcproj +769 -0
  538. data/vendor/tesseract-2.04/training/wordlist2dawg.cpp +69 -0
  539. data/vendor/tesseract-2.04/training/wordlist2dawg.dsp +319 -0
  540. data/vendor/tesseract-2.04/training/wordlist2dawg.vcproj +1113 -0
  541. data/vendor/tesseract-2.04/viewer/Makefile.am +9 -0
  542. data/vendor/tesseract-2.04/viewer/Makefile.in +591 -0
  543. data/vendor/tesseract-2.04/viewer/scrollview.cpp +825 -0
  544. data/vendor/tesseract-2.04/viewer/scrollview.h +414 -0
  545. data/vendor/tesseract-2.04/viewer/svmnode.cpp +140 -0
  546. data/vendor/tesseract-2.04/viewer/svmnode.h +94 -0
  547. data/vendor/tesseract-2.04/viewer/svpaint.cpp +220 -0
  548. data/vendor/tesseract-2.04/viewer/svutil.cpp +347 -0
  549. data/vendor/tesseract-2.04/viewer/svutil.h +138 -0
  550. data/vendor/tesseract-2.04/wordrec/Makefile.am +23 -0
  551. data/vendor/tesseract-2.04/wordrec/Makefile.in +641 -0
  552. data/vendor/tesseract-2.04/wordrec/associate.cpp +62 -0
  553. data/vendor/tesseract-2.04/wordrec/associate.h +93 -0
  554. data/vendor/tesseract-2.04/wordrec/badwords.cpp +106 -0
  555. data/vendor/tesseract-2.04/wordrec/badwords.h +51 -0
  556. data/vendor/tesseract-2.04/wordrec/bestfirst.cpp +526 -0
  557. data/vendor/tesseract-2.04/wordrec/bestfirst.h +203 -0
  558. data/vendor/tesseract-2.04/wordrec/charsample.h +208 -0
  559. data/vendor/tesseract-2.04/wordrec/chop.cpp +458 -0
  560. data/vendor/tesseract-2.04/wordrec/chop.h +153 -0
  561. data/vendor/tesseract-2.04/wordrec/chopper.cpp +750 -0
  562. data/vendor/tesseract-2.04/wordrec/chopper.h +104 -0
  563. data/vendor/tesseract-2.04/wordrec/closed.cpp +136 -0
  564. data/vendor/tesseract-2.04/wordrec/closed.h +65 -0
  565. data/vendor/tesseract-2.04/wordrec/djmenus.cpp +118 -0
  566. data/vendor/tesseract-2.04/wordrec/djmenus.h +33 -0
  567. data/vendor/tesseract-2.04/wordrec/drawfx.cpp +92 -0
  568. data/vendor/tesseract-2.04/wordrec/drawfx.h +33 -0
  569. data/vendor/tesseract-2.04/wordrec/findseam.cpp +566 -0
  570. data/vendor/tesseract-2.04/wordrec/findseam.h +69 -0
  571. data/vendor/tesseract-2.04/wordrec/gradechop.cpp +226 -0
  572. data/vendor/tesseract-2.04/wordrec/gradechop.h +91 -0
  573. data/vendor/tesseract-2.04/wordrec/heuristic.cpp +194 -0
  574. data/vendor/tesseract-2.04/wordrec/heuristic.h +120 -0
  575. data/vendor/tesseract-2.04/wordrec/makechop.cpp +281 -0
  576. data/vendor/tesseract-2.04/wordrec/makechop.h +69 -0
  577. data/vendor/tesseract-2.04/wordrec/matchtab.cpp +191 -0
  578. data/vendor/tesseract-2.04/wordrec/matchtab.h +45 -0
  579. data/vendor/tesseract-2.04/wordrec/matrix.cpp +118 -0
  580. data/vendor/tesseract-2.04/wordrec/matrix.h +104 -0
  581. data/vendor/tesseract-2.04/wordrec/measure.h +135 -0
  582. data/vendor/tesseract-2.04/wordrec/metrics.cpp +363 -0
  583. data/vendor/tesseract-2.04/wordrec/metrics.h +130 -0
  584. data/vendor/tesseract-2.04/wordrec/mfvars.cpp +51 -0
  585. data/vendor/tesseract-2.04/wordrec/mfvars.h +27 -0
  586. data/vendor/tesseract-2.04/wordrec/msmenus.cpp +110 -0
  587. data/vendor/tesseract-2.04/wordrec/msmenus.h +45 -0
  588. data/vendor/tesseract-2.04/wordrec/olutil.cpp +153 -0
  589. data/vendor/tesseract-2.04/wordrec/olutil.h +128 -0
  590. data/vendor/tesseract-2.04/wordrec/outlines.cpp +172 -0
  591. data/vendor/tesseract-2.04/wordrec/outlines.h +148 -0
  592. data/vendor/tesseract-2.04/wordrec/pieces.cpp +410 -0
  593. data/vendor/tesseract-2.04/wordrec/pieces.h +154 -0
  594. data/vendor/tesseract-2.04/wordrec/plotedges.cpp +134 -0
  595. data/vendor/tesseract-2.04/wordrec/plotedges.h +71 -0
  596. data/vendor/tesseract-2.04/wordrec/plotseg.cpp +116 -0
  597. data/vendor/tesseract-2.04/wordrec/plotseg.h +73 -0
  598. data/vendor/tesseract-2.04/wordrec/render.cpp +152 -0
  599. data/vendor/tesseract-2.04/wordrec/render.h +58 -0
  600. data/vendor/tesseract-2.04/wordrec/seam.cpp +482 -0
  601. data/vendor/tesseract-2.04/wordrec/seam.h +136 -0
  602. data/vendor/tesseract-2.04/wordrec/split.cpp +182 -0
  603. data/vendor/tesseract-2.04/wordrec/split.h +115 -0
  604. data/vendor/tesseract-2.04/wordrec/tally.cpp +68 -0
  605. data/vendor/tesseract-2.04/wordrec/tally.h +94 -0
  606. data/vendor/tesseract-2.04/wordrec/tessinit.cpp +108 -0
  607. data/vendor/tesseract-2.04/wordrec/tessinit.h +46 -0
  608. data/vendor/tesseract-2.04/wordrec/tface.cpp +272 -0
  609. data/vendor/tesseract-2.04/wordrec/tface.h +35 -0
  610. data/vendor/tesseract-2.04/wordrec/wordclass.cpp +284 -0
  611. data/vendor/tesseract-2.04/wordrec/wordclass.h +64 -0
  612. metadata +708 -0
@@ -0,0 +1,1823 @@
1
+ /******************************************************************************
2
+ ** Filename: intproto.c
3
+ ** Purpose: Definition of data structures for integer protos.
4
+ ** Author: Dan Johnson
5
+ ** History: Thu Feb 7 14:38:16 1991, DSJ, Created.
6
+ **
7
+ ** (c) Copyright Hewlett-Packard Company, 1988.
8
+ ** Licensed under the Apache License, Version 2.0 (the "License");
9
+ ** you may not use this file except in compliance with the License.
10
+ ** You may obtain a copy of the License at
11
+ ** http://www.apache.org/licenses/LICENSE-2.0
12
+ ** Unless required by applicable law or agreed to in writing, software
13
+ ** distributed under the License is distributed on an "AS IS" BASIS,
14
+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ ** See the License for the specific language governing permissions and
16
+ ** limitations under the License.
17
+ ******************************************************************************/
18
+ /**----------------------------------------------------------------------------
19
+ Include Files and Type Defines
20
+ ----------------------------------------------------------------------------**/
21
+ #include "intproto.h"
22
+ #include "picofeat.h"
23
+ #include "debug.h"
24
+ #include "mfoutline.h"
25
+ #include "emalloc.h"
26
+ #include "const.h"
27
+ #include "ndminx.h"
28
+ #include "svmnode.h"
29
+ #include "adaptmatch.h"
30
+ #include "globals.h"
31
+
32
+ //extern GetPicoFeatureLength();
33
+
34
+ #include <math.h>
35
+ #include <stdio.h>
36
+ #include <assert.h>
37
+ #ifdef __UNIX__
38
+ #include <unistd.h>
39
+ #endif
40
+
41
+ /* match debug display constants*/
42
+ #define DISPLAY_OFFSET (0.5 * INT_CHAR_NORM_RANGE)
43
+ #define PROTO_PRUNER_SCALE (4.0)
44
+
45
+ #define INT_DESCENDER (0.0 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
46
+ #define INT_BASELINE (0.25 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
47
+ #define INT_XHEIGHT (0.75 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
48
+ #define INT_CAPHEIGHT (1.0 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
49
+
50
+ #define INT_XCENTER (0.5 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
51
+ #define INT_YCENTER (0.5 * INT_CHAR_NORM_RANGE - DISPLAY_OFFSET)
52
+ #define INT_XRADIUS (0.2 * INT_CHAR_NORM_RANGE)
53
+ #define INT_YRADIUS (0.2 * INT_CHAR_NORM_RANGE)
54
+ #define INT_MIN_X (- DISPLAY_OFFSET)
55
+ #define INT_MIN_Y (- DISPLAY_OFFSET)
56
+ #define INT_MAX_X ( DISPLAY_OFFSET)
57
+ #define INT_MAX_Y ( DISPLAY_OFFSET)
58
+ #define DOUBLE_OFFSET 0.095
59
+
60
+ /* define pad used to snap near horiz/vertical protos to horiz/vertical */
61
+ #define HV_TOLERANCE (0.0025) /* approx 0.9 degrees */
62
+
63
+ typedef enum
64
+ { StartSwitch, EndSwitch, LastSwitch }
65
+ SWITCH_TYPE;
66
+ #define MAX_NUM_SWITCHES 3
67
+
68
+ typedef struct
69
+ {
70
+ SWITCH_TYPE Type;
71
+ inT8 X, Y;
72
+ inT16 YInit;
73
+ inT16 Delta;
74
+ }
75
+
76
+
77
+ FILL_SWITCH;
78
+
79
+ typedef struct
80
+ {
81
+ uinT8 NextSwitch;
82
+ uinT8 AngleStart, AngleEnd;
83
+ inT8 X;
84
+ inT16 YStart, YEnd;
85
+ inT16 StartDelta, EndDelta;
86
+ FILL_SWITCH Switch[MAX_NUM_SWITCHES];
87
+ }
88
+
89
+
90
+ TABLE_FILLER;
91
+
92
+ typedef struct
93
+ {
94
+ inT8 X;
95
+ inT8 YStart, YEnd;
96
+ uinT8 AngleStart, AngleEnd;
97
+ }
98
+
99
+
100
+ FILL_SPEC;
101
+
102
+ enum IntmatcherDebugAction {
103
+ IDA_ADAPTIVE,
104
+ IDA_STATIC,
105
+ IDA_BOTH
106
+ };
107
+
108
+ /**----------------------------------------------------------------------------
109
+ Macros
110
+ ----------------------------------------------------------------------------**/
111
+ /* macro for performing circular increments of bucket indices */
112
+ #define CircularIncrement(i,r) (((i) < (r) - 1)?((i)++):((i) = 0))
113
+
114
+ /* macro for mapping floats to ints without bounds checking */
115
+ #define MapParam(P,O,N) (floor (((P) + (O)) * (N)))
116
+
117
+ /*---------------------------------------------------------------------------
118
+ Private Function Prototypes
119
+ ----------------------------------------------------------------------------*/
120
+ FLOAT32 BucketStart(int Bucket, FLOAT32 Offset, int NumBuckets);
121
+
122
+ FLOAT32 BucketEnd(int Bucket, FLOAT32 Offset, int NumBuckets);
123
+
124
+ void DoFill(FILL_SPEC *FillSpec,
125
+ CLASS_PRUNER Pruner,
126
+ register uinT32 ClassMask,
127
+ register uinT32 ClassCount,
128
+ register uinT32 WordIndex);
129
+
130
+ BOOL8 FillerDone(TABLE_FILLER *Filler);
131
+
132
+ void FillPPCircularBits (uinT32
133
+ ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
134
+ int Bit, FLOAT32 Center, FLOAT32 Spread);
135
+
136
+ void FillPPLinearBits (uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
137
+ int Bit, FLOAT32 Center, FLOAT32 Spread);
138
+
139
+ #ifndef GRAPHICS_DISABLED
140
+ CLASS_ID GetClassToDebug(const char *Prompt);
141
+ #endif
142
+
143
+ void GetCPPadsForLevel(int Level,
144
+ FLOAT32 *EndPad,
145
+ FLOAT32 *SidePad,
146
+ FLOAT32 *AnglePad);
147
+
148
+ C_COL GetMatchColorFor(FLOAT32 Evidence);
149
+
150
+ void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill);
151
+
152
+ void InitTableFiller(FLOAT32 EndPad,
153
+ FLOAT32 SidePad,
154
+ FLOAT32 AnglePad,
155
+ PROTO Proto,
156
+ TABLE_FILLER *Filler);
157
+
158
+ #ifndef GRAPHICS_DISABLED
159
+ void RenderIntFeature(void *window, INT_FEATURE Feature, C_COL Color);
160
+
161
+ void RenderIntProto(void *window,
162
+ INT_CLASS Class,
163
+ PROTO_ID ProtoId,
164
+ C_COL Color);
165
+ #endif
166
+
167
+ int TruncateParam(FLOAT32 Param, int Min, int Max, char *Id);
168
+
169
+ /*
170
+ #if defined(__STDC__) || defined(__cplusplus)
171
+ # define _ARGS(s) s
172
+ #else
173
+ # define _ARGS(s) ()
174
+ #endif*/
175
+
176
+ /* /users/danj/wiseowl/src/danj/microfeatures/intproto.c
177
+ FLOAT32 BucketStart
178
+ _ARGS((int Bucket,
179
+ FLOAT32 Offset,
180
+ int NumBuckets));
181
+
182
+ FLOAT32 BucketEnd
183
+ _ARGS((int Bucket,
184
+ FLOAT32 Offset,
185
+ int NumBuckets));
186
+
187
+ void DoFill
188
+ _ARGS((FILL_SPEC *FillSpec,
189
+ CLASS_PRUNER Pruner,
190
+ uinT32 ClassMask,
191
+ uinT32 ClassCount,
192
+ uinT32 WordIndex));
193
+
194
+ BOOL8 FillerDone
195
+ _ARGS((TABLE_FILLER *Filler));
196
+
197
+ void FillPPCircularBits
198
+ _ARGS((uinT32 ParamTable [NUM_PP_BUCKETS ][WERDS_PER_PP_VECTOR ],
199
+ int Bit,
200
+ FLOAT32 Center,
201
+ FLOAT32 Spread));
202
+
203
+ void FillPPLinearBits
204
+ _ARGS((uinT32 ParamTable [NUM_PP_BUCKETS ][WERDS_PER_PP_VECTOR ],
205
+ int Bit,
206
+ FLOAT32 Center,
207
+ FLOAT32 Spread));
208
+
209
+ void GetCPPadsForLevel
210
+ _ARGS((int Level,
211
+ FLOAT32 *EndPad,
212
+ FLOAT32 *SidePad,
213
+ FLOAT32 *AnglePad));
214
+
215
+ C_COL GetMatchColorFor
216
+ _ARGS((FLOAT32 Evidence));
217
+
218
+ void GetNextFill
219
+ _ARGS((TABLE_FILLER *Filler,
220
+ FILL_SPEC *Fill));
221
+
222
+ void InitTableFiller
223
+ _ARGS((FLOAT32 EndPad,
224
+ FLOAT32 SidePad,
225
+ FLOAT32 AnglePad,
226
+ PROTO Proto,
227
+ TABLE_FILLER *Filler));
228
+
229
+ void RenderIntFeature
230
+ _ARGS((SHAPE_LIST ShapeList,
231
+ INT_FEATURE Feature,
232
+ char *Color));
233
+
234
+ void RenderIntProto
235
+ _ARGS((SHAPE_LIST ShapeList,
236
+ INT_CLASS Class,
237
+ PROTO_ID ProtoId,
238
+ char *Color));
239
+
240
+ int TruncateParam
241
+ _ARGS((FLOAT32 Param,
242
+ int Min,
243
+ int Max,
244
+ char *Id));
245
+
246
+ #undef _ARGS
247
+ */
248
+
249
+ /**----------------------------------------------------------------------------
250
+ Global Data Definitions and Declarations
251
+ ----------------------------------------------------------------------------**/
252
+ /* control knobs */
253
+ make_int_const (NumCPLevels, 3, MakeNumCPLevels);
254
+ make_float_const (CPAnglePadLoose, 45.0, MakeCPAnglePadLoose);
255
+ make_float_const (CPAnglePadMedium, 20.0, MakeCPAnglePadMedium);
256
+ make_float_const (CPAnglePadTight, 10.0, MakeCPAnglePadTight);
257
+ make_float_const (CPEndPadLoose, 0.5, MakeCPEndPadLoose);
258
+ make_float_const (CPEndPadMedium, 0.5, MakeCPEndPadMedium);
259
+ make_float_const (CPEndPadTight, 0.5, MakeCPEndPadTight);
260
+ make_float_const (CPSidePadLoose, 2.5, MakeCPSidePadLoose);
261
+ make_float_const (CPSidePadMedium, 1.2, MakeCPSidePadMedium);
262
+ make_float_const (CPSidePadTight, 0.6, MakeCPSidePadTight);
263
+ make_float_const (PPAnglePad, 45.0, MakePPAnglePad);
264
+ make_float_const (PPEndPad, 0.5, MakePPEndPad);
265
+ make_float_const (PPSidePad, 2.5, MakePPSidePad);
266
+
267
+ /* global display lists used to display proto and feature match information*/
268
+ ScrollView *IntMatchWindow = NULL;
269
+ //extern int LearningDebugLevel;
270
+
271
+ /**----------------------------------------------------------------------------
272
+ Public Code
273
+ ----------------------------------------------------------------------------**/
274
+ /*---------------------------------------------------------------------------*/
275
+ int AddIntClass(INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class) {
276
+ /*
277
+ ** Parameters:
278
+ ** Templates templates to add new class to
279
+ ** ClassId class id to associate new class with
280
+ ** Class class data structure to add to templates
281
+ ** Globals: none
282
+ ** Operation: This routine adds a new class structure to a set of
283
+ ** templates.
284
+ ** Return: The class index of the new class.
285
+ ** Exceptions: none
286
+ ** History: Mon Feb 11 11:52:08 1991, DSJ, Created.
287
+ */
288
+ int Index;
289
+ int Pruner;
290
+ uinT32 *Word;
291
+
292
+ assert (LegalClassId (ClassId));
293
+ assert (UnusedClassIdIn (Templates, ClassId));
294
+
295
+ Index = Templates->NumClasses;
296
+ Templates->IndexFor[ClassId] = Index;
297
+ Templates->ClassIdFor[Index] = ClassId;
298
+
299
+ Templates->NumClasses++;
300
+ Templates->Class[Index] = Class;
301
+
302
+ if (Templates->NumClasses > MaxNumClassesIn (Templates)) {
303
+ Pruner = Templates->NumClassPruners;
304
+ Templates->NumClassPruners++;
305
+ Templates->ClassPruner[Pruner] =
306
+ (CLASS_PRUNER) Emalloc (sizeof (CLASS_PRUNER_STRUCT));
307
+
308
+ for (Word = (uinT32 *) (Templates->ClassPruner[Pruner]);
309
+ Word < (uinT32 *) (Templates->ClassPruner[Pruner]) + WERDS_PER_CP;
310
+ *Word++ = 0);
311
+ }
312
+
313
+ return (Index);
314
+
315
+ } /* AddIntClass */
316
+
317
+
318
+ /*---------------------------------------------------------------------------*/
319
+ int AddIntConfig(INT_CLASS Class) {
320
+ /*
321
+ ** Parameters:
322
+ ** Class class to add new configuration to
323
+ ** Globals: none
324
+ ** Operation: This routine returns the index of the next free config
325
+ ** in Class.
326
+ ** Return: Index of next free config.
327
+ ** Exceptions: none
328
+ ** History: Mon Feb 11 14:44:40 1991, DSJ, Created.
329
+ */
330
+ int Index;
331
+
332
+ assert (Class->NumConfigs < MAX_NUM_CONFIGS);
333
+
334
+ Index = Class->NumConfigs;
335
+ Class->NumConfigs++;
336
+ Class->ConfigLengths[Index] = 0;
337
+ return (Index);
338
+ } /* AddIntConfig */
339
+
340
+
341
+ /*---------------------------------------------------------------------------*/
342
+ int AddIntProto(INT_CLASS Class) {
343
+ /*
344
+ ** Parameters:
345
+ ** Class class to add new proto to
346
+ ** Globals: none
347
+ ** Operation: This routine allocates the next free proto in Class and
348
+ ** returns its index.
349
+ ** Return: Proto index of new proto.
350
+ ** Exceptions: none
351
+ ** History: Mon Feb 11 13:26:41 1991, DSJ, Created.
352
+ */
353
+ int Index;
354
+ int ProtoSetId;
355
+ PROTO_SET ProtoSet;
356
+ INT_PROTO Proto;
357
+ register uinT32 *Word;
358
+
359
+ if (Class->NumProtos >= MAX_NUM_PROTOS)
360
+ return (NO_PROTO);
361
+
362
+ Index = Class->NumProtos++;
363
+
364
+ if (Class->NumProtos > MaxNumIntProtosIn(Class)) {
365
+ ProtoSetId = Class->NumProtoSets++;
366
+
367
+ ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
368
+ Class->ProtoSets[ProtoSetId] = ProtoSet;
369
+ for (Word = (uinT32 *) (ProtoSet->ProtoPruner);
370
+ Word < (uinT32 *) (ProtoSet->ProtoPruner) + WERDS_PER_PP;
371
+ *Word++ = 0);
372
+
373
+ /* reallocate space for the proto lengths and install in class */
374
+ Class->ProtoLengths = (uinT8 *) Erealloc (Class->ProtoLengths,
375
+ MaxNumIntProtosIn (Class) *
376
+ sizeof (uinT8));
377
+ }
378
+
379
+ /* initialize proto so its length is zero and it isn't in any configs */
380
+ Class->ProtoLengths[Index] = 0;
381
+ Proto = ProtoForProtoId (Class, Index);
382
+ for (Word = Proto->Configs;
383
+ Word < Proto->Configs + WERDS_PER_CONFIG_VEC; *Word++ = 0);
384
+
385
+ return (Index);
386
+
387
+ } /* AddIntProto */
388
+
389
+
390
+ /*---------------------------------------------------------------------------*/
391
+ void
392
+ AddProtoToClassPruner (PROTO Proto, CLASS_ID ClassId, INT_TEMPLATES Templates)
393
+ /*
394
+ ** Parameters:
395
+ ** Proto floating-pt proto to add to class pruner
396
+ ** ClassId class id corresponding to Proto
397
+ ** Templates set of templates containing class pruner
398
+ ** Globals:
399
+ ** NumCPLevels number of levels used in the class pruner
400
+ ** Operation: This routine adds Proto to the class pruning tables
401
+ ** for the specified class in Templates.
402
+ ** Return: none
403
+ ** Exceptions: none
404
+ ** History: Wed Feb 13 08:49:54 1991, DSJ, Created.
405
+ */
406
+ #define MAX_LEVEL 2
407
+ {
408
+ CLASS_PRUNER Pruner;
409
+ uinT32 ClassMask;
410
+ uinT32 ClassCount;
411
+ CLASS_INDEX ClassIndex;
412
+ uinT32 WordIndex;
413
+ int Level;
414
+ FLOAT32 EndPad, SidePad, AnglePad;
415
+ TABLE_FILLER TableFiller;
416
+ FILL_SPEC FillSpec;
417
+
418
+ ClassIndex = Templates->IndexFor[ClassId];
419
+ Pruner = Templates->ClassPruner [CPrunerIdFor (ClassIndex)];
420
+ WordIndex = CPrunerWordIndexFor (ClassIndex);
421
+ ClassMask = CPrunerMaskFor (MAX_LEVEL, ClassIndex);
422
+
423
+ for (Level = NumCPLevels - 1; Level >= 0; Level--) {
424
+ GetCPPadsForLevel(Level, &EndPad, &SidePad, &AnglePad);
425
+ ClassCount = CPrunerMaskFor (Level, ClassIndex);
426
+ InitTableFiller(EndPad, SidePad, AnglePad, Proto, &TableFiller);
427
+
428
+ while (!FillerDone (&TableFiller)) {
429
+ GetNextFill(&TableFiller, &FillSpec);
430
+ DoFill(&FillSpec, Pruner, ClassMask, ClassCount, WordIndex);
431
+ }
432
+ }
433
+ } /* AddProtoToClassPruner */
434
+
435
+
436
+ /*---------------------------------------------------------------------------*/
437
+ void AddProtoToProtoPruner(PROTO Proto, int ProtoId, INT_CLASS Class) {
438
+ /*
439
+ ** Parameters:
440
+ ** Proto floating-pt proto to be added to proto pruner
441
+ ** ProtoId id of proto
442
+ ** Class integer class that contains desired proto pruner
443
+ ** Globals: none
444
+ ** Operation: This routine updates the proto pruner lookup tables
445
+ ** for Class to include a new proto identified by ProtoId
446
+ ** and described by Proto.
447
+ ** Return: none
448
+ ** Exceptions: none
449
+ ** History: Fri Feb 8 13:07:19 1991, DSJ, Created.
450
+ */
451
+ FLOAT32 Angle, X, Y, Length;
452
+ FLOAT32 Pad;
453
+ int Index;
454
+ PROTO_SET ProtoSet;
455
+
456
+ if (ProtoId >= Class->NumProtos)
457
+ cprintf ("AddProtoToProtoPruner:assert failed: %d < %d",
458
+ ProtoId, Class->NumProtos);
459
+ assert (ProtoId < Class->NumProtos);
460
+
461
+ Index = IndexForProto (ProtoId);
462
+ ProtoSet = Class->ProtoSets[SetForProto (ProtoId)];
463
+
464
+ Angle = Proto->Angle;
465
+ FillPPCircularBits (ProtoSet->ProtoPruner[PRUNER_ANGLE], Index,
466
+ Angle + ANGLE_SHIFT, PPAnglePad / 360.0);
467
+
468
+ Angle *= 2.0 * PI;
469
+ Length = Proto->Length;
470
+
471
+ X = Proto->X + X_SHIFT;
472
+ Pad = max (fabs (cos (Angle)) * (Length / 2.0 +
473
+ PPEndPad * GetPicoFeatureLength ()),
474
+ fabs (sin (Angle)) * (PPSidePad * GetPicoFeatureLength ()));
475
+
476
+ FillPPLinearBits (ProtoSet->ProtoPruner[PRUNER_X], Index, X, Pad);
477
+
478
+ Y = Proto->Y + Y_SHIFT;
479
+ Pad = max (fabs (sin (Angle)) * (Length / 2.0 +
480
+ PPEndPad * GetPicoFeatureLength ()),
481
+ fabs (cos (Angle)) * (PPSidePad * GetPicoFeatureLength ()));
482
+
483
+ FillPPLinearBits (ProtoSet->ProtoPruner[PRUNER_Y], Index, Y, Pad);
484
+
485
+ } /* AddProtoToProtoPruner */
486
+
487
+
488
+ /*---------------------------------------------------------------------------*/
489
+ int BucketFor(FLOAT32 Param, FLOAT32 Offset, int NumBuckets) {
490
+ /*
491
+ ** Parameters:
492
+ ** Param parameter value to map into a bucket number
493
+ ** Offset amount to shift param before mapping it
494
+ ** NumBuckets number of buckets to map param into
495
+ ** Globals: none
496
+ ** Operation: This routine maps a parameter value into a bucket between
497
+ ** 0 and NumBuckets-1. Offset is added to the parameter
498
+ ** before mapping it. Values which map to buckets outside
499
+ ** the range are truncated to fit within the range. Mapping
500
+ ** is done by truncating rather than rounding.
501
+ ** Return: Bucket number corresponding to Param + Offset.
502
+ ** Exceptions: none
503
+ ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
504
+ */
505
+ int Bucket;
506
+
507
+ Bucket = (int) MapParam (Param, Offset, NumBuckets);
508
+ if (Bucket < 0)
509
+ Bucket = 0;
510
+ else if (Bucket >= NumBuckets)
511
+ Bucket = NumBuckets - 1;
512
+ return (Bucket);
513
+
514
+ } /* BucketFor */
515
+
516
+
517
+ /*---------------------------------------------------------------------------*/
518
+ int CircBucketFor(FLOAT32 Param, FLOAT32 Offset, int NumBuckets) {
519
+ /*
520
+ ** Parameters:
521
+ ** Param parameter value to map into a circular bucket
522
+ ** Offset amount to shift param before mapping it
523
+ ** NumBuckets number of buckets to map param into
524
+ ** Globals: none
525
+ ** Operation: This routine maps a parameter value into a bucket between
526
+ ** 0 and NumBuckets-1. Offset is added to the parameter
527
+ ** before mapping it. Values which map to buckets outside
528
+ ** the range are wrapped to a new value in a circular fashion.
529
+ ** Mapping is done by truncating rather than rounding.
530
+ ** Return: Bucket number corresponding to Param + Offset.
531
+ ** Exceptions: none
532
+ ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
533
+ */
534
+ int Bucket;
535
+
536
+ Bucket = (int) MapParam (Param, Offset, NumBuckets);
537
+ if (Bucket < 0)
538
+ Bucket += NumBuckets;
539
+ else if (Bucket >= NumBuckets)
540
+ Bucket -= NumBuckets;
541
+ return (Bucket);
542
+
543
+ } /* CircBucketFor */
544
+
545
+
546
+ /*---------------------------------------------------------------------------*/
547
+ #ifndef GRAPHICS_DISABLED
548
+ void UpdateMatchDisplay() {
549
+ /*
550
+ ** Parameters: none
551
+ ** Globals:
552
+ ** FeatureShapes display list for features
553
+ ** ProtoShapes display list for protos
554
+ ** Operation: This routine clears the global feature and proto
555
+ ** display lists.
556
+ ** Return: none
557
+ ** Exceptions: none
558
+ ** History: Thu Mar 21 15:40:19 1991, DSJ, Created.
559
+ */
560
+ if (IntMatchWindow != NULL)
561
+ c_make_current(IntMatchWindow);
562
+ } /* ClearMatchDisplay */
563
+ #endif
564
+
565
+ /*---------------------------------------------------------------------------*/
566
+ void ConvertConfig(BIT_VECTOR Config, int ConfigId, INT_CLASS Class) {
567
+ /*
568
+ ** Parameters:
569
+ ** Config config to be added to class
570
+ ** ConfigId id to be used for new config
571
+ ** Class class to add new config to
572
+ ** Globals: none
573
+ ** Operation: This operation updates the config vectors of all protos
574
+ ** in Class to indicate that the protos with 1's in Config
575
+ ** belong to a new configuration identified by ConfigId.
576
+ ** It is assumed that the length of the Config bit vector is
577
+ ** equal to the number of protos in Class.
578
+ ** Return: none
579
+ ** Exceptions: none
580
+ ** History: Mon Feb 11 14:57:31 1991, DSJ, Created.
581
+ */
582
+ int ProtoId;
583
+ INT_PROTO Proto;
584
+ int TotalLength;
585
+
586
+ for (ProtoId = 0, TotalLength = 0;
587
+ ProtoId < Class->NumProtos; ProtoId++)
588
+ if (test_bit (Config, ProtoId)) {
589
+ Proto = ProtoForProtoId (Class, ProtoId);
590
+ SET_BIT (Proto->Configs, ConfigId);
591
+ TotalLength += Class->ProtoLengths[ProtoId];
592
+ }
593
+ Class->ConfigLengths[ConfigId] = TotalLength;
594
+ } /* ConvertConfig */
595
+
596
+
597
+ /*---------------------------------------------------------------------------*/
598
+ void ConvertProto(PROTO Proto, int ProtoId, INT_CLASS Class) {
599
+ /*
600
+ ** Parameters:
601
+ ** Proto floating-pt proto to be converted to integer format
602
+ ** ProtoId id of proto
603
+ ** Class integer class to add converted proto to
604
+ ** Globals: none
605
+ ** Operation: This routine converts Proto to integer format and
606
+ ** installs it as ProtoId in Class.
607
+ ** Return: none
608
+ ** Exceptions: none
609
+ ** History: Fri Feb 8 11:22:43 1991, DSJ, Created.
610
+ */
611
+ INT_PROTO P;
612
+ FLOAT32 Param;
613
+
614
+ assert (ProtoId < Class->NumProtos);
615
+
616
+ P = ProtoForProtoId (Class, ProtoId);
617
+
618
+ Param = Proto->A * 128;
619
+ P->A = TruncateParam (Param, -128, 127, NULL);
620
+
621
+ Param = -Proto->B * 256;
622
+ P->B = TruncateParam (Param, 0, 255, NULL);
623
+
624
+ Param = Proto->C * 128;
625
+ P->C = TruncateParam (Param, -128, 127, NULL);
626
+
627
+ Param = Proto->Angle * 256;
628
+ if (Param < 0 || Param >= 256)
629
+ P->Angle = 0;
630
+ else
631
+ P->Angle = (uinT8) Param;
632
+
633
+ /* round proto length to nearest integer number of pico-features */
634
+ Param = (Proto->Length / GetPicoFeatureLength ()) + 0.5;
635
+ Class->ProtoLengths[ProtoId] = TruncateParam (Param, 1, 255, NULL);
636
+ if (LearningDebugLevel >= 2)
637
+ cprintf ("Converted ffeat to (A=%d,B=%d,C=%d,L=%d)",
638
+ P->A, P->B, P->C, Class->ProtoLengths[ProtoId]);
639
+ } /* ConvertProto */
640
+
641
+
642
+ /*---------------------------------------------------------------------------*/
643
+ INT_TEMPLATES CreateIntTemplates(CLASSES FloatProtos,
644
+ const UNICHARSET& target_unicharset) {
645
+ /*
646
+ ** Parameters:
647
+ ** FloatProtos prototypes in old floating pt format
648
+ ** Globals: none
649
+ ** Operation: This routine converts from the old floating point format
650
+ ** to the new integer format.
651
+ ** Return: New set of training templates in integer format.
652
+ ** Exceptions: none
653
+ ** History: Thu Feb 7 14:40:42 1991, DSJ, Created.
654
+ */
655
+ INT_TEMPLATES IntTemplates;
656
+ CLASS_TYPE FClass;
657
+ INT_CLASS IClass;
658
+ int ClassId;
659
+ int ProtoId;
660
+ int ConfigId;
661
+
662
+ IntTemplates = NewIntTemplates ();
663
+
664
+ for (ClassId = 0; ClassId < target_unicharset.size(); ClassId++) {
665
+ FClass = &(FloatProtos[ClassId]);
666
+ if (FClass->NumProtos > 0) {
667
+ assert (UnusedClassIdIn (IntTemplates, ClassId));
668
+ IClass = NewIntClass (FClass->NumProtos, FClass->NumConfigs);
669
+ AddIntClass(IntTemplates, ClassId, IClass);
670
+
671
+ for (ProtoId = 0; ProtoId < FClass->NumProtos; ProtoId++) {
672
+ AddIntProto(IClass);
673
+ ConvertProto (ProtoIn (FClass, ProtoId), ProtoId, IClass);
674
+ AddProtoToProtoPruner (ProtoIn (FClass, ProtoId), ProtoId,
675
+ IClass);
676
+ AddProtoToClassPruner (ProtoIn (FClass, ProtoId), ClassId,
677
+ IntTemplates);
678
+ }
679
+
680
+ for (ConfigId = 0; ConfigId < FClass->NumConfigs; ConfigId++) {
681
+ AddIntConfig(IClass);
682
+ ConvertConfig (FClass->Configurations[ConfigId], ConfigId, IClass);
683
+ }
684
+ }
685
+ }
686
+ return (IntTemplates);
687
+ } /* CreateIntTemplates */
688
+
689
+
690
+ /*---------------------------------------------------------------------------*/
691
+ #ifndef GRAPHICS_DISABLED
692
+ void DisplayIntFeature(INT_FEATURE Feature, FLOAT32 Evidence) {
693
+ /*
694
+ ** Parameters:
695
+ ** Feature pico-feature to be displayed
696
+ ** Evidence best evidence for this feature (0-1)
697
+ ** Globals:
698
+ ** FeatureShapes global display list for features
699
+ ** Operation: This routine renders the specified feature into a
700
+ ** global display list.
701
+ ** Return: none
702
+ ** Exceptions: none
703
+ ** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
704
+ */
705
+ C_COL Color;
706
+
707
+ Color = GetMatchColorFor (Evidence);
708
+ RenderIntFeature(IntMatchWindow, Feature, Color);
709
+ } /* DisplayIntFeature */
710
+
711
+
712
+ /*---------------------------------------------------------------------------*/
713
+ void DisplayIntProto(INT_CLASS Class, PROTO_ID ProtoId, FLOAT32 Evidence) {
714
+ /*
715
+ ** Parameters:
716
+ ** Class class to take proto from
717
+ ** ProtoId id of proto in Class to be displayed
718
+ ** Evidence total evidence for proto (0-1)
719
+ ** Globals:
720
+ ** ProtoShapes global display list for protos
721
+ ** Operation: This routine renders the specified proto into a
722
+ ** global display list.
723
+ ** Return: none
724
+ ** Exceptions: none
725
+ ** History: Thu Mar 21 14:45:04 1991, DSJ, Created.
726
+ */
727
+ C_COL Color;
728
+
729
+ Color = GetMatchColorFor (Evidence);
730
+ RenderIntProto(IntMatchWindow, Class, ProtoId, Color);
731
+
732
+ } /* DisplayIntProto */
733
+ #endif
734
+
735
+ /*---------------------------------------------------------------------------*/
736
+ void InitIntProtoVars() {
737
+ /*
738
+ ** Parameters: none
739
+ ** Globals: none
740
+ ** Operation: Initialize the control variables for the integer proto
741
+ ** routines.
742
+ ** Return: none
743
+ ** Exceptions: none
744
+ ** History: Tue Feb 12 08:04:34 1991, DSJ, Created.
745
+ */
746
+ MakeNumCPLevels();
747
+ MakeCPAnglePadLoose();
748
+ MakeCPAnglePadMedium();
749
+ MakeCPAnglePadTight();
750
+ MakeCPEndPadLoose();
751
+ MakeCPEndPadMedium();
752
+ MakeCPEndPadTight();
753
+ MakeCPSidePadLoose();
754
+ MakeCPSidePadMedium();
755
+ MakeCPSidePadTight();
756
+ MakePPAnglePad();
757
+ MakePPEndPad();
758
+ MakePPSidePad();
759
+ } /* InitIntProtoVars */
760
+
761
+
762
+ /*---------------------------------------------------------------------------*/
763
+ INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs) {
764
+ /*
765
+ ** Parameters:
766
+ ** MaxNumProtos number of protos to allocate space for
767
+ ** MaxNumConfigs number of configs to allocate space for
768
+ ** Globals: none
769
+ ** Operation: This routine creates a new integer class data structure
770
+ ** and returns it. Sufficient space is allocated
771
+ ** to handle the specified number of protos and configs.
772
+ ** Return: New class created.
773
+ ** Exceptions: none
774
+ ** History: Fri Feb 8 10:51:23 1991, DSJ, Created.
775
+ */
776
+ INT_CLASS Class;
777
+ PROTO_SET ProtoSet;
778
+ int i;
779
+ register uinT32 *Word;
780
+
781
+ assert (MaxNumConfigs <= MAX_NUM_CONFIGS);
782
+
783
+ Class = (INT_CLASS) Emalloc (sizeof (INT_CLASS_STRUCT));
784
+ Class->NumProtoSets = ((MaxNumProtos + PROTOS_PER_PROTO_SET - 1) /
785
+ PROTOS_PER_PROTO_SET);
786
+
787
+ assert(Class->NumProtoSets <= MAX_NUM_PROTO_SETS);
788
+
789
+ Class->NumProtos = 0;
790
+ Class->NumConfigs = 0;
791
+
792
+ for (i = 0; i < Class->NumProtoSets; i++) {
793
+ /* allocate space for a proto set, install in class, and initialize */
794
+ ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
795
+ Class->ProtoSets[i] = ProtoSet;
796
+ for (Word = (uinT32 *) (ProtoSet->ProtoPruner);
797
+ Word < (uinT32 *) (ProtoSet->ProtoPruner) + WERDS_PER_PP;
798
+ *Word++ = 0);
799
+
800
+ /* allocate space for the proto lengths and install in class */
801
+ }
802
+ Class->ProtoLengths = (uinT8 *) Emalloc (MaxNumIntProtosIn (Class) *
803
+ sizeof (uinT8));
804
+
805
+ return (Class);
806
+
807
+ } /* NewIntClass */
808
+
809
+
810
+ /*-------------------------------------------------------------------------*/
811
+ void free_int_class( /*class to free */
812
+ INT_CLASS int_class) {
813
+ int i;
814
+
815
+ for (i = 0; i < int_class->NumProtoSets; i++) {
816
+ Efree (int_class->ProtoSets[i]);
817
+ }
818
+ Efree (int_class->ProtoLengths);
819
+ Efree(int_class);
820
+ }
821
+
822
+
823
+ /*---------------------------------------------------------------------------*/
824
+ INT_TEMPLATES NewIntTemplates() {
825
+ /*
826
+ ** Parameters: none
827
+ ** Globals: none
828
+ ** Operation: This routine allocates a new set of integer templates
829
+ ** initialized to hold 0 classes.
830
+ ** Return: The integer templates created.
831
+ ** Exceptions: none
832
+ ** History: Fri Feb 8 08:38:51 1991, DSJ, Created.
833
+ */
834
+ INT_TEMPLATES T;
835
+ int i;
836
+
837
+ T = (INT_TEMPLATES) Emalloc (sizeof (INT_TEMPLATES_STRUCT));
838
+ T->NumClasses = 0;
839
+ T->NumClassPruners = 0;
840
+
841
+ /* initialize mapping tables */
842
+ for (i = 0; i <= MAX_CLASS_ID; i++)
843
+ T->IndexFor[i] = ILLEGAL_CLASS;
844
+ for (i = 0; i < MAX_NUM_CLASSES; i++)
845
+ T->ClassIdFor[i] = NO_CLASS;
846
+
847
+ return (T);
848
+
849
+ } /* NewIntTemplates */
850
+
851
+
852
+ /*---------------------------------------------------------------------------*/
853
+ void free_int_templates(INT_TEMPLATES templates) {
854
+ int i;
855
+
856
+ for (i = 0; i < templates->NumClasses; i++)
857
+ free_int_class (templates->Class[i]);
858
+ for (i = 0; i < templates->NumClassPruners; i++)
859
+ Efree (templates->ClassPruner[i]);
860
+ Efree(templates);
861
+ }
862
+
863
+
864
+ /*---------------------------------------------------------------------------*/
865
+ INT_TEMPLATES ReadIntTemplates(FILE *File, BOOL8 swap) {
866
+ /*
867
+ ** Parameters:
868
+ ** File open file to read templates from
869
+ ** Globals: none
870
+ ** Operation: This routine reads a set of integer templates from
871
+ ** File. File must already be open and must be in the
872
+ ** correct binary format.
873
+ ** Return: Pointer to integer templates read from File.
874
+ ** Exceptions: none
875
+ ** History: Wed Feb 27 11:48:46 1991, DSJ, Created.
876
+ */
877
+ int i, j, x, y, z;
878
+ int nread;
879
+ int unicharset_size;
880
+ int version_id = 0;
881
+ INT_TEMPLATES Templates;
882
+ CLASS_PRUNER Pruner;
883
+ INT_CLASS Class;
884
+ uinT8 *Lengths;
885
+ PROTO_SET ProtoSet;
886
+
887
+ /* first read the high level template struct */
888
+ Templates = NewIntTemplates ();
889
+ // Read Templates in parts for 64 bit compatibility.
890
+ if (fread(&unicharset_size, sizeof(int), 1, File) != 1)
891
+ cprintf ("Bad read of inttemp!\n");
892
+ if (fread(&Templates->NumClasses, sizeof(int), 1, File) != 1 ||
893
+ fread(&Templates->NumClassPruners, sizeof(int), 1, File) != 1)
894
+ cprintf ("Bad read of inttemp!\n");
895
+ // Swap status is determined automatically.
896
+ swap = Templates->NumClassPruners < 0 ||
897
+ Templates->NumClassPruners > MAX_NUM_CLASS_PRUNERS;
898
+ if (swap) {
899
+ reverse32 (&Templates->NumClassPruners);
900
+ reverse32 (&Templates->NumClasses);
901
+ reverse32 (&unicharset_size);
902
+ }
903
+ if (unicharset_size != unicharset.size()) {
904
+ cprintf("Error: %d classes in inttemp while "
905
+ "unicharset contains %d unichars.\n",
906
+ unicharset_size, unicharset.size());
907
+ exit(1);
908
+ }
909
+ if (Templates->NumClasses < 0) {
910
+ // This file has a version id!
911
+ version_id = -Templates->NumClasses;
912
+ if (fread(&Templates->NumClasses, sizeof(Templates->NumClasses),
913
+ 1, File) != 1)
914
+ cprintf("Bad read of inttemp!\n");
915
+ if (swap)
916
+ reverse32 (&Templates->NumClasses);
917
+ }
918
+ for (i = 0; i < unicharset_size; ++i) {
919
+ if (fread(&Templates->IndexFor[i], sizeof(CLASS_INDEX), 1, File) != 1)
920
+ cprintf("Bad read of inttemp!\n");
921
+ }
922
+ for (i = 0; i < Templates->NumClasses; ++i) {
923
+ if (fread(&Templates->ClassIdFor[i], sizeof(CLASS_ID), 1, File) != 1)
924
+ cprintf("Bad read of inttemp!\n");
925
+ }
926
+ if (swap) {
927
+ for (i = 0; i < MAX_CLASS_ID + 1; i++)
928
+ reverse16 (&Templates->IndexFor[i]);
929
+ for (i = 0; i < MAX_NUM_CLASSES; i++)
930
+ reverse32 (&Templates->ClassIdFor[i]);
931
+ }
932
+
933
+ /* then read in the class pruners */
934
+ for (i = 0; i < Templates->NumClassPruners; i++) {
935
+ Pruner = (CLASS_PRUNER) Emalloc (sizeof (CLASS_PRUNER_STRUCT));
936
+ if ((nread =
937
+ fread ((char *) Pruner, 1, sizeof (CLASS_PRUNER_STRUCT),
938
+ File)) != sizeof (CLASS_PRUNER_STRUCT))
939
+ cprintf ("Bad read of inttemp!\n");
940
+ if (swap) {
941
+ for (j = 0; j < NUM_CP_BUCKETS; j++) {
942
+ for (x = 0; x < NUM_CP_BUCKETS; x++) {
943
+ for (y = 0; y < NUM_CP_BUCKETS; y++) {
944
+ for (z = 0; z < WERDS_PER_CP_VECTOR; z++) {
945
+ reverse32 (&Pruner[j][x][y][z]);
946
+ }
947
+ }
948
+ }
949
+ }
950
+ }
951
+ Templates->ClassPruner[i] = Pruner;
952
+ }
953
+
954
+ /* then read in each class */
955
+ for (i = 0; i < Templates->NumClasses; i++) {
956
+ /* first read in the high level struct for the class */
957
+ Class = (INT_CLASS) Emalloc (sizeof (INT_CLASS_STRUCT));
958
+ if (fread(&Class->NumProtos, sizeof(Class->NumProtos), 1, File) != 1 ||
959
+ fread(&Class->NumProtoSets, sizeof(Class->NumProtoSets), 1, File) != 1 ||
960
+ fread(&Class->NumConfigs, sizeof(Class->NumConfigs), 1, File) != 1)
961
+ cprintf ("Bad read of inttemp!\n");
962
+ if (version_id == 0) {
963
+ // Only version 0 writes 5 pointless pointers to the file.
964
+ for (j = 0; j < 5; ++j) {
965
+ int junk;
966
+ if (fread(&junk, sizeof(junk), 1, File) != 1)
967
+ cprintf ("Bad read of inttemp!\n");
968
+ }
969
+ }
970
+ for (j = 0; j < MAX_NUM_CONFIGS; ++j) {
971
+ if (fread(&Class->ConfigLengths[j], sizeof(uinT16), 1, File) != 1)
972
+ cprintf ("Bad read of inttemp!\n");
973
+ }
974
+ if (swap) {
975
+ reverse16 (&Class->NumProtos);
976
+ for (j = 0; j < MAX_NUM_CONFIGS; j++)
977
+ reverse16 (&Class->ConfigLengths[j]);
978
+ }
979
+ Templates->Class[i] = Class;
980
+
981
+ /* then read in the proto lengths */
982
+ Lengths = (uinT8 *) Emalloc (sizeof (uinT8) *
983
+ MaxNumIntProtosIn (Class));
984
+ if ((nread = fread ((char *) Lengths, sizeof (uinT8),
985
+ MaxNumIntProtosIn (Class),
986
+ File)) != MaxNumIntProtosIn (Class))
987
+ cprintf ("Bad read of inttemp!\n");
988
+ Class->ProtoLengths = Lengths;
989
+
990
+ /* then read in the proto sets */
991
+ for (j = 0; j < Class->NumProtoSets; j++) {
992
+ ProtoSet = (PROTO_SET) Emalloc (sizeof (PROTO_SET_STRUCT));
993
+ if ((nread =
994
+ fread ((char *) ProtoSet, 1, sizeof (PROTO_SET_STRUCT),
995
+ File)) != sizeof (PROTO_SET_STRUCT))
996
+ cprintf ("Bad read of inttemp!\n");
997
+ if (swap) {
998
+ for (x = 0; x < NUM_PP_PARAMS; x++)
999
+ for (y = 0; y < NUM_PP_BUCKETS; y++)
1000
+ for (z = 0; z < WERDS_PER_PP_VECTOR; z++)
1001
+ reverse32 (&ProtoSet->ProtoPruner[x][y][z]);
1002
+ for (x = 0; x < PROTOS_PER_PROTO_SET; x++)
1003
+ for (y = 0; y < WERDS_PER_CONFIG_VEC; y++)
1004
+ reverse32 (&ProtoSet->Protos[x].Configs[y]);
1005
+ }
1006
+ Class->ProtoSets[j] = ProtoSet;
1007
+ }
1008
+ }
1009
+ return (Templates);
1010
+ } /* ReadIntTemplates */
1011
+
1012
+
1013
+ /*---------------------------------------------------------------------------*/
1014
+ #ifndef GRAPHICS_DISABLED
1015
+ void ShowMatchDisplay() {
1016
+ /*
1017
+ ** Parameters: none
1018
+ ** Globals:
1019
+ ** FeatureShapes display list containing feature matches
1020
+ ** ProtoShapes display list containing proto matches
1021
+ ** Operation: This routine sends the shapes in the global display
1022
+ ** lists to the match debugger window.
1023
+ ** Return: none
1024
+ ** Exceptions: none
1025
+ ** History: Thu Mar 21 15:47:33 1991, DSJ, Created.
1026
+ */
1027
+ void *window;
1028
+ /* Size of drawable */
1029
+ if (IntMatchWindow == NULL) {
1030
+ IntMatchWindow = c_create_window ("IntMatchWindow", 50, 200,
1031
+ 520, 520,
1032
+ -130.0, 130.0, -130.0, 130.0);
1033
+ SVMenuNode* popup_menu = new SVMenuNode();
1034
+
1035
+ popup_menu->AddChild("Debug Adapted classes", IDA_ADAPTIVE,
1036
+ "x", "Class to debug");
1037
+ popup_menu->AddChild("Debug Static classes", IDA_STATIC,
1038
+ "x", "Class to debug");
1039
+ popup_menu->AddChild("Debug Both", IDA_BOTH,
1040
+ "x", "Class to debug");
1041
+ popup_menu->BuildMenu(IntMatchWindow, false);
1042
+ }
1043
+ else
1044
+ c_clear_window(IntMatchWindow);
1045
+
1046
+ window = IntMatchWindow;
1047
+ c_line_color_index(window, Grey);
1048
+ /* Default size of drawing */
1049
+ if (NormMethod == baseline) {
1050
+ c_move (window, -1000.0, INT_BASELINE);
1051
+ c_draw (window, 1000.0, INT_BASELINE);
1052
+ c_move (window, -1000.0, INT_DESCENDER);
1053
+ c_draw (window, 1000.0, INT_DESCENDER);
1054
+ c_move (window, -1000.0, INT_XHEIGHT);
1055
+ c_draw (window, 1000.0, INT_XHEIGHT);
1056
+ c_move (window, -1000.0, INT_CAPHEIGHT);
1057
+ c_draw (window, 1000.0, INT_CAPHEIGHT);
1058
+ c_move (window, INT_MIN_X, -1000.0);
1059
+ c_draw (window, INT_MIN_X, 1000.0);
1060
+ c_move (window, INT_MAX_X, -1000.0);
1061
+ c_draw (window, INT_MAX_X, 1000.0);
1062
+ }
1063
+ else {
1064
+ c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
1065
+ c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
1066
+ c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
1067
+ c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
1068
+ c_move (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
1069
+ c_draw (window, INT_XCENTER - INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
1070
+ c_move (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER - INT_YRADIUS);
1071
+ c_draw (window, INT_XCENTER + INT_XRADIUS, INT_YCENTER + INT_YRADIUS);
1072
+ c_move(window, INT_MIN_X, INT_MIN_Y);
1073
+ c_draw(window, INT_MIN_X, INT_MAX_Y);
1074
+ c_move(window, INT_MIN_X, INT_MIN_Y);
1075
+ c_draw(window, INT_MAX_X, INT_MIN_Y);
1076
+ c_move(window, INT_MAX_X, INT_MAX_Y);
1077
+ c_draw(window, INT_MIN_X, INT_MAX_Y);
1078
+ c_move(window, INT_MAX_X, INT_MAX_Y);
1079
+ c_draw(window, INT_MAX_X, INT_MIN_Y);
1080
+ }
1081
+ IntMatchWindow->ZoomToRectangle(INT_MIN_X, INT_MIN_Y,
1082
+ INT_MAX_X, INT_MAX_Y);
1083
+ } /* ShowMatchDisplay */
1084
+ #endif
1085
+
1086
+ /*---------------------------------------------------------------------------*/
1087
+ void WriteIntTemplates(FILE *File, INT_TEMPLATES Templates,
1088
+ const UNICHARSET& target_unicharset) {
1089
+ /*
1090
+ ** Parameters:
1091
+ ** File open file to write templates to
1092
+ ** Templates templates to save into File
1093
+ ** Globals: none
1094
+ ** Operation: This routine writes Templates to File. The format
1095
+ ** is an efficient binary format. File must already be open
1096
+ ** for writing.
1097
+ ** Return: none
1098
+ ** Exceptions: none
1099
+ ** History: Wed Feb 27 11:48:46 1991, DSJ, Created.
1100
+ */
1101
+ int i, j;
1102
+ INT_CLASS Class;
1103
+ int unicharset_size = target_unicharset.size();
1104
+ int version_id = -1; // When negated by the reader -1 becomes +1 etc.
1105
+
1106
+ /* first write the high level template struct */
1107
+ fwrite(&unicharset_size, sizeof(unicharset_size), 1, File);
1108
+ fwrite(&version_id, sizeof(version_id), 1, File);
1109
+ fwrite(&Templates->NumClassPruners, sizeof(Templates->NumClassPruners),
1110
+ 1, File);
1111
+ fwrite(&Templates->NumClasses, sizeof(Templates->NumClasses), 1, File);
1112
+ fwrite(&Templates->IndexFor[0], sizeof(Templates->IndexFor[0]),
1113
+ unicharset_size, File);
1114
+ fwrite(&Templates->ClassIdFor[0], sizeof(Templates->ClassIdFor[0]),
1115
+ Templates->NumClasses, File);
1116
+
1117
+ /* then write out the class pruners */
1118
+ for (i = 0; i < Templates->NumClassPruners; i++)
1119
+ fwrite(Templates->ClassPruner[i],
1120
+ sizeof(CLASS_PRUNER_STRUCT), 1, File);
1121
+
1122
+ /* then write out each class */
1123
+ for (i = 0; i < Templates->NumClasses; i++) {
1124
+ Class = Templates->Class[i];
1125
+
1126
+ /* first write out the high level struct for the class */
1127
+ fwrite(&Class->NumProtos, sizeof(Class->NumProtos), 1, File);
1128
+ fwrite(&Class->NumProtoSets, sizeof(Class->NumProtoSets), 1, File);
1129
+ fwrite(&Class->NumConfigs, sizeof(Class->NumConfigs), 1, File);
1130
+ for (j = 0; j < MAX_NUM_CONFIGS; ++j) {
1131
+ fwrite(&Class->ConfigLengths[j], sizeof(uinT16), 1, File);
1132
+ }
1133
+
1134
+ /* then write out the proto lengths */
1135
+ fwrite ((char *) (Class->ProtoLengths), sizeof (uinT8),
1136
+ MaxNumIntProtosIn (Class), File);
1137
+
1138
+ /* then write out the proto sets */
1139
+ for (j = 0; j < Class->NumProtoSets; j++)
1140
+ fwrite ((char *) Class->ProtoSets[j],
1141
+ sizeof (PROTO_SET_STRUCT), 1, File);
1142
+ }
1143
+ } /* WriteIntTemplates */
1144
+
1145
+
1146
+ /**----------------------------------------------------------------------------
1147
+ Private Code
1148
+ ----------------------------------------------------------------------------**/
1149
+ /*---------------------------------------------------------------------------*/
1150
+ FLOAT32 BucketStart(int Bucket, FLOAT32 Offset, int NumBuckets) {
1151
+ /*
1152
+ ** Parameters:
1153
+ ** Bucket bucket whose start is to be computed
1154
+ ** Offset offset used to map params to buckets
1155
+ ** NumBuckets total number of buckets
1156
+ ** Globals: none
1157
+ ** Operation: This routine returns the parameter value which
1158
+ ** corresponds to the beginning of the specified bucket.
1159
+ ** The bucket number should have been generated using the
1160
+ ** BucketFor() function with parameters Offset and NumBuckets.
1161
+ ** Return: Param value corresponding to start position of Bucket.
1162
+ ** Exceptions: none
1163
+ ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
1164
+ */
1165
+ return (((FLOAT32) Bucket / NumBuckets) - Offset);
1166
+
1167
+ } /* BucketStart */
1168
+
1169
+
1170
+ /*---------------------------------------------------------------------------*/
1171
+ FLOAT32 BucketEnd(int Bucket, FLOAT32 Offset, int NumBuckets) {
1172
+ /*
1173
+ ** Parameters:
1174
+ ** Bucket bucket whose end is to be computed
1175
+ ** Offset offset used to map params to buckets
1176
+ ** NumBuckets total number of buckets
1177
+ ** Globals: none
1178
+ ** Operation: This routine returns the parameter value which
1179
+ ** corresponds to the end of the specified bucket.
1180
+ ** The bucket number should have been generated using the
1181
+ ** BucketFor() function with parameters Offset and NumBuckets.
1182
+ ** Return: Param value corresponding to end position of Bucket.
1183
+ ** Exceptions: none
1184
+ ** History: Thu Feb 14 13:24:33 1991, DSJ, Created.
1185
+ */
1186
+ return (((FLOAT32) (Bucket + 1) / NumBuckets) - Offset);
1187
+ } /* BucketEnd */
1188
+
1189
+
1190
+ /*---------------------------------------------------------------------------*/
1191
+ void DoFill(FILL_SPEC *FillSpec,
1192
+ CLASS_PRUNER Pruner,
1193
+ register uinT32 ClassMask,
1194
+ register uinT32 ClassCount,
1195
+ register uinT32 WordIndex) {
1196
+ /*
1197
+ ** Parameters:
1198
+ ** FillSpec specifies which bits to fill in pruner
1199
+ ** Pruner class pruner to be filled
1200
+ ** ClassMask indicates which bits to change in each word
1201
+ ** ClassCount indicates what to change bits to
1202
+ ** WordIndex indicates which word to change
1203
+ ** Globals: none
1204
+ ** Operation: This routine fills in the section of a class pruner
1205
+ ** corresponding to a single x value for a single proto of
1206
+ ** a class.
1207
+ ** Return: none
1208
+ ** Exceptions: none
1209
+ ** History: Tue Feb 19 11:11:29 1991, DSJ, Created.
1210
+ */
1211
+ register int X, Y, Angle;
1212
+ register uinT32 OldWord;
1213
+
1214
+ X = FillSpec->X;
1215
+ if (X < 0)
1216
+ X = 0;
1217
+ if (X >= NUM_CP_BUCKETS)
1218
+ X = NUM_CP_BUCKETS - 1;
1219
+
1220
+ if (FillSpec->YStart < 0)
1221
+ FillSpec->YStart = 0;
1222
+ if (FillSpec->YEnd >= NUM_CP_BUCKETS)
1223
+ FillSpec->YEnd = NUM_CP_BUCKETS - 1;
1224
+
1225
+ for (Y = FillSpec->YStart; Y <= FillSpec->YEnd; Y++)
1226
+ for (Angle = FillSpec->AngleStart;
1227
+ TRUE; CircularIncrement (Angle, NUM_CP_BUCKETS)) {
1228
+ OldWord = Pruner[X][Y][Angle][WordIndex];
1229
+ if (ClassCount > (OldWord & ClassMask)) {
1230
+ OldWord &= ~ClassMask;
1231
+ OldWord |= ClassCount;
1232
+ Pruner[X][Y][Angle][WordIndex] = OldWord;
1233
+ }
1234
+ if (Angle == FillSpec->AngleEnd)
1235
+ break;
1236
+ }
1237
+ } /* DoFill */
1238
+
1239
+
1240
+ /*---------------------------------------------------------------------------*/
1241
+ BOOL8 FillerDone(TABLE_FILLER *Filler) {
1242
+ /*
1243
+ ** Parameters:
1244
+ ** Filler table filler to check if done
1245
+ ** Globals: none
1246
+ ** Operation: Return TRUE if the specified table filler is done, i.e.
1247
+ ** if it has no more lines to fill.
1248
+ ** Return: TRUE if no more lines to fill, FALSE otherwise.
1249
+ ** Exceptions: none
1250
+ ** History: Tue Feb 19 10:08:05 1991, DSJ, Created.
1251
+ */
1252
+ FILL_SWITCH *Next;
1253
+
1254
+ Next = &(Filler->Switch[Filler->NextSwitch]);
1255
+
1256
+ if (Filler->X > Next->X && Next->Type == LastSwitch)
1257
+ return (TRUE);
1258
+ else
1259
+ return (FALSE);
1260
+
1261
+ } /* FillerDone */
1262
+
1263
+
1264
+ /*---------------------------------------------------------------------------*/
1265
+ void
1266
+ FillPPCircularBits (uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
1267
+ int Bit, FLOAT32 Center, FLOAT32 Spread) {
1268
+ /*
1269
+ ** Parameters:
1270
+ ** ParamTable table of bit vectors, one per param bucket
1271
+ ** Bit bit position in vectors to be filled
1272
+ ** Center center of filled area
1273
+ ** Spread spread of filled area
1274
+ ** Globals: none
1275
+ ** Operation: This routine sets Bit in each bit vector whose
1276
+ ** bucket lies within the range Center +- Spread. The fill
1277
+ ** is done for a circular dimension, i.e. bucket 0 is adjacent
1278
+ ** to the last bucket. It is assumed that Center and Spread
1279
+ ** are expressed in a circular coordinate system whose range
1280
+ ** is 0 to 1.
1281
+ ** Return: none
1282
+ ** Exceptions: none
1283
+ ** History: Tue Oct 16 09:26:54 1990, DSJ, Created.
1284
+ */
1285
+ int i, FirstBucket, LastBucket;
1286
+
1287
+ if (Spread > 0.5)
1288
+ Spread = 0.5;
1289
+
1290
+ FirstBucket = (int) floor ((Center - Spread) * NUM_PP_BUCKETS);
1291
+ if (FirstBucket < 0)
1292
+ FirstBucket += NUM_PP_BUCKETS;
1293
+
1294
+ LastBucket = (int) floor ((Center + Spread) * NUM_PP_BUCKETS);
1295
+ if (LastBucket >= NUM_PP_BUCKETS)
1296
+ LastBucket -= NUM_PP_BUCKETS;
1297
+ if (LearningDebugLevel >= 2)
1298
+ cprintf ("Circular fill from %d to %d", FirstBucket, LastBucket);
1299
+ for (i = FirstBucket; TRUE; CircularIncrement (i, NUM_PP_BUCKETS)) {
1300
+ SET_BIT (ParamTable[i], Bit);
1301
+
1302
+ /* exit loop after we have set the bit for the last bucket */
1303
+ if (i == LastBucket)
1304
+ break;
1305
+ }
1306
+
1307
+ } /* FillPPCircularBits */
1308
+
1309
+
1310
+ /*---------------------------------------------------------------------------*/
1311
+ void
1312
+ FillPPLinearBits (uinT32 ParamTable[NUM_PP_BUCKETS][WERDS_PER_PP_VECTOR],
1313
+ int Bit, FLOAT32 Center, FLOAT32 Spread) {
1314
+ /*
1315
+ ** Parameters:
1316
+ ** ParamTable table of bit vectors, one per param bucket
1317
+ ** Bit bit number being filled
1318
+ ** Center center of filled area
1319
+ ** Spread spread of filled area
1320
+ ** Globals: none
1321
+ ** Operation: This routine sets Bit in each bit vector whose
1322
+ ** bucket lies within the range Center +- Spread. The fill
1323
+ ** is done for a linear dimension, i.e. there is no wrap-around
1324
+ ** for this dimension. It is assumed that Center and Spread
1325
+ ** are expressed in a linear coordinate system whose range
1326
+ ** is approximately 0 to 1. Values outside this range will
1327
+ ** be clipped.
1328
+ ** Return: none
1329
+ ** Exceptions: none
1330
+ ** History: Tue Oct 16 09:26:54 1990, DSJ, Created.
1331
+ */
1332
+ int i, FirstBucket, LastBucket;
1333
+
1334
+ FirstBucket = (int) floor ((Center - Spread) * NUM_PP_BUCKETS);
1335
+ if (FirstBucket < 0)
1336
+ FirstBucket = 0;
1337
+
1338
+ LastBucket = (int) floor ((Center + Spread) * NUM_PP_BUCKETS);
1339
+ if (LastBucket >= NUM_PP_BUCKETS)
1340
+ LastBucket = NUM_PP_BUCKETS - 1;
1341
+
1342
+ if (LearningDebugLevel >= 2)
1343
+ cprintf ("Linear fill from %d to %d", FirstBucket, LastBucket);
1344
+ for (i = FirstBucket; i <= LastBucket; i++)
1345
+ SET_BIT (ParamTable[i], Bit);
1346
+
1347
+ } /* FillPPLinearBits */
1348
+
1349
+
1350
+ /*---------------------------------------------------------------------------*/
1351
+ #ifndef GRAPHICS_DISABLED
1352
+ CLASS_ID GetClassToDebug(const char *Prompt) {
1353
+ /*
1354
+ ** Parameters:
1355
+ ** Prompt prompt to print while waiting for input from window
1356
+ ** Globals: none
1357
+ ** Operation: This routine prompts the user with Prompt and waits
1358
+ ** for the user to enter something in the debug window.
1359
+ ** Return: Character entered in the debug window.
1360
+ ** Exceptions: none
1361
+ ** History: Thu Mar 21 16:55:13 1991, DSJ, Created.
1362
+ */
1363
+ tprintf("%s\n", Prompt);
1364
+ SVEvent* ev;
1365
+ SVEventType ev_type;
1366
+ // Wait until a click or popup event.
1367
+ do {
1368
+ ev = IntMatchWindow->AwaitEvent(SVET_ANY);
1369
+ ev_type = ev->type;
1370
+ if (ev_type == SVET_POPUP) {
1371
+ // TODO(rays) must return which menu item was selected, but
1372
+ // that can't be done in this CL without dragging in a lot of
1373
+ // other changes.
1374
+ if (unicharset.contains_unichar(ev->parameter))
1375
+ return unicharset.unichar_to_id(ev->parameter);
1376
+ tprintf("Char class '%s' not found in unicharset",
1377
+ ev->parameter);
1378
+ }
1379
+ delete ev;
1380
+ } while (ev_type != SVET_CLICK);
1381
+ return 0;
1382
+ } /* GetClassToDebug */
1383
+ #endif
1384
+
1385
+ /*---------------------------------------------------------------------------*/
1386
+ void GetCPPadsForLevel(int Level,
1387
+ FLOAT32 *EndPad,
1388
+ FLOAT32 *SidePad,
1389
+ FLOAT32 *AnglePad) {
1390
+ /*
1391
+ ** Parameters:
1392
+ ** Level "tightness" level to return pads for
1393
+ ** EndPad place to put end pad for Level
1394
+ ** SidePad place to put side pad for Level
1395
+ ** AnglePad place to put angle pad for Level
1396
+ ** Globals: none
1397
+ ** Operation: This routine copies the appropriate global pad variables
1398
+ ** into EndPad, SidePad, and AnglePad. This is a kludge used
1399
+ ** to get around the fact that global control variables cannot
1400
+ ** be arrays. If the specified level is illegal, the tightest
1401
+ ** possible pads are returned.
1402
+ ** Return: none (results are returned in EndPad, SidePad, and AnglePad.
1403
+ ** Exceptions: none
1404
+ ** History: Thu Feb 14 08:26:49 1991, DSJ, Created.
1405
+ */
1406
+ switch (Level) {
1407
+ case 0:
1408
+ *EndPad = CPEndPadLoose * GetPicoFeatureLength ();
1409
+ *SidePad = CPSidePadLoose * GetPicoFeatureLength ();
1410
+ *AnglePad = CPAnglePadLoose / 360.0;
1411
+ break;
1412
+
1413
+ case 1:
1414
+ *EndPad = CPEndPadMedium * GetPicoFeatureLength ();
1415
+ *SidePad = CPSidePadMedium * GetPicoFeatureLength ();
1416
+ *AnglePad = CPAnglePadMedium / 360.0;
1417
+ break;
1418
+
1419
+ case 2:
1420
+ *EndPad = CPEndPadTight * GetPicoFeatureLength ();
1421
+ *SidePad = CPSidePadTight * GetPicoFeatureLength ();
1422
+ *AnglePad = CPAnglePadTight / 360.0;
1423
+ break;
1424
+
1425
+ default:
1426
+ *EndPad = CPEndPadTight * GetPicoFeatureLength ();
1427
+ *SidePad = CPSidePadTight * GetPicoFeatureLength ();
1428
+ *AnglePad = CPAnglePadTight / 360.0;
1429
+ break;
1430
+ }
1431
+ if (*AnglePad > 0.5)
1432
+ *AnglePad = 0.5;
1433
+
1434
+ } /* GetCPPadsForLevel */
1435
+
1436
+
1437
+ /*---------------------------------------------------------------------------*/
1438
+ C_COL GetMatchColorFor(FLOAT32 Evidence) {
1439
+ /*
1440
+ ** Parameters:
1441
+ ** Evidence evidence value to return color for
1442
+ ** Globals: none
1443
+ ** Operation:
1444
+ ** Return: Color which corresponds to specified Evidence value.
1445
+ ** Exceptions: none
1446
+ ** History: Thu Mar 21 15:24:52 1991, DSJ, Created.
1447
+ */
1448
+
1449
+ assert (Evidence >= 0.0);
1450
+ assert (Evidence <= 1.0);
1451
+
1452
+ if (Evidence >= 0.90)
1453
+ return White;
1454
+ else if (Evidence >= 0.75)
1455
+ return Green;
1456
+ else if (Evidence >= 0.50)
1457
+ return Red;
1458
+ else
1459
+ return Blue;
1460
+ } /* GetMatchColorFor */
1461
+
1462
+
1463
+ /*---------------------------------------------------------------------------*/
1464
+ void GetNextFill(TABLE_FILLER *Filler, FILL_SPEC *Fill) {
1465
+ /*
1466
+ ** Parameters:
1467
+ ** Filler filler to get next fill spec from
1468
+ ** Fill place to put spec for next fill
1469
+ ** Globals: none
1470
+ ** Operation: This routine returns (in Fill) the specification of
1471
+ ** the next line to be filled from Filler. FillerDone() should
1472
+ ** always be called before GetNextFill() to ensure that we
1473
+ ** do not run past the end of the fill table.
1474
+ ** Return: none (results are returned in Fill)
1475
+ ** Exceptions: none
1476
+ ** History: Tue Feb 19 10:17:42 1991, DSJ, Created.
1477
+ */
1478
+ FILL_SWITCH *Next;
1479
+
1480
+ /* compute the fill assuming no switches will be encountered */
1481
+ Fill->AngleStart = Filler->AngleStart;
1482
+ Fill->AngleEnd = Filler->AngleEnd;
1483
+ Fill->X = Filler->X;
1484
+ Fill->YStart = Filler->YStart >> 8;
1485
+ Fill->YEnd = Filler->YEnd >> 8;
1486
+
1487
+ /* update the fill info and the filler for ALL switches at this X value */
1488
+ Next = &(Filler->Switch[Filler->NextSwitch]);
1489
+ while (Filler->X >= Next->X) {
1490
+ Fill->X = Filler->X = Next->X;
1491
+ if (Next->Type == StartSwitch) {
1492
+ Fill->YStart = Next->Y;
1493
+ Filler->StartDelta = Next->Delta;
1494
+ Filler->YStart = Next->YInit;
1495
+ }
1496
+ else if (Next->Type == EndSwitch) {
1497
+ Fill->YEnd = Next->Y;
1498
+ Filler->EndDelta = Next->Delta;
1499
+ Filler->YEnd = Next->YInit;
1500
+ }
1501
+ else { /* Type must be LastSwitch */
1502
+ break;
1503
+ }
1504
+ Filler->NextSwitch++;
1505
+ Next = &(Filler->Switch[Filler->NextSwitch]);
1506
+ }
1507
+
1508
+ /* prepare the filler for the next call to this routine */
1509
+ Filler->X++;
1510
+ Filler->YStart += Filler->StartDelta;
1511
+ Filler->YEnd += Filler->EndDelta;
1512
+
1513
+ } /* GetNextFill */
1514
+
1515
+
1516
+ /*---------------------------------------------------------------------------*/
1517
+ void
1518
+ InitTableFiller (FLOAT32 EndPad,
1519
+ FLOAT32 SidePad,
1520
+ FLOAT32 AnglePad, PROTO Proto, TABLE_FILLER * Filler)
1521
+ /*
1522
+ ** Parameters:
1523
+ ** EndPad, SidePad, AnglePad padding to add to proto
1524
+ ** Proto proto to create a filler for
1525
+ ** Filler place to put table filler
1526
+ ** Globals: none
1527
+ ** Operation: This routine computes a data structure (Filler)
1528
+ ** which can be used to fill in a rectangle surrounding
1529
+ ** the specified Proto.
1530
+ ** Return: none (results are returned in Filler)
1531
+ ** Exceptions: none
1532
+ ** History: Thu Feb 14 09:27:05 1991, DSJ, Created.
1533
+ */
1534
+ #define XS X_SHIFT
1535
+ #define YS Y_SHIFT
1536
+ #define AS ANGLE_SHIFT
1537
+ #define NB NUM_CP_BUCKETS
1538
+ {
1539
+ FLOAT32 Angle;
1540
+ FLOAT32 X, Y, HalfLength;
1541
+ FLOAT32 Cos, Sin;
1542
+ FLOAT32 XAdjust, YAdjust;
1543
+ FPOINT Start, Switch1, Switch2, End;
1544
+ int S1 = 0;
1545
+ int S2 = 1;
1546
+
1547
+ Angle = Proto->Angle;
1548
+ X = Proto->X;
1549
+ Y = Proto->Y;
1550
+ HalfLength = Proto->Length / 2.0;
1551
+
1552
+ Filler->AngleStart = CircBucketFor (Angle - AnglePad, AS, NB);
1553
+ Filler->AngleEnd = CircBucketFor (Angle + AnglePad, AS, NB);
1554
+ Filler->NextSwitch = 0;
1555
+
1556
+ if (fabs (Angle - 0.0) < HV_TOLERANCE || fabs (Angle - 0.5) < HV_TOLERANCE) {
1557
+ /* horizontal proto - handle as special case */
1558
+ Filler->X = BucketFor (X - HalfLength - EndPad, XS, NB);
1559
+ Filler->YStart = BucketFor (Y - SidePad, YS, NB * 256);
1560
+ Filler->YEnd = BucketFor (Y + SidePad, YS, NB * 256);
1561
+ Filler->StartDelta = 0;
1562
+ Filler->EndDelta = 0;
1563
+ Filler->Switch[0].Type = LastSwitch;
1564
+ Filler->Switch[0].X = BucketFor (X + HalfLength + EndPad, XS, NB);
1565
+ }
1566
+ else if (fabs (Angle - 0.25) < HV_TOLERANCE ||
1567
+ fabs (Angle - 0.75) < HV_TOLERANCE) {
1568
+ /* vertical proto - handle as special case */
1569
+ Filler->X = BucketFor (X - SidePad, XS, NB);
1570
+ Filler->YStart = BucketFor (Y - HalfLength - EndPad, YS, NB * 256);
1571
+ Filler->YEnd = BucketFor (Y + HalfLength + EndPad, YS, NB * 256);
1572
+ Filler->StartDelta = 0;
1573
+ Filler->EndDelta = 0;
1574
+ Filler->Switch[0].Type = LastSwitch;
1575
+ Filler->Switch[0].X = BucketFor (X + SidePad, XS, NB);
1576
+ }
1577
+ else {
1578
+ /* diagonal proto */
1579
+
1580
+ if ((Angle > 0.0 && Angle < 0.25) || (Angle > 0.5 && Angle < 0.75)) {
1581
+ /* rising diagonal proto */
1582
+ Angle *= 2.0 * PI;
1583
+ Cos = fabs (cos (Angle));
1584
+ Sin = fabs (sin (Angle));
1585
+
1586
+ /* compute the positions of the corners of the acceptance region */
1587
+ Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1588
+ Start.y = Y - (HalfLength + EndPad) * Sin + SidePad * Cos;
1589
+ End.x = 2.0 * X - Start.x;
1590
+ End.y = 2.0 * Y - Start.y;
1591
+ Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1592
+ Switch1.y = Y - (HalfLength + EndPad) * Sin - SidePad * Cos;
1593
+ Switch2.x = 2.0 * X - Switch1.x;
1594
+ Switch2.y = 2.0 * Y - Switch1.y;
1595
+
1596
+ if (Switch1.x > Switch2.x) {
1597
+ S1 = 1;
1598
+ S2 = 0;
1599
+ }
1600
+
1601
+ /* translate into bucket positions and deltas */
1602
+ Filler->X = (inT8) MapParam (Start.x, XS, NB);
1603
+ Filler->StartDelta = -(inT16) ((Cos / Sin) * 256);
1604
+ Filler->EndDelta = (inT16) ((Sin / Cos) * 256);
1605
+
1606
+ XAdjust = BucketEnd (Filler->X, XS, NB) - Start.x;
1607
+ YAdjust = XAdjust * Cos / Sin;
1608
+ Filler->YStart = (inT16) MapParam (Start.y - YAdjust, YS, NB * 256);
1609
+ YAdjust = XAdjust * Sin / Cos;
1610
+ Filler->YEnd = (inT16) MapParam (Start.y + YAdjust, YS, NB * 256);
1611
+
1612
+ Filler->Switch[S1].Type = StartSwitch;
1613
+ Filler->Switch[S1].X = (inT8) MapParam (Switch1.x, XS, NB);
1614
+ Filler->Switch[S1].Y = (inT8) MapParam (Switch1.y, YS, NB);
1615
+ XAdjust = Switch1.x - BucketStart (Filler->Switch[S1].X, XS, NB);
1616
+ YAdjust = XAdjust * Sin / Cos;
1617
+ Filler->Switch[S1].YInit =
1618
+ (inT16) MapParam (Switch1.y - YAdjust, YS, NB * 256);
1619
+ Filler->Switch[S1].Delta = Filler->EndDelta;
1620
+
1621
+ Filler->Switch[S2].Type = EndSwitch;
1622
+ Filler->Switch[S2].X = (inT8) MapParam (Switch2.x, XS, NB);
1623
+ Filler->Switch[S2].Y = (inT8) MapParam (Switch2.y, YS, NB);
1624
+ XAdjust = Switch2.x - BucketStart (Filler->Switch[S2].X, XS, NB);
1625
+ YAdjust = XAdjust * Cos / Sin;
1626
+ Filler->Switch[S2].YInit =
1627
+ (inT16) MapParam (Switch2.y + YAdjust, YS, NB * 256);
1628
+ Filler->Switch[S2].Delta = Filler->StartDelta;
1629
+
1630
+ Filler->Switch[2].Type = LastSwitch;
1631
+ Filler->Switch[2].X = (inT8) MapParam (End.x, XS, NB);
1632
+ }
1633
+ else {
1634
+ /* falling diagonal proto */
1635
+ Angle *= 2.0 * PI;
1636
+ Cos = fabs (cos (Angle));
1637
+ Sin = fabs (sin (Angle));
1638
+
1639
+ /* compute the positions of the corners of the acceptance region */
1640
+ Start.x = X - (HalfLength + EndPad) * Cos - SidePad * Sin;
1641
+ Start.y = Y + (HalfLength + EndPad) * Sin - SidePad * Cos;
1642
+ End.x = 2.0 * X - Start.x;
1643
+ End.y = 2.0 * Y - Start.y;
1644
+ Switch1.x = X - (HalfLength + EndPad) * Cos + SidePad * Sin;
1645
+ Switch1.y = Y + (HalfLength + EndPad) * Sin + SidePad * Cos;
1646
+ Switch2.x = 2.0 * X - Switch1.x;
1647
+ Switch2.y = 2.0 * Y - Switch1.y;
1648
+
1649
+ if (Switch1.x > Switch2.x) {
1650
+ S1 = 1;
1651
+ S2 = 0;
1652
+ }
1653
+
1654
+ /* translate into bucket positions and deltas */
1655
+ Filler->X = (inT8) MapParam (Start.x, XS, NB);
1656
+ Filler->StartDelta = -(inT16) ((Sin / Cos) * 256);
1657
+ Filler->EndDelta = (inT16) ((Cos / Sin) * 256);
1658
+
1659
+ XAdjust = BucketEnd (Filler->X, XS, NB) - Start.x;
1660
+ YAdjust = XAdjust * Sin / Cos;
1661
+ Filler->YStart = (inT16) MapParam (Start.y - YAdjust, YS, NB * 256);
1662
+ YAdjust = XAdjust * Cos / Sin;
1663
+ Filler->YEnd = (inT16) MapParam (Start.y + YAdjust, YS, NB * 256);
1664
+
1665
+ Filler->Switch[S1].Type = EndSwitch;
1666
+ Filler->Switch[S1].X = (inT8) MapParam (Switch1.x, XS, NB);
1667
+ Filler->Switch[S1].Y = (inT8) MapParam (Switch1.y, YS, NB);
1668
+ XAdjust = Switch1.x - BucketStart (Filler->Switch[S1].X, XS, NB);
1669
+ YAdjust = XAdjust * Sin / Cos;
1670
+ Filler->Switch[S1].YInit =
1671
+ (inT16) MapParam (Switch1.y + YAdjust, YS, NB * 256);
1672
+ Filler->Switch[S1].Delta = Filler->StartDelta;
1673
+
1674
+ Filler->Switch[S2].Type = StartSwitch;
1675
+ Filler->Switch[S2].X = (inT8) MapParam (Switch2.x, XS, NB);
1676
+ Filler->Switch[S2].Y = (inT8) MapParam (Switch2.y, YS, NB);
1677
+ XAdjust = Switch2.x - BucketStart (Filler->Switch[S2].X, XS, NB);
1678
+ YAdjust = XAdjust * Cos / Sin;
1679
+ Filler->Switch[S2].YInit =
1680
+ (inT16) MapParam (Switch2.y - YAdjust, YS, NB * 256);
1681
+ Filler->Switch[S2].Delta = Filler->EndDelta;
1682
+
1683
+ Filler->Switch[2].Type = LastSwitch;
1684
+ Filler->Switch[2].X = (inT8) MapParam (End.x, XS, NB);
1685
+ }
1686
+ }
1687
+ } /* InitTableFiller */
1688
+
1689
+
1690
+ /*---------------------------------------------------------------------------*/
1691
+ #ifndef GRAPHICS_DISABLED
1692
+ void RenderIntFeature(void *window, INT_FEATURE Feature, C_COL Color) {
1693
+ /*
1694
+ ** Parameters:
1695
+ ** ShapeList shape list to add feature rendering to
1696
+ ** Feature feature to be rendered
1697
+ ** Color color to use for feature rendering
1698
+ ** Globals: none
1699
+ ** Operation: This routine renders the specified feature into ShapeList.
1700
+ ** Return: New shape list with rendering of Feature added.
1701
+ ** Exceptions: none
1702
+ ** History: Thu Mar 21 14:57:41 1991, DSJ, Created.
1703
+ */
1704
+ FLOAT32 X, Y, Dx, Dy, Length;
1705
+
1706
+ c_line_color_index(window, Color);
1707
+ assert (Feature != NULL);
1708
+ assert (Color != 0);
1709
+
1710
+ X = Feature->X - DISPLAY_OFFSET;
1711
+ Y = Feature->Y - DISPLAY_OFFSET;
1712
+ Length = GetPicoFeatureLength () * 0.7 * INT_CHAR_NORM_RANGE;
1713
+ Dx = (Length / 2.0) * cos ((Feature->Theta / 256.0) * 2.0 * PI);
1714
+ Dy = (Length / 2.0) * sin ((Feature->Theta / 256.0) * 2.0 * PI);
1715
+
1716
+ c_move (window, X - Dx, Y - Dy);
1717
+ c_draw (window, X + Dx, Y + Dy);
1718
+ c_move (window, X - Dx - Dy * DOUBLE_OFFSET, Y - Dy + Dx * DOUBLE_OFFSET);
1719
+ c_draw (window, X + Dx - Dy * DOUBLE_OFFSET, Y + Dy + Dx * DOUBLE_OFFSET);
1720
+ } /* RenderIntFeature */
1721
+
1722
+
1723
+ /*---------------------------------------------------------------------------*/
1724
+ void RenderIntProto(void *window,
1725
+ INT_CLASS Class,
1726
+ PROTO_ID ProtoId,
1727
+ C_COL Color) {
1728
+ /*
1729
+ ** Parameters:
1730
+ ** ShapeList shape list to append proto rendering onto
1731
+ ** Class class that proto is contained in
1732
+ ** ProtoId id of proto to be rendered
1733
+ ** Color color to render proto in
1734
+ ** Globals: none
1735
+ ** Operation: This routine extracts the parameters of the specified
1736
+ ** proto from the class description and adds a rendering of
1737
+ ** the proto onto the ShapeList.
1738
+ ** Return: New shape list with a rendering of one proto added.
1739
+ ** Exceptions: none
1740
+ ** History: Thu Mar 21 10:21:09 1991, DSJ, Created.
1741
+ */
1742
+ PROTO_SET ProtoSet;
1743
+ INT_PROTO Proto;
1744
+ int ProtoSetIndex;
1745
+ int ProtoWordIndex;
1746
+ FLOAT32 Length;
1747
+ int Xmin, Xmax, Ymin, Ymax;
1748
+ FLOAT32 X, Y, Dx, Dy;
1749
+ uinT32 ProtoMask;
1750
+ int Bucket;
1751
+
1752
+ assert (ProtoId >= 0);
1753
+ assert (Class != NULL);
1754
+ assert (ProtoId < Class->NumProtos);
1755
+ assert (Color != 0);
1756
+ c_line_color_index(window, Color);
1757
+
1758
+ ProtoSet = Class->ProtoSets[SetForProto (ProtoId)];
1759
+ ProtoSetIndex = IndexForProto (ProtoId);
1760
+ Proto = &(ProtoSet->Protos[ProtoSetIndex]);
1761
+ Length = (Class->ProtoLengths[ProtoId] *
1762
+ GetPicoFeatureLength () * INT_CHAR_NORM_RANGE);
1763
+ ProtoMask = PPrunerMaskFor (ProtoId);
1764
+ ProtoWordIndex = PPrunerWordIndexFor (ProtoId);
1765
+
1766
+ // find the x and y extent of the proto from the proto pruning table
1767
+ Xmin = Ymin = NUM_PP_BUCKETS;
1768
+ Xmax = Ymax = 0;
1769
+ for (Bucket = 0; Bucket < NUM_PP_BUCKETS; Bucket++) {
1770
+ if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_X][Bucket][ProtoWordIndex]) {
1771
+ if (Bucket < Xmin)
1772
+ Xmin = Bucket;
1773
+ else if (Bucket > Xmax)
1774
+ Xmax = Bucket;
1775
+ }
1776
+
1777
+ if (ProtoMask & ProtoSet->ProtoPruner[PRUNER_Y][Bucket][ProtoWordIndex]) {
1778
+ if (Bucket < Ymin)
1779
+ Ymin = Bucket;
1780
+ else if (Bucket > Ymax)
1781
+ Ymax = Bucket;
1782
+ }
1783
+ }
1784
+ X = (Xmin + Xmax + 1) / 2.0 * PROTO_PRUNER_SCALE - DISPLAY_OFFSET;
1785
+ Y = (Ymin + Ymax + 1) / 2.0 * PROTO_PRUNER_SCALE - DISPLAY_OFFSET;
1786
+ Dx = (Length / 2.0) * cos ((Proto->Angle / 256.0) * 2.0 * PI);
1787
+ Dy = (Length / 2.0) * sin ((Proto->Angle / 256.0) * 2.0 * PI);
1788
+
1789
+ c_move (window, X - Dx, Y - Dy);
1790
+ c_draw (window, X + Dx, Y + Dy);
1791
+ } /* RenderIntProto */
1792
+ #endif
1793
+
1794
+ /*---------------------------------------------------------------------------*/
1795
+ int TruncateParam(FLOAT32 Param, int Min, int Max, char *Id) {
1796
+ /*
1797
+ ** Parameters:
1798
+ ** Param parameter value to be truncated
1799
+ ** Min, Max parameter limits (inclusive)
1800
+ ** Id string id of parameter for error messages
1801
+ ** Globals: none
1802
+ ** Operation: This routine truncates Param to lie within the range
1803
+ ** of Min-Max inclusive. If a truncation is performed, and
1804
+ ** Id is not null, an warning message is printed.
1805
+ ** Return: Truncated parameter.
1806
+ ** Exceptions: none
1807
+ ** History: Fri Feb 8 11:54:28 1991, DSJ, Created.
1808
+ */
1809
+ if (Param < Min) {
1810
+ if (Id)
1811
+ cprintf ("Warning: Param %s truncated from %f to %d!\n",
1812
+ Id, Param, Min);
1813
+ Param = Min;
1814
+ }
1815
+ else if (Param > Max) {
1816
+ if (Id)
1817
+ cprintf ("Warning: Param %s truncated from %f to %d!\n",
1818
+ Id, Param, Max);
1819
+ Param = Max;
1820
+ }
1821
+ return (int) floor (Param);
1822
+
1823
+ } /* TruncateParam */