VIA - Volumetric Image Analysis
VEdges.h
00001 /*
00002  *  $Id: VEdges.h 726 2004-03-08 13:12:45Z lohmann $
00003  *
00004  *  Definitions associated with edges: their representation in files and
00005  *  in memory, and operations that can be performed with them.
00006  */
00007 
00008 #ifndef V_VEdges_h
00009 #define V_VEdges_h 1
00010 
00011 /*
00012  *  Copyright 1993, 1994 University of British Columbia
00013  *
00014  *  Permission to use, copy, modify, distribute, and sell this software and its
00015  *  documentation for any purpose is hereby granted without fee, provided that
00016  *  the above copyright notice appears in all copies and that both that
00017  *  copyright notice and this permission notice appear in supporting
00018  *  documentation. UBC makes no representations about the suitability of this
00019  *  software for any purpose. It is provided "as is" without express or
00020  *  implied warranty.
00021  *
00022  *  Author: David Lowe, UBC Laboratory for Computational Intelligence
00023  */
00024 
00025 /* From the Vista library: */
00026 #include "viaio/Vlib.h"
00027 #include "viaio/file.h"
00028 
00029 /* For portability: */
00030 #include <X11/Xfuncproto.h>
00031 
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035 
00036 
00037 /*  Structures for representing edges in memory.
00038  *  -------------------------------------------
00039  *
00040  *  The edges are stored as a linked list of edge records, as this makes
00041  *     it easy to allocate and add individual edges.
00042  *  The point data for each edge are stored in a 2-D array of floating point
00043  *     values.
00044  */
00045 
00046 typedef struct V_EdgesRec {
00047     int nrows;                  /* number of rows */
00048     int ncolumns;               /* number of columns */
00049     VAttrList attributes;       /* list of other attributes */
00050     int nedge_fields;           /* number of fields in each edge record */
00051     int npoint_fields;          /* number of fields in each point record */
00052     int nedges;                 /* number of edges */
00053     int npoints;                /* total number of points */
00054     struct VEdgeStruct *first;  /* first edge in linked list of edges */
00055     struct VEdgeStruct *last;   /* last edge in linked list of edges */
00056     VPointer free;              /* free this storage when destroying edges */
00057 } VEdgesRec;
00058 
00059 
00060 typedef struct VEdgeStruct {
00061     struct VEdgeStruct *next;   /* next edge in linked list of edges */
00062     VFloat *edge_fields;        /* vector of field entries for this edge */
00063     VBoolean closed;            /* indicates closed edge (a loop) */
00064     int npoints;                /* number of points in this edge */
00065     VFloat **point_index;       /* pointers to start of each point */
00066     VPointer free;              /* free this storage when destroying edges */
00067 } VEdgeRec, *VEdge;
00068 
00069 
00070 /*
00071  *  Attributes used to represent edges
00072  *  ----------------------------------
00073  */
00074 
00075 /* Attribute type names: */
00076 #define VEdgesAttr              "edges"
00077 #define VNEdgeFieldsAttr        "nedge_fields"
00078 #define VNPointFieldsAttr       "npoint_fields"
00079 #define VNEdgesAttr             "nedges"
00080 #define VNPointsAttr            "npoints"
00081 
00082 
00083 /*
00084  *  Macros for accessing edges attributes in memory.
00085  *  -----------------------------------------------
00086  */
00087 
00088 #define VEdgesNRows(edges)      ((edges)->nrows)
00089 
00090 #define VEdgesNColumns(edges)   ((edges)->ncolumns)
00091 
00092 #define VEdgesAttrList(edges)   ((edges)->attributes)
00093 
00094 #define VNEdgeFields(edges)     ((edges)->nedge_fields)
00095 
00096 #define VNPointFields(edges)    ((edges)->npoint_fields)
00097 
00098 #define VNEdges(edges)          ((edges)->nedges)
00099 
00100 #define VFirstEdge(edges)       ((edges)->first)
00101 
00102 #define VNextEdge(edge)         ((edge)->next)
00103 
00104 #define VEdgeExists(edge)       ((edge) != NULL)
00105 
00106 #define VEdgeFields(edge)       ((edge)->edge_fields)
00107 
00108 #define VEdgeNPoints(edge)      ((edge)->npoints)
00109 
00110 #define VEdgeClosed(edge)       ((edge)->closed)
00111 
00112 #define VEdgePointArray(edge)   ((edge)->point_index)
00113 
00114 /* Following are old macro names which should no longer be used.
00115    They can be removed in a future version once all of the documentation
00116    is in place and has been announced. */
00117 #define VEdgesCount(edges)      ((edges)->nedges)
00118 #define VEdgePoints(edge)       ((edge)->point_index)
00119 #define VEdgesEdgeFields(edges) ((edges)->nedge_fields)
00120 #define VEdgesPointFields(edges) ((edges)->npoint_fields)
00121 #define VEdgesRows(edges)       ((edges)->nrows)
00122 #define VEdgesColumns(edges)    ((edges)->ncolumns)
00123 #define VEdgePointCount(edge)   ((edge)->npoints)
00124 
00125 
00126 /*
00127  *  Declarations of library routines.
00128  */
00129 
00130 /* From Edges.c: */
00131 
00132 extern VEdges VCreateEdges (
00133 #if NeedFunctionPrototypes
00134     int                 /* nrows */,
00135     int                 /* ncols */,
00136     int                 /* nedge_fields */,
00137     int                 /* npoint_fields */
00138 #endif
00139 );
00140 
00141 extern VEdge VAddEdge (
00142 #if NeedFunctionPrototypes
00143     VEdges              /* edges */,
00144     VFloat *            /* edge_fields */,
00145     int                 /* npoints */,
00146     VFloat *            /* points */,
00147     VBooleanPromoted    /* closed */,
00148     VBooleanPromoted    /* copy */
00149 #endif
00150 );
00151 
00152 
00153 extern VEdges VCopyEdges (
00154 #if NeedFunctionPrototypes
00155     VEdges              /* edges */
00156 #endif
00157 );
00158 
00159 extern void VDestroyEdges (
00160 #if NeedFunctionPrototypes
00161     VEdges              /* edges */
00162 #endif
00163 );
00164 
00165 /* From EdgesIO.c: */
00166 
00167 extern int VReadEdges (
00168 #if NeedFunctionPrototypes
00169     FILE *              /* file */,
00170     VAttrList *         /* attributes */,
00171     VEdges **           /* edge_sets */
00172 #endif
00173 );
00174 
00175 extern VBoolean VWriteEdges (
00176 #if NeedFunctionPrototypes
00177     FILE *              /* file */,
00178     VAttrList           /* attributes */,
00179     int                 /* nedge_sets */,
00180     VEdges *            /* edge_sets */
00181 #endif
00182 );
00183 
00184 /* From EdgesToPS.c: */
00185 
00186 extern VBoolean VEdgesToPS (
00187 #if NeedFunctionPrototypes
00188     FILE *              /* f */,
00189     VEdges              /* edge_set */,
00190     VBooleanPromoted    /* endpoints */
00191 #endif
00192 );
00193 
00194 /* From Link.c: */
00195 
00196 extern VEdges VLinkImage (
00197 #if NeedFunctionPrototypes
00198     VImage              /* image */,
00199     int                 /* low */,
00200     int                 /* high */,
00201     int                 /* minlength */
00202 #endif
00203 );
00204 
00205 /* From SegEdges.c: */
00206 
00207 extern VEdges VSegEdgesIntoLines (
00208 #if NeedFunctionPrototypes
00209     VEdges              /* edge_set */,
00210     double              /* accuracy */,
00211     int                 /* granularity */,
00212     double              /* magnitude */,
00213     int                 /* product */
00214 #endif
00215 );
00216 
00217 #ifdef __cplusplus
00218 }
00219 #endif
00220 
00221 #endif /* V_VEdges_h */