tesseract 3.04.01

TESSLINE Struct Reference

#include <blobs.h>

List of all members.

Public Member Functions

 TESSLINE ()
 TESSLINE (const TESSLINE &src)
 ~TESSLINE ()
TESSLINEoperator= (const TESSLINE &src)
void CopyFrom (const TESSLINE &src)
void Clear ()
void Normalize (const DENORM &denorm)
void Rotate (const FCOORD rotation)
void Move (const ICOORD vec)
void Scale (float factor)
void SetupFromPos ()
void ComputeBoundingBox ()
void MinMaxCrossProduct (const TPOINT vec, int *min_xp, int *max_xp) const
TBOX bounding_box () const
bool SameBox (const TESSLINE &other) const
bool SegmentCrosses (const TPOINT &pt1, const TPOINT &pt2) const
bool Contains (const TPOINT &pt) const
void plot (ScrollView *window, ScrollView::Color color, ScrollView::Color child_color)
EDGEPTFindBestStartPt () const
int BBArea () const

Static Public Member Functions

static TESSLINEBuildFromOutlineList (EDGEPT *outline)

Public Attributes

TPOINT topleft
TPOINT botright
TPOINT start
bool is_hole
EDGEPTloop
TESSLINEnext

Detailed Description

Definition at line 180 of file blobs.h.


Constructor & Destructor Documentation

TESSLINE::TESSLINE ( ) [inline]

Definition at line 181 of file blobs.h.

: is_hole(false), loop(NULL), next(NULL) {}
TESSLINE::TESSLINE ( const TESSLINE src) [inline]

Definition at line 182 of file blobs.h.

                                : loop(NULL), next(NULL) {
    CopyFrom(src);
  }
TESSLINE::~TESSLINE ( ) [inline]

Definition at line 185 of file blobs.h.

              {
    Clear();
  }

Member Function Documentation

int TESSLINE::BBArea ( ) const [inline]

Definition at line 249 of file blobs.h.

                     {
    return (botright.x - topleft.x) * (topleft.y - botright.y);
  }
TBOX TESSLINE::bounding_box ( ) const

Definition at line 273 of file blobs.cpp.

                                  {
  return TBOX(topleft.x, botright.y, botright.x, topleft.y);
}
TESSLINE * TESSLINE::BuildFromOutlineList ( EDGEPT outline) [static]

Definition at line 104 of file blobs.cpp.

                                                        {
  TESSLINE* result = new TESSLINE;
  result->loop = outline;
  if (outline->src_outline != NULL) {
    // ASSUMPTION: This function is only ever called from ApproximateOutline
    // and therefore either all points have a src_outline or all do not.
                // Just as SetupFromPos sets the vectors from the vertices, setup the
                // step_count members to indicate the (positive) number of original
                // C_OUTLINE steps to the next vertex.
                EDGEPT* pt = outline;
                do {
                  pt->step_count = pt->next->start_step - pt->start_step;
                  if (pt->step_count < 0)
                    pt->step_count += pt->src_outline->pathlength();
                  pt = pt->next;
                } while (pt != outline);
  }
  result->SetupFromPos();
  return result;
}
void TESSLINE::Clear ( )

Definition at line 153 of file blobs.cpp.

                     {
  if (loop == NULL)
    return;

  EDGEPT* this_edge = loop;
  do {
    EDGEPT* next_edge = this_edge->next;
    delete this_edge;
    this_edge = next_edge;
  } while (this_edge != loop);
  loop = NULL;
}
void TESSLINE::ComputeBoundingBox ( )

Definition at line 225 of file blobs.cpp.

                                  {
  int minx = MAX_INT32;
  int miny = MAX_INT32;
  int maxx = -MAX_INT32;
  int maxy = -MAX_INT32;

  // Find boundaries.
  start = loop->pos;
  EDGEPT* this_edge = loop;
  do {
    if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
      if (this_edge->pos.x < minx)
        minx = this_edge->pos.x;
      if (this_edge->pos.y < miny)
        miny = this_edge->pos.y;
      if (this_edge->pos.x > maxx)
        maxx = this_edge->pos.x;
      if (this_edge->pos.y > maxy)
        maxy = this_edge->pos.y;
    }
    this_edge = this_edge->next;
  } while (this_edge != loop);
  // Reset bounds.
  topleft.x = minx;
  topleft.y = maxy;
  botright.x = maxx;
  botright.y = miny;
}
bool TESSLINE::Contains ( const TPOINT pt) const [inline]

Definition at line 234 of file blobs.h.

                                        {
    return topleft.x <= pt.x && pt.x <= botright.x &&
           botright.y <= pt.y && pt.y <= topleft.y;
  }
void TESSLINE::CopyFrom ( const TESSLINE src)

Definition at line 126 of file blobs.cpp.

                                           {
  Clear();
  topleft = src.topleft;
  botright = src.botright;
  start = src.start;
  is_hole = src.is_hole;
  if (src.loop != NULL) {
    EDGEPT* prevpt = NULL;
    EDGEPT* newpt = NULL;
    EDGEPT* srcpt = src.loop;
    do {
      newpt = new EDGEPT(*srcpt);
      if (prevpt == NULL) {
        loop = newpt;
      } else {
        newpt->prev = prevpt;
        prevpt->next = newpt;
      }
      prevpt = newpt;
      srcpt = srcpt->next;
    } while (srcpt != src.loop);
    loop->prev = newpt;
    newpt->next = loop;
  }
}
EDGEPT * TESSLINE::FindBestStartPt ( ) const

