00001
00021 #ifndef BESTFIRST_H
00022 #define BESTFIRST_H
00023
00024
00025
00026
00027 #include "oldheap.h"
00028 #include "closed.h"
00029 #include "choicearr.h"
00030 #include "associate.h"
00031 #include "choices.h"
00032 #include "states.h"
00033 #include "stopper.h"
00034 #include "blobs.h"
00035 #include "tessclas.h"
00036 #include "seam.h"
00037
00038
00039
00040
00050 typedef struct
00051 {
00052 HEAP *open_states;
00053 HASH_TABLE closed_states;
00054 STATE *this_state;
00055 STATE *first_state;
00056 STATE *best_state;
00057 int num_joints;
00058 long num_states;
00059 long before_best;
00060 A_CHOICE *best_choice;
00061 A_CHOICE *raw_choice;
00062 } SEARCH_RECORD;
00063
00064
00065
00066
00067 extern int num_seg_states;
00068 extern int num_popped;
00069
00070
00071
00072
00077 #define chunks_gap(chunk_widths,last_chunk) \
00078 ((last_chunk < (chunk_widths)->num_chars - 1) ? \
00079 ((chunk_widths)->widths[last_chunk * 2 + 1]) : \
00080 (0))
00081
00082
00083
00084
00085 void init_bestfirst_vars();
00086
00087 void best_first_search(CHUNKS_RECORD *chunks_record,
00088 A_CHOICE *best_choice,
00089 A_CHOICE *raw_choice,
00090 STATE *state,
00091 DANGERR *fixpt,
00092 STATE *best_state,
00093 INT32 pass);
00094
00095 int chunks_width(WIDTH_RECORD *width_record, int start_chunk, int last_chunk);
00096
00097 void delete_search(SEARCH_RECORD *the_search);
00098
00099 CHOICES_LIST evaluate_chunks(CHUNKS_RECORD *chunks_record,
00100 SEARCH_STATE search_state,
00101 STATE *this_state,
00102 STATE *best_state,
00103 INT32 pass);
00104
00105 INT16 evaluate_state(CHUNKS_RECORD *chunks_record,
00106 SEARCH_RECORD *the_search,
00107 DANGERR *fixpt,
00108 STATE *best_state,
00109 INT32 pass);
00110
00111 CHOICES_LIST rebuild_current_state(TBLOB *blobs,
00112 SEAMS seam_list,
00113 STATE *state,
00114 CHOICES_LIST old_choices,
00115 int fx);
00116
00117 void expand_node(CHUNKS_RECORD *chunks_record, SEARCH_RECORD *the_search);
00118
00119 SEARCH_RECORD *new_search(CHUNKS_RECORD *chunks_record,
00120 int num_joints,
00121 A_CHOICE *best_choice,
00122 A_CHOICE *raw_choice,
00123 STATE *state);
00124
00125 STATE *pop_queue(HEAP *queue);
00126
00127 void push_queue(HEAP *queue, STATE *state, FLOAT32 priority);
00128
00129 void replace_char_widths(CHUNKS_RECORD *chunks_record, SEARCH_STATE state);
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202 #endif