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

Linux Cross Reference
Tina6/tina-libs/tina/geometry/geomEdge_gen.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/geomEdge_gen.c,v $
 27  * Date    :  $Date: 2005/01/09 17:49:25 $
 28  * Version :  $Revision: 1.2 $
 29  * CVS Id  :  $Id: geomEdge_gen.c,v 1.2 2005/01/09 17:49:25 paul Exp $
 30  *
 31  * Author  : Legacy TINA
 32  *
 33  * Notes : edge handling functions
 34  *
 35  *********
 36 */
 37 
 38 #include "geomEdge_gen.h"
 39 
 40 #if HAVE_CONFIG_H
 41   #include <config.h>
 42 #endif
 43 
 44 #include <math.h>
 45 #include <stdio.h>
 46 #include <string.h>
 47 #include <tina/sys/sysDef.h>
 48 #include <tina/sys/sysPro.h>
 49 #include <tina/math/mathDef.h>
 50 #include <tina/math/mathPro.h>
 51 #include <tina/geometry/geomDef.h>
 52 #include <tina/geometry/geom_EdgeDef.h>
 53 #ifdef _PCC
 54 #include <memory.h>
 55 #endif
 56 
 57 static int label;
 58 
 59 Edgel  *edge_alloc(int type)
 60 {
 61     Edgel  *edge = ts_ralloc(Edgel);
 62 
 63     edge->type = type;
 64     edge->label = label++;
 65     edge->pos = vec2_zero();
 66     edge->orient = edge->contrast = (float) 0.0;
 67     edge->props = NULL;
 68     return (edge);
 69 }
 70 
 71 Edge_conn *econn_alloc(void)
 72 {
 73     Edge_conn *econn = ts_ralloc(Edge_conn);
 74 
 75     econn->conns = NULL;
 76     econn->c1 = econn->c2 = NULL;
 77     econn->count = 0;
 78     return (econn);
 79 }
 80 
 81 void    edge_free(Edgel * edge)
 82 {
 83     if (edge == NULL)
 84         return;
 85     proplist_freelist(edge->props);
 86     rfree((void *) edge);
 87 }
 88 
 89 void    econn_free(Edge_conn * econn)
 90 {
 91     list_rm_links(econn->conns);
 92     rfree((void *) econn);
 93 }
 94 
 95 Edgel  *edge_copy(Edgel * edge)
 96 {
 97     Edgel  *copy;
 98     List   *proplist_copy();
 99 
100     if (edge == NULL)
101         return (NULL);
102 
103     copy = ts_ralloc(Edgel);
104     (void) memcpy((char *) copy, (char *) edge, sizeof(Edgel));
105     copy->props = proplist_copy(edge->props);
106     return (copy);
107 }
108 
109 void   *edge_sindex_prop_get(Edgel * e, int ptype)
110 
111 /* type of prop required */
112 {
113     Tstring *es;
114 
115     if (e == NULL)
116         return (NULL);
117 
118     es = (Tstring *) prop_get(e->props, SINDEX);
119     return ((es == NULL) ? NULL : prop_get(es->props, ptype));
120 }
121 
122 void   *edge_prop_get(Edgel * e, int ptype)
123 
124 /* type of prop required */
125 {
126     return ((e == NULL) ? NULL : prop_get(e->props, ptype));
127 }
128 
129 /* Get position of edge in image if possible */
130 Vec2    edge_image_pos(Edgel * edge)
131 {
132     Vec2   *pos = NULL;
133 
134     if (edge->type & EDGE_GET_RECT_MASK)        /* rectified in some way */
135         pos = prop_get(edge->props, IMPOS);
136 
137     return ((pos == NULL) ? edge->pos : *pos);
138 }
139 
140 void    edge_set_type_remove_me(Edgel * edge)
141 {
142     edge->type = REMOVE_ME;
143 }
144 
145 /* ARGSUSED quieten lint */
146 void    edge_rm_on_remove_me(Edgel * edge, int type, Imrect * edgerect, int i, int j)
147 {
148     if (edge->type == REMOVE_ME)
149     {
150         edge_free(edge);
151         IM_PTR(edgerect, i, j) = NULL;
152     }
153 }
154 
155 void    edge_save_pos_prop(Edgel * edge, int type, int prop_type)
156 {
157     Vec2   *p;
158 
159     if (type != EDGE || edge == NULL)
160         return;
161 
162     p = vec2_alloc();
163     *p = edge->pos;
164     edge->props = proplist_addifnp(edge->props, (void *) p, prop_type, vec2_free, true);
165 }
166 
167 void    edge_get_pos_prop(Edgel * edge, int type, int prop_type)
168 {
169     Vec2   *p;
170 
171     if (type != EDGE || edge == NULL)
172         return;
173 
174     p = prop_get(edge->props, prop_type);
175     if (p != NULL)
176         edge->pos = *p;
177 }
178 
179 void    edge_print(FILE * fp, Edgel * edge)
180 {
181     (void) fprintf(fp, "Edge type %d label %d ", edge->type, edge->label);
182     vec2_print(fp, edge->pos);
183     (void) fprintf(fp, "or %f con %f\n", edge->orient, edge->contrast);
184 }
185 
186 void    edge_format(Edgel * edge)
187 {
188     format("Edge type %d label %d ", edge->type, edge->label);
189     vec2_format(edge->pos);
190     format("or %f con %f\n", edge->orient, edge->contrast);
191 }
192 

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