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

Linux Cross Reference
Tina5/tina-libs/tina/geometry/geomCurve_string3.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_string3.c,v $
 23  * Date    :  $Date: 2003/09/09 16:02:21 $
 24  * Version :  $Revision: 1.2 $
 25  * CVS Id  :  $Id: geomCurve_string3.c,v 1.2 2003/09/09 16:02:21 ipoole Exp $
 26  *
 27  * Author  : Legacy TINA
 28  *
 29  * Notes : 
 30 recover string of Vec3 from curve function
 31  *
 32  *********
 33 */
 34 
 35 #include "geomCurve_string3.h"
 36 
 37 #if HAVE_CONFIG_H
 38   #include <config.h>
 39 #endif
 40 
 41 #include <math.h>
 42 #include <tina/sys/sysDef.h>
 43 #include <tina/sys/sysPro.h>
 44 #include <tina/math/mathDef.h>
 45 #include <tina/math/mathPro.h>
 46 
 47 
 48 static  Vec3(*curve_func) ();           /* static data! */      
 49 static void *curve_data;                        /* static data! */
 50 static double max_sep = 2.0;            /* static data! */
 51 
 52 void    str_to_curve3_sep_set(double sep)
 53 {
 54     max_sep = sep;
 55 }
 56 
 57 double  str_to_curve3_sep_get(void)
 58 {
 59     return (max_sep);
 60 }
 61 
 62 static List *curve3_chop(double t1, double t2, Vec3 v1, Vec3 v2)
 63 {
 64     double  t;
 65     Vec3    v = {Vec3_id};
 66 
 67     if (vec3_mod(vec3_diff(v1, v2)) < max_sep)
 68         return (dd_link_alloc((void *) vec3_make(v2), VEC3));
 69 
 70     t = (t1 + t2) * 0.5;
 71     v = curve_func(curve_data, t);
 72     return (dd_append(curve3_chop(t1, t, v1, v), curve3_chop(t, t2, v, v2)));
 73 }
 74 
 75 Tstring *str3_of_curve3(Vec3(*c_func) ( /* ??? */ ), void *c_data, double t1, double t2)
 76 {
 77     List *list;
 78     Tstring *str;
 79     double  tm;
 80     Vec3    v1 = {Vec3_id};
 81     Vec3    v2 = {Vec3_id};
 82     Vec3    vm = {Vec3_id};
 83 
 84     if (c_func == NULL)
 85         return (NULL);
 86 
 87     curve_func = c_func;
 88     curve_data = c_data;
 89 
 90     tm = (t1 + t2) * 0.5;
 91     v1 = curve_func(curve_data, t1);
 92     v2 = curve_func(curve_data, t2);
 93     vm = curve_func(curve_data, tm);
 94     list = dd_link_alloc((void *) vec3_make(v1), VEC3);
 95     list = dd_append(list, curve3_chop(t1, tm, v1, vm));
 96     list = dd_append(list, curve3_chop(tm, t2, vm, v2));
 97 
 98     str = str_make(STRING, list, dd_get_end(list));
 99     return (str);
100 }
101 

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