| 1 | /*<html><pre> -<a href="qh-poly_r.htm" |
| 2 | >-------------------------------</a><a name="TOP">-</a> |
| 3 | |
| 4 | poly_r.c |
| 5 | implements polygons and simplices |
| 6 | |
| 7 | see qh-poly_r.htm, poly_r.h and libqhull_r.h |
| 8 | |
| 9 | infrequent code is in poly2_r.c |
| 10 | (all but top 50 and their callers 12/3/95) |
| 11 | |
| 12 | Copyright (c) 1993-2020 The Geometry Center. |
| 13 | $Id: //main/2019/qhull/src/libqhull_r/poly_r.c#8 $$Change: 2953 $ |
| 14 | $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $ |
| 15 | */ |
| 16 | |
| 17 | #include "qhull_ra.h"cxx . . $ `<file>/vendor/qhull/libqhull_r/qhull_ra.h`/ |
| 18 | |
| 19 | /*======== functions in alphabetical order ==========*/ |
| 20 | |
| 21 | /*-<a href="qh-poly_r.htm#TOC" |
| 22 | >-------------------------------</a><a name="appendfacet">-</a> |
| 23 | |
| 24 | qh_appendfacet(qh, facet ) |
| 25 | appends facet to end of qh.facet_list, |
| 26 | |
| 27 | returns: |
| 28 | updates qh.newfacet_list, facet_next, facet_list |
| 29 | increments qh.numfacets |
| 30 | |
| 31 | notes: |
| 32 | assumes qh.facet_list/facet_tail is defined (createsimplex) |
| 33 | |
| 34 | see: |
| 35 | qh_removefacet() |
| 36 | |
| 37 | */ |
| 38 | void qh_appendfacetcxx . . $ qh_appendfacet(6436bdf99f629b76).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *facet) { |
| 39 | facetTcxx . . $ facetT# *tail= qh->facet_tailcxx . . $ qhT#facet_tail.; |
| 40 | |
| 41 | if (tail == qh->newfacet_listcxx . . $ qhT#newfacet_list.) { |
| 42 | qh->newfacet_listcxx . . $ qhT#newfacet_list.= facet; |
| 43 | if (tail == qh->visible_listcxx . . $ qhT#visible_list.) /* visible_list is at or before newfacet_list */ |
| 44 | qh->visible_listcxx . . $ qhT#visible_list.= facet; |
| 45 | } |
| 46 | if (tail == qh->facet_nextcxx . . $ qhT#facet_next.) |
| 47 | qh->facet_nextcxx . . $ qhT#facet_next.= facet; |
| 48 | facet->previouscxx . . $ facetT#previous.= tail->previouscxx . . $ facetT#previous.; |
| 49 | facet->nextcxx . . $ facetT#next.= tail; |
| 50 | if (tail->previouscxx . . $ facetT#previous.) |
| 51 | tail->previouscxx . . $ facetT#previous.->nextcxx . . $ facetT#next.= facet; |
| 52 | else |
| 53 | qh->facet_listcxx . . $ qhT#facet_list.= facet; |
| 54 | tail->previouscxx . . $ facetT#previous.= facet; |
| 55 | qh->num_facetscxx . . $ qhT#num_facets.++; |
| 56 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4044, "qh_appendfacet: append f%d to facet_list\n", facet->id)); |
| 57 | } /* appendfacet */ |
| 58 | |
| 59 | |
| 60 | /*-<a href="qh-poly_r.htm#TOC" |
| 61 | >-------------------------------</a><a name="appendvertex">-</a> |
| 62 | |
| 63 | qh_appendvertex(qh, vertex ) |
| 64 | appends vertex to end of qh.vertex_list, |
| 65 | |
| 66 | returns: |
| 67 | sets vertex->newfacet |
| 68 | updates qh.vertex_list, newvertex_list |
| 69 | increments qh.num_vertices |
| 70 | |
| 71 | notes: |
| 72 | assumes qh.vertex_list/vertex_tail is defined (createsimplex) |
| 73 | |
| 74 | */ |
| 75 | void qh_appendvertexcxx . . $ qh_appendvertex(3be63de346aefe7d).(qhTcxx . . $ qhT# *qh, vertexTcxx . . $ vertexT# *vertex) { |
| 76 | vertexTcxx . . $ vertexT# *tail= qh->vertex_tailcxx . . $ qhT#vertex_tail.; |
| 77 | |
| 78 | if (tail == qh->newvertex_listcxx . . $ qhT#newvertex_list.) |
| 79 | qh->newvertex_listcxx . . $ qhT#newvertex_list.= vertex; |
| 80 | vertex->newfacetcxx . . $ vertexT#newfacet.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 81 | vertex->previouscxx . . $ vertexT#previous.= tail->previouscxx . . $ vertexT#previous.; |
| 82 | vertex->nextcxx . . $ vertexT#next.= tail; |
| 83 | if (tail->previouscxx . . $ vertexT#previous.) |
| 84 | tail->previouscxx . . $ vertexT#previous.->nextcxx . . $ vertexT#next.= vertex; |
| 85 | else |
| 86 | qh->vertex_listcxx . . $ qhT#vertex_list.= vertex; |
| 87 | tail->previouscxx . . $ vertexT#previous.= vertex; |
| 88 | qh->num_verticescxx . . $ qhT#num_vertices.++; |
| 89 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4045, "qh_appendvertex: append v%d to qh.newvertex_list and set v.newfacet\n", vertex->id)); |
| 90 | } /* appendvertex */ |
| 91 | |
| 92 | |
| 93 | /*-<a href="qh-poly_r.htm#TOC" |
| 94 | >-------------------------------</a><a name="attachnewfacets">-</a> |
| 95 | |
| 96 | qh_attachnewfacets(qh) |
| 97 | attach horizon facets to new facets in qh.newfacet_list |
| 98 | newfacets have neighbor and ridge links to horizon but not vice versa |
| 99 | |
| 100 | returns: |
| 101 | clears qh.NEWtentative |
| 102 | set qh.NEWfacets |
| 103 | horizon facets linked to new facets |
| 104 | ridges changed from visible facets to new facets |
| 105 | simplicial ridges deleted |
| 106 | qh.visible_list, no ridges valid |
| 107 | facet->f.replace is a newfacet (if any) |
| 108 | |
| 109 | notes: |
| 110 | used for qh.NEWtentative, otherwise see qh_makenew_nonsimplicial and qh_makenew_simplicial |
| 111 | qh_delridge_merge not needed (as tested by qh_checkdelridge) |
| 112 | |
| 113 | design: |
| 114 | delete interior ridges and neighbor sets by |
| 115 | for each visible, non-simplicial facet |
| 116 | for each ridge |
| 117 | if last visit or if neighbor is simplicial |
| 118 | if horizon neighbor |
| 119 | delete ridge for horizon's ridge set |
| 120 | delete ridge |
| 121 | erase neighbor set |
| 122 | attach horizon facets and new facets by |
| 123 | for all new facets |
| 124 | if corresponding horizon facet is simplicial |
| 125 | locate corresponding visible facet {may be more than one} |
| 126 | link visible facet to new facet |
| 127 | replace visible facet with new facet in horizon |
| 128 | else it is non-simplicial |
| 129 | for all visible neighbors of the horizon facet |
| 130 | link visible neighbor to new facet |
| 131 | delete visible neighbor from horizon facet |
| 132 | append new facet to horizon's neighbors |
| 133 | the first ridge of the new facet is the horizon ridge |
| 134 | link the new facet into the horizon ridge |
| 135 | */ |
| 136 | void qh_attachnewfacetscxx . . $ qh_attachnewfacets(fb32973c8cc8eae9).(qhTcxx . . $ qhT# *qh /* qh.visible_list, qh.newfacet_list */) { |
| 137 | facetTcxx . . $ facetT# *newfacet= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *neighbor, **neighborp, *horizon, *visible; |
| 138 | ridgeTcxx . . $ ridgeT# *ridge, **ridgep; |
| 139 | |
| 140 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3012, "qh_attachnewfacets: delete interior ridges\n")); |
| 141 | if (qh->CHECKfrequentlycxx . . $ qhT#CHECKfrequently.) { |
| 142 | qh_checkdelridgecxx . . $ qh_checkdelridge(fb32973c8cc8eae9).(qh); |
| 143 | } |
| 144 | qh->visit_idcxx . . $ qhT#visit_id.++; |
| 145 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 146 | visible->visitidcxx . . $ facetT#visitid.= qh->visit_idcxx . . $ qhT#visit_id.; |
| 147 | if (visible->ridgescxx . . $ facetT#ridges.) { |
| 148 | FOREACHridge_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1032:9`!(visible->ridges) { |
| 149 | neighbor= otherfacet_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:891:9`!(ridge, visible); |
| 150 | if (neighbor->visitidcxx . . $ facetT#visitid. == qh->visit_idcxx . . $ qhT#visit_id. |
| 151 | || (!neighbor->visiblecxx . . $ facetT#visible. && neighbor->simplicialcxx . . $ facetT#simplicial.)) { |
| 152 | if (!neighbor->visiblecxx . . $ facetT#visible.) /* delete ridge for simplicial horizon */ |
| 153 | qh_setdelcxx . . $ qh_setdel(117666f5f13ff3be).(neighbor->ridgescxx . . $ facetT#ridges., ridge); |
| 154 | qh_delridgecxx . . $ qh_delridge(19ea2400ed1d8228).(qh, ridge); /* delete on second visit */ |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | trace1cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:88:9`!((qh, qh->ferr, 1017, "qh_attachnewfacets: attach horizon facets to new facets\n")); |
| 160 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 161 | horizon= SETfirstt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:387:9`!(newfacet->neighbors, facetT); |
| 162 | if (horizon->simplicialcxx . . $ facetT#simplicial.) { |
| 163 | visible= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 164 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(horizon) { /* may have more than one horizon ridge */ |
| 165 | if (neighbor->visiblecxx . . $ facetT#visible.) { |
| 166 | if (visible) { |
| 167 | if (qh_setequal_skipcxx . . $ qh_setequal_skip(b3f63bd3cf74acc2).(newfacet->verticescxx . . $ facetT#vertices., 0, horizon->verticescxx . . $ facetT#vertices., |
| 168 | SETindex_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:324:9`!(horizon->neighbors, neighbor))) { |
| 169 | visible= neighbor; |
| 170 | break; |
| 171 | } |
| 172 | }else |
| 173 | visible= neighbor; |
| 174 | } |
| 175 | } |
| 176 | if (visible) { |
| 177 | visible->fcxx . . $ facetT#f..replacecxx . . $ facetT#$anonymous_type_3#replace.= newfacet; |
| 178 | qh_setreplacecxx . . $ qh_setreplace(e04772c008a00ec4).(qh, horizon->neighborscxx . . $ facetT#neighbors., visible, newfacet); |
| 179 | }else { |
| 180 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6102, "qhull internal error (qh_attachnewfacets): could not find visible facet for horizon f%d of newfacet f%d\n", |
| 181 | horizon->idcxx . . $ facetT#id., newfacet->idcxx . . $ facetT#id.); |
| 182 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, horizon, newfacet); |
| 183 | } |
| 184 | }else { /* non-simplicial, with a ridge for newfacet */ |
| 185 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(horizon) { /* may hold for many new facets */ |
| 186 | if (neighbor->visiblecxx . . $ facetT#visible.) { |
| 187 | neighbor->fcxx . . $ facetT#f..replacecxx . . $ facetT#$anonymous_type_3#replace.= newfacet; |
| 188 | qh_setdelnthcxx . . $ qh_setdelnth(4711ee2c395cd458).(qh, horizon->neighborscxx . . $ facetT#neighbors., SETindex_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:324:9`!(horizon->neighbors, neighbor)); |
| 189 | neighborp--; /* repeat */ |
| 190 | } |
| 191 | } |
| 192 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &horizon->neighborscxx . . $ facetT#neighbors., newfacet); |
| 193 | ridge= SETfirstt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:387:9`!(newfacet->ridges, ridgeT); |
| 194 | if (ridge->topcxx . . $ ridgeT#top. == horizon) { |
| 195 | ridge->bottomcxx . . $ ridgeT#bottom.= newfacet; |
| 196 | ridge->simplicialbotcxx . . $ ridgeT#simplicialbot.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 197 | }else { |
| 198 | ridge->topcxx . . $ ridgeT#top.= newfacet; |
| 199 | ridge->simplicialtopcxx . . $ ridgeT#simplicialtop.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 200 | } |
| 201 | } |
| 202 | } /* newfacets */ |
| 203 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4094, "qh_attachnewfacets: clear f.ridges and f.neighbors for visible facets, may become invalid before qh_deletevisible\n")); |
| 204 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 205 | if (visible->ridgescxx . . $ facetT#ridges.) |
| 206 | SETfirst_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:378:9`!(visible->ridges)= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 207 | SETfirst_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:378:9`!(visible->neighbors)= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 208 | } |
| 209 | qh->NEWtentativecxx . . $ qhT#NEWtentative.= Falsecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:137:9`!; |
| 210 | qh->NEWfacetscxx . . $ qhT#NEWfacets.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 211 | if (qh->PRINTstatisticscxx . . $ qhT#PRINTstatistics.) { |
| 212 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 213 | if (!visible->fcxx . . $ facetT#f..replacecxx . . $ facetT#$anonymous_type_3#replace.) |
| 214 | zinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:428:9`!(Zinsidevisible); |
| 215 | } |
| 216 | } |
| 217 | } /* attachnewfacets */ |
| 218 | |
| 219 | /*-<a href="qh-poly_r.htm#TOC" |
| 220 | >-------------------------------</a><a name="checkflipped">-</a> |
| 221 | |
| 222 | qh_checkflipped(qh, facet, dist, allerror ) |
| 223 | checks facet orientation to interior point |
| 224 | |
| 225 | if allerror set, |
| 226 | tests against -qh.DISTround |
| 227 | else |
| 228 | tests against 0.0 since tested against -qh.DISTround before |
| 229 | |
| 230 | returns: |
| 231 | False if it flipped orientation (sets facet->flipped) |
| 232 | distance if non-NULL |
| 233 | |
| 234 | notes: |
| 235 | called by qh_setfacetplane, qh_initialhull, and qh_checkflipped_all |
| 236 | */ |
| 237 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! qh_checkflippedcxx . . $ qh_checkflipped(e8493651136531c1).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *facet, realTcxx . . $ `vendor/qhull/libqhull_r/user_r.h:159:9`! *distp, boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! allerror) { |
| 238 | realTcxx . . $ `vendor/qhull/libqhull_r/user_r.h:159:9`! dist; |
| 239 | |
| 240 | if (facet->flippedcxx . . $ facetT#flipped. && !distp) |
| 241 | return Falsecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:137:9`!; |
| 242 | zzinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:424:9`!(Zdistcheck); |
| 243 | qh_distplanecxx . . $ qh_distplane(4b1ba4cb548df22).(qh, qh->interior_pointcxx . . $ qhT#interior_point., facet, &dist); |
| 244 | if (distp) |
| 245 | *distp= dist; |
| 246 | if ((allerror && dist >= -qh->DISTroundcxx . . $ qhT#DISTround.) || (!allerror && dist > 0.0)) { |
| 247 | facet->flippedcxx . . $ facetT#flipped.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 248 | trace0cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:87:9`!((qh, qh->ferr, 19, "qh_checkflipped: facet f%d flipped, allerror? %d, distance= %6.12g during p%d\n", |
| 249 | facet->id, allerror, dist, qh->furthest_id)); |
| 250 | if (qh->num_facetscxx . . $ qhT#num_facets. > qh->hull_dimcxx . . $ qhT#hull_dim.+1) { /* qh_initialhull reverses orientation if !qh_checkflipped */ |
| 251 | zzinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:424:9`!(Zflippedfacets); |
| 252 | qh_joggle_restartcxx . . $ qh_joggle_restart(1ce62fb2aa3cd5bf).(qh, "flipped facet"); |
| 253 | } |
| 254 | return Falsecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:137:9`!; |
| 255 | } |
| 256 | return Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 257 | } /* checkflipped */ |
| 258 | |
| 259 | /*-<a href="qh-poly_r.htm#TOC" |
| 260 | >-------------------------------</a><a name="delfacet">-</a> |
| 261 | |
| 262 | qh_delfacet(qh, facet ) |
| 263 | removes facet from facet_list and frees up its memory |
| 264 | |
| 265 | notes: |
| 266 | assumes vertices and ridges already freed or referenced elsewhere |
| 267 | */ |
| 268 | void qh_delfacetcxx . . $ qh_delfacet(6436bdf99f629b76).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *facet) { |
| 269 | void **freelistp; /* used if !qh_NOmem by qh_memfree_() */ |
| 270 | |
| 271 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3057, "qh_delfacet: delete f%d\n", facet->id)); |
| 272 | if (qh->CHECKfrequentlycxx . . $ qhT#CHECKfrequently. || qh->VERIFYoutputcxx . . $ qhT#VERIFYoutput.) { |
| 273 | if (!qh->NOerrexitcxx . . $ qhT#NOerrexit.) { |
| 274 | qh_checkdelfacetcxx . . $ qh_checkdelfacet(e3b5cb83a845c92e).(qh, facet, qh->facet_mergesetcxx . . $ qhT#facet_mergeset.); |
| 275 | qh_checkdelfacetcxx . . $ qh_checkdelfacet(e3b5cb83a845c92e).(qh, facet, qh->degen_mergesetcxx . . $ qhT#degen_mergeset.); |
| 276 | qh_checkdelfacetcxx . . $ qh_checkdelfacet(e3b5cb83a845c92e).(qh, facet, qh->vertex_mergesetcxx . . $ qhT#vertex_mergeset.); |
| 277 | } |
| 278 | } |
| 279 | if (facet == qh->tracefacetcxx . . $ qhT#tracefacet.) |
| 280 | qh->tracefacetcxx . . $ qhT#tracefacet.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 281 | if (facet == qh->GOODclosestcxx . . $ qhT#GOODclosest.) |
| 282 | qh->GOODclosestcxx . . $ qhT#GOODclosest.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 283 | qh_removefacetcxx . . $ qh_removefacet(6436bdf99f629b76).(qh, facet); |
| 284 | if (!facet->tricoplanarcxx . . $ facetT#tricoplanar. || facet->keepcentrumcxx . . $ facetT#keepcentrum.) { |
| 285 | qh_memfree_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:198:9`!(qh, facet->normal, qh->normal_size, freelistp); |
| 286 | if (qh->CENTERtypecxx . . $ qhT#CENTERtype. == qh_ASvoronoicxx . . $ qh_ASvoronoi.) { /* braces for macro calls */ |
| 287 | qh_memfree_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:198:9`!(qh, facet->center, qh->center_size, freelistp); |
| 288 | }else /* AScentrum */ { |
| 289 | qh_memfree_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:198:9`!(qh, facet->center, qh->normal_size, freelistp); |
| 290 | } |
| 291 | } |
| 292 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(facet->neighborscxx . . $ facetT#neighbors.)); |
| 293 | if (facet->ridgescxx . . $ facetT#ridges.) |
| 294 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(facet->ridgescxx . . $ facetT#ridges.)); |
| 295 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(facet->verticescxx . . $ facetT#vertices.)); |
| 296 | if (facet->outsidesetcxx . . $ facetT#outsideset.) |
| 297 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(facet->outsidesetcxx . . $ facetT#outsideset.)); |
| 298 | if (facet->coplanarsetcxx . . $ facetT#coplanarset.) |
| 299 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(facet->coplanarsetcxx . . $ facetT#coplanarset.)); |
| 300 | qh_memfree_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:198:9`!(qh, facet, (int)sizeof(facetT), freelistp); |
| 301 | } /* delfacet */ |
| 302 | |
| 303 | |
| 304 | /*-<a href="qh-poly_r.htm#TOC" |
| 305 | >-------------------------------</a><a name="deletevisible">-</a> |
| 306 | |
| 307 | qh_deletevisible() |
| 308 | delete visible facets and vertices |
| 309 | |
| 310 | returns: |
| 311 | deletes each facet and removes from facetlist |
| 312 | deletes vertices on qh.del_vertices and ridges in qh.del_ridges |
| 313 | at exit, qh.visible_list empty (== qh.newfacet_list) |
| 314 | |
| 315 | notes: |
| 316 | called by qh_all_vertexmerges, qh_addpoint, and qh_qhull |
| 317 | ridges already deleted or moved elsewhere |
| 318 | deleted vertices on qh.del_vertices |
| 319 | horizon facets do not reference facets on qh.visible_list |
| 320 | new facets in qh.newfacet_list |
| 321 | uses qh.visit_id; |
| 322 | */ |
| 323 | void qh_deletevisiblecxx . . $ qh_deletevisible(fb32973c8cc8eae9).(qhTcxx . . $ qhT# *qh /* qh.visible_list */) { |
| 324 | facetTcxx . . $ facetT# *visible, *nextfacet; |
| 325 | vertexTcxx . . $ vertexT# *vertex, **vertexp; |
| 326 | int numvisible= 0, numdel= qh_setsizecxx . . $ qh_setsize(8330125fbf155b5c).(qh, qh->del_verticescxx . . $ qhT#del_vertices.); |
| 327 | |
| 328 | trace1cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:88:9`!((qh, qh->ferr, 1018, "qh_deletevisible: delete %d visible facets and %d vertices\n", |
| 329 | qh->num_visible, numdel)); |
| 330 | for (visible=qh->visible_listcxx . . $ qhT#visible_list.; visible && visible->visiblecxx . . $ facetT#visible.; |
| 331 | visible= nextfacet) { /* deleting current */ |
| 332 | nextfacet= visible->nextcxx . . $ facetT#next.; |
| 333 | numvisible++; |
| 334 | qh_delfacetcxx . . $ qh_delfacet(6436bdf99f629b76).(qh, visible); /* f.ridges deleted or moved elsewhere, deleted f.vertices on qh.del_vertices */ |
| 335 | } |
| 336 | if (numvisible != qh->num_visiblecxx . . $ qhT#num_visible.) { |
| 337 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6103, "qhull internal error (qh_deletevisible): qh->num_visible %d is not number of visible facets %d\n", |
| 338 | qh->num_visiblecxx . . $ qhT#num_visible., numvisible); |
| 339 | qh_errexitcxx . . $ qh_errexit(6867cd51ab709aa0).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 340 | } |
| 341 | qh->num_visiblecxx . . $ qhT#num_visible.= 0; |
| 342 | zadd_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:443:9`!(Zvisfacettot, numvisible); |
| 343 | zmax_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:474:9`!(Zvisfacetmax, numvisible); |
| 344 | zzadd_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:437:9`!(Zdelvertextot, numdel); |
| 345 | zmax_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:474:9`!(Zdelvertexmax, numdel); |
| 346 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(qh->del_vertices) |
| 347 | qh_delvertexcxx . . $ qh_delvertex(3be63de346aefe7d).(qh, vertex); |
| 348 | qh_settruncatecxx . . $ qh_settruncate(98aa07c3e0c03500).(qh, qh->del_verticescxx . . $ qhT#del_vertices., 0); |
| 349 | } /* deletevisible */ |
| 350 | |
| 351 | /*-<a href="qh-poly_r.htm#TOC" |
| 352 | >-------------------------------</a><a name="facetintersect">-</a> |
| 353 | |
| 354 | qh_facetintersect(qh, facetA, facetB, skipa, skipB, prepend ) |
| 355 | return vertices for intersection of two simplicial facets |
| 356 | may include 1 prepended entry (if more, need to settemppush) |
| 357 | |
| 358 | returns: |
| 359 | returns set of qh.hull_dim-1 + prepend vertices |
| 360 | returns skipped index for each test and checks for exactly one |
| 361 | |
| 362 | notes: |
| 363 | does not need settemp since set in quick memory |
| 364 | |
| 365 | see also: |
| 366 | qh_vertexintersect and qh_vertexintersect_new |
| 367 | use qh_setnew_delnthsorted to get nth ridge (no skip information) |
| 368 | |
| 369 | design: |
| 370 | locate skipped vertex by scanning facet A's neighbors |
| 371 | locate skipped vertex by scanning facet B's neighbors |
| 372 | intersect the vertex sets |
| 373 | */ |
| 374 | setTcxx . . $ setT# *qh_facetintersectcxx . . $ qh_facetintersect(e5559fdcfc266cb6).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *facetA, facetTcxx . . $ facetT# *facetB, |
| 375 | int *skipA,int *skipB, int prepend) { |
| 376 | setTcxx . . $ setT# *intersect; |
| 377 | int dim= qh->hull_dimcxx . . $ qhT#hull_dim., i, j; |
| 378 | facetTcxx . . $ facetT# **neighborsA, **neighborsB; |
| 379 | |
| 380 | neighborsA= SETaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:412:9`!(facetA->neighbors, facetT); |
| 381 | neighborsB= SETaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:412:9`!(facetB->neighbors, facetT); |
| 382 | i= j= 0; |
| 383 | if (facetB == *neighborsA++) |
| 384 | *skipA= 0; |
| 385 | else if (facetB == *neighborsA++) |
| 386 | *skipA= 1; |
| 387 | else if (facetB == *neighborsA++) |
| 388 | *skipA= 2; |
| 389 | else { |
| 390 | for (i=3; i < dim; i++) { |
| 391 | if (facetB == *neighborsA++) { |
| 392 | *skipA= i; |
| 393 | break; |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | if (facetA == *neighborsB++) |
| 398 | *skipB= 0; |
| 399 | else if (facetA == *neighborsB++) |
| 400 | *skipB= 1; |
| 401 | else if (facetA == *neighborsB++) |
| 402 | *skipB= 2; |
| 403 | else { |
| 404 | for (j=3; j < dim; j++) { |
| 405 | if (facetA == *neighborsB++) { |
| 406 | *skipB= j; |
| 407 | break; |
| 408 | } |
| 409 | } |
| 410 | } |
| 411 | if (i >= dim || j >= dim) { |
| 412 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6104, "qhull internal error (qh_facetintersect): f%d or f%d not in other's neighbors\n", |
| 413 | facetA->idcxx . . $ facetT#id., facetB->idcxx . . $ facetT#id.); |
| 414 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, facetA, facetB); |
| 415 | } |
| 416 | intersect= qh_setnew_delnthsortedcxx . . $ qh_setnew_delnthsorted(8e6bbbfae9f71594).(qh, facetA->verticescxx . . $ facetT#vertices., qh->hull_dimcxx . . $ qhT#hull_dim., *skipA, prepend); |
| 417 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4047, "qh_facetintersect: f%d skip %d matches f%d skip %d\n", |
| 418 | facetA->id, *skipA, facetB->id, *skipB)); |
| 419 | return(intersect); |
| 420 | } /* facetintersect */ |
| 421 | |
| 422 | /*-<a href="qh-poly_r.htm#TOC" |
| 423 | >-------------------------------</a><a name="gethash">-</a> |
| 424 | |
| 425 | qh_gethash(qh, hashsize, set, size, firstindex, skipelem ) |
| 426 | return hashvalue for a set with firstindex and skipelem |
| 427 | |
| 428 | notes: |
| 429 | returned hash is in [0,hashsize) |
| 430 | assumes at least firstindex+1 elements |
| 431 | assumes skipelem is NULL, in set, or part of hash |
| 432 | |
| 433 | hashes memory addresses which may change over different runs of the same data |
| 434 | using sum for hash does badly in high d |
| 435 | */ |
| 436 | int qh_gethashcxx . . $ qh_gethash(b9618e642442736e).(qhTcxx . . $ qhT# *qh, int hashsize, setTcxx . . $ setT# *set, int size, int firstindex, void *skipelem) { |
| 437 | void **elemp= SETelemaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:369:9`!(set, firstindex, void); |
| 438 | ptr_intTcxx . . $ ptr_intT# hash= 0, elem; |
| 439 | unsigned int uresult; |
| 440 | int i; |
| 441 | #ifdef _MSC_VER /* Microsoft Visual C++ -- warn about 64-bit issues */ |
| 442 | #pragma warning( push) /* WARN64 -- ptr_intT holds a 64-bit pointer */ |
| 443 | #pragma warning( disable : 4311) /* 'type cast': pointer truncation from 'void*' to 'ptr_intT' */ |
| 444 | #endif |
| 445 | |
| 446 | switch (size-firstindex) { |
| 447 | case 1: |
| 448 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 449 | break; |
| 450 | case 2: |
| 451 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) + (ptr_intTcxx . . $ ptr_intT#)elemp[1] - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 452 | break; |
| 453 | case 3: |
| 454 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) + (ptr_intTcxx . . $ ptr_intT#)elemp[1] + (ptr_intTcxx . . $ ptr_intT#)elemp[2] |
| 455 | - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 456 | break; |
| 457 | case 4: |
| 458 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) + (ptr_intTcxx . . $ ptr_intT#)elemp[1] + (ptr_intTcxx . . $ ptr_intT#)elemp[2] |
| 459 | + (ptr_intTcxx . . $ ptr_intT#)elemp[3] - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 460 | break; |
| 461 | case 5: |
| 462 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) + (ptr_intTcxx . . $ ptr_intT#)elemp[1] + (ptr_intTcxx . . $ ptr_intT#)elemp[2] |
| 463 | + (ptr_intTcxx . . $ ptr_intT#)elemp[3] + (ptr_intTcxx . . $ ptr_intT#)elemp[4] - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 464 | break; |
| 465 | case 6: |
| 466 | hash= (ptr_intTcxx . . $ ptr_intT#)(*elemp) + (ptr_intTcxx . . $ ptr_intT#)elemp[1] + (ptr_intTcxx . . $ ptr_intT#)elemp[2] |
| 467 | + (ptr_intTcxx . . $ ptr_intT#)elemp[3] + (ptr_intTcxx . . $ ptr_intT#)elemp[4]+ (ptr_intTcxx . . $ ptr_intT#)elemp[5] |
| 468 | - (ptr_intTcxx . . $ ptr_intT#) skipelem; |
| 469 | break; |
| 470 | default: |
| 471 | hash= 0; |
| 472 | i= 3; |
| 473 | do { /* this is about 10% in 10-d */ |
| 474 | if ((elem= (ptr_intTcxx . . $ ptr_intT#)*elemp++) != (ptr_intTcxx . . $ ptr_intT#)skipelem) { |
| 475 | hash ^= (elem << i) + (elem >> (32-i)); |
| 476 | i += 3; |
| 477 | if (i >= 32) |
| 478 | i -= 32; |
| 479 | } |
| 480 | }while (*elemp); |
| 481 | break; |
| 482 | } |
| 483 | if (hashsize<0) { |
| 484 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6202, "qhull internal error: negative hashsize %d passed to qh_gethash [poly_r.c]\n", hashsize); |
| 485 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 486 | } |
| 487 | uresult= (unsigned int)hash; |
| 488 | uresult %= (unsigned int)hashsize; |
| 489 | /* result= 0; for debugging */ |
| 490 | return (int)uresult; |
| 491 | #ifdef _MSC_VER |
| 492 | #pragma warning( pop) |
| 493 | #endif |
| 494 | } /* gethash */ |
| 495 | |
| 496 | /*-<a href="qh-poly_r.htm#TOC" |
| 497 | >-------------------------------</a><a name="getreplacement">-</a> |
| 498 | |
| 499 | qh_getreplacement(qh, visible ) |
| 500 | get replacement for visible facet |
| 501 | |
| 502 | returns: |
| 503 | valid facet from visible.replace (may be chained) |
| 504 | */ |
| 505 | facetTcxx . . $ facetT# *qh_getreplacementcxx . . $ qh_getreplacement(dfbef15a79112b5a).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *visible) { |
| 506 | unsigned int count= 0; |
| 507 | |
| 508 | facetTcxx . . $ facetT# *result= visible; |
| 509 | while (result && result->visiblecxx . . $ facetT#visible.) { |
| 510 | result= result->fcxx . . $ facetT#f..replacecxx . . $ facetT#$anonymous_type_3#replace.; |
| 511 | if (count++ > qh->facet_idcxx . . $ qhT#facet_id.) |
| 512 | qh_infiniteloopcxx . . $ qh_infiniteloop(6436bdf99f629b76).(qh, visible); |
| 513 | } |
| 514 | return result; |
| 515 | } |
| 516 | |
| 517 | /*-<a href="qh-poly_r.htm#TOC" |
| 518 | >-------------------------------</a><a name="makenewfacet">-</a> |
| 519 | |
| 520 | qh_makenewfacet(qh, vertices, toporient, horizon ) |
| 521 | creates a toporient? facet from vertices |
| 522 | |
| 523 | returns: |
| 524 | returns newfacet |
| 525 | adds newfacet to qh.facet_list |
| 526 | newfacet->vertices= vertices |
| 527 | if horizon |
| 528 | newfacet->neighbor= horizon, but not vice versa |
| 529 | newvertex_list updated with vertices |
| 530 | */ |
| 531 | facetTcxx . . $ facetT# *qh_makenewfacetcxx . . $ qh_makenewfacet(786bf0a2ea9612a9).(qhTcxx . . $ qhT# *qh, setTcxx . . $ setT# *vertices, boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! toporient, facetTcxx . . $ facetT# *horizon) { |
| 532 | facetTcxx . . $ facetT# *newfacet; |
| 533 | vertexTcxx . . $ vertexT# *vertex, **vertexp; |
| 534 | |
| 535 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(vertices) { |
| 536 | if (!vertex->newfacetcxx . . $ vertexT#newfacet.) { |
| 537 | qh_removevertexcxx . . $ qh_removevertex(3be63de346aefe7d).(qh, vertex); |
| 538 | qh_appendvertexcxx . . $ qh_appendvertex(3be63de346aefe7d).(qh, vertex); |
| 539 | } |
| 540 | } |
| 541 | newfacet= qh_newfacetcxx . . $ qh_newfacet(5ab391dae1598d95).(qh); |
| 542 | newfacet->verticescxx . . $ facetT#vertices.= vertices; |
| 543 | if (toporient) |
| 544 | newfacet->toporientcxx . . $ facetT#toporient.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 545 | if (horizon) |
| 546 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &(newfacet->neighborscxx . . $ facetT#neighbors.), horizon); |
| 547 | qh_appendfacetcxx . . $ qh_appendfacet(6436bdf99f629b76).(qh, newfacet); |
| 548 | return(newfacet); |
| 549 | } /* makenewfacet */ |
| 550 | |
| 551 | |
| 552 | /*-<a href="qh-poly_r.htm#TOC" |
| 553 | >-------------------------------</a><a name="makenewplanes">-</a> |
| 554 | |
| 555 | qh_makenewplanes() |
| 556 | make new hyperplanes for facets on qh.newfacet_list |
| 557 | |
| 558 | returns: |
| 559 | all facets have hyperplanes or are marked for merging |
| 560 | doesn't create hyperplane if horizon is coplanar (will merge) |
| 561 | updates qh.min_vertex if qh.JOGGLEmax |
| 562 | |
| 563 | notes: |
| 564 | facet->f.samecycle is defined for facet->mergehorizon facets |
| 565 | */ |
| 566 | void qh_makenewplanescxx . . $ qh_makenewplanes(fb32973c8cc8eae9).(qhTcxx . . $ qhT# *qh /* qh.newfacet_list */) { |
| 567 | facetTcxx . . $ facetT# *newfacet; |
| 568 | |
| 569 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4074, "qh_makenewplanes: make new hyperplanes for facets on qh.newfacet_list f%d\n", |
| 570 | qh->newfacet_list->id)); |
| 571 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 572 | if (!newfacet->mergehorizoncxx . . $ facetT#mergehorizon.) |
| 573 | qh_setfacetplanecxx . . $ qh_setfacetplane(6436bdf99f629b76).(qh, newfacet); /* updates Wnewvertexmax */ |
| 574 | } |
| 575 | if (qh->JOGGLEmaxcxx . . $ qhT#JOGGLEmax. < REALmaxcxx . . $ `vendor/qhull/libqhull_r/user_r.h:160:9`!/2) |
| 576 | minimize_cxx . . $ `vendor/qhull/libqhull_r/geom_r.h:59:9`!(qh->min_vertex, -wwval_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:454:9`!(Wnewvertexmax)); |
| 577 | } /* makenewplanes */ |
| 578 | |
| 579 | #ifndef qh_NOmerge |
| 580 | /*-<a href="qh-poly_r.htm#TOC" |
| 581 | >-------------------------------</a><a name="makenew_nonsimplicial">-</a> |
| 582 | |
| 583 | qh_makenew_nonsimplicial(qh, visible, apex, numnew ) |
| 584 | make new facets for ridges of a visible facet |
| 585 | |
| 586 | returns: |
| 587 | first newfacet, bumps numnew as needed |
| 588 | attaches new facets if !qh->NEWtentative |
| 589 | marks ridge neighbors for simplicial visible |
| 590 | if (qh.NEWtentative) |
| 591 | ridges on newfacet, horizon, and visible |
| 592 | else |
| 593 | ridge and neighbors between newfacet and horizon |
| 594 | visible facet's ridges are deleted |
| 595 | visible facet's f.neighbors is empty |
| 596 | |
| 597 | notes: |
| 598 | called by qh_makenewfacets and qh_triangulatefacet |
| 599 | qh.visit_id if visible has already been processed |
| 600 | sets neighbor->seen for building f.samecycle |
| 601 | assumes all 'seen' flags initially false |
| 602 | qh_delridge_merge not needed (as tested by qh_checkdelridge in qh_makenewfacets) |
| 603 | |
| 604 | design: |
| 605 | for each ridge of visible facet |
| 606 | get neighbor of visible facet |
| 607 | if neighbor was already processed |
| 608 | delete the ridge (will delete all visible facets later) |
| 609 | if neighbor is a horizon facet |
| 610 | create a new facet |
| 611 | if neighbor coplanar |
| 612 | adds newfacet to f.samecycle for later merging |
| 613 | else |
| 614 | updates neighbor's neighbor set |
| 615 | (checks for non-simplicial facet with multiple ridges to visible facet) |
| 616 | updates neighbor's ridge set |
| 617 | (checks for simplicial neighbor to non-simplicial visible facet) |
| 618 | (deletes ridge if neighbor is simplicial) |
| 619 | |
| 620 | */ |
| 621 | facetTcxx . . $ facetT# *qh_makenew_nonsimplicialcxx . . $ qh_makenew_nonsimplicial(633f8b4f79841835).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *visible, vertexTcxx . . $ vertexT# *apex, int *numnew) { |
| 622 | void **freelistp; /* used if !qh_NOmem by qh_memfree_() */ |
| 623 | ridgeTcxx . . $ ridgeT# *ridge, **ridgep; |
| 624 | facetTcxx . . $ facetT# *neighbor, *newfacet= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *samecycle; |
| 625 | setTcxx . . $ setT# *vertices; |
| 626 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! toporient; |
| 627 | unsigned int ridgeid; |
| 628 | |
| 629 | FOREACHridge_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1032:9`!(visible->ridges) { |
| 630 | ridgeid= ridge->idcxx . . $ ridgeT#id.; |
| 631 | neighbor= otherfacet_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:891:9`!(ridge, visible); |
| 632 | if (neighbor->visiblecxx . . $ facetT#visible.) { |
| 633 | if (!qh->NEWtentativecxx . . $ qhT#NEWtentative.) { |
| 634 | if (neighbor->visitidcxx . . $ facetT#visitid. == qh->visit_idcxx . . $ qhT#visit_id.) { |
| 635 | if (qh->traceridgecxx . . $ qhT#traceridge. == ridge) |
| 636 | qh->traceridgecxx . . $ qhT#traceridge.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 637 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &(ridge->verticescxx . . $ ridgeT#vertices.)); /* delete on 2nd visit */ |
| 638 | qh_memfree_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:198:9`!(qh, ridge, (int)sizeof(ridgeT), freelistp); |
| 639 | } |
| 640 | } |
| 641 | }else { /* neighbor is an horizon facet */ |
| 642 | toporient= (ridge->topcxx . . $ ridgeT#top. == visible); |
| 643 | vertices= qh_setnewcxx . . $ qh_setnew(a2b89a85792cc9f6).(qh, qh->hull_dimcxx . . $ qhT#hull_dim.); /* makes sure this is quick */ |
| 644 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &vertices, apex); |
| 645 | qh_setappend_setcxx . . $ qh_setappend_set(5f861e67ea6df2db).(qh, &vertices, ridge->verticescxx . . $ ridgeT#vertices.); |
| 646 | newfacet= qh_makenewfacetcxx . . $ qh_makenewfacet(786bf0a2ea9612a9).(qh, vertices, toporient, neighbor); |
| 647 | (*numnew)++; |
| 648 | if (neighbor->coplanarhorizoncxx . . $ facetT#coplanarhorizon.) { |
| 649 | newfacet->mergehorizoncxx . . $ facetT#mergehorizon.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 650 | if (!neighbor->seencxx . . $ facetT#seen.) { |
| 651 | newfacet->fcxx . . $ facetT#f..samecyclecxx . . $ facetT#$anonymous_type_3#samecycle.= newfacet; |
| 652 | neighbor->fcxx . . $ facetT#f..newcyclecxx . . $ facetT#$anonymous_type_3#newcycle.= newfacet; |
| 653 | }else { |
| 654 | samecycle= neighbor->fcxx . . $ facetT#f..newcyclecxx . . $ facetT#$anonymous_type_3#newcycle.; |
| 655 | newfacet->fcxx . . $ facetT#f..samecyclecxx . . $ facetT#$anonymous_type_3#samecycle.= samecycle->fcxx . . $ facetT#f..samecyclecxx . . $ facetT#$anonymous_type_3#samecycle.; |
| 656 | samecycle->fcxx . . $ facetT#f..samecyclecxx . . $ facetT#$anonymous_type_3#samecycle.= newfacet; |
| 657 | } |
| 658 | } |
| 659 | if (qh->NEWtentativecxx . . $ qhT#NEWtentative.) { |
| 660 | if (!neighbor->simplicialcxx . . $ facetT#simplicial.) |
| 661 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &(newfacet->ridgescxx . . $ facetT#ridges.), ridge); |
| 662 | }else { /* qh_attachnewfacets */ |
| 663 | if (neighbor->seencxx . . $ facetT#seen.) { |
| 664 | if (neighbor->simplicialcxx . . $ facetT#simplicial.) { |
| 665 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6105, "qhull internal error (qh_makenew_nonsimplicial): simplicial f%d sharing two ridges with f%d\n", |
| 666 | neighbor->idcxx . . $ facetT#id., visible->idcxx . . $ facetT#id.); |
| 667 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, neighbor, visible); |
| 668 | } |
| 669 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &(neighbor->neighborscxx . . $ facetT#neighbors.), newfacet); |
| 670 | }else |
| 671 | qh_setreplacecxx . . $ qh_setreplace(e04772c008a00ec4).(qh, neighbor->neighborscxx . . $ facetT#neighbors., visible, newfacet); |
| 672 | if (neighbor->simplicialcxx . . $ facetT#simplicial.) { |
| 673 | qh_setdelcxx . . $ qh_setdel(117666f5f13ff3be).(neighbor->ridgescxx . . $ facetT#ridges., ridge); |
| 674 | qh_delridgecxx . . $ qh_delridge(19ea2400ed1d8228).(qh, ridge); |
| 675 | }else { |
| 676 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &(newfacet->ridgescxx . . $ facetT#ridges.), ridge); |
| 677 | if (toporient) { |
| 678 | ridge->topcxx . . $ ridgeT#top.= newfacet; |
| 679 | ridge->simplicialtopcxx . . $ ridgeT#simplicialtop.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 680 | }else { |
| 681 | ridge->bottomcxx . . $ ridgeT#bottom.= newfacet; |
| 682 | ridge->simplicialbotcxx . . $ ridgeT#simplicialbot.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4048, "qh_makenew_nonsimplicial: created facet f%d from v%d and r%d of horizon f%d\n", |
| 687 | newfacet->id, apex->id, ridgeid, neighbor->id)); |
| 688 | } |
| 689 | neighbor->seencxx . . $ facetT#seen.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 690 | } /* for each ridge */ |
| 691 | return newfacet; |
| 692 | } /* makenew_nonsimplicial */ |
| 693 | |
| 694 | #else /* qh_NOmerge */ |
| 695 | facetT *qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew) { |
| 696 | QHULL_UNUSED(qh) |
| 697 | QHULL_UNUSED(visible) |
| 698 | QHULL_UNUSED(apex) |
| 699 | QHULL_UNUSED(numnew) |
| 700 | |
| 701 | return NULL; |
| 702 | } |
| 703 | #endif /* qh_NOmerge */ |
| 704 | |
| 705 | /*-<a href="qh-poly_r.htm#TOC" |
| 706 | >-------------------------------</a><a name="makenew_simplicial">-</a> |
| 707 | |
| 708 | qh_makenew_simplicial(qh, visible, apex, numnew ) |
| 709 | make new facets for simplicial visible facet and apex |
| 710 | |
| 711 | returns: |
| 712 | attaches new facets if !qh.NEWtentative |
| 713 | neighbors between newfacet and horizon |
| 714 | |
| 715 | notes: |
| 716 | nop if neighbor->seen or neighbor->visible(see qh_makenew_nonsimplicial) |
| 717 | |
| 718 | design: |
| 719 | locate neighboring horizon facet for visible facet |
| 720 | determine vertices and orientation |
| 721 | create new facet |
| 722 | if coplanar, |
| 723 | add new facet to f.samecycle |
| 724 | update horizon facet's neighbor list |
| 725 | */ |
| 726 | facetTcxx . . $ facetT# *qh_makenew_simplicialcxx . . $ qh_makenew_simplicial(633f8b4f79841835).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *visible, vertexTcxx . . $ vertexT# *apex, int *numnew) { |
| 727 | facetTcxx . . $ facetT# *neighbor, **neighborp, *newfacet= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 728 | setTcxx . . $ setT# *vertices; |
| 729 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! flip, toporient; |
| 730 | int horizonskip= 0, visibleskip= 0; |
| 731 | |
| 732 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(visible) { |
| 733 | if (!neighbor->seencxx . . $ facetT#seen. && !neighbor->visiblecxx . . $ facetT#visible.) { |
| 734 | vertices= qh_facetintersectcxx . . $ qh_facetintersect(e5559fdcfc266cb6).(qh, neighbor,visible, &horizonskip, &visibleskip, 1); |
| 735 | SETfirst_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:378:9`!(vertices)= apex; |
| 736 | flip= ((horizonskip & 0x1) ^ (visibleskip & 0x1)); |
| 737 | if (neighbor->toporientcxx . . $ facetT#toporient.) |
| 738 | toporient= horizonskip & 0x1; |
| 739 | else |
| 740 | toporient= (horizonskip & 0x1) ^ 0x1; |
| 741 | newfacet= qh_makenewfacetcxx . . $ qh_makenewfacet(786bf0a2ea9612a9).(qh, vertices, toporient, neighbor); |
| 742 | (*numnew)++; |
| 743 | if (neighbor->coplanarhorizoncxx . . $ facetT#coplanarhorizon. && (qh->PREmergecxx . . $ qhT#PREmerge. || qh->MERGEexactcxx . . $ qhT#MERGEexact.)) { |
| 744 | #ifndef qh_NOmerge |
| 745 | newfacet->fcxx . . $ facetT#f..samecyclecxx . . $ facetT#$anonymous_type_3#samecycle.= newfacet; |
| 746 | newfacet->mergehorizoncxx . . $ facetT#mergehorizon.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 747 | #endif |
| 748 | } |
| 749 | if (!qh->NEWtentativecxx . . $ qhT#NEWtentative.) |
| 750 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(neighbor->neighbors, horizonskip)= newfacet; |
| 751 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4049, "qh_makenew_simplicial: create facet f%d top %d from v%d and horizon f%d skip %d top %d and visible f%d skip %d, flip? %d\n", |
| 752 | newfacet->id, toporient, apex->id, neighbor->id, horizonskip, |
| 753 | neighbor->toporient, visible->id, visibleskip, flip)); |
| 754 | } |
| 755 | } |
| 756 | return newfacet; |
| 757 | } /* makenew_simplicial */ |
| 758 | |
| 759 | /*-<a href="qh-poly_r.htm#TOC" |
| 760 | >-------------------------------</a><a name="matchneighbor">-</a> |
| 761 | |
| 762 | qh_matchneighbor(qh, newfacet, newskip, hashsize, hashcount ) |
| 763 | either match subridge of newfacet with neighbor or add to hash_table |
| 764 | |
| 765 | returns: |
| 766 | matched ridges of newfacet, except for duplicate ridges |
| 767 | duplicate ridges marked by qh_DUPLICATEridge for qh_matchdupridge |
| 768 | |
| 769 | notes: |
| 770 | called by qh_matchnewfacets |
| 771 | assumes newfacet is simplicial |
| 772 | ridge is newfacet->vertices w/o newskip vertex |
| 773 | do not allocate memory (need to free hash_table cleanly) |
| 774 | uses linear hash chains |
| 775 | see qh_matchdupridge (poly2_r.c) |
| 776 | |
| 777 | design: |
| 778 | for each possible matching facet in qh.hash_table |
| 779 | if vertices match |
| 780 | set ismatch, if facets have opposite orientation |
| 781 | if ismatch and matching facet doesn't have a match |
| 782 | match the facets by updating their neighbor sets |
| 783 | else |
| 784 | note: dupridge detected when a match 'f&d skip %d' has already been seen |
| 785 | need to mark all of the dupridges for qh_matchdupridge |
| 786 | indicate a duplicate ridge by qh_DUPLICATEridge and f.dupridge |
| 787 | add facet to hashtable |
| 788 | unless the other facet was already a duplicate ridge |
| 789 | mark both facets with a duplicate ridge |
| 790 | add other facet (if defined) to hash table |
| 791 | |
| 792 | state at "indicate a duplicate ridge": |
| 793 | newfacet@newskip= the argument |
| 794 | facet= the hashed facet@skip that has the same vertices as newfacet@newskip |
| 795 | same= true if matched vertices have the same orientation |
| 796 | matchfacet= neighbor at facet@skip |
| 797 | matchfacet=qh_DUPLICATEridge, matchfacet was previously detected as a dupridge of facet@skip |
| 798 | ismatch if 'vertex orientation (same) matches facet/newfacet orientation (toporient) |
| 799 | unknown facet will match later |
| 800 | |
| 801 | details at "indicate a duplicate ridge": |
| 802 | if !ismatch and matchfacet, |
| 803 | dupridge is between hashed facet@skip/matchfacet@matchskip and arg newfacet@newskip/unknown |
| 804 | set newfacet@newskip, facet@skip, and matchfacet@matchskip to qh_DUPLICATEridge |
| 805 | add newfacet and matchfacet to hash_table |
| 806 | if ismatch and matchfacet, |
| 807 | same as !ismatch and matchfacet -- it matches facet instead of matchfacet |
| 808 | if !ismatch and !matchfacet |
| 809 | dupridge between hashed facet@skip/unknown and arg newfacet@newskip/unknown |
| 810 | set newfacet@newskip and facet@skip to qh_DUPLICATEridge |
| 811 | add newfacet to hash_table |
| 812 | if ismatch and matchfacet==qh_DUPLICATEridge |
| 813 | dupridge with already duplicated hashed facet@skip and arg newfacet@newskip/unknown |
| 814 | set newfacet@newskip to qh_DUPLICATEridge |
| 815 | add newfacet to hash_table |
| 816 | facet's hyperplane already set |
| 817 | */ |
| 818 | void qh_matchneighborcxx . . $ qh_matchneighbor(891c955e8919119d).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *newfacet, int newskip, int hashsize, int *hashcount) { |
| 819 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! newfound= Falsecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:137:9`!; /* True, if new facet is already in hash chain */ |
| 820 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! same, ismatch; |
| 821 | int hash, scan; |
| 822 | facetTcxx . . $ facetT# *facet, *matchfacet; |
| 823 | int skip, matchskip; |
| 824 | |
| 825 | hash= qh_gethashcxx . . $ qh_gethash(b9618e642442736e).(qh, hashsize, newfacet->verticescxx . . $ facetT#vertices., qh->hull_dimcxx . . $ qhT#hull_dim., 1, |
| 826 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(newfacet->vertices, newskip)); |
| 827 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4050, "qh_matchneighbor: newfacet f%d skip %d hash %d hashcount %d\n", |
| 828 | newfacet->id, newskip, hash, *hashcount)); |
| 829 | zinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:428:9`!(Zhashlookup); |
| 830 | for (scan=hash; (facet= SETelemt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:358:9`!(qh->hash_table, scan, facetT)); |
| 831 | scan= (++scan >= hashsize ? 0 : scan)) { |
| 832 | if (facet == newfacet) { |
| 833 | newfound= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 834 | continue; |
| 835 | } |
| 836 | zinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:428:9`!(Zhashtests); |
| 837 | if (qh_matchverticescxx . . $ qh_matchvertices(ff25c79428d3644e).(qh, 1, newfacet->verticescxx . . $ facetT#vertices., newskip, facet->verticescxx . . $ facetT#vertices., &skip, &same)) { |
| 838 | if (SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(newfacet->vertices, newskip) == SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(facet->vertices, skip)) { |
| 839 | qh_joggle_restartcxx . . $ qh_joggle_restart(1ce62fb2aa3cd5bf).(qh, "two new facets with the same vertices"); |
| 840 | /* duplicated for multiple skips, not easily avoided */ |
| 841 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 7084, "qhull topology warning (qh_matchneighbor): will merge vertices to undo new facets -- f%d and f%d have the same vertices (skip %d, skip %d) and same horizon ridges to f%d and f%d\n", |
| 842 | facet->idcxx . . $ facetT#id., newfacet->idcxx . . $ facetT#id., skip, newskip, SETfirstt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:387:9`!(facet->neighbors, facetT)->idcxx . . $ facetT#id., SETfirstt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:387:9`!(newfacet->neighbors, facetT)->idcxx . . $ facetT#id.); |
| 843 | /* will rename a vertex (QH3053). The fault was duplicate ridges (same vertices) in different facets due to a previous rename. Expensive to detect beforehand */ |
| 844 | } |
| 845 | ismatch= (same == (boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`!)((newfacet->toporientcxx . . $ facetT#toporient. ^ facet->toporientcxx . . $ facetT#toporient.))); |
| 846 | matchfacet= SETelemt_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:358:9`!(facet->neighbors, skip, facetT); |
| 847 | if (ismatch && !matchfacet) { |
| 848 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(facet->neighbors, skip)= newfacet; |
| 849 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(newfacet->neighbors, newskip)= facet; |
| 850 | (*hashcount)--; |
| 851 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4051, "qh_matchneighbor: f%d skip %d matched with new f%d skip %d\n", |
| 852 | facet->id, skip, newfacet->id, newskip)); |
| 853 | return; |
| 854 | } |
| 855 | if (!qh->PREmergecxx . . $ qhT#PREmerge. && !qh->MERGEexactcxx . . $ qhT#MERGEexact.) { |
| 856 | qh_joggle_restartcxx . . $ qh_joggle_restart(1ce62fb2aa3cd5bf).(qh, "a ridge with more than two neighbors"); |
| 857 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6107, "qhull topology error: facets f%d, f%d and f%d meet at a ridge with more than 2 neighbors. Can not continue due to no qh.PREmerge and no 'Qx' (MERGEexact)\n", |
| 858 | facet->idcxx . . $ facetT#id., newfacet->idcxx . . $ facetT#id., getid_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:902:9`!(matchfacet)); |
| 859 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRtopologycxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:209:9`!, facet, newfacet); |
| 860 | } |
| 861 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(newfacet->neighbors, newskip)= qh_DUPLICATEridgecxx . . $ `vendor/qhull/libqhull_r/poly_r.h:46:9`!; |
| 862 | newfacet->dupridgecxx . . $ facetT#dupridge.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 863 | qh_addhashcxx . . $ qh_addhash(ab618b2d2adda5ae).(newfacet, qh->hash_tablecxx . . $ qhT#hash_table., hashsize, hash); |
| 864 | (*hashcount)++; |
| 865 | if (matchfacet != qh_DUPLICATEridgecxx . . $ `vendor/qhull/libqhull_r/poly_r.h:46:9`!) { |
| 866 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(facet->neighbors, skip)= qh_DUPLICATEridgecxx . . $ `vendor/qhull/libqhull_r/poly_r.h:46:9`!; |
| 867 | facet->dupridgecxx . . $ facetT#dupridge.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 868 | if (matchfacet) { |
| 869 | matchskip= qh_setindexcxx . . $ qh_setindex(1cb32c02d661274).(matchfacet->neighborscxx . . $ facetT#neighbors., facet); |
| 870 | if (matchskip<0) { |
| 871 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6260, "qhull topology error (qh_matchneighbor): matchfacet f%d is in f%d neighbors but not vice versa. Can not continue.\n", |
| 872 | matchfacet->idcxx . . $ facetT#id., facet->idcxx . . $ facetT#id.); |
| 873 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRtopologycxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:209:9`!, matchfacet, facet); |
| 874 | } |
| 875 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(matchfacet->neighbors, matchskip)= qh_DUPLICATEridgecxx . . $ `vendor/qhull/libqhull_r/poly_r.h:46:9`!; /* matchskip>=0 by QH6260 */ |
| 876 | matchfacet->dupridgecxx . . $ facetT#dupridge.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 877 | qh_addhashcxx . . $ qh_addhash(ab618b2d2adda5ae).(matchfacet, qh->hash_tablecxx . . $ qhT#hash_table., hashsize, hash); |
| 878 | *hashcount += 2; |
| 879 | } |
| 880 | } |
| 881 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4052, "qh_matchneighbor: new f%d skip %d duplicates ridge for f%d skip %d matching f%d ismatch %d at hash %d\n", |
| 882 | newfacet->id, newskip, facet->id, skip, |
| 883 | (matchfacet == qh_DUPLICATEridge ? -2 : getid_(matchfacet)), |
| 884 | ismatch, hash)); |
| 885 | return; /* end of duplicate ridge */ |
| 886 | } |
| 887 | } |
| 888 | if (!newfound) |
| 889 | SETelem_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:347:9`!(qh->hash_table, scan)= newfacet; /* same as qh_addhash */ |
| 890 | (*hashcount)++; |
| 891 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4053, "qh_matchneighbor: no match for f%d skip %d at hash %d\n", |
| 892 | newfacet->id, newskip, hash)); |
| 893 | } /* matchneighbor */ |
| 894 | |
| 895 | |
| 896 | /*-<a href="qh-poly_r.htm#TOC" |
| 897 | >-------------------------------</a><a name="matchnewfacets">-</a> |
| 898 | |
| 899 | qh_matchnewfacets(qh ) |
| 900 | match new facets in qh.newfacet_list to their newfacet neighbors |
| 901 | all facets are simplicial |
| 902 | |
| 903 | returns: |
| 904 | if dupridges and merging |
| 905 | returns maxdupdist (>=0.0) from vertex to opposite facet |
| 906 | sets facet->dupridge |
| 907 | missing neighbor links identify dupridges to be merged (qh_DUPLICATEridge) |
| 908 | else |
| 909 | qh.newfacet_list with full neighbor sets |
| 910 | vertices for the nth neighbor match all but the nth vertex |
| 911 | if not merging and qh.FORCEoutput |
| 912 | for facets with normals (i.e., with dupridges) |
| 913 | sets facet->flippped for flipped normals, also prevents point partitioning |
| 914 | |
| 915 | notes: |
| 916 | called by qh_buildcone* and qh_triangulate_facet |
| 917 | neighbor[0] of new facets is the horizon facet |
| 918 | if NEWtentative, new facets not attached to the horizon |
| 919 | assumes qh.hash_table is NULL |
| 920 | vertex->neighbors has not been updated yet |
| 921 | do not allocate memory after qh.hash_table (need to free it cleanly) |
| 922 | |
| 923 | design: |
| 924 | truncate neighbor sets to horizon facet for all new facets |
| 925 | initialize a hash table |
| 926 | for all new facets |
| 927 | match facet with neighbors |
| 928 | if unmatched facets (due to duplicate ridges) |
| 929 | for each new facet with a duplicate ridge |
| 930 | try to match facets with the same coplanar horizon |
| 931 | if not all matched |
| 932 | for each new facet with a duplicate ridge |
| 933 | match it with a coplanar facet, or identify a pinched vertex |
| 934 | if not merging and qh.FORCEoutput |
| 935 | check for flipped facets |
| 936 | */ |
| 937 | coordTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:89:9`! qh_matchnewfacetscxx . . $ qh_matchnewfacets(733abb61795913aa).(qhTcxx . . $ qhT# *qh /* qh.newfacet_list */) { |
| 938 | int numnew=0, hashcount=0, newskip; |
| 939 | facetTcxx . . $ facetT# *newfacet, *neighbor; |
| 940 | coordTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:89:9`! maxdupdist= 0.0, maxdist2; |
| 941 | int dim= qh->hull_dimcxx . . $ qhT#hull_dim., hashsize, neighbor_i, neighbor_n; |
| 942 | setTcxx . . $ setT# *neighbors; |
| 943 | #ifndef qh_NOtracecxx . . $ `vendor/qhull/libqhull_r/user_r.h:627:9`! |
| 944 | int facet_i, facet_n, numunused= 0; |
| 945 | facetT *facet; |
| 946 | #endif |
| 947 | |
| 948 | trace1cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:88:9`!((qh, qh->ferr, 1019, "qh_matchnewfacets: match neighbors for new facets.\n")); |
| 949 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 950 | numnew++; |
| 951 | { /* inline qh_setzero(qh, newfacet->neighbors, 1, qh->hull_dim); */ |
| 952 | neighbors= newfacet->neighborscxx . . $ facetT#neighbors.; |
| 953 | neighbors->ecxx . . $ setT#e.[neighbors->maxsizecxx . . $ setT#maxsize.].icxx . . $ setelemT#i.= dim+1; /*may be overwritten*/ |
| 954 | memsetcxx . . $ memset(d1de1e4fb215f1c6).((char *)SETelemaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:369:9`!(neighbors, 1, void), 0, (size_tcxx . . $ size_t#)(dim * SETelemsizecxx . . $ `vendor/qhull/libqhull_r/qset_r.h:105:9`!)); |
| 955 | } |
| 956 | } |
| 957 | |
| 958 | qh_newhashtablecxx . . $ qh_newhashtable(1ab78c06be7805d2).(qh, numnew*(qh->hull_dimcxx . . $ qhT#hull_dim.-1)); /* twice what is normally needed, |
| 959 | but every ridge could be DUPLICATEridge */ |
| 960 | hashsize= qh_setsizecxx . . $ qh_setsize(8330125fbf155b5c).(qh, qh->hash_tablecxx . . $ qhT#hash_table.); |
| 961 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 962 | if (!newfacet->simplicialcxx . . $ facetT#simplicial.) { |
| 963 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6377, "qhull internal error (qh_matchnewfacets): expecting simplicial facets on qh.newfacet_list f%d for qh_matchneighbors, qh_matchneighbor, and qh_matchdupridge. Got non-simplicial f%d\n", |
| 964 | qh->newfacet_listcxx . . $ qhT#newfacet_list.->idcxx . . $ facetT#id., newfacet->idcxx . . $ facetT#id.); |
| 965 | qh_errexit2cxx . . $ qh_errexit2(229677952110e8f5).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, newfacet, qh->newfacet_listcxx . . $ qhT#newfacet_list.); |
| 966 | } |
| 967 | for (newskip=1; newskip<qh->hull_dimcxx . . $ qhT#hull_dim.; newskip++) /* furthest/horizon already matched */ |
| 968 | /* hashsize>0 because hull_dim>1 and numnew>0 */ |
| 969 | qh_matchneighborcxx . . $ qh_matchneighbor(891c955e8919119d).(qh, newfacet, newskip, hashsize, &hashcount); |
| 970 | #if 0 /* use the following to trap hashcount errors */ |
| 971 | { |
| 972 | int count= 0, k; |
| 973 | facetT *facet, *neighbor; |
| 974 | |
| 975 | count= 0; |
| 976 | FORALLfacet_(qh->newfacet_list) { /* newfacet already in use */ |
| 977 | for (k=1; k < qh->hull_dim; k++) { |
| 978 | neighbor= SETelemt_(facet->neighbors, k, facetT); |
| 979 | if (!neighbor || neighbor == qh_DUPLICATEridge) |
| 980 | count++; |
| 981 | } |
| 982 | if (facet == newfacet) |
| 983 | break; |
| 984 | } |
| 985 | if (count != hashcount) { |
| 986 | qh_fprintf(qh, qh->ferr, 6266, "qhull error (qh_matchnewfacets): after adding facet %d, hashcount %d != count %d\n", |
| 987 | newfacet->id, hashcount, count); |
| 988 | qh_errexit(qh, qh_ERRdebug, newfacet, NULL); |
| 989 | } |
| 990 | } |
| 991 | #endif /* end of trap code */ |
| 992 | } /* end FORALLnew_facets */ |
| 993 | if (hashcount) { /* all neighbors matched, except for qh_DUPLICATEridge neighbors */ |
| 994 | qh_joggle_restartcxx . . $ qh_joggle_restart(1ce62fb2aa3cd5bf).(qh, "ridge with multiple neighbors"); |
| 995 | if (hashcount) { |
| 996 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 997 | if (newfacet->dupridgecxx . . $ facetT#dupridge.) { |
| 998 | FOREACHneighbor_i_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1080:9`!(qh, newfacet) { |
| 999 | if (neighbor == qh_DUPLICATEridgecxx . . $ `vendor/qhull/libqhull_r/poly_r.h:46:9`!) { |
| 1000 | maxdist2= qh_matchdupridgecxx . . $ qh_matchdupridge(7b1396f289d61210).(qh, newfacet, neighbor_i, hashsize, &hashcount); |
| 1001 | maximize_cxx . . $ `vendor/qhull/libqhull_r/geom_r.h:51:9`!(maxdupdist, maxdist2); |
| 1002 | } |
| 1003 | } |
| 1004 | } |
| 1005 | } |
| 1006 | } |
| 1007 | } |
| 1008 | if (hashcount) { |
| 1009 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 6108, "qhull internal error (qh_matchnewfacets): %d neighbors did not match up\n", |
| 1010 | hashcount); |
| 1011 | qh_printhashtablecxx . . $ qh_printhashtable(92be47226f66e56f).(qh, qh->ferrcxx . . $ qhT#ferr.); |
| 1012 | qh_errexitcxx . . $ qh_errexit(6867cd51ab709aa0).(qh, qh_ERRqhullcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:207:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1013 | } |
| 1014 | #ifndef qh_NOtracecxx . . $ `vendor/qhull/libqhull_r/user_r.h:627:9`! |
| 1015 | if (qh->IStracing >= 3) { |
| 1016 | FOREACHfacet_i_(qh, qh->hash_table) { |
| 1017 | if (!facet) |
| 1018 | numunused++; |
| 1019 | } |
| 1020 | qh_fprintf(qh, qh->ferr, 3063, "qh_matchnewfacets: maxdupdist %2.2g, new facets %d, unused hash entries %d, hashsize %d\n", |
| 1021 | maxdupdist, numnew, numunused, qh_setsize(qh, qh->hash_table)); |
| 1022 | } |
| 1023 | #endif /* !qh_NOtrace */ |
| 1024 | qh_setfreecxx . . $ qh_setfree(8a9e83df9950f349).(qh, &qh->hash_tablecxx . . $ qhT#hash_table.); |
| 1025 | if (qh->PREmergecxx . . $ qhT#PREmerge. || qh->MERGEexactcxx . . $ qhT#MERGEexact.) { |
| 1026 | if (qh->IStracingcxx . . $ qhT#IStracing. >= 4) |
| 1027 | qh_printfacetlistcxx . . $ qh_printfacetlist(6a91645e88e2e23a).(qh, qh->newfacet_listcxx . . $ qhT#newfacet_list., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, qh_ALLcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:189:9`!); |
| 1028 | } |
| 1029 | return maxdupdist; |
| 1030 | } /* matchnewfacets */ |
| 1031 | |
| 1032 | |
| 1033 | /*-<a href="qh-poly_r.htm#TOC" |
| 1034 | >-------------------------------</a><a name="matchvertices">-</a> |
| 1035 | |
| 1036 | qh_matchvertices(qh, firstindex, verticesA, skipA, verticesB, skipB, same ) |
| 1037 | tests whether vertices match with a single skip |
| 1038 | starts match at firstindex since all new facets have a common vertex |
| 1039 | |
| 1040 | returns: |
| 1041 | true if matched vertices |
| 1042 | skip index for skipB |
| 1043 | sets same iff vertices have the same orientation |
| 1044 | |
| 1045 | notes: |
| 1046 | called by qh_matchneighbor and qh_matchdupridge |
| 1047 | assumes skipA is in A and both sets are the same size |
| 1048 | |
| 1049 | design: |
| 1050 | set up pointers |
| 1051 | scan both sets checking for a match |
| 1052 | test orientation |
| 1053 | */ |
| 1054 | boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! qh_matchverticescxx . . $ qh_matchvertices(ff25c79428d3644e).(qhTcxx . . $ qhT# *qh, int firstindex, setTcxx . . $ setT# *verticesA, int skipA, |
| 1055 | setTcxx . . $ setT# *verticesB, int *skipB, boolTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:130:9`! *same) { |
| 1056 | vertexTcxx . . $ vertexT# **elemAp, **elemBp, **skipBp=NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, **skipAp; |
| 1057 | |
| 1058 | elemAp= SETelemaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:369:9`!(verticesA, firstindex, vertexT); |
| 1059 | elemBp= SETelemaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:369:9`!(verticesB, firstindex, vertexT); |
| 1060 | skipAp= SETelemaddr_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:369:9`!(verticesA, skipA, vertexT); |
| 1061 | do if (elemAp != skipAp) { |
| 1062 | while (*elemAp != *elemBp++) { |
| 1063 | if (skipBp) |
| 1064 | return Falsecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:137:9`!; |
| 1065 | skipBp= elemBp; /* one extra like FOREACH */ |
| 1066 | } |
| 1067 | }while (*(++elemAp)); |
| 1068 | if (!skipBp) |
| 1069 | skipBp= ++elemBp; |
| 1070 | *skipB= SETindex_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:324:9`!(verticesB, skipB); /* i.e., skipBp - verticesB |
| 1071 | verticesA and verticesB are the same size, otherwise trace4 may segfault */ |
| 1072 | *same= !((skipA & 0x1) ^ (*skipB & 0x1)); /* result is 0 or 1 */ |
| 1073 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4054, "qh_matchvertices: matched by skip %d(v%d) and skip %d(v%d) same? %d\n", |
| 1074 | skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same)); |
| 1075 | return(Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!); |
| 1076 | } /* matchvertices */ |
| 1077 | |
| 1078 | /*-<a href="qh-poly_r.htm#TOC" |
| 1079 | >-------------------------------</a><a name="newfacet">-</a> |
| 1080 | |
| 1081 | qh_newfacet(qh) |
| 1082 | return a new facet |
| 1083 | |
| 1084 | returns: |
| 1085 | all fields initialized or cleared (NULL) |
| 1086 | preallocates neighbors set |
| 1087 | */ |
| 1088 | facetTcxx . . $ facetT# *qh_newfacetcxx . . $ qh_newfacet(5ab391dae1598d95).(qhTcxx . . $ qhT# *qh) { |
| 1089 | facetTcxx . . $ facetT# *facet; |
| 1090 | void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */ |
| 1091 | |
| 1092 | qh_memalloc_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:168:9`!(qh, (int)sizeof(facetT), freelistp, facet, facetT); |
| 1093 | memsetcxx . . $ memset(d1de1e4fb215f1c6).((char *)facet, (size_tcxx . . $ size_t#)0, sizeof(facetTcxx . . $ facetT#)); |
| 1094 | if (qh->facet_idcxx . . $ qhT#facet_id. == qh->tracefacet_idcxx . . $ qhT#tracefacet_id.) |
| 1095 | qh->tracefacetcxx . . $ qhT#tracefacet.= facet; |
| 1096 | facet->idcxx . . $ facetT#id.= qh->facet_idcxx . . $ qhT#facet_id.++; |
| 1097 | facet->neighborscxx . . $ facetT#neighbors.= qh_setnewcxx . . $ qh_setnew(a2b89a85792cc9f6).(qh, qh->hull_dimcxx . . $ qhT#hull_dim.); |
| 1098 | #if !qh_COMPUTEfurthestcxx . . $ `vendor/qhull/libqhull_r/user_r.h:565:9`! |
| 1099 | facet->furthestdistcxx . . $ facetT#furthestdist.= 0.0; |
| 1100 | #endif |
| 1101 | #if qh_MAXoutsidecxx . . $ `vendor/qhull/libqhull_r/user_r.h:589:9`! |
| 1102 | if (qh->FORCEoutputcxx . . $ qhT#FORCEoutput. && qh->APPROXhullcxx . . $ qhT#APPROXhull.) |
| 1103 | facet->maxoutsidecxx . . $ facetT#maxoutside.= qh->MINoutsidecxx . . $ qhT#MINoutside.; |
| 1104 | else |
| 1105 | facet->maxoutsidecxx . . $ facetT#maxoutside.= qh->DISTroundcxx . . $ qhT#DISTround.; /* same value as test for QH7082 */ |
| 1106 | #endif |
| 1107 | facet->simplicialcxx . . $ facetT#simplicial.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1108 | facet->goodcxx . . $ facetT#good.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1109 | facet->newfacetcxx . . $ facetT#newfacet.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1110 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4055, "qh_newfacet: created facet f%d\n", facet->id)); |
| 1111 | return(facet); |
| 1112 | } /* newfacet */ |
| 1113 | |
| 1114 | |
| 1115 | /*-<a href="qh-poly_r.htm#TOC" |
| 1116 | >-------------------------------</a><a name="newridge">-</a> |
| 1117 | |
| 1118 | qh_newridge() |
| 1119 | return a new ridge |
| 1120 | notes: |
| 1121 | caller sets qh.traceridge |
| 1122 | */ |
| 1123 | ridgeTcxx . . $ ridgeT# *qh_newridgecxx . . $ qh_newridge(9675d035e3b396f6).(qhTcxx . . $ qhT# *qh) { |
| 1124 | ridgeTcxx . . $ ridgeT# *ridge; |
| 1125 | void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */ |
| 1126 | |
| 1127 | qh_memalloc_cxx . . $ `vendor/qhull/libqhull_r/mem_r.h:168:9`!(qh, (int)sizeof(ridgeT), freelistp, ridge, ridgeT); |
| 1128 | memsetcxx . . $ memset(d1de1e4fb215f1c6).((char *)ridge, (size_tcxx . . $ size_t#)0, sizeof(ridgeTcxx . . $ ridgeT#)); |
| 1129 | zinc_cxx . . $ `vendor/qhull/libqhull_r/stat_r.h:428:9`!(Ztotridges); |
| 1130 | if (qh->ridge_idcxx . . $ qhT#ridge_id. == UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!) { |
| 1131 | qh_fprintfcxx . . $ qh_fprintf(8ec5d2aaf35eb28b).(qh, qh->ferrcxx . . $ qhT#ferr., 7074, "qhull warning: more than 2^32 ridges. Qhull results are OK. Since the ridge ID wraps around to 0, two ridges may have the same identifier.\n"); |
| 1132 | } |
| 1133 | ridge->idcxx . . $ ridgeT#id.= qh->ridge_idcxx . . $ qhT#ridge_id.++; |
| 1134 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4056, "qh_newridge: created ridge r%d\n", ridge->id)); |
| 1135 | return(ridge); |
| 1136 | } /* newridge */ |
| 1137 | |
| 1138 | |
| 1139 | /*-<a href="qh-poly_r.htm#TOC" |
| 1140 | >-------------------------------</a><a name="pointid">-</a> |
| 1141 | |
| 1142 | qh_pointid(qh, point ) |
| 1143 | return id for a point, |
| 1144 | returns qh_IDnone(-3) if null, qh_IDinterior(-2) if interior, or qh_IDunknown(-1) if not known |
| 1145 | |
| 1146 | alternative code if point is in qh.first_point... |
| 1147 | unsigned long id; |
| 1148 | id= ((unsigned long)point - (unsigned long)qh.first_point)/qh.normal_size; |
| 1149 | |
| 1150 | notes: |
| 1151 | Valid points are non-negative |
| 1152 | WARN64 -- id truncated to 32-bits, at most 2G points |
| 1153 | NOerrors returned (QhullPoint::id) |
| 1154 | if point not in point array |
| 1155 | the code does a comparison of unrelated pointers. |
| 1156 | */ |
| 1157 | int qh_pointidcxx . . $ qh_pointid(dcb1157715d34ae8).(qhTcxx . . $ qhT# *qh, pointTcxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:105:9`! *point) { |
| 1158 | ptr_intTcxx . . $ ptr_intT# offset, id; |
| 1159 | |
| 1160 | if (!point || !qh) |
| 1161 | return qh_IDnonecxx . . $ qh_IDnone.; |
| 1162 | else if (point == qh->interior_pointcxx . . $ qhT#interior_point.) |
| 1163 | return qh_IDinteriorcxx . . $ qh_IDinterior.; |
| 1164 | else if (point >= qh->first_pointcxx . . $ qhT#first_point. |
| 1165 | && point < qh->first_pointcxx . . $ qhT#first_point. + qh->num_pointscxx . . $ qhT#num_points. * qh->hull_dimcxx . . $ qhT#hull_dim.) { |
| 1166 | offset= (ptr_intTcxx . . $ ptr_intT#)(point - qh->first_pointcxx . . $ qhT#first_point.); |
| 1167 | id= offset / qh->hull_dimcxx . . $ qhT#hull_dim.; |
| 1168 | }else if ((id= qh_setindexcxx . . $ qh_setindex(1cb32c02d661274).(qh->other_pointscxx . . $ qhT#other_points., point)) != -1) |
| 1169 | id += qh->num_pointscxx . . $ qhT#num_points.; |
| 1170 | else |
| 1171 | return qh_IDunknowncxx . . $ qh_IDunknown.; |
| 1172 | return (int)id; |
| 1173 | } /* pointid */ |
| 1174 | |
| 1175 | /*-<a href="qh-poly_r.htm#TOC" |
| 1176 | >-------------------------------</a><a name="removefacet">-</a> |
| 1177 | |
| 1178 | qh_removefacet(qh, facet ) |
| 1179 | unlinks facet from qh.facet_list, |
| 1180 | |
| 1181 | returns: |
| 1182 | updates qh.facet_list .newfacet_list .facet_next visible_list |
| 1183 | decrements qh.num_facets |
| 1184 | |
| 1185 | see: |
| 1186 | qh_appendfacet |
| 1187 | */ |
| 1188 | void qh_removefacetcxx . . $ qh_removefacet(6436bdf99f629b76).(qhTcxx . . $ qhT# *qh, facetTcxx . . $ facetT# *facet) { |
| 1189 | facetTcxx . . $ facetT# *next= facet->nextcxx . . $ facetT#next., *previous= facet->previouscxx . . $ facetT#previous.; /* next is always defined */ |
| 1190 | |
| 1191 | if (facet == qh->newfacet_listcxx . . $ qhT#newfacet_list.) |
| 1192 | qh->newfacet_listcxx . . $ qhT#newfacet_list.= next; |
| 1193 | if (facet == qh->facet_nextcxx . . $ qhT#facet_next.) |
| 1194 | qh->facet_nextcxx . . $ qhT#facet_next.= next; |
| 1195 | if (facet == qh->visible_listcxx . . $ qhT#visible_list.) |
| 1196 | qh->visible_listcxx . . $ qhT#visible_list.= next; |
| 1197 | if (previous) { |
| 1198 | previous->nextcxx . . $ facetT#next.= next; |
| 1199 | next->previouscxx . . $ facetT#previous.= previous; |
| 1200 | }else { /* 1st facet in qh->facet_list */ |
| 1201 | qh->facet_listcxx . . $ qhT#facet_list.= next; |
| 1202 | qh->facet_listcxx . . $ qhT#facet_list.->previouscxx . . $ facetT#previous.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1203 | } |
| 1204 | qh->num_facetscxx . . $ qhT#num_facets.--; |
| 1205 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4057, "qh_removefacet: removed f%d from facet_list, newfacet_list, and visible_list\n", facet->id)); |
| 1206 | } /* removefacet */ |
| 1207 | |
| 1208 | |
| 1209 | /*-<a href="qh-poly_r.htm#TOC" |
| 1210 | >-------------------------------</a><a name="removevertex">-</a> |
| 1211 | |
| 1212 | qh_removevertex(qh, vertex ) |
| 1213 | unlinks vertex from qh.vertex_list, |
| 1214 | |
| 1215 | returns: |
| 1216 | updates qh.vertex_list .newvertex_list |
| 1217 | decrements qh.num_vertices |
| 1218 | */ |
| 1219 | void qh_removevertexcxx . . $ qh_removevertex(3be63de346aefe7d).(qhTcxx . . $ qhT# *qh, vertexTcxx . . $ vertexT# *vertex) { |
| 1220 | vertexTcxx . . $ vertexT# *next= vertex->nextcxx . . $ vertexT#next., *previous= vertex->previouscxx . . $ vertexT#previous.; /* next is always defined */ |
| 1221 | |
| 1222 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4058, "qh_removevertex: remove v%d from qh.vertex_list\n", vertex->id)); |
| 1223 | if (vertex == qh->newvertex_listcxx . . $ qhT#newvertex_list.) |
| 1224 | qh->newvertex_listcxx . . $ qhT#newvertex_list.= next; |
| 1225 | if (previous) { |
| 1226 | previous->nextcxx . . $ vertexT#next.= next; |
| 1227 | next->previouscxx . . $ vertexT#previous.= previous; |
| 1228 | }else { /* 1st vertex in qh->vertex_list */ |
| 1229 | qh->vertex_listcxx . . $ qhT#vertex_list.= next; |
| 1230 | qh->vertex_listcxx . . $ qhT#vertex_list.->previouscxx . . $ vertexT#previous.= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1231 | } |
| 1232 | qh->num_verticescxx . . $ qhT#num_vertices.--; |
| 1233 | } /* removevertex */ |
| 1234 | |
| 1235 | |
| 1236 | /*-<a href="qh-poly_r.htm#TOC" |
| 1237 | >-------------------------------</a><a name="update_vertexneighbors">-</a> |
| 1238 | |
| 1239 | qh_update_vertexneighbors(qh ) |
| 1240 | update vertex neighbors and delete interior vertices |
| 1241 | |
| 1242 | returns: |
| 1243 | if qh.VERTEXneighbors, |
| 1244 | if qh.newvertex_list, |
| 1245 | removes visible neighbors from vertex neighbors |
| 1246 | if qh.newfacet_list |
| 1247 | adds new facets to vertex neighbors |
| 1248 | if qh.visible_list |
| 1249 | interior vertices added to qh.del_vertices for later partitioning as coplanar points |
| 1250 | if not qh.VERTEXneighbors (not merging) |
| 1251 | interior vertices of visible facets added to qh.del_vertices for later partitioning as coplanar points |
| 1252 | |
| 1253 | notes |
| 1254 | [jan'19] split off qh_update_vertexneighbors_cone. Optimize the remaining cases in a future release |
| 1255 | called by qh_triangulate_facet after triangulating a non-simplicial facet, followed by reset_lists |
| 1256 | called by qh_triangulate after triangulating null and mirror facets |
| 1257 | called by qh_all_vertexmerges after calling qh_merge_pinchedvertices |
| 1258 | |
| 1259 | design: |
| 1260 | if qh.VERTEXneighbors |
| 1261 | for each vertex on newvertex_list (i.e., new vertices and vertices of new facets) |
| 1262 | delete visible facets from vertex neighbors |
| 1263 | for each new facet on newfacet_list |
| 1264 | for each vertex of facet |
| 1265 | append facet to vertex neighbors |
| 1266 | for each visible facet on qh.visible_list |
| 1267 | for each vertex of facet |
| 1268 | if the vertex is not on a new facet and not itself deleted |
| 1269 | if the vertex has a not-visible neighbor (due to merging) |
| 1270 | remove the visible facet from the vertex's neighbors |
| 1271 | otherwise |
| 1272 | add the vertex to qh.del_vertices for later deletion |
| 1273 | |
| 1274 | if not qh.VERTEXneighbors (not merging) |
| 1275 | for each vertex of a visible facet |
| 1276 | if the vertex is not on a new facet and not itself deleted |
| 1277 | add the vertex to qh.del_vertices for later deletion |
| 1278 | */ |
| 1279 | void qh_update_vertexneighborscxx . . $ qh_update_vertexneighbors(fb32973c8cc8eae9).(qhTcxx . . $ qhT# *qh /* qh.newvertex_list, newfacet_list, visible_list */) { |
| 1280 | facetTcxx . . $ facetT# *newfacet= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *neighbor, **neighborp, *visible; |
| 1281 | vertexTcxx . . $ vertexT# *vertex, **vertexp; |
| 1282 | int neighborcount= 0; |
| 1283 | |
| 1284 | if (qh->VERTEXneighborscxx . . $ qhT#VERTEXneighbors.) { |
| 1285 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3013, "qh_update_vertexneighbors: update v.neighbors for qh.newvertex_list (v%d) and qh.newfacet_list (f%d)\n", |
| 1286 | getid_(qh->newvertex_list), getid_(qh->newfacet_list))); |
| 1287 | FORALLvertex_cxx . . $ `vendor/qhull/libqhull_r/poly_r.h:102:9`!(qh->newvertex_list) { |
| 1288 | neighborcount= 0; |
| 1289 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(vertex) { |
| 1290 | if (neighbor->visiblecxx . . $ facetT#visible.) { |
| 1291 | neighborcount++; |
| 1292 | SETref_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:335:9`!(neighbor)= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1293 | } |
| 1294 | } |
| 1295 | if (neighborcount) { |
| 1296 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4046, "qh_update_vertexneighbors: delete %d of %d vertex neighbors for v%d. Removes to-be-deleted, visible facets\n", |
| 1297 | neighborcount, qh_setsize(qh, vertex->neighbors), vertex->id)); |
| 1298 | qh_setcompactcxx . . $ qh_setcompact(8608e985da769b75).(qh, vertex->neighborscxx . . $ vertexT#neighbors.); |
| 1299 | } |
| 1300 | } |
| 1301 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 1302 | if (qh->first_newfacetcxx . . $ qhT#first_newfacet. && newfacet->idcxx . . $ facetT#id. >= qh->first_newfacetcxx . . $ qhT#first_newfacet.) { |
| 1303 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(newfacet->vertices) |
| 1304 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &vertex->neighborscxx . . $ vertexT#neighbors., newfacet); |
| 1305 | }else { /* called after qh_merge_pinchedvertices. In 7-D, many more neighbors than new facets. qh_setin is expensive */ |
| 1306 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(newfacet->vertices) |
| 1307 | qh_setuniquecxx . . $ qh_setunique(5a401bdcd6f32747).(qh, &vertex->neighborscxx . . $ vertexT#neighbors., newfacet); |
| 1308 | } |
| 1309 | } |
| 1310 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3058, "qh_update_vertexneighbors: delete interior vertices for qh.visible_list (f%d)\n", |
| 1311 | getid_(qh->visible_list))); |
| 1312 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 1313 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(visible->vertices) { |
| 1314 | if (!vertex->newfacetcxx . . $ vertexT#newfacet. && !vertex->deletedcxx . . $ vertexT#deleted.) { |
| 1315 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(vertex) { /* this can happen under merging */ |
| 1316 | if (!neighbor->visiblecxx . . $ facetT#visible.) |
| 1317 | break; |
| 1318 | } |
| 1319 | if (neighbor) |
| 1320 | qh_setdelcxx . . $ qh_setdel(117666f5f13ff3be).(vertex->neighborscxx . . $ vertexT#neighbors., visible); |
| 1321 | else { |
| 1322 | vertex->deletedcxx . . $ vertexT#deleted.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1323 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &qh->del_verticescxx . . $ qhT#del_vertices., vertex); |
| 1324 | trace2cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:89:9`!((qh, qh->ferr, 2041, "qh_update_vertexneighbors: delete interior vertex p%d(v%d) of visible f%d\n", |
| 1325 | qh_pointid(qh, vertex->point), vertex->id, visible->id)); |
| 1326 | } |
| 1327 | } |
| 1328 | } |
| 1329 | } |
| 1330 | }else { /* !VERTEXneighbors */ |
| 1331 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3058, "qh_update_vertexneighbors: delete old vertices for qh.visible_list (f%d)\n", |
| 1332 | getid_(qh->visible_list))); |
| 1333 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 1334 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(visible->vertices) { |
| 1335 | if (!vertex->newfacetcxx . . $ vertexT#newfacet. && !vertex->deletedcxx . . $ vertexT#deleted.) { |
| 1336 | vertex->deletedcxx . . $ vertexT#deleted.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1337 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &qh->del_verticescxx . . $ qhT#del_vertices., vertex); |
| 1338 | trace2cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:89:9`!((qh, qh->ferr, 2042, "qh_update_vertexneighbors: will delete interior vertex p%d(v%d) of visible f%d\n", |
| 1339 | qh_pointid(qh, vertex->point), vertex->id, visible->id)); |
| 1340 | } |
| 1341 | } |
| 1342 | } |
| 1343 | } |
| 1344 | } /* update_vertexneighbors */ |
| 1345 | |
| 1346 | /*-<a href="qh-poly_r.htm#TOC" |
| 1347 | >-------------------------------</a><a name="update_vertexneighbors_cone">-</a> |
| 1348 | |
| 1349 | qh_update_vertexneighbors_cone(qh ) |
| 1350 | update vertex neighbors for a cone of new facets and delete interior vertices |
| 1351 | |
| 1352 | returns: |
| 1353 | if qh.VERTEXneighbors, |
| 1354 | if qh.newvertex_list, |
| 1355 | removes visible neighbors from vertex neighbors |
| 1356 | if qh.newfacet_list |
| 1357 | adds new facets to vertex neighbors |
| 1358 | if qh.visible_list |
| 1359 | interior vertices added to qh.del_vertices for later partitioning as coplanar points |
| 1360 | if not qh.VERTEXneighbors (not merging) |
| 1361 | interior vertices of visible facets added to qh.del_vertices for later partitioning as coplanar points |
| 1362 | |
| 1363 | notes |
| 1364 | called by qh_addpoint after create cone and before premerge |
| 1365 | |
| 1366 | design: |
| 1367 | if qh.VERTEXneighbors |
| 1368 | for each vertex on newvertex_list (i.e., new vertices and vertices of new facets) |
| 1369 | delete visible facets from vertex neighbors |
| 1370 | for each new facet on newfacet_list |
| 1371 | for each vertex of facet |
| 1372 | append facet to vertex neighbors |
| 1373 | for each visible facet on qh.visible_list |
| 1374 | for each vertex of facet |
| 1375 | if the vertex is not on a new facet and not itself deleted |
| 1376 | if the vertex has a not-visible neighbor (due to merging) |
| 1377 | remove the visible facet from the vertex's neighbors |
| 1378 | otherwise |
| 1379 | add the vertex to qh.del_vertices for later deletion |
| 1380 | |
| 1381 | if not qh.VERTEXneighbors (not merging) |
| 1382 | for each vertex of a visible facet |
| 1383 | if the vertex is not on a new facet and not itself deleted |
| 1384 | add the vertex to qh.del_vertices for later deletion |
| 1385 | |
| 1386 | */ |
| 1387 | void qh_update_vertexneighbors_conecxx . . $ qh_update_vertexneighbors_cone(fb32973c8cc8eae9).(qhTcxx . . $ qhT# *qh /* qh.newvertex_list, newfacet_list, visible_list */) { |
| 1388 | facetTcxx . . $ facetT# *newfacet= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, *neighbor, **neighborp, *visible; |
| 1389 | vertexTcxx . . $ vertexT# *vertex, **vertexp; |
| 1390 | int delcount= 0; |
| 1391 | |
| 1392 | if (qh->VERTEXneighborscxx . . $ qhT#VERTEXneighbors.) { |
| 1393 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3059, "qh_update_vertexneighbors_cone: update v.neighbors for qh.newvertex_list (v%d) and qh.newfacet_list (f%d)\n", |
| 1394 | getid_(qh->newvertex_list), getid_(qh->newfacet_list))); |
| 1395 | FORALLvertex_cxx . . $ `vendor/qhull/libqhull_r/poly_r.h:102:9`!(qh->newvertex_list) { |
| 1396 | delcount= 0; |
| 1397 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(vertex) { |
| 1398 | if (neighbor->visiblecxx . . $ facetT#visible.) { /* alternative design is a loop over visible facets, but needs qh_setdel() */ |
| 1399 | delcount++; |
| 1400 | qh_setdelnthcxx . . $ qh_setdelnth(4711ee2c395cd458).(qh, vertex->neighborscxx . . $ vertexT#neighbors., SETindex_cxx . . $ `vendor/qhull/libqhull_r/qset_r.h:324:9`!(vertex->neighbors, neighbor)); |
| 1401 | neighborp--; /* repeat */ |
| 1402 | } |
| 1403 | } |
| 1404 | if (delcount) { |
| 1405 | trace4cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:91:9`!((qh, qh->ferr, 4021, "qh_update_vertexneighbors_cone: deleted %d visible vertexneighbors of v%d\n", |
| 1406 | delcount, vertex->id)); |
| 1407 | } |
| 1408 | } |
| 1409 | FORALLnew_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:90:9`! { |
| 1410 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(newfacet->vertices) |
| 1411 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &vertex->neighborscxx . . $ vertexT#neighbors., newfacet); |
| 1412 | } |
| 1413 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3065, "qh_update_vertexneighbors_cone: delete interior vertices, if any, for qh.visible_list (f%d)\n", |
| 1414 | getid_(qh->visible_list))); |
| 1415 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 1416 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(visible->vertices) { |
| 1417 | if (!vertex->newfacetcxx . . $ vertexT#newfacet. && !vertex->deletedcxx . . $ vertexT#deleted.) { |
| 1418 | FOREACHneighbor_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:998:9`!(vertex) { /* this can happen under merging, qh_checkfacet QH4025 */ |
| 1419 | if (!neighbor->visiblecxx . . $ facetT#visible.) |
| 1420 | break; |
| 1421 | } |
| 1422 | if (neighbor) |
| 1423 | qh_setdelcxx . . $ qh_setdel(117666f5f13ff3be).(vertex->neighborscxx . . $ vertexT#neighbors., visible); |
| 1424 | else { |
| 1425 | vertex->deletedcxx . . $ vertexT#deleted.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1426 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &qh->del_verticescxx . . $ qhT#del_vertices., vertex); |
| 1427 | trace2cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:89:9`!((qh, qh->ferr, 2102, "qh_update_vertexneighbors_cone: will delete interior vertex p%d(v%d) of visible f%d\n", |
| 1428 | qh_pointid(qh, vertex->point), vertex->id, visible->id)); |
| 1429 | } |
| 1430 | } |
| 1431 | } |
| 1432 | } |
| 1433 | }else { /* !VERTEXneighbors */ |
| 1434 | trace3cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:90:9`!((qh, qh->ferr, 3066, "qh_update_vertexneighbors_cone: delete interior vertices for qh.visible_list (f%d)\n", |
| 1435 | getid_(qh->visible_list))); |
| 1436 | FORALLvisible_facetscxx . . $ `vendor/qhull/libqhull_r/poly_r.h:114:9`! { |
| 1437 | FOREACHvertex_cxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:1049:9`!(visible->vertices) { |
| 1438 | if (!vertex->newfacetcxx . . $ vertexT#newfacet. && !vertex->deletedcxx . . $ vertexT#deleted.) { |
| 1439 | vertex->deletedcxx . . $ vertexT#deleted.= Truecxx . . $ `vendor/qhull/libqhull_r/libqhull_r.h:138:9`!; |
| 1440 | qh_setappendcxx . . $ qh_setappend(7d4389bcfd90c694).(qh, &qh->del_verticescxx . . $ qhT#del_vertices., vertex); |
| 1441 | trace2cxx . . $ `vendor/qhull/libqhull_r/qhull_ra.h:89:9`!((qh, qh->ferr, 2059, "qh_update_vertexneighbors_cone: will delete interior vertex p%d(v%d) of visible f%d\n", |
| 1442 | qh_pointid(qh, vertex->point), vertex->id, visible->id)); |
| 1443 | } |
| 1444 | } |
| 1445 | } |
| 1446 | } |
| 1447 | } /* update_vertexneighbors_cone */ |
| 1448 |