lib/psPoly.c

Go to the documentation of this file.
00001 /* psPoly - two dimensional polygon. */
00002 #include "common.h"
00003 #include "psPoly.h"
00004 
00005 struct psPoly *psPolyNew()
00006 /* Create new (empty) polygon */
00007 {
00008 struct psPoly *poly;
00009 AllocVar(poly);
00010 return poly;
00011 }
00012 
00013 void psPolyFree(struct psPoly **pPoly)
00014 /* Free up resources associated with polygon */
00015 {
00016 struct psPoly *poly = *pPoly;
00017 if (poly != NULL)
00018     {
00019     if (poly->lastPoint != NULL)
00020         {
00021         poly->lastPoint->next = NULL;
00022         slFreeList(&poly->ptList);
00023         }
00024     freez(pPoly);
00025     }
00026 }
00027 
00028 void psPolyAddPoint(struct psPoly *poly, double x, double y)
00029 /* Add point to polygon. */
00030 {
00031 struct psPoint *pt;
00032 poly->ptCount += 1;
00033 AllocVar(pt);
00034 pt->x = x;
00035 pt->y = y;
00036 if (poly->ptList == NULL)
00037     {
00038     poly->ptList = poly->lastPoint = pt;
00039     pt->next = pt;
00040     }
00041 else
00042     {
00043     poly->lastPoint->next = pt;
00044     pt->next = poly->ptList;
00045     poly->lastPoint = pt;
00046     }
00047 }
00048 

Generated on Tue Dec 25 18:39:31 2007 for blat by  doxygen 1.5.2