File: track.h

package info (click to toggle)
ocrad 0.17-4
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 624 kB
  • ctags: 687
  • sloc: cpp: 7,809; sh: 161; makefile: 149
file content (73 lines) | stat: -rw-r--r-- 2,941 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*  GNU Ocrad - Optical Character Recognition program
    Copyright (C) 2003, 2004, 2005, 2006, 2007 Antonio Diaz Diaz.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

class Vrhomboid			// Rhomboid with two vertical sides.
  {
  int _left, _lvcenter, _right, _rvcenter, _height;

public:
  Vrhomboid( const int l, const int lc, const int r, const int rc, const int h ) throw();

  int left()     const throw() { return _left;     }
  int lvcenter() const throw() { return _lvcenter; }
  int right()    const throw() { return _right;    }
  int rvcenter() const throw() { return _rvcenter; }
  int height()   const throw() { return _height;   }
  int width()    const throw() { return _right - _left + 1; }
  int size()     const throw() { return _height * width(); }

  void left( const int l ) throw();
  void lvcenter( const int lc ) throw() { _lvcenter = lc; }
  void right( const int r ) throw();
  void rvcenter( const int rc ) throw() { _rvcenter = rc; }
  void height( const int h ) throw();
  void extend_left( const int l ) throw();
  void extend_right( const int r ) throw();

  int bottom( const int col ) const throw() { return vcenter( col ) + ( _height / 2 ); }
  int top( const int col ) const throw() { return bottom( col ) - _height + 1; }
  int vcenter( const int col ) const throw();

  bool includes( const Rectangle & r ) const throw();
  bool includes( const int row, const int col ) const throw();
  };


class Track		// vector of Vrhomboids tracking a Textline.
  {
  std::vector< Vrhomboid > data;

public:
  Track() throw() {}
  Track( const Track & t ) throw() : data( t.data ) {}
  Track & operator=( const Track & t ) throw()
    { if( this != &t ) { data = t.data; } return *this; }

  void set_track( const std::vector< Rectangle > & rectangle_vector ) throw();

  int segments() const throw() { return data.size(); }
  int height() const throw() { return data.size() ? data[0].height() : 0; }
  int left() const throw() { return data.size() ? data[0].left() : 0; }
  int right() const throw() { return data.size() ? data.back().right() : 0; }

  int bottom( const int col ) const throw();
  int top( const int col ) const throw();
  int vcenter( const int col ) const throw();

  bool includes( const Rectangle & r ) const throw();
  bool includes( const int row, const int col ) const throw();
  };