Skip to content

Instantly share code, notes, and snippets.

@Abacn
Last active October 15, 2024 20:15
Show Gist options
  • Save Abacn/8f0b3ba3653f63a10b4503aeb6f83f90 to your computer and use it in GitHub Desktop.
Save Abacn/8f0b3ba3653f63a10b4503aeb6f83f90 to your computer and use it in GitHub Desktop.
Calling qhull library in C++
/* Compiling command:
g++ -o Qhullex Qhullex.cpp -lqhullstatic_r -lqhullcpp
Note:
(1) this is the minimum example (user_eg3) in qhull package, also mentioned in http://www.qhull.org/html/qh-code.htm#cpp .
However, the version on the website (Dated 03/19/2019) is inconsistent with the source code and it does not pass the compiler
(2) libqhullstatic_r is the correct library to use.
* Linking to libqhull results in runtime error
"QH6248 qh_lib_check: Incorrect qhull library called. Caller uses reentrant Qhull while library is non-reentrant";
* Linking to libqhull_r results in runtime error
"QH6231 Qhull internal error (userprintf_rbox_r.c): fp is 0. Wrong qh_fprintf_rbox called."
*/
#include <iostream>
#include <libqhullcpp/Qhull.h>
#include <libqhullcpp/QhullFacetList.h>
#include <libqhullcpp/RboxPoints.h>
using namespace std;
using namespace orgQhull;
int main(void) {
RboxPoints rbox("100");
Qhull qhull;
qhull.runQhull(rbox, "");
QhullFacetList facets = qhull.facetList();
cout<< facets;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment