tesseract 4.1.1
Loading...
Searching...
No Matches
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 }

◆ 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 551 of file fpchop.cpp.

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

◆ C_OUTLINE_FRAG() [3/3]

C_OUTLINE_FRAG::C_OUTLINE_FRAG ( C_OUTLINE_FRAG head,
int16_t  tail_y 
)

Definition at line 583 of file fpchop.cpp.

585 {
586 ycoord = tail_y;
587 other_end = head;
588 start = head->start;
589 end = head->end;
590 steps = nullptr;
591 stepcount = 0;
592}

Member Function Documentation

◆ close()

C_OUTLINE * C_OUTLINE_FRAG::close ( )

Definition at line 767 of file fpchop.cpp.

767 { //join pieces
768 DIR128 *new_steps; //new steps
769 int32_t new_stepcount; //no of steps
770 int16_t fake_count; //fake steps
771 DIR128 fake_step; //step entry
772
773 ASSERT_HOST (start.x () == end.x ());
774 fake_count = start.y () - end.y ();
775 if (fake_count < 0) {
776 fake_count = -fake_count;
777 fake_step = 32;
778 }
779 else
780 fake_step = 96;
781
782 new_stepcount = stepcount + fake_count;
783 if (new_stepcount > C_OUTLINE::kMaxOutlineLength)
784 return nullptr; // Can't join them
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
int8_t get_dir() const
Definition: mod128.h:76
int16_t x() const
access function
Definition: points.h:52

◆ operator=()

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

Definition at line 801 of file fpchop.cpp.

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

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: