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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomGen_error.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/geomGen_error.c,v $
 27  * Date    :  $Date: 2008/12/07 04:33:58 $
 28  * Version :  $Revision: 1.3 $
 29  * CVS Id  :  $Id: geomGen_error.c,v 1.3 2008/12/07 04:33:58 paul Exp $
 30  *
 31  * Notes :
 32  *
 33  *********
 34 */
 35 
 36 
 37 #include "geomGen_error.h"
 38 
 39 #if HAVE_CONFIG_H
 40   #include <config.h>
 41 #endif
 42 
 43 #include <tina/sys/sysDef.h>
 44 #include <tina/sys/sysPro.h>
 45 #include <tina/math/mathDef.h>
 46 #include <tina/math/mathPro.h>
 47 #include <tina/geometry/geomDef.h>
 48 #include <tina/geometry/geom_PointDef.h>
 49 #include <tina/geometry/geom_PointPro.h>
 50 #include <tina/geometry/geom_LineDef.h>
 51 #include <tina/geometry/geom_LinePro.h>
 52 #include <tina/geometry/geom_CurveDef.h>
 53 #include <tina/geometry/geom_CurvePro.h>
 54 #include <tina/geometry/geomGen_copy.h>
 55 #include <tina/geometry/geomGen_flat.h>
 56 #include <tina/geometry/geomGen_trans.h>
 57 #include <tina/geometry/geomGen_free.h>
 58 
 59 
 60 Bool    geom_within_error(void *geom1, void *geom2, int type)
 61 {
 62     switch (type)
 63     {
 64         case POINT3:
 65         return (point3_within_error((Point3 *) geom1, (Point3 *) geom2));
 66         break;
 67     case LINE3:
 68         return (line3_within_error((Line3 *) geom1, (Line3 *) geom2));
 69         break;
 70     case CONIC3:
 71         return (conic3_within_error((Conic3 *) geom1, (Conic3 *) geom2));
 72         break;
 73     }
 74     return (false);
 75 }
 76 
 77 /* for use with reclist_update of reclist_flat */
 78 void   *geom_within_error_update(void *geom1, int *type, void *geom2)
 79 {
 80     if (geom_within_error(geom1, geom2, *type))
 81         return (geom1);
 82     return (NULL);
 83 }
 84 
 85 static Match *geom_make_match(void *geom2, int *type, void *geom1)
 86 {
 87     Match  *match = match_make(geom1, geom2, *type);
 88 
 89     *type = MATCH;
 90     return (match);
 91 }
 92 
 93 static void *all_matches(void *geom, int *type, Pair * pair)
 94 
 95 
 96 /* transform and geom_list */
 97 {
 98     List   *geom_list;
 99     List   *mat_list;
100     Transform3 *trans;
101     Match  *match = NULL;
102     void   *copy;
103 
104     geom_list = (List *) pair->to1;
105     trans = (Transform3 *) pair->to2;
106 
107     copy = geom_copy(geom, *type);
108     geom_transform(copy, *type, trans);
109     geom_list = reclist_list_flat(geom_list, geom_within_error_update, *type, copy);
110     geom_free(copy, *type);
111 
112     if (geom_list == NULL)
113         return (NULL);
114 
115     if (list_length(geom_list) == 1)    /* a unique match */
116     {
117         match = match_make(geom, geom_list->to, *type);
118         list_rm_links(geom_list);
119         *type = MATCH;
120         return ((void *) match);
121     }
122     mat_list = reclist_list_update(geom_list, (void *(*) ()) geom_make_match, 0,
123                                    geom);
124     list_rm_links(geom_list);
125     *type = LIST;
126     return ((void *) mat_list);
127 }
128 
129 List   *geom3_all_matches_under_trans(List * g1, List * g2, Transform3 trans)
130 {
131     Pair   *pair = pair_make((void *) g2, LIST, (void *) &trans, TRANSFORM3);
132     List   *all_mats;
133 
134     all_mats = reclist_list_flat(g1, all_matches, 0, (void *) pair);    /* not flat */
135     return (geom_list_make_flat(all_mats));
136 }
137 

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