Tesseract 3.02

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Attributes | Friends
ICOORD Class Reference

integer coordinate More...

`#include <points.h>`

Inheritance diagram for ICOORD:

List of all members.

## Public Member Functions

| ICOORD ()
| empty constructor
| ICOORD (inT16 xin, inT16 yin)
| ~ICOORD ()
| destructor
inT16 | x () const
| access function
inT16 | y () const
| access_function
void | set_x (inT16 xin)
| rewrite function
void | set_y (inT16 yin)
| rewrite function
void | set_with_shrink (int x, int y)
| Set from the given x,y, shrinking the vector to fit if needed.
float | sqlength () const
| find sq length
float | length () const
| find length
float | pt_to_pt_sqdist (const ICOORD &pt) const
| sq dist between pts
float | pt_to_pt_dist (const ICOORD &pt) const
| Distance between pts.
float | angle () const
| find angle
BOOL8 | operator== (const ICOORD &other) const
| test equality
BOOL8 | operator!= (const ICOORD &other) const
| test inequality
void | rotate (const FCOORD &vec)
void | setup_render (ICOORD *major_step, ICOORD *minor_step, int *major, int *minor) const
bool | Serialize (FILE *fp) const
bool | DeSerialize (bool swap, FILE *fp)

## Protected Attributes

inT16 | xcoord
inT16 | ycoord

## Friends

class | FCOORD
ICOORD | operator! (const ICOORD &)
| rotate 90 deg anti
ICOORD | operator- (const ICOORD &)
| unary minus
ICOORD | operator+ (const ICOORD &, const ICOORD &)
| add
ICOORD & | operator+= (ICOORD &, const ICOORD &)
| add
ICOORD | operator- (const ICOORD &, const ICOORD &)
| subtract
ICOORD & | operator-= (ICOORD &, const ICOORD &)
| subtract
inT32 | operator% (const ICOORD &, const ICOORD &)
| scalar product
inT32 | operator* (const ICOORD &, const ICOORD &)
| cross product
ICOORD | operator* (const ICOORD &, inT16)
| multiply
ICOORD | operator* (inT16, const ICOORD &)
| multiply
ICOORD & | operator*= (ICOORD &, inT16)
| multiply
ICOORD | operator/ (const ICOORD &, inT16)
| divide
ICOORD & | operator/= (ICOORD &, inT16)
| divide

## Detailed Description

integer coordinate

Definition at line 30 of file points.h.

## Constructor & Destructor Documentation

ICOORD::ICOORD | ( |  | ) |

inline

empty constructor

Definition at line 36 of file points.h.

{
xcoord = ycoord = 0; //default zero
}

ICOORD::ICOORD | ( | inT16 | xin,
|  | inT16 | yin
| ) |  |

inline

constructor

Parameters:

  xin | x value
  yin | y value

Definition at line 42 of file points.h.

{
xcoord = xin;
ycoord = yin;
}

ICOORD::~ICOORD | ( |  | ) |

inline

destructor

Definition at line 48 of file points.h.

{
}

## Member Function Documentation

float ICOORD::angle | ( |  | ) | const

inline

find angle

Definition at line 97 of file points.h.

{
return (float) atan2 ((double) ycoord, (double) xcoord);
}

bool ICOORD::DeSerialize | ( | bool | swap,
|  | FILE * | fp
| ) |  |

Definition at line 67 of file points.cpp.

{
if (fread(&xcoord, sizeof(xcoord), 1, fp) != 1) return false;
if (fread(&ycoord, sizeof(ycoord), 1, fp) != 1) return false;
if (swap) {
ReverseN(&xcoord, sizeof(xcoord));
ReverseN(&ycoord, sizeof(ycoord));
}
return true;
}

float ICOORD::length | ( |  | ) | const

inline

find length

Definition at line 78 of file points.h.

{
return (float) sqrt (sqlength ());
}

BOOL8 ICOORD::operator!= | ( | const ICOORD & | other | ) | const

inline

