1 /* -*-C-*- 2 ******************************************************************************** 3 * 4 * File: olutil.h (Formerly olutil.h) 5 * Description: 6 * Author: Mark Seaman, SW Productivity 7 * Created: Fri Oct 16 14:37:00 1987 8 * Modified: Wed Jul 10 14:21:55 1991 (Mark Seaman) marks@hpgrlt 9 * Language: C 10 * Package: N/A 11 * Status: Reusable Software Component 12 * 13 * (c) Copyright 1987, Hewlett-Packard Company. 14 ** Licensed under the Apache License, Version 2.0 (the "License"); 15 ** you may not use this file except in compliance with the License. 16 ** You may obtain a copy of the License at 17 ** http://www.apache.org/licenses/LICENSE-2.0 18 ** Unless required by applicable law or agreed to in writing, software 19 ** distributed under the License is distributed on an "AS IS" BASIS, 20 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 ** See the License for the specific language governing permissions and 22 ** limitations under the License. 23 * 24 *********************************************************************************/ 25 #ifndef OLUTIL_H 26 #define OLUTIL_H 27 28 /*---------------------------------------------------------------------- 29 I n c l u d e s 30 ----------------------------------------------------------------------*/ 31 #include "tessclas.h" 32 #include "general.h" 33 34 /*---------------------------------------------------------------------- 35 M a c r o s 36 ----------------------------------------------------------------------*/ 37 /********************************************************************** 38 * is_inside_angle 39 * 40 * Return true if the edgept supplied as input is an inside angle. This 41 * is determined by the angular change of the vectors from point to 42 * point. 43 44 **********************************************************************/ 45 46 #define is_inside_angle(pt) \ 47 (angle_change ((pt)->prev, (pt), (pt)->next) < chop_inside_angle) 48 49 /********************************************************************** 50 * point_in_outline 51 * 52 * Check to see if this point falls within the bounding box of this 53 * outline. Note that this does not totally ensure that the edge 54 * point falls on this outline. 55 **********************************************************************/ 56 57 #define point_in_outline(p,o) \ 58 ((p)->pos.x >= (o)->topleft.x && \ 59 (p)->pos.y <= (o)->topleft.y && \ 60 (p)->pos.x <= (o)->botright.x && \ 61 (p)->pos.y >= (o)->botright.y) \ 62 63 64 /********************************************************************** 65 * same_outline_bounds 66 * 67 * Return TRUE if these two outlines have the same bounds. 68 **********************************************************************/ 69 70 #define same_outline_bounds(outline,other_outline) \ 71 (outline->topleft.x == other_outline->topleft.x && \ 72 outline->topleft.y == other_outline->topleft.y && \ 73 outline->botright.x == other_outline->botright.x && \ 74 outline->botright.y == other_outline->botright.y) \ 75 76 77 /********************************************************************** 78 * weighted_edgept_dist 79 * 80 * Return the distance (squared) between the two edge points. 81 **********************************************************************/ 82 83 #define weighted_edgept_dist(p1,p2,chop_x_y_weight) \ 84 (((p1)->pos.x - (p2)->pos.x) * \ 85 ((p1)->pos.x - (p2)->pos.x) * chop_x_y_weight + \ 86 ((p1)->pos.y - (p2)->pos.y) * \ 87 ((p1)->pos.y - (p2)->pos.y)) 88 89 /*---------------------------------------------------------------------- 90 F u n c t i o n s 91 ----------------------------------------------------------------------*/ 92 void check_outline_mem(); 93 94 void correct_blob_order(TBLOB *blob1, TBLOB *blob2); 95 96 void eliminate_duplicate_outlines(TBLOB *blob); 97 98 void setup_outline(TESSLINE *outline); 99 100 void setup_blob_outlines(TBLOB *blob); 101 102 #endif 103