35 #define INTERSECTING INT16_MAX//no winding number
91 static void FakeOutline(
const TBOX& box, C_OUTLINE_LIST* outlines);
100 return flags.bit(mask);
105 flags.set_bit(mask, value);
108 C_OUTLINE_LIST *child() {
113 const TBOX &bounding_box()
const {
119 int shift = stepindex%4 * 2;
120 uint8_t mask = 3 << shift;
121 steps[stepindex/4] = ((stepdir << shift) & mask) |
122 (steps[stepindex/4] & ~mask);
131 set_step(stepindex, chaindir);
135 int32_t pathlength()
const {
139 DIR128 step_dir(
int index)
const {
140 return DIR128(static_cast<int16_t>(((steps[index/4] >> (index%4 * 2)) &
STEP_MASK) <<
144 ICOORD step(
int index)
const {
145 return step_coords[chain_code(index)];
148 const ICOORD &start_pos()
const {
153 ICOORD position_at_index(
int index)
const {
155 for (
int i = 0; i < index; ++i)
163 FCOORD sub_pixel_pos_at_index(
const ICOORD& pos,
int index)
const {
164 const ICOORD& step_to_next(step(index));
165 FCOORD f_pos(pos.
x() + step_to_next.
x() / 2.0f,
166 pos.
y() + step_to_next.
y() / 2.0f);
167 if (offsets !=
nullptr && offsets[index].pixel_diff > 0) {
168 float offset = offsets[index].offset_numerator;
169 offset /= offsets[index].pixel_diff;
170 if (step_to_next.
x() != 0)
171 f_pos.
set_y(f_pos.y() + offset);
173 f_pos.set_x(f_pos.x() + offset);
178 int direction_at_index(
int index)
const {
179 if (offsets !=
nullptr && offsets[index].pixel_diff > 0)
180 return offsets[index].direction;
187 int edge_strength_at_index(
int index)
const {
188 if (offsets !=
nullptr)
189 return offsets[index].pixel_diff;
195 int chain_code(
int index)
const {
196 return (steps[index / 4] >> (index % 4 * 2)) &
STEP_MASK;
199 int32_t area()
const;
200 int32_t perimeter()
const;
201 int32_t outer_area()
const;
202 int32_t count_transitions(
210 return other < *
this;
212 int16_t winding_number(
215 int16_t turn_direction()
const;
225 bool IsLegallyNested()
const;
232 void RemoveSmallRecursive(
int min_size, C_OUTLINE_IT* it);
236 void ComputeEdgeOffsets(
int threshold, Pix* pix);
239 void ComputeBinaryOffsets();
243 void render(
int left,
int top, Pix* pix)
const;
249 #ifndef GRAPHICS_DISABLED
257 #endif // GRAPHICS_DISABLED
267 static ICOORD chain_step(
int chaindir);
273 static const int kMaxOutlineLength = 16000;
280 void increment_step(
int s,
int increment,
ICOORD* pos,
int* dir_counts,
281 int* pos_totals)
const;
282 int step_mem()
const {
return (stepcount+3) / 4; }
290 C_OUTLINE_LIST children;
291 static ICOORD step_coords[4];