tesseract  4.0.0-1-g2a2b
tesseract::GridBase Class Reference

#include <bbgrid.h>

Inheritance diagram for tesseract::GridBase:
tesseract::BBGrid< BLOBNBOX, BLOBNBOX_CLIST, BLOBNBOX_C_IT > tesseract::BBGrid< ColPartition, ColPartition_CLIST, ColPartition_C_IT > tesseract::BBGrid< ColSegment, ColSegment_CLIST, ColSegment_C_IT > tesseract::BBGrid< BBC, BBC_CLIST, BBC_C_IT > tesseract::IntGrid tesseract::BlobGrid tesseract::ColPartitionGrid tesseract::AlignedBlob tesseract::CCNonTextDetect tesseract::StrokeWidth tesseract::TabFind tesseract::ColumnFinder

Public Member Functions

 GridBase ()=default
 
 GridBase (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
virtual ~GridBase ()
 
void Init (int gridsize, const ICOORD &bleft, const ICOORD &tright)
 
int gridsize () const
 
int gridwidth () const
 
int gridheight () const
 
const ICOORDbleft () const
 
const ICOORDtright () const
 
void GridCoords (int x, int y, int *grid_x, int *grid_y) const
 
void ClipGridCoords (int *x, int *y) const
 

Protected Attributes

int gridsize_
 
int gridwidth_
 
int gridheight_
 
int gridbuckets_
 
ICOORD bleft_
 
ICOORD tright_
 

Detailed Description

Definition at line 53 of file bbgrid.h.

Constructor & Destructor Documentation

◆ GridBase() [1/2]

tesseract::GridBase::GridBase ( )
default

◆ GridBase() [2/2]

tesseract::GridBase::GridBase ( int  gridsize,
const ICOORD bleft,
const ICOORD tright 
)

Definition at line 30 of file bbgrid.cpp.

30  {
32 }
int gridsize() const
Definition: bbgrid.h:64
const ICOORD & bleft() const
Definition: bbgrid.h:73
void Init(int gridsize, const ICOORD &bleft, const ICOORD &tright)
Definition: bbgrid.cpp:41
const ICOORD & tright() const
Definition: bbgrid.h:76

◆ ~GridBase()

tesseract::GridBase::~GridBase ( )
virtualdefault

Member Function Documentation

◆ bleft()

const ICOORD& tesseract::GridBase::bleft ( ) const
inline

Definition at line 73 of file bbgrid.h.

73  {
74  return bleft_;
75  }

◆ ClipGridCoords()

void tesseract::GridBase::ClipGridCoords ( int *  x,
int *  y 
) const

Definition at line 60 of file bbgrid.cpp.

60  {
61  *x = ClipToRange(*x, 0, gridwidth_ - 1);
62  *y = ClipToRange(*y, 0, gridheight_ - 1);
63 }
T ClipToRange(const T &x, const T &lower_bound, const T &upper_bound)
Definition: helpers.h:111

◆ GridCoords()

void tesseract::GridBase::GridCoords ( int  x,
int  y,
int *  grid_x,
int *  grid_y 
) const

Definition at line 53 of file bbgrid.cpp.

53  {
54  *grid_x = (x - bleft_.x()) / gridsize_;
55  *grid_y = (y - bleft_.y()) / gridsize_;
56  ClipGridCoords(grid_x, grid_y);
57 }
int16_t y() const
access_function
Definition: points.h:57
int16_t x() const
access function
Definition: points.h:53
void ClipGridCoords(int *x, int *y) const
Definition: bbgrid.cpp:60

◆ gridheight()

int tesseract::GridBase::gridheight ( ) const
inline

Definition at line 70 of file bbgrid.h.

70  {
71  return gridheight_;
72  }

◆ gridsize()

int tesseract::GridBase::gridsize ( ) const
inline

Definition at line 64 of file bbgrid.h.

64  {
65  return gridsize_;
66  }

◆ gridwidth()

int tesseract::GridBase::gridwidth ( ) const
inline

Definition at line 67 of file bbgrid.h.

67  {
68  return gridwidth_;
69  }

◆ Init()

void tesseract::GridBase::Init ( int  gridsize,
const ICOORD bleft,
const ICOORD tright 
)

Definition at line 41 of file bbgrid.cpp.

41  {
43  bleft_ = bleft;
44  tright_ = tright;
45  if (gridsize_ == 0)
46  gridsize_ = 1;
47  gridwidth_ = (tright.x() - bleft.x() + gridsize_ - 1) / gridsize_;
48  gridheight_ = (tright.y() - bleft.y() + gridsize_ - 1) / gridsize_;
50 }
int gridsize() const
Definition: bbgrid.h:64
const ICOORD & bleft() const
Definition: bbgrid.h:73
int16_t y() const
access_function
Definition: points.h:57
ICOORD tright_
Definition: bbgrid.h:92
int16_t x() const
access function
Definition: points.h:53
const ICOORD & tright() const
Definition: bbgrid.h:76

◆ tright()

const ICOORD& tesseract::GridBase::tright ( ) const
inline

Definition at line 76 of file bbgrid.h.

76  {
77  return tright_;
78  }
ICOORD tright_
Definition: bbgrid.h:92

Member Data Documentation

◆ bleft_

ICOORD tesseract::GridBase::bleft_
protected

Definition at line 91 of file bbgrid.h.

◆ gridbuckets_

int tesseract::GridBase::gridbuckets_
protected

Definition at line 90 of file bbgrid.h.

◆ gridheight_

int tesseract::GridBase::gridheight_
protected

Definition at line 89 of file bbgrid.h.

◆ gridsize_

int tesseract::GridBase::gridsize_
protected

Definition at line 87 of file bbgrid.h.

◆ gridwidth_

int tesseract::GridBase::gridwidth_
protected

Definition at line 88 of file bbgrid.h.

◆ tright_

ICOORD tesseract::GridBase::tright_
protected

Definition at line 92 of file bbgrid.h.


The documentation for this class was generated from the following files: