tesseract  4.0.0-1-g2a2b
rect.cpp File Reference
#include "rect.h"
#include "strngs.h"

Go to the source code of this file.

Functions

DLLSYM TBOXoperator+= (TBOX &op1, const TBOX &op2)
 
TBOXoperator &= (TBOX &op1, const TBOX &op2)
 

Function Documentation

◆ operator &=()

TBOX& operator&= ( TBOX op1,
const TBOX op2 
)

Definition at line 230 of file rect.cpp.

230  {
231  if (op1.overlap (op2)) {
232  if (op2.bot_left.x () > op1.bot_left.x ())
233  op1.bot_left.set_x (op2.bot_left.x ());
234 
235  if (op2.top_right.x () < op1.top_right.x ())
236  op1.top_right.set_x (op2.top_right.x ());
237 
238  if (op2.bot_left.y () > op1.bot_left.y ())
239  op1.bot_left.set_y (op2.bot_left.y ());
240 
241  if (op2.top_right.y () < op1.top_right.y ())
242  op1.top_right.set_y (op2.top_right.y ());
243  }
244  else {
245  op1.bot_left.set_x (INT16_MAX);
246  op1.bot_left.set_y (INT16_MAX);
247  op1.top_right.set_x (-INT16_MAX);
248  op1.top_right.set_y (-INT16_MAX);
249  }
250  return op1;
251 }
void set_x(int16_t xin)
rewrite function
Definition: points.h:62
int16_t y() const
access_function
Definition: points.h:57
int16_t x() const
access function
Definition: points.h:53
bool overlap(const TBOX &box) const
Definition: rect.h:355
void set_y(int16_t yin)
rewrite function
Definition: points.h:66

◆ operator+=()

DLLSYM TBOX& operator+= ( TBOX op1,
const TBOX op2 
)

Definition at line 205 of file rect.cpp.

207  {
208  if (op2.bot_left.x () < op1.bot_left.x ())
209  op1.bot_left.set_x (op2.bot_left.x ());
210 
211  if (op2.top_right.x () > op1.top_right.x ())
212  op1.top_right.set_x (op2.top_right.x ());
213 
214  if (op2.bot_left.y () < op1.bot_left.y ())
215  op1.bot_left.set_y (op2.bot_left.y ());
216 
217  if (op2.top_right.y () > op1.top_right.y ())
218  op1.top_right.set_y (op2.top_right.y ());
219 
220  return op1;
221 }
void set_x(int16_t xin)
rewrite function
Definition: points.h:62
int16_t y() const
access_function
Definition: points.h:57
int16_t x() const
access function
Definition: points.h:53
void set_y(int16_t yin)
rewrite function
Definition: points.h:66