qhull_interface.cpp
Go to the documentation of this file.
00001 /*<html><pre>  -<a                             href="../libqhull/qh-user.htm"
00002   >-------------------------------</a><a name="TOP">-</a>
00003 */
00004 
00005 #include <iostream.h>
00006 #include <conio.h>
00007 
00008 //--- Include qhull, so it works from with in a C++ source file
00009 //---
00010 //--- In MVC one cannot just do:
00011 //---
00012 //---    extern "C"
00013 //---    {
00014 //---      #include "qhull_a.h"
00015 //---    }
00016 //---
00017 //--- Because qhull_a.h includes math.h, which can not appear
00018 //--- inside a extern "C" declaration.
00019 //---
00020 //--- Maybe that why Numerical recipes in C avoid this problem, by removing
00021 //--- standard include headers from its header files and add them in the
00022 //--- respective source files instead.
00023 //---
00024 //--- [K. Erleben]
00025 
00026 #if defined(__cplusplus)
00027 extern "C"
00028 {
00029 #endif
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <libqhull/qhulllib.h>
00033 #include <libqhull/mem.h>
00034 #include <libqhull/qset.h>
00035 #include <libqhull/geom.h>
00036 #include <libqhull/merge.h>
00037 #include <libqhull/poly.h>
00038 #include <libqhull/io.h>
00039 #include <libqhull/stat.h>
00040 #if defined(__cplusplus)
00041 }
00042 #endif
00043 
00044 /*********************************************************************/
00045 /*                                                                   */
00046 /*                                                                   */
00047 /*                                                                   */
00048 /*                                                                   */
00049 /*********************************************************************/
00050 
00051 void compute_convex_hull(void)
00052 {
00053         int dim;                      /* dimension of points */
00054         int numpoints;            /* number of points */
00055         coordT *points;           /* array of coordinates for each point */
00056         boolT ismalloc;           /* True if qhull should free points in qh_freeqhull() or reallocation */
00057         char flags[]= "qhull Tv"; /* option flags for qhull, see qh_opt.htm */
00058         FILE *outfile= stdout;    /* output from qh_produce_output()
00059                                      use NULL to skip qh_produce_output() */
00060         FILE *errfile= stderr;    /* error messages from qhull code */
00061         int exitcode;             /* 0 if no error from qhull */
00062         facetT *facet;            /* set by FORALLfacets */
00063         int curlong, totlong;     /* memory remaining after qh_memfreeshort */
00064 
00065         /* initialize dim, numpoints, points[], ismalloc here */
00066         exitcode= qh_new_qhull(dim, numpoints, points, ismalloc,
00067                                                         flags, outfile, errfile);
00068         if (!exitcode) { /* if no error */
00069                 /* 'qh facet_list' contains the convex hull */
00070                 FORALLfacets {
00071                         /* ... your code ... */
00072                 }
00073         }
00074         qh_freeqhull(!qh_ALL);
00075         qh_memfreeshort(&curlong, &totlong);
00076         if (curlong || totlong)
00077                 fprintf(errfile, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
00078                              totlong, curlong);
00079 };
00080 
00081 /*********************************************************************/
00082 /*                                                                   */
00083 /*                                                                   */
00084 /*                                                                   */
00085 /*                                                                   */
00086 /*********************************************************************/
00087 
00088 void main()
00089 {
00090         cout << "Hello world" << endl;
00091 
00092         cout << "Press any key..." << endl;
00093 
00094         while (!_kbhit());
00095 
00096 };
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


libqhull
Author(s): Robert Krug
autogenerated on Tue Jun 18 2013 12:38:50