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

Linux Cross Reference
Tina6/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 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 General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU 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  * ANY users of TINA who require exemption from the existing licence must
 20  * negotiate a new licence with Dr. Neil.A.Thacker, the sole agent for
 21  * the University of Manchester.
 22  *
 23  **********
 24  * 
 25  * Program :    TINA
 26  * File    :  $Source: /home/tina/cvs/tina-libs/tina/geometry/geomEdge_bnd_region.c,v $
 27  * Date    :  $Date: 2002/12/09 11:51:23 $
 28  * Version :  $Revision: 1.1.1.1 $
 29  * CVS Id  :  $Id: geomEdge_bnd_region.c,v 1.1.1.1 2002/12/09 11:51:23 cvstina Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes : 
 34  *
 35  *********
 36 */
 37 
 38 #include "geomEdge_bnd_region.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <tina/sys/sysDef.h>
 46 #include <tina/sys/sysPro.h>
 47 #include <tina/math/mathDef.h>
 48 #include <tina/math/mathPro.h>
 49 #include <tina/image/imgDef.h>
 50 #include <tina/image/imgPro.h>
 51 #include <tina/geometry/geomDef.h>
 52 #include <tina/geometry/geomPro.h>
 53 
 54 
 55 static void inc_region(void *ptr, int type, Imregion * roi)
 56 {
 57     int     x, y;
 58     Vec2    p = {Vec2_id};
 59 
 60     GET_POS2(ptr, type, p);
 61     x = (int)floor(vec2_x(p));
 62     y = (int)floor(vec2_y(p));
 63 
 64     if (roi->lx == LARGEST_INT)
 65     {
 66         roi->lx = roi->ux = x;
 67         roi->ly = roi->uy = y;
 68         return;
 69     }
 70     if (x < roi->lx)
 71         roi->lx = x;
 72     if (y < roi->ly)
 73         roi->ly = y;
 74     if (x > roi->ux)
 75         roi->ux = x;
 76     if (y > roi->uy)
 77         roi->uy = y;
 78 }
 79 
 80 /* ARGSUSED quieten lint */
 81 static void es_region(Tstring * str, int type, Imregion * roi)
 82 {
 83     str_apply_func(str, inc_region, (void *) roi);
 84 }
 85 
 86 Imregion *es_bounding_region(Tstring * es)
 87 {
 88     Imregion *roi;
 89 
 90     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
 91     str_apply_func(es, inc_region, (void *) roi);
 92     if (roi->lx == LARGEST_INT)
 93     {
 94         rfree((void *) roi);
 95         return (NULL);
 96     }
 97     roi->ux += 1;
 98     roi->uy += 1;
 99     return (roi);
100 }
101 
102 Imregion *strings_bounding_region(List * strings)
103 {
104     Imregion *roi;
105 
106     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
107     list_apply_func(strings, es_region, (void *) roi);
108     if (roi->lx == LARGEST_INT)
109     {
110         rfree((void *) roi);
111         return (NULL);
112     }
113     roi->ux += 1;
114     roi->uy += 1;
115     return (roi);
116 }
117 
118 Imregion *er_bounding_region(Imrect * er)
119 {
120     Imregion *roi;
121 
122     if (er == NULL || er->vtype != ptr_v)
123         return (NULL);
124 
125     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
126     er_apply_to_all_strings(er, es_region, (void *) roi);
127     if (roi->lx == LARGEST_INT)
128     {
129         rfree((void *) roi);
130         return (NULL);
131     }
132     roi->ux += 1;
133     roi->uy += 1;
134     return (roi);
135 }
136 

~ [ 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.