~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina5/tina-libs/tina/geometry/geomEdge_bnd_region.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**********
  2  * 
  3  * This file is part of the TINA Open Source Image Analysis Environment
  4  * henceforth known as TINA
  5  *
  6  * TINA is free software; you can redistribute it and/or modify
  7  * it under the terms of the GNU Lesser General Public License as 
  8  * published by the Free Software Foundation.
  9  *
 10  * TINA is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU Lesser General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU Lesser General Public License
 16  * along with TINA; if not, write to the Free Software Foundation, Inc., 
 17  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 18  *
 19  **********
 20  * 
 21  * Program :    TINA
 22  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomEdge_bnd_region.c,v $
 23  * Date    :  $Date: 2002/12/09 11:51:23 $
 24  * Version :  $Revision: 1.1.1.1 $
 25  * CVS Id  :  $Id: geomEdge_bnd_region.c,v 1.1.1.1 2002/12/09 11:51:23 cvstina Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes : 
 30  *
 31  *********
 32 */
 33 
 34 #include "geomEdge_bnd_region.h"
 35 
 36 #if HAVE_CONFIG_H
 37   #include <config.h>
 38 #endif
 39 
 40 #include <math.h>
 41 #include <tina/sys/sysDef.h>
 42 #include <tina/sys/sysPro.h>
 43 #include <tina/math/mathDef.h>
 44 #include <tina/math/mathPro.h>
 45 #include <tina/image/imgDef.h>
 46 #include <tina/image/imgPro.h>
 47 #include <tina/geometry/geomDef.h>
 48 #include <tina/geometry/geomPro.h>
 49 
 50 
 51 static void inc_region(void *ptr, int type, Imregion * roi)
 52 {
 53     int     x, y;
 54     Vec2    p = {Vec2_id};
 55 
 56     GET_POS2(ptr, type, p);
 57     x = (int)floor(vec2_x(p));
 58     y = (int)floor(vec2_y(p));
 59 
 60     if (roi->lx == LARGEST_INT)
 61     {
 62         roi->lx = roi->ux = x;
 63         roi->ly = roi->uy = y;
 64         return;
 65     }
 66     if (x < roi->lx)
 67         roi->lx = x;
 68     if (y < roi->ly)
 69         roi->ly = y;
 70     if (x > roi->ux)
 71         roi->ux = x;
 72     if (y > roi->uy)
 73         roi->uy = y;
 74 }
 75 
 76 /* ARGSUSED quieten lint */
 77 static void es_region(Tstring * str, int type, Imregion * roi)
 78 {
 79     str_apply_func(str, inc_region, (void *) roi);
 80 }
 81 
 82 Imregion *es_bounding_region(Tstring * es)
 83 {
 84     Imregion *roi;
 85 
 86     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
 87     str_apply_func(es, inc_region, (void *) roi);
 88     if (roi->lx == LARGEST_INT)
 89     {
 90         rfree((void *) roi);
 91         return (NULL);
 92     }
 93     roi->ux += 1;
 94     roi->uy += 1;
 95     return (roi);
 96 }
 97 
 98 Imregion *strings_bounding_region(List * strings)
 99 {
100     Imregion *roi;
101 
102     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
103     list_apply_func(strings, es_region, (void *) roi);
104     if (roi->lx == LARGEST_INT)
105     {
106         rfree((void *) roi);
107         return (NULL);
108     }
109     roi->ux += 1;
110     roi->uy += 1;
111     return (roi);
112 }
113 
114 Imregion *er_bounding_region(Imrect * er)
115 {
116     Imregion *roi;
117 
118     if (er == NULL || er->vtype != ptr_v)
119         return (NULL);
120 
121     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
122     er_apply_to_all_strings(er, es_region, (void *) roi);
123     if (roi->lx == LARGEST_INT)
124     {
125         rfree((void *) roi);
126         return (NULL);
127     }
128     roi->ux += 1;
129     roi->uy += 1;
130     return (roi);
131 }
132 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.