tesseract  5.0.0
tesseract::C_OUTLINE_FRAG Class Reference

#include <fpchop.h>

Inheritance diagram for tesseract::C_OUTLINE_FRAG:
tesseract::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 tesseract::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 27 of file fpchop.h.

Constructor & Destructor Documentation

◆ C_OUTLINE_FRAG() [1/3]

tesseract::C_OUTLINE_FRAG::C_OUTLINE_FRAG ( )
inline

Definition at line 29 of file fpchop.h.

29  { // empty constructor
30  steps = nullptr;
31  stepcount = 0;
32  }

◆ ~C_OUTLINE_FRAG()

tesseract::C_OUTLINE_FRAG::~C_OUTLINE_FRAG ( )
inline

Definition at line 33 of file fpchop.h.

33  {
34  delete[] steps;
35  }

◆ C_OUTLINE_FRAG() [2/3]

tesseract::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 553 of file fpchop.cpp.

557  {
558  start = start_pt;
559  end = end_pt;
560  ycoord = start_pt.y();
561  stepcount = end_index - start_index;
562  if (stepcount < 0) {
563  stepcount += outline->pathlength();
564  }
565  ASSERT_HOST(stepcount > 0);
566  steps = new DIR128[stepcount];
567  if (end_index > start_index) {
568  for (int i = start_index; i < end_index; ++i) {
569  steps[i - start_index] = outline->step_dir(i);
570  }
571  } else {
572  int len = outline->pathlength();
573  int i = start_index;
574  for (; i < len; ++i) {
575  steps[i - start_index] = outline->step_dir(i);
576  }
577  if (end_index > 0) {
578  for (; i < end_index + len; ++i) {
579  steps[i - start_index] = outline->step_dir(i - len);
580  }
581  }
582  }
583  other_end = nullptr;
584  delete close();
585 }
#define ASSERT_HOST(x)
Definition: errcode.h:59
C_OUTLINE_FRAG * other_end
Definition: fpchop.h:51
C_OUTLINE * close()
Definition: fpchop.cpp:766

◆ C_OUTLINE_FRAG() [3/3]

tesseract::C_OUTLINE_FRAG::C_OUTLINE_FRAG ( C_OUTLINE_FRAG head,
int16_t  tail_y 
)

Definition at line 587 of file fpchop.cpp.

589  {
590  ycoord = tail_y;
591  other_end = head;
592  start = head->start;
593  end = head->end;
594  steps = nullptr;
595  stepcount = 0;
596 }

Member Function Documentation

◆ close()

C_OUTLINE * tesseract::C_OUTLINE_FRAG::close ( )

Definition at line 766 of file fpchop.cpp.

766  { // join pieces
767  DIR128 *new_steps; // new steps
768  int32_t new_stepcount; // no of steps
769  int16_t fake_count; // fake steps
770  DIR128 fake_step; // step entry
771 
772  ASSERT_HOST(start.x() == end.x());
773  fake_count = start.y() - end.y();
774  if (fake_count < 0) {
775  fake_count = -fake_count;
776  fake_step = 32;
777  } else {
778  fake_step = 96;
779  }
780 
781  new_stepcount = stepcount + fake_count;
782  if (new_stepcount > C_OUTLINE::kMaxOutlineLength) {
783  return nullptr; // Can't join them
784  }
785  new_steps = new DIR128[new_stepcount];
786  memmove(new_steps, steps, stepcount);
787  memset(new_steps + stepcount, fake_step.get_dir(), fake_count);
788  auto *result = new C_OUTLINE(start, new_steps, new_stepcount);
789  delete[] new_steps;
790  return result;
791 }
static const int kMaxOutlineLength
Definition: coutln.h:273
TDimension y() const
access_function
Definition: points.h:62
TDimension x() const
access function
Definition: points.h:58

◆ operator=()

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

Definition at line 800 of file fpchop.cpp.

801  {
802  delete[] steps;
803 
804  stepcount = src.stepcount;
805  steps = new DIR128[stepcount];
806  memmove(steps, src.steps, stepcount);
807  start = src.start;
808  end = src.end;
809  ycoord = src.ycoord;
810  return *this;
811 }

Member Data Documentation

◆ end

ICOORD tesseract::C_OUTLINE_FRAG::end

Definition at line 48 of file fpchop.h.

◆ other_end

C_OUTLINE_FRAG* tesseract::C_OUTLINE_FRAG::other_end

Definition at line 51 of file fpchop.h.

◆ start

ICOORD tesseract::C_OUTLINE_FRAG::start

Definition at line 47 of file fpchop.h.

◆ stepcount

int32_t tesseract::C_OUTLINE_FRAG::stepcount

Definition at line 50 of file fpchop.h.

◆ steps

DIR128* tesseract::C_OUTLINE_FRAG::steps

Definition at line 49 of file fpchop.h.

◆ ycoord

int16_t tesseract::C_OUTLINE_FRAG::ycoord

Definition at line 52 of file fpchop.h.


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