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

Linux Cross Reference
Tina6/tina-libs/tina/vision/visModel_geom.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/vision/visModel_geom.c,v $
 27  * Date    :  $Date: 2003/10/06 12:29:48 $
 28  * Version :  $Revision: 1.3 $
 29  * CVS Id  :  $Id: visModel_geom.c,v 1.3 2003/10/06 12:29:48 neil Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes :
 34  *
 35  *
 36  *********
 37 */
 38 
 39 #include "visModel_geom.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 #include <tina/geometry/geomDef.h>
 51 #include <tina/geometry/geomPro.h>
 52 #include <tina/vision/vis_ModelDef.h>
 53 #include <tina/vision/vis_ModelPro.h>
 54 
 55 static float lthres = (float) 10.0;
 56 
 57 void    matcher_set_lthres(double lengththres)
 58 {
 59     lthres = (float) lengththres;
 60 }
 61 
 62 double  matcher_get_lthres(void)
 63 {
 64     return (lthres);
 65 }
 66 
 67 void   *smm_filter(void *geom, int type)
 68 {
 69     switch (type)
 70     {
 71         case POINT3:
 72         return ((void *) point3_copy((Point3 *) geom));
 73     case LINE3:
 74         {
 75             Line3  *l = (Line3 *) geom;
 76 
 77             if (l->length > lthres)
 78                 return ((void *) line3_copy(l));
 79             return (NULL);
 80         }
 81     case CONIC3:
 82         {
 83             Conic3 *c = (Conic3 *) geom;
 84 
 85             if (c->type == ELLIPSE)
 86                 return ((void *) conic3_copy(c));
 87             return (NULL);
 88         }
 89     case PLANE:
 90         return ((void *) plane_copy((Plane *) geom));
 91     case TRANSF3:
 92         return ((void *) transf3_copy((Transf3 *) geom));
 93     }
 94     return (NULL);
 95 }
 96 
 97 Bool    smm_pwr_allowed_type(int type)
 98 {
 99     switch (type)
100     {
101         case POINT3:
102         case LINE3:
103         case CONIC3:
104         return (true);
105     default:
106         return (false);
107     }
108 }
109 
110 Vec3    smm_geom_position(void *geom, int type)
111 {
112     switch (type)
113     {
114         case POINT3:
115         return (((Point3 *) geom)->p);
116     case LINE3:
117         {
118             Line3  *l = (Line3 *) geom;
119 
120             return (vec3_times(0.5, vec3_sum(l->p1, l->p2)));
121         }
122     case CONIC3:
123         return (((Conic3 *) geom)->origin);
124     }
125     return (vec3(0.0, 0.0, 0.0));
126 }
127 
128 double  smm_geom_separation(void *g1, int type1, void *g2, int type2)
129 {
130     Vec3    diff = {Vec3_id};
131 
132     diff = vec3_diff(smm_geom_position(g1, type1), smm_geom_position(g2, type2));
133     return (vec3_mod(diff));
134 }
135 
136 double  smm_geom_sepsq(void *g1, int type1, void *g2, int type2)
137 {
138     Vec3    diff = {Vec3_id};
139 
140     diff = vec3_diff(smm_geom_position(g1, type1), smm_geom_position(g2, type2));
141     return (vec3_sqrmod(diff));
142 }
143 
144 #define PARALLEL_DOTPROD 0.985  /* cos of 10 degrees */
145 
146 Bool    smm_geom_parallel(void *g1, int type1, void *g2, int type2)
147 {
148     switch (OPAIR(type1, type2))
149     {
150         case OPAIR(LINE3, LINE3):
151         {
152             Line3  *l1 = (Line3 *) g1;
153             Line3  *l2 = (Line3 *) g2;
154 
155             if (fabs(vec3_dot(l1->v, l2->v)) > PARALLEL_DOTPROD)
156                 return (true);
157             else
158                 return (false);
159         }
160     case OPAIR(LINE3, CONIC3):
161         {
162             Line3  *l = (Line3 *) g1;
163             Conic3 *c = (Conic3 *) g2;
164 
165             if (fabs(vec3_dot(l->v, c->ez)) > PARALLEL_DOTPROD)
166                 return (true);
167             else
168                 return (false);
169         }
170     case OPAIR(CONIC3, LINE3):
171         {
172             Conic3 *c = (Conic3 *) g1;
173             Line3  *l = (Line3 *) g2;
174 
175             if (fabs(vec3_dot(l->v, c->ez)) > PARALLEL_DOTPROD)
176                 return (true);
177             else
178                 return (false);
179         }
180     }
181     return (false);
182 }
183 

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