12 #include "QhullError.h"
13 #include "RboxPoints.h"
15 #include "QhullFacet.h"
16 #include "QhullFacetList.h"
19 #include "../libqhull_r/qhull_ra.h"
30 #pragma warning( disable : 4611)
31 #pragma warning( disable : 4996)
39 const char s_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 ";
57 Qhull(
const RboxPoints &rboxPoints,
const char *qhullCommand2)
64 runQhull(rboxPoints, qhullCommand2);
71 Qhull(
const char *inputComment2,
int pointDimension,
int pointCount,
const realT *pointCoordinates,
const char *qhullCommand2)
78 runQhull(inputComment2, pointDimension, pointCount, pointCoordinates, qhullCommand2);
88 void *p2=
static_cast<qhT *
>(qh_qh);
89 char *
s=
static_cast<char *
>(p);
90 char *s2=
static_cast<char *
>(p2);
92 throw QhullError(10074,
"Qhull error: QhullQh at a different address than base type QhT (%d bytes). Please report compiler to qhull.org",
int(s2-
s));
100 if(qh_qh->hasQhullMessage()){
101 cerr<<
"\nQhull output at end\n";
102 cerr<< qh_qh->qhullMessage();
103 qh_qh->clearQhullMessage();
112 checkIfQhullInitialized()
115 throw QhullError(10023,
"Qhull error: checkIfQhullInitialized failed. Call runQhull() first.");
122 feasiblePoint()
const
125 if(qh_qh->feasible_point){
126 result.append(qh_qh->hull_dim, qh_qh->feasible_point);
128 result= feasible_point;
137 QhullPoint result= origin();
138 result.setDimension(qh_qh->input_dim);
146 checkIfQhullInitialized();
147 if(!qh_qh->hasAreaVolume){
149 qh_getarea(qh_qh, qh_qh->facet_list);
151 qh_qh->NOerrexit=
true;
152 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
154 return qh_qh->totarea;
159 checkIfQhullInitialized();
160 if(!qh_qh->hasAreaVolume){
162 qh_getarea(qh_qh, qh_qh->facet_list);
164 qh_qh->NOerrexit=
true;
165 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
167 return qh_qh->totvol;
176 defineVertexNeighborFacets(){
177 checkIfQhullInitialized();
178 if(!qh_qh->hasAreaVolume){
180 qh_vertexneighbors(qh_qh);
182 qh_qh->NOerrexit=
true;
183 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
187 QhullFacetList Qhull::
189 return QhullFacetList(beginFacet(), endFacet());
195 return QhullPoints(qh_qh, qh_qh->hull_dim, qh_qh->num_points*qh_qh->hull_dim, qh_qh->first_point);
198 QhullPointSet Qhull::
201 return QhullPointSet(qh_qh, qh_qh->other_points);
205 QhullVertexList Qhull::
207 return QhullVertexList(beginVertex(), endVertex());
215 checkIfQhullInitialized();
217 qh_produce_output2(qh_qh);
219 qh_qh->NOerrexit=
true;
220 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
224 outputQhull(
const char *outputflags)
226 checkIfQhullInitialized();
229 char *command=
const_cast<char*
>(cmd.c_str());
231 qh_clear_outputflags(qh_qh);
232 char *
s = qh_qh->qhull_command + strlen(qh_qh->qhull_command) + 1;
233 strncat(qh_qh->qhull_command, command,
sizeof(qh_qh->qhull_command)-strlen(qh_qh->qhull_command)-1);
235 qh_initflags(qh_qh,
s);
236 qh_initqhull_outputflags(qh_qh);
237 if(qh_qh->KEEPminArea < REALmax/2
238 || (0 != qh_qh->KEEParea + qh_qh->KEEPmerge + qh_qh->GOODvertex
239 + qh_qh->GOODthreshold + qh_qh->GOODpoint + qh_qh->SPLITthresholds)){
241 qh_qh->ONLYgood= False;
242 FORALLfacet_(qh_qh->facet_list) {
245 qh_prepare_output(qh_qh);
247 qh_produce_output2(qh_qh);
248 if(qh_qh->VERIFYoutput && !qh_qh->STOPpoint && !qh_qh->STOPcone){
249 qh_check_points(qh_qh);
252 qh_qh->NOerrexit=
true;
253 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
258 runQhull(
const RboxPoints &rboxPoints,
const char *qhullCommand2)
260 runQhull(rboxPoints.comment().c_str(), rboxPoints.dimension(), rboxPoints.count(), &*rboxPoints.coordinates(), qhullCommand2);
268 runQhull(
const char *inputComment2,
int pointDimension,
int pointCount,
const realT *pointCoordinates,
const char *qhullCommand2)
271 throw QhullError(10027,
"Qhull error: runQhull called twice. Only one call allowed.");
276 char *command=
const_cast<char*
>(
s.c_str());
289 qh_initflags(qh_qh, command);
290 *qh_qh->rbox_command=
'\0';
291 strncat( qh_qh->rbox_command, inputComment2,
sizeof(qh_qh->rbox_command)-1);
293 qh_qh->PROJECTdelaunay= True;
295 pointT *newPoints=
const_cast<pointT*
>(pointCoordinates);
296 int newDimension= pointDimension;
297 int newIsMalloc= False;
298 if(qh_qh->HALFspace){
300 initializeFeasiblePoint(newDimension);
301 newPoints= qh_sethalfspace_all(qh_qh, pointDimension, pointCount, newPoints, qh_qh->feasible_point);
304 qh_init_B(qh_qh, newPoints, pointCount, newDimension, newIsMalloc);
306 qh_check_output(qh_qh);
307 qh_prepare_output(qh_qh);
308 if(qh_qh->VERIFYoutput && !qh_qh->STOPpoint && !qh_qh->STOPcone){
309 qh_check_points(qh_qh);
312 qh_qh->NOerrexit=
true;
313 for(
int k= qh_qh->hull_dim; k--; ){
316 qh_qh->maybeThrowQhullMessage(QH_TRY_status);
325 initializeFeasiblePoint(
int hulldim)
327 if(qh_qh->feasible_string){
328 qh_setfeasible(qh_qh, hulldim);
330 if(feasible_point.isEmpty()){
331 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");
332 qh_errexit(qh_qh, qh_ERRmem, NULL, NULL);
334 if(feasible_point.size()!=(
size_t)hulldim){
335 qh_fprintf(qh_qh, qh_qh->ferr, 6210,
"qhull error: dimension of feasiblePoint should be %d. It is %u", hulldim, feasible_point.size());
336 qh_errexit(qh_qh, qh_ERRmem, NULL, NULL);
338 if (!(qh_qh->feasible_point= (coordT*)qh_malloc(hulldim *
sizeof(coordT)))) {
339 qh_fprintf(qh_qh, qh_qh->ferr, 6202,
"qhull error: insufficient memory for feasible point\n");
340 qh_errexit(qh_qh, qh_ERRmem, NULL, NULL);
342 coordT *t= qh_qh->feasible_point;
344 for(Coordinates::ConstIterator p=feasible_point.begin(); p<feasible_point.end(); p++){
std::set< std::string > & s
void qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt,...)
GenericScelFormatter< double > volume()
QhullRidge – Qhull's ridge structure, ridgeT, as a C++ class.
const char s_unsupported_options[]
const char s_not_output_options[]