home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / warphead.zip / H / POLYCLIP.H < prev    next >
C/C++ Source or Header  |  1997-02-28  |  4KB  |  106 lines

  1. /* @(#)Z 1.5 com/src/imaging/polyclip/PolyClip.h, odimaging, od96os2, odos29646d 96/11/15 15:25:09 (96/10/29 09:26:51) */
  2. /*====START_GENERATED_PROLOG======================================
  3.  */
  4. /*
  5.  *   COMPONENT_NAME: odimaging
  6.  *
  7.  *   CLASSES: none
  8.  *
  9.  *   ORIGINS: 82,27
  10.  *
  11.  *
  12.  *   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  13.  *   All Rights Reserved
  14.  *   Licensed Materials - Property of IBM
  15.  *   US Government Users Restricted Rights - Use, duplication or
  16.  *   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  17.  *       
  18.  *   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  19.  *   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  20.  *   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21.  *   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22.  *   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23.  *   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  24.  *   OR PERFORMANCE OF THIS SOFTWARE.
  25.  */
  26. /*====END_GENERATED_PROLOG========================================
  27.  */
  28.  
  29. /*
  30.   File:    PolyClip.h
  31.  
  32.   Contains:  The polygon clipper! Performs intersection, union, difference.
  33.  
  34.   Written by:  Jens Alfke (based on algorithm by A. C. Kilgour)
  35.  
  36.   Copyright:  ⌐ 1994 by Apple Computer, Inc., all rights reserved.
  37.  
  38.   Change History (most recent first):
  39.   
  40.      <3>  10/24/94  jpa    Added PolyOutset. [1186719]
  41.      <2>    9/9/94  jpa    Added kShapeOutset (not yet implemented...)
  42.                   [1178690]
  43.      <1>   6/15/94  jpa    first checked in
  44.      ---------------------------Moved to ODSOM project.
  45.      <1>    5/9/94  jpa    first checked in
  46.   
  47.   Theory Of Operation:
  48.     PolyClip( ) performs Boolean operations on any number of polygons.
  49.     Pass the number of polygons, an array of pointers to them, and the
  50.     operation you want performed:
  51.      kShapeIntersection computes the intersection of all the polygons.
  52.      kShapeUnion computes the union of all the polygons.
  53.      kShapeDifference subtracts all the other polygons from the first.
  54.     
  55.     PolySimplify( ) "simplifies" an input polygon by removing all
  56.     overlaps or self-intersections. F'rinstance, given a pentagram it
  57.     would return a five-pointed star. (This actually just calls
  58.     PolyClip with nPolys=1 and op=kShapeUnion.)
  59.     
  60.     PolyOutset( ) outsets the vertices of a polygon by a given distance,
  61.     or insets them if the distance is negative. The result may need
  62.     simplification, since parts of contours may flip over. The function
  63.     returns True if additional simplification may be needed.
  64.     
  65.     ** PolyClip is _not_ guaranteed to operate properly on self-
  66.     intersecting input polygons for operations other than union.
  67.     If this is a problem, just simplify the inputs beforehand.
  68.     
  69.     ** PolyClip uses winding-rule containment. This means that input
  70.     vertices must be ordered such that positive contours go clockwise
  71.     and holes go counterclockwise, as viewed in a coordinate system
  72.     where the positive Y axis extends downward (i.e. in the Macintosh
  73.     coordinate system, but not that of PostScript or traditional
  74.     computer graphics.)
  75. */
  76.  
  77.  
  78. #ifndef _POLYCLIP_
  79. #define _POLYCLIP_
  80.  
  81. #ifndef _ODTYPES_
  82. #include "ODTypes.h"
  83. #endif
  84.  
  85.  
  86. typedef enum {
  87.   kShapeIntersection,
  88.   kShapeUnion,
  89.   kShapeDifference,
  90.   
  91.   // For use internally by ODShape: do not pass to PolyClip:
  92.   kShapeOutset,
  93.   kShapeNoOp = -1
  94. } ODShapeOp; 
  95.  
  96.  
  97. void    PolyClip( ODSLong nPolys, const ODPolygon* polys[], ODShapeOp op, ODPolygon &result );
  98. void    PolySimplify( ODPolygon &dstPoly, const ODPolygon &srcPoly );
  99. // It's okay to use the same ODPolygon for input and output.
  100.  
  101. ODBoolean  PolyOutset( ODPolygon &poly, ODCoordinate distance );  // True if needs simplifying
  102.  
  103. #endif /*_POLYCLIP_*/
  104.  
  105.  
  106.