1
// Gmsh - Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
1
// Gmsh - Copyright (C) 1997-2009 C. Geuzaine, J.-F. Remacle
3
3
// See the LICENSE.txt file for license information. Please report all
4
4
// bugs and problems to <gmsh@geuz.org>.
18
18
#include "CreateFile.h"
21
#if defined(HAVE_FLTK)
23
#if (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 1) && (FL_PATCH_VERSION > 6)
25
#elif (FL_MAJOR_VERSION == 1) && (FL_MINOR_VERSION == 3)
28
#error "Gmsh requires FLTK >= 1.1.7 or FLTK 1.3.x"
21
32
#if !defined(HAVE_NO_POST)
43
54
Msg::Direct("Mesh options:");
44
55
Msg::Direct(" -1, -2, -3 Perform 1D, 2D or 3D mesh generation, then exit");
45
56
Msg::Direct(" -refine Perform uniform mesh refinement, then exit");
46
Msg::Direct(" -part Partition after batch mesh generation");
57
Msg::Direct(" -part int Partition after batch mesh generation");
47
58
Msg::Direct(" -saveall Save all elements (discard physical group definitions)");
48
59
Msg::Direct(" -o file Specify mesh output file name");
49
60
Msg::Direct(" -format string Set output mesh format (msh, msh1, msh2, unv, vrml, stl, mesh,");
50
61
Msg::Direct(" bdf, p3d, cgns, med)");
51
62
Msg::Direct(" -bin Use binary format when available");
52
63
Msg::Direct(" -parametric Save vertices with their parametric coordinates");
53
Msg::Direct(" -algo string Select mesh algorithm (de, del2d, frontal, iso, netgen, tetgen)");
64
Msg::Direct(" -numsubedges Set the number of subdivisions when displaying high order elements");
65
Msg::Direct(" -algo string Select mesh algorithm (iso, frontal, del2d, del3d, netgen)");
54
66
Msg::Direct(" -smooth int Set number of mesh smoothing steps");
55
67
Msg::Direct(" -optimize[_netgen] Optimize quality of tetrahedral elements");
56
68
Msg::Direct(" -order int Set mesh order (1, ..., 5)");
156
168
int terminal = CTX.terminal;
157
169
CTX.terminal = 1;
159
// Create a dummy model during option processing so we cannot crash
160
// the parser, and so we can load files for -convert
161
GModel *dummy = new GModel();
163
171
#if !defined(HAVE_NO_PARSER)
164
172
// Parse session and option files
165
ParseFile(CTX.session_filename_fullpath, 1);
166
ParseFile(CTX.options_filename_fullpath, 1);
173
ParseFile((CTX.home_dir + CTX.session_filename).c_str(), true);
174
ParseFile((CTX.home_dir + CTX.options_filename).c_str(), true);
169
177
// Get command line options
211
219
else if(!strcmp(argv[i] + 1, "part")) {
212
CTX.batch_after_mesh = 1;
222
CTX.batch_after_mesh = 1;
223
opt_mesh_partition_num(0, GMSH_SET, atoi(argv[i++]));
226
Msg::Fatal("Missing number");
215
228
else if(!strcmp(argv[i] + 1, "new")) {
216
229
CTX.files.push_back("-new");
286
299
Msg::Fatal("Missing file name");
301
else if(!strcmp(argv[i] + 1, "nw")) {
304
CTX.num_windows = atoi(argv[i++]);
306
Msg::Fatal("Missing number");
308
else if(!strcmp(argv[i] + 1, "nt")) {
311
CTX.num_tiles = atoi(argv[i++]);
313
Msg::Fatal("Missing number");
288
315
else if(!strcmp(argv[i] + 1, "convert")) {
291
318
while(i < argc) {
293
sprintf(filename, "%s_new", argv[i]);
319
std::string fileName = std::string(argv[i]) + "_new";
294
320
#if !defined(HAVE_NO_POST)
295
321
unsigned int n = PView::list.size();
298
324
#if !defined(HAVE_NO_POST)
299
325
// convert post-processing views to latest binary format
300
326
for(unsigned int j = n; j < PView::list.size(); j++)
301
PView::list[j]->write(filename, 1, (j == n) ? false : true);
327
PView::list[j]->write(fileName, 1, (j == n) ? false : true);
303
329
// convert mesh to latest binary format
304
330
if(GModel::current()->getMeshStatus() > 0){
305
331
CTX.mesh.msh_file_version = 2.0;
306
332
CTX.mesh.binary = 1;
307
CreateOutputFile(filename, FORMAT_MSH);
333
CreateOutputFile(fileName, FORMAT_MSH);
418
444
Msg::Fatal("Missing number");
446
else if(!strcmp(argv[i] + 1, "numsubedges")) {
449
opt_mesh_num_sub_edges(0, GMSH_SET, atof(argv[i++]));
451
Msg::Fatal("Missing number");
420
453
else if(!strcmp(argv[i] + 1, "c1")) {
422
455
opt_mesh_c1(0, GMSH_SET, 1);
538
571
else if(!strcmp(argv[i] + 1, "help") || !strcmp(argv[i] + 1, "-help")) {
539
572
fprintf(stderr, "Gmsh, a 3D mesh generator with pre- and post-processing facilities\n");
540
fprintf(stderr, "Copyright (C) 1997-2008 Christophe Geuzaine and Jean-Francois Remacle\n");
573
fprintf(stderr, "Copyright (C) 1997-2009 Christophe Geuzaine and Jean-Francois Remacle\n");
541
574
Print_Usage(argv[0]);
592
625
Msg::Fatal("Missing number");
627
else if(!strcmp(argv[i] + 1, "deltafontsize")) {
630
CTX.deltafontsize = atoi(argv[i++]);
632
Msg::Fatal("Missing number");
594
634
else if(!strcmp(argv[i] + 1, "theme") || !strcmp(argv[i] + 1, "scheme")) {
596
636
if(argv[i] != NULL)
630
if(CTX.files.empty())
631
strncpy(CTX.filename, CTX.default_filename_fullpath, 255);
670
if(CTX.files.empty()){
671
std::string base = (getenv("PWD") ? "" : CTX.home_dir);
672
GModel::current()->setFileName((base + CTX.default_filename).c_str());
633
strncpy(CTX.filename, CTX.files[0].c_str(), 255);
675
GModel::current()->setFileName(CTX.files[0]);
637
677
CTX.terminal = terminal;