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

Linux Cross Reference
Tina4/src/vision/edge/bnd_region.c

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

  1 /**@(#)
  2 **/
  3 #include <tina/sys.h>
  4 #include <tina/sysfuncs.h>
  5 #include <tina/math.h>
  6 #include <tina/vision.h>
  7 #include <tina/visionfuncs.h>
  8 
  9 static void inc_region(void *ptr, int type, Imregion * roi)
 10 {
 11     int     x, y;
 12     Vec2    p = {Vec2_id};
 13 
 14     GET_POS2(ptr, type, p);
 15     x = (int)floor(vec2_x(p));
 16     y = (int)floor(vec2_y(p));
 17 
 18     if (roi->lx == LARGEST_INT)
 19     {
 20         roi->lx = roi->ux = x;
 21         roi->ly = roi->uy = y;
 22         return;
 23     }
 24     if (x < roi->lx)
 25         roi->lx = x;
 26     if (y < roi->ly)
 27         roi->ly = y;
 28     if (x > roi->ux)
 29         roi->ux = x;
 30     if (y > roi->uy)
 31         roi->uy = y;
 32 }
 33 
 34 /* ARGSUSED quieten lint */
 35 static void es_region(Tstring * str, int type, Imregion * roi)
 36 {
 37     str_apply_func(str, inc_region, (void *) roi);
 38 }
 39 
 40 Imregion *es_bounding_region(Tstring * es)
 41 {
 42     Imregion *roi;
 43 
 44     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
 45     str_apply_func(es, inc_region, (void *) roi);
 46     if (roi->lx == LARGEST_INT)
 47     {
 48         rfree((void *) roi);
 49         return (NULL);
 50     }
 51     roi->ux += 1;
 52     roi->uy += 1;
 53     return (roi);
 54 }
 55 
 56 Imregion *strings_bounding_region(List * strings)
 57 {
 58     Imregion *roi;
 59 
 60     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
 61     list_apply_func(strings, es_region, (void *) roi);
 62     if (roi->lx == LARGEST_INT)
 63     {
 64         rfree((void *) roi);
 65         return (NULL);
 66     }
 67     roi->ux += 1;
 68     roi->uy += 1;
 69     return (roi);
 70 }
 71 
 72 Imregion *er_bounding_region(Imrect * er)
 73 {
 74     Imregion *roi;
 75 
 76     if (er == NULL || er->vtype != ptr_v)
 77         return (NULL);
 78 
 79     roi = roi_alloc(LARGEST_INT, LARGEST_INT, LARGEST_INT, LARGEST_INT);
 80     er_apply_to_all_strings(er, es_region, (void *) roi);
 81     if (roi->lx == LARGEST_INT)
 82     {
 83         rfree((void *) roi);
 84         return (NULL);
 85     }
 86     roi->ux += 1;
 87     roi->uy += 1;
 88     return (roi);
 89 }
 90 

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