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

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

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