#//! Compile libqhull_r and Qhull together due to use of setjmp/longjmp()
#include "libqhullcpp/Qhull.h"
#include "libqhullcpp/QhullError.h"
#include "libqhullcpp/RboxPoints.h"
#include "libqhullcpp/QhullQh.h"
#include "libqhullcpp/QhullFacet.h"
#include "libqhullcpp/QhullFacetList.h"
#include <iostream>
usingstd::cerr;
usingstd::string;
usingstd::vector;
usingstd::ostream;
#ifdef _MSC_VER // Microsoft Visual C++ -- warning level 4
#pragma warning( disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
#pragma warning( disable : 4996) // function was declared deprecated(strcpy, localtime, etc.)
#endif
namespaceorgQhull{
#//!\name Global variables
constchars_unsupported_options[]=" Fd TI ";
constchars_not_output_options[]=" Fd TI A C d E H P Qb QbB Qbb Qc Qf Qg Qi Qm QJ Qr QR Qs Qt Qv Qx Qz Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 R Tc TC TM TP TR Tv TV TW U v V W ";
#//!\name Constructor, destructor, etc.
Qhull::
Qhull()
:qh_qh(0)
,origin_point()
,run_called(false)
,feasible_point()
{
allocateQhullQh();
}//Qhull
//! Invokes Qhull on rboxPoints
//! Same as runQhull()
//! For rbox commands, see http://www.qhull.org/html/rbox.htm or html/rbox.htm
//! For qhull commands, see http://www.qhull.org/html/qhull.htm or html/qhull.htm
for(intk=qh_qh->hull_dim;k--;){// Do not move into QH_TRY block. It may throw an error
origin_point<<0.0;
}
qh_qh->maybeThrowQhullMessage(QH_TRY_status);
}//runQhull
#//!\name Helpers -- be careful of allocating C++ objects due to setjmp/longjmp() error handling by qh_... routines
//! initialize qh.feasible_point for half-space intersection
//! Sets from qh.feasible_string if available, otherwise from Qhull::feasible_point
//! called only once from runQhull(), otherwise it leaks memory (the same as qh_setFeasible)
voidQhull::
initializeFeasiblePoint(inthulldim)
{
if(qh_qh->feasible_string){
qh_setfeasible(qh_qh,hulldim);
}else{
if(feasible_point.isEmpty()){
qh_fprintf(qh_qh,qh_qh->ferr,6209,"qhull error: missing feasible point for halfspace intersection. Use option 'Hn,n' or Qhull::setFeasiblePoint before runQhull()\n");
qh_errexit(qh_qh,qh_ERRmem,NULL,NULL);
}
if(feasible_point.size()!=(size_t)hulldim){
qh_fprintf(qh_qh,qh_qh->ferr,6210,"qhull error: dimension of feasiblePoint should be %d. It is %u",hulldim,feasible_point.size());