Back to index

tetex-bin  3.0
regions.h
Go to the documentation of this file.
00001 /* $XConsortium: regions.h,v 1.2 91/10/10 11:19:06 rws Exp $ */
00002 /* Copyright International Business Machines, Corp. 1991
00003  * All Rights Reserved
00004  * Copyright Lexmark International, Inc. 1991
00005  * All Rights Reserved
00006  *
00007  * License to use, copy, modify, and distribute this software and its
00008  * documentation for any purpose and without fee is hereby granted,
00009  * provided that the above copyright notice appear in all copies and that
00010  * both that copyright notice and this permission notice appear in
00011  * supporting documentation, and that the name of IBM or Lexmark not be
00012  * used in advertising or publicity pertaining to distribution of the
00013  * software without specific, written prior permission.
00014  *
00015  * IBM AND LEXMARK PROVIDE THIS SOFTWARE "AS IS", WITHOUT ANY WARRANTIES OF
00016  * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO ANY
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
00018  * AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.  THE ENTIRE RISK AS TO THE
00019  * QUALITY AND PERFORMANCE OF THE SOFTWARE, INCLUDING ANY DUTY TO SUPPORT
00020  * OR MAINTAIN, BELONGS TO THE LICENSEE.  SHOULD ANY PORTION OF THE
00021  * SOFTWARE PROVE DEFECTIVE, THE LICENSEE (NOT IBM OR LEXMARK) ASSUMES THE
00022  * ENTIRE COST OF ALL SERVICING, REPAIR AND CORRECTION.  IN NO EVENT SHALL
00023  * IBM OR LEXMARK BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
00024  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00025  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00026  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
00027  * THIS SOFTWARE.
00028  */
00029 /*SHARED*/
00030  
00031 
00032 #define   Interior(p,rule)        t1_Interior(p,rule)
00033 #define   Union(a1,a2)            t1_Union(a1,a2)
00034 #define   Intersect(a1,a2)        t1_Intersect(a1,a2)
00035 #define   Complement(area)        t1_Complement(area)
00036 #define   Overlap(a1,a2)          t1_OverLap(a1,a2)
00037  
00038 struct region *t1_Interior(); /* returns the interior of a closed path        */
00039 struct region *t1_Union();   /* set union of paths or regions                */
00040 struct region *t1_Intersect();  /* set intersection of regions                */
00041 struct region *t1_Complement();  /* complement of a region                    */
00042 int t1_Overlap();             /* returns a Boolean; TRUE if regions overlap   */
00043  
00044 
00045 /*END SHARED*/
00046 /*SHARED*/
00047  
00048 #define   ChangeDirection(type,R,x,y,dy,x2,y2)  t1_ChangeDirection(type,R,x,y,dy,x2,y2)
00049  
00050 void t1_ChangeDirection();    /* called when we change direction in Y         */
00051 #define   CD_FIRST         -1  /* enumeration of ChangeDirection type       */
00052 #define   CD_CONTINUE       0  /* enumeration of ChangeDirection type        */
00053 #define   CD_LAST           1  /* enumeration of ChangeDirection type        */
00054  
00055 #define    MoreWorkArea(R,x1,y1,x2,y2)     t1_MoreWorkArea(R,x1,y1,x2,y2)
00056 #define    KillRegion(area)   t1_KillRegion(area)
00057 #define    CopyRegion(area)   t1_CopyRegion(area)
00058 #define    BoxClip(R,xmin,ymin,xmax,ymax)  t1_BoxClip(R,xmin,ymin,xmax,ymax)
00059 #define    SortSwath(a,p,f)   t1_SortSwath(a,p,f)
00060 #define    SwathUnion(b,e)    t1_SwathUnion(b,e)
00061 #define    RegionBounds(r)    t1_RegionBounds(r)
00062 #define    CoerceRegion(p)    t1_CoerceRegion(p)
00063 #define    MoveEdges(R,dx,dy) t1_MoveEdges(R,dx,dy)
00064 #define    UnJumble(R)        t1_UnJumble(R)
00065  
00066 void t1_MoreWorkArea();       /* get longer edge list for stepping            */
00067 struct region *t1_CopyRegion();  /* duplicate a region                       */
00068 void t1_KillRegion();         /* destroy a region                             */
00069 struct region *t1_BoxClip();  /* clip a region to a rectangle                 */
00070 struct edgelist *t1_SortSwath();  /* sort edges onto growing edge list        */
00071 struct edgelist *t1_SwathUnion();  /* 'union' two edges into a swath          */
00072 struct segment *t1_RegionBounds();  /* returns bounding box of a region       */
00073 struct region *t1_CoerceRegion();  /* force text to become a true region      */
00074 void t1_MoveEdges();          /* moves the edge values in a region            */
00075 void t1_UnJumble();           /* sort the edges and reset the jumbled flag    */
00076  
00077 /*END SHARED*/
00078 /*SHARED*/
00079  
00080 #define GOING_TO(R, x1, y1, x2, y2, dy) { \
00081    if (dy < 0) { \
00082       if (R->lastdy >= 0) \
00083           ChangeDirection(CD_CONTINUE, R, x1, y1, dy, x2, y2); \
00084       if (y2 < R->edgeYstop) \
00085           MoreWorkArea(R, x1, y1, x2, y2); \
00086    } \
00087    else if (dy > 0) { \
00088       if (R->lastdy <= 0) \
00089           ChangeDirection(CD_CONTINUE, R, x1, y1, dy, x2, y2); \
00090       if (y2 > R->edgeYstop) \
00091           MoreWorkArea(R, x1, y1, x2, y2); \
00092    } \
00093    else /* dy == 0 */ ChangeDirection(CD_CONTINUE, R, x1, y1, dy, x2, y2); \
00094    if (x2 < R->edgexmin) R->edgexmin = x2; \
00095    else if (x2 > R->edgexmax) R->edgexmax = x2; \
00096 }
00097  
00098  
00099 #define    MINPEL    (-1<<(8*sizeof(pel)-1))  /* smallest value fitting in a pel */
00100 #define    MAXPEL    ((1<<(8*sizeof(pel)-1))-1)/* largest value fitting in a pel */
00101  
00102 /*
00103 The "Unique"-type macro is different (unique?) for regions, because some
00104 regions structures are shared among several objects, and might have
00105 to be made unique for that reason (i.e., references > 1).
00106 */
00107  
00108 #define    ConsumeRegion(R)   MAKECONSUME(R,KillRegion(R))
00109 #define    UniqueRegion(R)    MAKEUNIQUE(R,CopyRegion(R))
00110  
00111  
00112 /*END SHARED*/
00113 /*SHARED*/
00114  
00115 struct region {
00116        XOBJ_COMMON           /* xobject common data define 3-26-91 PNM    */
00117                              /* type = REGIONTYPE                         */
00118        struct fractpoint origin;    /* beginning handle:  X,Y origin of region      */
00119        struct fractpoint ending;    /* ending handle:  X,Y change after painting region */
00120        pel xmin,ymin;        /* minimum X,Y of region                        */
00121        pel xmax,ymax;        /* mat1_mum X,Y of region                        */
00122        struct edgelist *anchor;  /* list of edges that bound the region      */
00123        struct picture *thresholded;  /* region defined by thresholded picture*/
00124 /*
00125 Note that the ending handle and the bounding box values are stored
00126 relative to 'origin'.
00127  
00128 The above elements describe a region.  The following elements are
00129 scratchpad areas used while the region is being built:
00130 */
00131        fractpel lastdy;      /* direction of last segment                    */
00132        fractpel firstx,firsty;    /* starting point of current edge          */
00133        fractpel edgexmin,edgexmax;  /* x extent of current edge              */
00134        struct edgelist *lastedge,*firstedge;  /* last and first edges in subpath */
00135        pel *edge;            /* pointer to array of X values for edge        */
00136        fractpel edgeYstop;   /* Y value where 'edges' array ends             */
00137        int (*newedgefcn)();  /* function to use when building a new edge     */
00138        struct strokeinfo *strokeinfo;  /* scratchpad info during stroking only */
00139 } ;
00140 /*
00141 The ISCOMPLEMENT flag indicates the region is reversed--it is the
00142 "outside" of the nominal region.
00143 */
00144 #define   ISCOMPLEMENT(flag)   ((flag)&0x80)
00145 /*
00146 The ISJUMBLED flag indicates the region is not sorted top-to-bottom.
00147 */
00148 #define   ISJUMBLED(flag)      ((flag)&0x40)
00149 /*
00150 The ISINFINITE flag allows a quick check for an INFINITE region, which
00151 is frequently intersected.
00152 */
00153 #define   ISINFINITE(flag)     ((flag)&0x20)
00154  
00155 /*END SHARED*/
00156 /*SHARED*/
00157  
00158 #define   ISRECTANGULAR(flag)  ((flag)&0x08)
00159  
00160 /*END SHARED*/
00161 /*SHARED*/
00162  
00163 #define  EmptyRegion   t1_EmptyRegion
00164  
00165 /*END SHARED*/
00166 /*SHARED*/
00167  
00168 struct edgelist {
00169   XOBJ_COMMON          /* xobject common data define 3-26-91 PNM        */
00170   /* type = EDGETYPE                               */
00171   struct edgelist *link;  /* pointer to next in linked list             */
00172   struct edgelist *subpath;  /* informational link for "same subpath"   */
00173   pel xmin,xmax;        /* range of edge in X                           */
00174   pel ymin,ymax;        /* range of edge in Y                           */
00175   pel *xvalues;         /* pointer to ymax-ymin X values                */
00176   
00177   fractpel fpx1;        /* Added by RMz, author of t1lib, 2002-08-15.   */
00178   fractpel fpy1;        /* This produces a little memory overhead, but  */
00179   fractpel fpx2;        /* gives the opportunity to take more           */ 
00180   fractpel fpy2;        /* intelligent decisions in ApplyContinuity().  */
00181 } ;
00182 /*
00183 The end of the list is marked by either "link" being NULL, or by
00184 ymin == ymax.  See :hdref refid=discard..  We define the VALIDEDGE
00185 predicate to test for the opposite of these conditions:
00186 */
00187  
00188 #define   VALIDEDGE(p)    ((p)!=NULL&&(p)->ymin<(p)->ymax)
00189  
00190 /*END SHARED*/
00191 /*SHARED*/
00192  
00193 #define   ISDOWN(f)       ((f)&0x80)
00194  
00195 #define   ISAMBIGUOUS(f)  ((f)&0x40)
00196  
00197 /*END SHARED*/
00198 /*SHARED*/
00199  
00200 /*
00201 Interior() rule enumerations:
00202 */
00203 #define   WINDINGRULE -2
00204 #define   EVENODDRULE -3
00205  
00206 #define   CONTINUITY  0x80   /* can be added to above rules; e.g. WINDINGRULE+CONTINUITY */
00207  
00208 /*END SHARED*/