Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Analysis.AlgorithmBehavior/qhull-2012.1/src/HeuristicLab.qhull/HeuristicLab_qhull.c @ 10208

Last change on this file since 10208 was 10208, checked in by ascheibe, 10 years ago

#1886

  • added x64 configurations for qhull
  • added a wrapper for qhull volume calculation
  • removed old volume calculation code
File size: 2.7 KB
Line 
1/* HeuristicLab
2* Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
3*
4* This file is part of HeuristicLab.
5*
6* HeuristicLab is free software: you can redistribute it and/or modify
7* it under the terms of the GNU General Public License as published by
8* the Free Software Foundation, either version 3 of the License, or
9* (at your option) any later version.
10*
11* HeuristicLab is distributed in the hope that it will be useful,
12* but WITHOUT ANY WARRANTY; without even the implied warranty of
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14* GNU General Public License for more details.
15*
16* You should have received a copy of the GNU General Public License
17* along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
18*
19*
20* Export qhull functionality for HeuristicLab.
21* Code based on qhull's user_eg.c as well as
22* R's geometry package (Rconvhulln.c, Copyright Kai Habel, Raoul Grasman, David Sterratt; licensed under the GNU GPL).
23*
24*/     
25
26#define qh_QHimport
27#include "qhull_a.h"
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32  __declspec(dllexport) double qhull_volume(int dim, int numpoints, double *data);
33  void print_summary (void);
34#ifdef __cplusplus
35}
36#endif
37
38void print_summary (void) {
39  facetT *facet;
40  int k;
41
42  printf ("\n%d vertices and %d facets with normals:\n",
43    qh num_vertices, qh num_facets);
44  FORALLfacets {
45    for (k=0; k < qh hull_dim; k++)
46      printf ("%6.2g ", facet->normal[k]);
47    printf ("\n");
48  }
49}         
50
51double qhull_volume(int dim, int numpoints, double *data) {
52  boolT ismalloc= False;   
53  char flags[250];       
54  FILE *outfile= stdout;   
55  FILE *errfile= stdout;   
56  facetT *facet;           
57  int curlong, totlong;   
58  int i,j, exitcode;
59  double volume = -1.0;
60
61#if qh_QHpointer 
62  if (qh_qh){
63    printf ("QH6233: Qhull link error.  The global variable qh_qh was not initialized\n\
64            to NULL by global.c.  Please compile user_eg.c with -Dqh_QHpointer_dllimport\n\
65            as well as -Dqh_QHpointer, or use libqhullstatic, or use a different tool chain.\n\n");
66    return -1;
67  }
68#endif
69
70  sprintf (flags, "qhull s Tv Qt FA");
71
72  exitcode= qh_new_qhull (dim, numpoints, data, ismalloc, flags, outfile, errfile);
73  if (!exitcode) {                     
74    print_summary(); 
75    volume = qh totvol;
76  } else {
77   return -1.0;
78  }
79  qh_freeqhull(!qh_ALL);           
80  qh_memfreeshort (&curlong, &totlong);
81  if (curlong || totlong)
82    fprintf (errfile, "qhull internal warning (HeuristicLab_qhull, #1): did not free %d bytes of long memory (%d pieces)\n", totlong, curlong);
83
84  return volume;
85}
86
Note: See TracBrowser for help on using the repository browser.