comparison mupdf-source/thirdparty/tesseract/src/ccstruct/quspline.h @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
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 "scrollview.h" // for ScrollView, ScrollView::Color
24
25 #include <cstdint> // for int32_t
26
27 struct Pix;
28
29 namespace tesseract {
30
31 class ICOORD;
32 class QUAD_COEFFS;
33 class ROW;
34 class TBOX;
35
36 class TESS_API QSPLINE {
37 friend void make_first_baseline(TBOX *, int, int *, int *, QSPLINE *, QSPLINE *, float);
38 friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
39 friend void tweak_row_baseline(ROW *, double, double);
40
41 public:
42 QSPLINE() { // empty constructor
43 segments = 0;
44 xcoords = nullptr; // everything empty
45 quadratics = nullptr;
46 }
47 QSPLINE( // copy constructor
48 const QSPLINE &src);
49 QSPLINE( // constructor
50 int32_t count, // number of segments
51 int32_t *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 bool 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 // Paint the baseline over pix. If pix has depth of 32, then the line will
84 // be painted in red. Otherwise it will be painted in black.
85 void plot(Image pix) const;
86
87 QSPLINE &operator=(const QSPLINE &source); // from this
88
89 private:
90 int32_t spline_index( // binary search
91 double x) const; // for x
92 int32_t segments; // no of segments
93 int32_t *xcoords; // no of coords
94 QUAD_COEFFS *quadratics; // spline pieces
95 };
96
97 } // namespace tesseract
98
99 #endif