00001 /* -*-C-*- 00002 ******************************************************************************** 00003 * 00004 * File: olutil.h (Formerly olutil.h) 00005 * Description: 00006 * Author: Mark Seaman, SW Productivity 00007 * Created: Fri Oct 16 14:37:00 1987 00008 * Modified: Wed Jul 10 14:21:55 1991 (Mark Seaman) marks@hpgrlt 00009 * Language: C 00010 * Package: N/A 00011 * Status: Reusable Software Component 00012 * 00013 * (c) Copyright 1987, 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 #ifndef OLUTIL_H 00026 #define OLUTIL_H 00027 00028 /*---------------------------------------------------------------------- 00029 I n c l u d e s 00030 ----------------------------------------------------------------------*/ 00031 #include "tessclas.h" 00032 #include "general.h" 00033 00034 /*---------------------------------------------------------------------- 00035 M a c r o s 00036 ----------------------------------------------------------------------*/ 00037 /********************************************************************** 00038 * is_inside_angle 00039 * 00040 * Return true if the edgept supplied as input is an inside angle. This 00041 * is determined by the angular change of the vectors from point to 00042 * point. 00043 00044 **********************************************************************/ 00045 00046 #define is_inside_angle(pt) \ 00047 (angle_change ((pt)->prev, (pt), (pt)->next) < chop_inside_angle) 00048 00049 /********************************************************************** 00050 * point_in_outline 00051 * 00052 * Check to see if this point falls within the bounding box of this 00053 * outline. Note that this does not totally ensure that the edge 00054 * point falls on this outline. 00055 **********************************************************************/ 00056 00057 #define point_in_outline(p,o) \ 00058 ((p)->pos.x >= (o)->topleft.x && \ 00059 (p)->pos.y <= (o)->topleft.y && \ 00060 (p)->pos.x <= (o)->botright.x && \ 00061 (p)->pos.y >= (o)->botright.y) \ 00062 00063 00064 /********************************************************************** 00065 * same_outline_bounds 00066 * 00067 * Return TRUE if these two outlines have the same bounds. 00068 **********************************************************************/ 00069 00070 #define same_outline_bounds(outline,other_outline) \ 00071 (outline->topleft.x == other_outline->topleft.x && \ 00072 outline->topleft.y == other_outline->topleft.y && \ 00073 outline->botright.x == other_outline->botright.x && \ 00074 outline->botright.y == other_outline->botright.y) \ 00075 00076 00077 /********************************************************************** 00078 * weighted_edgept_dist 00079 * 00080 * Return the distance (squared) between the two edge points. 00081 **********************************************************************/ 00082 00083 #define weighted_edgept_dist(p1,p2,chop_x_y_weight) \ 00084 (((p1)->pos.x - (p2)->pos.x) * \ 00085 ((p1)->pos.x - (p2)->pos.x) * chop_x_y_weight + \ 00086 ((p1)->pos.y - (p2)->pos.y) * \ 00087 ((p1)->pos.y - (p2)->pos.y)) 00088 00089 /*---------------------------------------------------------------------- 00090 F u n c t i o n s 00091 ----------------------------------------------------------------------*/ 00092 void check_outline_mem(); 00093 00094 void correct_blob_order(TBLOB *blob1, TBLOB *blob2); 00095 00096 void eliminate_duplicate_outlines(TBLOB *blob); 00097 00098 void setup_outline(TESSLINE *outline); 00099 00100 void setup_blob_outlines(TBLOB *blob); 00101 00102 #endif