897 {
901 int32_t blob_count;
902 int32_t src_index;
903 int32_t dest_index;
904 float ydiff;
905 float x_centre;
906
908 C_BLOB_IT blob_it;
909
910 blob_count = 0;
911 for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
912 word = word_it.data ();
913
915 }
916 if (blob_count == 0)
917 return;
918
919 std::vector<int32_t> xstarts(blob_count + row->baseline.segments + 1);
920
921 std::vector<double> coeffs((blob_count + row->baseline.segments) * 3);
922
923 src_index = 0;
924 dest_index = 0;
925 xstarts[0] = row->baseline.xcoords[0];
926 for (word_it.mark_cycle_pt (); !word_it.cycled_list (); word_it.forward ()) {
927 word = word_it.data ();
928
930 for (blob_it.mark_cycle_pt (); !blob_it.cycled_list ();
931 blob_it.forward ()) {
932 blob = blob_it.data ();
934 x_centre = (blob_box.
left () + blob_box.
right ()) / 2.0;
936 if (ydiff < 0)
938 else
940 if (ydiff < blshift_maxshift
942 if (xstarts[dest_index] >= x_centre)
943 xstarts[dest_index] = blob_box.
left ();
944 coeffs[dest_index * 3] = 0;
945 coeffs[dest_index * 3 + 1] = 0;
946 coeffs[dest_index * 3 + 2] = blob_box.
bottom ();
947
948 dest_index++;
949 xstarts[dest_index] = blob_box.
right () + 1;
950 }
951 else {
952 if (xstarts[dest_index] <= x_centre) {
953 while (row->baseline.xcoords[src_index + 1] <= x_centre
954 && src_index < row->baseline.segments - 1) {
955 if (row->baseline.xcoords[src_index + 1] >
956 xstarts[dest_index]) {
957 coeffs[dest_index * 3] =
958 row->baseline.quadratics[src_index].
a;
959 coeffs[dest_index * 3 + 1] =
960 row->baseline.quadratics[src_index].
b;
961 coeffs[dest_index * 3 + 2] =
962 row->baseline.quadratics[src_index].
c;
963 dest_index++;
964 xstarts[dest_index] =
965 row->baseline.xcoords[src_index + 1];
966 }
967 src_index++;
968 }
969 coeffs[dest_index * 3] =
970 row->baseline.quadratics[src_index].
a;
971 coeffs[dest_index * 3 + 1] =
972 row->baseline.quadratics[src_index].
b;
973 coeffs[dest_index * 3 + 2] =
974 row->baseline.quadratics[src_index].
c;
975 dest_index++;
976 xstarts[dest_index] = row->baseline.xcoords[src_index + 1];
977 }
978 }
979 }
980 }
981 while (src_index < row->baseline.segments
982 && row->baseline.xcoords[src_index + 1] <= xstarts[dest_index])
983 src_index++;
984 while (src_index < row->baseline.segments) {
985 coeffs[dest_index * 3] = row->baseline.quadratics[src_index].
a;
986 coeffs[dest_index * 3 + 1] = row->baseline.quadratics[src_index].
b;
987 coeffs[dest_index * 3 + 2] = row->baseline.quadratics[src_index].
c;
988 dest_index++;
989 src_index++;
990 xstarts[dest_index] = row->baseline.xcoords[src_index];
991 }
992
993 row->baseline =
QSPLINE(dest_index, &xstarts[0], &coeffs[0]);
994}
float base_line(float xpos) const
TBOX bounding_box() const
C_BLOB_LIST * cblob_list()