88#define PY_SSIZE_T_CLEAN
99#include " Python.h"
1010#include " numpy/ndarrayobject.h"
11+ #ifdef _MSC_VER
12+ /* The Qhull header does not declare this as extern "C", but only MSVC seems to
13+ * do name mangling on global variables. We thus need to declare this before
14+ * the header so that it treats it correctly, and doesn't mangle the name. */
15+ extern " C" {
16+ extern const char qh_version[];
17+ }
18+ #endif
1119#include " libqhull_r/qhull_ra.h"
12- #include <stdio.h >
20+ #include < cstdio >
1321
1422
1523#ifndef MPL_DEVNULL
@@ -50,17 +58,18 @@ get_facet_neighbours(const facetT* facet, const int* tri_indices,
5058 *indices++ = (neighbor->upperdelaunay ? -1 : tri_indices[neighbor->id ]);
5159}
5260
53- /* Return 1 if the specified points arrays contain at least 3 unique points,
54- * or 0 otherwise. */
55- static int
61+ /* Return true if the specified points arrays contain at least 3 unique points,
62+ * or false otherwise. */
63+ static bool
5664at_least_3_unique_points (int npoints, const double * x, const double * y)
5765{
5866 int i;
5967 const int unique1 = 0 ; /* First unique point has index 0. */
6068 int unique2 = 0 ; /* Second unique point index is 0 until set. */
6169
62- if (npoints < 3 )
63- return 0 ;
70+ if (npoints < 3 ) {
71+ return false ;
72+ }
6473
6574 for (i = 1 ; i < npoints; ++i) {
6675 if (unique2 == 0 ) {
@@ -73,20 +82,21 @@ at_least_3_unique_points(int npoints, const double* x, const double* y)
7382 if ( (x[i] != x[unique1] || y[i] != y[unique1]) &&
7483 (x[i] != x[unique2] || y[i] != y[unique2]) ) {
7584 /* 3 unique points found, with indices 0, unique2 and i. */
76- return 1 ;
85+ return true ;
7786 }
7887 }
7988 }
8089
8190 /* Run out of points before 3 unique points found. */
82- return 0 ;
91+ return false ;
8392}
8493
85- /* Delaunay implementation method. If hide_qhull_errors is 1 then qhull error
86- * messages are discarded; if it is 0 then they are written to stderr. */
94+ /* Delaunay implementation method.
95+ * If hide_qhull_errors is true then qhull error messages are discarded;
96+ * if it is false then they are written to stderr. */
8797static PyObject*
8898delaunay_impl (int npoints, const double * x, const double * y,
89- int hide_qhull_errors )
99+ bool hide_qhull_errors)
90100{
91101 qhT qh_qh; /* qh variable type and name must be like */
92102 qhT* qh = &qh_qh; /* this for Qhull macros to work correctly. */
@@ -151,8 +161,8 @@ delaunay_impl(int npoints, const double* x, const double* y,
151161
152162 /* Perform Delaunay triangulation. */
153163 qh_zero (qh, error_file);
154- exitcode = qh_new_qhull (qh , ndim , npoints , points , False ,
155- "qhull d Qt Qbb Qc Qz" , NULL , error_file );
164+ exitcode = qh_new_qhull (qh, ndim, ( int ) npoints, points, False,
165+ ( char *) " qhull d Qt Qbb Qc Qz" , NULL , error_file);
156166 if (exitcode != qh_ERRnone) {
157167 PyErr_Format (PyExc_RuntimeError,
158168 " Error in qhull Delaunay triangulation calculation: %s (exitcode=%d)%s" ,
0 commit comments