ccstruct/rect.cpp File Reference

#include "mfcpch.h"
#include "rect.h"

Go to the source code of this file.

Functions


Function Documentation

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

Extend one box to include the other (In place union).

Definition at line 146 of file rect.cpp.

References BOX::bot_left, ICOORD::set_x(), ICOORD::set_y(), BOX::top_right, and ICOORD::y().

00148                  {
00149   if (op2.bot_left.x () < op1.bot_left.x ())
00150     op1.bot_left.set_x (op2.bot_left.x ());
00151 
00152   if (op2.top_right.x () > op1.top_right.x ())
00153     op1.top_right.set_x (op2.top_right.x ());
00154 
00155   if (op2.bot_left.y () < op1.bot_left.y ())
00156     op1.bot_left.set_y (op2.bot_left.y ());
00157 
00158   if (op2.top_right.y () > op1.top_right.y ())
00159     op1.top_right.set_y (op2.top_right.y ());
00160 
00161   return op1;
00162 }

DLLSYM BOX& operator-= ( BOX op1,
const BOX op2 
)

Reduce one box to intersection with the other (In place intersection).

Definition at line 169 of file rect.cpp.

References BOX::bot_left, MAX_INT16, BOX::overlap(), ICOORD::set_x(), ICOORD::set_y(), BOX::top_right, and ICOORD::y().

00171                  {
00172   if (op1.overlap (op2)) {
00173     if (op2.bot_left.x () > op1.bot_left.x ())
00174       op1.bot_left.set_x (op2.bot_left.x ());
00175 
00176     if (op2.top_right.x () < op1.top_right.x ())
00177       op1.top_right.set_x (op2.top_right.x ());
00178 
00179     if (op2.bot_left.y () > op1.bot_left.y ())
00180       op1.bot_left.set_y (op2.bot_left.y ());
00181 
00182     if (op2.top_right.y () < op1.top_right.y ())
00183       op1.top_right.set_y (op2.top_right.y ());
00184   }
00185   else {
00186     op1.bot_left.set_x (MAX_INT16);
00187     op1.bot_left.set_y (MAX_INT16);
00188     op1.top_right.set_x (-MAX_INT16);
00189     op1.top_right.set_y (-MAX_INT16);
00190   }
00191   return op1;
00192 }


Generated on Wed Feb 28 19:49:16 2007 for Tesseract by  doxygen 1.5.1