dev-13 adding back run_qvoronoi and run_qconvex

This commit is contained in:
Peter Schmidtke
2018-07-23 22:51:22 +02:00
parent 633efaa841
commit 81a864715c
7 changed files with 131 additions and 76 deletions

View File

@@ -36,7 +36,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include "topology.h"
#define DEBUG 1
#define DEBUG 0
#define DEBUG_STREAM stdout /**< define on zhich stream you want to see the debug messages, valid are stdout or stderr*/

View File

@@ -28,8 +28,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#include "utils.h"
#include "../src/qhull/qvoronoi.h"
#include "../src/qhull/qconvex.h"
#include "../src/qhull/qvoronoi/qvoronoi.h"
#include "../src/qhull/qconvex/qconvex.h"
#include "memhandler.h"

View File

@@ -129,7 +129,7 @@ $(PATH_OBJ)%.o: $(PATH_SRC)%.cpp
all: $(MYPROGS) # $(PATH_BIN)$(CHECK)
qhull:
qhull:
cd src/qhull/ && make
$(PATH_BIN)$(CHECK): $(CHOBJ) $(QOBJS)

View File

@@ -251,29 +251,30 @@ Except for 'F.' and 'PG', upper-case options take an argument.\n\
\n\
Angle_max Centrum_size Random_dist Ucoplanar_max Wide_outside\n\
";
/*-<a href="../libqhull/qh-qhull.htm"
>-------------------------------</a><a name="main">-</a>
main( argc, argv )
processes the command line, calls qhull() to do the work, and exits
design:
initializes data structures
reads points
finishes initialization
computes convex hull and other structures
checks the result
writes the output
frees memory
*/
int main(int argc, char *argv[]) {
int run_qconvex(FILE *fin,FILE *fout) {
int curlong, totlong; /* used !qh_NOmem */
int exitcode, numpoints, dim;
coordT *points;
boolT ismalloc;
QHULL_LIB_CHECK /* Check for compatible library */
int argc=2;
char *argv[2];
argv[0]=malloc(sizeof(char)*200);
argv[0]="src/qhull/qconvex\0";
argv[1]=malloc(sizeof(char)*2);
argv[1]="FS\0";
#if __MWERKS__ && __POWERPC__
char inBuf[BUFSIZ], outBuf[BUFSIZ], errBuf[BUFSIZ];
SIOUXSettings.showstatusline= false;
SIOUXSettings.tabspaces= 1;
SIOUXSettings.rows= 40;
if (setvbuf(stdin, inBuf, _IOFBF, sizeof(inBuf)) < 0 /* w/o, SIOUX I/O is slow*/
|| setvbuf(stdout, outBuf, _IOFBF, sizeof(outBuf)) < 0
|| (stdout != stderr && setvbuf(stderr, errBuf, _IOFBF, sizeof(errBuf)) < 0))
fprintf(stderr, "qhull internal warning (main): could not change stdio to fully buffered.\n");
argc= ccommand(&argv);
#endif
if ((argc == 1) && isatty( 0 /*stdin*/)) {
fprintf(stdout, qh_prompt2, qh_version);
@@ -284,18 +285,13 @@ int main(int argc, char *argv[]) {
qh_promptb, qh_promptc, qh_promptd, qh_prompte);
exit(qh_ERRnone);
}
if (argc > 1 && *argv[1] == '.' && !*(argv[1]+1)) {
if (argc >1 && *argv[1] == '.' && !*(argv[1]+1)) {
fprintf(stdout, qh_prompt3, qh_version);
exit(qh_ERRnone);
}
if (argc > 1 && *argv[1] == '-' && *(argv[1]+1)=='V') {
fprintf(stdout, "%s\n", qh_version2);
exit(qh_ERRnone);
}
qh_init_A(stdin, stdout, stderr, argc, argv); /* sets qh qhull_command */
qh_init_A(fin, fout, stderr, argc, argv); /* sets qh qhull_command */
exitcode= setjmp(qh errexit); /* simple statement for CRAY J916 */
if (!exitcode) {
qh NOerrexit = False;
qh_checkflags(qh qhull_command, hidden_options);
qh_initflags(qh qhull_command);
points= qh_readpoints(&numpoints, &dim, &ismalloc);
@@ -313,14 +309,13 @@ int main(int argc, char *argv[]) {
}
qh NOerrexit= True; /* no more setjmp */
#ifdef qh_NOmem
qh_freeqhull(qh_ALL);
qh_freeqhull( True);
#else
qh_freeqhull(!qh_ALL);
qh_freeqhull( False);
qh_memfreeshort(&curlong, &totlong);
if (curlong || totlong)
qh_fprintf_stderr(6263, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
fprintf(stderr, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
totlong, curlong);
#endif
return exitcode;
} /* main */

View File

@@ -0,0 +1,27 @@
/*
* File: qconvex.h
* Author: peter
*
* Created on November 21, 2012, 9:18 PM
*/
#ifndef QCONVEX_H
#define QCONVEX_H
/*
* File: qconvex.h
* Author: peter
*
* Created on 04 March 2012, 15:38
* This file is not part of the official qhull distribution.
* (v) added again to the new QHULL distribution (2010.1)
*/
int run_qconvex(FILE *fin,FILE *fout);
#endif /* QCONVEX_H */

View File

@@ -8,8 +8,15 @@
see unix.c for full interface
Copyright (c) 1993-2015, The Geometry Center
* This file was modified by Vincent Le Guilloux and Peter Schmidtke on
* 4/03/2009 and 23/07/2018 in order to link it to the fpocket program.
* The former main function was replaced by run_qvoronoi(FILE *fin,FILE *fout).
* Else the file remains unchanged as well the rest of the qhull distribution. A
* qvoronoi.h file was added.
* You can obtain the original source code of this file on www.qhull.org.
*/
#include "libqhull/libqhull.h"
#include <stdio.h>
@@ -225,62 +232,71 @@ Except for 'F.' and 'PG', upper-case options take an argument.\n\
Angle_max Centrum_size Random_dist Wide_outside\n\
";
/*-<a href="../libqhull/qh-qhull.htm#TOC"
>-------------------------------</a><a name="main">-</a>
main( argc, argv )
processes the command line, calls qhull() to do the work, and exits
design:
initializes data structures
reads points
finishes initialization
computes convex hull and other structures
checks the result
writes the output
frees memory
*/
int main(int argc, char *argv[]) {
int curlong, totlong; /* used !qh_NOmem */
int run_qvoronoi(FILE *fin,FILE *fout) {
int curlong, i,totlong; /* used !qh_NOmem */
int exitcode, numpoints, dim;
coordT *points;
boolT ismalloc;
int argc=6;
char *argv[6];
argv[0]=malloc(sizeof(char)*200);
argv[0]="src/qhull/qvoronoi\0";
argv[1]=malloc(sizeof(char)*2);
argv[1]="p\0";
argv[2]=malloc(sizeof(char)*2);
argv[2]="i\0";
argv[3]=malloc(sizeof(char)*3);
argv[3]="Pp\0";/*
argv[5]=malloc(sizeof(char)*6);
argv[5]="QR0\0";
argv[6]=malloc(sizeof(char)*5);
argv[6]="C-0\0";*/
argv[4]=malloc(sizeof(char)*4);
argv[4]="Qz\0";
argv[5]=malloc(sizeof(char)*4);
argv[5]="Qt\0";
/*argv[6]="R1.0e-5\0";*/
/*#if __MWERKS__ && __POWERPC__
char inBuf[BUFSIZ], outBuf[BUFSIZ], errBuf[BUFSIZ];
SIOUXSettings.showstatusline= false;
SIOUXSettings.tabspaces= 1;
SIOUXSettings.rows= 40;
if (setvbuf (stdin, inBuf, _IOFBF, sizeof(inBuf)) < 0 */ /* w/o, SIOUX I/O is slow*/
/*|| setvbuf (stdout, outBuf, _IOFBF, sizeof(outBuf)) < 0
|| (stdout != stderr && setvbuf (stderr, errBuf, _IOFBF, sizeof(errBuf)) < 0))
fprintf (stderr, "qhull internal warning (main): could not change stdio to fully buffered.\n");
argc= ccommand(&argv);
#endif
QHULL_LIB_CHECK /* Check for compatible library */
if ((argc == 1) && isatty( 0 /*stdin*/)) {
if ((argc == 1) && isatty( 0 *//*stdin*//*)) {
fprintf(stdout, qh_prompt2, qh_version);
exit(qh_ERRnone);
}
if (argc > 1 && *argv[1] == '-' && !*(argv[1]+1)) {
fprintf(stdout, qh_prompta, qh_version,
qh_promptb, qh_promptc, qh_promptd, qh_prompte);
qh_promptb, qh_promptc, qh_promptd, qh_prompte);
exit(qh_ERRnone);
}
if (argc > 1 && *argv[1] == '.' && !*(argv[1]+1)) {
if (argc >1 && *argv[1] == '.' && !*(argv[1]+1)) {
fprintf(stdout, qh_prompt3, qh_version);
exit(qh_ERRnone);
}
if (argc > 1 && *argv[1] == '-' && *(argv[1]+1)=='V') {
fprintf(stdout, "%s\n", qh_version2);
exit(qh_ERRnone);
}
qh_init_A(stdin, stdout, stderr, argc, argv); /* sets qh qhull_command */
exitcode= setjmp(qh errexit); /* simple statement for CRAY J916 */
}*/
qh_init_A (fin, fout, stderr, argc, argv); /* sets qh qhull_command */
exitcode= setjmp (qh errexit); /* simple statement for CRAY J916 */
if (!exitcode) {
qh NOerrexit= False;
qh_option("voronoi _bbound-last _coplanar-keep", NULL, NULL);
qh_option ("voronoi _bbound-last _coplanar-keep", NULL, NULL);
qh DELAUNAY= True; /* 'v' */
qh VORONOI= True;
qh VORONOI= True;
qh SCALElast= True; /* 'Qbb' */
qh_checkflags(qh qhull_command, hidden_options);
qh_initflags(qh qhull_command);
points= qh_readpoints(&numpoints, &dim, &ismalloc);
/*qh_checkflags (qh qhull_command, hidden_options);*/
qh_initflags (qh qhull_command);
points= qh_readpoints (&numpoints, &dim, &ismalloc);
if (dim >= 5) {
qh_option("_merge-exact", NULL, NULL);
qh_option ("_merge-exact", NULL, NULL);
qh MERGEexact= True; /* 'Qx' always */
}
qh_init_B(points, numpoints, dim, ismalloc);
qh_init_B (points, numpoints, dim, ismalloc);
qh_qhull();
qh_check_output();
qh_produce_output();
@@ -290,14 +306,13 @@ int main(int argc, char *argv[]) {
}
qh NOerrexit= True; /* no more setjmp */
#ifdef qh_NOmem
qh_freeqhull(qh_ALL);
qh_freeqhull( True);
#else
qh_freeqhull(!qh_ALL);
qh_memfreeshort(&curlong, &totlong);
if (curlong || totlong)
qh_fprintf_stderr(6263, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n",
qh_freeqhull( False);
qh_memfreeshort (&curlong, &totlong);
if (curlong || totlong)
fprintf (stderr, "qhull internal warning (main): did not free %d bytes of long memory (%d pieces)\n",
totlong, curlong);
#endif
return exitcode;
} /* main */
} /* main */

View File

@@ -0,0 +1,18 @@
/*
* File: qvoronoi.h
* Author: peter
*
* Created on 04 March 2009, 15:38
* This file is not part of the official qhull distribution.
* (p) added again to the new QHULL distribution (2015.2)
*/
#ifndef _QVORONOI_H
#define _QVORONOI_H
int qvoronoi_test(int v);
int run_qvoronoi(FILE *fin,FILE *fout);
#endif /* _QVORONOI_H */