Tesseract 3.02

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
quspline.h
Go to the documentation of this file.
1 /**********************************************************************
2 * File: quspline.h (Formerly qspline.h)
3 * Description: Code for the QSPLINE class.
4 * Author: Ray Smith
5 * Created: Tue Oct 08 17:16:12 BST 1991
6 *
7 * (C) Copyright 1991, Hewlett-Packard Ltd.
8 ** Licensed under the Apache License, Version 2.0 (the "License");
9 ** you may not use this file except in compliance with the License.
10 ** You may obtain a copy of the License at
11 ** http://www.apache.org/licenses/LICENSE-2.0
12 ** Unless required by applicable law or agreed to in writing, software
13 ** distributed under the License is distributed on an "AS IS" BASIS,
14 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 ** See the License for the specific language governing permissions and
16 ** limitations under the License.
17 *
18 **********************************************************************/
19
20 #ifndef QUSPLINE_H
21 #define QUSPLINE_H
22
23 #include "quadratc.h"
24 #include "serialis.h"
25 #include "memry.h"
26 #include "rect.h"
27
28 class ROW;
29
30 class QSPLINE
31 {
32 friend void make_first_baseline(TBOX *,
33 int,
34 int *,
35 int *,
36 QSPLINE *,
37 QSPLINE *,
38 float);
39 friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
40 friend void tweak_row_baseline(ROW *, double, double);
41 public:
42 QSPLINE() { //empty constructor
43 segments = 0;
44 xcoords = NULL; //everything empty
45 quadratics = NULL;
46 }
47 QSPLINE( //copy constructor
48 const QSPLINE &src);
49 QSPLINE( //constructor
50 inT32 count, //number of segments
51 inT32 *xstarts, //segment starts
52 double *coeffs); //coefficients
53 ~QSPLINE (); //destructor
54 QSPLINE ( //least squares fit
55 int xstarts[], //spline boundaries
56 int segcount, //no of segments
57 int xcoords[], //points to fit
58 int ycoords[], int blobcount,//no of coords
59 int degree); //function
60
61 double step( //step change
62 double x1, //between coords
63 double x2);
64 double y( //evaluate
65 double x) const; //at x
66
67 void move( // reposition spline
68 ICOORD vec); // by vector
69 BOOL8 overlap( //test overlap
70 QSPLINE *spline2, //2 cannot be smaller
71 double fraction); //by more than this
72 void extrapolate( //linear extrapolation
73 double gradient, //gradient to use
74 int left, //new left edge
75 int right); //new right edge
76
77 #ifndef GRAPHICS_DISABLED
78 void plot( //draw it
79 ScrollView* window, //in window
80 ScrollView::Color colour) const; //in colour
81 #endif
82
83 QSPLINE & operator= (
84 const QSPLINE & source); //from this
85
86 private:
87
88 inT32 spline_index( //binary search
89 double x) const; //for x
90 inT32 segments; //no of segments
91 inT32 *xcoords; //no of coords
92 QUAD_COEFFS *quadratics; //spline pieces
93 };
94 #endif