Skip to content
Snippets Groups Projects
CommandLine.cpp 17.9 KiB
Newer Older
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// $Id: CommandLine.cpp,v 1.51 2004-11-25 02:10:30 geuzaine Exp $
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// Copyright (C) 1997-2004 C. Geuzaine, J.-F. Remacle
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
// 
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// Please report all bugs and problems to <gmsh@geuz.org>.
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include <sys/types.h>
#include <unistd.h>
#include "Gmsh.h"
#include "GmshUI.h"
#include "GmshVersion.h"
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#include "CommandLine.h"
#include "Numeric.h"
#include "Context.h"
#include "Options.h"
#include "Geo.h"
#include "Mesh.h"
#include "Views.h"
#include "OpenFile.h"
#include "Parser.h"

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if !defined(GMSH_EXTRA_VERSION)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#error
#error Common/GmshVersion.h is not up-to-date.
#error Please run 'make tag'.
#error
#endif

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
extern Context_T CTX;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
extern Mesh *THEM;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char *TheFileNameTab[MAX_OPEN_FILES];
char *TheBgmFileName = NULL, *TheOptString = NULL;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char gmsh_progname[]  = "Gmsh, a 3D mesh generator with pre- and post-processing facilities" ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char gmsh_copyright[] = "Copyright (C) 1997-2004 Christophe Geuzaine and Jean-Francois Remacle";
char gmsh_version[]   = "Version        : " ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char gmsh_license[]   = "License        : " GMSH_SHORT_LICENSE;
char gmsh_gui[]       = "GUI toolkit    : " ;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char gmsh_os[]        = "Build OS       : " GMSH_OS ;
char gmsh_options[]   = "Build options  : " ;
char gmsh_date[]      = "Build date     : " GMSH_DATE ;
char gmsh_host[]      = "Build host     : " GMSH_HOST ;
char gmsh_packager[]  = "Packager       : " GMSH_PACKAGER ;
char gmsh_url[]       = "Web site       : http://www.geuz.org/gmsh/" ;
char gmsh_email[]     = "Mailing list   : gmsh@geuz.org" ;

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
// If you change the following, please also change
// * the texinfo documentation (doc/texinfo/command_line.texi)
// * the man page (doc/gmsh.1)

void Print_Usage(char *name){
  Msg(DIRECT, "Usage: %s [options] [files]", name);
  Msg(DIRECT, "Geometry options:");
  Msg(DIRECT, "  -0                    parse input files, output unrolled geometry, and exit");
  Msg(DIRECT, "Mesh options:");
  Msg(DIRECT, "  -1, -2, -3            perform batch 1D, 2D and 3D mesh generation");
  Msg(DIRECT, "  -saveall              save all elements (discard physical group definitions)");
  Msg(DIRECT, "  -o file               specify mesh output file name");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -format string        set output mesh format (msh, unv, gref)");
  Msg(DIRECT, "  -algo string          select mesh algorithm (iso, tri, aniso, netgen)");
  Msg(DIRECT, "  -smooth int           set number of mesh smoothing steps");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -optimize             optimize quality of tetrahedral elements");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -order int            set mesh order (1, 2)");
  Msg(DIRECT, "  -scale float          set global scaling factor");
  Msg(DIRECT, "  -meshscale float      set mesh scaling factor");
  Msg(DIRECT, "  -clscale float        set characteristic length scaling factor");
  Msg(DIRECT, "  -rand float           set random perturbation factor");
  Msg(DIRECT, "  -bgm file             load backround mesh from file");
  Msg(DIRECT, "  -constrain            constrain background mesh with characteristic lengths");
  Msg(DIRECT, "  -histogram            print mesh quality histogram");
  Msg(DIRECT, "  -extrude              use old extrusion mesh generator");
  Msg(DIRECT, "  -recombine            recombine meshes from old extrusion mesh generator");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_FLTK)
  Msg(DIRECT, "  -interactive          display 2D mesh construction interactively");
  Msg(DIRECT, "Post-processing options:");
  Msg(DIRECT, "  -noview               hide all views on startup");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -link int             select link mode between views (0, 1, 2, 3, 4)");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -combine              combine input views into multi-time-step ones");
  Msg(DIRECT, "Display options:");    
  Msg(DIRECT, "  -nodb                 disable double buffering");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -fontsize int         specify the font size for the GUI");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -scheme string        specify FLTK GUI scheme");
  Msg(DIRECT, "  -display string       specify display");
