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

Linux Cross Reference
Tina4/src/vision/curve2/string2.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/mathfuncs.h>
  7 #include <tina/vision.h>
  8 #include <tina/visionfuncs.h>
  9 
 10 /**
 11 recover unbroken (in pixel sence) string of Vec2 from curve function
 12 **/
 13 
 14 static  Vec2(*curve_func) ();
 15 static void *curve_data;
 16 static void *extra_data;
 17 
 18 static List *curve2_chop(double t1, double t2, Vec2 v1, Vec2 v2)
 19 {
 20     int     x1, y1, x2, y2;
 21     double  t;
 22     Vec2    v = {Vec2_id};
 23 
 24     x1 = (int)floor(vec2_x(v1));
 25     y1 = (int)floor(vec2_y(v1));
 26     x2 = (int)floor(vec2_x(v2));
 27     y2 = (int)floor(vec2_y(v2));
 28     if (x1 == x2 && y1 == y2)   /* same pixel */
 29         return (NULL);
 30     if (abs(x1 - x2) <= 1 && abs(y1 - y2) <= 1) /* neighbours */
 31         return (dd_link_alloc((void *) vec2_make(v2), VEC2));
 32 
 33     t = (t1 + t2) * 0.5;
 34     v = curve_func(curve_data, t, extra_data);
 35     return (dd_append(curve2_chop(t1, t, v1, v), curve2_chop(t, t2, v, v2)));
 36 }
 37 
 38 Tstring *str2_of_curve2(Vec2(*c_func) ( /* ??? */ ), void *c_data, double t1, double t2, void *e_data)
 39 {
 40     List *list;
 41     Tstring *str;
 42     double  tm;
 43     Vec2    v1 = {Vec2_id};
 44     Vec2    v2 = {Vec2_id};
 45     Vec2    vm = {Vec2_id};
 46     int     x1, x2, y1, y2;
 47 
 48     if (c_func == NULL)
 49         return (NULL);
 50 
 51     curve_func = c_func;
 52     curve_data = c_data;
 53     extra_data = e_data;
 54 
 55     tm = (t1 + t2) * 0.5;
 56     v1 = curve_func(curve_data, t1, extra_data);
 57     v2 = curve_func(curve_data, t2, extra_data);
 58     vm = curve_func(curve_data, tm, extra_data);
 59     list = dd_link_alloc((void *) vec2_make(v1), VEC2);
 60     list = dd_append(list, curve2_chop(t1, tm, v1, vm));
 61     list = dd_append(list, curve2_chop(tm, t2, vm, v2));
 62 
 63     str = str_make(STRING, list, dd_get_end(list));
 64     if (str == NULL || str->start == str->end)
 65         return (str);
 66 
 67     x1 = (int)floor(vec2_x(v1));
 68     x2 = (int)floor(vec2_x(v2));
 69     y1 = (int)floor(vec2_y(v1));
 70     y2 = (int)floor(vec2_y(v2));
 71     if (abs(x1 - x2) <= 1 && abs(y1 - y2) <= 1) /* neighbours */
 72     {
 73         if (x1 == x2 && y1 == y2)       /* in same pixel */
 74         {
 75             str->start = str->start->next;
 76             (void) dd_link_rm(list, rfree);     /* same as start */
 77         }
 78         str->type = LOOP;
 79         str->start->last = str->end;
 80         str->end->next = str->start;
 81     }
 82     return (str);
 83 }
 84 

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