poly_r.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /*<html><pre> -<a href="qh-poly_r.htm"
  2. >-------------------------------</a><a name="TOP">-</a>
  3. poly_r.h
  4. header file for poly_r.c and poly2_r.c
  5. see qh-poly_r.htm, libqhull_r.h and poly_r.c
  6. Copyright (c) 1993-2020 The Geometry Center.
  7. $Id: //main/2019/qhull/src/libqhull_r/poly_r.h#5 $$Change: 2963 $
  8. $DateTime: 2020/06/03 19:31:01 $$Author: bbarber $
  9. */
  10. #ifndef qhDEFpoly
  11. #define qhDEFpoly 1
  12. #include "libqhull_r.h"
  13. /*=============== constants ========================== */
  14. /*-<a href="qh-geom_r.htm#TOC"
  15. >--------------------------------</a><a name="ALGORITHMfault">-</a>
  16. qh_ALGORITHMfault
  17. use as argument to checkconvex() to report errors during buildhull
  18. */
  19. #define qh_ALGORITHMfault 0
  20. /*-<a href="qh-poly_r.htm#TOC"
  21. >--------------------------------</a><a name="DATAfault">-</a>
  22. qh_DATAfault
  23. use as argument to checkconvex() to report errors during initialhull
  24. */
  25. #define qh_DATAfault 1
  26. /*-<a href="qh-poly_r.htm#TOC"
  27. >--------------------------------</a><a name="DUPLICATEridge">-</a>
  28. qh_DUPLICATEridge
  29. special value for facet->neighbor to indicate a duplicate ridge
  30. notes:
  31. set by qh_matchneighbor for qh_matchdupridge
  32. */
  33. #define qh_DUPLICATEridge (facetT *)1L
  34. /*-<a href="qh-poly_r.htm#TOC"
  35. >--------------------------------</a><a name="MERGEridge">-</a>
  36. qh_MERGEridge flag in facet
  37. special value for facet->neighbor to indicate a duplicate ridge that needs merging
  38. notes:
  39. set by qh_matchnewfacets..qh_matchdupridge from qh_DUPLICATEridge
  40. used by qh_mark_dupridges to set facet->mergeridge, facet->mergeridge2 from facet->dupridge
  41. */
  42. #define qh_MERGEridge (facetT *)2L
  43. /*============ -structures- ====================*/
  44. /*=========== -macros- =========================*/
  45. /*-<a href="qh-poly_r.htm#TOC"
  46. >--------------------------------</a><a name="FORALLfacet_">-</a>
  47. FORALLfacet_( facetlist ) { ... }
  48. assign 'facet' to each facet in facetlist
  49. notes:
  50. uses 'facetT *facet;'
  51. assumes last facet is a sentinel
  52. see:
  53. FORALLfacets
  54. */
  55. #define FORALLfacet_( facetlist ) if (facetlist) for ( facet=(facetlist); facet && facet->next; facet= facet->next )
  56. /*-<a href="qh-poly_r.htm#TOC"
  57. >--------------------------------</a><a name="FORALLnew_facets">-</a>
  58. FORALLnew_facets { ... }
  59. assign 'newfacet' to each facet in qh.newfacet_list
  60. notes:
  61. uses 'facetT *newfacet;'
  62. at exit, newfacet==NULL
  63. */
  64. #define FORALLnew_facets for ( newfacet=qh->newfacet_list; newfacet && newfacet->next; newfacet=newfacet->next )
  65. /*-<a href="qh-poly_r.htm#TOC"
  66. >--------------------------------</a><a name="FORALLvertex_">-</a>
  67. FORALLvertex_( vertexlist ) { ... }
  68. assign 'vertex' to each vertex in vertexlist
  69. notes:
  70. uses 'vertexT *vertex;'
  71. at exit, vertex==NULL
  72. */
  73. #define FORALLvertex_( vertexlist ) for (vertex=( vertexlist );vertex && vertex->next;vertex= vertex->next )
  74. /*-<a href="qh-poly_r.htm#TOC"
  75. >--------------------------------</a><a name="FORALLvisible_facets">-</a>
  76. FORALLvisible_facets { ... }
  77. assign 'visible' to each visible facet in qh.visible_list
  78. notes:
  79. uses 'vacetT *visible;'
  80. at exit, visible==NULL
  81. */
  82. #define FORALLvisible_facets for (visible=qh->visible_list; visible && visible->visible; visible= visible->next)
  83. /*-<a href="qh-poly_r.htm#TOC"
  84. >--------------------------------</a><a name="FORALLsame_">-</a>
  85. FORALLsame_( newfacet ) { ... }
  86. assign 'same' to each facet in newfacet->f.samecycle
  87. notes:
  88. uses 'facetT *same;'
  89. stops when it returns to newfacet
  90. */
  91. #define FORALLsame_(newfacet) for (same= newfacet->f.samecycle; same != newfacet; same= same->f.samecycle)
  92. /*-<a href="qh-poly_r.htm#TOC"
  93. >--------------------------------</a><a name="FORALLsame_cycle_">-</a>
  94. FORALLsame_cycle_( newfacet ) { ... }
  95. assign 'same' to each facet in newfacet->f.samecycle
  96. notes:
  97. uses 'facetT *same;'
  98. at exit, same == NULL
  99. */
  100. #define FORALLsame_cycle_(newfacet) \
  101. for (same= newfacet->f.samecycle; \
  102. same; same= (same == newfacet ? NULL : same->f.samecycle))
  103. /*-<a href="qh-poly_r.htm#TOC"
  104. >--------------------------------</a><a name="FOREACHneighborA_">-</a>
  105. FOREACHneighborA_( facet ) { ... }
  106. assign 'neighborA' to each neighbor in facet->neighbors
  107. FOREACHneighborA_( vertex ) { ... }
  108. assign 'neighborA' to each neighbor in vertex->neighbors
  109. declare:
  110. facetT *neighborA, **neighborAp;
  111. see:
  112. <a href="qset_r.h#FOREACHsetelement_">FOREACHsetelement_</a>
  113. */
  114. #define FOREACHneighborA_(facet) FOREACHsetelement_(facetT, facet->neighbors, neighborA)
  115. /*-<a href="qh-poly_r.htm#TOC"
  116. >--------------------------------</a><a name="FOREACHvisible_">-</a>
  117. FOREACHvisible_( facets ) { ... }
  118. assign 'visible' to each facet in facets
  119. notes:
  120. uses 'facetT *facet, *facetp;'
  121. see <a href="qset_r.h#FOREACHsetelement_">FOREACHsetelement_</a>
  122. */
  123. #define FOREACHvisible_(facets) FOREACHsetelement_(facetT, facets, visible)
  124. /*-<a href="qh-poly_r.htm#TOC"
  125. >--------------------------------</a><a name="FOREACHnewfacet_">-</a>
  126. FOREACHnewfacet_( facets ) { ... }
  127. assign 'newfacet' to each facet in facets
  128. notes:
  129. uses 'facetT *newfacet, *newfacetp;'
  130. see <a href="qset_r.h#FOREACHsetelement_">FOREACHsetelement_</a>
  131. */
  132. #define FOREACHnewfacet_(facets) FOREACHsetelement_(facetT, facets, newfacet)
  133. /*-<a href="qh-poly_r.htm#TOC"
  134. >--------------------------------</a><a name="FOREACHvertexA_">-</a>
  135. FOREACHvertexA_( vertices ) { ... }
  136. assign 'vertexA' to each vertex in vertices
  137. notes:
  138. uses 'vertexT *vertexA, *vertexAp;'
  139. see <a href="qset_r.h#FOREACHsetelement_">FOREACHsetelement_</a>
  140. */
  141. #define FOREACHvertexA_(vertices) FOREACHsetelement_(vertexT, vertices, vertexA)
  142. /*-<a href="qh-poly_r.htm#TOC"
  143. >--------------------------------</a><a name="FOREACHvertexreverse12_">-</a>
  144. FOREACHvertexreverse12_( vertices ) { ... }
  145. assign 'vertex' to each vertex in vertices
  146. reverse order of first two vertices
  147. notes:
  148. uses 'vertexT *vertex, *vertexp;'
  149. see <a href="qset_r.h#FOREACHsetelement_">FOREACHsetelement_</a>
  150. */
  151. #define FOREACHvertexreverse12_(vertices) FOREACHsetelementreverse12_(vertexT, vertices, vertex)
  152. /*=============== prototypes poly_r.c in alphabetical order ================*/
  153. #ifdef __cplusplus
  154. extern "C" {
  155. #endif
  156. void qh_appendfacet(qhT *qh, facetT *facet);
  157. void qh_appendvertex(qhT *qh, vertexT *vertex);
  158. void qh_attachnewfacets(qhT *qh /* qh.visible_list, qh.newfacet_list */);
  159. boolT qh_checkflipped(qhT *qh, facetT *facet, realT *dist, boolT allerror);
  160. void qh_delfacet(qhT *qh, facetT *facet);
  161. void qh_deletevisible(qhT *qh /* qh.visible_list, qh.horizon_list */);
  162. setT *qh_facetintersect(qhT *qh, facetT *facetA, facetT *facetB, int *skipAp,int *skipBp, int extra);
  163. int qh_gethash(qhT *qh, int hashsize, setT *set, int size, int firstindex, void *skipelem);
  164. facetT *qh_getreplacement(qhT *qh, facetT *visible);
  165. facetT *qh_makenewfacet(qhT *qh, setT *vertices, boolT toporient, facetT *facet);
  166. void qh_makenewplanes(qhT *qh /* qh.newfacet_list */);
  167. facetT *qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew);
  168. facetT *qh_makenew_simplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew);
  169. void qh_matchneighbor(qhT *qh, facetT *newfacet, int newskip, int hashsize,
  170. int *hashcount);
  171. coordT qh_matchnewfacets(qhT *qh);
  172. boolT qh_matchvertices(qhT *qh, int firstindex, setT *verticesA, int skipA,
  173. setT *verticesB, int *skipB, boolT *same);
  174. facetT *qh_newfacet(qhT *qh);
  175. ridgeT *qh_newridge(qhT *qh);
  176. int qh_pointid(qhT *qh, pointT *point);
  177. void qh_removefacet(qhT *qh, facetT *facet);
  178. void qh_removevertex(qhT *qh, vertexT *vertex);
  179. void qh_update_vertexneighbors(qhT *qh);
  180. void qh_update_vertexneighbors_cone(qhT *qh);
  181. /*========== -prototypes poly2_r.c in alphabetical order ===========*/
  182. boolT qh_addfacetvertex(qhT *qh, facetT *facet, vertexT *newvertex);
  183. void qh_addhash(void *newelem, setT *hashtable, int hashsize, int hash);
  184. void qh_check_bestdist(qhT *qh);
  185. void qh_check_maxout(qhT *qh);
  186. void qh_check_output(qhT *qh);
  187. void qh_check_point(qhT *qh, pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2, int *errcount);
  188. void qh_check_points(qhT *qh);
  189. void qh_checkconvex(qhT *qh, facetT *facetlist, int fault);
  190. void qh_checkfacet(qhT *qh, facetT *facet, boolT newmerge, boolT *waserrorp);
  191. void qh_checkflipped_all(qhT *qh, facetT *facetlist);
  192. boolT qh_checklists(qhT *qh, facetT *facetlist);
  193. void qh_checkpolygon(qhT *qh, facetT *facetlist);
  194. void qh_checkvertex(qhT *qh, vertexT *vertex, boolT allchecks, boolT *waserrorp);
  195. void qh_clearcenters(qhT *qh, qh_CENTER type);
  196. void qh_createsimplex(qhT *qh, setT *vertices);
  197. void qh_delridge(qhT *qh, ridgeT *ridge);
  198. void qh_delvertex(qhT *qh, vertexT *vertex);
  199. setT *qh_facet3vertex(qhT *qh, facetT *facet);
  200. facetT *qh_findbestfacet(qhT *qh, pointT *point, boolT bestoutside,
  201. realT *bestdist, boolT *isoutside);
  202. facetT *qh_findbestlower(qhT *qh, facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart);
  203. facetT *qh_findfacet_all(qhT *qh, pointT *point, boolT noupper, realT *bestdist, boolT *isoutside,
  204. int *numpart);
  205. int qh_findgood(qhT *qh, facetT *facetlist, int goodhorizon);
  206. void qh_findgood_all(qhT *qh, facetT *facetlist);
  207. void qh_furthestnext(qhT *qh /* qh.facet_list */);
  208. void qh_furthestout(qhT *qh, facetT *facet);
  209. void qh_infiniteloop(qhT *qh, facetT *facet);
  210. void qh_initbuild(qhT *qh);
  211. void qh_initialhull(qhT *qh, setT *vertices);
  212. setT *qh_initialvertices(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints);
  213. vertexT *qh_isvertex(pointT *point, setT *vertices);
  214. vertexT *qh_makenewfacets(qhT *qh, pointT *point /* qh.horizon_list, visible_list */);
  215. coordT qh_matchdupridge(qhT *qh, facetT *atfacet, int atskip, int hashsize, int *hashcount);
  216. void qh_nearcoplanar(qhT *qh /* qh.facet_list */);
  217. vertexT *qh_nearvertex(qhT *qh, facetT *facet, pointT *point, realT *bestdistp);
  218. int qh_newhashtable(qhT *qh, int newsize);
  219. vertexT *qh_newvertex(qhT *qh, pointT *point);
  220. facetT *qh_nextfacet2d(facetT *facet, vertexT **nextvertexp);
  221. ridgeT *qh_nextridge3d(ridgeT *atridge, facetT *facet, vertexT **vertexp);
  222. vertexT *qh_opposite_vertex(qhT *qh, facetT *facetA, facetT *neighbor);
  223. void qh_outcoplanar(qhT *qh /* qh.facet_list */);
  224. pointT *qh_point(qhT *qh, int id);
  225. void qh_point_add(qhT *qh, setT *set, pointT *point, void *elem);
  226. setT *qh_pointfacet(qhT *qh /* qh.facet_list */);
  227. setT *qh_pointvertex(qhT *qh /* qh.facet_list */);
  228. void qh_prependfacet(qhT *qh, facetT *facet, facetT **facetlist);
  229. void qh_printhashtable(qhT *qh, FILE *fp);
  230. void qh_printlists(qhT *qh);
  231. void qh_replacefacetvertex(qhT *qh, facetT *facet, vertexT *oldvertex, vertexT *newvertex);
  232. void qh_resetlists(qhT *qh, boolT stats, boolT resetVisible /* qh.newvertex_list qh.newfacet_list qh.visible_list */);
  233. void qh_setvoronoi_all(qhT *qh);
  234. void qh_triangulate(qhT *qh /* qh.facet_list */);
  235. void qh_triangulate_facet(qhT *qh, facetT *facetA, vertexT **first_vertex);
  236. void qh_triangulate_link(qhT *qh, facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB);
  237. void qh_triangulate_mirror(qhT *qh, facetT *facetA, facetT *facetB);
  238. void qh_triangulate_null(qhT *qh, facetT *facetA);
  239. void qh_vertexintersect(qhT *qh, setT **vertexsetA,setT *vertexsetB);
  240. setT *qh_vertexintersect_new(qhT *qh, setT *vertexsetA,setT *vertexsetB);
  241. void qh_vertexneighbors(qhT *qh /* qh.facet_list */);
  242. boolT qh_vertexsubset(setT *vertexsetA, setT *vertexsetB);
  243. #ifdef __cplusplus
  244. } /* extern "C" */
  245. #endif
  246. #endif /* qhDEFpoly */