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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomCurve_str3_tris.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_str3_tris.c,v $
 27  * Date    :  $Date: 2002/12/09 11:51:23 $
 28  * Version :  $Revision: 1.1.1.1 $
 29  * CVS Id  :  $Id: geomCurve_str3_tris.c,v 1.1.1.1 2002/12/09 11:51:23 cvstina Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *********
 36 */
 37 
 38 #include "geomCurve_str3_tris.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <tina/sys/sysDef.h>
 46 #include <tina/sys/sysPro.h>
 47 #include <tina/math/mathDef.h>
 48 #include <tina/math/mathPro.h>
 49 #include <tina/geometry/geomDef.h>
 50 
 51 
 52 Bool    dist_to_pos3(Vec3 * ptr, int type, Vec3 * pp, double *dist)
 53 {
 54     if (ptr == NULL || type != VEC3)
 55         return (false);
 56 
 57     *dist = vec3_mod(vec3_diff(*pp, *ptr));
 58     return (true);
 59 }
 60 
 61 Vec3   *tri3_make(Vec3 p1, Vec3 p2, Vec3 p3)
 62 {
 63     Vec3   *tri;
 64 
 65     tri = ts_nvector_alloc(0, 3, Vec3); /* array of VEC3 */
 66     tri[0] = p1;
 67     tri[1] = p2;
 68     tri[2] = p3;
 69     return (tri);
 70 }
 71 
 72 List   *str3_triangulate(Tstring * s1, Tstring * s2, int sample)
 73 {
 74     List *ptr1;
 75     List *ptr2;
 76     List *end;
 77     Vec3    p1 = {Vec3_id};
 78     Vec3    p2 = {Vec3_id};
 79     Vec3    p1_last = {Vec3_id};
 80     Vec3    p2_last = {Vec3_id};
 81     List   *tris = NULL;
 82     int     i;
 83 
 84     if (s1 == NULL || s2 == NULL || s1->start == s1->end)
 85         return (NULL);
 86 
 87     ptr1 = s1->start;
 88     end = s1->end;
 89     p1_last = *(Vec3 *) (ptr1->to);
 90     ptr2 = str_get_min(s2, dist_to_pos3, (void *) &p1_last);
 91     p2_last = *(Vec3 *) (ptr2->to);
 92     ptr1 = ptr1->next;
 93 
 94     for (i = 1;; i++, ptr1 = ptr1->next)
 95     {
 96         if (i % sample == 0 || ptr1 == end)
 97         {
 98             if (ptr1 == end && s1->type == LOOP)
 99                 p1 = *(Vec3 *) (s1->start->to);
100             else
101                 p1 = *(Vec3 *) (ptr1->to);
102             ptr2 = str_get_min(s2, dist_to_pos3, (void *) &p1);
103             p2 = *(Vec3 *) (ptr2->to);
104 
105             tris = ref_addtostart(tris, (void *) tri3_make(p1_last, p2_last, p2), TRIANGLE3);
106             tris = ref_addtostart(tris, (void *) tri3_make(p1_last, p2, p1), TRIANGLE3);
107             p1_last = p1;
108             p2_last = p2;
109         }
110         if (ptr1 == end)
111             break;
112     }
113     return (tris);
114 }
115 
116 static Vec3 *make_vec3_from_vec2(Vec2 * v2, int *type, double *z)
117 {
118     Vec3   *v3;
119 
120     v3 = vec3_make(vec3_of_vec2(*v2));
121     vec3_z(*v3) = (float) *z;
122     *type = VEC3;
123     return (v3);
124 }
125 
126 List   *str2_triangulate3(Tstring * s1, double z1, Tstring * s2, double z2, int sample)
127 {
128     Tstring *s1_3, *s2_3;
129     List   *tris;
130 
131     s1_3 = reclist_string_update(s1, (void *(*) ()) make_vec3_from_vec2,
132                                  VEC2, (void *) &z1);
133     s2_3 = reclist_string_update(s2, (void *(*) ()) make_vec3_from_vec2,
134                                  VEC2, (void *) &z2);
135     tris = str3_triangulate(s1_3, s2_3, sample);
136     str_rm(s1_3, rfree);
137     str_rm(s2_3, rfree);
138     return (tris);
139 }
140 

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