WERDIT Class Reference

#include <werdit.h>

List of all members.


Detailed Description

Iterator for passing over all the words in a document.

Definition at line 31 of file werdit.h.

Public Member Functions

Private Attributes


Constructor & Destructor Documentation

WERDIT::WERDIT (  )  [inline]

Definition at line 34 of file werdit.h.

00034              { 
00035     }                            //empty contructor

WERDIT::WERDIT ( BLOCK_LIST *  blocklist  )  [inline]

Definition at line 36 of file werdit.h.

References start_page().

00037                                   {  //blocks on page
00038       start_page(blocklist);  //ready to scan
00039     }


Member Function Documentation

BLOCK* WERDIT::block (  )  [inline]

Definition at line 54 of file werdit.h.

References block_it.

00054                    {  //get current block
00055       return block_it.data ();
00056     }

WERD * WERDIT::forward (  ) 

Give the next word on the page, or NULL if none left; use iterators.

Parameters:
none 
Returns:
word
This code assumes all rows to be non-empty, but blocks are allowed to be empty as eventually we will have non-text blocks. The output is always a copy and needs to be deleted by somebody.

Definition at line 71 of file werdit.cpp.

References block_it, NULL, WERD::poly_copy(), row(), row_it, word_it, and ROW::x_height().

00071                       {
00072   WERD *word;         //actual word
00073   //WERD    *larc_word;          //linearc copy
00074   WERD *result;                  //output word
00075   ROW *row;                      //row of word
00076 
00077   if (word_it.cycled_list ()) {
00078     return NULL;                 //finished page
00079   }
00080   else {
00081     word = word_it.data ();
00082     row = row_it.data ();
00083     word_it.forward ();
00084     if (word_it.cycled_list ()) {
00085       row_it.forward ();         //finished row
00086       if (row_it.cycled_list ()) {
00087         do {
00088           block_it.forward ();   //finished block
00089           if (!block_it.cycled_list ()) {
00090             row_it.set_to_list (block_it.data ()->row_list ());
00091             row_it.mark_cycle_pt ();
00092           }
00093         }
00094         //find non-empty block
00095         while (!block_it.cycled_list ()
00096           && row_it.cycled_list ());
00097       }
00098       if (!row_it.cycled_list ()) {
00099         word_it.set_to_list (row_it.data ()->word_list ());
00100         word_it.mark_cycle_pt ();
00101       }
00102     }
00103 
00104     //              if (wordit_linearc && !word->flag(W_POLYGON))
00105     //              {
00106     //                      larc_word=word->larc_copy(row->x_height());
00107     //                      result=larc_word->poly_copy(row->x_height());
00108     //                      delete larc_word;
00109     //              }
00110     //              else
00111     result = word->poly_copy (row->x_height ());
00112     return result;
00113   }
00114 }

ROW* WERDIT::next_row (  )  [inline]

Definition at line 51 of file werdit.h.

References row_it.

00051                     {  //get next row
00052       return row_it.data_relative (1);
00053     }

WERD* WERDIT::next_word (  )  [inline]

Definition at line 45 of file werdit.h.

References word_it.

00045                       {  //get next word
00046       return word_it.data ();    //already at next
00047     }

ROW* WERDIT::row (  )  [inline]

Definition at line 48 of file werdit.h.

References NULL, row_it, and word_it.

Referenced by forward().

00048                {  //get current row
00049       return word_it.cycled_list ()? NULL : row_it.data ();
00050     }

void WERDIT::start_page ( BLOCK_LIST *  block_list  ) 

Get ready to iterate over the page by setting the iterators.

Parameters:
block_list blocks to check
Returns:
none

Definition at line 33 of file werdit.cpp.

References block_it, row_it, and word_it.

Referenced by WERDIT().

00035                          {
00036   block_it.set_to_list (block_list);
00037   block_it.mark_cycle_pt ();
00038   do {
00039     while (block_it.data ()->row_list ()->empty ()
00040     && !block_it.cycled_list ()) {
00041       block_it.forward ();
00042     }
00043     if (!block_it.data ()->row_list ()->empty ()) {
00044       row_it.set_to_list (block_it.data ()->row_list ());
00045       row_it.mark_cycle_pt ();
00046       while (row_it.data ()->word_list ()->empty ()
00047       && !row_it.cycled_list ()) {
00048         row_it.forward ();
00049       }
00050       if (!row_it.data ()->word_list ()->empty ()) {
00051         word_it.set_to_list (row_it.data ()->word_list ());
00052         word_it.mark_cycle_pt ();
00053       }
00054     }
00055   }
00056   while (!block_it.cycled_list () && row_it.data ()->word_list ()->empty ());
00057 }


Member Data Documentation

BLOCK_IT WERDIT::block_it [private]

Definition at line 59 of file werdit.h.

Referenced by block(), forward(), and start_page().

ROW_IT WERDIT::row_it [private]

Definition at line 60 of file werdit.h.

Referenced by forward(), next_row(), row(), and start_page().

WERD_IT WERDIT::word_it [private]

Definition at line 61 of file werdit.h.

Referenced by forward(), next_word(), row(), and start_page().


The documentation for this class was generated from the following files:
Generated on Wed Feb 28 19:49:35 2007 for Tesseract by  doxygen 1.5.1