#endif
  Msg(DIRECT, "Other options:");      
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_FLTK)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -a, -g, -m, -s, -p    start in automatic, geometry, mesh, solver or post-processing mode");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -pid                  print process id on stdout");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -v int                set verbosity level");
  Msg(DIRECT, "  -string \"string\"      parse string before project file");
  Msg(DIRECT, "  -option file          parse option file before GUI creation");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  Msg(DIRECT, "  -convert file file    perform batch conversion of views and meshes into latest file formats");
  Msg(DIRECT, "  -version              show version number");
  Msg(DIRECT, "  -info                 show detailed version information");
  Msg(DIRECT, "  -help                 show this message");
}

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
char *Get_BuildOptions(void)
{
  static int first=1;
  static char opt[128] = "";
  
  if(first){
#if defined(HAVE_GSL)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    strcat(opt, "GSL ");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
#if defined(HAVE_TRIANGLE)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    strcat(opt, "TRIANGLE ");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_NETGEN)
    strcat(opt, "NETGEN ");
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_LIBJPEG)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
    strcat(opt, "JPEG ");
#endif
#if defined(HAVE_LIBPNG)
    strcat(opt, "PNG ");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
#if defined(HAVE_LIBZ)
    strcat(opt, "ZLIB ");
#endif
#if defined(HAVE_MATH_EVAL)
    strcat(opt, "MATHEVAL ");
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
    first = 0;
  }
  return opt;
}

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
void Get_Options(int argc, char *argv[], int *nbfiles)
{
  int i = 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // This symbol context is local to option parsing (the symbols will
  // not interfere with subsequent OpenFiles)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  InitSymbols();
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  // Parse session and option files

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  ParseFile(CTX.session_filename_fullpath, 1, 1);
  ParseFile(CTX.options_filename_fullpath, 1, 1);

  // Get command line options

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
  TheFileNameTab[0] = CTX.default_filename_fullpath;
  *nbfiles = 0;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed

  while(i < argc) {

    if(argv[i][0] == '-') {

Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      if(!strcmp(argv[i] + 1, "pid")) {
	fprintf(stdout, "%d\n", getpid());
	fflush(stdout);
        i++;
      }
      else if(!strcmp(argv[i] + 1, "string")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        i++;
        if(argv[i] != NULL)
          TheOptString = argv[i++];
        else {
          fprintf(stderr, ERROR_STR "Missing string\n");
          exit(1);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "a")) {
        CTX.initial_context = 0;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "g")) {
        CTX.initial_context = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "m")) {
        CTX.initial_context = 2;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "s")) {
        CTX.initial_context = 3;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "p")) {
        CTX.initial_context = 4;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "0")) {
        CTX.batch = -1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "1")) {
        CTX.batch = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "2")) {
        CTX.batch = 2;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "3")) {
        CTX.batch = 3;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "saveall")) {
        CTX.mesh.save_all = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "extrude")) { // old extrusion mesh generator
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        CTX.mesh.oldxtrude = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "recombine")) { // old extrusion mesh generator
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        CTX.mesh.oldxtrude_recombine = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "dupli")) {
        CTX.mesh.check_duplicates = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "histogram")) {
        CTX.mesh.histogram = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "optimize")) {
        CTX.mesh.optimize = 1;
        i++;
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "option")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          ParseFile(argv[i++], 1, 1);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        else {
          fprintf(stderr, ERROR_STR "Missing file name\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "o")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.output_filename = argv[i++];
        else {
          fprintf(stderr, ERROR_STR "Missing file name\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "bgm")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          TheBgmFileName = argv[i++];
        else {
          fprintf(stderr, ERROR_STR "Missing file name\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "constrain")) {
        CTX.mesh.constrained_bgmesh = 1;
        i++;
      }
      else if(!strcmp(argv[i] + 1, "convert")) {
        i++;
        CTX.terminal = 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        CTX.batch = 1;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] && argv[i + 1]) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          OpenProblem(argv[i]);
	  // convert post-processing views to latest (binary) format
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          for(int j = 0; j < List_Nbr(CTX.post.list); j++)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
            WriteView(*(Post_View **) List_Pointer(CTX.post.list, j),
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
                      argv[i + 1], 1, j ? 1 : 0);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
	  // convert any mesh to the latest format
	  if(THEM){
	    if(Tree_Nbr(THEM->Vertices)){
	      CTX.mesh.msh_file_version = 2.0;
	      Print_Mesh(THEM, argv[i + 1], FORMAT_MSH);
	    }
	  }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        }
        else
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          fprintf(stderr, "Usage: %s -convert file file\n", argv[0]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        exit(1);
      }
      else if(!strcmp(argv[i] + 1, "old")) {
        CTX.geom.old_circle = 1;
        i++;
      }
      else if(!strcmp(argv[i] + 1, "initial")) {
        i++;
        if(argv[i] != NULL)
          CTX.mesh.initial_only = atoi(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "quality")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.mesh.quality = atof(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "scale")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.geom.scaling_factor = atof(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "meshscale")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.mesh.scaling_factor = atof(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "rand")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.mesh.rand_factor = atof(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "clscale")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
          CTX.mesh.lc_factor = atof(argv[i++]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          if(CTX.mesh.lc_factor <= 0.0) {
            fprintf(stderr, ERROR_STR
                    "Characteristic length factor must be > 0\n");
            exit(1);
          }
        }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "smooth")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.mesh.nb_smoothing = atoi(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "order") || !strcmp(argv[i] + 1, "degree")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          opt_mesh_order(0, GMSH_SET, atof(argv[i++]));
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "format") || !strcmp(argv[i] + 1, "f")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
          if(!strcmp(argv[i], "msh") ||
             !strcmp(argv[i], "MSH") || !strcmp(argv[i], "gmsh")) {
            CTX.mesh.format = FORMAT_MSH;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else if(!strcmp(argv[i], "unv") ||
                  !strcmp(argv[i], "UNV") || !strcmp(argv[i], "ideas")) {
            CTX.mesh.format = FORMAT_UNV;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else if(!strcmp(argv[i], "gref") ||
                  !strcmp(argv[i], "GREF") || !strcmp(argv[i], "Gref")) {
            CTX.mesh.format = FORMAT_GREF;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else {
            fprintf(stderr, ERROR_STR "Unknown mesh format\n");
            exit(1);
          }
          i++;
        }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        else {
          fprintf(stderr, ERROR_STR "Missing format\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "algo")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
          if(!strncmp(argv[i], "iso", 3))
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
            CTX.mesh.algo2d = DELAUNAY_ISO;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else if(!strncmp(argv[i], "tri", 3))
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
            CTX.mesh.algo2d = DELAUNAY_TRIANGLE;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else if(!strncmp(argv[i], "aniso", 5))
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
            CTX.mesh.algo2d = DELAUNAY_ANISO;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else if(!strncmp(argv[i], "netgen", 6))
            CTX.mesh.algo3d = FRONTAL_NETGEN;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          else {
            fprintf(stderr, ERROR_STR "Unknown mesh algorithm\n");
            exit(1);
          }
          i++;
        }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        else {
          fprintf(stderr, ERROR_STR "Missing algorithm\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "version") ||
              !strcmp(argv[i] + 1, "-version")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        fprintf(stderr, "%s\n", GMSH_VERSION);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "info") || !strcmp(argv[i] + 1, "-info")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        fprintf(stderr, "%s%s\n", gmsh_version, GMSH_VERSION);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_FLTK)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        fprintf(stderr, "%sFLTK %d.%d.%d\n", gmsh_gui, FL_MAJOR_VERSION,
                FL_MINOR_VERSION, FL_PATCH_VERSION);
#else
        fprintf(stderr, "%snone\n", gmsh_gui);
#endif
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        fprintf(stderr, "%s\n", gmsh_license);
        fprintf(stderr, "%s\n", gmsh_os);
        fprintf(stderr, "%s%s\n", gmsh_options, Get_BuildOptions());
        fprintf(stderr, "%s\n", gmsh_date);
        fprintf(stderr, "%s\n", gmsh_host);
        fprintf(stderr, "%s\n", gmsh_packager);
        fprintf(stderr, "%s\n", gmsh_url);
        fprintf(stderr, "%s\n", gmsh_email);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        exit(1);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "help") || !strcmp(argv[i] + 1, "-help")) {
        fprintf(stderr, "%s\n", gmsh_progname);
        fprintf(stderr, "%s\n", gmsh_copyright);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        CTX.terminal = 1;
        Print_Usage(argv[0]);
        exit(1);
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "v")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL)
          CTX.verbosity = atoi(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#if defined(HAVE_FLTK)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "term")) {
        CTX.terminal = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "dual")) {
        CTX.mesh.dual = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "interactive")) {
        CTX.mesh.interactive = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "noview")) {
        opt_view_visible(0, GMSH_SET, 0);
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "link")) {
        i++;
        if(argv[i] != NULL)
          CTX.post.link = atoi(argv[i++]);
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "fill")) {
        opt_view_intervals_type(0, GMSH_SET, DRAW_POST_CONTINUOUS);
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "smoothview")) {
        CTX.post.smooth = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "combine")) {
        CTX.post.combine_time = 1;
        i++;
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "nbiso")) {
        i++;
        if(argv[i] != NULL)
          opt_view_nb_iso(0, GMSH_SET, atoi(argv[i++]));
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "threads")) {
        CTX.threads = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "nothreads")) {
        CTX.threads = 0;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "db")) {
        CTX.db = 1;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "nodb")) {
        CTX.db = 0;
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "fontsize")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
          CTX.fontsize = atoi(argv[i]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        }
        else {
          fprintf(stderr, ERROR_STR "Missing number\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "scheme")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
          CTX.scheme = argv[i];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        }
        else {
          fprintf(stderr, ERROR_STR "Missing argument\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strcmp(argv[i] + 1, "display")) {
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        if(argv[i] != NULL) {
          CTX.display = argv[i];
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        }
        else {
          fprintf(stderr, ERROR_STR "Missing argument\n");
          exit(1);
        }
      }
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
#endif
#if defined(__APPLE__)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      else if(!strncmp(argv[i] + 1, "psn", 3)) {
        // The Mac Finder launches programs with a special command
        // line argument of the form -psn_XXX: just ignore it silently
        // (and don't exit!)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        i++;
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
      }
#endif
      else {
        fprintf(stderr, "Unknown option '%s'\n", argv[i]);
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        CTX.terminal = 1;
        Print_Usage(argv[0]);
        exit(1);
      }
    }

    else {
      if(*nbfiles < MAX_OPEN_FILES)
Christophe Geuzaine's avatar
 
Christophe Geuzaine committed
        TheFileNameTab[(*nbfiles)++] = argv[i++];
      else {
        fprintf(stderr, ERROR_STR "Too many input files\n");
        exit(1);
      }
    }

  }

  strncpy(CTX.filename, TheFileNameTab[0], 255);
}