test inequality

Definition at line 106 of file points.h.

{
return xcoord != other.xcoord || ycoord != other.ycoord;
}

BOOL8 ICOORD::operator== | ( | const ICOORD & | other | ) | const

inline

test equality

Definition at line 102 of file points.h.

{
return xcoord == other.xcoord && ycoord == other.ycoord;
}

float ICOORD::pt_to_pt_dist | ( | const ICOORD & | pt | ) | const

inline

Distance between pts.

Definition at line 92 of file points.h.

{
return (float) sqrt (pt_to_pt_sqdist (pt));
}

float ICOORD::pt_to_pt_sqdist | ( | const ICOORD & | pt | ) | const

inline

sq dist between pts

Definition at line 83 of file points.h.

{
ICOORD gap;
gap.xcoord = xcoord - pt.xcoord;
gap.ycoord = ycoord - pt.ycoord;
return gap.sqlength ();
}

void ICOORD::rotate | ( | const FCOORD & | vec | ) |

inline

rotate

Parameters:

  vec | by vector

Definition at line 241 of file ipoints.h.

{
inT16 tmp;
tmp = (inT16) floor (xcoord * vec.x () - ycoord * vec.y () + 0.5);
ycoord = (inT16) floor (ycoord * vec.x () + xcoord * vec.y () + 0.5);
xcoord = tmp;
}

bool ICOORD::Serialize | ( | FILE * | fp | ) | const

Definition at line 60 of file points.cpp.

{
if (fwrite(&xcoord, sizeof(xcoord), 1, fp) != 1) return false;
if (fwrite(&ycoord, sizeof(ycoord), 1, fp) != 1) return false;
return true;
}

void ICOORD::set_with_shrink | ( | int | x,
|  | int | y
| ) |  |

Set from the given x,y, shrinking the vector to fit if needed.

Definition at line 40 of file points.cpp.

{
// Fit the vector into an ICOORD, which is 16 bit.
int factor = 1;
int max_extent = MAX(abs(x), abs(y));
if (max_extent > MAX_INT16)
factor = max_extent / MAX_INT16 + 1;
xcoord = x / factor;
ycoord = y / factor;
}

void ICOORD::set_x | ( | inT16 | xin | ) |

inline

rewrite function

Definition at line 61 of file points.h.

{
xcoord = xin; //write new value
}

void ICOORD::set_y | ( | inT16 | yin | ) |

inline

rewrite function

Definition at line 65 of file points.h.

{ //value to set
ycoord = yin;
}

void ICOORD::setup_render | ( | ICOORD * | major_step,
|  | ICOORD * | minor_step,
|  | int * | major,
|  | int * | minor
| ) |  | const

Setup for iterating over the pixels in a vector by the well-known Bresenham rendering algorithm. Starting with major/2 in the accumulator, on each step move by major_step, and then add minor to the accumulator. When accumulator >= major subtract major and also move by minor_step.

Definition at line 83 of file points.cpp.

{
int abs_x = abs(xcoord);
int abs_y = abs(ycoord);
if (abs_x >= abs_y) {
// X-direction is major.
major_step->xcoord = sign(xcoord);
major_step->ycoord = 0;
minor_step->xcoord = 0;
minor_step->ycoord = sign(ycoord);
*major = abs_x;
*minor = abs_y;
} else {
// Y-direction is major.
major_step->xcoord = 0;
major_step->ycoord = sign(ycoord);
minor_step->xcoord = sign(xcoord);
minor_step->ycoord = 0;
*major = abs_y;
*minor = abs_x;
}
}

float ICOORD::sqlength | ( |  | ) | const

inline

find sq length

Definition at line 73 of file points.h.

{
return (float) (xcoord * xcoord + ycoord * ycoord);
}

inT16 ICOORD::x | ( |  | ) | const

inline

access function

Definition at line 52 of file points.h.

{
return xcoord;
}

inT16 ICOORD::y | ( |  | ) | const

inline

access_function

