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

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

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