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