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

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

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