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

Linux Cross Reference
Tina5/tina-libs/tina/geometry/geomCurve_splines.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/geomCurve_splines.c,v $
 23  * Date    :  $Date: 2003/09/12 18:01:24 $
 24  * Version :  $Revision: 1.2 $
 25  * CVS Id  :  $Id: geomCurve_splines.c,v 1.2 2003/09/12 18:01:24 ipoole Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes :
 30  *
 31  * functions to take strings of 2d positions and return various forms of
 32  * spline fit through them
 33  * 
 34  * function to take a string of pos2 (referenced through the DD_GET_POS
 35  * macro) and return a string of Vec2 representation of the
 36  * interpolated conic spline 
 37  *********
 38 */
 39 
 40 #include "geomCurve_splines.h"
 41 
 42 #if HAVE_CONFIG_H
 43   #include <config.h>
 44 #endif
 45 
 46 #include <math.h>
 47 #include <tina/sys/sysDef.h>
 48 #include <tina/sys/sysPro.h>
 49 #include <tina/math/mathDef.h>
 50 #include <tina/math/mathPro.h>
 51 #include <tina/geometry/geomDef.h>
 52 
 53 
 54 Tstring *str_ics2(Tstring * str, int knot_sample, double str_space, double *a, double *b)
 55 /* string of pos2 */
 56 /* sample of underlying spline */
 57 /* with respect to units of underlying string */
 58 /* end point derivetive conditions: NULL for natural */
 59 {
 60     List *ptr;
 61     List *start;
 62     List *end;
 63     int     i, nknots;
 64     float  *t, *x, *y, *x2, *y2;
 65     float   s, sum;
 66     Vec2    p = {Vec2_id};
 67     Vec2    p_last = {Vec2_id};
 68 
 69     if (str == NULL || str->start == str->end || str->start == NULL)
 70         return (NULL);
 71 
 72     nknots = str->count / knot_sample + 2;      /* maximum possible size */
 73     start = str->start;
 74     end = str->end;
 75 
 76     t = fvector_alloc(0, nknots);
 77     x = fvector_alloc(0, nknots);
 78     y = fvector_alloc(0, nknots);
 79     x2 = fvector_alloc(0, nknots);
 80     y2 = fvector_alloc(0, nknots);
 81 
 82     DD_GET_POS2(start, p_last);
 83     for (nknots=0, sum=(float)0.0, i=0, ptr=start;; ptr=ptr->next, i++)
 84     {
 85         if (i % knot_sample == 0 || ptr == end)
 86         {
 87             DD_GET_POS2(ptr, p);
 88             x[nknots] = vec2_x(p);
 89             y[nknots] = vec2_y(p);
 90             sum += (float) vec2_mod(vec2_diff(p, p_last));
 91             t[nknots] = sum;
 92             nknots++;
 93             p_last = p;
 94             if (ptr == end)
 95                 break;
 96         }
 97     }
 98 
 99     spl_ci_sbp(t, x, nknots, a, b, x2);
100     spl_ci_sbp(t, y, nknots, a, b, y2);
101 
102     start = NULL;
103     for (s = t[0]; s <= sum; s += (float)str_space)
104     {
105         vec2_x(p) = (float) spl_ci_val(t, x, x2, nknots, s);
106         vec2_y(p) = (float) spl_ci_val(t, y, y2, nknots, s);
107         start = dd_ref_addtostart(start, vec2_make(p), VEC2);
108     }
109 
110     if (start == NULL)
111         return (NULL);
112 
113     start = dd_list_reverse(start);
114     end = dd_get_end(start);
115 
116     fvector_free(t, 0);
117     fvector_free(x, 0);
118     fvector_free(y, 0);
119     fvector_free(x2, 0);
120     fvector_free(y2, 0);
121 
122     return (str_make(STRING, start, end));
123 }
124 

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