2
0

geom.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. ** SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
  3. ** Copyright (C) [dates of first publication] Silicon Graphics, Inc.
  4. ** All Rights Reserved.
  5. **
  6. ** Permission is hereby granted, free of charge, to any person obtaining a copy
  7. ** of this software and associated documentation files (the "Software"), to deal
  8. ** in the Software without restriction, including without limitation the rights
  9. ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  10. ** of the Software, and to permit persons to whom the Software is furnished to do so,
  11. ** subject to the following conditions:
  12. **
  13. ** The above copyright notice including the dates of first publication and either this
  14. ** permission notice or a reference to http://oss.sgi.com/projects/FreeB/ shall be
  15. ** included in all copies or substantial portions of the Software.
  16. **
  17. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  18. ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
  19. ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON GRAPHICS, INC.
  20. ** BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  21. ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
  22. ** OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ** Except as contained in this notice, the name of Silicon Graphics, Inc. shall not
  25. ** be used in advertising or otherwise to promote the sale, use or other dealings in
  26. ** this Software without prior written authorization from Silicon Graphics, Inc.
  27. */
  28. /*
  29. ** Author: Eric Veach, July 1994.
  30. */
  31. #ifndef GEOM_H
  32. #define GEOM_H
  33. #include "mesh.h"
  34. #ifdef NO_BRANCH_CONDITIONS
  35. /* MIPS architecture has special instructions to evaluate boolean
  36. * conditions -- more efficient than branching, IF you can get the
  37. * compiler to generate the right instructions (SGI compiler doesn't)
  38. */
  39. #define VertEq(u,v) (((u)->s == (v)->s) & ((u)->t == (v)->t))
  40. #define VertLeq(u,v) (((u)->s < (v)->s) | \
  41. ((u)->s == (v)->s & (u)->t <= (v)->t))
  42. #else
  43. #define VertEq(u,v) ((u)->s == (v)->s && (u)->t == (v)->t)
  44. #define VertLeq(u,v) (((u)->s < (v)->s) || ((u)->s == (v)->s && (u)->t <= (v)->t))
  45. #endif
  46. #define EdgeEval(u,v,w) tesedgeEval(u,v,w)
  47. #define EdgeSign(u,v,w) tesedgeSign(u,v,w)
  48. /* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
  49. #define TransLeq(u,v) (((u)->t < (v)->t) || ((u)->t == (v)->t && (u)->s <= (v)->s))
  50. #define TransEval(u,v,w) testransEval(u,v,w)
  51. #define TransSign(u,v,w) testransSign(u,v,w)
  52. #define EdgeGoesLeft(e) VertLeq( (e)->Dst, (e)->Org )
  53. #define EdgeGoesRight(e) VertLeq( (e)->Org, (e)->Dst )
  54. #define ABS(x) ((x) < 0 ? -(x) : (x))
  55. #define VertL1dist(u,v) (ABS(u->s - v->s) + ABS(u->t - v->t))
  56. #define VertCCW(u,v,w) tesvertCCW(u,v,w)
  57. int tesvertLeq( TESSvertex *u, TESSvertex *v );
  58. TESSreal tesedgeEval( TESSvertex *u, TESSvertex *v, TESSvertex *w );
  59. TESSreal tesedgeSign( TESSvertex *u, TESSvertex *v, TESSvertex *w );
  60. TESSreal testransEval( TESSvertex *u, TESSvertex *v, TESSvertex *w );
  61. TESSreal testransSign( TESSvertex *u, TESSvertex *v, TESSvertex *w );
  62. int tesvertCCW( TESSvertex *u, TESSvertex *v, TESSvertex *w );
  63. void tesedgeIntersect( TESSvertex *o1, TESSvertex *d1, TESSvertex *o2, TESSvertex *d2, TESSvertex *v );
  64. #endif