tesseract  4.0.0-1-g2a2b
C_OUTLINE_FRAG Class Reference

#include <fpchop.h>

Inheritance diagram for C_OUTLINE_FRAG:
ELIST_LINK

Public Member Functions

 C_OUTLINE_FRAG ()
 
 ~C_OUTLINE_FRAG ()
 
 C_OUTLINE_FRAG (ICOORD start_pt, ICOORD end_pt, C_OUTLINE *outline, int16_t start_index, int16_t end_index)
 
 C_OUTLINE_FRAG (C_OUTLINE_FRAG *head, int16_t tail_y)
 
C_OUTLINEclose ()
 
C_OUTLINE_FRAGoperator= (const C_OUTLINE_FRAG &src)
 
- Public Member Functions inherited from ELIST_LINK
 ELIST_LINK ()
 
 ELIST_LINK (const ELIST_LINK &)
 
void operator= (const ELIST_LINK &)
 

Public Attributes

ICOORD start
 
ICOORD end
 
DIR128steps
 
int32_t stepcount
 
C_OUTLINE_FRAGother_end
 
int16_t ycoord
 

Detailed Description

Definition at line 25 of file fpchop.h.

Constructor & Destructor Documentation

◆ C_OUTLINE_FRAG() [1/3]

C_OUTLINE_FRAG::C_OUTLINE_FRAG ( )
inline

Definition at line 28 of file fpchop.h.

28  { //empty constructor
29  steps = nullptr;
30  stepcount = 0;
31  }
int32_t stepcount
Definition: fpchop.h:50
DIR128 * steps
Definition: fpchop.h:49

◆ ~C_OUTLINE_FRAG()

C_OUTLINE_FRAG::~C_OUTLINE_FRAG ( )
inline

Definition at line 32 of file fpchop.h.

32  {
33  delete [] steps;
34  }
DIR128 * steps
Definition: fpchop.h:49

◆ C_OUTLINE_FRAG() [2/3]

C_OUTLINE_FRAG::C_OUTLINE_FRAG ( ICOORD  start_pt,
ICOORD  end_pt,
C_OUTLINE outline,
int16_t  start_index,
int16_t  end_index 
)

Definition at line 554 of file fpchop.cpp.

559  {
560  start = start_pt;
561  end = end_pt;
562  ycoord = start_pt.y ();
563  stepcount = end_index - start_index;
564  if (stepcount < 0)
565  stepcount += outline->pathlength ();
566  ASSERT_HOST (stepcount > 0);
567  steps = new DIR128[stepcount];
568  if (end_index > start_index) {
569  for (int i = start_index; i < end_index; ++i)
570  steps[i - start_index] = outline->step_dir(i);
571  }
572  else {
573  int len = outline->pathlength();
574  int i = start_index;
575  for (; i < len; ++i)
576  steps[i - start_index] = outline->step_dir(i);
577  if (end_index > 0)
578  for (; i < end_index + len; ++i)
579  steps[i - start_index] = outline->step_dir(i - len);
580  }
581  other_end = nullptr;
582  delete close();
583 }
C_OUTLINE_FRAG * other_end
Definition: fpchop.h:51
int16_t ycoord
Definition: fpchop.h:52
ICOORD end
Definition: fpchop.h:48
ICOORD start
Definition: fpchop.h:47
int16_t y() const
access_function
Definition: points.h:57
Definition: mod128.h:29
int32_t pathlength() const
Definition: coutln.h:135
int32_t stepcount
Definition: fpchop.h:50
C_OUTLINE * close()
Definition: fpchop.cpp:770
DIR128 step_dir(int index) const
Definition: coutln.h:139
DIR128 * steps
Definition: fpchop.h:49
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ C_OUTLINE_FRAG() [3/3]

C_OUTLINE_FRAG::C_OUTLINE_FRAG ( C_OUTLINE_FRAG head,
int16_t  tail_y 
)

Definition at line 586 of file fpchop.cpp.

588  {
589  ycoord = tail_y;
590  other_end = head;
591  start = head->start;
592  end = head->end;
593  steps = nullptr;
594  stepcount = 0;
595 }
C_OUTLINE_FRAG * other_end
Definition: fpchop.h:51
int16_t ycoord
Definition: fpchop.h:52
ICOORD end
Definition: fpchop.h:48
ICOORD start
Definition: fpchop.h:47
int32_t stepcount
Definition: fpchop.h:50
DIR128 * steps
Definition: fpchop.h:49

Member Function Documentation

◆ close()

C_OUTLINE * C_OUTLINE_FRAG::close ( )

Definition at line 770 of file fpchop.cpp.

770  { //join pieces
771  DIR128 *new_steps; //new steps
772  int32_t new_stepcount; //no of steps
773  int16_t fake_count; //fake steps
774  DIR128 fake_step; //step entry
775 
776  ASSERT_HOST (start.x () == end.x ());
777  fake_count = start.y () - end.y ();
778  if (fake_count < 0) {
779  fake_count = -fake_count;
780  fake_step = 32;
781  }
782  else
783  fake_step = 96;
784 
785  new_stepcount = stepcount + fake_count;
786  if (new_stepcount > C_OUTLINE::kMaxOutlineLength)
787  return nullptr; // Can't join them
788  new_steps = new DIR128[new_stepcount];
789  memmove(new_steps, steps, stepcount);
790  memset (new_steps + stepcount, fake_step.get_dir(), fake_count);
791  C_OUTLINE* result = new C_OUTLINE (start, new_steps, new_stepcount);
792  delete [] new_steps;
793  return result;
794 }
ICOORD end
Definition: fpchop.h:48
ICOORD start
Definition: fpchop.h:47
int16_t y() const
access_function
Definition: points.h:57
int8_t get_dir() const
Definition: mod128.h:76
int16_t x() const
access function
Definition: points.h:53
Definition: mod128.h:29
int32_t stepcount
Definition: fpchop.h:50
static const int kMaxOutlineLength
Definition: coutln.h:273
DIR128 * steps
Definition: fpchop.h:49
class DLLSYM C_OUTLINE
Definition: coutln.h:68
#define ASSERT_HOST(x)
Definition: errcode.h:84

◆ operator=()

C_OUTLINE_FRAG & C_OUTLINE_FRAG::operator= ( const C_OUTLINE_FRAG src)

Definition at line 804 of file fpchop.cpp.

806  {
807  delete [] steps;
808 
809  stepcount = src.stepcount;
810  steps = new DIR128[stepcount];
811  memmove (steps, src.steps, stepcount);
812  start = src.start;
813  end = src.end;
814  ycoord = src.ycoord;
815  return *this;
816 }
int16_t ycoord
Definition: fpchop.h:52
ICOORD end
Definition: fpchop.h:48
ICOORD start
Definition: fpchop.h:47
Definition: mod128.h:29
int32_t stepcount
Definition: fpchop.h:50
DIR128 * steps
Definition: fpchop.h:49

Member Data Documentation

◆ end

ICOORD C_OUTLINE_FRAG::end

Definition at line 48 of file fpchop.h.

◆ other_end

C_OUTLINE_FRAG* C_OUTLINE_FRAG::other_end

Definition at line 51 of file fpchop.h.

◆ start

ICOORD C_OUTLINE_FRAG::start

Definition at line 47 of file fpchop.h.

◆ stepcount

int32_t C_OUTLINE_FRAG::stepcount

Definition at line 50 of file fpchop.h.

◆ steps

DIR128* C_OUTLINE_FRAG::steps

Definition at line 49 of file fpchop.h.

◆ ycoord

int16_t C_OUTLINE_FRAG::ycoord

Definition at line 52 of file fpchop.h.


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