gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
scriptStringInterface.cpp
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #include <string.h>
7 #include <sstream>
8 #include "GmshConfig.h"
9 #include "GmshMessage.h"
10 #include "GModel.h"
11 #include "GModelIO_GEO.h"
12 #include "GModelIO_OCC.h"
13 #include "Numeric.h"
14 #include "StringUtils.h"
15 #include "Geo.h"
16 #include "scriptStringInterface.h"
17 #include "OpenFile.h"
18 #include "Context.h"
19 #include "OS.h"
20 #include "Parser.h"
21 
22 #if defined(HAVE_MESH)
23 #include "Field.h"
24 #endif
25 
26 #if defined(HAVE_ONELAB)
27 #include "onelab.h"
28 #endif
29 
30 static void scriptAddCommand(const std::string &text,
31  const std::string &fileNameOrEmpty,
32  const std::string &lang)
33 {
34  if(lang != "geo") {
35  if(!text.empty()) printf("%s: %s\n", lang.c_str(), text.c_str());
36  return;
37  }
38 
39  const std::string &fileName = fileNameOrEmpty;
40  if(fileName.empty()) {
41  std::string base = (getenv("PWD") ? "" : CTX::instance()->homeDir);
42  GModel::current()->setFileName(base + CTX::instance()->defaultFileName);
43  GModel::current()->setName("");
44  }
45 
46  Msg::Debug("Adding `%s' to file `%s'", text.c_str(), fileName.c_str());
47  std::vector<std::string> split = SplitFileName(fileName);
48  std::string noExt = split[0] + split[1], ext = split[2];
49  // make sure we don't add stuff in a non-geo file
50  static bool proceed = false;
51  if(!CTX::instance()->expertMode && !proceed) {
52  if(ext.size() && ext != ".geo" && ext != ".GEO") {
53  std::ostringstream sstream;
54  sstream << "A scripting command is going to be appended to a non-`.geo' "
55  "file. Are\nyou sure you want to proceed?\n\n"
56  "You probably want to create a new `.geo' file containing the "
57  "command\n`Merge \""
58  << split[1] + split[2]
59  << "\";' and use that file instead.\n\n"
60  "(To disable this warning in the future, select `Enable "
61  "expert mode'\nin the option dialog.)";
62  int ret = Msg::GetAnswer(sstream.str().c_str(), 2, "Cancel",
63  "Proceed as is", "Create new `.geo' file");
64  if(ret == 2) {
65  std::string newFileName = split[0] + split[1] + ".geo";
66  if(CTX::instance()->confirmOverwrite) {
67  if(!StatFile(newFileName)) {
68  std::ostringstream sstream;
69  sstream << "File '" << newFileName
70  << "' already exists.\n\nDo you want to replace it?";
71  if(!Msg::GetAnswer(sstream.str().c_str(), 0, "Cancel", "Replace"))
72  return;
73  }
74  }
75  FILE *fp = Fopen(newFileName.c_str(), "w");
76  if(!fp) {
77  Msg::Error("Unable to open file '%s'", newFileName.c_str());
78  return;
79  }
80  fprintf(fp, "Merge \"%s\";\n//+\n%s\n", (split[1] + split[2]).c_str(),
81  text.c_str());
82  fclose(fp);
83  OpenProject(newFileName);
84  return;
85  }
86  else if(ret == 1)
87  proceed = true;
88  else if(ret == 0)
89  return;
90  }
91  }
92 
93 #if defined(HAVE_PARSER)
94  std::string tmpFileName =
96  FILE *gmsh_yyin_old = gmsh_yyin;
97  FILE *tmp_file;
98  if(!(tmp_file = Fopen(tmpFileName.c_str(), "w"))) {
99  Msg::Error("Unable to open temporary file '%s'", tmpFileName.c_str());
100  return;
101  }
102  fprintf(tmp_file, "%s\n", text.c_str());
103  fclose(tmp_file);
104  gmsh_yyin = Fopen(tmpFileName.c_str(), "r");
105  while(!feof(gmsh_yyin)) { gmsh_yyparse(); }
106  fclose(gmsh_yyin);
107  gmsh_yyin = gmsh_yyin_old;
108 
110  if(GModel::current()->getOCCInternals())
112  GModel::current()->setName(split[1]);
114 
115  FILE *fp = Fopen(fileName.c_str(), "a");
116  if(!fp) {
117  Msg::Error("Unable to open file '%s'", fileName.c_str());
118  return;
119  }
120  fprintf(fp, "//+\n%s\n", text.c_str());
121  fclose(fp);
122 #else
123  Msg::Error("GEO file creation not available without Gmsh parser");
124 #endif
125 
126  // mark Gmsh data as changed in onelab
127  if(text.find("Physical") != std::string::npos) {
128  // re-import the physical groups in onelab, and only ask to re-save the mesh
131  }
132  else if(text.find("MeshSize") != std::string::npos) {
133  // only ask to remesh and re-save
135  }
136  else {
137  // ask to reload the geometry, remesh and re-save
139  }
140 }
141 
142 void scriptRemoveLastCommand(const std::string &fileName)
143 {
144  if(StatFile(fileName)) return;
145  // FIXME: make this work with compressed files
146  std::ifstream t;
147  t.open(fileName.c_str(), std::ifstream::in);
148  std::stringstream buffer;
149  buffer << t.rdbuf();
150  std::string s(buffer.str());
151  int found = (int)s.rfind("//+");
152  if(found != (int)std::string::npos) { s.erase(found); }
153  else {
154  Msg::Warning("Could not find last command in script `%s'",
155  fileName.c_str());
156  return;
157  }
158  FILE *fp = Fopen(fileName.c_str(), "w");
159  if(fp) {
160  fprintf(fp, "%s", s.c_str());
161  fclose(fp);
162  }
163  else {
164  Msg::Error("Could not open file `%s'", fileName.c_str());
165  }
166  OpenProject(fileName);
167 }
168 
169 static std::string list2String(List_T *list, const std::string &lang)
170 {
171  std::ostringstream sstream;
172  if(lang == "py" || lang == "jl")
173  sstream << "[";
174  else if(lang == "geo" || lang == "cpp")
175  sstream << "{";
176  for(int i = 0; i < List_Nbr(list); i++) {
177  int num;
178  List_Read(list, i, &num);
179  if(i) sstream << ", ";
180  sstream << num;
181  }
182  if(lang == "py" || lang == "jl")
183  sstream << "]";
184  else if(lang == "geo" || lang == "cpp")
185  sstream << "}";
186  return sstream.str();
187 }
188 
189 static std::string vector2String(const std::vector<int> &v,
190  const std::string &lang)
191 {
192  std::ostringstream sstream;
193  if(lang == "py" || lang == "jl")
194  sstream << "[";
195  else if(lang == "geo" || lang == "cpp")
196  sstream << "{";
197  for(std::size_t i = 0; i < v.size(); i++) {
198  if(i) sstream << ", ";
199  sstream << v[i];
200  }
201  if(lang == "py" || lang == "jl")
202  sstream << "]";
203  else if(lang == "geo" || lang == "cpp")
204  sstream << "}";
205  return sstream.str();
206 }
207 
208 static std::string dimTags2String(const std::vector<std::pair<int, int> > &l,
209  const std::string &lang)
210 {
211  std::ostringstream sstream;
212  if(lang == "py" || lang == "jl")
213  sstream << "[";
214  else if(lang == "cpp")
215  sstream << "{";
216 
217  for(std::size_t i = 0; i < l.size(); i++) {
218  if(lang == "geo") {
219  switch(l[i].first) {
220  case 0: sstream << "Point{" << l[i].second << "}; "; break;
221  case 1: sstream << "Curve{" << l[i].second << "}; "; break;
222  case 2: sstream << "Surface{" << l[i].second << "}; "; break;
223  case 3: sstream << "Volume{" << l[i].second << "}; "; break;
224  }
225  }
226  else if(lang == "py" || lang == "jl") {
227  if(i) sstream << ", ";
228  sstream << "(" << l[i].first << ", " << l[i].second << ")";
229  }
230  else if(lang == "cpp") {
231  if(i) sstream << ", ";
232  sstream << "{" << l[i].first << ", " << l[i].second << "}";
233  }
234  else {
235  Msg::Error("Unhandled language ('%s') in script generator", lang.c_str());
236  }
237  }
238 
239  if(lang == "py" || lang == "jl")
240  sstream << "]";
241  else if(lang == "cpp")
242  sstream << "}";
243  return sstream.str();
244 }
245 
246 static std::string currentFactory = "geo";
247 
248 static void checkOCC(std::ostringstream &sstream, const std::string &lang)
249 {
250  currentFactory = "occ";
251 #if defined(HAVE_PARSER)
252  if(lang == "geo" && gmsh_yyfactory != "OpenCASCADE") {
253  sstream << "SetFactory(\"OpenCASCADE\");\n";
254  return;
255  }
256 #endif
257 }
258 
259 void scriptSetFactory(const std::string &factory, const std::string &fileName)
260 {
261  if(factory == "OpenCASCADE")
262  currentFactory = "occ";
263  else
264  currentFactory = "geo";
265  for(auto &lang : CTX::instance()->scriptLang) {
266  std::ostringstream sstream;
267  if(lang == "geo") {
268  sstream << "SetFactory(\"" << factory << "\");";
269  scriptAddCommand(sstream.str(), fileName, lang);
270  }
271  }
272 }
273 
274 static std::string api(const std::string &name, const std::string &args,
275  const std::string &lang)
276 {
277  if(lang == "py" || lang == "jl")
278  return ReplaceSubString("/", ".", name) + "(" + args + ")";
279  else if(lang == "cpp")
280  return ReplaceSubString("/", "::", name) + "(" + args + ");";
281 
282  Msg::Error("Unhandled language ('%s') in script generator", lang.c_str());
283  return "";
284 }
285 
286 void scriptSetMeshSize(const std::string &fileName, const std::vector<int> &l,
287  const std::string &lc)
288 {
289  for(auto &lang : CTX::instance()->scriptLang) {
290  std::ostringstream sstream;
291  if(lang == "geo") {
292  sstream << "MeshSize " << vector2String(l, lang) << " = " << lc << ";";
293  }
294  else {
295  std::vector<std::pair<int, int> > dimTags;
296  for(auto t : l) dimTags.push_back(std::make_pair(0, t));
297  sstream << api("gmsh/model/mesh/setSize",
298  dimTags2String(dimTags, lang) + ", " + lc, lang);
299  }
300  scriptAddCommand(sstream.str(), fileName, lang);
301  }
302 }
303 
304 void scriptRecombineSurface(const std::string &fileName,
305  const std::vector<int> &l)
306 {
307  for(auto &lang : CTX::instance()->scriptLang) {
308  std::ostringstream sstream;
309  if(lang == "geo")
310  sstream << "Recombine Surface " << vector2String(l, lang) << ";";
311  else if(currentFactory == "geo")
312  sstream << api("gmsh/model/geo/mesh/setRecombine", vector2String(l, lang),
313  lang);
314  else
315  sstream << api("gmsh/model/occ/synchronize", "", lang) << "\n"
316  << api("gmsh/model/mesh/setRecombine", vector2String(l, lang),
317  lang);
318  scriptAddCommand(sstream.str(), fileName, lang);
319  }
320 }
321 
322 void scriptSetTransfiniteLine(std::vector<int> &l, const std::string &fileName,
323  const std::string &type,
324  const std::string &typearg,
325  const std::string &pts)
326 {
327  for(auto &lang : CTX::instance()->scriptLang) {
328  std::ostringstream sstream;
329  if(lang == "geo") {
330  sstream << "Transfinite Curve {";
331  for(std::size_t i = 0; i < l.size(); i++) {
332  if(i) sstream << ", ";
333  sstream << l[i];
334  }
335  sstream << "} = " << pts;
336  if(typearg.size()) sstream << " Using " << type << " " << typearg;
337  sstream << ";";
338  }
339  else {
340  // TODO
341  }
342  scriptAddCommand(sstream.str(), fileName, lang);
343  }
344 }
345 
346 void scriptSetTransfiniteSurface(std::vector<int> &l,
347  const std::string &fileName,
348  const std::string &dir)
349 {
350  for(auto &lang : CTX::instance()->scriptLang) {
351  std::ostringstream sstream;
352  if(lang == "geo") {
353  sstream << "Transfinite Surface {" << l[0] << "}";
354  if(l.size() > 1) {
355  sstream << " = {";
356  for(std::size_t i = 1; i < l.size(); i++) {
357  if(i > 1) sstream << ", ";
358  sstream << l[i];
359  }
360  sstream << "}";
361  }
362  if(dir != "Left") sstream << " " << dir;
363  sstream << ";";
364  }
365  else {
366  // TODO
367  }
368  scriptAddCommand(sstream.str(), fileName, lang);
369  }
370 }
371 
372 void scriptSetTransfiniteVolume(std::vector<int> &l,
373  const std::string &fileName)
374 {
375  for(auto &lang : CTX::instance()->scriptLang) {
376  std::ostringstream sstream;
377  if(lang == "geo") {
378  sstream << "Transfinite Volume{" << l[0] << "}";
379  if(l.size() > 1) {
380  sstream << " = {";
381  for(std::size_t i = 1; i < l.size(); i++) {
382  if(i > 1) sstream << ", ";
383  sstream << l[i];
384  }
385  sstream << "}";
386  }
387  sstream << ";";
388  }
389  else {
390  // TODO
391  }
392  scriptAddCommand(sstream.str(), fileName, lang);
393  }
394 }
395 
396 void scriptEmbed(const std::string &fileName, const std::string &what,
397  std::vector<int> &l, int dim, int tag)
398 {
399  for(auto &lang : CTX::instance()->scriptLang) {
400  std::ostringstream sstream;
401  if(lang == "geo") {
402  sstream << what << "" << vector2String(l, lang) << " In ";
403  if(dim == 2)
404  sstream << "Surface{";
405  else
406  sstream << "Volume{";
407  sstream << tag << "};";
408  }
409  else {
410  // TODO
411  }
412  scriptAddCommand(sstream.str(), fileName, lang);
413  }
414 }
415 
416 void scriptAddParameter(const std::string &par, const std::string &value,
417  const std::string &label, const std::string &path,
418  const std::string &fileName)
419 {
420  for(auto &lang : CTX::instance()->scriptLang) {
421  std::ostringstream sstream;
422  if(lang == "geo") {
423  sstream << par << " = DefineNumber[ " << value;
424  sstream << ", Name \"";
425  if(path.size() && label.size())
426  sstream << path << "/" << label;
427  else if(path.size())
428  sstream << path << "/" << par;
429  else if(label.size())
430  sstream << label;
431  else
432  sstream << par;
433  sstream << "\" ];";
434  }
435  else {
436  // TODO
437  }
438  scriptAddCommand(sstream.str(), fileName, lang);
439  }
440 }
441 
442 void scriptAddPoint(const std::string &fileName, const std::string &x,
443  const std::string &y, const std::string &z,
444  const std::string &lc)
445 {
446  for(auto &lang : CTX::instance()->scriptLang) {
447  std::ostringstream sstream;
448  if(lang == "geo") {
449  sstream << "Point(" << GModel::current()->getMaxElementaryNumber(0) + 1
450  << ") = {" << x << ", " << y << ", " << z;
451  if(lc.size()) sstream << ", " << lc;
452  sstream << "};";
453  }
454  else {
455  std::string addPointStr = "gmsh/model/" + currentFactory + "/addPoint";
456  std::ostringstream args;
457  args << x << ", " << y << ", " << z;
458  if(lc.size()) args << ", " << lc;
459  sstream << api(addPointStr, args.str(), lang);
460  }
461  scriptAddCommand(sstream.str(), fileName, lang);
462  }
463 }
464 
465 void scriptAddFieldOption(int field_id, const std::string &option_name,
466  const std::string &option_value, int option_type,
467  const std::string &fileName)
468 {
469 #if defined(HAVE_MESH)
470  for(auto &lang : CTX::instance()->scriptLang) {
471  std::ostringstream sstream;
472  if(lang == "geo") {
473  sstream << "Field[" << field_id << "]." << option_name << " = "
474  << option_value << ";";
475  }
476  else {
477  std::ostringstream args;
478  switch(option_type) {
479  case FIELD_OPTION_DOUBLE:
480  case FIELD_OPTION_INT:
481  case FIELD_OPTION_BOOL:
482  args << field_id << ", \"" << option_name << "\", " << option_value;
483  sstream << api("gmsh/model/mesh/field/setNumber", args.str(), lang);
484  break;
485  case FIELD_OPTION_STRING:
486  case FIELD_OPTION_PATH:
487  args << field_id << ", \"" << option_name << "\", " << option_value;
488  sstream << api("gmsh/model/mesh/field/setString", args.str(), lang);
489  break;
490  case FIELD_OPTION_LIST:
492  std::string list_val = option_value;
493  if(lang == "py" || lang == "jl") {
494  ReplaceSubStringInPlace("{", "[", list_val);
495  ReplaceSubStringInPlace("}", "]", list_val);
496  }
497  args << field_id << ", \"" << option_name << "\", " << list_val;
498  sstream << api("gmsh/model/mesh/field/setNumbers", args.str(), lang);
499  break;
500  }
501  }
502  scriptAddCommand(sstream.str(), fileName, lang);
503  }
504 #endif
505 }
506 
507 void scriptAddField(int field_id, const std::string &type_name,
508  const std::string &fileName)
509 {
510  for(auto &lang : CTX::instance()->scriptLang) {
511  std::ostringstream sstream;
512  if(lang == "geo") {
513  sstream << "Field[" << field_id << "] = " << type_name << ";";
514  }
515  else {
516  std::ostringstream args;
517  args << "\"" << type_name << "\"" << ", " << field_id;
518  sstream << api("gmsh/model/mesh/field/add", args.str(), lang);
519  }
520  scriptAddCommand(sstream.str(), fileName, lang);
521  }
522 }
523 
524 void scriptDeleteField(int field_id, const std::string &fileName)
525 {
526  for(auto &lang : CTX::instance()->scriptLang) {
527  std::ostringstream sstream;
528  if(lang == "geo") { sstream << "Delete Field [" << field_id << "];"; }
529  else {
530  sstream << api("gmsh/model/mesh/field/remove",
531  std::to_string(field_id), lang);
532  }
533  scriptAddCommand(sstream.str(), fileName, lang);
534  }
535 }
536 
537 void scriptSetBackgroundField(int field_id, const std::string &fileName)
538 {
539  for(auto &lang : CTX::instance()->scriptLang) {
540  std::ostringstream sstream;
541  if(lang == "geo") { sstream << "Background Field = " << field_id << ";"; }
542  else {
543  sstream << api("gmsh/model/mesh/field/setAsBackgroundMesh",
544  std::to_string(field_id), lang);
545  }
546  scriptAddCommand(sstream.str(), fileName, lang);
547  }
548 }
549 
550 void scriptAddCurve(const std::string &type, std::vector<int> &p,
551  const std::string &fileName)
552 {
553  for(auto &lang : CTX::instance()->scriptLang) {
554  std::ostringstream sstream;
555  if(lang == "geo") {
556  sstream << type << "(" << GModel::current()->getMaxElementaryNumber(1) + 1
557  << ") = {";
558  for(std::size_t i = 0; i < p.size(); i++) {
559  if(i) sstream << ", ";
560  sstream << p[i];
561  }
562  sstream << "};";
563  }
564  else {
565  // TODO
566  }
567  scriptAddCommand(sstream.str(), fileName, lang);
568  }
569 }
570 
571 void scriptAddCircleArc(int p1, int p2, int p3, const std::string &fileName)
572 {
573  for(auto &lang : CTX::instance()->scriptLang) {
574  std::ostringstream sstream;
575  if(lang == "geo") {
576  sstream << "Circle(" << GModel::current()->getMaxElementaryNumber(1) + 1
577  << ") = {" << p1 << ", " << p2 << ", " << p3 << "};";
578  }
579  else {
580  // TODO
581  }
582  scriptAddCommand(sstream.str(), fileName, lang);
583  }
584 }
585 
586 void scriptAddEllipseArc(int p1, int p2, int p3, int p4,
587  const std::string &fileName)
588 {
589  for(auto &lang : CTX::instance()->scriptLang) {
590  std::ostringstream sstream;
591  if(lang == "geo") {
592  sstream << "Ellipse(" << GModel::current()->getMaxElementaryNumber(1) + 1
593  << ") = {" << p1 << ", " << p2 << ", " << p3 << ", " << p4
594  << "};";
595  }
596  else {
597  // TODO
598  }
599  scriptAddCommand(sstream.str(), fileName, lang);
600  }
601 }
602 
603 void scriptAddCurveLoop(List_T *list, const std::string &fileName, int *numloop)
604 {
605  if(RecognizeLineLoop(list, numloop)) return;
606  *numloop = GModel::current()->getGEOInternals()->getMaxTag(-1) + 1;
607  if(GModel::current()->getOCCInternals())
608  *numloop = std::max(
609  *numloop, GModel::current()->getOCCInternals()->getMaxTag(-1) + 1);
610 
611  for(auto &lang : CTX::instance()->scriptLang) {
612  std::ostringstream sstream;
613  if(lang == "geo") {
614  sstream << "Curve Loop(" << *numloop << ") = " << list2String(list, lang)
615  << ";";
616  }
617  else {
618  // TODO
619  }
620  scriptAddCommand(sstream.str(), fileName, lang);
621  }
622 }
623 
624 void scriptAddSurface(const std::string &type, List_T *list,
625  const std::string &fileName)
626 {
627  for(auto &lang : CTX::instance()->scriptLang) {
628  std::ostringstream sstream;
629  if(lang == "geo") {
630  sstream << type << "(" << GModel::current()->getMaxElementaryNumber(2) + 1
631  << ") = " << list2String(list, lang) << ";";
632  }
633  else {
634  // TODO
635  }
636  scriptAddCommand(sstream.str(), fileName, lang);
637  }
638 }
639 
640 void scriptAddSurfaceLoop(List_T *list, const std::string &fileName,
641  int *numloop)
642 {
643  if(RecognizeSurfaceLoop(list, numloop)) return;
644  *numloop = GModel::current()->getGEOInternals()->getMaxTag(-2) + 1;
645  if(GModel::current()->getOCCInternals())
646  *numloop = std::max(
647  *numloop, GModel::current()->getOCCInternals()->getMaxTag(-2) + 1);
648 
649  for(auto &lang : CTX::instance()->scriptLang) {
650  std::ostringstream sstream;
651  if(lang == "geo") {
652  sstream << "Surface Loop(" << *numloop
653  << ") = " << list2String(list, lang) << ";";
654  }
655  else {
656  // TODO
657  }
658  scriptAddCommand(sstream.str(), fileName, lang);
659  }
660 }
661 
662 void scriptAddVolume(List_T *list, const std::string &fileName)
663 {
664  for(auto &lang : CTX::instance()->scriptLang) {
665  std::ostringstream sstream;
666  if(lang == "geo") {
667  sstream << "Volume(" << GModel::current()->getMaxElementaryNumber(3) + 1
668  << ") = " << list2String(list, lang) << ";";
669  }
670  else {
671  // TODO
672  }
673  scriptAddCommand(sstream.str(), fileName, lang);
674  }
675 }
676 
677 void scriptAddRemovePhysicalGroup(const std::string &fileName,
678  const std::string &what,
679  const std::vector<int> &l,
680  const std::string &name, int forceTag,
681  bool append, const std::string &mode)
682 {
683  for(auto &lang : CTX::instance()->scriptLang) {
684  std::ostringstream sstream;
685  if(lang == "geo") {
686  sstream << "Physical " << what << "(";
687  if(name.size()) {
688  sstream << "\"" << name << "\"";
689  if(forceTag) sstream << ", " << forceTag;
690  }
691  else {
692  sstream
693  << (forceTag ?
694  forceTag :
696  }
697  sstream << ") ";
698  if(mode == "Remove")
699  sstream << "-";
700  else if(append)
701  sstream << "+";
702  sstream << "= " << vector2String(l, lang) << ";";
703  }
704  else {
705  // TODO
706  }
707  scriptAddCommand(sstream.str(), fileName, lang);
708  }
709 }
710 
711 void scriptSetCompound(const std::string &fileName, const std::string &type,
712  const std::vector<int> &l)
713 {
714  for(auto &lang : CTX::instance()->scriptLang) {
715  std::ostringstream sstream;
716  if(lang == "geo") {
717  sstream << "Compound " << type << " " << vector2String(l, lang) << ";";
718  }
719  else {
720  // TODO
721  }
722  scriptAddCommand(sstream.str(), fileName, lang);
723  }
724 }
725 
726 void scriptAddCircle(const std::string &fileName, const std::string &x,
727  const std::string &y, const std::string &z,
728  const std::string &r, const std::string &alpha1,
729  const std::string &alpha2)
730 {
731  for(auto &lang : CTX::instance()->scriptLang) {
732  std::ostringstream sstream;
733  checkOCC(sstream, lang);
734  if(lang == "geo") {
735  sstream << "Circle(" << GModel::current()->getMaxElementaryNumber(1) + 1
736  << ") = {" << x << ", " << y << ", " << z << ", " << r;
737  if(alpha1.size()) sstream << ", " << alpha1;
738  if(alpha1.size() && alpha2.size()) sstream << ", " << alpha2;
739  sstream << "};";
740  }
741  else {
742  // TODO
743  }
744  scriptAddCommand(sstream.str(), fileName, lang);
745  }
746 }
747 
748 void scriptAddEllipse(const std::string &fileName, const std::string &x,
749  const std::string &y, const std::string &z,
750  const std::string &rx, const std::string &ry,
751  const std::string &alpha1, const std::string &alpha2)
752 {
753  for(auto &lang : CTX::instance()->scriptLang) {
754  std::ostringstream sstream;
755  checkOCC(sstream, lang);
756  if(lang == "geo") {
757  sstream << "Ellipse(" << GModel::current()->getMaxElementaryNumber(1) + 1
758  << ") = {" << x << ", " << y << ", " << z << ", " << rx << ", "
759  << ry;
760  if(alpha1.size()) sstream << ", " << alpha1;
761  if(alpha1.size() && alpha2.size()) sstream << ", " << alpha2;
762  sstream << "};";
763  }
764  else {
765  // TODO
766  }
767  scriptAddCommand(sstream.str(), fileName, lang);
768  }
769 }
770 
771 void scriptAddDisk(const std::string &fileName, const std::string &x,
772  const std::string &y, const std::string &z,
773  const std::string &rx, const std::string &ry)
774 {
775  for(auto &lang : CTX::instance()->scriptLang) {
776  std::ostringstream sstream;
777  checkOCC(sstream, lang);
778  if(lang == "geo") {
779  sstream << "Disk(" << GModel::current()->getMaxElementaryNumber(2) + 1
780  << ") = {" << x << ", " << y << ", " << z << ", " << rx << ", "
781  << ry << "};";
782  }
783  else {
784  // TODO
785  }
786  scriptAddCommand(sstream.str(), fileName, lang);
787  }
788 }
789 
790 void scriptAddRectangle(const std::string &fileName, const std::string &x,
791  const std::string &y, const std::string &z,
792  const std::string &dx, const std::string &dy,
793  const std::string &roundedRadius)
794 {
795  for(auto &lang : CTX::instance()->scriptLang) {
796  std::ostringstream sstream;
797  checkOCC(sstream, lang);
798  if(lang == "geo") {
799  sstream << "Rectangle("
800  << GModel::current()->getMaxElementaryNumber(2) + 1 << ") = {"
801  << x << ", " << y << ", " << z << ", " << dx << ", " << dy;
802  if(roundedRadius.size()) sstream << ", " << roundedRadius;
803  sstream << "};";
804  }
805  else {
806  // TODO
807  }
808  scriptAddCommand(sstream.str(), fileName, lang);
809  }
810 }
811 
812 void scriptAddSphere(const std::string &fileName, const std::string &x,
813  const std::string &y, const std::string &z,
814  const std::string &r, const std::string &alpha1,
815  const std::string &alpha2, const std::string &alpha3)
816 {
817  for(auto &lang : CTX::instance()->scriptLang) {
818  std::ostringstream sstream;
819  checkOCC(sstream, lang);
820  if(lang == "geo") {
821  sstream << "Sphere(" << GModel::current()->getMaxElementaryNumber(3) + 1
822  << ") = {" << x << ", " << y << ", " << z << ", " << r;
823  if(alpha1.size()) sstream << ", " << alpha1;
824  if(alpha1.size() && alpha2.size()) sstream << ", " << alpha2;
825  if(alpha1.size() && alpha2.size() && alpha3.size())
826  sstream << ", " << alpha3;
827  sstream << "};";
828  }
829  else {
830  // TODO
831  }
832  scriptAddCommand(sstream.str(), fileName, lang);
833  }
834 }
835 
836 void scriptAddCylinder(const std::string &fileName, const std::string &x,
837  const std::string &y, const std::string &z,
838  const std::string &dx, const std::string &dy,
839  const std::string &dz, const std::string &r,
840  const std::string &alpha)
841 {
842  for(auto &lang : CTX::instance()->scriptLang) {
843  std::ostringstream sstream;
844  checkOCC(sstream, lang);
845  if(lang == "geo") {
846  sstream << "Cylinder(" << GModel::current()->getMaxElementaryNumber(3) + 1
847  << ") = {" << x << ", " << y << ", " << z << ", " << dx << ", "
848  << dy << ", " << dz << ", " << r;
849  if(alpha.size()) sstream << ", " << alpha;
850  sstream << "};";
851  }
852  else {
853  // TODO
854  }
855  scriptAddCommand(sstream.str(), fileName, lang);
856  }
857 }
858 
859 void scriptAddBox(const std::string &fileName, const std::string &x,
860  const std::string &y, const std::string &z,
861  const std::string &dx, const std::string &dy,
862  const std::string &dz)
863 {
864  for(auto &lang : CTX::instance()->scriptLang) {
865  std::ostringstream sstream;
866  checkOCC(sstream, lang);
867  if(lang == "geo") {
868  sstream << "Box(" << GModel::current()->getMaxElementaryNumber(3) + 1
869  << ") = {" << x << ", " << y << ", " << z << ", " << dx << ", "
870  << dy << ", " << dz << "};";
871  }
872  else {
873  // TODO
874  }
875  scriptAddCommand(sstream.str(), fileName, lang);
876  }
877 }
878 
879 void scriptAddTorus(const std::string &fileName, const std::string &x,
880  const std::string &y, const std::string &z,
881  const std::string &r1, const std::string &r2,
882  const std::string &alpha)
883 {
884  for(auto &lang : CTX::instance()->scriptLang) {
885  std::ostringstream sstream;
886  checkOCC(sstream, lang);
887  if(lang == "geo") {
888  sstream << "Torus(" << GModel::current()->getMaxElementaryNumber(3) + 1
889  << ") = {" << x << ", " << y << ", " << z << ", " << r1 << ", "
890  << r2;
891  if(alpha.size()) sstream << ", " << alpha;
892  sstream << "};";
893  }
894  else {
895  // TODO
896  }
897  scriptAddCommand(sstream.str(), fileName, lang);
898  }
899 }
900 
901 void scriptAddCone(const std::string &fileName, const std::string &x,
902  const std::string &y, const std::string &z,
903  const std::string &dx, const std::string &dy,
904  const std::string &dz, const std::string &r1,
905  const std::string &r2, const std::string &alpha)
906 {
907  for(auto &lang : CTX::instance()->scriptLang) {
908  std::ostringstream sstream;
909  checkOCC(sstream, lang);
910  if(lang == "geo") {
911  sstream << "Cone(" << GModel::current()->getMaxElementaryNumber(3) + 1
912  << ") = {" << x << ", " << y << ", " << z << ", " << dx << ", "
913  << dy << ", " << dz << ", " << r1 << ", " << r2;
914  if(alpha.size()) sstream << ", " << alpha;
915  sstream << "};";
916  }
917  else {
918  // TODO
919  }
920  scriptAddCommand(sstream.str(), fileName, lang);
921  }
922 }
923 
924 void scriptAddWedge(const std::string &fileName, const std::string &x,
925  const std::string &y, const std::string &z,
926  const std::string &dx, const std::string &dy,
927  const std::string &dz, const std::string &ltx)
928 {
929  for(auto &lang : CTX::instance()->scriptLang) {
930  std::ostringstream sstream;
931  checkOCC(sstream, lang);
932  if(lang == "geo") {
933  sstream << "Wedge(" << GModel::current()->getMaxElementaryNumber(3) + 1
934  << ") = {" << x << ", " << y << ", " << z << ", " << dx << ", "
935  << dy << ", " << dz << ", " << ltx << "};";
936  }
937  else {
938  // TODO
939  }
940  scriptAddCommand(sstream.str(), fileName, lang);
941  }
942 }
943 
944 void scriptTranslate(const std::string &fileName,
945  const std::vector<std::pair<int, int> > &l,
946  const std::string &tx, const std::string &ty,
947  const std::string &tz, bool duplicata)
948 {
949  for(auto &lang : CTX::instance()->scriptLang) {
950  std::ostringstream sstream;
951  if(lang == "geo") {
952  sstream << "Translate {" << tx << ", " << ty << ", " << tz << "} {\n ";
953  if(duplicata) sstream << "Duplicata { ";
954  sstream << dimTags2String(l, lang);
955  if(duplicata) sstream << "}";
956  sstream << "\n}";
957  }
958  else {
959  // TODO
960  }
961  scriptAddCommand(sstream.str(), fileName, lang);
962  }
963 }
964 
965 void scriptRotate(const std::string &fileName,
966  const std::vector<std::pair<int, int> > &l,
967  const std::string &ax, const std::string &ay,
968  const std::string &az, const std::string &px,
969  const std::string &py, const std::string &pz,
970  const std::string &angle, bool duplicata)
971 {
972  for(auto &lang : CTX::instance()->scriptLang) {
973  std::ostringstream sstream;
974  if(lang == "geo") {
975  sstream << "Rotate {{" << ax << ", " << ay << ", " << az << "}, {" << px
976  << ", " << py << ", " << pz << "}, " << angle << "} {\n ";
977  if(duplicata) sstream << "Duplicata { ";
978  sstream << dimTags2String(l, lang);
979  if(duplicata) sstream << "}";
980  sstream << "\n}";
981  }
982  else {
983  // TODO
984  }
985  scriptAddCommand(sstream.str(), fileName, lang);
986  }
987 }
988 
989 void scriptDilate(const std::string &fileName,
990  const std::vector<std::pair<int, int> > &l,
991  const std::string &cx, const std::string &cy,
992  const std::string &cz, const std::string &sx,
993  const std::string &sy, const std::string &sz, bool duplicata)
994 {
995  for(auto &lang : CTX::instance()->scriptLang) {
996  std::ostringstream sstream;
997  if(lang == "geo") {
998  sstream << "Dilate {{" << cx << ", " << cy << ", " << cz << "}, {" << sx
999  << ", " << sy << ", " << sz << "}} {\n ";
1000  if(duplicata) sstream << "Duplicata { ";
1001  sstream << dimTags2String(l, lang);
1002  if(duplicata) sstream << "}";
1003  sstream << "\n}";
1004  }
1005  else {
1006  // TODO
1007  }
1008  scriptAddCommand(sstream.str(), fileName, lang);
1009  }
1010 }
1011 
1012 void scriptMirror(const std::string &fileName,
1013  const std::vector<std::pair<int, int> > &l,
1014  const std::string &sa, const std::string &sb,
1015  const std::string &sc, const std::string &sd, bool duplicata)
1016 {
1017  for(auto &lang : CTX::instance()->scriptLang) {
1018  std::ostringstream sstream;
1019  if(lang == "geo") {
1020  sstream << "Symmetry {" << sa << ", " << sb << ", " << sc << ", " << sd
1021  << "} {\n ";
1022  if(duplicata) sstream << "Duplicata { ";
1023  sstream << dimTags2String(l, lang);
1024  if(duplicata) sstream << "}";
1025  sstream << "\n}";
1026  }
1027  else {
1028  // TODO
1029  }
1030  scriptAddCommand(sstream.str(), fileName, lang);
1031  }
1032 }
1033 
1034 void scriptExtrude(const std::string &fileName,
1035  const std::vector<std::pair<int, int> > &l,
1036  const std::string &tx, const std::string &ty,
1037  const std::string &tz, bool extrudeMesh,
1038  const std::string &layers, bool recombineMesh)
1039 {
1040  for(auto &lang : CTX::instance()->scriptLang) {
1041  std::ostringstream sstream;
1042  if(lang == "geo") {
1043  sstream << "Extrude {" << tx << ", " << ty << ", " << tz << "} {\n "
1044  << dimTags2String(l, lang);
1045  if(extrudeMesh) {
1046  sstream << "Layers {" << layers << "}; ";
1047  if(recombineMesh) sstream << "Recombine;";
1048  }
1049  sstream << "\n}";
1050  }
1051  else {
1052  // TODO
1053  }
1054  scriptAddCommand(sstream.str(), fileName, lang);
1055  }
1056 }
1057 
1058 void scriptProtude(const std::string &fileName,
1059  const std::vector<std::pair<int, int> > &l,
1060  const std::string &ax, const std::string &ay,
1061  const std::string &az, const std::string &px,
1062  const std::string &py, const std::string &pz,
1063  const std::string &angle, bool extrudeMesh,
1064  const std::string &layers, bool recombineMesh)
1065 {
1066  for(auto &lang : CTX::instance()->scriptLang) {
1067  std::ostringstream sstream;
1068  if(lang == "geo") {
1069  sstream << "Extrude {{" << ax << ", " << ay << ", " << az << "}, {" << px
1070  << ", " << py << ", " << pz << "}, " << angle << "} {\n "
1071  << dimTags2String(l, lang);
1072  if(extrudeMesh) {
1073  sstream << "Layers{" << layers << "}; ";
1074  if(recombineMesh) sstream << "Recombine;";
1075  }
1076  sstream << "\n}";
1077  }
1078  else {
1079  // TODO
1080  }
1081  scriptAddCommand(sstream.str(), fileName, lang);
1082  }
1083 }
1084 
1085 void scriptAddPipe(const std::string &fileName,
1086  const std::vector<std::pair<int, int> > &l,
1087  const std::vector<int> &l2)
1088 {
1089  for(auto &lang : CTX::instance()->scriptLang) {
1090  std::ostringstream sstream;
1091  checkOCC(sstream, lang);
1092  if(lang == "geo") {
1093  int wire = GModel::current()->getGEOInternals()->getMaxTag(-1) + 1;
1094  if(GModel::current()->getOCCInternals())
1095  wire = std::max(
1096  wire, GModel::current()->getOCCInternals()->getMaxTag(-1) + 1);
1097  sstream << "Wire(" << wire << ") = " << vector2String(l2, lang) << ";\n";
1098  sstream << "Extrude { " << dimTags2String(l, lang) << "} Using Wire {"
1099  << wire << "}\n";
1100  }
1101  else {
1102  // TODO
1103  }
1104  scriptAddCommand(sstream.str(), fileName, lang);
1105  }
1106 }
1107 
1108 void scriptSplitCurve(int edge_id, List_T *vertices,
1109  const std::string &fileName)
1110 {
1111  for(auto &lang : CTX::instance()->scriptLang) {
1112  std::ostringstream sstream;
1113  if(lang == "geo") {
1114  sstream << "Split Curve {" << edge_id << "} Point "
1115  << list2String(vertices, lang) << ";";
1116  }
1117  else {
1118  // TODO
1119  }
1120  scriptAddCommand(sstream.str(), fileName, lang);
1121  }
1122 }
1123 
1124 void scriptBoolean(const std::string &fileName, const std::string &op,
1125  const std::vector<std::pair<int, int> > &object,
1126  const std::vector<std::pair<int, int> > &tool,
1127  int deleteObject, int deleteTool)
1128 {
1129  for(auto &lang : CTX::instance()->scriptLang) {
1130  std::ostringstream sstream;
1131  checkOCC(sstream, lang);
1132  if(lang == "geo") {
1133  sstream << op << "{ " << dimTags2String(object, lang);
1134  if(deleteObject) sstream << "Delete; ";
1135  sstream << "}{ " << dimTags2String(tool, lang);
1136  if(deleteTool) sstream << "Delete; ";
1137  sstream << "}";
1138  }
1139  else {
1140  // TODO
1141  }
1142  scriptAddCommand(sstream.str(), fileName, lang);
1143  }
1144 }
1145 
1146 void scriptFillet(const std::string &fileName, const std::vector<int> &regions,
1147  const std::vector<int> &edges, const std::string &radius)
1148 {
1149  for(auto &lang : CTX::instance()->scriptLang) {
1150  std::ostringstream sstream;
1151  checkOCC(sstream, lang);
1152  if(lang == "geo") {
1153  sstream << "Fillet " << vector2String(regions, lang)
1154  << vector2String(edges, lang) << "{" << radius << "}";
1155  }
1156  else {
1157  // TODO
1158  }
1159  scriptAddCommand(sstream.str(), fileName, lang);
1160  }
1161 }
1162 
1163 void scriptCoherence(const std::string &fileName)
1164 {
1165  for(auto &lang : CTX::instance()->scriptLang) {
1166  if(lang == "geo") { scriptAddCommand("Coherence;", fileName, lang); }
1167  else {
1168  // TODO
1169  }
1170  }
1171 }
1172 
1173 void scriptDeleteEntities(const std::string &fileName,
1174  const std::vector<std::pair<int, int> > &l,
1175  bool recursive)
1176 {
1177  for(auto &lang : CTX::instance()->scriptLang) {
1178  std::ostringstream sstream;
1179  if(lang == "geo") {
1180  if(recursive) sstream << "Recursive ";
1181  sstream << "Delete {\n " << dimTags2String(l, lang) << "\n}";
1182  }
1183  else {
1184  // TODO
1185  }
1186  scriptAddCommand(sstream.str(), fileName, lang);
1187  }
1188 }
1189 
1190 void scriptSetVisibilityAll(int mode, const std::string &fileName)
1191 {
1192  for(auto &lang : CTX::instance()->scriptLang) {
1193  if(lang == "geo") {
1194  if(mode)
1195  scriptAddCommand("Show \"*\";", fileName, lang);
1196  else
1197  scriptAddCommand("Hide \"*\";", fileName, lang);
1198  }
1199  else {
1200  // TODO
1201  }
1202  }
1203 }
1204 
1205 void scriptSetVisibility(int mode, const std::vector<std::pair<int, int> > &l,
1206  const std::string &fileName)
1207 {
1208  for(auto &lang : CTX::instance()->scriptLang) {
1209  std::ostringstream sstream;
1210  if(lang == "geo") {
1211  if(mode)
1212  sstream << "Show {\n " << dimTags2String(l, lang) << "\n}";
1213  else
1214  sstream << "Hide {\n " << dimTags2String(l, lang) << "\n}";
1215  }
1216  else {
1217  // TODO
1218  }
1219  scriptAddCommand(sstream.str(), fileName, lang);
1220  }
1221 }
scriptDilate
void scriptDilate(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &cx, const std::string &cy, const std::string &cz, const std::string &sx, const std::string &sy, const std::string &sz, bool duplicata)
Definition: scriptStringInterface.cpp:989
scriptAddVolume
void scriptAddVolume(List_T *list, const std::string &fileName)
Definition: scriptStringInterface.cpp:662
Geo.h
SplitFileName
std::vector< std::string > SplitFileName(const std::string &fileName)
Definition: StringUtils.cpp:93
Field.h
scriptAddParameter
void scriptAddParameter(const std::string &par, const std::string &value, const std::string &label, const std::string &path, const std::string &fileName)
Definition: scriptStringInterface.cpp:416
GEO_Internals::getMaxTag
int getMaxTag(int dim) const
Definition: GModelIO_GEO.cpp:99
scriptAddDisk
void scriptAddDisk(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &rx, const std::string &ry)
Definition: scriptStringInterface.cpp:771
scriptFillet
void scriptFillet(const std::string &fileName, const std::vector< int > &regions, const std::vector< int > &edges, const std::string &radius)
Definition: scriptStringInterface.cpp:1146
scriptAddRemovePhysicalGroup
void scriptAddRemovePhysicalGroup(const std::string &fileName, const std::string &what, const std::vector< int > &l, const std::string &name, int forceTag, bool append, const std::string &mode)
Definition: scriptStringInterface.cpp:677
scriptAddSurface
void scriptAddSurface(const std::string &type, List_T *list, const std::string &fileName)
Definition: scriptStringInterface.cpp:624
GModel::getMaxElementaryNumber
int getMaxElementaryNumber(int dim)
Definition: GModel.cpp:817
scriptAddWedge
void scriptAddWedge(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &dx, const std::string &dy, const std::string &dz, const std::string &ltx)
Definition: scriptStringInterface.cpp:924
scriptCoherence
void scriptCoherence(const std::string &fileName)
Definition: scriptStringInterface.cpp:1163
CTX::homeDir
std::string homeDir
Definition: Context.h:147
checkOCC
static void checkOCC(std::ostringstream &sstream, const std::string &lang)
Definition: scriptStringInterface.cpp:248
angle
double angle(const SVector3 &a, const SVector3 &b)
Definition: SVector3.h:157
OS.h
Msg::Debug
static void Debug(const char *fmt,...)
Definition: GmshMessage.cpp:752
scriptAddPoint
void scriptAddPoint(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &lc)
Definition: scriptStringInterface.cpp:442
List_T
Definition: ListUtils.h:9
Msg::Warning
static void Warning(const char *fmt,...)
Definition: GmshMessage.cpp:543
Msg::Error
static void Error(const char *fmt,...)
Definition: GmshMessage.cpp:482
List_Nbr
int List_Nbr(List_T *liste)
Definition: ListUtils.cpp:106
Msg::ImportPhysicalGroupsInOnelab
static void ImportPhysicalGroupsInOnelab()
Definition: GmshMessage.cpp:1523
scriptAddTorus
void scriptAddTorus(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &r1, const std::string &r2, const std::string &alpha)
Definition: scriptStringInterface.cpp:879
GModelIO_OCC.h
scriptAddCurve
void scriptAddCurve(const std::string &type, std::vector< int > &p, const std::string &fileName)
Definition: scriptStringInterface.cpp:550
GModelIO_GEO.h
FIELD_OPTION_PATH
@ FIELD_OPTION_PATH
Definition: Field.h:33
GmshMessage.h
edges
static int edges[6][2]
Definition: meshGRegionLocalMeshMod.cpp:23
scriptSetBackgroundField
void scriptSetBackgroundField(int field_id, const std::string &fileName)
Definition: scriptStringInterface.cpp:537
scriptTranslate
void scriptTranslate(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &tx, const std::string &ty, const std::string &tz, bool duplicata)
Definition: scriptStringInterface.cpp:944
scriptAddEllipseArc
void scriptAddEllipseArc(int p1, int p2, int p3, int p4, const std::string &fileName)
Definition: scriptStringInterface.cpp:586
scriptSetFactory
void scriptSetFactory(const std::string &factory, const std::string &fileName)
Definition: scriptStringInterface.cpp:259
Fopen
FILE * Fopen(const char *f, const char *mode)
Definition: OS.cpp:273
scriptEmbed
void scriptEmbed(const std::string &fileName, const std::string &what, std::vector< int > &l, int dim, int tag)
Definition: scriptStringInterface.cpp:396
CTX::instance
static CTX * instance()
Definition: Context.cpp:122
dimTags2String
static std::string dimTags2String(const std::vector< std::pair< int, int > > &l, const std::string &lang)
Definition: scriptStringInterface.cpp:208
scriptSetMeshSize
void scriptSetMeshSize(const std::string &fileName, const std::vector< int > &l, const std::string &lc)
Definition: scriptStringInterface.cpp:286
scriptSetVisibility
void scriptSetVisibility(int mode, const std::vector< std::pair< int, int > > &l, const std::string &fileName)
Definition: scriptStringInterface.cpp:1205
GModel::setName
void setName(const std::string &name)
Definition: GModel.h:328
scriptSetTransfiniteVolume
void scriptSetTransfiniteVolume(std::vector< int > &l, const std::string &fileName)
Definition: scriptStringInterface.cpp:372
GModel::setFileName
void setFileName(const std::string &fileName)
Definition: GModel.cpp:123
FIELD_OPTION_BOOL
@ FIELD_OPTION_BOOL
Definition: Field.h:34
gmsh_yyin
FILE * gmsh_yyin
scriptAddCommand
static void scriptAddCommand(const std::string &text, const std::string &fileNameOrEmpty, const std::string &lang)
Definition: scriptStringInterface.cpp:30
OpenProject
void OpenProject(const std::string &fileName, bool errorIfMissing)
Definition: OpenFile.cpp:718
ReplaceSubStringInPlace
void ReplaceSubStringInPlace(const std::string &olds, const std::string &news, std::string &str)
Definition: StringUtils.cpp:130
scriptAddCircle
void scriptAddCircle(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &r, const std::string &alpha1, const std::string &alpha2)
Definition: scriptStringInterface.cpp:726
scriptAddSurfaceLoop
void scriptAddSurfaceLoop(List_T *list, const std::string &fileName, int *numloop)
Definition: scriptStringInterface.cpp:640
scriptAddField
void scriptAddField(int field_id, const std::string &type_name, const std::string &fileName)
Definition: scriptStringInterface.cpp:507
list2String
static std::string list2String(List_T *list, const std::string &lang)
Definition: scriptStringInterface.cpp:169
scriptAddPipe
void scriptAddPipe(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::vector< int > &l2)
Definition: scriptStringInterface.cpp:1085
Numeric.h
ReplaceSubString
std::string ReplaceSubString(const std::string &olds, const std::string &news, const std::string &str)
Definition: StringUtils.cpp:140
scriptSetTransfiniteSurface
void scriptSetTransfiniteSurface(std::vector< int > &l, const std::string &fileName, const std::string &dir)
Definition: scriptStringInterface.cpp:346
onelab.h
Msg::SetOnelabChanged
static void SetOnelabChanged(int value, const std::string &client="Gmsh")
Definition: GmshMessage.cpp:1612
scriptSplitCurve
void scriptSplitCurve(int edge_id, List_T *vertices, const std::string &fileName)
Definition: scriptStringInterface.cpp:1108
scriptAddSphere
void scriptAddSphere(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &r, const std::string &alpha1, const std::string &alpha2, const std::string &alpha3)
Definition: scriptStringInterface.cpp:812
FIELD_OPTION_DOUBLE
@ FIELD_OPTION_DOUBLE
Definition: Field.h:30
GEO_Internals::getMaxPhysicalTag
int getMaxPhysicalTag() const
Definition: GModelIO_GEO.h:132
extrudeMesh
static void extrudeMesh(GVertex *from, GEdge *to)
Definition: meshGEdgeExtruded.cpp:26
scriptMirror
void scriptMirror(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &sa, const std::string &sb, const std::string &sc, const std::string &sd, bool duplicata)
Definition: scriptStringInterface.cpp:1012
FIELD_OPTION_LIST
@ FIELD_OPTION_LIST
Definition: Field.h:35
scriptAddCircleArc
void scriptAddCircleArc(int p1, int p2, int p3, const std::string &fileName)
Definition: scriptStringInterface.cpp:571
CTX::mesh
contextMeshOptions mesh
Definition: Context.h:313
Parser.h
scriptAddBox
void scriptAddBox(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &dx, const std::string &dy, const std::string &dz)
Definition: scriptStringInterface.cpp:859
scriptDeleteEntities
void scriptDeleteEntities(const std::string &fileName, const std::vector< std::pair< int, int > > &l, bool recursive)
Definition: scriptStringInterface.cpp:1173
scriptBoolean
void scriptBoolean(const std::string &fileName, const std::string &op, const std::vector< std::pair< int, int > > &object, const std::vector< std::pair< int, int > > &tool, int deleteObject, int deleteTool)
Definition: scriptStringInterface.cpp:1124
scriptSetCompound
void scriptSetCompound(const std::string &fileName, const std::string &type, const std::vector< int > &l)
Definition: scriptStringInterface.cpp:711
StatFile
int StatFile(const std::string &fileName)
Definition: OS.cpp:489
StringUtils.h
contextMeshOptions::changed
int changed
Definition: Context.h:82
scriptSetTransfiniteLine
void scriptSetTransfiniteLine(std::vector< int > &l, const std::string &fileName, const std::string &type, const std::string &typearg, const std::string &pts)
Definition: scriptStringInterface.cpp:322
FIELD_OPTION_INT
@ FIELD_OPTION_INT
Definition: Field.h:31
vector2String
static std::string vector2String(const std::vector< int > &v, const std::string &lang)
Definition: scriptStringInterface.cpp:189
scriptRecombineSurface
void scriptRecombineSurface(const std::string &fileName, const std::vector< int > &l)
Definition: scriptStringInterface.cpp:304
RecognizeLineLoop
int RecognizeLineLoop(List_T *liste, int *loop)
Definition: Geo.cpp:1214
ENT_ALL
#define ENT_ALL
Definition: GmshDefines.h:235
Context.h
scriptExtrude
void scriptExtrude(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &tx, const std::string &ty, const std::string &tz, bool extrudeMesh, const std::string &layers, bool recombineMesh)
Definition: scriptStringInterface.cpp:1034
Msg::GetAnswer
static int GetAnswer(const char *question, int defaultval, const char *zero, const char *one, const char *two=nullptr)
Definition: GmshMessage.cpp:952
RecognizeSurfaceLoop
int RecognizeSurfaceLoop(List_T *liste, int *loop)
Definition: Geo.cpp:1232
z
const double z
Definition: GaussQuadratureQuad.cpp:56
scriptAddFieldOption
void scriptAddFieldOption(int field_id, const std::string &option_name, const std::string &option_value, int option_type, const std::string &fileName)
Definition: scriptStringInterface.cpp:465
scriptDeleteField
void scriptDeleteField(int field_id, const std::string &fileName)
Definition: scriptStringInterface.cpp:524
api
static std::string api(const std::string &name, const std::string &args, const std::string &lang)
Definition: scriptStringInterface.cpp:274
scriptAddCurveLoop
void scriptAddCurveLoop(List_T *list, const std::string &fileName, int *numloop)
Definition: scriptStringInterface.cpp:603
gmsh_yyparse
int gmsh_yyparse()
OCC_Internals::synchronize
void synchronize(GModel *model)
Definition: GModelIO_OCC.h:803
scriptProtude
void scriptProtude(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &ax, const std::string &ay, const std::string &az, const std::string &px, const std::string &py, const std::string &pz, const std::string &angle, bool extrudeMesh, const std::string &layers, bool recombineMesh)
Definition: scriptStringInterface.cpp:1058
currentFactory
static std::string currentFactory
Definition: scriptStringInterface.cpp:246
scriptAddRectangle
void scriptAddRectangle(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &dx, const std::string &dy, const std::string &roundedRadius)
Definition: scriptStringInterface.cpp:790
FIELD_OPTION_LIST_DOUBLE
@ FIELD_OPTION_LIST_DOUBLE
Definition: Field.h:36
GModel.h
scriptAddCylinder
void scriptAddCylinder(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &dx, const std::string &dy, const std::string &dz, const std::string &r, const std::string &alpha)
Definition: scriptStringInterface.cpp:836
scriptAddCone
void scriptAddCone(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &dx, const std::string &dy, const std::string &dz, const std::string &r1, const std::string &r2, const std::string &alpha)
Definition: scriptStringInterface.cpp:901
gmsh_yyfactory
std::string gmsh_yyfactory
Definition: Gmsh.tab.cpp:645
CTX::tmpFileName
std::string tmpFileName
Definition: Context.h:141
GEO_Internals::synchronize
void synchronize(GModel *model, bool resetMeshAttributes=true)
Definition: GModelIO_GEO.cpp:1370
GModel::getGEOInternals
GEO_Internals * getGEOInternals()
Definition: GModel.h:315
scriptRemoveLastCommand
void scriptRemoveLastCommand(const std::string &fileName)
Definition: scriptStringInterface.cpp:142
GModel::getOCCInternals
OCC_Internals * getOCCInternals()
Definition: GModel.h:314
List_Read
void List_Read(List_T *liste, int index, void *data)
Definition: ListUtils.cpp:111
scriptAddEllipse
void scriptAddEllipse(const std::string &fileName, const std::string &x, const std::string &y, const std::string &z, const std::string &rx, const std::string &ry, const std::string &alpha1, const std::string &alpha2)
Definition: scriptStringInterface.cpp:748
OpenFile.h
GModel::current
static GModel * current(int index=-1)
Definition: GModel.cpp:136
scriptSetVisibilityAll
void scriptSetVisibilityAll(int mode, const std::string &fileName)
Definition: scriptStringInterface.cpp:1190
scriptRotate
void scriptRotate(const std::string &fileName, const std::vector< std::pair< int, int > > &l, const std::string &ax, const std::string &ay, const std::string &az, const std::string &px, const std::string &py, const std::string &pz, const std::string &angle, bool duplicata)
Definition: scriptStringInterface.cpp:965
FIELD_OPTION_STRING
@ FIELD_OPTION_STRING
Definition: Field.h:32
scriptStringInterface.h