Tesseract  3.02
TWERD Struct Reference

#include <blobs.h>

List of all members.

Public Member Functions

 TWERD ()
 TWERD (const TWERD &src)
 ~TWERD ()
TWERDoperator= (const TWERD &src)
void SetupBLNormalize (const BLOCK *block, const ROW *row, float x_height, bool numeric_mode, DENORM *denorm) const
void Normalize (const DENORM &denorm)
void CopyFrom (const TWERD &src)
void Clear ()
void ComputeBoundingBoxes ()
int NumBlobs () const
TBOX bounding_box () const
void MergeBlobs (int start, int end)
void plot (ScrollView *window)

Static Public Member Functions

static TWERDPolygonalCopy (WERD *src)

Public Attributes

TBLOBblobs
bool latin_script
TWERDnext

Detailed Description

Definition at line 229 of file blobs.h.


Constructor & Destructor Documentation

TWERD::TWERD ( ) [inline]

Definition at line 230 of file blobs.h.

: blobs(NULL), latin_script(false), next(NULL) {}
TWERD::TWERD ( const TWERD src) [inline]

Definition at line 231 of file blobs.h.

                          : blobs(NULL), next(NULL) {
    CopyFrom(src);
  }
TWERD::~TWERD ( ) [inline]

Definition at line 234 of file blobs.h.

           {
    Clear();
  }

Member Function Documentation

TBOX TWERD::bounding_box ( ) const

Definition at line 476 of file blobs.cpp.

                               {
  TBOX result;
  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
    TBOX box = blob->bounding_box();
    result += box;
  }
  return result;
}
void TWERD::Clear ( )

Definition at line 462 of file blobs.cpp.

                  {
  for (TBLOB* next_blob = NULL; blobs != NULL; blobs = next_blob) {
    next_blob = blobs->next;
    delete blobs;
  }
}
void TWERD::ComputeBoundingBoxes ( )

Definition at line 470 of file blobs.cpp.

                                 {
  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
    blob->ComputeBoundingBoxes();
  }
}
void TWERD::CopyFrom ( const TWERD src)

Definition at line 447 of file blobs.cpp.

                                     {
  Clear();
  latin_script = src.latin_script;
  TBLOB* prev_blob = NULL;
  for (TBLOB* srcblob = src.blobs; srcblob != NULL; srcblob = srcblob->next) {
    TBLOB* new_blob = new TBLOB(*srcblob);
    if (blobs == NULL)
      blobs = new_blob;
    else
      prev_blob->next = new_blob;
    prev_blob = new_blob;
  }
}
void TWERD::MergeBlobs ( int  start,
int  end 
)

Definition at line 487 of file blobs.cpp.

                                         {
  TBLOB* blob = blobs;
  for (int i = 0; i < start && blob != NULL; ++i)
    blob = blob->next;
  if (blob == NULL || blob->next == NULL)
    return;
  TBLOB* next_blob = blob->next;
  TESSLINE* outline = blob->outlines;
  for (int i = start + 1; i < end && next_blob != NULL; ++i) {
    // Take the outlines from the next blob.
    if (outline == NULL) {
      blob->outlines = next_blob->outlines;
      outline = blob->outlines;
    } else {
      while (outline->next != NULL)
        outline = outline->next;
      outline->next = next_blob->outlines;
      next_blob->outlines = NULL;
    }
    // Delete the next blob and move on.
    TBLOB* dead_blob = next_blob;
    next_blob = next_blob->next;
    blob->next = next_blob;
    delete dead_blob;
  }
}
void TWERD::Normalize ( const DENORM denorm)

Definition at line 440 of file blobs.cpp.

                                          {
  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
    blob->Normalize(denorm);
  }
}
int TWERD::NumBlobs ( ) const [inline]

Definition at line 259 of file blobs.h.

                       {
    return count_blobs(blobs);
  }
TWERD& TWERD::operator= ( const TWERD src) [inline]

Definition at line 237 of file blobs.h.

                                     {
    CopyFrom(src);
    return *this;
  }
void TWERD::plot ( ScrollView window)

Definition at line 514 of file blobs.cpp.

                                   {
  ScrollView::Color color = WERD::NextColor(ScrollView::BLACK);
  for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
    blob->plot(window, color, ScrollView::BROWN);
    color = WERD::NextColor(color);
  }
}
TWERD * TWERD::PolygonalCopy ( WERD src) [static]

Definition at line 398 of file blobs.cpp.

                                     {
  TWERD* tessword = new TWERD;
  tessword->latin_script = src->flag(W_SCRIPT_IS_LATIN);
  C_BLOB_IT b_it(src->cblob_list());
  TBLOB *tail = NULL;
  for (b_it.mark_cycle_pt(); !b_it.cycled_list(); b_it.forward()) {
    C_BLOB* blob = b_it.data();
    TBLOB* tblob = TBLOB::PolygonalCopy(blob);
    if (tail == NULL) {
      tessword->blobs = tblob;
    } else {
      tail->next = tblob;
    }
    tail = tblob;
  }
  return tessword;
}
void TWERD::SetupBLNormalize ( const BLOCK block,
const ROW row,
float  x_height,
bool  numeric_mode,
DENORM denorm 
) const

Definition at line 417 of file blobs.cpp.

                                                   {
  int num_segments = 0;
  DENORM_SEG* segs = NULL;
  if (numeric_mode) {
    segs = new DENORM_SEG[NumBlobs()];
    for (TBLOB* blob = blobs; blob != NULL; blob = blob->next) {
      TBOX blob_box = blob->bounding_box();
      float factor = kBlnXHeight / x_height;
      factor = ClipToRange(kBlnXHeight * 4.0f / (3 * blob_box.height()),
                           factor, factor * 1.5f);
      segs[num_segments].xstart = blob_box.left();
      segs[num_segments].ycoord = blob_box.bottom();
      segs[num_segments++].scale_factor = factor;
    }
  }
  denorm->SetupBLNormalize(block, row, x_height, bounding_box(),
                           num_segments, segs);
  delete [] segs;
}

Member Data Documentation

Definition at line 270 of file blobs.h.

Definition at line 271 of file blobs.h.

Definition at line 272 of file blobs.h.


The documentation for this struct was generated from the following files: