core/vgl/internals/gpc.h
Go to the documentation of this file.
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) 1997-2004, 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 /* For example: #define GPC_EPSILON (DBL_EPSILON*1000000000)             */
00048 #define GPC_EPSILON (DBL_EPSILON)
00049 
00050 #define GPC_VERSION "2.32"
00051 
00052 
00053 /*
00054 ===========================================================================
00055                            Public Data Types
00056 ===========================================================================
00057 */
00058 #ifdef __cplusplus
00059 extern "C" {
00060 #endif
00061 
00062 typedef enum                        /* Set operation type                */
00063 {
00064   GPC_DIFF,                         /* Difference                        */
00065   GPC_INT,                          /* Intersection                      */
00066   GPC_XOR,                          /* Exclusive or                      */
00067   GPC_UNION                         /* Union                             */
00068 } gpc_op;
00069 
00070 typedef struct                      /* Polygon vertex structure          */
00071 {
00072   double              x;            /* Vertex x component                */
00073   double              y;            /* vertex y component                */
00074 } gpc_vertex;
00075 
00076 typedef struct                      /* Vertex list structure             */
00077 {
00078   int                 num_vertices; /* Number of vertices in list        */
00079   gpc_vertex         *vertex;       /* Vertex array pointer              */
00080 } gpc_vertex_list;
00081 
00082 typedef struct                      /* Polygon set structure             */
00083 {
00084   int                 num_contours; /* Number of contours in polygon     */
00085   int                *hole;         /* Hole / external contour flags     */
00086   gpc_vertex_list    *contour;      /* Contour array pointer             */
00087 } gpc_polygon;
00088 
00089 typedef struct                      /* Tristrip set structure            */
00090 {
00091   int                 num_strips;   /* Number of tristrips               */
00092   gpc_vertex_list    *strip;        /* Tristrip array pointer            */
00093 } gpc_tristrip;
00094 
00095 
00096 /*
00097 ===========================================================================
00098                        Public Function Prototypes
00099 ===========================================================================
00100 */
00101 
00102 int  gpc_polygon_clip        (gpc_op           set_operation,
00103                               gpc_polygon     *subject_polygon,
00104                               gpc_polygon     *clip_polygon,
00105                               gpc_polygon     *result_polygon);
00106 
00107 void gpc_free_polygon        (gpc_polygon     *polygon);
00108 
00109 #if 0 /* These functions are not used in vgl_clip */ 
00110 
00111 void gpc_read_polygon        (FILE            *infile_ptr, 
00112                               int              read_hole_flags,
00113                               gpc_polygon     *polygon);
00114 
00115 void gpc_write_polygon       (FILE            *outfile_ptr,
00116                               int              write_hole_flags,
00117                               gpc_polygon     *polygon);
00118 
00119 void gpc_add_contour         (gpc_polygon     *polygon,
00120                               gpc_vertex_list *contour,
00121                               int              hole);
00122 
00123 void gpc_tristrip_clip       (gpc_op           set_operation,
00124                               gpc_polygon     *subject_polygon,
00125                               gpc_polygon     *clip_polygon,
00126                               gpc_tristrip    *result_tristrip);
00127 
00128 void gpc_polygon_to_tristrip (gpc_polygon     *polygon,
00129                               gpc_tristrip    *tristrip);
00130 
00131 void gpc_free_tristrip       (gpc_tristrip    *tristrip);
00132 
00133 #endif /* 0 */
00134 
00135 #ifdef __cplusplus
00136 }
00137 #endif
00138 
00139 #endif /* gpc_h_ */
00140 
00141 /*
00142 ===========================================================================
00143                            End of file: gpc.h
00144 ===========================================================================
00145 */