00001
00002
00003
00004
00005
00006
00007
00008
#include <qtextstream.h>
00009
#include <qfile.h>
00010
00011
#include <stdio.h>
00012
#include <stdlib.h>
00013
00014
#include "DelaunayMeshGenerator.h"
00015
00016
00017
00137
char* __delaunay_version =
"<Version> : 1.0.1 (" __DATE__
", " __TIME__
")";
00138
char* __delaunay_lib_version =
"<Version 1.0.1> (" __DATE__
", " __TIME__
")";
00139
00140
00141
void print_help(
const char* a)
00142 {
00143 printf(
"\n== delaunay mesh generator ==\n\n");
00144 printf(__delaunay_version);
00145 printf(
"\n");
00146 printf(
"<Author> : Jochen Hanff <delauany@pamidion.de>\n");
00147 printf(
"\n\n");
00148
00149 printf(
"Arguments :\n");
00150
00151 printf(
" -i [input file] : specifies input file\n");
00152 printf(
" -o [output file] : specifies output file, default is stdout\n");
00153 printf(
" -v, --verbose : show some progress on stderr\n");
00154 printf(
" --version : print version\n");
00155 printf(
" -h, --help : print this help\n");
00156
00157 printf(
"\nexamples :\n");
00158 printf(
"- $ cat [input file] | %s \n", a );
00159 printf(
"- $ %s -i [input file] \n", a );
00160
00161 printf(
"\n");
00162
00163 }
00164
00165
00166
00167
int main(
int args,
char* argv[])
00168 {
00169
00170 QString inputfile;
00171 QString outputfile;
00172
00173
bool verbose =
false;
00174
00175
DelaunayMeshGenerator* generator;
00176
00177
for(
int i=1; i<args; i++) {
00178
00179 QString qarg(argv[i]);
00180
00181
if(qarg ==
"-h" || qarg ==
"-help") {
00182 print_help(argv[0]);
00183 exit(0);
00184 }
00185
00186
if(qarg ==
"-i") {
00187 inputfile = argv[i+1];
00188 i++;
00189
continue;
00190 }
00191
00192
if(qarg ==
"-o") {
00193 outputfile = argv[i+1];
00194 i++;
00195
continue;
00196 }
00197
00198
if(qarg ==
"--version") {
00199 printf(
"\n== delaunay mesh generator ==\n");
00200 printf(__delaunay_version);
00201 printf(
"\n\n");
00202 exit(0);
00203 }
00204
00205
if(qarg ==
"-v" || qarg ==
"--verbose") {
00206 verbose =
true;
00207
continue;
00208 }
00209
00210 printf(
"\ndon't know argument '%s' \n\n", qarg.latin1());
00211 print_help(argv[0]);
00212 exit(0);
00213 }
00214
00215
00216
00217
if(!inputfile.isEmpty()) {
00218 generator =
new DelaunayMeshGenerator(inputfile,verbose);
00219 }
else {
00220 QTextIStream cin(stdin);
00221 generator =
new DelaunayMeshGenerator(*(cin.device()),verbose);
00222 }
00223
00224 QTextStream* cout;
00225 QFile* qfile;
00226
00227
if(!outputfile.isEmpty()) {
00228 qfile =
new QFile(outputfile);
00229
if(!qfile->open(IO_WriteOnly | IO_Translate )) exit(1);
00230 cout =
new QTextStream( qfile );
00231
00232 }
else {
00233 cout =
new QTextStream(stdout,IO_WriteOnly | IO_Translate);
00234 }
00235
00236 generator->
generate();
00237 generator->
mesh()->
write_XML(*cout);
00238
00239 }