Tesseract  3.02
tesseract-ocr/ccstruct/vecfuncs.cpp
Go to the documentation of this file.
00001 /* -*-C-*-
00002  ********************************************************************************
00003  *
00004  * File:        vecfuncs.c  (Formerly vecfuncs.c)
00005  * Description:  Blob definition
00006  * Author:       Mark Seaman, OCR Technology
00007  * Created:      Fri Oct 27 15:39:52 1989
00008  * Modified:     Tue Jul  9 17:44:12 1991 (Mark Seaman) marks@hpgrlt
00009  * Language:     C
00010  * Package:      N/A
00011  * Status:       Experimental (Do Not Distribute)
00012  *
00013  * (c) Copyright 1989, Hewlett-Packard Company.
00014  ** Licensed under the Apache License, Version 2.0 (the "License");
00015  ** you may not use this file except in compliance with the License.
00016  ** You may obtain a copy of the License at
00017  ** http://www.apache.org/licenses/LICENSE-2.0
00018  ** Unless required by applicable law or agreed to in writing, software
00019  ** distributed under the License is distributed on an "AS IS" BASIS,
00020  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00021  ** See the License for the specific language governing permissions and
00022  ** limitations under the License.
00023  *
00024  ********************************************************************************
00025  * Revision 5.1  89/07/27  11:47:50  11:47:50  ray ()
00026  * Added ratings acces methods.
00027  * This version ready for independent development.
00028  */
00029 /*----------------------------------------------------------------------
00030               I n c l u d e s
00031 ----------------------------------------------------------------------*/
00032 #include "mfcpch.h"
00033 #include "vecfuncs.h"
00034 
00035 /*----------------------------------------------------------------------
00036               F u n c t i o n s
00037 ----------------------------------------------------------------------*/
00038 /**********************************************************************
00039  *  direction
00040  *
00041  *  Show if the line is going in the positive or negative X direction.
00042  **********************************************************************/
00043 int direction(EDGEPT *point) {
00044   int dir;                       
00045   EDGEPT *prev;                  
00046   EDGEPT *next;                  
00048   dir = 0;
00049   prev = point->prev;
00050   next = point->next;
00051 
00052   if (((prev->pos.x <= point->pos.x) &&
00053     (point->pos.x < next->pos.x)) ||
00054     ((prev->pos.x < point->pos.x) && (point->pos.x <= next->pos.x)))
00055     dir = 1;
00056 
00057   if (((prev->pos.x >= point->pos.x) &&
00058     (point->pos.x > next->pos.x)) ||
00059     ((prev->pos.x > point->pos.x) && (point->pos.x >= next->pos.x)))
00060     dir = -1;
00061 
00062   return dir;
00063 }