/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/common/geom.h

Go to the documentation of this file.
00001 /* $Id: geom.h,v 1.10 2007/12/27 20:13:13 ellson Exp $ $Revision: 1.10 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 /* geometric types and macros (e.g. points and boxes) with application to, but
00018  * no specific dependance on graphs */
00019 
00020 #ifndef GV_GEOM_H
00021 #define GV_GEOM_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include "arith.h"
00025 #endif
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030     
00031 typedef struct { int x, y; } point;
00032 
00033 typedef struct pointf_s { double x, y; } pointf;
00034 
00035 /* tell pathplan/pathgeom.h */
00036 #define HAVE_POINTF_S
00037 
00038 typedef struct { point LL, UR; } box;
00039 
00040 typedef struct { pointf LL, UR; } boxf;
00041 
00042 #ifdef HAVE_CONFIG_H
00043 /* true if point p is inside box b */
00044 #define INSIDE(p,b)     (BETWEEN((b).LL.x,(p).x,(b).UR.x) && BETWEEN((b).LL.y,(p).y,(b).UR.y))
00045 /* true if boxes b0 and b1 overlap */
00046 #define OVERLAP(b0,b1)  (((b0).UR.x >= (b1).LL.x) && ((b1).UR.x >= (b0).LL.x) && ((b0).UR.y >= (b1).LL.y) && ((b1).UR.y >= (b0).LL.y))
00047 /* true if box b0 completely contains b1*/
00048 #define CONTAINS(b0,b1) (((b0).UR.x >= (b1).UR.x) && ((b0).UR.y >= (b1).UR.y) && ((b0).LL.x <= (b1).LL.x) && ((b0).LL.y <= (b1).LL.y))
00049 
00050 /* expand box b as needed to enclose point p */
00051 #define EXPANDBP(b, p)  (b.LL.x = MIN(b.LL.x, p.x), b.LL.y = MIN(b.LL.y, p.y), b.UR.x = MAX(b.UR.x, p.x), b.UR.y = MAX(b.UR.y, p.y))
00052 /* expand box b0 as needed to enclose box b1 */
00053 #define EXPANDBB(b0, b1) (b0.LL.x = MIN(b0.LL.x, b1.LL.x), b0.LL.y = MIN(b0.LL.y, b1.LL.y), b0.UR.x = MAX(b0.UR.x, b1.UR.x), b0.UR.y = MAX(b0.UR.y, b1.UR.y))
00054 /* clip box b0 to fit box b1 */
00055 #define CLIPBB(b0, b1) (b0.LL.x = MAX(b0.LL.x, b1.LL.x), b0.LL.y = MAX(b0.LL.y, b1.LL.y), b0.UR.x = MIN(b0.UR.x, b1.UR.x), b0.UR.y = MIN(b0.UR.y, b1.UR.y))
00056 
00057 #define DIST2(p1,p2) (SQR((p1.x) - (p2.x))) + (SQR((p1.y) - (p2.y)))
00058 #define DIST(p1,p2) (sqrt(DIST2((p1),(p2))))
00059 
00060 #define POINTS_PER_INCH 72
00061 #define POINTS_PER_PC ((double)POINTS_PER_INCH / 6)
00062 #define POINTS_PER_CM ((double)POINTS_PER_INCH * 0.393700787)
00063 #define POINTS_PER_MM ((double)POINTS_PER_INCH * 0.0393700787)
00064 
00065 #define POINTS(f_inch)  (ROUND((f_inch)*POINTS_PER_INCH))
00066 #define PS2INCH(ps)             ((ps)/(double)POINTS_PER_INCH)
00067 
00068 #define P2PF(p, pf) (pf.x = p.x, pf.y = p.y)
00069 #define PF2P(pf, p) (p.x = ROUND (pf.x), p.y = ROUND (pf.y))
00070 #define B2BF(b, bf) (bf.LL.x = b.LL.x, bf.LL.y = b.LL.y, bf.UR.x = b.UR.x, bf.UR.y = b.UR.y)
00071 #define BF2B(bf, b) (b.LL.x = ROUND (bf.LL.x), b.LL.y = ROUND (bf.LL.y), b.UR.x = ROUND (bf.UR.x), b.UR.y = ROUND (bf.UR.y))
00072 
00073 #endif
00074 
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078 
00079 #endif

Generated on Mon Mar 31 19:03:24 2008 for Graphviz by  doxygen 1.5.1