Definition at line 299 of file blobs.cpp.

                                        {
  EDGEPT* best_start = loop;
  int best_step = loop->start_step;
  // Iterate the polygon.
  EDGEPT* pt = loop;
  do {
    if (pt->IsHidden()) continue;
    if (pt->prev->IsHidden() || pt->prev->src_outline != pt->src_outline)
      return pt;  // Qualifies as the best.
    if (pt->start_step < best_step) {
      best_step = pt->start_step;
      best_start = pt;
    }
  } while ((pt = pt->next) != loop);
  return best_start;
}
void TESSLINE::MinMaxCrossProduct ( const TPOINT  vec,
int *  min_xp,
int *  max_xp 
) const

Definition at line 259 of file blobs.cpp.

                                                                  {
  *min_xp = MAX_INT32;
  *max_xp = MIN_INT32;
  EDGEPT* this_edge = loop;
  do {
    if (!this_edge->IsHidden() || !this_edge->prev->IsHidden()) {
      int product = CROSS(this_edge->pos, vec);
      UpdateRange(product, min_xp, max_xp);
    }
    this_edge = this_edge->next;
  } while (this_edge != loop);
}
void TESSLINE::Move ( const ICOORD  vec)

Definition at line 191 of file blobs.cpp.

                                    {
  EDGEPT* pt = loop;
  do {
    pt->pos.x += vec.x();
    pt->pos.y += vec.y();
    pt = pt->next;
  } while (pt != loop);
  SetupFromPos();
}
void TESSLINE::Normalize ( const DENORM denorm)

Definition at line 167 of file blobs.cpp.

                                             {
  EDGEPT* pt = loop;
  do {
    denorm.LocalNormTransform(pt->pos, &pt->pos);
    pt = pt->next;
  } while (pt != loop);
  SetupFromPos();
}
TESSLINE& TESSLINE::operator= ( const TESSLINE src) [inline]

Definition at line 188 of file blobs.h.

                                           {
    CopyFrom(src);
    return *this;
  }
void TESSLINE::plot ( ScrollView window,
ScrollView::Color  color,
ScrollView::Color  child_color 
)

Definition at line 278 of file blobs.cpp.

                                                 {
  if (is_hole)
    window->Pen(child_color);
  else
    window->Pen(color);
  window->SetCursor(start.x, start.y);
  EDGEPT* pt = loop;
  do {
    bool prev_hidden = pt->IsHidden();
    pt = pt->next;
    if (prev_hidden)
      window->SetCursor(pt->pos.x, pt->pos.y);
    else
      window->DrawTo(pt->pos.x, pt->pos.y);
  } while (pt != loop);
}
void TESSLINE::Rotate ( const FCOORD  rotation)

Definition at line 177 of file blobs.cpp.

                                      {
  EDGEPT* pt = loop;
  do {
    int tmp = static_cast<int>(floor(pt->pos.x * rot.x() -
                                     pt->pos.y * rot.y() + 0.5));
    pt->pos.y = static_cast<int>(floor(pt->pos.y * rot.x() +
                                       pt->pos.x * rot.y() + 0.5));
    pt->pos.x = tmp;
    pt = pt->next;
  } while (pt != loop);
  SetupFromPos();
}
bool TESSLINE::SameBox ( const TESSLINE other) const [inline]

Definition at line 219 of file blobs.h.

                                            {
    return topleft == other.topleft && botright == other.botright;
  }
void TESSLINE::Scale ( float  factor)

Definition at line 202 of file blobs.cpp.

                                 {
  EDGEPT* pt = loop;
  do {
    pt->pos.x = static_cast<int>(floor(pt->pos.x * factor + 0.5));
    pt->pos.y = static_cast<int>(floor(pt->pos.y * factor + 0.5));
    pt = pt->next;
  } while (pt != loop);
  SetupFromPos();
}
bool TESSLINE::SegmentCrosses ( const TPOINT pt1,
const TPOINT pt2 
) const [inline]

Definition at line 223 of file blobs.h.

                                                                  {
    if (Contains(pt1) && Contains(pt2)) {
      EDGEPT* pt = loop;
      do {
        if (TPOINT::IsCrossed(pt1, pt2, pt->pos, pt->next->pos)) return true;
        pt = pt->next;
      } while (pt != loop);
    }
    return false;
  }
void TESSLINE::SetupFromPos ( )

Definition at line 213 of file blobs.cpp.

                            {
  EDGEPT* pt = loop;
  do {
    pt->vec.x = pt->next->pos.x - pt->pos.x;
    pt->vec.y = pt->next->pos.y - pt->pos.y;
    pt = pt->next;
  } while (pt != loop);
  start = pt->pos;
  ComputeBoundingBox();
}

Member Data Documentation

Definition at line 254 of file blobs.h.

Definition at line 256 of file blobs.h.

Definition at line 257 of file blobs.h.

Definition at line 258 of file blobs.h.

Definition at line 255 of file blobs.h.

Definition at line 253 of file blobs.h.


The documentation for this struct was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines