00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef QUSPLINE_H
00021 #define QUSPLINE_H
00022
00023 #include "quadratc.h"
00024 #include "serialis.h"
00025 #include "memry.h"
00026 #include "rect.h"
00027
00028 class ROW;
00029
00030 class QSPLINE
00031 {
00032 friend void make_first_baseline(TBOX *,
00033 int,
00034 int *,
00035 int *,
00036 QSPLINE *,
00037 QSPLINE *,
00038 float);
00039 friend void make_holed_baseline(TBOX *, int, QSPLINE *, QSPLINE *, float);
00040 friend void tweak_row_baseline(ROW *);
00041 public:
00042 QSPLINE() {
00043 segments = 0;
00044 xcoords = NULL;
00045 quadratics = NULL;
00046 }
00047 QSPLINE(
00048 const QSPLINE &src);
00049 QSPLINE(
00050 inT32 count,
00051 inT32 *xstarts,
00052 double *coeffs);
00053 ~QSPLINE ();
00054 QSPLINE (
00055 int xstarts[],
00056 int segcount,
00057 int xcoords[],
00058 int ycoords[], int blobcount,
00059 int degree);
00060
00061 double step(
00062 double x1,
00063 double x2);
00064 double y(
00065 double x) const;
00066
00067 void move(
00068 ICOORD vec);
00069 BOOL8 overlap(
00070 QSPLINE *spline2,
00071 double fraction);
00072 void extrapolate(
00073 double gradient,
00074 int left,
00075 int right);
00076
00077 #ifndef GRAPHICS_DISABLED
00078 void plot(
00079 ScrollView* window,
00080 ScrollView::Color colour) const;
00081 #endif
00082
00083 void prep_serialise() {
00084 }
00085
00086 void dump(
00087 FILE *f) {
00088 serialise_bytes (f, (void *) xcoords, (segments + 1) * sizeof (inT32));
00089 serialise_bytes (f, (void *) quadratics, segments * sizeof (QUAD_COEFFS));
00090 }
00091
00092 void de_dump(
00093 FILE *f) {
00094 xcoords = (inT32 *) de_serialise_bytes (f,
00095 (segments + 1) * sizeof (inT32));
00096 quadratics = (QUAD_COEFFS *) de_serialise_bytes (f,
00097 segments *
00098 sizeof (QUAD_COEFFS));
00099 }
00100
00101
00102 make_serialise (QSPLINE) QSPLINE & operator= (
00103 const QSPLINE & source);
00104
00105 private:
00106
00107 inT32 spline_index(
00108 double x) const;
00109 inT32 segments;
00110 inT32 *xcoords;
00111 QUAD_COEFFS *quadratics;
00112 };
00113 #endif