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

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

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