00001 /* 00002 ** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008) 00003 ** Copyright (C) [dates of first publication] Silicon Graphics, Inc. 00004 ** All Rights Reserved. 00005 ** 00006 ** Permission is hereby granted, free of charge, to any person obtaining a copy 00007 ** of this software and associated documentation files (the "Software"), to deal 00008 ** in the Software without restriction, including without limitation the rights 00009 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 00010 ** of the Software, and to permit persons to whom the Software is furnished to do so, 00011 ** subject to the following conditions: 00012 ** 00013 ** The above copyright notice including the dates of first publication and either this 00014 ** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be 00015 ** included in all copies or substantial portions of the Software. 00016 ** 00017 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 00018 ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00019 ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC. 00020 ** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00021 ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 00022 ** OR OTHER DEALINGS IN THE SOFTWARE. 00023 ** 00024 ** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not 00025 ** be used in advertising or otherwise to promote the sale, use or other dealings in 00026 ** this Software without prior written authorization from Silicon Graphics, Inc. 00027 */ 00028 /* 00029 ** Author: Eric Veach, July 1994. 00030 */ 00031 00032 #ifndef GEOM_H 00033 #define GEOM_H 00034 00035 #include "mesh.h" 00036 00037 #ifdef NO_BRANCH_CONDITIONS 00038 /* MIPS architecture has special instructions to evaluate boolean 00039 * conditions -- more efficient than branching, IF you can get the 00040 * compiler to generate the right instructions (SGI compiler doesn't) 00041 */ 00042 #define VertEq(u,v) (((u)->s == (v)->s) & ((u)->t == (v)->t)) 00043 #define VertLeq(u,v) (((u)->s < (v)->s) | \ 00044 ((u)->s == (v)->s & (u)->t <= (v)->t)) 00045 #else 00046 #define VertEq(u,v) ((u)->s == (v)->s && (u)->t == (v)->t) 00047 #define VertLeq(u,v) (((u)->s < (v)->s) || ((u)->s == (v)->s && (u)->t <= (v)->t)) 00048 #endif 00049 00050 #define EdgeEval(u,v,w) tesedgeEval(u,v,w) 00051 #define EdgeSign(u,v,w) tesedgeSign(u,v,w) 00052 00053 /* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */ 00054 00055 #define TransLeq(u,v) (((u)->t < (v)->t) || ((u)->t == (v)->t && (u)->s <= (v)->s)) 00056 #define TransEval(u,v,w) testransEval(u,v,w) 00057 #define TransSign(u,v,w) testransSign(u,v,w) 00058 00059 00060 #define EdgeGoesLeft(e) VertLeq( (e)->Dst, (e)->Org ) 00061 #define EdgeGoesRight(e) VertLeq( (e)->Org, (e)->Dst ) 00062 00063 #define ABS(x) ((x) < 0 ? -(x) : (x)) 00064 #define VertL1dist(u,v) (ABS(u->s - v->s) + ABS(u->t - v->t)) 00065 00066 #define VertCCW(u,v,w) tesvertCCW(u,v,w) 00067 00068 int tesvertLeq( TESSvertex *u, TESSvertex *v ); 00069 TESSreal tesedgeEval( TESSvertex *u, TESSvertex *v, TESSvertex *w ); 00070 TESSreal tesedgeSign( TESSvertex *u, TESSvertex *v, TESSvertex *w ); 00071 TESSreal testransEval( TESSvertex *u, TESSvertex *v, TESSvertex *w ); 00072 TESSreal testransSign( TESSvertex *u, TESSvertex *v, TESSvertex *w ); 00073 int tesvertCCW( TESSvertex *u, TESSvertex *v, TESSvertex *w ); 00074 void tesedgeIntersect( TESSvertex *o1, TESSvertex *d1, TESSvertex *o2, TESSvertex *d2, TESSvertex *v ); 00075 00076 #endif