[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

C. Programming notes

Gmsh is written in C++, the scripting language is parsed using Lex and Yacc (actually, Flex and Bison), and the GUI relies on OpenGL for the 3D graphics and FLTK (http://www.fltk.org) for the widget set. Gmsh's build system is based on autoconf. Practical notes on how to compile Gmsh's source code are included in the distribution. See E. Frequently asked questions, for more information.

C.1 Main code structure  
C.2 Coding style  
C.3 Option handling  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

C.1 Main code structure

Gmsh's code is structured in several libraries, roughly separated between the three main core modules (`Geo', `Mesh', `Post') and associated utility libraries (`Common', `Numeric') on one hand, and graphics (`Graphics') and interface (`Fltk', `Parser') libraries on the other.

The geometry and mesh modules are based on an object-oriented model class (`Geo/GModel.h'), built upon abstract geometrical entity classes (`Geo/GVertex.h', `Geo/GEdge.h', `Geo/GFace.h' and `Geo/GRegion.h'). Concrete implementation of the geometrical entity classes are provided for each supported CAD kernel (e.g. `Geo/gmshVertex.h' for geometry points in Gmsh's native CAD format, or `Geo/OCCVertex.h' for geometry points from OpenCascade). The post-processing module is based on the concept of views (`Post/PView.h') and abstract data containers (derived from `Post/PViewData.h').


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

C.2 Coding style

If you plan to contribute code to the Gmsh project, here are some easy rules to make the code easy to read/debug/maintain:

  1. please enable full warnings for your compiler (e.g., add -Wall to FLAGS in the `variables' file);
  2. always use the Msg:: class to print information, errors, ...;
  3. indent your files (2 spaces)
  4. convert all tabs to spaces.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

C.3 Option handling

To add a new option in Gmsh:

  1. create the option in the CTX class (`Common/Context.h') if it's a classical option, or in the PViewOptions class (`Post/PViewOptions.h') if it's a post-processing view-dependent option;
  2. in `Common/DefaultOptions.h', give a name (for the parser to be able to access it), a reference to a handling routine (i.e. opt_XXX) and a default value for this option;
  3. create the handling routine opt_XXX in `Common/Options.cpp' (and add the prototype in `Common/Options.h');
  4. optional: create the associated widget in `Fltk/optionWindow.cpp';


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

Back to geuz.org/gmsh