1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
Description: Use reentrant libqhull_r instead of deprecated libqh
The non-reentrant version has been deprecated by upstream and is no
longer built by default.
.
The reentrant version is available since qhull 2015.1. As the
old-style qhull/* headers were removed with qhull 2011.1 these are no
longer relevant.
Author: Stefan Büns <stefan.bruens@rwth-aachen.de>
Bug-Debian: https://bugs.debian.org/990397
Origin: other, https://sourceforge.net/p/plplot/bugs/196/attachment/0001-Use-reentrant-libqhull_r-instead-of-deprecated-libqh.patch
Bug: https://sourceforge.net/p/plplot/bugs/196/
Forwarded: not-needed
Reviewed-By: Rafael Laboissière <rafael@debian.org>
Last-Update: 2021-07-03
--- a/cmake/modules/FindQHULL.cmake
+++ b/cmake/modules/FindQHULL.cmake
@@ -16,27 +16,27 @@
# that is what is supplied by upstream qhull, and if the user is
# finding a local install of the upstream library below, he wants to
# access that same upstream version of the headers to be consistent.
-find_file(QHULL_HEADER_FILE NAMES libqhull/qhull_a.h qhull/qhull_a.h)
+find_file(QHULL_HEADER_FILE NAMES libqhull_r/qhull_ra.h)
if(QHULL_HEADER_FILE)
# message(STATUS "QHULL_HEADER_FILE = ${QHULL_HEADER_FILE}")
- if(QHULL_HEADER_FILE MATCHES "libqhull")
+ if(QHULL_HEADER_FILE MATCHES "libqhull_r")
set(HAS_LIBQHULL_INCLUDE ON)
- else(QHULL_HEADER_FILE MATCHES "libqhull")
+ else()
set(HAS_LIBQHULL_INCLUDE OFF)
- endif(QHULL_HEADER_FILE MATCHES "libqhull")
+ endif()
# Determine grandparent directory of header file
get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_HEADER_FILE} DIRECTORY)
get_filename_component(QHULL_INCLUDE_DIRS ${QHULL_INCLUDE_DIRS} DIRECTORY)
elseif(NOT QHULL_HEADER_FILE AND NOT QHULL_FIND_QUIETLY)
- message(STATUS "Neither qhull/qhull_a.h header nor libqhull/qhull_a.h could be found")
+ message(STATUS "libqhull_r/qhull_ra.h could not be found")
endif(QHULL_HEADER_FILE)
-find_library(QHULL_LIBRARY qhull)
+find_library(QHULL_LIBRARY qhull_r)
if( QHULL_LIBRARY )
get_filename_component(QHULL_LIBRARY_DIRS ${QHULL_LIBRARY} DIRECTORY)
set(QHULL_LIBRARIES ${QHULL_LIBRARY})
elseif(NOT QHULL_LIBRARY AND NOT QHULL_FIND_QUIETLY)
- message(STATUS "qhull library could not be found")
+ message(STATUS "qhull_r library could not be found")
endif(QHULL_LIBRARY)
find_package_handle_standard_args(QHULL
--- a/lib/nn/delaunay.c
+++ b/lib/nn/delaunay.c
@@ -34,11 +34,7 @@
#include <limits.h>
#include <float.h>
#ifdef USE_QHULL
-#ifdef HAS_LIBQHULL_INCLUDE
-#include <libqhull/qhull_a.h>
-#else
-#include <qhull/qhull_a.h>
-#endif
+#include <libqhull_r/qhull_ra.h>
#else
#include "triangle.h"
#endif
@@ -388,7 +384,10 @@
// climax
//
- exitcode = qh_new_qhull( dim, np, qpoints, ismalloc,
+ qhT context = { 0 };
+ qhT* qh = &context;
+
+ exitcode = qh_new_qhull( qh, dim, np, qpoints, ismalloc,
flags, outfile, errfile );
if ( !exitcode )
@@ -433,8 +432,8 @@
}
}
- qh_findgood_all( qh facet_list );
- qh_countfacets( qh facet_list, NULL, !qh_ALL, &numfacets,
+ qh_findgood_all( qh, qh->facet_list );
+ qh_countfacets( qh, qh->facet_list, NULL, !qh_ALL, &numfacets,
&numsimplicial, &totneighbors, &numridges,
&numcoplanars, &numtricoplanars );
@@ -462,7 +461,7 @@
j = 0;
FOREACHvertex_( facet->vertices )
- t->vids[j++] = qh_pointid( vertex->point );
+ t->vids[j++] = qh_pointid( qh, vertex->point );
j = 0;
FOREACHneighbor_( facet )
@@ -548,8 +547,8 @@
}
free( qpoints );
- qh_freeqhull( !qh_ALL ); // free long memory
- qh_memfreeshort( &curlong, &totlong ); // free short memory and memory allocator
+ qh_freeqhull( qh, !qh_ALL ); // free long memory
+ qh_memfreeshort( qh, &curlong, &totlong ); // free short memory and memory allocator
if ( curlong || totlong )
fprintf( errfile,
"qhull: did not free %d bytes of long memory (%d pieces)\n",
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -259,9 +259,9 @@
# No *.pc files for lib subdirectory libraries so must add relevant bits
# to the plplot.pc file instead.
if(QHULL_RPATH)
- list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -L${QHULL_RPATH} -lqhull)
+ list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -L${QHULL_RPATH} -lqhull_r)
else(QHULL_RPATH)
- list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -lqhull)
+ list(APPEND pc_libplplot_LINK_FLAGS -l${WRITEABLE_TARGET}csironn -lqhull_r)
endif(QHULL_RPATH)
# Needed by plgridd.c.
--- a/src/plgridd.c
+++ b/src/plgridd.c
@@ -32,11 +32,7 @@
#include "../lib/nn/nn.h"
// PLPLOT_NONN not #defined or tested for more than a decade.
#ifdef PLPLOT_NONN // another DTLI, based only on QHULL, not nn
-#ifdef HAS_LIBQHULL_INCLUDE
-#include <libqhull/qhull_a.h>
-#else //#ifdef HAS_LIBQHULL_INCLUDE
-#include <qhull/qhull_a.h>
-#endif //#ifdef HAS_LIBQHULL_INCLUDE
+#include <libqhull_r/qhull_ra.h>
#endif //#ifdef PLPLOT_NONN
#endif //#ifdef PL_HAVE_QHUL
@@ -852,8 +848,11 @@
points[i * dim + 1] = y[i];
}
+ qhT context = { 0 };
+ qhT* qh = &context;
+
#if 1 // easy way
- exitcode = qh_new_qhull( dim, npts, points, ismalloc,
+ exitcode = qh_new_qhull( qh, dim, npts, points, ismalloc,
flags, outfile, errfile );
#else
qh_init_A( stdin, stdout, stderr, 0, NULL );
@@ -899,17 +898,17 @@
#endif
// Without the setjmp(), Qhull will exit() after reporting an error
- exitcode = setjmp( qh errexit );
+ exitcode = setjmp( qh->errexit );
if ( !exitcode )
{
- qh NOerrexit = False;
+ qh->NOerrexit = False;
for ( i = 0; i < nptsx; i++ )
for ( j = 0; j < nptsy; j++ )
{
l = 0;
point[0] = xg[i];
point[1] = yg[j];
- qh_setdelaunay( 3, 1, point );
+ qh_setdelaunay( qh, 3, 1, point );
// several ways to find the triangle given a point follow.
@@ -942,7 +941,7 @@
// Another possibility is to implement the 'walking
// triangle algorithm
- facet = qh_findfacet_all( point, &bestdist, &isoutside, &totpart );
+ facet = qh_findfacet_all( qh, point, &bestdist, &isoutside, &totpart );
if ( facet->upperdelaunay )
zops->set( zgp, i, j, NaN );
@@ -950,7 +949,7 @@
{
FOREACHvertex_( facet->vertices )
{
- k = qh_pointid( vertex->point );
+ k = qh_pointid( qh, vertex->point );
xt[l] = x[k];
yt[l] = y[k];
zt[l] = z[k];
@@ -969,12 +968,12 @@
}
}
}
- qh NOerrexit = True;
+ qh->NOerrexit = True;
}
free( points );
- qh_freeqhull( !qh_ALL ); // free long memory
- qh_memfreeshort( &curlong, &totlong ); // free short memory and memory allocator
+ qh_freeqhull( qh, !qh_ALL ); // free long memory
+ qh_memfreeshort( qh, &curlong, &totlong ); // free short memory and memory allocator
if ( curlong || totlong )
fprintf( errfile,
"qhull: did not free %d bytes of long memory (%d pieces)\n",
--- a/cmake/modules/csiro.cmake
+++ b/cmake/modules/csiro.cmake
@@ -83,11 +83,7 @@
message(STATUS "WARNING: function qh_new_qhull not found. Setting PL_HAVE_QHULL to OFF.")
set(PL_HAVE_QHULL OFF CACHE BOOL "Enable use of the Qhull library" FORCE)
endif(NOT QH_NEW_EXIST)
- if(HAS_LIBQHULL_INCLUDE)
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <libqhull/qhull_a.h>")
- else(HAS_LIBQHULL_INCLUDE)
- file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <qhull/qhull_a.h>")
- endif(HAS_LIBQHULL_INCLUDE)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c "#include <libqhull_r/qhull_ra.h>")
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/Check_realT_size.c
"
int main(void)
|