| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#ifndef AUTOTRACE_H |
| 22 |
#define AUTOTRACE_H |
| 23 |
|
| 24 |
#include <stdio.h> |
| 25 |
|
| 26 |
#include "point.h" |
| 27 |
#include "pm_c_util.h" |
| 28 |
#include "ppm.h" |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
typedef struct _at_fitting_opts_type at_fitting_opts_type; |
| 39 |
typedef struct _at_input_opts_type at_input_opts_type; |
| 40 |
typedef struct _at_output_opts_type at_output_opts_type; |
| 41 |
typedef struct _at_bitmap_type at_bitmap_type; |
| 42 |
typedef struct _at_spline_type at_spline_type; |
| 43 |
typedef struct _at_spline_list_type at_spline_list_type; |
| 44 |
typedef struct _at_spline_list_array_type at_spline_list_array_type; |
| 45 |
|
| 46 |
|
| 47 |
typedef enum _at_polynomial_degree |
| 48 |
{ |
| 49 |
AT_LINEARTYPE = 1, |
| 50 |
AT_QUADRATICTYPE = 2, |
| 51 |
AT_CUBICTYPE = 3, |
| 52 |
AT_PARALLELELLIPSETYPE = 4, |
| 53 |
AT_ELLIPSETYPE = 5, |
| 54 |
AT_CIRCLETYPE = 6 |
| 55 |
|
| 56 |
|
| 57 |
} at_polynomial_degree; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
struct _at_spline_type |
| 65 |
{ |
| 66 |
Point v[4]; |
| 67 |
at_polynomial_degree degree; |
| 68 |
float linearity; |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
struct _at_spline_list_type |
| 74 |
{ |
| 75 |
at_spline_type *data; |
| 76 |
unsigned length; |
| 77 |
bool clockwise; |
| 78 |
pixel color; |
| 79 |
bool open; |
| 80 |
}; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
struct _at_spline_list_array_type |
| 85 |
{ |
| 86 |
at_spline_list_type *data; |
| 87 |
unsigned length; |
| 88 |
|
| 89 |
|
| 90 |
unsigned short height, width; |
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
bool backgroundSpec; |
| 95 |
pixel background_color; |
| 96 |
bool centerline; |
| 97 |
bool preserve_width; |
| 98 |
float width_weight_factor; |
| 99 |
|
| 100 |
}; |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
struct _at_fitting_opts_type { |
| 107 |
bool backgroundSpec; |
| 108 |
pixel background_color; |
| 109 |
float corner_always_threshold; |
| 110 |
unsigned corner_surround; |
| 111 |
float corner_threshold; |
| 112 |
float error_threshold; |
| 113 |
unsigned filter_iterations; |
| 114 |
float line_reversion_threshold; |
| 115 |
float line_threshold; |
| 116 |
bool remove_adjacent_corners; |
| 117 |
unsigned tangent_surround; |
| 118 |
bool centerline; |
| 119 |
bool preserve_width; |
| 120 |
float width_weight_factor; |
| 121 |
}; |
| 122 |
|
| 123 |
struct _at_output_opts_type |
| 124 |
{ |
| 125 |
int dpi; |
| 126 |
}; |
| 127 |
|
| 128 |
struct _at_bitmap_type |
| 129 |
{ |
| 130 |
unsigned short height; |
| 131 |
unsigned short width; |
| 132 |
unsigned char *bitmap; |
| 133 |
unsigned int np; |
| 134 |
}; |
| 135 |
|
| 136 |
typedef enum _at_msg_type |
| 137 |
{ |
| 138 |
AT_MSG_FATAL = 1, |
| 139 |
AT_MSG_WARNING |
| 140 |
} at_msg_type; |
| 141 |
|
| 142 |
typedef |
| 143 |
void (* at_msg_func) (const char * const msg, |
| 144 |
at_msg_type const msg_type, |
| 145 |
void * const client_data); |
| 146 |
|
| 147 |
typedef |
| 148 |
int (*at_output_write_func) (FILE * const file, |
| 149 |
const char * const name, |
| 150 |
int const llx, |
| 151 |
int const lly, |
| 152 |
int const urx, |
| 153 |
int const ury, |
| 154 |
at_output_opts_type * const opts, |
| 155 |
at_spline_list_array_type const shape, |
| 156 |
at_msg_func msg_func, |
| 157 |
void * const msg_data); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
typedef |
| 164 |
void (*at_progress_func) (float const percentage, |
| 165 |
void * const client_data); |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
typedef |
| 172 |
bool (*at_testcancel_func) (void * const client_data); |
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
at_fitting_opts_type * at_fitting_opts_new(void); |
| 184 |
at_fitting_opts_type * at_fitting_opts_copy (at_fitting_opts_type * original); |
| 185 |
void at_fitting_opts_free(at_fitting_opts_type * opts); |
| 186 |
|
| 187 |
|
| 188 |
#define at_fitting_opts_doc(opt) _(at_doc__##opt) |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
at_output_opts_type * at_output_opts_new(void); |
| 196 |
at_output_opts_type * at_output_opts_copy(at_output_opts_type * original); |
| 197 |
void at_output_opts_free(at_output_opts_type * opts); |
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
at_spline_list_array_type * |
| 229 |
at_splines_new_full(at_bitmap_type * const bitmap, |
| 230 |
at_fitting_opts_type * const opts, |
| 231 |
at_msg_func msg_func, |
| 232 |
void * const msg_data, |
| 233 |
at_progress_func notify_progress, |
| 234 |
void * const progress_data, |
| 235 |
at_testcancel_func test_cancel, |
| 236 |
void * const testcancel_data); |
| 237 |
|
| 238 |
void |
| 239 |
at_splines_write(at_output_write_func output_writer, |
| 240 |
FILE * const writeto, |
| 241 |
at_output_opts_type * const opts, |
| 242 |
at_spline_list_array_type * const splines, |
| 243 |
at_msg_func msg_func, |
| 244 |
void * const msg_data); |
| 245 |
|
| 246 |
void |
| 247 |
at_splines_free(at_spline_list_array_type * const splines); |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
#ifdef __cplusplus |
| 255 |
} |
| 256 |
#endif |
| 257 |
|
| 258 |
#endif |