Definition at line 56 of file points.h.

{
return ycoord;
}

## Friends And Related Function Documentation

friend class FCOORD

friend

Definition at line 32 of file points.h.

ICOORD operator! | ( | const ICOORD & | src | ) |

friend

rotate 90 deg anti

Definition at line 32 of file ipoints.h.

{
ICOORD result; //output
result.xcoord = -src.ycoord;
result.ycoord = src.xcoord;
return result;
}

inT32 operator% | ( | const ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

scalar product

Definition at line 136 of file ipoints.h.

{
return op1.xcoord * op2.xcoord + op1.ycoord * op2.ycoord;
}

inT32 operator* | ( | const ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

cross product

Definition at line 149 of file ipoints.h.

{
return op1.xcoord * op2.ycoord - op1.ycoord * op2.xcoord;
}

ICOORD operator* | ( | const ICOORD & | op1,
|  | inT16 | scale
| ) |  |

friend

multiply

Definition at line 162 of file ipoints.h.

{
ICOORD result; //output
result.xcoord = op1.xcoord * scale;
result.ycoord = op1.ycoord * scale;
return result;
}

ICOORD operator* | ( | inT16 | scale,
|  | const ICOORD & | op1
| ) |  |

friend

multiply

Definition at line 173 of file ipoints.h.

{
ICOORD result; //output
result.xcoord = op1.xcoord * scale;
result.ycoord = op1.ycoord * scale;
return result;
}

ICOORD& operator*= | ( | ICOORD & | op1,
|  | inT16 | scale
| ) |  |

friend

multiply

Definition at line 192 of file ipoints.h.

{
op1.xcoord *= scale;
op1.ycoord *= scale;
return op1;
}

ICOORD operator+ | ( | const ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

add

Definition at line 68 of file ipoints.h.

{
ICOORD sum; //result
sum.xcoord = op1.xcoord + op2.xcoord;
sum.ycoord = op1.ycoord + op2.ycoord;
return sum;
}

ICOORD& operator+= | ( | ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

add

Definition at line 86 of file ipoints.h.

{
op1.xcoord += op2.xcoord;
op1.ycoord += op2.ycoord;
return op1;
}

ICOORD operator- | ( | const ICOORD & | src | ) |

friend

unary minus

Definition at line 50 of file ipoints.h.

{
ICOORD result; //output
result.xcoord = -src.xcoord;
result.ycoord = -src.ycoord;
return result;
}

ICOORD operator- | ( | const ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

subtract

Definition at line 102 of file ipoints.h.

{
ICOORD sum; //result
sum.xcoord = op1.xcoord - op2.xcoord;
sum.ycoord = op1.ycoord - op2.ycoord;
return sum;
}

ICOORD& operator-= | ( | ICOORD & | op1,
|  | const ICOORD & | op2
| ) |  |

friend

subtract

Definition at line 120 of file ipoints.h.

{
op1.xcoord -= op2.xcoord;
op1.ycoord -= op2.ycoord;
return op1;
}

ICOORD operator/ | ( | const ICOORD & | op1,
|  | inT16 | scale
| ) |  |

friend

divide

Definition at line 208 of file ipoints.h.

{
ICOORD result; //output
result.xcoord = op1.xcoord / scale;
result.ycoord = op1.ycoord / scale;
return result;
}

ICOORD& operator/= | ( | ICOORD & | op1,
|  | inT16 | scale
| ) |  |

friend

divide

Definition at line 226 of file ipoints.h.

{
op1.xcoord /= scale;
op1.ycoord /= scale;
return op1;
}

## Member Data Documentation

inT16 ICOORD::xcoord

protected

Definition at line 157 of file points.h.

inT16 ICOORD::ycoord

protected

Definition at line 158 of file points.h.

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

- /mnt/data/src/tesseract-ocr/ccstruct/points.h
- /mnt/data/src/tesseract-ocr/ccstruct/ipoints.h
- /mnt/data/src/tesseract-ocr/ccstruct/points.cpp