tri.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*************************************************************************
  2. * Copyright (c) 2011 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #include <stdbool.h>
  11. #include <stddef.h>
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include <pathgeom.h>
  16. #ifdef GVDLL
  17. #ifdef PATHPLAN_EXPORTS
  18. #define TRI_API __declspec(dllexport)
  19. #else
  20. #define TRI_API __declspec(dllimport)
  21. #endif
  22. #endif
  23. #ifndef TRI_API
  24. #define TRI_API /* nothing */
  25. #endif
  26. /* Points in polygon must be in CCW order */
  27. TRI_API int Ptriangulate(Ppoly_t *polygon,
  28. void (*fn)(void *closure, const Ppoint_t tri[]),
  29. void *vc);
  30. #undef TRI_API
  31. /// return value from `ccw`
  32. enum {
  33. ISCCW = 1, ///< counter-clockwise
  34. ISCW = 2, ///< clockwise
  35. ISON = 3, ///< co-linear
  36. };
  37. /// are the given points counter-clockwise, clockwise, or co-linear?
  38. int ccw(Ppoint_t p1, Ppoint_t p2, Ppoint_t p3);
  39. /// is pb between pa and pc?
  40. bool between(Ppoint_t pa, Ppoint_t pb, Ppoint_t pc);
  41. /// line to line intersection
  42. bool intersects(Ppoint_t pa, Ppoint_t pb, Ppoint_t pc, Ppoint_t pd);
  43. typedef Ppoint_t (*indexer_t)(void *base, size_t index);
  44. /// is (i, i + 2) a diagonal?
  45. bool isdiagonal(size_t i, size_t ip2, void *pointp, size_t pointn,
  46. indexer_t indexer);
  47. #ifdef __cplusplus
  48. }
  49. #endif