35 #include "genericvector.h" 38 #include "publictypes.h" 40 #include "scrollview.h" 59 TPOINT(int16_t vx, int16_t vy) :
x(vx),
y(vy) {}
71 return x == other.
x &&
y == other.
y;
85 : next(nullptr), prev(nullptr), src_outline(nullptr), start_step(0), step_count(0) {
86 memset(flags, 0, EDGEPTFLAGS *
sizeof(flags[0]));
99 memcpy(flags, src.
flags, EDGEPTFLAGS *
sizeof(flags[0]));
107 int x_dist = pos.x - other.
pos.
x;
108 int y_dist = pos.y - other.
pos.
y;
109 return x_dist * x_dist * x_factor + y_dist * y_dist;
116 TBOX box(pos.x, pos.y, pos.x, pos.y);
124 }
while (pt != end && pt !=
this);
131 const EDGEPT* pt = this->next;
134 area += CROSS(origin_vec, pt->
vec);
136 }
while (pt != end && pt !=
this);
146 if (pt == end)
return true;
149 }
while (pt !=
this && count <= min_points);
161 return flags[0] != 0;
167 return flags[2] != 0;
175 char flags[EDGEPTFLAGS];
188 TESSLINE() : is_hole(false), loop(nullptr), next(nullptr) {}
189 TESSLINE(
const TESSLINE& src) : loop(nullptr), next(nullptr) {
200 static TESSLINE* BuildFromOutlineList(
EDGEPT* outline);
202 void CopyFrom(
const TESSLINE& src);
206 void Normalize(
const DENORM& denorm);
208 void Rotate(
const FCOORD rotation);
210 void Move(
const ICOORD vec);
212 void Scale(
float factor);
216 void ComputeBoundingBox();
222 void MinMaxCrossProduct(
const TPOINT vec,
int* min_xp,
int* max_xp)
const;
224 TBOX bounding_box()
const;
231 if (Contains(pt1) && Contains(pt2)) {
236 }
while (pt != loop);
242 return topleft.x <= pt.
x && pt.
x <= botright.x &&
243 botright.y <= pt.
y && pt.
y <= topleft.y;
246 #ifndef GRAPHICS_DISABLED 249 #endif // GRAPHICS_DISABLED 253 EDGEPT* FindBestStartPt()
const;
257 return (botright.x - topleft.x) * (topleft.y - botright.y);
284 static TBLOB* PolygonalCopy(
bool allow_detailed_fx,
C_BLOB* src);
292 TBLOB* ClassifyNormalizeIfNeeded()
const;
295 void CopyFrom(
const TBLOB& src);
301 void Normalize(
const BLOCK* block,
303 const DENORM* predecessor,
304 float x_origin,
float y_origin,
305 float x_scale,
float y_scale,
306 float final_xshift,
float final_yshift,
307 bool inverse, Pix* pix);
309 void Rotate(
const FCOORD rotation);
311 void Move(
const ICOORD vec);
313 void Scale(
float factor);
315 void ComputeBoundingBoxes();
318 int NumOutlines()
const;
320 TBOX bounding_box()
const;
324 for (
const TESSLINE* outline = outlines; outline !=
nullptr;
325 outline = outline->
next) {
326 if (outline->SegmentCrosses(pt1, pt2))
return true;
332 for (
const TESSLINE* outline = outlines; outline !=
nullptr;
333 outline = outline->
next) {
334 if (outline->Contains(pt))
return true;
341 void EliminateDuplicateOutlines();
345 void CorrectBlobOrder(
TBLOB* next);
351 #ifndef GRAPHICS_DISABLED 354 #endif // GRAPHICS_DISABLED 358 for (
TESSLINE* outline = outlines; outline !=
nullptr; outline = outline->
next)
359 total_area += outline->BBArea();
367 int ComputeMoments(
FCOORD* center,
FCOORD* second_moments)
const;
370 void GetPreciseBoundingBox(
TBOX* precise_box)
const;
380 void GetEdgeCoords(
const TBOX& box,
392 void CollectEdges(
const TBOX& box,
416 static TWERD* PolygonalCopy(
bool allow_detailed_fx,
WERD* src);
419 void BLNormalize(
const BLOCK* block,
const ROW* row, Pix* pix,
bool inverse,
420 float x_height,
float baseline_shift,
bool numeric_mode,
422 const TBOX* norm_box,
425 void CopyFrom(
const TWERD& src);
429 void ComputeBoundingBoxes();
435 TBOX bounding_box()
const;
439 void MergeBlobs(
int start,
int end);
451 bool divisible_blob(
TBLOB *blob,
bool italic_blob,
TPOINT* location);
453 void divide_blobs(
TBLOB *blob,
TBLOB *other_blob,
bool italic_blob,
EDGEPT * prev
Definition: blobs.h:177
bool Contains(const TPOINT &pt) const
Definition: blobs.h:331
bool SegmentCrossesOutline(const TPOINT &pt1, const TPOINT &pt2) const
Definition: blobs.h:323
int step_count
Definition: blobs.h:181
void set_right(int x)
Definition: rect.h:82
TESSLINE * next
Definition: blobs.h:265
TPOINT topleft
Definition: blobs.h:260
int16_t right() const
Definition: rect.h:79
TESSLINE & operator=(const TESSLINE &src)
Definition: blobs.h:195
int BBArea() const
Definition: blobs.h:356
DENORM denorm_
Definition: blobs.h:399
bool SegmentCrosses(const TPOINT &pt1, const TPOINT &pt2) const
Definition: blobs.h:230
TPOINT start
Definition: blobs.h:262
TWERD & operator=(const TWERD &src)
Definition: blobs.h:410
void operator/=(int divisor)
Definition: blobs.h:66
VECTOR vec
Definition: blobs.h:171
char flags[4]
Definition: blobs.h:175
~TBLOB()
Definition: blobs.h:273
TESSLINE(const TESSLINE &src)
Definition: blobs.h:189
bool EqualPos(const EDGEPT &other) const
Definition: blobs.h:112
bool Contains(const TPOINT &pt) const
Definition: blobs.h:241
void set_left(int x)
Definition: rect.h:75
TBLOB(const TBLOB &src)
Definition: blobs.h:270
bool operator==(const TPOINT &other) const
Definition: blobs.h:70
static bool IsCrossed(const TPOINT &a0, const TPOINT &a1, const TPOINT &b0, const TPOINT &b1)
Definition: blobs.cpp:72
EDGEPT * next
Definition: blobs.h:176
int16_t x
Definition: blobs.h:78
C_OUTLINE * src_outline
Definition: blobs.h:178
int start_step
Definition: blobs.h:180
void Reveal()
Definition: blobs.h:157
TBLOB & operator=(const TBLOB &src)
Definition: blobs.h:276
int BBArea() const
Definition: blobs.h:256
bool SameBox(const TESSLINE &other) const
Definition: blobs.h:226
TPOINT botright
Definition: blobs.h:261
TPOINT()
Definition: blobs.h:58
bool latin_script
Definition: blobs.h:444
int16_t bottom() const
Definition: rect.h:65
void operator+=(const TPOINT &other)
Definition: blobs.h:62
TPOINT(int16_t vx, int16_t vy)
Definition: blobs.h:59
TWERD()
Definition: blobs.h:403
GenericVector< TBLOB * > blobs
Definition: blobs.h:443
void MarkChop()
Definition: blobs.h:163
int NumBlobs() const
Definition: blobs.h:432
Definition: ocrblock.h:30
TWERD(const TWERD &src)
Definition: blobs.h:404
~TWERD()
Definition: blobs.h:407
TESSLINE * outlines
Definition: blobs.h:384
void CopyFrom(const EDGEPT &src)
Definition: blobs.h:96
Definition: stepblob.h:37
void Hide()
Definition: blobs.h:154
EDGEPT()
Definition: blobs.h:84
int WeightedDistance(const EDGEPT &other, int x_factor) const
Definition: blobs.h:106
bool IsChopPt() const
Definition: blobs.h:166
TBOX SegmentBox(const EDGEPT *end) const
Definition: blobs.h:115
TPOINT(const ICOORD &ic)
Definition: blobs.h:60
void set_top(int y)
Definition: rect.h:61
bool ShortNonCircularSegment(int min_points, const EDGEPT *end) const
Definition: blobs.h:142
bool is_hole
Definition: blobs.h:263
integer coordinate
Definition: points.h:32
int16_t top() const
Definition: rect.h:58
Definition: normalis.h:50
const DENORM & denorm() const
Definition: blobs.h:347
EDGEPT(const EDGEPT &src)
Definition: blobs.h:88
EDGEPT & operator=(const EDGEPT &src)
Definition: blobs.h:91
int16_t left() const
Definition: rect.h:72
TESSLINE()
Definition: blobs.h:188
TPOINT pos
Definition: blobs.h:170
bool IsHidden() const
Definition: blobs.h:160
TBLOB()
Definition: blobs.h:269
OcrEngineMode
Definition: publictypes.h:268
void set_bottom(int y)
Definition: rect.h:68
int16_t y
Definition: blobs.h:79
EDGEPT * loop
Definition: blobs.h:264
int SegmentArea(const EDGEPT *end) const
Definition: blobs.h:129
~TESSLINE()
Definition: blobs.h:192