gpc.h

00001 /*
00002 ===========================================================================
00003 
00004 Project:   Generic Polygon Clipper
00005 
00006            A new algorithm for calculating the difference, intersection,
00007            exclusive-or or union of arbitrary polygon sets.
00008 
00009 File:      gpc.h
00010 Author:    Alan Murta (email: gpc@cs.man.ac.uk)
00011 Version:   2.32
00012 Date:      17th December 2004
00013 
00014 Copyright: (C) Advanced Interfaces Group,
00015            University of Manchester.
00016 
00017            This software is free for non-commercial use. It may be copied,
00018            modified, and redistributed provided that this copyright notice
00019            is preserved on all copies. The intellectual property rights of
00020            the algorithms used reside with the University of Manchester
00021            Advanced Interfaces Group.
00022 
00023            You may not use this software, in whole or in part, in support
00024            of any commercial product without the express consent of the
00025            author.
00026 
00027            There is no warranty or other guarantee of fitness of this
00028            software for any purpose. It is provided solely "as is".
00029 
00030 ===========================================================================
00031 */
00032 
00033 #ifndef __gpc_h
00034 #define __gpc_h
00035 
00036 #include <stdio.h>
00037 
00038 
00039 /*
00040 ===========================================================================
00041                                Constants
00042 ===========================================================================
00043 */
00044 
00045 /* Increase GPC_EPSILON to encourage merging of near coincident edges    */
00046 
00047 #define GPC_EPSILON (DBL_EPSILON)
00048 
00049 #define GPC_VERSION "2.32"
00050 
00051 
00052 /*
00053 ===========================================================================
00054                            Public Data Types
00055 ===========================================================================
00056 */
00057 
00058 typedef enum                        /* Set operation type                */
00059 {
00060   GPC_DIFF,                         /* Difference                        */
00061   GPC_INT,                          /* Intersection                      */
00062   GPC_XOR,                          /* Exclusive or                      */
00063   GPC_UNION                         /* Union                             */
00064 } gpc_op;
00065 
00066 typedef struct                      /* Polygon vertex structure          */
00067 {
00068   double              x;            /* Vertex x component                */
00069   double              y;            /* vertex y component                */
00070 } gpc_vertex;
00071 
00072 typedef struct                      /* Vertex list structure             */
00073 {
00074   int                 num_vertices; /* Number of vertices in list        */
00075   gpc_vertex         *vertex;       /* Vertex array pointer              */
00076 } gpc_vertex_list;
00077 
00078 typedef struct                      /* Polygon set structure             */
00079 {
00080   int                 num_contours; /* Number of contours in polygon     */
00081   int                *hole;         /* Hole / external contour flags     */
00082   gpc_vertex_list    *contour;      /* Contour array pointer             */
00083 } gpc_polygon;
00084 
00085 typedef struct                      /* Tristrip set structure            */
00086 {
00087   int                 num_strips;   /* Number of tristrips               */
00088   gpc_vertex_list    *strip;        /* Tristrip array pointer            */
00089 } gpc_tristrip;
00090 
00091 
00092 /*
00093 ===========================================================================
00094                        Public Function Prototypes
00095 ===========================================================================
00096 */
00097 
00098 void gpc_read_polygon        (FILE            *infile_ptr, 
00099                               int              read_hole_flags,
00100                               gpc_polygon     *polygon);
00101 
00102 void gpc_write_polygon       (FILE            *outfile_ptr,
00103                               int              write_hole_flags,
00104                               gpc_polygon     *polygon);
00105 
00106 void gpc_add_contour         (gpc_polygon     *polygon,
00107                               gpc_vertex_list *contour,
00108                               int              hole);
00109 
00110 void gpc_polygon_clip        (gpc_op           set_operation,
00111                               gpc_polygon     *subject_polygon,
00112                               gpc_polygon     *clip_polygon,
00113                               gpc_polygon     *result_polygon);
00114 
00115 void gpc_tristrip_clip       (gpc_op           set_operation,
00116                               gpc_polygon     *subject_polygon,
00117                               gpc_polygon     *clip_polygon,
00118                               gpc_tristrip    *result_tristrip);
00119 
00120 void gpc_polygon_to_tristrip (gpc_polygon     *polygon,
00121                               gpc_tristrip    *tristrip);
00122 
00123 void gpc_free_polygon        (gpc_polygon     *polygon);
00124 
00125 void gpc_free_tristrip       (gpc_tristrip    *tristrip);
00126 
00127 #endif
00128 
00129 /*
00130 ===========================================================================
00131                            End of file: gpc.h
00132 ===========================================================================
00133 */

Generated on Tue Feb 10 10:01:29 2009 for imaging2 by  doxygen 1.5.5