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

Linux Cross Reference
Tina4/src/vision/corner/set_findex.c

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

  1 /**@(#)
  2 **/
  3 /* functions for indexing the edgerect structure at the edgel level.
  4  * 
  5  */
  6 #include <tina/sys.h>
  7 #include <tina/sysfuncs.h>
  8 #include <tina/math.h>
  9 #include <tina/vision.h>
 10 #include <tina/visionfuncs.h>
 11 
 12 static Vec2 *(*locate) ();
 13 static Imregion *er_rect_bounding_region(Imrect * er);
 14 
 15 
 16 /* routine to construct a fast access index for edge structures stored
 17  * in the Imrect er. The indexing scheme is positional using the
 18  * location for each edge defined by the function locate_func. The
 19  * resulting structure is put into the Imrects property list for later
 20  * retrieval by the given type and then returned. */
 21 Rindex *er_set_findex(Imrect * er, int type, Vec2 * (*locate_func) ( /* ??? */ ))
 22 {
 23     Rindex *fx;
 24     Rindex *rx_alloc();
 25     Imregion *index_region;
 26     int     lx, ly, ux, uy;
 27     int     i, j;
 28     Vec2   *edge_pos(Edgel * edgel);
 29     void    rx_free_links();
 30 
 31     if (er->vtype != ptr_v)
 32     {
 33         error("findex: passed non edge rect ", non_fatal);
 34         return (NULL);
 35     }
 36     if (locate_func == NULL)
 37         locate = edge_pos;
 38     else
 39         locate = locate_func;
 40 
 41     index_region = er_rect_bounding_region(er);
 42     if (index_region == NULL)
 43     {
 44         error("findex: nill region ", non_fatal);
 45         return (NULL);
 46     }
 47     fx = rx_alloc(index_region, type);
 48 
 49     lx = er->region->lx;
 50     ly = er->region->ly;
 51     ux = er->region->ux;
 52     uy = er->region->uy;
 53 
 54     for (i = ly; i < uy; ++i)
 55     {
 56         for (j = lx; j < ux; ++j)
 57         {
 58             Edgel  *edge = (Edgel *) IM_PTR(er, i, j);
 59 
 60             if (edge != NULL)
 61             {
 62                 List   *link_addtostart();
 63                 Vec2   *rect;
 64                 int     ry;
 65 
 66                 if ((rect = locate(edge)) != NULL)
 67                 {
 68                     ry = (int)floor(rect->el[1]);
 69                     fx->index[ry] = link_addtostart((List *) fx->index[ry],
 70                                    link_alloc((void *) edge, STRING));
 71                 }
 72             }
 73         }
 74     }
 75     er->props = proplist_addifnp(er->props, (void *) fx, type, rx_free_links, true);
 76     return (fx);
 77 }
 78 
 79 Vec2   *edge_pos(Edgel * edgel)
 80 {
 81     return (&edgel->pos);
 82 }
 83 
 84 /* ARGSUSED quieten lint */
 85 static void inc_region(Edgel * edge, int type, Imregion * roi)
 86 
 87 /* not used */
 88 
 89 {
 90     int     x, y;
 91     Vec2   *rect;
 92 
 93     if ((rect = locate(edge)) == NULL)
 94         return;
 95     x = (int)floor(rect->el[0]);
 96     y = (int)floor(rect->el[1]);
 97 
 98     if (roi->lx == LARGEST_INT)
 99     {
100         roi->lx = roi->ux = x;
101         roi->ly = roi->uy = y;
102         return;
103     }
104     if (x < roi->lx)
105         roi->lx = x;
106     if (y < roi->ly)
107         roi->ly = y;
108     if (x > roi->ux)
109         roi->ux = x;
110     if (y > roi->uy)
111         roi->uy = y;
112 }
113 
114 static Imregion *er_rect_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_edges(er, (void (*) ()) inc_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.