diff --git a/Common/CommandLine.h b/Common/CommandLine.h
index e34ca9d23383da01b3279b33429e2248aead9975..2dd5a9a5a5c7bc3aa627f0f96982a344605c821e 100644
--- a/Common/CommandLine.h
+++ b/Common/CommandLine.h
@@ -21,7 +21,8 @@ const char *GetGmshShortLicense();
 const char *GetGmshBuildOptions();
 
 std::vector<std::pair<std::string, std::string> > GetUsage();
-std::vector<std::pair<std::string, std::string> > GetShortcutsUsage(const std::string &ctrl="");
+std::vector<std::pair<std::string, std::string> >
+GetShortcutsUsage(const std::string &ctrl = "");
 std::vector<std::pair<std::string, std::string> > GetMouseUsage();
 void PrintUsage(const std::string &name);
 void GetOptions(int argc, char *argv[], bool readConfigFiles, bool exitOnError);
diff --git a/Common/Context.h b/Common/Context.h
index 6a03797ffce61173db846dcf936b48d48e0a7172..65f228b9ef53fc9b80b3741951bd9af3a50ab695 100644
--- a/Common/Context.h
+++ b/Common/Context.h
@@ -17,7 +17,7 @@ class GamePad;
 
 struct contextMeshOptions {
   // mesh algorithms
-  int optimize,  optimizeNetgen, smoothCrossField, refineSteps;
+  int optimize, optimizeNetgen, smoothCrossField, refineSteps;
   double lcFactor, randFactor, randFactor3d, lcIntegrationPrecision;
   double optimizeThreshold, normals, tangents, explode, angleSmoothNormals;
   double allowSwapEdgeAngle;
@@ -32,8 +32,8 @@ struct contextMeshOptions {
   int meshOnlyVisible, minCircPoints, minCurvPoints;
   int hoOptimize, hoNLayers, hoOptPrimSurfMesh;
   double hoThresholdMin, hoThresholdMax, hoPoissonRatio;
-  std::map<int,int> algo2dPerFace;
-  std::map<int,int> curvatureControlPerFace;
+  std::map<int, int> algo2dPerFace;
+  std::map<int, int> curvatureControlPerFace;
   int NewtonConvergenceTestXYZ;
   int ignorePeriodicity, boundaryLayerFanPoints;
   int maxNumThreads1D, maxNumThreads2D, maxNumThreads3D;
@@ -48,8 +48,10 @@ struct contextMeshOptions {
   int preserveNumberingMsh2;
   // partitioning
   int numPartitions, partitionCreateTopology, partitionCreateGhostCells;
-  int partitionCreatePhysicals, partitionSplitMeshFiles, partitionSaveTopologyFile;
-  int partitionTriWeight, partitionQuaWeight, partitionTetWeight, partitionHexWeight;
+  int partitionCreatePhysicals, partitionSplitMeshFiles,
+    partitionSaveTopologyFile;
+  int partitionTriWeight, partitionQuaWeight, partitionTetWeight,
+    partitionHexWeight;
   int partitionPriWeight, partitionPyrWeight, partitionTrihWeight;
   int partitionOldStyleMsh2;
   int metisAlgorithm, metisEdgeMatching, metisRefinementAlgorithm;
@@ -99,13 +101,15 @@ struct contextGeometryOptions {
 
 // The interface-independent context.
 class CTX {
- private:
+private:
   static CTX *_instance;
- public:
+
+public:
   CTX();
   ~CTX();
   static CTX *instance();
- public:
+
+public:
   // files on the command line and various file names
   std::vector<std::string> files;
   std::string bgmFileName, outputFileName, defaultFileName, tmpFileName;
@@ -120,7 +124,7 @@ class CTX {
   // create mesh statistics report (0: do nothing, 1: create, 2: append)
   int createAppendMeshStatReport;
   // should we launch a solver at startup?
-  int launchSolverAtStartup ;
+  int launchSolverAtStartup;
   // save session/option file on exit?
   int sessionSave, optionsSave;
   // ask confirmation when overwriting files?
@@ -142,8 +146,10 @@ class CTX {
   // show tootips in the GUI?
   int tooltips;
   // position and size of various windows in the GUI
-  int glPosition[2], glSize[2], msgSize, menuPosition[2], menuSize[2], detachedMenu;
-  int optPosition[2], visPosition[2], hotPosition[2], clipPosition[2], manipPosition[2];
+  int glPosition[2], glSize[2], msgSize, menuPosition[2], menuSize[2],
+    detachedMenu;
+  int optPosition[2], visPosition[2], hotPosition[2], clipPosition[2],
+    manipPosition[2];
   int statPosition[2], ctxPosition[2];
   int pluginPosition[2], pluginSize[2], fieldPosition[2], fieldSize[2];
   int fileChooserPosition[2], extraPosition[2], extraSize[2];
@@ -151,9 +157,9 @@ class CTX {
   int systemMenuBar;
   // use high-resolution opengl graphics (retina Macs)
   int highResolutionGraphics;
-  // batch mode (-4: lua session, -3: server daemon, -2: check coherence, -1: write
-  // geo, 0: full gfx, 1: 1D mesh, 2: 2D mesh, 3: 3D mesh, 4: adapt
-  // mesh, 5: refine mesh, 6: reclassify mesh)
+  // batch mode (-4: lua session, -3: server daemon, -2: check coherence, -1:
+  // write geo, 0: full gfx, 1: 1D mesh, 2: 2D mesh, 3: 3D mesh, 4: adapt mesh,
+  // 5: refine mesh, 6: reclassify mesh)
   int batch;
   // batch operations to apply after meshing (1: partition mesh)
   int batchAfterMesh;
@@ -183,13 +189,13 @@ class CTX {
   double min[3], max[3];
   // "center of mass" of the current geometry, used for graphics only
   double cg[3];
- // characteristic length for the whole problem (never used in mesh
+  // characteristic length for the whole problem (never used in mesh
   // generation ->only for geo/post)
   double lc;
   // double buffer/antialias/stereo graphics?
-  int db, antialiasing, stereo, camera ;
+  int db, antialiasing, stereo, camera;
   bool fileread;
-  double eye_sep_ratio,focallength_ratio,camera_aperture;
+  double eye_sep_ratio, focallength_ratio, camera_aperture;
   // orthogonal projection?
   int ortho;
   // draw the bounding boxes and the rot center?
@@ -265,7 +271,7 @@ class CTX {
   contextMeshOptions mesh;
   CGNSOptions cgnsOptions;
   // post processing options
-  struct{
+  struct {
     int draw, link, horizontalScales;
     int smooth, animCycle, animStep, combineTime, combineRemoveOrig;
     int fileFormat, plugins, forceNodeData, forceElementData;
@@ -274,9 +280,9 @@ class CTX {
     std::string doubleClickedGraphPointCommand;
     double doubleClickedGraphPointX, doubleClickedGraphPointY;
     int doubleClickedView;
-  }post;
+  } post;
   // solver options
-  struct{
+  struct {
     int plugins, listen;
     double timeout;
     std::string socketName, pythonInterpreter, octaveInterpreter;
@@ -285,9 +291,9 @@ class CTX {
     int autoSaveDatabase, autoLoadDatabase;
     int autoArchiveOutputFiles, autoMesh, autoMergeFile;
     int autoShowViews, autoShowLastStep, autoCheck, showInvisibleParameters;
-  }solver;
+  } solver;
   // print options
-  struct{
+  struct {
     int fileFormat, epsQuality, epsCompress, epsPS3Shading;
     int epsOcclusionCulling, epsBestRoot;
     double epsLineWidthFactor, epsPointSizeFactor;
@@ -304,15 +310,15 @@ class CTX {
     double x3dPrecision, x3dTransparency;
   } print;
   // color options
-  struct{
+  struct {
     unsigned int bg, bgGrad, fg, text, axes, smallAxes;
     unsigned int ambientLight[6], diffuseLight[6], specularLight[6];
-    struct{
+    struct {
       unsigned int point, curve, surface, volume;
       unsigned int selection, highlight[3], projection;
       unsigned int tangents, normals;
     } geom;
-    struct{
+    struct {
       unsigned int node, nodeSup, line, triangle, quadrangle;
       unsigned int tetrahedron, hexahedron, prism, pyramid, trihedron;
       unsigned int carousel[20];
diff --git a/Common/CreateFile.h b/Common/CreateFile.h
index 12ad5b783f1ccddc663362f6c8ee2bb7ae798926..ae5cb1784a11a44f595b12ccd87b5544c4e23c92 100644
--- a/Common/CreateFile.h
+++ b/Common/CreateFile.h
@@ -8,12 +8,14 @@
 
 #include <string>
 
-int GetFileFormatFromExtension(const std::string &fileName, double *version = 0);
-int GuessFileFormatFromFileName(const std::string &fileName, double *version = 0);
+int GetFileFormatFromExtension(const std::string &fileName,
+                               double *version = 0);
+int GuessFileFormatFromFileName(const std::string &fileName,
+                                double *version = 0);
 std::string GetDefaultFileExtension(int format, bool onlyMeshFormats = false);
 std::string GetDefaultFileName(int format);
 std::string GetKnownFileFormats(bool onlyMeshFormats = false);
 void CreateOutputFile(const std::string &fileName, int format,
-                      bool status=true, bool redraw=true);
+                      bool status = true, bool redraw = true);
 
 #endif
diff --git a/Common/GamePad.h b/Common/GamePad.h
index 61f43015410a106d991fc0347e7a17fa96045807..e3e17187c783fac381880aa219ce12453bd75931 100644
--- a/Common/GamePad.h
+++ b/Common/GamePad.h
@@ -25,7 +25,7 @@
 #endif
 
 class GamePad {
- public:
+public:
   bool active;
   bool toggle_status[GP_BUTTONS];
   bool event_read;
@@ -39,7 +39,8 @@ class GamePad {
   void affiche();
   int button_map[10];
   int axe_map[8];
- private:
+
+private:
   char name[256];
 #if defined(WIN32)
   int gamepad_fd;
diff --git a/Common/GmshGlobal.cpp b/Common/GmshGlobal.cpp
index 0eb4e9784fb4f23f90d2a2b2f1c9fd9858b1d7a9..b7aaa675329ff15788be846d98500f7a3bf4fcb1 100644
--- a/Common/GmshGlobal.cpp
+++ b/Common/GmshGlobal.cpp
@@ -105,13 +105,9 @@ int GmshSetMessageHandler(GmshMessage *callback)
   return 1;
 }
 
-GmshMessage *GmshGetMessageHandler()
-{
-  return Msg::GetCallback();
-}
+GmshMessage *GmshGetMessageHandler() { return Msg::GetCallback(); }
 
-int GmshSetBoundingBox(double xmin, double xmax,
-                       double ymin, double ymax,
+int GmshSetBoundingBox(double xmin, double xmax, double ymin, double ymax,
                        double zmin, double zmax)
 {
   SetBoundingBox(xmin, xmax, ymin, ymax, zmin, zmax);
@@ -121,43 +117,43 @@ int GmshSetBoundingBox(double xmin, double xmax,
 int GmshSetOption(const std::string &category, const std::string &name,
                   std::string value, int index)
 {
-  return StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-                      value, false);
+  return StringOption(GMSH_SET | GMSH_GUI, category.c_str(), index,
+                      name.c_str(), value, false);
 }
 
 int GmshSetOption(const std::string &category, const std::string &name,
                   double value, int index)
 {
-  return NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-                      value, false);
+  return NumberOption(GMSH_SET | GMSH_GUI, category.c_str(), index,
+                      name.c_str(), value, false);
 }
 
 int GmshSetOption(const std::string &category, const std::string &name,
                   unsigned int value, int index)
 {
-  return ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+  return ColorOption(GMSH_SET | GMSH_GUI, category.c_str(), index, name.c_str(),
                      value, false);
 }
 
 void GmshSetStringOption(const std::string &category, const std::string &name,
                          std::string value, int index)
 {
-  StringOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+  StringOption(GMSH_SET | GMSH_GUI, category.c_str(), index, name.c_str(),
                value, false);
 }
 
 void GmshSetNumberOption(const std::string &category, const std::string &name,
                          double value, int index)
 {
-  NumberOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
+  NumberOption(GMSH_SET | GMSH_GUI, category.c_str(), index, name.c_str(),
                value, false);
 }
 
 void GmshSetColorOption(const std::string &category, const std::string &name,
                         unsigned int value, int index)
 {
-  ColorOption(GMSH_SET|GMSH_GUI, category.c_str(), index, name.c_str(),
-              value, false);
+  ColorOption(GMSH_SET | GMSH_GUI, category.c_str(), index, name.c_str(), value,
+              false);
 }
 
 int GmshGetOption(const std::string &category, const std::string &name,
@@ -181,8 +177,8 @@ int GmshGetOption(const std::string &category, const std::string &name,
                      false);
 }
 
-std::string GmshGetStringOption(const std::string &category, const std::string &name,
-                                int index)
+std::string GmshGetStringOption(const std::string &category,
+                                const std::string &name, int index)
 {
   std::string value;
   StringOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
@@ -197,8 +193,8 @@ double GmshGetNumberOption(const std::string &category, const std::string &name,
   return value;
 }
 
-unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
-                       int index)
+unsigned int GmshGetColorOption(const std::string &category,
+                                const std::string &name, int index)
 {
   unsigned int value;
   ColorOption(GMSH_GET, category.c_str(), index, name.c_str(), value, false);
@@ -231,8 +227,9 @@ int GmshMergeFile(const std::string &fileName)
 
 int GmshMergePostProcessingFile(const std::string &fileName)
 {
-  return MergePostProcessingFile(fileName, CTX::instance()->solver.autoShowViews,
-                                 CTX::instance()->solver.autoShowLastStep, true);
+  return MergePostProcessingFile(
+    fileName, CTX::instance()->solver.autoShowViews,
+    CTX::instance()->solver.autoShowLastStep, true);
 }
 
 int GmshWriteFile(const std::string &fileName)
@@ -245,16 +242,16 @@ int GmshFinalize()
 {
 #if defined(HAVE_POST)
   // Delete all PViewData stored in static list of PView class
-  while(PView::list.size()>0) delete PView::list[PView::list.size()-1];
-  std::vector<PView*>().swap(PView::list);
+  while(PView::list.size() > 0) delete PView::list[PView::list.size() - 1];
+  std::vector<PView *>().swap(PView::list);
 
   // Delete static _interpolationSchemes of PViewData class
   PViewData::removeAllInterpolationSchemes();
 #endif
 
   // Delete all Gmodels
-  while(GModel::list.size()>0) delete GModel::list[GModel::list.size()-1];
-  std::vector<GModel*>().swap(GModel::list);
+  while(GModel::list.size() > 0) delete GModel::list[GModel::list.size() - 1];
+  std::vector<GModel *>().swap(GModel::list);
 
   return 1;
 }
@@ -262,14 +259,14 @@ int GmshFinalize()
 int GmshBatch()
 {
   Msg::Info("Running '%s' [Gmsh %s, %d node%s, max. %d thread%s]",
-            Msg::GetCommandLineArgs().c_str(), GMSH_VERSION,
-            Msg::GetCommSize(), Msg::GetCommSize() > 1 ? "s" : "",
-            Msg::GetMaxThreads(), Msg::GetMaxThreads() > 1 ? "s" : "");
+            Msg::GetCommandLineArgs().c_str(), GMSH_VERSION, Msg::GetCommSize(),
+            Msg::GetCommSize() > 1 ? "s" : "", Msg::GetMaxThreads(),
+            Msg::GetMaxThreads() > 1 ? "s" : "");
   Msg::Info("Started on %s", Msg::GetLaunchDate().c_str());
 
   OpenProject(GModel::current()->getFileName());
   bool open = false;
-  for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
+  for(unsigned int i = 0; i < CTX::instance()->files.size(); i++) {
     if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
     if(CTX::instance()->files[i] == "-new")
       new GModel();
@@ -293,24 +290,23 @@ int GmshBatch()
   }
 #endif
 
-  if(CTX::instance()->batch == -3){
+  if(CTX::instance()->batch == -3) {
     GmshRemote();
   }
-  else if(CTX::instance()->batch == -2){
+  else if(CTX::instance()->batch == -2) {
     GModel::current()->checkMeshCoherence(CTX::instance()->geom.tolerance);
 #if defined(HAVE_PARSER)
     std::vector<std::string> s;
     PrintParserSymbols(0, s);
-    for(unsigned int i = 0; i < s.size(); i++)
-      Msg::Direct("%s", s[i].c_str());
+    for(unsigned int i = 0; i < s.size(); i++) Msg::Direct("%s", s[i].c_str());
 #endif
   }
-  else if(CTX::instance()->batch == -1){
+  else if(CTX::instance()->batch == -1) {
     CreateOutputFile(CTX::instance()->outputFileName,
                      CTX::instance()->outputFileName.empty() ? FORMAT_GEO :
-                     FORMAT_AUTO);
+                                                               FORMAT_AUTO);
   }
-  else if(CTX::instance()->batch > 0){
+  else if(CTX::instance()->batch > 0) {
 #if defined(HAVE_MESH)
     if(CTX::instance()->batch < 4)
       GModel::current()->mesh(CTX::instance()->batch);
@@ -329,9 +325,9 @@ int GmshBatch()
      CTX::instance()->mesh.numPartitions > 1)
     GModel::current()->partitionMesh(CTX::instance()->mesh.numPartitions);
 
-  if(CTX::instance()->batch > 0 || CTX::instance()->batchAfterMesh){
+  if(CTX::instance()->batch > 0 || CTX::instance()->batchAfterMesh) {
     std::string name = CTX::instance()->outputFileName;
-    if(name.empty()){
+    if(name.empty()) {
       if(CTX::instance()->mesh.fileFormat == FORMAT_AUTO)
         name = GetDefaultFileName(FORMAT_MSH);
       else
@@ -340,7 +336,7 @@ int GmshBatch()
     CreateOutputFile(name, CTX::instance()->mesh.fileFormat);
   }
 
-  // launch solver (if requested)
+    // launch solver (if requested)
 #if defined(HAVE_ONELAB)
   onelabUtils::runClient();
 #endif
@@ -364,15 +360,15 @@ int GmshFLTK(int argc, char **argv)
   FlGui::instance()->check();
 
   if(FlGui::getOpenedThroughMacFinder().size() &&
-     CTX::instance()->files.empty()){
+     CTX::instance()->files.empty()) {
     OpenProject(FlGui::getOpenedThroughMacFinder());
   }
-  else{
+  else {
     OpenProject(GModel::current()->getFileName());
     bool open = false;
-    for(unsigned int i = 0; i < CTX::instance()->files.size(); i++){
+    for(unsigned int i = 0; i < CTX::instance()->files.size(); i++) {
       if(i == 0 && CTX::instance()->files[0][0] != '-') continue;
-      if(CTX::instance()->files[i] == "-new"){
+      if(CTX::instance()->files[i] == "-new") {
         GModel::current()->setVisibility(0);
         new GModel();
       }
@@ -389,13 +385,13 @@ int GmshFLTK(int argc, char **argv)
 
   FlGui::instance()->setFinishedProcessingCommandLine();
 
-  if(CTX::instance()->post.combineTime){
+  if(CTX::instance()->post.combineTime) {
     PView::combine(true, 2, CTX::instance()->post.combineRemoveOrig);
     FlGui::instance()->updateViews(true, true);
   }
 
   // init first context
-  switch (CTX::instance()->initialContext) {
+  switch(CTX::instance()->initialContext) {
   case 1: FlGui::instance()->openModule("Geometry"); break;
   case 2: FlGui::instance()->openModule("Mesh"); break;
   case 3: FlGui::instance()->openModule("Solver"); break;
@@ -415,13 +411,13 @@ int GmshFLTK(int argc, char **argv)
   }
 
   // listen to external solvers
-  if(CTX::instance()->solver.listen){
+  if(CTX::instance()->solver.listen) {
     gmshLocalNetworkClient *c = new gmshLocalNetworkClient("Listen", "");
     c->run();
   }
 
   // launch solver (if requested) and fill onelab tree
-  solver_cb(0, (void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
+  solver_cb(0, (void *)(intptr_t)CTX::instance()->launchSolverAtStartup);
 
   // loop
   return FlGui::instance()->run();
@@ -433,7 +429,7 @@ int GmshFLTK(int argc, char **argv)
 
 GMSH_API int GmshMainBatch(int argc, char **argv)
 {
-  if(argc < 2){
+  if(argc < 2) {
     CTX::instance()->terminal = 1;
     PrintUsage(argv[0]);
     exit(0);
@@ -459,7 +455,7 @@ GMSH_API int GmshMainFLTK(int argc, char **argv)
 
   // Hack to generate automatic documentation (before getting
   // user-defined options)
-  if(argc == 2 && std::string(argv[1]) == "-doc"){
+  if(argc == 2 && std::string(argv[1]) == "-doc") {
     InitOptions(0);
 #if defined(HAVE_PLUGINS)
     PluginManager::instance()->registerDefaultPlugins();
@@ -475,7 +471,7 @@ GMSH_API int GmshMainFLTK(int argc, char **argv)
   if(CTX::instance()->batch) {
     if(!Msg::GetGmshClient()) CTX::instance()->terminal = 1;
     GmshBatch();
-    //GmshFinalize();
+    // GmshFinalize();
     Msg::Exit(0);
   }
 
diff --git a/Common/GmshGlobal.h b/Common/GmshGlobal.h
index cd362e5f8ea660cdbec3a1cacf10dacac3856cae..ee399ca93a286d4a06a138da3b51232cb5ac8d48 100644
--- a/Common/GmshGlobal.h
+++ b/Common/GmshGlobal.h
@@ -13,8 +13,7 @@ int GmshInitialize(int argc = 0, char **argv = 0, bool readConfigFiles = false,
                    bool exitOnCommandLineError = true);
 int GmshSetMessageHandler(GmshMessage *callback);
 GmshMessage *GmshGetMessageHandler();
-int GmshSetBoundingBox(double xmin, double xmax,
-                       double ymin, double ymax,
+int GmshSetBoundingBox(double xmin, double xmax, double ymin, double ymax,
                        double zmin, double zmax);
 int GmshSetOption(const std::string &category, const std::string &name,
                   std::string value, int index = 0);
@@ -34,12 +33,12 @@ int GmshGetOption(const std::string &category, const std::string &name,
                   double &value, int index = 0);
 int GmshGetOption(const std::string &category, const std::string &name,
                   unsigned int &value, int index = 0);
-std::string GmshGetStringOption(const std::string &category, const std::string &name,
-                                int index = 0);
+std::string GmshGetStringOption(const std::string &category,
+                                const std::string &name, int index = 0);
 double GmshGetNumberOption(const std::string &category, const std::string &name,
                            int index = 0);
-unsigned int GmshGetColorOption(const std::string &category, const std::string &name,
-                                int index = 0);
+unsigned int GmshGetColorOption(const std::string &category,
+                                const std::string &name, int index = 0);
 int GmshRestoreDefaultOptions();
 int GmshOpenProject(const std::string &fileName);
 int GmshClearProject();
diff --git a/Common/GmshMessage.h b/Common/GmshMessage.h
index 522e20ae9f01b8b7bb16894b60c454f5f89e2ebe..c7ecd15cbf50d639ccdfe2bdf45b34f3535ef068 100644
--- a/Common/GmshMessage.h
+++ b/Common/GmshMessage.h
@@ -14,19 +14,21 @@
 #include "GmshConfig.h"
 
 class GmshClient;
-namespace onelab{ class client; }
+namespace onelab {
+  class client;
+}
 
 // the external message handler
-class GmshMessage{
- public:
-  GmshMessage(){}
-  virtual ~GmshMessage(){}
-  virtual void operator()(std::string level, std::string message){}
+class GmshMessage {
+public:
+  GmshMessage() {}
+  virtual ~GmshMessage() {}
+  virtual void operator()(std::string level, std::string message) {}
 };
 
 // a class to manage messages
 class Msg {
- private:
+private:
   // current cpu number and total number of cpus
   static int _commRank, _commSize;
   // verbosity level (0: silent except fatal errors, 1: +errors, 2: +warnings,
@@ -61,7 +63,8 @@ class Msg {
   // log file
   static std::string _logFileName;
   static FILE *_logFile;
- public:
+
+public:
   Msg() {}
   static void Init(int argc, char **argv);
   static void Exit(int level);
@@ -111,11 +114,13 @@ class Msg {
   static double GetValue(const char *text, double defaultval);
   static std::string GetString(const char *text, const std::string &defaultval);
   static int GetAnswer(const char *question, int defaultval, const char *zero,
-                       const char *one, const char *two=0);
-  static void InitializeOnelab(const std::string &name, const std::string &sockname="");
+                       const char *one, const char *two = 0);
+  static void InitializeOnelab(const std::string &name,
+                               const std::string &sockname = "");
   static void SetExecutableName(const std::string &name);
   static std::string GetExecutableName();
-  static void LoadOnelabClient(const std::string &name, const std::string &sockName);
+  static void LoadOnelabClient(const std::string &name,
+                               const std::string &sockName);
   static int GetNumOnelabClients();
   static GmshClient *GetGmshClient();
 #if defined(HAVE_ONELAB)
@@ -143,28 +148,29 @@ class Msg {
                                     bool readOnly = false, bool visible = true);
   static void SetOnelabAction(const std::string &action);
   static std::string GetOnelabAction();
-  static void ExchangeOnelabParameter(const std::string &key,
-                                      std::vector<double> &val,
-                                      std::map<std::string, std::vector<double> > &fopt,
-                                      std::map<std::string, std::vector<std::string> > &copt);
-  static void ExchangeOnelabParameter(const std::string &key,
-                                      std::string &val,
-                                      std::map<std::string, std::vector<double> > &fopt,
-                                      std::map<std::string, std::vector<std::string> > &copt);
+  static void ExchangeOnelabParameter(
+    const std::string &key, std::vector<double> &val,
+    std::map<std::string, std::vector<double> > &fopt,
+    std::map<std::string, std::vector<std::string> > &copt);
+  static void ExchangeOnelabParameter(
+    const std::string &key, std::string &val,
+    std::map<std::string, std::vector<double> > &fopt,
+    std::map<std::string, std::vector<std::string> > &copt);
   static void UndefineOnelabParameter(const std::string &name);
-  static void RunOnelabClient(const std::string &name, const std::string &exe="");
-  static void SetOnelabChanged(int value, const std::string &client="Gmsh");
+  static void RunOnelabClient(const std::string &name,
+                              const std::string &exe = "");
+  static void SetOnelabChanged(int value, const std::string &client = "Gmsh");
   static void ImportPhysicalGroupsInOnelab();
 };
 
 // a class to print the progression and estimated remaining time
-class MsgProgressStatus
-{
+class MsgProgressStatus {
 private:
   int _totalElementToTreat, _currentI, _nextIToCheck;
   double _initialTime, _lastTime;
   int _lastPercentage;
   int _progressMeterStep;
+
 public:
   MsgProgressStatus(int numElementToTreat);
   ~MsgProgressStatus();
diff --git a/Common/GmshRemote.cpp b/Common/GmshRemote.cpp
index 4f1a697f359128a1748e90fa7bf7cff279f4739e..93341b44c7bff8985e5eb02a4ae83b3564e08859 100644
--- a/Common/GmshRemote.cpp
+++ b/Common/GmshRemote.cpp
@@ -7,13 +7,13 @@
 
 #if defined(HAVE_MPI)
 #include <mpi.h>
-#define MPI_GMSH_COMPUTE_VIEW  1
-#define MPI_GMSH_DATA_READY    2
-#define MPI_GMSH_VARRAY        3
-#define MPI_GMSH_VARRAY_LEN    4
-#define MPI_GMSH_SHUTDOWN      5
-#define MPI_GMSH_PARSE_STRING  6
-#define MPI_GMSH_MERGE_FILE    7
+#define MPI_GMSH_COMPUTE_VIEW 1
+#define MPI_GMSH_DATA_READY 2
+#define MPI_GMSH_VARRAY 3
+#define MPI_GMSH_VARRAY_LEN 4
+#define MPI_GMSH_SHUTDOWN 5
+#define MPI_GMSH_PARSE_STRING 6
+#define MPI_GMSH_MERGE_FILE 7
 #endif
 
 #include <sstream>
@@ -31,29 +31,29 @@
 #include "PViewData.h"
 #include "PViewDataRemote.h"
 
-static void computeAndSendVertexArrays(GmshClient *client, bool compute=true)
+static void computeAndSendVertexArrays(GmshClient *client, bool compute = true)
 {
-  for(unsigned int i = 0; i < PView::list.size(); i++){
+  for(unsigned int i = 0; i < PView::list.size(); i++) {
     PView *p = PView::list[i];
     if(compute) p->fillVertexArrays();
     PViewData *data = p->getData();
     PViewOptions *opt = p->getOptions();
     double min = data->getMin(), max = data->getMax();
-    if(opt->rangeType == PViewOptions::PerTimeStep){
+    if(opt->rangeType == PViewOptions::PerTimeStep) {
       min = data->getMin(opt->timeStep);
       max = data->getMax(opt->timeStep);
     }
-    VertexArray *va[4] =
-      {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
-    for(int type = 0; type < 4; type++){
-      if(va[type]){
+    VertexArray *va[4] = {p->va_points, p->va_lines, p->va_triangles,
+                          p->va_vectors};
+    for(int type = 0; type < 4; type++) {
+      if(va[type]) {
         int len;
-        char *str = va[type]->toChar
-          (p->getTag(), data->getName(), type + 1, min, max,
-           data->getNumTimeSteps(), data->getTime(opt->timeStep),
-           data->getBoundingBox(), len);
+        char *str = va[type]->toChar(p->getTag(), data->getName(), type + 1,
+                                     min, max, data->getNumTimeSteps(),
+                                     data->getTime(opt->timeStep),
+                                     data->getBoundingBox(), len);
         client->SendMessage(GmshSocket::GMSH_VERTEX_ARRAY, len, str);
-        delete [] str;
+        delete[] str;
       }
     }
   }
@@ -68,37 +68,37 @@ static void computeAndSendVertexArrays()
     PView::list[i]->fillVertexArrays();
 
   // ...and send
-  int nbArrays = PView::list.size()* 4;
+  int nbArrays = PView::list.size() * 4;
   MPI_Send(&nbArrays, 1, MPI_INT, 0, MPI_GMSH_DATA_READY, MPI_COMM_WORLD);
 
-  for(unsigned int i = 0; i < PView::list.size(); i++){
+  for(unsigned int i = 0; i < PView::list.size(); i++) {
     PView *p = PView::list[i];
     PViewData *data = p->getData();
     PViewOptions *opt = p->getOptions();
     double min = data->getMin(), max = data->getMax();
-    if(opt->rangeType == PViewOptions::PerTimeStep){
+    if(opt->rangeType == PViewOptions::PerTimeStep) {
       min = data->getMin(opt->timeStep);
       max = data->getMax(opt->timeStep);
     }
-    VertexArray *va[4] =
-      {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
-    for(int type = 0; type < 4; type++){
-      if(va[type]){
+    VertexArray *va[4] = {p->va_points, p->va_lines, p->va_triangles,
+                          p->va_vectors};
+    for(int type = 0; type < 4; type++) {
+      if(va[type]) {
         int len;
-        char *str = va[type]->toChar
-          (p->getTag(), data->getName(), type + 1, min, max,
-           data->getNumTimeSteps(), data->getTime(opt->timeStep),
-           data->getBoundingBox(), len);
+        char *str = va[type]->toChar(p->getTag(), data->getName(), type + 1,
+                                     min, max, data->getNumTimeSteps(),
+                                     data->getTime(opt->timeStep),
+                                     data->getBoundingBox(), len);
         MPI_Send(&len, 1, MPI_INT, 0, MPI_GMSH_VARRAY_LEN, MPI_COMM_WORLD);
         MPI_Send(str, len, MPI_CHAR, 0, MPI_GMSH_VARRAY, MPI_COMM_WORLD);
-        delete [] str;
+        delete[] str;
       }
     }
   }
 }
 
 // Merge the vertex arrays
-static void addToVertexArrays(int length, const char* bytes, int swap)
+static void addToVertexArrays(int length, const char *bytes, int swap)
 {
   std::string name;
   int num, type, numSteps;
@@ -109,13 +109,13 @@ static void addToVertexArrays(int length, const char* bytes, int swap)
   PView *p = PView::list[num - 1];
   PViewData *data = p->getData();
 
-  VertexArray *varrays[4] =
-    {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
+  VertexArray *varrays[4] = {p->va_points, p->va_lines, p->va_triangles,
+                             p->va_vectors};
 
   VertexArray *va = varrays[type - 1];
 
-  if (data->getMin() > min) data->setMin(min);
-  if (data->getMax() < max) data->setMax(max);
+  if(data->getMin() > min) data->setMin(min);
+  if(data->getMax() < max) data->setMax(max);
 
   SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax);
   SBoundingBox3d bb = data->getBoundingBox();
@@ -123,18 +123,18 @@ static void addToVertexArrays(int length, const char* bytes, int swap)
 
   data->setBoundingBox(bb);
 
-  if (type == 4) type = 2;
-  VertexArray* toAdd = new VertexArray(type, 100);
+  if(type == 4) type = 2;
+  VertexArray *toAdd = new VertexArray(type, 100);
   toAdd->fromChar(length, bytes, swap);
   va->merge(toAdd);
   delete toAdd;
 }
 #endif
 
-static void gatherAndSendVertexArrays(GmshClient* client, bool swap)
+static void gatherAndSendVertexArrays(GmshClient *client, bool swap)
 {
 #if defined(HAVE_MPI)
-  //int rank = Msg::GetCommRank();
+  // int rank = Msg::GetCommRank();
   int nbDaemon = Msg::GetCommSize();
   // tell every node to start computing
   int mpi_msg = MPI_GMSH_COMPUTE_VIEW;
@@ -143,22 +143,22 @@ static void gatherAndSendVertexArrays(GmshClient* client, bool swap)
   for(unsigned int i = 0; i < PView::list.size(); i++)
     PView::list[i]->fillVertexArrays();
   // wait and send the data from every other node
-  for (int i = 0; i < nbDaemon - 1; i++) {
+  for(int i = 0; i < nbDaemon - 1; i++) {
     int nbArrays;
     MPI_Status status;
-    MPI_Recv(&nbArrays, 1, MPI_INT, MPI_ANY_SOURCE,
-             MPI_GMSH_DATA_READY, MPI_COMM_WORLD, &status);
-    //int source = status.MPI_SOURCE;
+    MPI_Recv(&nbArrays, 1, MPI_INT, MPI_ANY_SOURCE, MPI_GMSH_DATA_READY,
+             MPI_COMM_WORLD, &status);
+    // int source = status.MPI_SOURCE;
     // get each varray in turn, then add it to the varrays of
     // the master node
-    for (int j = 0; j < nbArrays; j++) {
+    for(int j = 0; j < nbArrays; j++) {
       int len;
       MPI_Status status2;
-      MPI_Recv(&len, 1, MPI_INT, status.MPI_SOURCE,
-               MPI_GMSH_VARRAY_LEN, MPI_COMM_WORLD, &status2);
+      MPI_Recv(&len, 1, MPI_INT, status.MPI_SOURCE, MPI_GMSH_VARRAY_LEN,
+               MPI_COMM_WORLD, &status2);
       char str[len];
-      MPI_Recv(str, len, MPI_CHAR, status.MPI_SOURCE,
-               MPI_GMSH_VARRAY, MPI_COMM_WORLD, &status2);
+      MPI_Recv(str, len, MPI_CHAR, status.MPI_SOURCE, MPI_GMSH_VARRAY,
+               MPI_COMM_WORLD, &status2);
       addToVertexArrays(len, str, swap);
     }
   }
@@ -180,40 +180,40 @@ int GmshRemote()
   else if(client && nbDaemon >= 2 && rank == 0)
     gatherAndSendVertexArrays(client, false);
 
-  while(1){
-
+  while(1) {
     // on the node with MPI rank 0, communicate through a socket
-    if (rank == 0) {
+    if(rank == 0) {
       // stop if we have no communications for 5 minutes
       int ret = client->Select(300, 0);
-      if(!ret){
+      if(!ret) {
         client->Info("Timeout: stopping remote Gmsh...");
         break;
       }
-      else if(ret < 0){
+      else if(ret < 0) {
         client->Error("Error on select: stopping remote Gmsh...");
         break;
       }
 
       int type, length, swap;
-      if(!client->ReceiveHeader(&type, &length, &swap)){
-        client->Error("Did not receive message header: stopping remote Gmsh...");
+      if(!client->ReceiveHeader(&type, &length, &swap)) {
+        client->Error(
+          "Did not receive message header: stopping remote Gmsh...");
         break;
       }
 
       char *msg = new char[length + 1];
-      if(!client->ReceiveString(length, msg)){
+      if(!client->ReceiveString(length, msg)) {
         client->Error("Did not receive message body: stopping remote Gmsh...");
-        delete [] msg;
+        delete[] msg;
         break;
       }
 
-      if(type == GmshSocket::GMSH_STOP){
+      if(type == GmshSocket::GMSH_STOP) {
         client->Info("Stopping remote Gmsh...");
-        delete [] msg;
+        delete[] msg;
         break;
       }
-      else if(type == GmshSocket::GMSH_VERTEX_ARRAY){
+      else if(type == GmshSocket::GMSH_VERTEX_ARRAY) {
         ParseString(msg);
 #if !defined(HAVE_MPI)
         computeAndSendVertexArrays(client);
@@ -225,7 +225,7 @@ int GmshRemote()
         gatherAndSendVertexArrays(client, swap);
 #endif
       }
-      else if(type == GmshSocket::GMSH_MERGE_FILE){
+      else if(type == GmshSocket::GMSH_MERGE_FILE) {
         MergeFile(msg);
 #if !defined(HAVE_MPI)
         computeAndSendVertexArrays(client);
@@ -237,7 +237,7 @@ int GmshRemote()
         gatherAndSendVertexArrays(client, swap);
 #endif
       }
-      else if(type == GmshSocket::GMSH_PARSE_STRING){
+      else if(type == GmshSocket::GMSH_PARSE_STRING) {
         ParseString(msg);
 #if defined(HAVE_MPI)
         int mpi_msg = MPI_GMSH_PARSE_STRING;
@@ -246,33 +246,33 @@ int GmshRemote()
         MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
 #endif
       }
-      else if(type == GmshSocket::GMSH_SPEED_TEST){
+      else if(type == GmshSocket::GMSH_SPEED_TEST) {
         client->Info("Sending huge array");
         std::string huge(500000000, 'a');
         client->SpeedTest(huge.c_str());
       }
-      else{
+      else {
         client->Error("Ignoring unknown message");
       }
 
-      delete [] msg;
+      delete[] msg;
     }
     else { // if we're not on the master node (rank != 0) wait for him...
 #if defined(HAVE_MPI)
       int mpi_msg;
       MPI_Bcast(&mpi_msg, 1, MPI_INT, 0, MPI_COMM_WORLD);
-      if (mpi_msg == MPI_GMSH_COMPUTE_VIEW)
+      if(mpi_msg == MPI_GMSH_COMPUTE_VIEW)
         computeAndSendVertexArrays();
       else if(mpi_msg == MPI_GMSH_SHUTDOWN)
         Msg::Exit(0);
-      else if(mpi_msg == MPI_GMSH_PARSE_STRING){
+      else if(mpi_msg == MPI_GMSH_PARSE_STRING) {
         int length;
         MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
         char msg[length];
         MPI_Bcast(msg, length, MPI_CHAR, 0, MPI_COMM_WORLD);
         ParseString(msg);
       }
-      else if (mpi_msg == MPI_GMSH_MERGE_FILE){
+      else if(mpi_msg == MPI_GMSH_MERGE_FILE) {
         int length;
         MPI_Bcast(&length, 1, MPI_INT, 0, MPI_COMM_WORLD);
         char msg[length];
diff --git a/Common/GmshRemote.h b/Common/GmshRemote.h
index 29a7a009885a4a90236250b5a3dc78318d000cb8..ff7eab7d4f2a62e408146d853a1bfe403e098ae0 100644
--- a/Common/GmshRemote.h
+++ b/Common/GmshRemote.h
@@ -11,4 +11,3 @@
 int GmshRemote();
 
 #endif
-
diff --git a/Common/Hash.h b/Common/Hash.h
index 153f14214432cbc04bb0607368e591e99d83bba6..d40597785927a3230045af1d5e005522ce9492db 100644
--- a/Common/Hash.h
+++ b/Common/Hash.h
@@ -9,10 +9,10 @@
 //--FNV hashing parameters
 
 #if defined(HAVE_64BIT_SIZE_T)
-#define FNV_PRIME        1099511628211UL
+#define FNV_PRIME 1099511628211UL
 #define FNV_OFFSET_BASIS 14695981039346656037UL
 #else
-#define FNV_PRIME        16777619UL
+#define FNV_PRIME 16777619UL
 #define FNV_OFFSET_BASIS 2166136261UL
 #endif
 
@@ -20,9 +20,9 @@
 
 inline size_t hash_FNV1a(const void *const key, const int len)
 {
-  const unsigned char *p = static_cast<const unsigned char*>(key);
+  const unsigned char *p = static_cast<const unsigned char *>(key);
   size_t hash = FNV_OFFSET_BASIS;
-  for(int n = len; n--; ) hash = (hash^static_cast<size_t>(*p++))*FNV_PRIME;
+  for(int n = len; n--;) hash = (hash ^ static_cast<size_t>(*p++)) * FNV_PRIME;
   return hash;
 }
 
@@ -33,14 +33,15 @@ inline size_t hash_FNV1a(const void *const key, const int len)
 template <int N> struct Hash1FNV1a {
   static size_t eval(size_t hash, const unsigned char *p)
   {
-    return Hash1FNV1a<N-1>::eval((hash^static_cast<size_t>(*p))*FNV_PRIME, p+1);
+    return Hash1FNV1a<N - 1>::eval((hash ^ static_cast<size_t>(*p)) * FNV_PRIME,
+                                   p + 1);
   }
 };
 
 template <> struct Hash1FNV1a<1> {
   static size_t eval(size_t hash, const unsigned char *p)
   {
-    return (hash^static_cast<size_t>(*p))*FNV_PRIME;
+    return (hash ^ static_cast<size_t>(*p)) * FNV_PRIME;
   }
 };
 
@@ -49,7 +50,7 @@ template <int N> struct HashFNV1a {
   static size_t eval(const void *const key)
   {
     size_t hash = FNV_OFFSET_BASIS;
-    return Hash1FNV1a<N>::eval(hash, static_cast<const unsigned char*>(key));
+    return Hash1FNV1a<N>::eval(hash, static_cast<const unsigned char *>(key));
   }
 };
 
diff --git a/Common/HashMap.h b/Common/HashMap.h
index 7d313ee3329b74975a9b76053a6e6632341ee68a..ccc3083382e6762cefa95c6ff0aa3fa0fc1b9478 100644
--- a/Common/HashMap.h
+++ b/Common/HashMap.h
@@ -9,7 +9,7 @@
 //--Define custom hash map here.  It must have form <key, value, HashFunctor,
 //--EqualFunctor>
 
-#define HASH_MAP         __gnu_cxx::hash_map
+#define HASH_MAP __gnu_cxx::hash_map
 #include <ext/hash_map>
 
 #endif
diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp
index 0596e77ecade1107645cb2a92ea21eaf12a15fa6..500ec1223cb2339f48b9140b3c6cb9d4c0f9f5d8 100644
--- a/Common/ListUtils.cpp
+++ b/Common/ListUtils.cpp
@@ -256,7 +256,9 @@ void List_Invert(List_T *a, List_T *b)
   if(!a || !b) return;
   int i, N;
   N = List_Nbr(a);
-  for(i = 0; i < N; i++) { List_Add(b, List_Pointer(a, N - i - 1)); }
+  for(i = 0; i < N; i++) {
+    List_Add(b, List_Pointer(a, N - i - 1));
+  }
 }
 
 void List_Reset(List_T *liste)
@@ -278,7 +280,9 @@ void List_Copy(List_T *a, List_T *b)
   if(!a || !b) return;
   int i, N;
   N = List_Nbr(a);
-  for(i = 0; i < N; i++) { List_Add(b, List_Pointer(a, i)); }
+  for(i = 0; i < N; i++) {
+    List_Add(b, List_Pointer(a, i));
+  }
 }
 
 void List_Remove(List_T *a, int i)
diff --git a/Common/MallocUtils.cpp b/Common/MallocUtils.cpp
index 1358b57484c887da780e937c91af289a24485d46..7f5d6c5c9b2dfa6f694a17af6640ebfa376c4ccc 100644
--- a/Common/MallocUtils.cpp
+++ b/Common/MallocUtils.cpp
@@ -13,11 +13,9 @@ void *Malloc(size_t size)
 {
   void *ptr;
 
-  if(!size)
-    return (NULL);
+  if(!size) return (NULL);
   ptr = malloc(size);
-  if(ptr == NULL)
-    Msg::Fatal("Out of memory (buy some more RAM!)");
+  if(ptr == NULL) Msg::Fatal("Out of memory (buy some more RAM!)");
   return (ptr);
 }
 
@@ -25,27 +23,22 @@ void *Calloc(size_t num, size_t size)
 {
   void *ptr;
 
-  if(!size)
-    return (NULL);
+  if(!size) return (NULL);
   ptr = calloc(num, size);
-  if(ptr == NULL)
-    Msg::Fatal("Out of memory (buy some more RAM!)");
+  if(ptr == NULL) Msg::Fatal("Out of memory (buy some more RAM!)");
   return (ptr);
 }
 
 void *Realloc(void *ptr, size_t size)
 {
-  if(!size)
-    return (NULL);
+  if(!size) return (NULL);
   ptr = realloc(ptr, size);
-  if(ptr == NULL)
-    Msg::Fatal("Out of memory (buy some more RAM!)");
+  if(ptr == NULL) Msg::Fatal("Out of memory (buy some more RAM!)");
   return (ptr);
 }
 
 void Free(void *ptr)
 {
-  if(ptr == NULL)
-    return;
+  if(ptr == NULL) return;
   free(ptr);
 }
diff --git a/Common/MallocUtils.h b/Common/MallocUtils.h
index 84e0f7f73af88023c766f3eb2cca1f162d27454a..67b80b9dab385573ad8afccf830496a54b17caf4 100644
--- a/Common/MallocUtils.h
+++ b/Common/MallocUtils.h
@@ -11,6 +11,6 @@
 void *Malloc(size_t size);
 void *Calloc(size_t num, size_t size);
 void *Realloc(void *ptr, size_t size);
-void  Free(void *ptr);
+void Free(void *ptr);
 
 #endif
diff --git a/Common/OS.cpp b/Common/OS.cpp
index d038fe4e8d969f99f61201f8e67e73e935df0b81..a7cdf16dc8c321b799509c9dae4f1f8df23acd25 100644
--- a/Common/OS.cpp
+++ b/Common/OS.cpp
@@ -62,126 +62,156 @@
 
 // Unicode utility routines borrowed from FLTK
 
-static unsigned int utf8decode(const char* p, const char* end, int* len)
+static unsigned int utf8decode(const char *p, const char *end, int *len)
 {
   static unsigned short cp1252[32] = {
     0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021,
     0x02c6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008d, 0x017d, 0x008f,
     0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
-    0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178
-  };
-  unsigned char c = *(unsigned char*)p;
-  if (c < 0x80) {
-    if (len) *len = 1;
+    0x02dc, 0x2122, 0x0161, 0x203a, 0x0153, 0x009d, 0x017e, 0x0178};
+  unsigned char c = *(unsigned char *)p;
+  if(c < 0x80) {
+    if(len) *len = 1;
     return c;
-  } else if (c < 0xa0) {
-    if (len) *len = 1;
-    return cp1252[c-0x80];
-  } else if (c < 0xc2) {
+  }
+  else if(c < 0xa0) {
+    if(len) *len = 1;
+    return cp1252[c - 0x80];
+  }
+  else if(c < 0xc2) {
     goto FAIL;
   }
-  if ( (end && p+1 >= end) || (p[1]&0xc0) != 0x80) goto FAIL;
-  if (c < 0xe0) {
-    if (len) *len = 2;
-    return
-      ((p[0] & 0x1f) << 6) +
-      ((p[1] & 0x3f));
-  } else if (c == 0xe0) {
-    if (((unsigned char*)p)[1] < 0xa0) goto FAIL;
+  if((end && p + 1 >= end) || (p[1] & 0xc0) != 0x80) goto FAIL;
+  if(c < 0xe0) {
+    if(len) *len = 2;
+    return ((p[0] & 0x1f) << 6) + ((p[1] & 0x3f));
+  }
+  else if(c == 0xe0) {
+    if(((unsigned char *)p)[1] < 0xa0) goto FAIL;
     goto UTF8_3;
-  } else if (c < 0xf0) {
+  }
+  else if(c < 0xf0) {
   UTF8_3:
-    if ( (end && p+2 >= end) || (p[2]&0xc0) != 0x80) goto FAIL;
-    if (len) *len = 3;
-    return
-      ((p[0] & 0x0f) << 12) +
-      ((p[1] & 0x3f) << 6) +
-      ((p[2] & 0x3f));
-  } else if (c == 0xf0) {
-    if (((unsigned char*)p)[1] < 0x90) goto FAIL;
+    if((end && p + 2 >= end) || (p[2] & 0xc0) != 0x80) goto FAIL;
+    if(len) *len = 3;
+    return ((p[0] & 0x0f) << 12) + ((p[1] & 0x3f) << 6) + ((p[2] & 0x3f));
+  }
+  else if(c == 0xf0) {
+    if(((unsigned char *)p)[1] < 0x90) goto FAIL;
     goto UTF8_4;
-  } else if (c < 0xf4) {
+  }
+  else if(c < 0xf4) {
   UTF8_4:
-    if ( (end && p+3 >= end) || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL;
-    if (len) *len = 4;
-    return
-      ((p[0] & 0x07) << 18) +
-      ((p[1] & 0x3f) << 12) +
-      ((p[2] & 0x3f) << 6) +
-      ((p[3] & 0x3f));
-  } else if (c == 0xf4) {
-    if (((unsigned char*)p)[1] > 0x8f) goto FAIL; // after 0x10ffff
+    if((end && p + 3 >= end) || (p[2] & 0xc0) != 0x80 || (p[3] & 0xc0) != 0x80)
+      goto FAIL;
+    if(len) *len = 4;
+    return ((p[0] & 0x07) << 18) + ((p[1] & 0x3f) << 12) +
+           ((p[2] & 0x3f) << 6) + ((p[3] & 0x3f));
+  }
+  else if(c == 0xf4) {
+    if(((unsigned char *)p)[1] > 0x8f) goto FAIL; // after 0x10ffff
     goto UTF8_4;
-  } else {
+  }
+  else {
   FAIL:
-    if (len) *len = 1;
+    if(len) *len = 1;
     return c;
   }
 }
 
-static unsigned int utf8toUtf16(const char* src, unsigned int srclen,
-                                unsigned short* dst, unsigned int dstlen)
+static unsigned int utf8toUtf16(const char *src, unsigned int srclen,
+                                unsigned short *dst, unsigned int dstlen)
 {
-  const char* p = src;
-  const char* e = src+srclen;
+  const char *p = src;
+  const char *e = src + srclen;
   unsigned int count = 0;
-  if (dstlen) for (;;) {
-    if (p >= e) {dst[count] = 0; return count;}
-    if (!(*p & 0x80)) { // ascii
-      dst[count] = *p++;
-    } else {
-      int len; unsigned int ucs = utf8decode(p,e,&len);
-      p += len;
-      if (ucs < 0x10000) {
-	dst[count] = ucs;
-      } else {
-	// make a surrogate pair:
-	if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
-	dst[count] = (((ucs-0x10000u)>>10)&0x3ff) | 0xd800;
-	dst[++count] = (ucs&0x3ff) | 0xdc00;
+  if(dstlen)
+    for(;;) {
+      if(p >= e) {
+        dst[count] = 0;
+        return count;
+      }
+      if(!(*p & 0x80)) { // ascii
+        dst[count] = *p++;
+      }
+      else {
+        int len;
+        unsigned int ucs = utf8decode(p, e, &len);
+        p += len;
+        if(ucs < 0x10000) {
+          dst[count] = ucs;
+        }
+        else {
+          // make a surrogate pair:
+          if(count + 2 >= dstlen) {
+            dst[count] = 0;
+            count += 2;
+            break;
+          }
+          dst[count] = (((ucs - 0x10000u) >> 10) & 0x3ff) | 0xd800;
+          dst[++count] = (ucs & 0x3ff) | 0xdc00;
+        }
+      }
+      if(++count == dstlen) {
+        dst[count - 1] = 0;
+        break;
       }
     }
-    if (++count == dstlen) {dst[count-1] = 0; break;}
-  }
   // we filled dst, measure the rest:
-  while (p < e) {
-    if (!(*p & 0x80)) p++;
+  while(p < e) {
+    if(!(*p & 0x80))
+      p++;
     else {
-      int len; unsigned int ucs = utf8decode(p,e,&len);
+      int len;
+      unsigned int ucs = utf8decode(p, e, &len);
       p += len;
-      if (ucs >= 0x10000) ++count;
+      if(ucs >= 0x10000) ++count;
     }
     ++count;
   }
   return count;
 }
 
-static unsigned int utf8FromUtf16(char* dst, unsigned int dstlen,
-                                  const wchar_t* src, unsigned int srclen)
+static unsigned int utf8FromUtf16(char *dst, unsigned int dstlen,
+                                  const wchar_t *src, unsigned int srclen)
 {
   unsigned int i = 0;
   unsigned int count = 0;
-  if (dstlen) {
-    for (;;) {
+  if(dstlen) {
+    for(;;) {
       unsigned int ucs;
-      if (i >= srclen) {dst[count] = 0; return count;}
+      if(i >= srclen) {
+        dst[count] = 0;
+        return count;
+      }
       ucs = src[i++];
-      if (ucs < 0x80U) {
+      if(ucs < 0x80U) {
         dst[count++] = ucs;
-        if (count >= dstlen) {dst[count-1] = 0; break;}
+        if(count >= dstlen) {
+          dst[count - 1] = 0;
+          break;
+        }
       }
-      else if (ucs < 0x800U) { /* 2 bytes */
-        if (count+2 >= dstlen) {dst[count] = 0; count += 2; break;}
+      else if(ucs < 0x800U) { /* 2 bytes */
+        if(count + 2 >= dstlen) {
+          dst[count] = 0;
+          count += 2;
+          break;
+        }
         dst[count++] = 0xc0 | (ucs >> 6);
         dst[count++] = 0x80 | (ucs & 0x3F);
       }
-      else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen &&
-	       src[i] >= 0xdc00 && src[i] <= 0xdfff) {
+      else if(ucs >= 0xd800 && ucs <= 0xdbff && i < srclen &&
+              src[i] >= 0xdc00 && src[i] <= 0xdfff) {
         /* surrogate pair */
         unsigned int ucs2 = src[i++];
-        ucs = 0x10000U + ((ucs&0x3ff)<<10) + (ucs2&0x3ff);
+        ucs = 0x10000U + ((ucs & 0x3ff) << 10) + (ucs2 & 0x3ff);
         /* all surrogate pairs turn into 4-byte utf8 */
-        if (count+4 >= dstlen) {dst[count] = 0; count += 4; break;}
+        if(count + 4 >= dstlen) {
+          dst[count] = 0;
+          count += 4;
+          break;
+        }
         dst[count++] = 0xf0 | (ucs >> 18);
         dst[count++] = 0x80 | ((ucs >> 12) & 0x3F);
         dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
@@ -189,7 +219,11 @@ static unsigned int utf8FromUtf16(char* dst, unsigned int dstlen,
       }
       else {
         /* all others are 3 bytes: */
-        if (count+3 >= dstlen) {dst[count] = 0; count += 3; break;}
+        if(count + 3 >= dstlen) {
+          dst[count] = 0;
+          count += 3;
+          break;
+        }
         dst[count++] = 0xe0 | (ucs >> 12);
         dst[count++] = 0x80 | ((ucs >> 6) & 0x3F);
         dst[count++] = 0x80 | (ucs & 0x3F);
@@ -197,16 +231,16 @@ static unsigned int utf8FromUtf16(char* dst, unsigned int dstlen,
     }
   }
   /* we filled dst, measure the rest: */
-  while (i < srclen) {
+  while(i < srclen) {
     unsigned int ucs = src[i++];
-    if (ucs < 0x80U) {
+    if(ucs < 0x80U) {
       count++;
     }
-    else if (ucs < 0x800U) { /* 2 bytes */
+    else if(ucs < 0x800U) { /* 2 bytes */
       count += 2;
     }
-    else if (ucs >= 0xd800 && ucs <= 0xdbff && i < srclen-1 &&
-             src[i+1] >= 0xdc00 && src[i+1] <= 0xdfff) {
+    else if(ucs >= 0xd800 && ucs <= 0xdbff && i < srclen - 1 &&
+            src[i + 1] >= 0xdc00 && src[i + 1] <= 0xdfff) {
       /* surrogate pair */
       ++i;
       count += 4;
@@ -227,9 +261,9 @@ static void setwbuf(int i, const char *f)
   // (through wchar_t), so we need to convert.
   if(i < 0 || i > 2) return;
   size_t l = strlen(f);
-  unsigned int wn = utf8toUtf16(f, (unsigned int) l, NULL, 0) + 1;
-  wbuf[i] = (wchar_t*)realloc(wbuf[i], sizeof(wchar_t)*wn);
-  wn = utf8toUtf16(f, (unsigned) l, (unsigned short *)wbuf[i], wn);
+  unsigned int wn = utf8toUtf16(f, (unsigned int)l, NULL, 0) + 1;
+  wbuf[i] = (wchar_t *)realloc(wbuf[i], sizeof(wchar_t) * wn);
+  wn = utf8toUtf16(f, (unsigned)l, (unsigned short *)wbuf[i], wn);
   wbuf[i][wn] = 0;
 }
 
@@ -237,7 +271,7 @@ static void setwbuf(int i, const char *f)
 
 FILE *Fopen(const char *f, const char *mode)
 {
-#if defined (WIN32) && !defined(__CYGWIN__)
+#if defined(WIN32) && !defined(__CYGWIN__)
   setwbuf(0, f);
   setwbuf(1, mode);
   return _wfopen(wbuf[0], wbuf[1]);
@@ -277,8 +311,8 @@ double GetTimeInSeconds()
 #if defined(WIN32) && !defined(__CYGWIN__)
   FILETIME ft;
   GetSystemTimeAsFileTime(&ft);
-  double t =  1.e-7 * 4294967296. * (double)ft.dwHighDateTime +
-              1.e-7 * (double)ft.dwLowDateTime;
+  double t = 1.e-7 * 4294967296. * (double)ft.dwHighDateTime +
+             1.e-7 * (double)ft.dwLowDateTime;
   return t;
 #else
   struct timeval tp;
@@ -301,7 +335,7 @@ static void GetResources(double *s, long *mem)
 {
 #if defined(WIN32) && !defined(__CYGWIN__)
   FILETIME creation, exit, kernel, user;
-  if(GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user)){
+  if(GetProcessTimes(GetCurrentProcess(), &creation, &exit, &kernel, &user)) {
     *s = 1.e-7 * 4294967296. * (double)user.dwHighDateTime +
          1.e-7 * (double)user.dwLowDateTime;
   }
@@ -322,7 +356,7 @@ static void GetResources(double *s, long *mem)
 
 void CheckResources()
 {
-#if !defined (WIN32) || defined(__CYGWIN__)
+#if !defined(WIN32) || defined(__CYGWIN__)
   static struct rlimit r;
 
   getrlimit(RLIMIT_STACK, &r);
@@ -330,8 +364,9 @@ void CheckResources()
   // Try to get at least 16 MB of stack. Running with too small a stack
   // can cause crashes in the recursive calls (e.g. for tet
   // classification in 3D Delaunay)
-  if(r.rlim_cur < 16 * 1024 * 1024){
-    Msg::Info("Increasing process stack size (%d kB < 16 MB)", r.rlim_cur / 1024);
+  if(r.rlim_cur < 16 * 1024 * 1024) {
+    Msg::Info("Increasing process stack size (%d kB < 16 MB)",
+              r.rlim_cur / 1024);
     r.rlim_cur = r.rlim_max;
     setrlimit(RLIMIT_STACK, &r);
   }
@@ -357,19 +392,19 @@ double TotalRam()
   int name[] = {CTL_HW, HW_MEMSIZE};
   int64_t value;
   size_t len = sizeof(value);
-  if(sysctl(name, 2, &value, &len, NULL, 0) != -1)
-    ram = value / (1024 * 1024);
-#elif defined (WIN32)
+  if(sysctl(name, 2, &value, &len, NULL, 0) != -1) ram = value / (1024 * 1024);
+#elif defined(WIN32)
   MEMORYSTATUSEX status;
   status.dwLength = sizeof(status);
   GlobalMemoryStatusEx(&status);
-  ram = status.ullTotalPhys  / ((double)1024 * 1024);
+  ram = status.ullTotalPhys / ((double)1024 * 1024);
 #elif defined(BUILD_ANDROID)
   ram = 1024;
 #elif defined(__linux__)
   struct sysinfo infos;
   if(sysinfo(&infos) != -1)
-    ram = infos.totalram * (unsigned long)infos.mem_unit / ((double)1024 * 1024);
+    ram =
+      infos.totalram * (unsigned long)infos.mem_unit / ((double)1024 * 1024);
 #endif
   return ram;
 }
@@ -377,7 +412,7 @@ double TotalRam()
 double TimeOfDay()
 {
 #if defined(WIN32) && !defined(__CYGWIN__)
-  struct _timeb  localTime;
+  struct _timeb localTime;
   _ftime(&localTime);
   return localTime.time + 1.e-3 * localTime.millitm;
 #else
@@ -410,7 +445,7 @@ std::string GetExecutableFileName()
 #if defined(WIN32) && !defined(__CYGWIN__)
   wchar_t src[MAX_PATH];
   unsigned long size = GetModuleFileNameW(NULL, src, MAX_PATH);
-  if(size){
+  if(size) {
     char dst[MAX_PATH];
     utf8FromUtf16(dst, MAX_PATH, src, size);
     name = std::string(dst);
@@ -418,16 +453,16 @@ std::string GetExecutableFileName()
 #elif defined(__APPLE__)
   char path[PATH_MAX];
   uint32_t size = sizeof(path);
-  if(_NSGetExecutablePath(path, &size) == 0){
+  if(_NSGetExecutablePath(path, &size) == 0) {
     char real[PATH_MAX];
-    if(realpath(path, real)){
+    if(realpath(path, real)) {
       name = std::string(real);
     }
   }
 #elif defined(__linux__)
   char path[4096];
   int n = readlink("/proc/self/exe", path, sizeof(path));
-  if(n > 0 && n < (int)sizeof(path)){
+  if(n > 0 && n < (int)sizeof(path)) {
     path[n] = '\0';
     name = std::string(path);
   }
@@ -441,15 +476,14 @@ std::string GetAbsolutePath(const std::string &fileName)
   setwbuf(0, fileName.c_str());
   wchar_t path[MAX_PATH];
   unsigned long size = GetFullPathNameW(wbuf[0], MAX_PATH, path, NULL);
-  if(size){
+  if(size) {
     char dst[MAX_PATH];
     utf8FromUtf16(dst, MAX_PATH, path, size);
     return std::string(dst);
   }
 #else
   char path[4096];
-  if(realpath(fileName.c_str(), path))
-    return path;
+  if(realpath(fileName.c_str(), path)) return path;
 #endif
   return fileName;
 }
@@ -511,13 +545,12 @@ int KillProcess(int pid)
 {
 #if defined(WIN32) && !defined(__CYGWIN__)
   HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
-  if(!TerminateProcess(hProc, 0)){
+  if(!TerminateProcess(hProc, 0)) {
     CloseHandle(hProc);
     return 0;
   }
 #else
-  if(kill(pid, 9))
-    return 0;
+  if(kill(pid, 9)) return 0;
 #endif
   return 1;
 }
@@ -531,22 +564,22 @@ int SystemCallExe(const std::string &exe, const std::string &argsOrCommand,
   bool isOctave = (split[2] == ".m" || split[2] == ".M");
   bool isExe = (split[2] == ".exe" || split[2] == ".EXE");
 
-  if(isPython || isOctave || isExe){
-    if(StatFile(exe)){
+  if(isPython || isOctave || isExe) {
+    if(StatFile(exe)) {
       Msg::Error("Unable to open file '%s'", exe.c_str());
       return 1;
     }
   }
 
   std::string command;
-  if(exe.size()){
+  if(exe.size()) {
     command.append("\"" + exe + "\""); // allows exe with white space
     if(argsOrCommand.size()) command.append(" ");
   }
   command.append(argsOrCommand);
 
 #if defined(WIN32) && !defined(__CYGWIN__)
-  if(isPython || isOctave){
+  if(isPython || isOctave) {
     Msg::Info("Shell opening '%s' with arguments '%s'", exe.c_str(),
               argsOrCommand.c_str());
     setwbuf(0, "open");
@@ -554,51 +587,52 @@ int SystemCallExe(const std::string &exe, const std::string &argsOrCommand,
     setwbuf(2, argsOrCommand.c_str());
     ShellExecuteW(NULL, wbuf[0], wbuf[1], wbuf[2], NULL, 0);
   }
-  else{
+  else {
     STARTUPINFOW suInfo;
     PROCESS_INFORMATION prInfo;
     memset(&suInfo, 0, sizeof(suInfo));
     suInfo.cb = sizeof(suInfo);
     Msg::Info("Calling '%s'", command.c_str());
     setwbuf(0, command.c_str());
-    if(blocking){
-      CreateProcessW(NULL, wbuf[0], NULL, NULL, FALSE,
-		    NORMAL_PRIORITY_CLASS, NULL, NULL,
-		    &suInfo, &prInfo);
+    if(blocking) {
+      CreateProcessW(NULL, wbuf[0], NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
+                     NULL, NULL, &suInfo, &prInfo);
       // wait until child process exits.
       WaitForSingleObject(prInfo.hProcess, INFINITE);
       // close process and thread handles.
       CloseHandle(prInfo.hProcess);
       CloseHandle(prInfo.hThread);
     }
-    else{
+    else {
       // DETACHED_PROCESS removes the console (useful if the program to launch
       // is a console-mode exe)
       CreateProcessW(NULL, wbuf[0], NULL, NULL, FALSE,
-		    NORMAL_PRIORITY_CLASS|DETACHED_PROCESS, NULL, NULL,
-		    &suInfo, &prInfo);
+                     NORMAL_PRIORITY_CLASS | DETACHED_PROCESS, NULL, NULL,
+                     &suInfo, &prInfo);
     }
   }
 #elif(BUILD_IOS)
   Msg::Warning("SystemCall is not supported on iOS");
 #else
   std::string cmd(command);
-  if(isPython || isOctave || isExe){
-    if(access(exe.c_str(), X_OK)){
-      if(isPython){
+  if(isPython || isOctave || isExe) {
+    if(access(exe.c_str(), X_OK)) {
+      if(isPython) {
         Msg::Info("Script '%s' is not executable: running with `%s'",
-		  exe.c_str(), CTX::instance()->solver.pythonInterpreter.c_str());
+                  exe.c_str(),
+                  CTX::instance()->solver.pythonInterpreter.c_str());
         cmd = CTX::instance()->solver.pythonInterpreter + " " + cmd;
       }
-      else if(isOctave){
+      else if(isOctave) {
         Msg::Info("Script '%s' is not executable: running with `%s'",
-		  exe.c_str(), CTX::instance()->solver.octaveInterpreter.c_str());
+                  exe.c_str(),
+                  CTX::instance()->solver.octaveInterpreter.c_str());
         cmd = CTX::instance()->solver.octaveInterpreter + " " + cmd;
       }
       else
         Msg::Warning("File '%s' is not executable", exe.c_str());
     }
-    else if(split[0].empty()){
+    else if(split[0].empty()) {
       // workaround if pwd is not in PATH
       cmd = "./" + cmd;
     }
@@ -652,11 +686,11 @@ void RedirectIOToConsole()
   // redirect unbuffered stdout, stdin and stderr to the console
   {
     intptr_t lStdHandle = (intptr_t)GetStdHandle(STD_OUTPUT_HANDLE);
-    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE){
+    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE) {
       int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-      if(hConHandle >= 0){
+      if(hConHandle >= 0) {
         FILE *fp = _fdopen(hConHandle, "w");
-        if(fp){
+        if(fp) {
           *stdout = *fp;
           setvbuf(stdout, NULL, _IONBF, 0);
         }
@@ -665,11 +699,11 @@ void RedirectIOToConsole()
   }
   {
     intptr_t lStdHandle = (intptr_t)GetStdHandle(STD_INPUT_HANDLE);
-    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE){
+    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE) {
       int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-      if(hConHandle >= 0){
+      if(hConHandle >= 0) {
         FILE *fp = _fdopen(hConHandle, "r");
-        if(fp){
+        if(fp) {
           *stdin = *fp;
           setvbuf(stdin, NULL, _IONBF, 0);
         }
@@ -678,11 +712,11 @@ void RedirectIOToConsole()
   }
   {
     intptr_t lStdHandle = (intptr_t)GetStdHandle(STD_ERROR_HANDLE);
-    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE){
+    if(lStdHandle != (intptr_t)INVALID_HANDLE_VALUE) {
       int hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
-      if(hConHandle >= 0){
+      if(hConHandle >= 0) {
         FILE *fp = _fdopen(hConHandle, "w");
-        if(fp){
+        if(fp) {
           *stderr = *fp;
           setvbuf(stderr, NULL, _IONBF, 0);
         }
@@ -699,27 +733,27 @@ void UnzipFile(const std::string &fileName, const std::string &prependDir)
 {
 #if defined(HAVE_ZIPPER)
   std::string dir = prependDir;
-  if(dir.size() && dir[dir.size()-1] != '/' && dir[dir.size()-1] != '\\')
+  if(dir.size() && dir[dir.size() - 1] != '/' && dir[dir.size() - 1] != '\\')
     dir.push_back('/');
 
   ziputils::unzipper zipFile;
   zipFile.open(fileName.c_str());
   std::vector<std::string> dirnames = zipFile.getFolders();
-  for (std::vector<std::string>::const_iterator it = dirnames.begin();
-       it != dirnames.end(); it++){
+  for(std::vector<std::string>::const_iterator it = dirnames.begin();
+      it != dirnames.end(); it++) {
     std::string folder = dir + *it;
     Msg::Info("Creating folder `%s'", folder.c_str());
     CreatePath(folder);
   }
   std::vector<std::string> filenames = zipFile.getFilenames();
-  for (std::vector<std::string>::const_iterator it = filenames.begin();
-       it != filenames.end(); it++){
+  for(std::vector<std::string>::const_iterator it = filenames.begin();
+      it != filenames.end(); it++) {
     zipFile.openEntry(it->c_str());
     std::string name = dir + *it;
     Msg::Info("Extracting file `%s'", name.c_str());
     std::ofstream ofs;
     ofs.open(name.c_str());
-    if(ofs.is_open()){
+    if(ofs.is_open()) {
       zipFile >> ofs;
       ofs.close();
     }
diff --git a/Common/OS.h b/Common/OS.h
index c709e9cc54ad811f835285d4323a5d6a47878f72..2dc22be72000f847a56fd39af397a2ec7782d8d6 100644
--- a/Common/OS.h
+++ b/Common/OS.h
@@ -9,7 +9,7 @@
 #include <string>
 #include <stdio.h>
 
-FILE *Fopen(const char* f, const char *mode);
+FILE *Fopen(const char *f, const char *mode);
 const char *GetEnvironmentVar(const char *var);
 void SetEnvironmentVar(const char *var, const char *val);
 double GetTimeInSeconds();
@@ -28,11 +28,11 @@ int StatFile(const std::string &fileName);
 int KillProcess(int pid);
 int CreateSingleDir(const std::string &dirName);
 void CreatePath(const std::string &fullPath);
-int SystemCall(const std::string &command, bool blocking=false);
+int SystemCall(const std::string &command, bool blocking = false);
 int SystemCallExe(const std::string &exe, const std::string &argsOrCommand,
-                  bool blocking=false);
+                  bool blocking = false);
 std::string GetCurrentWorkdir();
 void RedirectIOToConsole();
-void UnzipFile(const std::string &fileName, const std::string &prependDir="");
+void UnzipFile(const std::string &fileName, const std::string &prependDir = "");
 
 #endif
diff --git a/Common/Octree.cpp b/Common/Octree.cpp
index 28ba21573cca0190ad9ac8d5a758970dd1ca280e..7699fa26cfbe58e12b090c302a2be1e61683c7e0 100644
--- a/Common/Octree.cpp
+++ b/Common/Octree.cpp
@@ -8,21 +8,21 @@
 #include <vector>
 #include "Octree.h"
 
-Octree* Octree_Create(int maxElements, double origin[3], double size[3],   
-                      void  (*BB)(void *, double*, double*),
-                      void  (*Centroid)(void *, double *),
-                      int   (*InEle)(void *, double *))
+Octree *Octree_Create(int maxElements, double origin[3], double size[3],
+                      void (*BB)(void *, double *, double *),
+                      void (*Centroid)(void *, double *),
+                      int (*InEle)(void *, double *))
 {
   Octree *myOctree = new Octree;
-  initializeOctantBuckets(origin, size, maxElements,
-                          &(myOctree->root), &(myOctree->info));       
+  initializeOctantBuckets(origin, size, maxElements, &(myOctree->root),
+                          &(myOctree->info));
   myOctree->function_BB = BB;
   myOctree->function_centroid = Centroid;
   myOctree->function_inElement = InEle;
   return myOctree;
 }
 
-void free_buckets(octantBucket * bucket)
+void free_buckets(octantBucket *bucket)
 {
   int i, numBuck = 8;
   ELink ptr1, ptr2;
@@ -34,13 +34,12 @@ void free_buckets(octantBucket * bucket)
       ptr1 = ptr1->next;
       delete ptr2;
     }
-    bucket->listBB.clear(); 
+    bucket->listBB.clear();
     return;
   }
 
-  for(i = numBuck-1; i >= 0; i--) 
-    free_buckets((bucket->next)+i);         
-  delete []bucket->next;
+  for(i = numBuck - 1; i >= 0; i--) free_buckets((bucket->next) + i);
+  delete[] bucket->next;
   return;
 }
 
@@ -62,35 +61,33 @@ void Octree_Insert(void *element, Octree *myOctree)
   (*(myOctree->function_centroid))(element, centroid);
   bucket = findElementBucket(myOctree->root, centroid);
   if(bucket)
-    addElement2Bucket(bucket, element, minBB, maxBB,
-                      centroid, myOctree->info);  
+    addElement2Bucket(bucket, element, minBB, maxBB, centroid, myOctree->info);
 }
 
 void Octree_Arrange(Octree *myOctree)
 {
   if(!myOctree) return;
-  //std::list<void *>::iterator iter;
+  // std::list<void *>::iterator iter;
   std::vector<void *>::iterator iter;
   double minPt[3], maxPt[3];
-  for(iter = myOctree->info->listAllElements.begin(); iter!= 
-      myOctree->info->listAllElements.end(); iter++) {
+  for(iter = myOctree->info->listAllElements.begin();
+      iter != myOctree->info->listAllElements.end(); iter++) {
     (*(myOctree->function_BB))(*iter, minPt, maxPt);
     insertOneBB(*iter, minPt, maxPt, myOctree->root);
   }
   myOctree->info->listAllElements.clear();
-}   
+}
 
 void *Octree_Search(double *pt, Octree *myOctree)
 {
   if(!myOctree) return 0;
-  return searchElement(myOctree->root, pt, myOctree->info, 
+  return searchElement(myOctree->root, pt, myOctree->info,
                        myOctree->function_BB, myOctree->function_inElement);
 }
 
-void Octree_SearchAll(double *pt, Octree *myOctree, std::vector<void*> *output)
+void Octree_SearchAll(double *pt, Octree *myOctree, std::vector<void *> *output)
 {
   if(!myOctree) return;
   searchAllElements(myOctree->root, pt, myOctree->info, myOctree->function_BB,
-                    myOctree->function_inElement, output);      
+                    myOctree->function_inElement, output);
 }
-
diff --git a/Common/Octree.h b/Common/Octree.h
index ae4167aa849a0f77e671bdc27d4ec6c12a945ae5..cd1040fcb3433ba107f9f8111ec440838b6c50ba 100644
--- a/Common/Octree.h
+++ b/Common/Octree.h
@@ -9,14 +9,14 @@
 #include <vector>
 #include "OctreeInternals.h"
 
-Octree* Octree_Create(int maxElements, // max. num of elts allowed in an octant
+Octree *Octree_Create(int maxElements, // max. num of elts allowed in an octant
                       double *origin, // smallest x,y, z of model's bounding box
                       double *size, // size in x, y, z of model bounding box
-                      void (*BB)(void *, double*, double*),
+                      void (*BB)(void *, double *, double *),
                       void (*Centroid)(void *, double *),
                       int (*InEle)(void *, double *));
 
-void Octree_Delete(Octree *);  
+void Octree_Delete(Octree *);
 void Octree_Insert(void *, Octree *);
 void Octree_Arrange(Octree *);
 void *Octree_Search(double *, Octree *);
diff --git a/Common/OctreeInternals.cpp b/Common/OctreeInternals.cpp
index 210b800f06ff16bc4efcd80e3a4c29b0e85750cd..7336d3c199c1e7aad90644d458116af0a92b9923 100644
--- a/Common/OctreeInternals.cpp
+++ b/Common/OctreeInternals.cpp
@@ -11,7 +11,8 @@
 #include "OctreeInternals.h"
 
 int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
-                            octantBucket **buckets_head, globalInfo **globalPara)
+                            octantBucket **buckets_head,
+                            globalInfo **globalPara)
 // Initialize the buckets
 // Given by user: orig and size -- information about the domain
 //                maxElem -- maximum number of elements per bucket
@@ -21,12 +22,11 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
 {
   int i, j, k, tmp1;
   int p = 1;
-  int initial_buckets_num;  // which is a number of 8^p form for integer p
+  int initial_buckets_num; // which is a number of 8^p form for integer p
   double tmp[3], error[3];
   octantBucket *buckets;
 
-  for (i = 0; i < 3; i++)
-    error[i]= _size[i]*0.01;
+  for(i = 0; i < 3; i++) error[i] = _size[i] * 0.01;
 
   initial_buckets_num = (int)pow(8., p); // it is actually 8
 
@@ -35,20 +35,20 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
   (*globalPara)->maxElements = _maxElem;
   (*globalPara)->ptrToPrevElement = NULL;
 
-  for (i = 0; i < 3; i++) {
+  for(i = 0; i < 3; i++) {
     (*globalPara)->origin[i] = _orig[i];
     (*globalPara)->size[i] = _size[i];
   }
 
   (*globalPara)->numBuckets = initial_buckets_num;
   *buckets_head = new octantBucket;
-  if (!(*buckets_head)) {
+  if(!(*buckets_head)) {
     Msg::Error("initializeOctantBuckets could not allocate enough space");
     return (0);
   } // if could not allocate buckets
 
   buckets = new octantBucket[8];
-  if (!buckets) {
+  if(!buckets) {
     Msg::Error("initializeOctantBuckets could not allocate enough space");
     return (0);
   }
@@ -58,12 +58,12 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
   (*buckets_head)->numElements = 0;
   (*buckets_head)->lhead = NULL;
   (*buckets_head)->precision = 0;
-  for (i = 0; i< 3; i++) {
-    (*buckets_head)->minPt[i] = _orig[i]-error[i];
-    (*buckets_head)->maxPt[i] = _size[i]+_orig[i]+error[i];
+  for(i = 0; i < 3; i++) {
+    (*buckets_head)->minPt[i] = _orig[i] - error[i];
+    (*buckets_head)->maxPt[i] = _size[i] + _orig[i] + error[i];
   }
 
-  for (i = 0; i < (*globalPara)->numBuckets; i++) {
+  for(i = 0; i < (*globalPara)->numBuckets; i++) {
     buckets[i].numElements = 0;
     buckets[i].lhead = NULL;
     buckets[i].next = NULL;
@@ -72,19 +72,25 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
   }
 
   tmp1 = (int)(pow(2., p));
-  for (i = 0; i < 3; i++) {
-    tmp[i] = (double)(_size[i]+2*error[i])/tmp1;
+  for(i = 0; i < 3; i++) {
+    tmp[i] = (double)(_size[i] + 2 * error[i]) / tmp1;
   }
 
-  for (k = 0; k < tmp1; k++) {
-    for (j = 0; j < tmp1; j++) {
-      for (i = 0; i < tmp1; i++) {
-        buckets[i+j*tmp1+k*tmp1*tmp1].minPt[0] = (*buckets_head)->minPt[0] + tmp[0]*i;
-        buckets[i+j*tmp1+k*tmp1*tmp1].minPt[1] = (*buckets_head)->minPt[1] + tmp[1]*j;
-        buckets[i+j*tmp1+k*tmp1*tmp1].minPt[2] = (*buckets_head)->minPt[2] + tmp[2]*k;
-        buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = (*buckets_head)->minPt[0] + tmp[0]*(i+1);
-        buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = (*buckets_head)->minPt[1] + tmp[1]*(j+1);
-        buckets[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = (*buckets_head)->minPt[2] + tmp[2]*(k+1);
+  for(k = 0; k < tmp1; k++) {
+    for(j = 0; j < tmp1; j++) {
+      for(i = 0; i < tmp1; i++) {
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].minPt[0] =
+          (*buckets_head)->minPt[0] + tmp[0] * i;
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].minPt[1] =
+          (*buckets_head)->minPt[1] + tmp[1] * j;
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].minPt[2] =
+          (*buckets_head)->minPt[2] + tmp[2] * k;
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].maxPt[0] =
+          (*buckets_head)->minPt[0] + tmp[0] * (i + 1);
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].maxPt[1] =
+          (*buckets_head)->minPt[1] + tmp[1] * (j + 1);
+        buckets[i + j * tmp1 + k * tmp1 * tmp1].maxPt[2] =
+          (*buckets_head)->minPt[2] + tmp[2] * (k + 1);
       }
     }
   }
@@ -102,9 +108,9 @@ int initializeOctantBuckets(double *_orig, double *_size, int _maxElem,
   return (1);
 }
 
-int addElement2Bucket(octantBucket *_bucket, void * _element,
-                      double *_minBB, double *_maxBB,
-                      double *_ele_centroid, globalInfo *_globalPara)
+int addElement2Bucket(octantBucket *_bucket, void *_element, double *_minBB,
+                      double *_maxBB, double *_ele_centroid,
+                      globalInfo *_globalPara)
 // Add another element to the octant bucket's list.
 // If the bucket contains too many elements after adding this element,
 // refine this bucket and reallocate the elements of this bucket
@@ -119,17 +125,17 @@ int addElement2Bucket(octantBucket *_bucket, void * _element,
   octantBucket *ptrBucket;
 
   // check for duplicates
-  if ( checkElementInBucket(_bucket, _element) == 1) return -1;
+  if(checkElementInBucket(_bucket, _element) == 1) return -1;
 
   // printf("\n addToBucket...\n");
   // ptr1 = (ELink) malloc(sizeof(Elem));
   ptr1 = new Elem;
   (_globalPara->listAllElements).push_back(_element);
 
-  ptr1-> next = _bucket->lhead;
-  ptr1-> region = _element;
+  ptr1->next = _bucket->lhead;
+  ptr1->region = _element;
 
-  for (i = 0; i < 3; i++) {
+  for(i = 0; i < 3; i++) {
     ptr1->minPt[i] = _minBB[i];
     ptr1->maxPt[i] = _maxBB[i];
     ptr1->centroid[i] = _ele_centroid[i];
@@ -149,10 +155,9 @@ int addElement2Bucket(octantBucket *_bucket, void * _element,
 
   // check whether the number of elements in the bucket > maxElements
   // if true, refine the bucket and reallocate the elements
-  while ( flag == 1) {
+  while(flag == 1) {
     flag = 0;
-    if (_bucket->numElements > _globalPara->maxElements) {
-
+    if(_bucket->numElements > _globalPara->maxElements) {
       // printf(" going to subdivide\n");
 
       subdivideOctantBucket(_bucket, _globalPara);
@@ -160,43 +165,42 @@ int addElement2Bucket(octantBucket *_bucket, void * _element,
       // printf("finish subdivede \n");
 
       ptr1 = _bucket->lhead;
-      while (ptr1 != NULL) {
+      while(ptr1 != NULL) {
         ptrBucket = findElementBucket(_bucket, ptr1->centroid);
         ptr2 = ptr1;
         ptr1 = ptr1->next;
-        if (ptrBucket == NULL){
+        if(ptrBucket == NULL) {
           Msg::Error("Wrong , ptrBucket = NULL. A bug here!");
           return 0;
         }
         ptr2->next = ptrBucket->lhead;
         ptrBucket->lhead = ptr2;
         (ptrBucket->numElements)++;
-        if (ptrBucket->numElements > _globalPara->maxElements) {
+        if(ptrBucket->numElements > _globalPara->maxElements) {
           flag = 1;
           _bucket->lhead = NULL;
           _bucket = ptrBucket;
         }
       }
-      if (flag == 0) _bucket->lhead = NULL;
+      if(flag == 0) _bucket->lhead = NULL;
     }
   }
   return 1;
 }
 
-int checkElementInBucket(octantBucket *_bucket, void* _element)
+int checkElementInBucket(octantBucket *_bucket, void *_element)
 // Given an elememt and an octant bucket, check if the element
 // exists in the bucket's element list. return 1 if already exits,
 // otherwise, return 0
 {
   ELink ptr;
-  for (ptr = _bucket->lhead; ptr != NULL; ptr = ptr->next) {
+  for(ptr = _bucket->lhead; ptr != NULL; ptr = ptr->next) {
     // changed ****, compare the objected pointed by the void *.
-    if (ptr->region == _element)    return 1;
+    if(ptr->region == _element) return 1;
   }
   return 0;
 }
 
-
 octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt)
 // Find the leaf bucket which contains the point _pt
 // given parameter: _buckets --- the point to buckets head
@@ -209,20 +213,19 @@ octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt)
   octantBucket *prevbucket = NULL;
   octantBucket *tmpbucket = _buckets_head->next;
 
-  while (tmpbucket != NULL) {
-    for (i = 0; i < num; i ++) {
-      for (j = 0; j < 3; j++) {
-        if (tmpbucket[i].minPt[j] > _pt[j] ||
-            tmpbucket[i].maxPt[j] < _pt[j])
+  while(tmpbucket != NULL) {
+    for(i = 0; i < num; i++) {
+      for(j = 0; j < 3; j++) {
+        if(tmpbucket[i].minPt[j] > _pt[j] || tmpbucket[i].maxPt[j] < _pt[j])
           break;
       }
-      if (j == 3) {
-        prevbucket = tmpbucket+i;
+      if(j == 3) {
+        prevbucket = tmpbucket + i;
         tmpbucket = tmpbucket[i].next;
         break;
       }
     } // for loop i
-    if (i == num) {
+    if(i == num) {
       // Msg::Error("No bucket contains the given point!");
       return NULL;
     }
@@ -230,7 +233,6 @@ octantBucket *findElementBucket(octantBucket *_buckets_head, double *_pt)
   return prevbucket;
 }
 
-
 int subdivideOctantBucket(octantBucket *_bucket, globalInfo *_globalPara)
 // To many elements are in this octant bucket, so try to refine
 // Returns 1 for success, 0 for failure (no memory left).
@@ -242,36 +244,42 @@ int subdivideOctantBucket(octantBucket *_bucket, globalInfo *_globalPara)
   _bucket->next = new octantBucket[8];
   // _bucket->next  = (octantBucket *) calloc(numBuck,sizeof(octantBucket));
 
-  if (!_bucket->next) {
+  if(!_bucket->next) {
     Msg::Error("subdivideOctantBucket could not allocate enough space");
     return 0;
   }
 
-  _globalPara->numBuckets +=8;
-  if (_bucket->precision == _globalPara->maxPrecision)
+  _globalPara->numBuckets += 8;
+  if(_bucket->precision == _globalPara->maxPrecision)
     _globalPara->maxPrecision++;
-  for (i = 0; i < numBuck; i++) {
+  for(i = 0; i < numBuck; i++) {
     (_bucket->next[i]).numElements = 0;
     (_bucket->next[i]).lhead = NULL;
     (_bucket->next[i]).next = NULL;
     (_bucket->next[i]).parent = _bucket;
-    (_bucket->next[i]).precision = _bucket->precision+1;
+    (_bucket->next[i]).precision = _bucket->precision + 1;
   }
 
   tmp1 = 2;
-  for (i = 0; i < 3; i++) {
-    tmp[i] = ((double)(_bucket->maxPt[i]-_bucket->minPt[i]))/tmp1;
+  for(i = 0; i < 3; i++) {
+    tmp[i] = ((double)(_bucket->maxPt[i] - _bucket->minPt[i])) / tmp1;
   }
 
-  for (k = 0; k < tmp1; k++) {
-    for (j = 0; j < tmp1; j++) {
-      for (i = 0; i < tmp1; i++) {
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[0] = _bucket->minPt[0] + tmp[0]*i;
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[1] = _bucket->minPt[1] + tmp[1]*j;
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].minPt[2] = _bucket->minPt[2] + tmp[2]*k;
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[0] = _bucket->minPt[0] + tmp[0]*(i+1);
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[1] = _bucket->minPt[1] + tmp[1]*(j+1);
-        _bucket->next[i+j*tmp1+k*tmp1*tmp1].maxPt[2] = _bucket->minPt[2] + tmp[2]*(k+1);
+  for(k = 0; k < tmp1; k++) {
+    for(j = 0; j < tmp1; j++) {
+      for(i = 0; i < tmp1; i++) {
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].minPt[0] =
+          _bucket->minPt[0] + tmp[0] * i;
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].minPt[1] =
+          _bucket->minPt[1] + tmp[1] * j;
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].minPt[2] =
+          _bucket->minPt[2] + tmp[2] * k;
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].maxPt[0] =
+          _bucket->minPt[0] + tmp[0] * (i + 1);
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].maxPt[1] =
+          _bucket->minPt[1] + tmp[1] * (j + 1);
+        _bucket->next[i + j * tmp1 + k * tmp1 * tmp1].maxPt[2] =
+          _bucket->minPt[2] + tmp[2] * (k + 1);
       }
     }
   }
@@ -279,24 +287,24 @@ int subdivideOctantBucket(octantBucket *_bucket, globalInfo *_globalPara)
   return 1;
 }
 
-void *searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara,
-                    BBFunction BBElement, InEleFunction xyzInElement)
+void *searchElement(octantBucket *_buckets_head, double *_pt,
+                    globalInfo *_globalPara, BBFunction BBElement,
+                    InEleFunction xyzInElement)
 {
   int flag;
   octantBucket *ptrBucket;
   ELink ptr1;
-  std::vector<void*>::iterator iter;
-  void * ptrToEle = _globalPara->ptrToPrevElement;
+  std::vector<void *>::iterator iter;
+  void *ptrToEle = _globalPara->ptrToPrevElement;
 
-  if (ptrToEle) {
+  if(ptrToEle) {
     flag = xyzInElementBB(_pt, ptrToEle, BBElement);
-    if (flag == 1)
-      flag = xyzInElement(ptrToEle, _pt);
-    if (flag == 1) return ptrToEle;
+    if(flag == 1) flag = xyzInElement(ptrToEle, _pt);
+    if(flag == 1) return ptrToEle;
   }
 
   ptrBucket = findElementBucket(_buckets_head, _pt);
-  if (ptrBucket == NULL) {
+  if(ptrBucket == NULL) {
     // this is not an error
     Msg::Debug("The point is not in the domain");
     return NULL;
@@ -313,33 +321,32 @@ void *searchElement(octantBucket *_buckets_head, double *_pt, globalInfo *_globa
   }
 #endif
 
-  while (ptr1 != NULL){
+  while(ptr1 != NULL) {
     flag = xyzInElementBB(_pt, ptr1->region, BBElement);
-    if (flag == 1)
-      flag = xyzInElement(ptr1->region, _pt);
-    if (flag == 1) {
+    if(flag == 1) flag = xyzInElement(ptr1->region, _pt);
+    if(flag == 1) {
       _globalPara->ptrToPrevElement = ptr1->region;
       return ptr1->region;
     }
     ptr1 = ptr1->next;
   }
 
-  for (iter = (ptrBucket->listBB).begin();
-       iter != (ptrBucket->listBB).end(); iter++){
+  for(iter = (ptrBucket->listBB).begin(); iter != (ptrBucket->listBB).end();
+      iter++) {
     flag = xyzInElementBB(_pt, *iter, BBElement);
-    if (flag == 1)
-      flag = xyzInElement(*iter, _pt);
-    if (flag == 1) {
+    if(flag == 1) flag = xyzInElement(*iter, _pt);
+    if(flag == 1) {
       _globalPara->ptrToPrevElement = *iter;
       return *iter;
     }
   }
 
-  // printf("This point is not found in all elements! It is not in the domain \n");
+  // printf("This point is not found in all elements! It is not in the domain
+  // \n");
   return NULL;
 }
 
-int xyzInElementBB(double *_xyz, void * _region, BBFunction _BBElement)
+int xyzInElementBB(double *_xyz, void *_region, BBFunction _BBElement)
 // Check if xyz is in the region's bounding box, return 1 if true, 0 otherwise
 // BBElement is the function given by user to find the bounding box
 {
@@ -349,25 +356,25 @@ int xyzInElementBB(double *_xyz, void * _region, BBFunction _BBElement)
 
   (*_BBElement)(_region, minPt, maxPt);
 
-  for (i = 0; i < 3; i++) {
-    if (_xyz[i] > maxPt[i] || _xyz[i] < minPt[i]) return 0;
+  for(i = 0; i < 3; i++) {
+    if(_xyz[i] > maxPt[i] || _xyz[i] < minPt[i]) return 0;
   } // for ith direction
 
   return 1;
 }
 
-void insertOneBB(void* _region, double *_minPt, double *_maxPt, octantBucket *_bucket)
+void insertOneBB(void *_region, double *_minPt, double *_maxPt,
+                 octantBucket *_bucket)
 {
   int i;
   ELink ptr;
-  for (i = 0; i < 3; i++) {
-    if (_bucket->minPt[i] > _maxPt[i] || _bucket->maxPt[i] < _minPt[i])
-      return;
+  for(i = 0; i < 3; i++) {
+    if(_bucket->minPt[i] > _maxPt[i] || _bucket->maxPt[i] < _minPt[i]) return;
   }
-  if (_bucket->next == NULL) {
+  if(_bucket->next == NULL) {
     ptr = _bucket->lhead;
-    while (ptr != NULL) {
-      if (ptr->region == _region) return;
+    while(ptr != NULL) {
+      if(ptr->region == _region) return;
       ptr = ptr->next;
     }
 
@@ -376,21 +383,22 @@ void insertOneBB(void* _region, double *_minPt, double *_maxPt, octantBucket *_b
     return;
   }
 
-  for (i = 0; i < 8; i++)
-    insertOneBB(_region, _minPt, _maxPt, _bucket->next+i);
+  for(i = 0; i < 8; i++)
+    insertOneBB(_region, _minPt, _maxPt, _bucket->next + i);
   return;
 }
 
-void *searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_globalPara,
-                        BBFunction BBElement, InEleFunction xyzInElement,
-                        std::vector<void*> *_elements)
+void *searchAllElements(octantBucket *_buckets_head, double *_pt,
+                        globalInfo *_globalPara, BBFunction BBElement,
+                        InEleFunction xyzInElement,
+                        std::vector<void *> *_elements)
 {
   int flag, flag1;
   octantBucket *ptrBucket;
-  std::vector<void*>::iterator iter;
+  std::vector<void *>::iterator iter;
 
   ptrBucket = findElementBucket(_buckets_head, _pt);
-  if (ptrBucket == NULL) {
+  if(ptrBucket == NULL) {
     Msg::Debug("The point is not in the domain");
     return NULL;
   }
@@ -407,31 +415,29 @@ void *searchAllElements(octantBucket *_buckets_head, double *_pt, globalInfo *_g
 
   flag1 = 0;
   ELink ptr1 = ptrBucket->lhead;
-  while (ptr1 != NULL){
+  while(ptr1 != NULL) {
     flag = xyzInElementBB(_pt, ptr1->region, BBElement);
-    if (flag == 1)
-      flag = xyzInElement(ptr1->region, _pt);
-    if (flag == 1) {
+    if(flag == 1) flag = xyzInElement(ptr1->region, _pt);
+    if(flag == 1) {
       _elements->push_back(ptr1->region);
       flag1 = 1;
     }
     ptr1 = ptr1->next;
   }
 
-  for (iter = (ptrBucket->listBB).begin();
-       iter != (ptrBucket->listBB).end(); iter++){
+  for(iter = (ptrBucket->listBB).begin(); iter != (ptrBucket->listBB).end();
+      iter++) {
     flag = xyzInElementBB(_pt, *iter, BBElement);
-    if (flag == 1)
-      flag = xyzInElement(*iter, _pt);
-    if (flag == 1) {
+    if(flag == 1) flag = xyzInElement(*iter, _pt);
+    if(flag == 1) {
       _elements->push_back(*iter);
       flag1 = 1;
     }
   }
 
-  if (flag1)
-    return (void *)(_elements);
+  if(flag1) return (void *)(_elements);
 
-  // Msg::Warning("This point is not found in any element! It is not in the domain");
+  // Msg::Warning("This point is not found in any element! It is not in the
+  // domain");
   return NULL;
 }
diff --git a/Common/OctreeInternals.h b/Common/OctreeInternals.h
index 51dbb1439d5b3db62c0cf8290eee6f87441dfd99..d25f11ea1cb2a8bfbf53fb480e65fd00ebcf9b4f 100644
--- a/Common/OctreeInternals.h
+++ b/Common/OctreeInternals.h
@@ -8,74 +8,72 @@
 
 #include <vector>
 
-// file of function prototypes and macro constants 
-typedef void (*BBFunction)(void *, double*, double*);
-typedef int (*InEleFunction)(void *, double *); 
+// file of function prototypes and macro constants
+typedef void (*BBFunction)(void *, double *, double *);
+typedef int (*InEleFunction)(void *, double *);
 typedef void (*CentroidFunction)(void *, double *);
 
-// structure for list of elements in an octant 
+// structure for list of elements in an octant
 typedef struct elem {
-  void * region;  // the pointer to a mesh Db region 
-  double centroid[3]; // centroid of element bounding box inside of the octant 
-  double minPt[3]; // corner of element bounding box nearest the origin 
-  double maxPt[3]; // corner of elem bound box furthest from the origin  
-  struct elem *next; // link to next item in list, NULL if end 
+  void *region; // the pointer to a mesh Db region
+  double centroid[3]; // centroid of element bounding box inside of the octant
+  double minPt[3]; // corner of element bounding box nearest the origin
+  double maxPt[3]; // corner of elem bound box furthest from the origin
+  struct elem *next; // link to next item in list, NULL if end
 } Elem;
 typedef Elem *ELink;
 
-// stucture for octant buckets 
+// stucture for octant buckets
 struct bucket {
-  double minPt[3];   //  the point with the smallest coordinates 
-  double maxPt[3];   //  the point with the biggest coordinates 
-  int numElements; // number of elements contained by bucket 
-  int precision;   // the level of precision of the bucket 
-  ELink lhead; // list of elements in bucket, if NULL -> no elements 
-  std::vector<void *> listBB; // list of elements in bucket by Bounding Box       
-  struct bucket *next; // link to ragged digit extensions to bucket array 
-  struct bucket *parent; // link to the parent bucket 
+  double minPt[3]; //  the point with the smallest coordinates
+  double maxPt[3]; //  the point with the biggest coordinates
+  int numElements; // number of elements contained by bucket
+  int precision; // the level of precision of the bucket
+  ELink lhead; // list of elements in bucket, if NULL -> no elements
+  std::vector<void *> listBB; // list of elements in bucket by Bounding Box
+  struct bucket *next; // link to ragged digit extensions to bucket array
+  struct bucket *parent; // link to the parent bucket
 };
-typedef struct bucket octantBucket; 
+typedef struct bucket octantBucket;
 
-// structure for global information and requirment 
+// structure for global information and requirment
 struct global {
-  int numBuckets; // number of octant buckets in initial grid array 
-  int maxElements; // max. number of elements allowed in an octant 
-  int maxPrecision; // current maximum octant precision for model 
-  double origin[3];   // smallest x,y, z of model's bounding box  
-  double size[3];    // size in x, y, z of model bounding box 
-  void * ptrToPrevElement;      
+  int numBuckets; // number of octant buckets in initial grid array
+  int maxElements; // max. number of elements allowed in an octant
+  int maxPrecision; // current maximum octant precision for model
+  double origin[3]; // smallest x,y, z of model's bounding box
+  double size[3]; // size in x, y, z of model bounding box
+  void *ptrToPrevElement;
   std::vector<void *> listAllElements;
 };
 typedef struct global globalInfo;
 
-class Octree
-{
- public:
+class Octree {
+public:
   globalInfo *info;
   octantBucket *root;
   BBFunction function_BB;
-  InEleFunction function_inElement; 
-  CentroidFunction function_centroid; 
+  InEleFunction function_inElement;
+  CentroidFunction function_centroid;
 };
 
-void refineOctants(octantBucket *buckets,
-                   globalInfo *globalPara);
+void refineOctants(octantBucket *buckets, globalInfo *globalPara);
 
-int addElement2Bucket(octantBucket *bucket, void * element, 
-                      double *minBB, double *maxBB,
-                      double *ele_centroid, globalInfo *globalPara);
+int addElement2Bucket(octantBucket *bucket, void *element, double *minBB,
+                      double *maxBB, double *ele_centroid,
+                      globalInfo *globalPara);
 int subdivideOctantBucket(octantBucket *bucket, globalInfo *globalPara);
 int initializeOctantBuckets(double *orig, double *size, int maxElem,
                             octantBucket **buckets, globalInfo **globalPara);
-int checkElementInBucket(octantBucket *bucket, void * element); 
+int checkElementInBucket(octantBucket *bucket, void *element);
 octantBucket *findElementBucket(octantBucket *buckets, double *pt);
-void *searchElement(octantBucket *buckets, double *pt, 
-                    globalInfo *globalPara, BBFunction BBElement, 
-                    InEleFunction xyzInElement);
+void *searchElement(octantBucket *buckets, double *pt, globalInfo *globalPara,
+                    BBFunction BBElement, InEleFunction xyzInElement);
 int xyzInElementBB(double *xyz, void *region, BBFunction BBElement);
 void insertOneBB(void *, double *, double *, octantBucket *);
-void *searchAllElements(octantBucket *_buckets_head, double *_pt, 
-                        globalInfo *_globalPara, BBFunction BBElement, 
-                        InEleFunction xyzInElement, std::vector<void *> *_elements);
+void *searchAllElements(octantBucket *_buckets_head, double *_pt,
+                        globalInfo *_globalPara, BBFunction BBElement,
+                        InEleFunction xyzInElement,
+                        std::vector<void *> *_elements);
 
 #endif
diff --git a/Common/OpenFile.cpp b/Common/OpenFile.cpp
index 82a9ffe87683408d5f9a6435644f741f696a2e11..0d271b66b8b26d800b8afba51e7017c7ca2cf949 100644
--- a/Common/OpenFile.cpp
+++ b/Common/OpenFile.cpp
@@ -59,7 +59,7 @@ typedef unsigned long intptr_t;
 #include "3M.h"
 #endif
 
-#define SQU(a)      ((a)*(a))
+#define SQU(a) ((a) * (a))
 
 static void FinishUpBoundingBox()
 {
@@ -70,45 +70,57 @@ static void FinishUpBoundingBox()
   if(range[0] < CTX::instance()->geom.tolerance &&
      range[1] < CTX::instance()->geom.tolerance &&
      range[2] < CTX::instance()->geom.tolerance) {
-    CTX::instance()->min[0] -= 1.; CTX::instance()->min[1] -= 1.;
-    CTX::instance()->max[0] += 1.; CTX::instance()->max[1] += 1.;
+    CTX::instance()->min[0] -= 1.;
+    CTX::instance()->min[1] -= 1.;
+    CTX::instance()->max[0] += 1.;
+    CTX::instance()->max[1] += 1.;
   }
   else if(range[0] < CTX::instance()->geom.tolerance &&
           range[1] < CTX::instance()->geom.tolerance) {
-    CTX::instance()->min[0] -= range[2]; CTX::instance()->min[1] -= range[2];
-    CTX::instance()->max[0] += range[2]; CTX::instance()->max[1] += range[2];
+    CTX::instance()->min[0] -= range[2];
+    CTX::instance()->min[1] -= range[2];
+    CTX::instance()->max[0] += range[2];
+    CTX::instance()->max[1] += range[2];
   }
   else if(range[0] < CTX::instance()->geom.tolerance &&
           range[2] < CTX::instance()->geom.tolerance) {
-    CTX::instance()->min[0] -= range[1]; CTX::instance()->max[0] += range[1];
+    CTX::instance()->min[0] -= range[1];
+    CTX::instance()->max[0] += range[1];
   }
   else if(range[1] < CTX::instance()->geom.tolerance &&
           range[2] < CTX::instance()->geom.tolerance) {
-    CTX::instance()->min[1] -= range[0]; CTX::instance()->max[1] += range[0];
+    CTX::instance()->min[1] -= range[0];
+    CTX::instance()->max[1] += range[0];
   }
   else if(range[0] < CTX::instance()->geom.tolerance) {
     double l = sqrt(SQU(range[1]) + SQU(range[2]));
-    CTX::instance()->min[0] -= l; CTX::instance()->max[0] += l;
+    CTX::instance()->min[0] -= l;
+    CTX::instance()->max[0] += l;
   }
   else if(range[1] < CTX::instance()->geom.tolerance) {
     double l = sqrt(SQU(range[0]) + SQU(range[2]));
-    CTX::instance()->min[1] -= l; CTX::instance()->max[1] += l;
+    CTX::instance()->min[1] -= l;
+    CTX::instance()->max[1] += l;
   }
 
-  CTX::instance()->lc = sqrt(SQU(CTX::instance()->max[0] - CTX::instance()->min[0]) +
-                             SQU(CTX::instance()->max[1] - CTX::instance()->min[1]) +
-                             SQU(CTX::instance()->max[2] - CTX::instance()->min[2]));
+  CTX::instance()->lc =
+    sqrt(SQU(CTX::instance()->max[0] - CTX::instance()->min[0]) +
+         SQU(CTX::instance()->max[1] - CTX::instance()->min[1]) +
+         SQU(CTX::instance()->max[2] - CTX::instance()->min[2]));
   for(int i = 0; i < 3; i++)
-    CTX::instance()->cg[i] = 0.5 * (CTX::instance()->min[i] + CTX::instance()->max[i]);
+    CTX::instance()->cg[i] =
+      0.5 * (CTX::instance()->min[i] + CTX::instance()->max[i]);
 }
 
-void SetBoundingBox(double xmin, double xmax,
-                    double ymin, double ymax,
+void SetBoundingBox(double xmin, double xmax, double ymin, double ymax,
                     double zmin, double zmax)
 {
-  CTX::instance()->min[0] = xmin; CTX::instance()->max[0] = xmax;
-  CTX::instance()->min[1] = ymin; CTX::instance()->max[1] = ymax;
-  CTX::instance()->min[2] = zmin; CTX::instance()->max[2] = zmax;
+  CTX::instance()->min[0] = xmin;
+  CTX::instance()->max[0] = xmax;
+  CTX::instance()->min[1] = ymin;
+  CTX::instance()->max[1] = ymax;
+  CTX::instance()->min[2] = zmin;
+  CTX::instance()->max[2] = zmax;
   FinishUpBoundingBox();
 }
 
@@ -126,14 +138,17 @@ void SetBoundingBox(bool aroundVisible)
           bb += PView::list[i]->getData()->getBoundingBox();
   }
 #endif
-  if(bb.empty()){
+  if(bb.empty()) {
     bb += SPoint3(-1., -1., -1.);
     bb += SPoint3(1., 1., 1.);
   }
 
-  CTX::instance()->min[0] = bb.min().x(); CTX::instance()->max[0] = bb.max().x();
-  CTX::instance()->min[1] = bb.min().y(); CTX::instance()->max[1] = bb.max().y();
-  CTX::instance()->min[2] = bb.min().z(); CTX::instance()->max[2] = bb.max().z();
+  CTX::instance()->min[0] = bb.min().x();
+  CTX::instance()->max[0] = bb.max().x();
+  CTX::instance()->min[1] = bb.min().y();
+  CTX::instance()->max[1] = bb.max().y();
+  CTX::instance()->min[2] = bb.min().z();
+  CTX::instance()->max[2] = bb.max().z();
   FinishUpBoundingBox();
 }
 
@@ -143,10 +158,7 @@ void SetBoundingBox(bool aroundVisible)
 // removed once the new database is filled directly during the parsing step
 static SBoundingBox3d temp_bb;
 
-void ResetTemporaryBoundingBox()
-{
-  temp_bb.reset();
-}
+void ResetTemporaryBoundingBox() { temp_bb.reset(); }
 
 void AddToTemporaryBoundingBox(double x, double y, double z)
 {
@@ -172,7 +184,7 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing)
   // add 'b' for pure Windows programs: opening in text mode messes up
   // fsetpos/fgetpos (used e.g. for user-defined functions)
   FILE *fp;
-  if(!(fp = Fopen(fileName.c_str(), "rb"))){
+  if(!(fp = Fopen(fileName.c_str(), "rb"))) {
     if(warnIfMissing)
       Msg::Warning("Unable to open file '%s'", fileName.c_str());
     return 0;
@@ -197,9 +209,9 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing)
   gmsh_yylineno = 1;
   gmsh_yyviewindex = 0;
 
-  while(!feof(gmsh_yyin)){
+  while(!feof(gmsh_yyin)) {
     gmsh_yyparse();
-    if(gmsh_yyerrorstate > 20){
+    if(gmsh_yyerrorstate > 20) {
       if(gmsh_yyerrorstate != 999) // 999 is a volontary exit
         Msg::Error("Too many errors: aborting parser...");
       gmsh_yyflush();
@@ -207,11 +219,11 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing)
     }
   }
 
-  if(close){
+  if(close) {
     gmsh_yyflush();
     fclose(gmsh_yyin);
   }
-  else{
+  else {
     openedFiles.push_back(gmsh_yyin);
   }
 
@@ -222,9 +234,10 @@ int ParseFile(const std::string &fileName, bool close, bool warnIfMissing)
   gmsh_yyviewindex = old_yyviewindex;
 
 #if defined(HAVE_FLTK) && defined(HAVE_POST)
-  if(FlGui::available()){
+  if(FlGui::available()) {
     // this is not enough if the script creates and deletes views
-    //FlGui::instance()->updateViews(numViewsBefore != (int)PView::list.size(), false);
+    // FlGui::instance()->updateViews(numViewsBefore != (int)PView::list.size(),
+    // false);
     FlGui::instance()->updateViews(true, false);
   }
 #endif
@@ -237,12 +250,13 @@ static bool doSystemUncompress(const std::string &fileName,
                                const std::string &noExt)
 {
   std::ostringstream sstream;
-  sstream << "File '"<< fileName << "' is in gzip format.\n\n"
+  sstream << "File '" << fileName << "' is in gzip format.\n\n"
           << "Do you want to uncompress it?";
-  if(Msg::GetAnswer(sstream.str().c_str(), 0, "Cancel", "Uncompress")){
+  if(Msg::GetAnswer(sstream.str().c_str(), 0, "Cancel", "Uncompress")) {
     if(SystemCall(std::string("gunzip -c ") + fileName + " > " + noExt, true))
-      Msg::Warning("Potentially failed to uncompress `%s': check directory permissions",
-                   fileName.c_str());
+      Msg::Warning(
+        "Potentially failed to uncompress `%s': check directory permissions",
+        fileName.c_str());
     GModel::current()->setFileName(noExt);
     return true;
   }
@@ -259,7 +273,7 @@ void ParseString(const std::string &str, bool inCurrentModelDir)
   else
     fileName = CTX::instance()->homeDir + CTX::instance()->tmpFileName;
   FILE *fp = Fopen(fileName.c_str(), "w");
-  if(fp){
+  if(fp) {
     fprintf(fp, "%s\n", str.c_str());
     fclose(fp);
     GModel::readGEO(fileName);
@@ -270,39 +284,41 @@ void ParseString(const std::string &str, bool inCurrentModelDir)
 #if defined(HAVE_ONELAB)
 static std::string getSolverForExtension(const std::string &ext)
 {
-  for(int i = 0; i < NUM_SOLVERS; i++){
+  for(int i = 0; i < NUM_SOLVERS; i++) {
     if(opt_solver_extension(i, GMSH_GET, "") == ext)
       return opt_solver_name(i, GMSH_GET, "");
   }
   return "";
 }
 
-
 static int defineSolver(const std::string &name)
 {
   int i;
-  for(i = 0; i < NUM_SOLVERS; i++){
+  for(i = 0; i < NUM_SOLVERS; i++) {
     if(opt_solver_name(i, GMSH_GET, "") == name) return i;
   }
-  opt_solver_name(i - 1, GMSH_SET|GMSH_GUI, name);
+  opt_solver_name(i - 1, GMSH_SET | GMSH_GUI, name);
   return i - 1;
 }
 #endif
 
-int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingBox,
-              bool importPhysicalsInOnelab)
+int MergeFile(const std::string &fileName, bool warnIfMissing,
+              bool setBoundingBox, bool importPhysicalsInOnelab)
 {
   // added 'b' for pure Windows programs, since some of these files
   // contain binary data
   FILE *fp = Fopen(fileName.c_str(), "rb");
-  if(!fp){
+  if(!fp) {
     if(warnIfMissing)
       Msg::Warning("Unable to open file '%s'", fileName.c_str());
     return 0;
   }
 
   char header[256];
-  if(!fgets(header, sizeof(header), fp)){ fclose(fp); return 0; }
+  if(!fgets(header, sizeof(header), fp)) {
+    fclose(fp);
+    return 0;
+  }
   fclose(fp);
 
   Msg::StatusBar(true, "Reading '%s'...", fileName.c_str());
@@ -317,14 +333,11 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
 #if defined(HAVE_COMPRESSED_IO) && defined(HAVE_LIBZ)
     std::vector<std::string> subsplit = SplitFileName(noExt);
     ext = subsplit[2];
-    if(ext != ".geo" && ext != ".GEO" &&
-       ext != ".unv" && ext != ".UNV"){
-      if(doSystemUncompress(fileName, noExt))
-        return MergeFile(noExt, false);
+    if(ext != ".geo" && ext != ".GEO" && ext != ".unv" && ext != ".UNV") {
+      if(doSystemUncompress(fileName, noExt)) return MergeFile(noExt, false);
     }
 #else
-    if(doSystemUncompress(fileName, noExt))
-      return MergeFile(noExt, false);
+    if(doSystemUncompress(fileName, noExt)) return MergeFile(noExt, false);
 #endif
   }
 
@@ -342,12 +355,12 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
 
 #if defined(HAVE_ONELAB)
   std::string solver = getSolverForExtension(ext);
-  if(solver.size()){
+  if(solver.size()) {
     int num = defineSolver(solver);
-    Msg::SetOnelabString(solver + "/Model name", fileName, true, true,
-                         false, 3, "file");
+    Msg::SetOnelabString(solver + "/Model name", fileName, true, true, false, 3,
+                         "file");
     if(GModel::current()->getName() == "" ||
-       Msg::GetOnelabString("Gmsh/Model name").empty()){
+       Msg::GetOnelabString("Gmsh/Model name").empty()) {
       GModel::current()->setFileName(split[0] + split[1] + ".geo");
       GModel::current()->setName(split[1] + ".geo");
       Msg::SetOnelabChanged(3);
@@ -356,9 +369,8 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
     CTX::instance()->geom.draw = 1;
     return 1;
   }
-  else if(ext == ".py" || ext == ".PY" ||
-          ext == ".m" || ext == ".M" ||
-          ext == ".exe" || ext == ".EXE"){
+  else if(ext == ".py" || ext == ".PY" || ext == ".m" || ext == ".M" ||
+          ext == ".exe" || ext == ".EXE") {
     int num = defineSolver(split[1]);
     opt_solver_executable(num, GMSH_SET, fileName);
     CTX::instance()->launchSolverAtStartup = num;
@@ -367,63 +379,63 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
   }
 #endif
 
-  if(GModel::current()->getName() == ""){
+  if(GModel::current()->getName() == "") {
     GModel::current()->setFileName(fileName);
     GModel::current()->setName(SplitFileName(fileName)[1]);
   }
 
-  if(ext == ".stl" || ext == ".STL"){
-    status = GModel::current()->readSTL(fileName, CTX::instance()->geom.tolerance);
+  if(ext == ".stl" || ext == ".STL") {
+    status =
+      GModel::current()->readSTL(fileName, CTX::instance()->geom.tolerance);
   }
-  else if(ext == ".brep" || ext == ".rle" || ext == ".brp" || ext == ".BRP"){
+  else if(ext == ".brep" || ext == ".rle" || ext == ".brp" || ext == ".BRP") {
     status = GModel::current()->readOCCBREP(fileName);
   }
-  else if(ext == ".iges" || ext == ".IGES" || ext == ".igs" || ext == ".IGS"){
+  else if(ext == ".iges" || ext == ".IGES" || ext == ".igs" || ext == ".IGS") {
     status = GModel::current()->readOCCIGES(fileName);
   }
-  else if(ext == ".step" || ext == ".STEP" || ext == ".stp" || ext == ".STP"){
+  else if(ext == ".step" || ext == ".STEP" || ext == ".stp" || ext == ".STP") {
     status = GModel::current()->readOCCSTEP(fileName);
   }
-  else if(ext == ".sat" || ext == ".SAT"){
+  else if(ext == ".sat" || ext == ".SAT") {
     status = GModel::current()->readACISSAT(fileName);
   }
-  else if(ext == ".unv" || ext == ".UNV"){
+  else if(ext == ".unv" || ext == ".UNV") {
     status = GModel::current()->readUNV(fileName);
   }
-  else if(ext == ".vtk" || ext == ".VTK"){
+  else if(ext == ".vtk" || ext == ".VTK") {
     status = GModel::current()->readVTK(fileName, CTX::instance()->bigEndian);
   }
   else if(ext == ".wrl" || ext == ".WRL" || ext == ".vrml" || ext == ".VRML" ||
-          ext == ".iv" || ext == ".IV"){
+          ext == ".iv" || ext == ".IV") {
     status = GModel::current()->readVRML(fileName);
   }
-  else if(ext == ".mesh" || ext == ".MESH"){
+  else if(ext == ".mesh" || ext == ".MESH") {
     status = GModel::current()->readMESH(fileName);
   }
-  else if(ext == ".diff" || ext == ".DIFF"){
+  else if(ext == ".diff" || ext == ".DIFF") {
     status = GModel::current()->readDIFF(fileName);
   }
   else if(ext == ".med" || ext == ".MED" || ext == ".mmed" || ext == ".MMED" ||
-          ext == ".rmed" || ext == ".RMED"){
+          ext == ".rmed" || ext == ".RMED") {
     status = GModel::readMED(fileName);
 #if defined(HAVE_POST)
     if(status > 1) status = PView::readMED(fileName);
 #endif
   }
-  else if(ext == ".bdf" || ext == ".BDF" || ext == ".nas" || ext == ".NAS"){
+  else if(ext == ".bdf" || ext == ".BDF" || ext == ".nas" || ext == ".NAS") {
     status = GModel::current()->readBDF(fileName);
   }
-  else if(ext == ".dat" || ext == ".DAT"){
+  else if(ext == ".dat" || ext == ".DAT") {
     if(!strncmp(header, "BEGIN ACTRAN", 12))
       status = GModel::current()->readACTRAN(fileName);
-    else if(!strncmp(header, "!", 1) ||
-            !strncmp(header, ";ECHO", 5) ||
+    else if(!strncmp(header, "!", 1) || !strncmp(header, ";ECHO", 5) ||
             !strncmp(header, ".NOE", 4))
       status = GModel::current()->readSAMCEF(fileName);
     else
       status = GModel::current()->readBDF(fileName);
   }
-  else if(ext == ".p3d" || ext == ".P3D"){
+  else if(ext == ".p3d" || ext == ".P3D") {
     status = GModel::current()->readP3D(fileName);
   }
   else if(ext == ".fm" || ext == ".FM") {
@@ -448,20 +460,20 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
   }
 #endif
 #endif
-  else if(ext == ".ply2" || ext == ".PLY2"){
+  else if(ext == ".ply2" || ext == ".PLY2") {
     status = GModel::current()->readPLY2(fileName);
   }
-  else if(ext == ".ply" || ext == ".PLY"){
+  else if(ext == ".ply" || ext == ".PLY") {
     status = GModel::current()->readPLY(fileName);
   }
-  else if(ext == ".geom" || ext == ".GEOM"){
+  else if(ext == ".geom" || ext == ".GEOM") {
     status = GModel::current()->readGEOM(fileName);
   }
 #if defined(HAVE_LIBCGNS)
-  else if(ext == ".cgns" || ext == ".CGNS"){
+  else if(ext == ".cgns" || ext == ".CGNS") {
     if(CTX::instance()->geom.matchGeomAndMesh && !GModel::current()->empty()) {
-      GModel* tmp2 = GModel::current();
-      GModel* tmp = new GModel();
+      GModel *tmp2 = GModel::current();
+      GModel *tmp = new GModel();
       tmp->readCGNS(fileName);
       tmp->scaleMesh(CTX::instance()->geom.matchMeshScaleFactor);
       status = GeomMeshMatcher::instance()->match(tmp2, tmp);
@@ -476,7 +488,7 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
   }
 #endif
 #if defined(HAVE_3M)
-  else if(ext == ".csv"){
+  else if(ext == ".csv") {
     status = readFile3M(fileName);
   }
 #endif
@@ -484,11 +496,13 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
     CTX::instance()->geom.draw = 1;
     if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) ||
        !strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) ||
-       !strncmp(header, "$MeshFormat", 11) || !strncmp(header, "$Comments", 9)) {
+       !strncmp(header, "$MeshFormat", 11) ||
+       !strncmp(header, "$Comments", 9)) {
       // mesh matcher
-      if(CTX::instance()->geom.matchGeomAndMesh && !GModel::current()->empty()) {
-        GModel* tmp2 = GModel::current();
-        GModel* tmp = new GModel();
+      if(CTX::instance()->geom.matchGeomAndMesh &&
+         !GModel::current()->empty()) {
+        GModel *tmp2 = GModel::current();
+        GModel *tmp = new GModel();
         tmp->readMSH(fileName);
         tmp->scaleMesh(CTX::instance()->geom.matchMeshScaleFactor);
         status = GeomMeshMatcher::instance()->match(tmp2, tmp);
@@ -504,17 +518,17 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
       if(status > 1) status = PView::readMSH(fileName);
 #endif
 #if defined(HAVE_MESH)
-      /*
-      This was introduced in r6039 by Koen to snap high order vertices on the
-      geometry. But it introduces subtle bugs when reading high-order
-      post-processing views ; we should have an explicit command to do this, and
-      not modify the mesh without warning just by reading a file --CG.
-
-      if(CTX::instance()->mesh.order > 1)
-        SetOrderN(GModel::current(), CTX::instance()->mesh.order,
-                  CTX::instance()->mesh.secondOrderLinear,
-                  CTX::instance()->mesh.secondOrderIncomplete);
-      */
+        /*
+        This was introduced in r6039 by Koen to snap high order vertices on the
+        geometry. But it introduces subtle bugs when reading high-order
+        post-processing views ; we should have an explicit command to do this,
+        and not modify the mesh without warning just by reading a file --CG.
+
+        if(CTX::instance()->mesh.order > 1)
+          SetOrderN(GModel::current(), CTX::instance()->mesh.order,
+                    CTX::instance()->mesh.secondOrderLinear,
+                    CTX::instance()->mesh.secondOrderIncomplete);
+        */
 #endif
     }
 #if defined(HAVE_POST)
@@ -528,18 +542,18 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
     }
   }
 
-  GModel::current()->getGEOInternals()->setMaxTag
-    (0, std::max(GModel::current()->getGEOInternals()->getMaxTag(0),
-                 GModel::current()->getMaxElementaryNumber(0)));
-  GModel::current()->getGEOInternals()->setMaxTag
-    (1, std::max(GModel::current()->getGEOInternals()->getMaxTag(1),
-                 GModel::current()->getMaxElementaryNumber(1)));
-  GModel::current()->getGEOInternals()->setMaxTag
-    (2, std::max(GModel::current()->getGEOInternals()->getMaxTag(2),
-                 GModel::current()->getMaxElementaryNumber(2)));
-  GModel::current()->getGEOInternals()->setMaxTag
-    (3, std::max(GModel::current()->getGEOInternals()->getMaxTag(3),
-                 GModel::current()->getMaxElementaryNumber(3)));
+  GModel::current()->getGEOInternals()->setMaxTag(
+    0, std::max(GModel::current()->getGEOInternals()->getMaxTag(0),
+                GModel::current()->getMaxElementaryNumber(0)));
+  GModel::current()->getGEOInternals()->setMaxTag(
+    1, std::max(GModel::current()->getGEOInternals()->getMaxTag(1),
+                GModel::current()->getMaxElementaryNumber(1)));
+  GModel::current()->getGEOInternals()->setMaxTag(
+    2, std::max(GModel::current()->getGEOInternals()->getMaxTag(2),
+                GModel::current()->getMaxElementaryNumber(2)));
+  GModel::current()->getGEOInternals()->setMaxTag(
+    3, std::max(GModel::current()->getGEOInternals()->getMaxTag(3),
+                GModel::current()->getMaxElementaryNumber(3)));
 
   if(setBoundingBox) SetBoundingBox();
   CTX::instance()->geom.draw = 1;
@@ -548,13 +562,14 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
   if(importPhysicalsInOnelab) Msg::ImportPhysicalGroupsInOnelab();
 
 #if defined(HAVE_FLTK) && defined(HAVE_POST)
-  if(FlGui::available()){
+  if(FlGui::available()) {
     // go directly to the first non-empty step after the one that is requested
     for(unsigned int i = numViewsBefore; i < PView::list.size(); i++)
       opt_view_timestep(i, GMSH_SET | GMSH_GUI,
-                        PView::list[i]->getData()->getFirstNonEmptyTimeStep
-                        (opt_view_timestep(i, GMSH_GET, 0)));
-    FlGui::instance()->updateViews(numViewsBefore != (int)PView::list.size(), false);
+                        PView::list[i]->getData()->getFirstNonEmptyTimeStep(
+                          opt_view_timestep(i, GMSH_GET, 0)));
+    FlGui::instance()->updateViews(numViewsBefore != (int)PView::list.size(),
+                                   false);
   }
 #endif
 
@@ -564,8 +579,7 @@ int MergeFile(const std::string &fileName, bool warnIfMissing, bool setBoundingB
   CTX::instance()->fileread = true;
 
   // merge the associated option file if there is one
-  if(!StatFile(fileName + ".opt"))
-    MergeFile(fileName + ".opt");
+  if(!StatFile(fileName + ".opt")) MergeFile(fileName + ".opt");
   return status;
 }
 
@@ -575,22 +589,26 @@ int MergePostProcessingFile(const std::string &fileName, int showViews,
 #if defined(HAVE_POST)
   // check if there is a mesh in the file
   FILE *fp = Fopen(fileName.c_str(), "rb");
-  if(!fp){
-    if(warnIfMissing) Msg::Warning("Unable to open file '%s'", fileName.c_str());
+  if(!fp) {
+    if(warnIfMissing)
+      Msg::Warning("Unable to open file '%s'", fileName.c_str());
     return 0;
   }
   char header[256];
-  if(!fgets(header, sizeof(header), fp)){ fclose(fp); return 0; }
+  if(!fgets(header, sizeof(header), fp)) {
+    fclose(fp);
+    return 0;
+  }
   bool haveMesh = false;
-  if(!strncmp(header, "$MeshFormat", 11)){
-    while(!feof(fp) && fgets(header, sizeof(header), fp)){
-      if(!strncmp(header, "$Nodes", 6)){
+  if(!strncmp(header, "$MeshFormat", 11)) {
+    while(!feof(fp) && fgets(header, sizeof(header), fp)) {
+      if(!strncmp(header, "$Nodes", 6)) {
         haveMesh = true;
         break;
       }
       else if(!strncmp(header, "$NodeData", 9) ||
               !strncmp(header, "$ElementData", 12) ||
-              !strncmp(header, "$ElementNodeData", 16)){
+              !strncmp(header, "$ElementNodeData", 16)) {
         break;
       }
     }
@@ -600,7 +618,7 @@ int MergePostProcessingFile(const std::string &fileName, int showViews,
   // store old step values
   unsigned int n = PView::list.size();
   std::vector<int> steps(n, 0);
-  if(showLastStep){
+  if(showLastStep) {
     for(unsigned int i = 0; i < PView::list.size(); i++)
       steps[i] = (int)opt_view_nb_timestep(i, GMSH_GET, 0);
   }
@@ -608,25 +626,26 @@ int MergePostProcessingFile(const std::string &fileName, int showViews,
   // if there is a mesh, create a new model to store it (don't merge elements in
   // the current mesh!)
   GModel *old = GModel::current();
-  if(haveMesh){
+  if(haveMesh) {
     GModel *m = new GModel();
     GModel::setCurrent(m);
   }
-  int ret = MergeFile(fileName, warnIfMissing, old->bounds().empty() ? true : false);
+  int ret =
+    MergeFile(fileName, warnIfMissing, old->bounds().empty() ? true : false);
   GModel::setCurrent(old);
   old->setVisibility(1);
 
   // hide everything except the onelab X-Y graphs
-  if(showViews == 0){
-    for(unsigned int i = 0; i < PView::list.size(); i++){
+  if(showViews == 0) {
+    for(unsigned int i = 0; i < PView::list.size(); i++) {
       if(PView::list[i]->getData()->getFileName().substr(0, 6) != "ONELAB")
         PView::list[i]->getOptions()->visible = 0;
     }
   }
-  else if(showViews == 2 && n < PView::list.size()){
+  else if(showViews == 2 && n < PView::list.size()) {
     // if we created new views, assume we only want to see those (and the
     // onelab X-Y graphs)
-    for(unsigned int i = 0; i < n; i++){
+    for(unsigned int i = 0; i < n; i++) {
       if(PView::list[i]->getData()->getFileName().substr(0, 6) != "ONELAB")
         PView::list[i]->getOptions()->visible = 0;
     }
@@ -634,12 +653,12 @@ int MergePostProcessingFile(const std::string &fileName, int showViews,
 
   // if we added steps, and we have more than 2 (to avoid always showing the
   // imaginary part for complex fields), go to the last one
-  if(showLastStep){
+  if(showLastStep) {
     steps.resize(PView::list.size(), 0);
-    for(unsigned int i = 0; i < PView::list.size(); i++){
+    for(unsigned int i = 0; i < PView::list.size(); i++) {
       int step = (int)opt_view_nb_timestep(i, GMSH_GET, 0);
       if(step > steps[i] && steps[i] > 1)
-        opt_view_timestep(i, GMSH_SET|GMSH_GUI, step - 1);
+        opt_view_timestep(i, GMSH_SET | GMSH_GUI, step - 1);
     }
   }
 
@@ -653,8 +672,7 @@ void ClearProject()
 {
   Msg::Info("Clearing all models and views...");
 #if defined(HAVE_POST)
-  for(int i = PView::list.size() - 1; i >= 0; i--)
-    delete PView::list[i];
+  for(int i = PView::list.size() - 1; i >= 0; i--) delete PView::list[i];
 #endif
 #if defined(HAVE_PARSER)
   gmsh_yysymbols.clear();
@@ -662,13 +680,11 @@ void ClearProject()
   gmsh_yyfactory.clear();
   gmsh_yynamespaces.clear();
 #endif
-  for(int i = GModel::list.size() - 1; i >= 0; i--)
-    delete GModel::list[i];
+  for(int i = GModel::list.size() - 1; i >= 0; i--) delete GModel::list[i];
 
   // close the files that might have been left open by ParseFile
-  if(openedFiles.size()){
-    for(unsigned int i = 0; i < openedFiles.size(); i++)
-      fclose(openedFiles[i]);
+  if(openedFiles.size()) {
+    for(unsigned int i = 0; i < openedFiles.size(); i++) fclose(openedFiles[i]);
     openedFiles.clear();
   }
   Msg::Info("Done clearing all models and views");
@@ -678,7 +694,7 @@ void ClearProject()
   GModel::current()->setFileName(base + CTX::instance()->defaultFileName);
   GModel::current()->setName("");
 #if defined(HAVE_FLTK)
-  if(FlGui::available()){
+  if(FlGui::available()) {
     FlGui::instance()->resetVisibility();
     FlGui::instance()->updateViews(true, true);
     FlGui::instance()->updateFields();
@@ -698,20 +714,20 @@ void OpenProject(const std::string &fileName)
 
   Msg::ResetErrorCounter();
 
-  if(GModel::current()->empty()){
+  if(GModel::current()->empty()) {
     // if the current model is empty, make sure it's reaaally cleaned-up, and
     // reuse it
     GModel::current()->destroy();
     GModel::current()->getGEOInternals()->destroy();
   }
-  else{
+  else {
     // if the current model is not empty make it invisible and add a new model
     new GModel();
     GModel::current(GModel::list.size() - 1);
   }
 
-  // clear parser variables, but keep -setnumber/-setstrings command line
-  // definitions
+    // clear parser variables, but keep -setnumber/-setstrings command line
+    // definitions
 #if defined(HAVE_PARSER)
   gmsh_yysymbols.clear();
   gmsh_yystringsymbols.clear();
@@ -738,27 +754,24 @@ void OpenProject(const std::string &fileName)
   std::vector<std::string> tmp = CTX::instance()->recentFiles;
   CTX::instance()->recentFiles.clear();
   CTX::instance()->recentFiles.push_back(fileName);
-  for(unsigned int i = 0; i < tmp.size(); i++){
-    if(tmp[i] != fileName)
-      CTX::instance()->recentFiles.push_back(tmp[i]);
+  for(unsigned int i = 0; i < tmp.size(); i++) {
+    if(tmp[i] != fileName) CTX::instance()->recentFiles.push_back(tmp[i]);
   }
   CTX::instance()->recentFiles.resize(10);
 #if defined(HAVE_FLTK)
-  if(FlGui::available())
-    FlGui::instance()->graph[0]->fillRecentHistoryMenu();
+  if(FlGui::available()) FlGui::instance()->graph[0]->fillRecentHistoryMenu();
 #endif
 
   // close the files that might have been left open by ParseFile
-  if(openedFiles.size()){
-    for(unsigned int i = 0; i < openedFiles.size(); i++)
-      fclose(openedFiles[i]);
+  if(openedFiles.size()) {
+    for(unsigned int i = 0; i < openedFiles.size(); i++) fclose(openedFiles[i]);
     openedFiles.clear();
   }
 
   CTX::instance()->lock = 0;
 
 #if defined(HAVE_FLTK)
-  if(FlGui::available()){
+  if(FlGui::available()) {
     file_watch_cb(0, 0);
     FlGui::instance()->resetVisibility();
     FlGui::instance()->updateViews(true, false);
@@ -771,16 +784,16 @@ void OpenProject(const std::string &fileName)
 void OpenProjectMacFinder(const char *fileName)
 {
 #if defined(HAVE_FLTK)
-  if(!FlGui::available() || !FlGui::getFinishedProcessingCommandLine()){
+  if(!FlGui::available() || !FlGui::getFinishedProcessingCommandLine()) {
     // Gmsh is not ready: will open the file later
     FlGui::setOpenedThroughMacFinder(fileName);
   }
-  else{
+  else {
     // Gmsh is running
     OpenProject(fileName);
     drawContext::global()->draw();
     if(CTX::instance()->launchSolverAtStartup >= 0)
-      solver_cb(0, (void*)(intptr_t)CTX::instance()->launchSolverAtStartup);
+      solver_cb(0, (void *)(intptr_t)CTX::instance()->launchSolverAtStartup);
   }
 #endif
 }
diff --git a/Common/OpenFile.h b/Common/OpenFile.h
index e5abcb466e8b9e60289c7c52dc2212a54aae899b..e3adc0153392388c8ba49d4d2d123739fabc3312 100644
--- a/Common/OpenFile.h
+++ b/Common/OpenFile.h
@@ -8,19 +8,20 @@
 
 #include <string>
 
-int ParseFile(const std::string &fileName, bool close, bool warnIfMissing=false);
-void ParseString(const std::string &str, bool inCurrentModelDir=false);
+int ParseFile(const std::string &fileName, bool close,
+              bool warnIfMissing = false);
+void ParseString(const std::string &str, bool inCurrentModelDir = false);
 void OpenProject(const std::string &filename);
 void OpenProjectMacFinder(const char *fileName);
-int MergeFile(const std::string &fileName, bool warnIfMissing=false,
-              bool setBoundingBox=true, bool importPhysicalsInOnelab=true);
-int MergePostProcessingFile(const std::string &fileName, int showViews=2,
-                            bool showLastStep=false, bool warnIfMissing=false);
+int MergeFile(const std::string &fileName, bool warnIfMissing = false,
+              bool setBoundingBox = true, bool importPhysicalsInOnelab = true);
+int MergePostProcessingFile(const std::string &fileName, int showViews = 2,
+                            bool showLastStep = false,
+                            bool warnIfMissing = false);
 void ClearProject();
-void SetBoundingBox(double xmin, double xmax,
-                    double ymin, double ymax,
+void SetBoundingBox(double xmin, double xmax, double ymin, double ymax,
                     double zmin, double zmax);
-void SetBoundingBox(bool aroundVisible=false);
+void SetBoundingBox(bool aroundVisible = false);
 void AddToTemporaryBoundingBox(double x, double y, double z);
 
 #endif
diff --git a/Common/Options.h b/Common/Options.h
index 7948beb3ca8b25d16dedf7f94dea5c22f58b9c4f..82ef981793867a93f7ac35d68a2b27657429764a 100644
--- a/Common/Options.h
+++ b/Common/Options.h
@@ -9,21 +9,21 @@
 #include <string>
 #include "ColorTable.h"
 
-#define GMSH_SET         (1<<0)
-#define GMSH_GET         (1<<1)
-#define GMSH_GUI         (1<<2)
-#define GMSH_SET_DEFAULT (1<<3)
-#define GMSH_GET_DEFAULT (1<<4)
+#define GMSH_SET (1 << 0)
+#define GMSH_GET (1 << 1)
+#define GMSH_GUI (1 << 2)
+#define GMSH_SET_DEFAULT (1 << 3)
+#define GMSH_GET_DEFAULT (1 << 4)
 
-#define GMSH_SESSIONRC (1<<0)
-#define GMSH_OPTIONSRC (1<<1)
-#define GMSH_FULLRC    (1<<2)
+#define GMSH_SESSIONRC (1 << 0)
+#define GMSH_OPTIONSRC (1 << 1)
+#define GMSH_FULLRC (1 << 2)
 
 // action is a combination of GMSH_SET, GMSH_GET, GMSH_GUI
 
-#define OPT_ARGS_STR   int num, int action, std::string val
-#define OPT_ARGS_NUM   int num, int action, double val
-#define OPT_ARGS_COL   int num, int action, unsigned int val
+#define OPT_ARGS_STR int num, int action, std::string val
+#define OPT_ARGS_NUM int num, int action, double val
+#define OPT_ARGS_COL int num, int action, unsigned int val
 
 // STRINGS
 
@@ -823,8 +823,8 @@ unsigned int opt_view_color_background2d(OPT_ARGS_COL);
 // Data structures and global functions
 
 typedef struct {
-  const char *str ;
-  int int1, int2, int3, int4 ;
+  const char *str;
+  int int1, int2, int3, int4;
 } StringX4Int;
 
 typedef struct {
@@ -839,7 +839,7 @@ typedef struct {
   int level;
   const char *str;
   double (*function)(int num, int action, double val);
-  double def ;
+  double def;
   const char *help;
 } StringXNumber;
 
@@ -858,15 +858,15 @@ void InitOptions(int num);
 void InitOptionsGUI(int num);
 void ReInitOptions(int num);
 void PrintOptions(int num, int level, int diff, int help, const char *filename,
-                  std::vector<std::string> *vec=0);
+                  std::vector<std::string> *vec = 0);
 void PrintOptionsDoc();
 
-bool StringOption(int action, const char *category, int num,
-                  const char *name, std::string &val, bool warnIfUnknown=true);
-bool NumberOption(int action, const char *category, int num,
-                  const char *name, double &val, bool warnIfUnknown=true);
-bool ColorOption(int action, const char *category, int num,
-                 const char *name, unsigned int &val, bool warnIfUnknown=true);
+bool StringOption(int action, const char *category, int num, const char *name,
+                  std::string &val, bool warnIfUnknown = true);
+bool NumberOption(int action, const char *category, int num, const char *name,
+                  double &val, bool warnIfUnknown = true);
+bool ColorOption(int action, const char *category, int num, const char *name,
+                 unsigned int &val, bool warnIfUnknown = true);
 
 GmshColorTable *GetColorTable(int num);
 int GetColorForString(int alpha, const char *string, int *FlagError);
diff --git a/Common/SmoothData.h b/Common/SmoothData.h
index 7441a6377ca3155716faa334712be74fe269d512..f6c2cfcd43cf3e83beb20369d8292b230226106e 100644
--- a/Common/SmoothData.h
+++ b/Common/SmoothData.h
@@ -23,45 +23,48 @@ struct xyzv {
   static double eps;
   xyzv(double xx, double yy, double zz)
     : x(xx), y(yy), z(zz), vals(0), nbvals(0), nboccurrences(0),
-      scaleValue(1.0), scale_numvals(0) {}
-  ~xyzv(){ if(vals) delete [] vals; }
+      scaleValue(1.0), scale_numvals(0)
+  {
+  }
+  ~xyzv()
+  {
+    if(vals) delete[] vals;
+  }
   // these are needed for set<> operations since the default copy constructor
   // won't allocate *vals
-  xyzv(const xyzv & other);
-  xyzv & operator = (const xyzv &other);
+  xyzv(const xyzv &other);
+  xyzv &operator=(const xyzv &other);
   void update(int n, double *v);
   void scale_update(double scale_val);
 };
 
 struct lessthanxyzv {
-  bool operator () (const xyzv &p2, const xyzv &p1) const
+  bool operator()(const xyzv &p2, const xyzv &p1) const
   {
-    if(p1.x - p2.x > xyzv::eps)
-      return true;
-    if(p1.x - p2.x < -xyzv::eps)
-      return false;
-    if(p1.y - p2.y > xyzv::eps)
-      return true;
-    if(p1.y - p2.y < -xyzv::eps)
-      return false;
-    if(p1.z - p2.z > xyzv::eps)
-      return true;
+    if(p1.x - p2.x > xyzv::eps) return true;
+    if(p1.x - p2.x < -xyzv::eps) return false;
+    if(p1.y - p2.y > xyzv::eps) return true;
+    if(p1.y - p2.y < -xyzv::eps) return false;
+    if(p1.z - p2.z > xyzv::eps) return true;
     return false;
   }
 };
 
-class smooth_data{
- private:
+class smooth_data {
+private:
   std::set<xyzv, lessthanxyzv> c;
- public:
+
+public:
   typedef std::set<xyzv, lessthanxyzv>::iterator iter;
-  iter begin(){ return c.begin(); }
-  iter end(){ return c.end(); }
+  iter begin() { return c.begin(); }
+  iter end() { return c.end(); }
   smooth_data() {}
   void add(double x, double y, double z, int n, double *vals);
   bool get(double x, double y, double z, int n, double *vals);
-  void add_scale(double x, double y, double z, double scale_val);  // Trevor Strickler
-  bool get_scale(double x, double y, double z, double *scale_val); // Trevor Strickler
+  void add_scale(double x, double y, double z,
+                 double scale_val); // Trevor Strickler
+  bool get_scale(double x, double y, double z,
+                 double *scale_val); // Trevor Strickler
   void normalize();
   bool exportview(const std::string &filename);
 };
@@ -69,46 +72,39 @@ class smooth_data{
 // Normal smoother with threshold (saves memory by storing normals as
 // chars and coordinates as floats)
 
-struct nnb
-{
+struct nnb {
   char nx, ny, nz;
   unsigned char nb;
 };
 
-struct xyzn
-{
+struct xyzn {
   float x, y, z;
   std::vector<nnb> n;
   static float eps;
-  xyzn(float xx, float yy, float zz) : x(xx), y(yy), z(zz){}
-  ~xyzn(){}
+  xyzn(float xx, float yy, float zz) : x(xx), y(yy), z(zz) {}
+  ~xyzn() {}
   float angle(int i, char n0, char n1, char n2);
   void update(char n0, char n1, char n2, float tol);
 };
 
-struct lessthanxyzn
-{
-  bool operator () (const xyzn &p2, const xyzn &p1) const
+struct lessthanxyzn {
+  bool operator()(const xyzn &p2, const xyzn &p1) const
   {
-    if(p1.x - p2.x > xyzn::eps)
-      return true;
-    if(p1.x - p2.x < -xyzn::eps)
-      return false;
-    if(p1.y - p2.y > xyzn::eps)
-      return true;
-    if(p1.y - p2.y < -xyzn::eps)
-      return false;
-    if(p1.z - p2.z > xyzn::eps)
-      return true;
+    if(p1.x - p2.x > xyzn::eps) return true;
+    if(p1.x - p2.x < -xyzn::eps) return false;
+    if(p1.y - p2.y > xyzn::eps) return true;
+    if(p1.y - p2.y < -xyzn::eps) return false;
+    if(p1.z - p2.z > xyzn::eps) return true;
     return false;
   }
 };
 
-class smooth_normals{
- private:
+class smooth_normals {
+private:
   float tol;
   std::set<xyzn, lessthanxyzn> c;
- public:
+
+public:
   smooth_normals(double angle) : tol((float)angle) {}
   void add(double x, double y, double z, double nx, double ny, double nz);
   bool get(double x, double y, double z, double &nx, double &ny, double &nz);
diff --git a/Common/StringUtils.cpp b/Common/StringUtils.cpp
index ccfc1c8a6a4abb49e8d09df0c734a1c4b09cdea5..a6805aa70205064f703bd2077e4dc423b80e7bd6 100644
--- a/Common/StringUtils.cpp
+++ b/Common/StringUtils.cpp
@@ -18,15 +18,14 @@ void SwapBytes(char *array, int size, int n)
   for(int i = 0; i < n; i++) {
     char *a = &array[i * size];
     memcpy(x, a, size);
-    for(int c = 0; c < size; c++)
-      a[size - 1 - c] = x[c];
+    for(int c = 0; c < size; c++) a[size - 1 - c] = x[c];
   }
-  delete [] x;
+  delete[] x;
 }
 
 std::string ExtractDoubleQuotedString(const char *str, int len)
 {
-  char *c = strstr((char*)str, "\"");
+  char *c = strstr((char *)str, "\"");
   if(!c) return "";
   std::string ret;
   for(int i = 1; i < len; i++) {
@@ -40,18 +39,17 @@ std::string SanitizeTeXString(const char *in, int equation)
 {
   // if there is a '$' or a '\' in the string, assume the author knows
   // what he's doing:
-  if(strstr(in, "$") || strstr(in, "\\"))
-    return std::string(in);
+  if(strstr(in, "$") || strstr(in, "\\")) return std::string(in);
 
   std::string out;
 
   if(equation) out.push_back('$');
 
   // otherwise, escape the following special characters:
-  char bad[8] = { '%', '^', '#', '%', '&', '_', '{', '}' };
-  while(*in){
-    for(unsigned int i = 0; i < sizeof(bad); i++){
-      if(*in == bad[i]){
+  char bad[8] = {'%', '^', '#', '%', '&', '_', '{', '}'};
+  while(*in) {
+    for(unsigned int i = 0; i < sizeof(bad); i++) {
+      if(*in == bad[i]) {
         out.push_back('\\');
         break;
       }
@@ -79,11 +77,11 @@ std::string FixRelativePath(const std::string &reference, const std::string &in)
   if(in.empty()) return "";
 
   if(in[0] == '/' || in[0] == '\\' ||
-     (in.size() > 3 && in[1] == ':' && (in[2] == '/' || in[2] == '\\'))){
+     (in.size() > 3 && in[1] == ':' && (in[2] == '/' || in[2] == '\\'))) {
     // do nothing: 'in' is an absolute path
     return in;
   }
-  else{
+  else {
     // append 'in' to the path of the reference file
     std::vector<std::string> split = SplitFileName(reference);
     return split[0] + in;
@@ -94,18 +92,18 @@ std::vector<std::string> SplitFileName(const std::string &fileName)
 {
   // JFR DO NOT CHANGE TO std::vector<std::string> s(3), it segfaults while
   // destructor si called
-  std::vector<std::string> s; s.resize(3);
-  if(fileName.size()){
+  std::vector<std::string> s;
+  s.resize(3);
+  if(fileName.size()) {
     // returns [path, baseName, extension]
     int idot = (int)fileName.find_last_of('.');
     int islash = (int)fileName.find_last_of("/\\");
     if(idot == (int)std::string::npos) idot = -1;
     if(islash == (int)std::string::npos) islash = -1;
-    if(idot > 0)
-      s[2] = fileName.substr(idot);
-    if(islash > 0)
-      s[0] = fileName.substr(0, islash + 1);
-    s[1] = fileName.substr(s[0].size(), fileName.size() - s[0].size() - s[2].size());
+    if(idot > 0) s[2] = fileName.substr(idot);
+    if(islash > 0) s[0] = fileName.substr(0, islash + 1);
+    s[1] =
+      fileName.substr(s[0].size(), fileName.size() - s[0].size() - s[2].size());
   }
   return s;
 }
@@ -130,7 +128,7 @@ std::string ConvertFileToString(const std::string &fileName)
 void ReplaceSubStringInPlace(const std::string &olds, const std::string &news,
                              std::string &str)
 {
-  while(1){
+  while(1) {
     int pos = (int)str.find(olds.c_str());
     if(pos == (int)std::string::npos) break;
     str.replace(pos, olds.size(), news.c_str());
@@ -157,20 +155,20 @@ bool SplitOptionName(const std::string &fullName, std::string &category,
                      std::string &name, int &index)
 {
   std::string::size_type d = fullName.find_first_of('.');
-  if(d == std::string::npos){
+  if(d == std::string::npos) {
     name = fullName;
     return false;
   }
   category = fullName.substr(0, d);
   std::string::size_type b1 = fullName.find_first_of('[');
   std::string::size_type b2 = fullName.find_last_of(']');
-  if(b1 != std::string::npos && b2 != std::string::npos){
+  if(b1 != std::string::npos && b2 != std::string::npos) {
     std::string id = fullName.substr(b1 + 1, b2 - b1 - 1);
     index = atoi(id.c_str());
     category = fullName.substr(0, b1);
     name = fullName.substr(d + 1, b1 - d);
   }
-  else{
+  else {
     index = 0;
     name = fullName.substr(d + 1);
   }
@@ -186,23 +184,22 @@ static std::string getNextTokenInString(const std::string &msg,
   if(first == std::string::npos) return "";
   std::string::size_type last = msg.find_first_of(separator, first);
   std::string next("");
-  if(last == std::string::npos){
+  if(last == std::string::npos) {
     next = msg.substr(first);
     first = last;
   }
-  else if(first == last){
+  else if(first == last) {
     next = "";
     first = last + 1;
   }
-  else{
+  else {
     next = msg.substr(first, last - first);
     first = last + 1;
   }
   return next;
 }
 
-std::vector<std::string> SplitString(const std::string &msg,
-                                     char separator)
+std::vector<std::string> SplitString(const std::string &msg, char separator)
 {
   std::vector<std::string> out;
   std::string::size_type first = 0;
diff --git a/Common/StringUtils.h b/Common/StringUtils.h
index 49569f4e1ce7e362e132418f9fbb79b0918ea1de..183d141dce389af78c42f800165fcf6b6f838d95 100644
--- a/Common/StringUtils.h
+++ b/Common/StringUtils.h
@@ -14,7 +14,8 @@ void SwapBytes(char *array, int size, int n);
 std::string ExtractDoubleQuotedString(const char *str, int len);
 std::string SanitizeTeXString(const char *in, int equation);
 std::string FixWindowsPath(const std::string &in);
-std::string FixRelativePath(const std::string &reference, const std::string &in);
+std::string FixRelativePath(const std::string &reference,
+                            const std::string &in);
 std::vector<std::string> SplitFileName(const std::string &fileName);
 std::string GetFileNameWithoutPath(const std::string &fileName);
 std::string ConvertFileToString(const std::string &fileName);
diff --git a/Common/TreeUtils.cpp b/Common/TreeUtils.cpp
index 91c550ca21c95fdfce7bf39305e638d685876bfc..83d01dd9860523b65ff29c1c5ab744d6e97a9812 100644
--- a/Common/TreeUtils.cpp
+++ b/Common/TreeUtils.cpp
@@ -12,29 +12,29 @@
 #include "MallocUtils.h"
 #include "TreeUtils.h"
 
-Tree_T *Tree_Create(int size, int (*fcmp) (const void *a, const void *b))
+Tree_T *Tree_Create(int size, int (*fcmp)(const void *a, const void *b))
 {
-  Tree_T *tree = (Tree_T*)Malloc(sizeof(Tree_T));
+  Tree_T *tree = (Tree_T *)Malloc(sizeof(Tree_T));
   tree->size = size;
   tree->root = avl_init_table(fcmp);
   return tree;
 }
 
-void Tree_Delete(Tree_T * tree)
+void Tree_Delete(Tree_T *tree)
 {
   if(!tree) return;
   avl_free_table(tree->root, Free, 0);
   Free(tree);
 }
 
-void Tree_Delete(Tree_T * tree, void (*freefn) (void * ))
+void Tree_Delete(Tree_T *tree, void (*freefn)(void *))
 {
   if(!tree) return;
   avl_free_table(tree->root, freefn, 0);
   Free(tree);
 }
 
-void *Tree_Add(Tree_T * tree, void *data)
+void *Tree_Add(Tree_T *tree, void *data)
 {
   if(!tree) return 0;
   void *ptr = Malloc(tree->size);
@@ -43,64 +43,61 @@ void *Tree_Add(Tree_T * tree, void *data)
   return ptr;
 }
 
-int Tree_Nbr(Tree_T * tree)
+int Tree_Nbr(Tree_T *tree)
 {
   if(!tree) return 0;
   return avl_count(tree->root);
 }
 
-int Tree_Insert(Tree_T * tree, void *data)
+int Tree_Insert(Tree_T *tree, void *data)
 {
-  if(!Tree_Search(tree, data)){
+  if(!Tree_Search(tree, data)) {
     Tree_Add(tree, data);
     return 1;
   }
   return 0;
 }
 
-int Tree_Search(Tree_T * tree, void *data)
+int Tree_Search(Tree_T *tree, void *data)
 {
   if(!tree) return 0;
   void *ptr;
   return avl_lookup(tree->root, data, &ptr);
 }
 
-int Tree_Query(Tree_T * tree, void *data)
+int Tree_Query(Tree_T *tree, void *data)
 {
   if(!tree) return 0;
   void *ptr;
-  if(!avl_lookup(tree->root, data, &ptr))
-    return 0;
+  if(!avl_lookup(tree->root, data, &ptr)) return 0;
   memcpy(data, ptr, tree->size);
   return 1;
 }
 
-void *Tree_PQuery(Tree_T * tree, void *data)
+void *Tree_PQuery(Tree_T *tree, void *data)
 {
   if(!tree) return 0;
   void *ptr;
-  if(!avl_lookup(tree->root, data, &ptr))
-    return 0;
+  if(!avl_lookup(tree->root, data, &ptr)) return 0;
   return ptr;
 }
 
-int Tree_Suppress(Tree_T * tree, void *data)
+int Tree_Suppress(Tree_T *tree, void *data)
 {
   if(!tree) return 0;
   void *ptr = data;
-  if(!avl_delete(tree->root, &ptr, &ptr))
-    return 0;
+  if(!avl_delete(tree->root, &ptr, &ptr)) return 0;
   Free(ptr);
   return 1;
 }
 
-int Tree_Size(Tree_T * tree)
+int Tree_Size(Tree_T *tree)
 {
   if(!tree) return 0;
   return tree->size;
 }
 
-void Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy))
+void Tree_Action(Tree_T *tree, void (*action)(void *data, void *dummy))
 {
   if(!tree) return;
   avl_foreach(tree->root, action, AVL_FORWARD);
@@ -108,17 +105,13 @@ void Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy))
 
 static List_T *pListTransfer;
 
-void TransferList(void *a, void *b)
-{
-  List_Add(pListTransfer, a);
-}
+void TransferList(void *a, void *b) { List_Add(pListTransfer, a); }
 
-List_T *Tree2List(Tree_T * pTree)
+List_T *Tree2List(Tree_T *pTree)
 {
   int Nb;
   Nb = Tree_Nbr(pTree);
-  if(Nb == 0)
-    Nb = 1;
+  if(Nb == 0) Nb = 1;
   pListTransfer = List_Create(Nb, Nb, Tree_Size(pTree));
   Tree_Action(pTree, TransferList);
   return pListTransfer;
diff --git a/Common/TreeUtils.h b/Common/TreeUtils.h
index 791b9d9f88da9883e6bc62f170dba6f09edb185f..0f1a83853fa56251b7da6ca1091376743567b73a 100644
--- a/Common/TreeUtils.h
+++ b/Common/TreeUtils.h
@@ -10,23 +10,23 @@
 #include "ListUtils.h"
 
 class Tree_T {
- public:
+public:
   int size;
   avl_tree *root;
 };
 
 Tree_T *Tree_Create(int size, int (*fcmp)(const void *a, const void *b));
-void    Tree_Delete(Tree_T *Tree);
-void    Tree_Delete(Tree_T *Tree, void (*freefn)(void * ) );
-void   *Tree_Add(Tree_T *tree, void *data);
-int     Tree_Nbr(Tree_T *Tree);
-int     Tree_Insert(Tree_T *Tree, void *data);
-int     Tree_Search(Tree_T *Tree, void *data);
-int     Tree_Query(Tree_T *Tree, void *data);
-void   *Tree_PQuery(Tree_T *Tree, void *data);
-int     Tree_Suppress(Tree_T *Tree, void *data);
-int     Tree_Size(Tree_T *tree) ;
-void    Tree_Action(Tree_T *tree, void (*action) (void *data, void *dummy));
+void Tree_Delete(Tree_T *Tree);
+void Tree_Delete(Tree_T *Tree, void (*freefn)(void *));
+void *Tree_Add(Tree_T *tree, void *data);
+int Tree_Nbr(Tree_T *Tree);
+int Tree_Insert(Tree_T *Tree, void *data);
+int Tree_Search(Tree_T *Tree, void *data);
+int Tree_Query(Tree_T *Tree, void *data);
+void *Tree_PQuery(Tree_T *Tree, void *data);
+int Tree_Suppress(Tree_T *Tree, void *data);
+int Tree_Size(Tree_T *tree);
+void Tree_Action(Tree_T *tree, void (*action)(void *data, void *dummy));
 List_T *Tree2List(Tree_T *pTree);
 
 #endif
diff --git a/Common/VertexArray.h b/Common/VertexArray.h
index 8afe8d54d48aeb8200040410dec30d6676d3f5e9..9777346bd9d1240e715224f10e73d5e8cfd961bd 100644
--- a/Common/VertexArray.h
+++ b/Common/VertexArray.h
@@ -19,28 +19,29 @@ typedef char normal_type;
 
 class MElement;
 
-template<int N>
-class ElementData {
- private:
+template <int N> class ElementData {
+private:
   float _x[N], _y[N], _z[N], _nx[N], _ny[N], _nz[N];
   unsigned char _r[N], _g[N], _b[N], _a[N];
   MElement *_ele;
- public:
+
+public:
   ElementData(double *x, double *y, double *z, SVector3 *n, unsigned char *r,
-              unsigned char *g, unsigned char *b, unsigned char *a, MElement *ele)
+              unsigned char *g, unsigned char *b, unsigned char *a,
+              MElement *ele)
   {
-    for(int i = 0; i < N; i++){
+    for(int i = 0; i < N; i++) {
       _x[i] = (float)x[i];
       _y[i] = (float)y[i];
       _z[i] = (float)z[i];
-      if(n){
+      if(n) {
         _nx[i] = (float)n[i].x();
         _ny[i] = (float)n[i].y();
         _nz[i] = (float)n[i].z();
       }
       else
         _nx[i] = _ny[i] = _nz[i] = 0.;
-      if(r && g && b && a){
+      if(r && g && b && a) {
         _r[i] = r[i];
         _g[i] = g[i];
         _b[i] = b[i];
@@ -65,7 +66,7 @@ class ElementData {
   SPoint3 barycenter() const
   {
     SPoint3 p(0., 0., 0.);
-    for(int i = 0; i < N; i++){
+    for(int i = 0; i < N; i++) {
       p[0] += _x[i];
       p[1] += _y[i];
       p[2] += _z[i];
@@ -77,51 +78,58 @@ class ElementData {
   }
 };
 
-template<int N>
-class ElementDataLessThan{
- public:
+template <int N> class ElementDataLessThan {
+public:
   static float tolerance;
   bool operator()(const ElementData<N> &e1, const ElementData<N> &e2) const
   {
     SPoint3 p1 = e1.barycenter();
     SPoint3 p2 = e2.barycenter();
-    if(p1.x() - p2.x() >  tolerance) return true;
+    if(p1.x() - p2.x() > tolerance) return true;
     if(p1.x() - p2.x() < -tolerance) return false;
-    if(p1.y() - p2.y() >  tolerance) return true;
+    if(p1.y() - p2.y() > tolerance) return true;
     if(p1.y() - p2.y() < -tolerance) return false;
-    if(p1.z() - p2.z() >  tolerance) return true;
+    if(p1.z() - p2.z() > tolerance) return true;
     return false;
   }
 };
 
 class Barycenter {
- private:
+private:
   float _x, _y, _z;
- public:
+
+public:
   Barycenter(double x, double y, double z)
-    : _x((float)x), _y((float)y), _z((float)z){}
+    : _x((float)x), _y((float)y), _z((float)z)
+  {
+  }
   inline float x() const { return _x; }
   inline float y() const { return _y; }
   inline float z() const { return _z; }
-  void operator+=(const Barycenter &p){ _x += p.x(); _y += p.y(); _z += p.z(); }
+  void operator+=(const Barycenter &p)
+  {
+    _x += p.x();
+    _y += p.y();
+    _z += p.z();
+  }
 };
 
-class BarycenterLessThan{
- public:
+class BarycenterLessThan {
+public:
   static float tolerance;
   bool operator()(const Barycenter &p1, const Barycenter &p2) const
   {
-    if(p1.x() - p2.x() >  tolerance) return true;
+    if(p1.x() - p2.x() > tolerance) return true;
     if(p1.x() - p2.x() < -tolerance) return false;
-    if(p1.y() - p2.y() >  tolerance) return true;
+    if(p1.y() - p2.y() > tolerance) return true;
     if(p1.y() - p2.y() < -tolerance) return false;
-    if(p1.z() - p2.z() >  tolerance) return true;
+    if(p1.z() - p2.z() > tolerance) return true;
     return false;
   }
 };
 
 class BarycenterHash {
- public:
+public:
   std::size_t operator()(const Barycenter &b) const
   {
     return (std::size_t)(b.x() + b.y() + b.z());
@@ -129,27 +137,28 @@ class BarycenterHash {
 };
 
 class BarycenterEqual {
- public:
-  bool operator ()(const Barycenter &a, const Barycenter &b) const
+public:
+  bool operator()(const Barycenter &a, const Barycenter &b) const
   {
-    return (fabs(a.x()-b.x()) < BarycenterLessThan::tolerance &&
-            fabs(a.y()-b.y()) < BarycenterLessThan::tolerance &&
-            fabs(a.z()-b.z()) < BarycenterLessThan::tolerance);
+    return (fabs(a.x() - b.x()) < BarycenterLessThan::tolerance &&
+            fabs(a.y() - b.y()) < BarycenterLessThan::tolerance &&
+            fabs(a.z() - b.z()) < BarycenterLessThan::tolerance);
   }
 };
 
 //#include <tr1/unordered_set>
 
-class VertexArray{
- private:
+class VertexArray {
+private:
   int _numVerticesPerElement;
   std::vector<float> _vertices;
   std::vector<normal_type> _normals;
   std::vector<unsigned char> _colors;
-  std::vector<MElement*> _elements;
+  std::vector<MElement *> _elements;
   std::set<ElementData<3>, ElementDataLessThan<3> > _data3;
   std::set<Barycenter, BarycenterLessThan> _barycenters;
-  //std::tr1::unordered_set<Barycenter, BarycenterHash, BarycenterEqual> _barycenters;
+  // std::tr1::unordered_set<Barycenter, BarycenterHash, BarycenterEqual>
+  // _barycenters;
 
   // add stuff in the arrays
   void _addVertex(float x, float y, float z);
@@ -157,9 +166,10 @@ class VertexArray{
   void _addColor(unsigned char r, unsigned char g, unsigned char b,
                  unsigned char a);
   void _addElement(MElement *ele);
- public:
+
+public:
   VertexArray(int numVerticesPerElement, int numElements);
-  ~VertexArray(){}
+  ~VertexArray() {}
   // return the number of vertices in the array
   int getNumVertices() { return (int)_vertices.size() / 3; }
   // return the number of vertices per element
@@ -169,33 +179,39 @@ class VertexArray{
   // return a pointer to the raw vertex array (warning: 1) we don't
   // range check 2) calling this if _vertices.size() == 0 will cause
   // some compilers to throw an exception)
-  float *getVertexArray(int i=0){ return &_vertices[i]; }
-  std::vector<float>::iterator firstVertex(){return _vertices.begin();}
-  std::vector<float>::iterator lastVertex(){return _vertices.end();}
+  float *getVertexArray(int i = 0) { return &_vertices[i]; }
+  std::vector<float>::iterator firstVertex() { return _vertices.begin(); }
+  std::vector<float>::iterator lastVertex() { return _vertices.end(); }
 
   // return a pointer to the raw normal array
-  normal_type *getNormalArray(int i=0){ return &_normals[i]; }
-  std::vector<normal_type>::iterator firstNormal(){return _normals.begin();}
-  std::vector<normal_type>::iterator lastNormal(){return _normals.end();}
+  normal_type *getNormalArray(int i = 0) { return &_normals[i]; }
+  std::vector<normal_type>::iterator firstNormal() { return _normals.begin(); }
+  std::vector<normal_type>::iterator lastNormal() { return _normals.end(); }
 
   // return a pointer to the raw color array
-  unsigned char *getColorArray(int i=0){ return &_colors[i]; }
-  std::vector<unsigned char>::iterator firstColor(){return _colors.begin();}
-  std::vector<unsigned char>::iterator lastColor(){return _colors.end();}
+  unsigned char *getColorArray(int i = 0) { return &_colors[i]; }
+  std::vector<unsigned char>::iterator firstColor() { return _colors.begin(); }
+  std::vector<unsigned char>::iterator lastColor() { return _colors.end(); }
 
   // return a pointer to the raw element array
-  MElement **getElementPointerArray(int i=0){ return &_elements[i]; }
-  std::vector<MElement*>::iterator firstElementPointer(){return _elements.begin();}
-  std::vector<MElement*>::iterator lastElementPointer(){return _elements.end();}
+  MElement **getElementPointerArray(int i = 0) { return &_elements[i]; }
+  std::vector<MElement *>::iterator firstElementPointer()
+  {
+    return _elements.begin();
+  }
+  std::vector<MElement *>::iterator lastElementPointer()
+  {
+    return _elements.end();
+  }
 
   // add element data in the arrays (if unique is set, only add the
   // element if another one with the same barycenter is not already
   // present)
   void add(double *x, double *y, double *z, SVector3 *n, unsigned int *col,
-           MElement *ele=0, bool unique=true, bool boundary=false);
-  void add(double *x, double *y, double *z, SVector3 *n, unsigned char *r=0,
-           unsigned char *g=0, unsigned char *b=0, unsigned char *a=0,
-           MElement *ele=0, bool unique=true, bool boundary=false);
+           MElement *ele = 0, bool unique = true, bool boundary = false);
+  void add(double *x, double *y, double *z, SVector3 *n, unsigned char *r = 0,
+           unsigned char *g = 0, unsigned char *b = 0, unsigned char *a = 0,
+           MElement *ele = 0, bool unique = true, bool boundary = false);
   // finalize the arrays
   void finalize();
   // sort the arrays with elements back to front wrt the eye position
@@ -209,8 +225,8 @@ class VertexArray{
                const SBoundingBox3d &bbox, int &len);
   void fromChar(int length, const char *bytes, int swap);
   static int decodeHeader(int length, const char *bytes, int swap,
-                          std::string &name, int &tag, int &type,
-                          double &min, double &max, int &numSteps, double &time,
+                          std::string &name, int &tag, int &type, double &min,
+                          double &max, int &numSteps, double &time,
                           double &xmin, double &ymin, double &zmin,
                           double &xmax, double &ymax, double &zmax);
   // merge another vertex array into this one
diff --git a/Common/gmsh.cpp b/Common/gmsh.cpp
index 9bb22cbfd54296c07942f2fe8ccc06a28cf9acc7..03780fad75f0f88f9e0fb5e62c173702a851ff9c 100644
--- a/Common/gmsh.cpp
+++ b/Common/gmsh.cpp
@@ -66,7 +66,7 @@
 // automatically generated C++ and C headers (in gmsh/api)
 #include "gmsh.h"
 extern "C" {
-  #include "gmshc.h"
+#include "gmshc.h"
 }
 
 static int _initialized = 0;
@@ -75,13 +75,13 @@ static char **_argv = 0;
 
 static bool _isInitialized()
 {
-  if(!_initialized){
+  if(!_initialized) {
     // make sure stuff gets printed out
     CTX::instance()->terminal = 1;
     Msg::Error("Gmsh has not been initialized");
     return false;
   }
-  if(!GModel::current()){
+  if(!GModel::current()) {
     Msg::Error("Gmsh has no current model");
     return false;
   }
@@ -90,30 +90,30 @@ static bool _isInitialized()
 
 // gmsh
 
-GMSH_API void gmsh::initialize(int argc,
-                               char **argv,
-                               bool readConfigFiles)
+GMSH_API void gmsh::initialize(int argc, char **argv, bool readConfigFiles)
 {
-  if(_initialized){
+  if(_initialized) {
     Msg::Warning("Gmsh has aleady been initialized");
     return;
   }
-  if(GmshInitialize(argc, argv, readConfigFiles, false)){
+  if(GmshInitialize(argc, argv, readConfigFiles, false)) {
     _initialized = 1;
     _argc = argc;
-    _argv = new char*[_argc + 1];
+    _argv = new char *[_argc + 1];
     for(int i = 0; i < argc; i++) _argv[i] = argv[i];
     return;
   }
-  throw -1;
+  throw - 1;
 }
 
 GMSH_API void gmsh::finalize()
 {
-  if(!_isInitialized()){ throw -1; }
-  if(GmshFinalize()){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(GmshFinalize()) {
     _argc = 0;
-    if(_argv) delete [] _argv;
+    if(_argv) delete[] _argv;
     _argv = 0;
     _initialized = 0;
     return;
@@ -124,36 +124,45 @@ GMSH_API void gmsh::finalize()
 
 GMSH_API void gmsh::open(const std::string &fileName)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   if(GmshOpenProject(fileName)) return;
   throw 1;
 }
 
 GMSH_API void gmsh::merge(const std::string &fileName)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   if(GmshMergeFile(fileName)) return;
   throw 1;
 }
 
 GMSH_API void gmsh::write(const std::string &fileName)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   if(GmshWriteFile(fileName)) return;
   throw 1;
 }
 
 GMSH_API void gmsh::clear()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   if(GmshClearProject()) return;
   throw 1;
 }
 
-class apiMsg : public GmshMessage{
- private:
+class apiMsg : public GmshMessage {
+private:
   std::vector<std::string> &_log;
- public:
+
+public:
   apiMsg(std::vector<std::string> &log) : _log(log) {}
   virtual void operator()(std::string level, std::string message)
   {
@@ -163,12 +172,14 @@ class apiMsg : public GmshMessage{
 
 GMSH_API void gmsh::logger::start(std::vector<std::string> &log)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GmshMessage *msg = Msg::GetCallback();
-  if(msg){
+  if(msg) {
     Msg::Warning("Logger already started - ignoring");
   }
-  else{
+  else {
     msg = new apiMsg(log);
     Msg::SetCallback(msg);
   }
@@ -176,13 +187,15 @@ GMSH_API void gmsh::logger::start(std::vector<std::string> &log)
 
 GMSH_API void gmsh::logger::stop()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GmshMessage *msg = Msg::GetCallback();
-  if(msg){
+  if(msg) {
     delete msg;
     Msg::SetCallback(0);
   }
-  else{
+  else {
     Msg::Warning("Logger not started - ignoring");
   }
 }
@@ -192,7 +205,9 @@ GMSH_API void gmsh::logger::stop()
 GMSH_API void gmsh::option::setNumber(const std::string &name,
                                       const double value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   std::string c, n;
   int i;
   SplitOptionName(name, c, n, i);
@@ -200,10 +215,11 @@ GMSH_API void gmsh::option::setNumber(const std::string &name,
   throw 1;
 }
 
-GMSH_API void gmsh::option::getNumber(const std::string &name,
-                                      double &value)
+GMSH_API void gmsh::option::getNumber(const std::string &name, double &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   std::string c, n;
   int i;
   SplitOptionName(name, c, n, i);
@@ -214,7 +230,9 @@ GMSH_API void gmsh::option::getNumber(const std::string &name,
 GMSH_API void gmsh::option::setString(const std::string &name,
                                       const std::string &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   std::string c, n;
   int i;
   SplitOptionName(name, c, n, i);
@@ -225,7 +243,9 @@ GMSH_API void gmsh::option::setString(const std::string &name,
 GMSH_API void gmsh::option::getString(const std::string &name,
                                       std::string &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   std::string c, n;
   int i;
   SplitOptionName(name, c, n, i);
@@ -237,55 +257,73 @@ GMSH_API void gmsh::option::getString(const std::string &name,
 
 GMSH_API void gmsh::model::add(const std::string &name)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel *m = new GModel(name);
-  if(!m){ throw 1; }
+  if(!m) {
+    throw 1;
+  }
 }
 
 GMSH_API void gmsh::model::remove()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel *m = GModel::current();
-  if(!m){ throw 1; }
+  if(!m) {
+    throw 1;
+  }
   delete m;
 }
 
 GMSH_API void gmsh::model::list(std::vector<std::string> &names)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   for(unsigned int i = 0; i < GModel::list.size(); i++)
     names.push_back(GModel::list[i]->getName());
 }
 
 GMSH_API void gmsh::model::setCurrent(const std::string &name)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel *m = GModel::findByName(name);
-  if(!m){ throw 1; }
+  if(!m) {
+    throw 1;
+  }
   GModel::setCurrent(m);
 }
 
-GMSH_API void gmsh::model::getEntities(vectorpair &dimTags,
-                                       const int dim)
+GMSH_API void gmsh::model::getEntities(vectorpair &dimTags, const int dim)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   dimTags.clear();
-  std::vector<GEntity*> entities;
+  std::vector<GEntity *> entities;
   GModel::current()->getEntities(entities, dim);
   for(unsigned int i = 0; i < entities.size(); i++)
-    dimTags.push_back(std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
+    dimTags.push_back(
+      std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
 }
 
-GMSH_API void gmsh::model::getPhysicalGroups(vectorpair &dimTags,
-                                             const int dim)
+GMSH_API void gmsh::model::getPhysicalGroups(vectorpair &dimTags, const int dim)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   dimTags.clear();
-  std::map<int, std::vector<GEntity*> > groups[4];
+  std::map<int, std::vector<GEntity *> > groups[4];
   GModel::current()->getPhysicalGroups(groups);
-  for(int d = 0; d < 4; d++){
-    if(dim < 0 || d == dim){
-      for(std::map<int, std::vector<GEntity*> >::iterator it = groups[d].begin();
+  for(int d = 0; d < 4; d++) {
+    if(dim < 0 || d == dim) {
+      for(std::map<int, std::vector<GEntity *> >::iterator it =
+            groups[d].begin();
           it != groups[d].end(); it++)
         dimTags.push_back(std::pair<int, int>(d, it->first));
     }
@@ -295,11 +333,11 @@ GMSH_API void gmsh::model::getPhysicalGroups(vectorpair &dimTags,
 static std::string _getEntityName(int dim, int tag)
 {
   std::stringstream stream;
-  switch(dim){
-  case 0 : stream << "Point "; break;
-  case 1 : stream << "Curve "; break;
-  case 2 : stream << "Surface "; break;
-  case 3 : stream << "Volume "; break;
+  switch(dim) {
+  case 0: stream << "Point "; break;
+  case 1: stream << "Curve "; break;
+  case 2: stream << "Surface "; break;
+  case 3: stream << "Volume "; break;
   }
   stream << tag;
   return stream.str();
@@ -309,35 +347,39 @@ GMSH_API void gmsh::model::getEntitiesForPhysicalGroup(const int dim,
                                                        const int tag,
                                                        std::vector<int> &tags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   tags.clear();
-  std::map<int, std::vector<GEntity*> > groups;
+  std::map<int, std::vector<GEntity *> > groups;
   GModel::current()->getPhysicalGroups(dim, groups);
-  std::map<int, std::vector<GEntity*> >::iterator it = groups.find(tag);
-  if(it != groups.end()){
+  std::map<int, std::vector<GEntity *> >::iterator it = groups.find(tag);
+  if(it != groups.end()) {
     for(unsigned j = 0; j < it->second.size(); j++)
       tags.push_back(it->second[j]->tag());
   }
-  else{
+  else {
     Msg::Error("Physical %s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
 }
 
-GMSH_API void gmsh::model::getPhysicalGroupsForEntity(const int dim,
-                                                      const int tag,
-                                                      std::vector<int> &physicalTags)
+GMSH_API void
+gmsh::model::getPhysicalGroupsForEntity(const int dim, const int tag,
+                                        std::vector<int> &physicalTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   physicalTags.clear();
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
   std::vector<int> phy = ge->getPhysicalEntities();
   physicalTags.resize(phy.size());
-  for(unsigned int i = 0; i < phy.size(); i++){
+  for(unsigned int i = 0; i < phy.size(); i++) {
     physicalTags[i] = phy[i];
   }
 }
@@ -346,91 +388,96 @@ GMSH_API int gmsh::model::addPhysicalGroup(const int dim,
                                            const std::vector<int> &tags,
                                            const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
   if(outTag < 0)
     outTag = GModel::current()->getGEOInternals()->getMaxPhysicalTag() + 1;
-  if(!GModel::current()->getGEOInternals()->modifyPhysicalGroup
-     (dim, outTag, 0, tags)){
+  if(!GModel::current()->getGEOInternals()->modifyPhysicalGroup(dim, outTag, 0,
+                                                                tags)) {
     throw 1;
   }
   GModel::current()->getGEOInternals()->synchronize(GModel::current());
   return outTag;
 }
 
-GMSH_API void gmsh::model::setPhysicalName(const int dim,
-                                           const int tag,
+GMSH_API void gmsh::model::setPhysicalName(const int dim, const int tag,
                                            const std::string &name)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->setPhysicalName(name, dim, tag);
 }
 
-GMSH_API void gmsh::model::getPhysicalName(const int dim,
-                                           const int tag,
+GMSH_API void gmsh::model::getPhysicalName(const int dim, const int tag,
                                            std::string &name)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   name = GModel::current()->getPhysicalName(dim, tag);
 }
 
 GMSH_API void gmsh::model::getBoundary(const vectorpair &dimTags,
                                        vectorpair &outDimTags,
-                                       const bool combined,
-                                       const bool oriented,
+                                       const bool combined, const bool oriented,
                                        const bool recursive)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   outDimTags.clear();
   if(!GModel::current()->getBoundaryTags(dimTags, outDimTags, combined,
-                                         oriented, recursive)){
+                                         oriented, recursive)) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::getEntitiesInBoundingBox(const double xmin,
-                                                    const double ymin,
-                                                    const double zmin,
-                                                    const double xmax,
-                                                    const double ymax,
-                                                    const double zmax,
-                                                    vectorpair &dimTags,
-                                                    const int dim)
+GMSH_API void gmsh::model::getEntitiesInBoundingBox(
+  const double xmin, const double ymin, const double zmin, const double xmax,
+  const double ymax, const double zmax, vectorpair &dimTags, const int dim)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   dimTags.clear();
   SBoundingBox3d box(xmin, ymin, zmin, xmax, ymax, zmax);
-  std::vector<GEntity*> entities;
+  std::vector<GEntity *> entities;
   GModel::current()->getEntitiesInBox(entities, box, dim);
   for(unsigned int i = 0; i < entities.size(); i++)
-    dimTags.push_back(std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
+    dimTags.push_back(
+      std::pair<int, int>(entities[i]->dim(), entities[i]->tag()));
 }
 
-GMSH_API void gmsh::model::getBoundingBox(const int dim,
-                                          const int tag,
-                                          double &xmin,
-                                          double &ymin,
-                                          double &zmin,
-                                          double &xmax,
-                                          double &ymax,
-                                          double &zmax)
+GMSH_API void gmsh::model::getBoundingBox(const int dim, const int tag,
+                                          double &xmin, double &ymin,
+                                          double &zmin, double &xmax,
+                                          double &ymax, double &zmax)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 
   SBoundingBox3d box;
-  if(dim < 0 && tag < 0){
+  if(dim < 0 && tag < 0) {
     box = GModel::current()->bounds();
-    if(box.empty()){ throw(3); }
+    if(box.empty()) {
+      throw(3);
+    }
   }
-  else{
+  else {
     GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-    if(!ge){
+    if(!ge) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
     box = ge->bounds();
   }
-  if(box.empty()){ throw(3); }
+  if(box.empty()) {
+    throw(3);
+  }
   xmin = box.min().x();
   ymin = box.min().y();
   zmin = box.min().z();
@@ -441,27 +488,30 @@ GMSH_API void gmsh::model::getBoundingBox(const int dim,
 
 GMSH_API int gmsh::model::getDimension()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 
   return GModel::current()->getDim();
 }
 
-GMSH_API int gmsh::model::addDiscreteEntity(const int dim,
-                                            const int tag,
+GMSH_API int gmsh::model::addDiscreteEntity(const int dim, const int tag,
                                             const std::vector<int> &boundary)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(outTag < 0){
+  if(outTag < 0) {
     outTag = GModel::current()->getMaxElementaryNumber(dim);
   }
   GEntity *e = GModel::current()->getEntityByTag(dim, outTag);
-  if(e){
+  if(e) {
     Msg::Error("%s already exists", _getEntityName(dim, outTag).c_str());
     throw 2;
   }
   // FIXME: check and set boundary entities to construct topology!
-  switch(dim){
+  switch(dim) {
   case 0: {
     GVertex *gv = new discreteVertex(GModel::current(), outTag);
     GModel::current()->add(gv);
@@ -483,8 +533,7 @@ GMSH_API int gmsh::model::addDiscreteEntity(const int dim,
     GModel::current()->add(gr);
     break;
   }
-  default :
-    throw 2;
+  default: throw 2;
   }
   return outTag;
 }
@@ -492,73 +541,77 @@ GMSH_API int gmsh::model::addDiscreteEntity(const int dim,
 GMSH_API void gmsh::model::removeEntities(const vectorpair &dimTags,
                                           const bool recursive)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->remove(dimTags, recursive);
 }
 
-GMSH_API void gmsh::model::getType(const int dim,
-                                   const int tag,
+GMSH_API void gmsh::model::getType(const int dim, const int tag,
                                    std::string &entityType)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
   entityType = ge->getTypeString();
 }
 
-GMSH_API void gmsh::model::getParent(const int dim,
-                                     const int tag,
-                                     int &parentDim,
-                                     int &parentTag)
+GMSH_API void gmsh::model::getParent(const int dim, const int tag,
+                                     int &parentDim, int &parentTag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   parentDim = -1;
   parentTag = -1;
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
   GEntity *parent = ge->getParentEntity();
-  if(parent){
+  if(parent) {
     parentDim = parent->dim();
     parentDim = parent->tag();
   }
 }
 
-GMSH_API void gmsh::model::getValue(const int dim,
-                                    const int tag,
+GMSH_API void gmsh::model::getValue(const int dim, const int tag,
                                     const std::vector<double> &parametricCoord,
                                     std::vector<double> &points)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   points.clear();
   GEntity *entity = GModel::current()->getEntityByTag(dim, tag);
-  if(!entity){
+  if(!entity) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(dim == 0){
+  if(dim == 0) {
     points.push_back(static_cast<GVertex *>(entity)->x());
     points.push_back(static_cast<GVertex *>(entity)->y());
     points.push_back(static_cast<GVertex *>(entity)->z());
   }
-  else if(dim == 1){
+  else if(dim == 1) {
     GEdge *ge = static_cast<GEdge *>(entity);
-    for(unsigned int i = 0; i < parametricCoord.size(); i++){
+    for(unsigned int i = 0; i < parametricCoord.size(); i++) {
       GPoint gp = ge->point(parametricCoord[i]);
       points.push_back(gp.x());
       points.push_back(gp.y());
       points.push_back(gp.z());
     }
   }
-  else if(dim == 2){
+  else if(dim == 2) {
     if(parametricCoord.size() < 2) return;
     GFace *gf = static_cast<GFace *>(entity);
-    for(unsigned int i = 0; i < parametricCoord.size(); i += 2){
+    for(unsigned int i = 0; i < parametricCoord.size(); i += 2) {
       SPoint2 param(parametricCoord[i], parametricCoord[i + 1]);
       GPoint gp = gf->point(param);
       points.push_back(gp.x());
@@ -568,31 +621,33 @@ GMSH_API void gmsh::model::getValue(const int dim,
   }
 }
 
-GMSH_API void gmsh::model::getDerivative(const int dim,
-                                         const int tag,
-                                         const std::vector<double> &parametricCoord,
-                                         std::vector<double> &deriv)
+GMSH_API void
+gmsh::model::getDerivative(const int dim, const int tag,
+                           const std::vector<double> &parametricCoord,
+                           std::vector<double> &deriv)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   deriv.clear();
   GEntity *entity = GModel::current()->getEntityByTag(dim, tag);
-  if(!entity){
+  if(!entity) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(dim == 1){
+  if(dim == 1) {
     GEdge *ge = static_cast<GEdge *>(entity);
-    for(unsigned int i = 0; i < parametricCoord.size(); i++){
+    for(unsigned int i = 0; i < parametricCoord.size(); i++) {
       SVector3 d = ge->firstDer(parametricCoord[i]);
       deriv.push_back(d.x());
       deriv.push_back(d.y());
       deriv.push_back(d.z());
     }
   }
-  else if(dim == 2){
+  else if(dim == 2) {
     if(parametricCoord.size() < 2) return;
     GFace *gf = static_cast<GFace *>(entity);
-    for(unsigned int i = 0; i < parametricCoord.size(); i += 2){
+    for(unsigned int i = 0; i < parametricCoord.size(); i += 2) {
       SPoint2 param(parametricCoord[i], parametricCoord[i + 1]);
       Pair<SVector3, SVector3> d = gf->firstDer(param);
       deriv.push_back(d.left().x());
@@ -605,43 +660,45 @@ GMSH_API void gmsh::model::getDerivative(const int dim,
   }
 }
 
-GMSH_API void gmsh::model::getCurvature(const int dim,
-                                        const int tag,
-                                        const std::vector<double> &parametricCoord,
-                                        std::vector<double> &curvatures)
+GMSH_API void
+gmsh::model::getCurvature(const int dim, const int tag,
+                          const std::vector<double> &parametricCoord,
+                          std::vector<double> &curvatures)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   curvatures.clear();
   GEntity *entity = GModel::current()->getEntityByTag(dim, tag);
-  if(!entity){
+  if(!entity) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(dim == 1){
+  if(dim == 1) {
     GEdge *ge = static_cast<GEdge *>(entity);
     for(unsigned int i = 0; i < parametricCoord.size(); i++)
       curvatures.push_back(ge->curvature(parametricCoord[i]));
   }
-  else if(dim == 2){
+  else if(dim == 2) {
     if(parametricCoord.size() < 2) return;
     GFace *gf = static_cast<GFace *>(entity);
-    for(unsigned int i = 0; i < parametricCoord.size(); i += 2){
+    for(unsigned int i = 0; i < parametricCoord.size(); i += 2) {
       SPoint2 param(parametricCoord[i], parametricCoord[i + 1]);
       curvatures.push_back(gf->curvatureMax(param));
     }
   }
 }
 
-GMSH_API void gmsh::model::getPrincipalCurvatures(const int tag,
-                                                  const std::vector<double> &parametricCoord,
-                                                  std::vector<double> &curvaturesMax,
-                                                  std::vector<double> &curvaturesMin,
-                                                  std::vector<double> &directionsMax,
-                                                  std::vector<double> &directionsMin)
+GMSH_API void gmsh::model::getPrincipalCurvatures(
+  const int tag, const std::vector<double> &parametricCoord,
+  std::vector<double> &curvaturesMax, std::vector<double> &curvaturesMin,
+  std::vector<double> &directionsMax, std::vector<double> &directionsMin)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GFace *gf = GModel::current()->getFaceByTag(tag);
-  if(!gf){
+  if(!gf) {
     Msg::Error("%s does not exist", _getEntityName(2, tag).c_str());
     throw 2;
   }
@@ -650,7 +707,7 @@ GMSH_API void gmsh::model::getPrincipalCurvatures(const int tag,
   directionsMax.clear();
   directionsMin.clear();
   if(parametricCoord.size() < 2) return;
-  for(unsigned int i = 0; i < parametricCoord.size(); i += 2){
+  for(unsigned int i = 0; i < parametricCoord.size(); i += 2) {
     SPoint2 param(parametricCoord[i], parametricCoord[i + 1]);
     double cmin, cmax;
     SVector3 dmin, dmax;
@@ -670,15 +727,17 @@ GMSH_API void gmsh::model::getNormal(const int tag,
                                      const std::vector<double> &parametricCoord,
                                      std::vector<double> &normals)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GFace *gf = GModel::current()->getFaceByTag(tag);
-  if(!gf){
+  if(!gf) {
     Msg::Error("%s does not exist", _getEntityName(2, tag).c_str());
     throw 2;
   }
   normals.clear();
   if(parametricCoord.size() < 2) return;
-  for(unsigned int i = 0; i < parametricCoord.size(); i += 2){
+  for(unsigned int i = 0; i < parametricCoord.size(); i += 2) {
     SPoint2 param(parametricCoord[i], parametricCoord[i + 1]);
     SVector3 n = gf->normal(param);
     normals.push_back(n.x());
@@ -691,29 +750,37 @@ GMSH_API void gmsh::model::getNormal(const int tag,
 
 GMSH_API void gmsh::model::mesh::generate(const int dim)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->mesh(dim);
   CTX::instance()->mesh.changed = ENT_ALL;
 }
 
 GMSH_API void gmsh::model::mesh::partition(const int numPart)
 {
-  if(!_isInitialized()){ throw -1; }
-  GModel::current()->partitionMesh(numPart >= 0 ? numPart :
-                                   CTX::instance()->mesh.numPartitions);
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  GModel::current()->partitionMesh(
+    numPart >= 0 ? numPart : CTX::instance()->mesh.numPartitions);
   CTX::instance()->mesh.changed = ENT_ALL;
 }
 
 GMSH_API void gmsh::model::mesh::refine()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->refineMesh(CTX::instance()->mesh.secondOrderLinear);
   CTX::instance()->mesh.changed = ENT_ALL;
 }
 
 GMSH_API void gmsh::model::mesh::setOrder(const int order)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->setOrderN(order, CTX::instance()->mesh.secondOrderLinear,
                                CTX::instance()->mesh.secondOrderIncomplete);
   CTX::instance()->mesh.changed = ENT_ALL;
@@ -721,8 +788,10 @@ GMSH_API void gmsh::model::mesh::setOrder(const int order)
 
 GMSH_API void gmsh::model::mesh::getLastEntityError(vectorpair &dimTags)
 {
-  if(!_isInitialized()){ throw -1; }
-  std::vector<GEntity*> e = GModel::current()->getLastMeshEntityError();
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  std::vector<GEntity *> e = GModel::current()->getLastMeshEntityError();
   dimTags.clear();
   for(unsigned int i = 0; i < e.size(); i++)
     dimTags.push_back(std::pair<int, int>(e[i]->dim(), e[i]->tag()));
@@ -730,11 +799,12 @@ GMSH_API void gmsh::model::mesh::getLastEntityError(vectorpair &dimTags)
 
 GMSH_API void gmsh::model::mesh::getLastNodeError(std::vector<int> &nodeTags)
 {
-  if(!_isInitialized()){ throw -1; }
-  std::vector<MVertex*> v = GModel::current()->getLastMeshVertexError();
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  std::vector<MVertex *> v = GModel::current()->getLastMeshVertexError();
   nodeTags.clear();
-  for(unsigned int i = 0; i < v.size(); i++)
-    nodeTags.push_back(v[i]->getNum());
+  for(unsigned int i = 0; i < v.size(); i++) nodeTags.push_back(v[i]->getNum());
 }
 
 static void _getAdditionalNodesOnBoundary(GEntity *entity,
@@ -743,15 +813,15 @@ static void _getAdditionalNodesOnBoundary(GEntity *entity,
                                           std::vector<double> &parametricCoord,
                                           bool parametric)
 {
-  std::vector<GFace*> f;
-  std::vector<GEdge*> e;
-  std::vector<GVertex*> v;
+  std::vector<GFace *> f;
+  std::vector<GEdge *> e;
+  std::vector<GVertex *> v;
   if(entity->dim() > 2) f = entity->faces();
   if(entity->dim() > 1) e = entity->edges();
   if(entity->dim() > 0) v = entity->vertices();
-  for(std::vector<GFace*>::iterator it = f.begin(); it != f.end(); it++){
+  for(std::vector<GFace *>::iterator it = f.begin(); it != f.end(); it++) {
     GFace *gf = *it;
-    for(unsigned int j = 0; j < gf->mesh_vertices.size(); j++){
+    for(unsigned int j = 0; j < gf->mesh_vertices.size(); j++) {
       MVertex *v = gf->mesh_vertices[j];
       nodeTags.push_back(v->getNum());
       coord.push_back(v->x());
@@ -759,17 +829,17 @@ static void _getAdditionalNodesOnBoundary(GEntity *entity,
       coord.push_back(v->z());
     }
   }
-  for(std::vector<GEdge*>::iterator it = e.begin(); it != e.end(); it++){
+  for(std::vector<GEdge *>::iterator it = e.begin(); it != e.end(); it++) {
     GEdge *ge = *it;
-    for(unsigned int j = 0; j < ge->mesh_vertices.size(); j++){
+    for(unsigned int j = 0; j < ge->mesh_vertices.size(); j++) {
       MVertex *v = ge->mesh_vertices[j];
       nodeTags.push_back(v->getNum());
       coord.push_back(v->x());
       coord.push_back(v->y());
       coord.push_back(v->z());
-      if(entity->dim() == 2 && parametric){
+      if(entity->dim() == 2 && parametric) {
         SPoint2 param;
-        if(!reparamMeshVertexOnFace(v, (GFace*)entity, param))
+        if(!reparamMeshVertexOnFace(v, (GFace *)entity, param))
           Msg::Warning("Failed to compute parameters of node %d on surface %d",
                        v->getNum(), entity->tag());
         parametricCoord.push_back(param.x());
@@ -777,25 +847,25 @@ static void _getAdditionalNodesOnBoundary(GEntity *entity,
       }
     }
   }
-  for(std::vector<GVertex*>::iterator it = v.begin(); it != v.end(); it++){
+  for(std::vector<GVertex *>::iterator it = v.begin(); it != v.end(); it++) {
     GVertex *gv = *it;
-    for(unsigned int j = 0; j < gv->mesh_vertices.size(); j++){
+    for(unsigned int j = 0; j < gv->mesh_vertices.size(); j++) {
       MVertex *v = gv->mesh_vertices[j];
       nodeTags.push_back(v->getNum());
       coord.push_back(v->x());
       coord.push_back(v->y());
       coord.push_back(v->z());
-      if(entity->dim() == 2 && parametric){
+      if(entity->dim() == 2 && parametric) {
         SPoint2 param;
-        if(!reparamMeshVertexOnFace(v, (GFace*)entity, param))
+        if(!reparamMeshVertexOnFace(v, (GFace *)entity, param))
           Msg::Warning("Failed to compute parameters of node %d on surface %d",
                        v->getNum(), entity->tag());
         parametricCoord.push_back(param.x());
         parametricCoord.push_back(param.y());
       }
-      else if(entity->dim() == 1 && parametric){
+      else if(entity->dim() == 1 && parametric) {
         double param;
-        if(!reparamMeshVertexOnEdge(v, (GEdge*)entity, param))
+        if(!reparamMeshVertexOnEdge(v, (GEdge *)entity, param))
           Msg::Warning("Failed to compute parameters of node %d on edge %d",
                        v->getNum(), entity->tag());
         parametricCoord.push_back(param);
@@ -807,43 +877,45 @@ static void _getAdditionalNodesOnBoundary(GEntity *entity,
 GMSH_API void gmsh::model::mesh::getNodes(std::vector<int> &nodeTags,
                                           std::vector<double> &coord,
                                           std::vector<double> &parametricCoord,
-                                          const int dim,
-                                          const int tag,
+                                          const int dim, const int tag,
                                           const bool includeBoundary)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   nodeTags.clear();
   coord.clear();
   parametricCoord.clear();
-  std::vector<GEntity*> entities;
-  if(dim >= 0 && tag >= 0){
+  std::vector<GEntity *> entities;
+  if(dim >= 0 && tag >= 0) {
     GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-    if(!ge){
+    if(!ge) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
     entities.push_back(ge);
   }
-  else{
+  else {
     GModel::current()->getEntities(entities, dim);
   }
-  for(unsigned int i = 0; i < entities.size(); i++){
+  for(unsigned int i = 0; i < entities.size(); i++) {
     GEntity *ge = entities[i];
-    for(unsigned int j = 0; j < ge->mesh_vertices.size(); j++){
+    for(unsigned int j = 0; j < ge->mesh_vertices.size(); j++) {
       MVertex *v = ge->mesh_vertices[j];
       nodeTags.push_back(v->getNum());
       coord.push_back(v->x());
       coord.push_back(v->y());
       coord.push_back(v->z());
-      if(dim > 0){
+      if(dim > 0) {
         double par;
-        for(int k = 0; k < dim; k++){
+        for(int k = 0; k < dim; k++) {
           if(v->getParameter(k, par)) parametricCoord.push_back(par);
         }
       }
     }
     if(includeBoundary)
-      _getAdditionalNodesOnBoundary(ge, nodeTags, coord, parametricCoord, dim > 0);
+      _getAdditionalNodesOnBoundary(ge, nodeTags, coord, parametricCoord,
+                                    dim > 0);
   }
 }
 
@@ -851,9 +923,11 @@ GMSH_API void gmsh::model::mesh::getNode(const int nodeTag,
                                          std::vector<double> &coord,
                                          std::vector<double> &parametricCoord)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   MVertex *v = GModel::current()->getMeshVertexByTag(nodeTag);
-  if(!v){
+  if(!v) {
     Msg::Error("Unknown node %d", nodeTag);
     throw 2;
   }
@@ -863,32 +937,34 @@ GMSH_API void gmsh::model::mesh::getNode(const int nodeTag,
   coord[2] = v->z();
   parametricCoord.reserve(2);
   double u;
-  if(v->getParameter(0, u))
-  parametricCoord.push_back(u);
-  if(v->getParameter(1, u))
-  parametricCoord.push_back(u);
+  if(v->getParameter(0, u)) parametricCoord.push_back(u);
+  if(v->getParameter(1, u)) parametricCoord.push_back(u);
 }
 
 GMSH_API void gmsh::model::mesh::rebuildNodeCache(bool onlyIfNecessary)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->rebuildMeshVertexCache(onlyIfNecessary);
 }
 
-GMSH_API void gmsh::model::mesh::getNodesForPhysicalGroup(const int dim,
-                                                          const int tag,
-                                                          std::vector<int> & nodeTags,
-                                                          std::vector<double> & coord)
+GMSH_API void
+gmsh::model::mesh::getNodesForPhysicalGroup(const int dim, const int tag,
+                                            std::vector<int> &nodeTags,
+                                            std::vector<double> &coord)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   nodeTags.clear();
   coord.clear();
-  std::vector<MVertex*> v;
+  std::vector<MVertex *> v;
   GModel::current()->getMeshVerticesForPhysicalGroup(dim, tag, v);
   if(v.empty()) return;
   nodeTags.resize(v.size());
   coord.resize(v.size() * 3);
-  for(unsigned int i = 0; i < v.size(); i++){
+  for(unsigned int i = 0; i < v.size(); i++) {
     nodeTags[i] = v[i]->getNum();
     coord[3 * i + 0] = v[i]->x();
     coord[3 * i + 1] = v[i]->y();
@@ -896,25 +972,25 @@ GMSH_API void gmsh::model::mesh::getNodesForPhysicalGroup(const int dim,
   }
 }
 
-GMSH_API void gmsh::model::mesh::setNodes(const int dim,
-                                          const int tag,
-                                          const std::vector<int> &nodeTags,
-                                          const std::vector<double> &coord,
-                                          const std::vector<double> &parametricCoord)
+GMSH_API void gmsh::model::mesh::setNodes(
+  const int dim, const int tag, const std::vector<int> &nodeTags,
+  const std::vector<double> &coord, const std::vector<double> &parametricCoord)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(coord.size() != 3 * nodeTags.size()){
+  if(coord.size() != 3 * nodeTags.size()) {
     Msg::Error("Wrong number of coordinates");
     throw 2;
   }
   bool param = false;
-  if(parametricCoord.size()){
-    if(parametricCoord.size() != dim * nodeTags.size()){
+  if(parametricCoord.size()) {
+    if(parametricCoord.size() != dim * nodeTags.size()) {
       Msg::Error("Wrong number of parametric coordinates");
       throw 2;
     }
@@ -922,70 +998,75 @@ GMSH_API void gmsh::model::mesh::setNodes(const int dim,
   }
   // delete nodes and elements; this will also delete the model mesh cache
   ge->deleteMesh();
-  for(unsigned int i = 0; i < nodeTags.size(); i++){
+  for(unsigned int i = 0; i < nodeTags.size(); i++) {
     int n = nodeTags[i];
     double x = coord[3 * i];
     double y = coord[3 * i + 1];
     double z = coord[3 * i + 2];
     MVertex *vv = 0;
-    if(param && dim == 1){
+    if(param && dim == 1) {
       double u = parametricCoord[i];
       vv = new MEdgeVertex(x, y, z, ge, u, n);
     }
-    else if(param && dim == 2){
+    else if(param && dim == 2) {
       double u = parametricCoord[2 * i];
       double v = parametricCoord[2 * i + 1];
       vv = new MFaceVertex(x, y, z, ge, u, v, n);
     }
     else
-    vv = new MVertex(x, y, z, ge, n);
+      vv = new MVertex(x, y, z, ge, n);
     ge->mesh_vertices.push_back(vv);
   }
 }
 
 GMSH_API void gmsh::model::mesh::reclassifyNodes()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->pruneMeshVertexAssociations();
 }
 
 static void _getElementTypeMap(int dim, int tag,
-                               std::map<int, std::vector<GEntity*> > &typeMap)
+                               std::map<int, std::vector<GEntity *> > &typeMap)
 {
-  std::vector<GEntity*> entities;
-  if(dim >= 0 && tag >= 0){
+  std::vector<GEntity *> entities;
+  if(dim >= 0 && tag >= 0) {
     GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-    if(!ge){
+    if(!ge) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
     entities.push_back(ge);
   }
-  else{
+  else {
     GModel::current()->getEntities(entities, dim);
   }
-  for(unsigned int i = 0; i < entities.size(); i++){
+  for(unsigned int i = 0; i < entities.size(); i++) {
     GEntity *ge = entities[i];
-    switch(ge->dim()){
+    switch(ge->dim()) {
     case 0: {
-      GVertex *v = static_cast<GVertex*>(ge);
+      GVertex *v = static_cast<GVertex *>(ge);
       if(v->points.size())
         typeMap[v->points.front()->getTypeForMSH()].push_back(ge);
-      break; }
+      break;
+    }
     case 1: {
-      GEdge *e = static_cast<GEdge*>(ge);
+      GEdge *e = static_cast<GEdge *>(ge);
       if(e->lines.size())
         typeMap[e->lines.front()->getTypeForMSH()].push_back(ge);
-      break; }
+      break;
+    }
     case 2: {
-      GFace *f = static_cast<GFace*>(ge);
+      GFace *f = static_cast<GFace *>(ge);
       if(f->triangles.size())
         typeMap[f->triangles.front()->getTypeForMSH()].push_back(ge);
       if(f->quadrangles.size())
         typeMap[f->quadrangles.front()->getTypeForMSH()].push_back(ge);
-      break; }
+      break;
+    }
     case 3: {
-      GRegion *r = static_cast<GRegion*>(ge);
+      GRegion *r = static_cast<GRegion *>(ge);
       if(r->tetrahedra.size())
         typeMap[r->tetrahedra.front()->getTypeForMSH()].push_back(ge);
       if(r->hexahedra.size())
@@ -994,54 +1075,57 @@ static void _getElementTypeMap(int dim, int tag,
         typeMap[r->prisms.front()->getTypeForMSH()].push_back(ge);
       if(r->pyramids.size())
         typeMap[r->pyramids.front()->getTypeForMSH()].push_back(ge);
-      break; }
+      break;
+    }
     }
   }
 }
 
-static unsigned int _getNumElementsByType(const int elementType,
-                                          const int tag)
+static unsigned int _getNumElementsByType(const int elementType, const int tag)
 {
   int dim = ElementType::getDimension(elementType);
-  std::vector<GEntity*> entities;
-  if(tag >= 0){
+  std::vector<GEntity *> entities;
+  if(tag >= 0) {
     GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-    if(!ge){
+    if(!ge) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
     entities.push_back(ge);
   }
-  else{
+  else {
     GModel::current()->getEntities(entities, dim);
   }
   unsigned int numberElement = 0;
-  for(unsigned int i = 0; i < entities.size(); i++){
+  for(unsigned int i = 0; i < entities.size(); i++) {
     GEntity *ge = entities[i];
-    switch(ge->dim()){
+    switch(ge->dim()) {
     case 0: {
-      GVertex *v = static_cast<GVertex*>(ge);
+      GVertex *v = static_cast<GVertex *>(ge);
       if(v->points.size())
         if(v->points.front()->getTypeForMSH() == elementType)
           numberElement += v->points.size();
-      break; }
+      break;
+    }
     case 1: {
-      GEdge *e = static_cast<GEdge*>(ge);
+      GEdge *e = static_cast<GEdge *>(ge);
       if(e->lines.size())
         if(e->lines.front()->getTypeForMSH() == elementType)
           numberElement += e->lines.size();
-      break; }
+      break;
+    }
     case 2: {
-      GFace *f = static_cast<GFace*>(ge);
+      GFace *f = static_cast<GFace *>(ge);
       if(f->triangles.size())
         if(f->triangles.front()->getTypeForMSH() == elementType)
           numberElement += f->triangles.size();
       if(f->quadrangles.size())
         if(f->quadrangles.front()->getTypeForMSH() == elementType)
           numberElement += f->quadrangles.size();
-      break; }
+      break;
+    }
     case 3: {
-      GRegion *r = static_cast<GRegion*>(ge);
+      GRegion *r = static_cast<GRegion *>(ge);
       if(r->tetrahedra.size())
         if(r->tetrahedra.front()->getTypeForMSH() == elementType)
           numberElement += r->tetrahedra.size();
@@ -1054,38 +1138,40 @@ static unsigned int _getNumElementsByType(const int elementType,
       if(r->pyramids.size())
         if(r->pyramids.front()->getTypeForMSH() == elementType)
           numberElement += r->pyramids.size();
-      break; }
+      break;
+    }
     }
   }
 
   return numberElement;
 }
 
-GMSH_API void gmsh::model::mesh::getElements(std::vector<int> &elementTypes,
-                                             std::vector<std::vector<int> > &elementTags,
-                                             std::vector<std::vector<int> > &nodeTags,
-                                             const int dim,
-                                             const int tag)
+GMSH_API void gmsh::model::mesh::getElements(
+  std::vector<int> &elementTypes, std::vector<std::vector<int> > &elementTags,
+  std::vector<std::vector<int> > &nodeTags, const int dim, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   elementTypes.clear();
   elementTags.clear();
   nodeTags.clear();
-  std::map<int, std::vector<GEntity*> > typeMap;
+  std::map<int, std::vector<GEntity *> > typeMap;
   _getElementTypeMap(dim, tag, typeMap);
-  for(std::map<int, std::vector<GEntity*> >::const_iterator it = typeMap.begin();
-      it != typeMap.end(); it++){
+  for(std::map<int, std::vector<GEntity *> >::const_iterator it =
+        typeMap.begin();
+      it != typeMap.end(); it++) {
     elementTypes.push_back(it->first);
     elementTags.push_back(std::vector<int>());
     nodeTags.push_back(std::vector<int>());
     int elementType = it->first;
-    for(unsigned int i = 0; i < it->second.size(); i++){
+    for(unsigned int i = 0; i < it->second.size(); i++) {
       GEntity *ge = it->second[i];
-      for(unsigned int j = 0; j < ge->getNumMeshElements(); j++){
+      for(unsigned int j = 0; j < ge->getNumMeshElements(); j++) {
         MElement *e = ge->getMeshElement(j);
-        if(e->getTypeForMSH() == elementType){
+        if(e->getTypeForMSH() == elementType) {
           elementTags.back().push_back(e->getNum());
-          for(std::size_t k = 0; k < e->getNumVertices(); k++){
+          for(std::size_t k = 0; k < e->getNumVertices(); k++) {
             nodeTags.back().push_back(e->getVertex(k)->getNum());
           }
         }
@@ -1098,17 +1184,19 @@ GMSH_API void gmsh::model::mesh::getElement(const int elementTag,
                                             int &elementType,
                                             std::vector<int> &nodeTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   MElement *e = GModel::current()->getMeshElementByTag(elementTag);
-  if(!e){
+  if(!e) {
     Msg::Error("Unknown element %d", elementTag);
     throw 2;
   }
   elementType = e->getTypeForMSH();
   nodeTags.clear();
-  for(std::size_t i = 0; i < e->getNumVertices(); i++){
+  for(std::size_t i = 0; i < e->getNumVertices(); i++) {
     MVertex *v = e->getVertex(i);
-    if(!v){
+    if(!v) {
       Msg::Error("Unknown node in element %d", elementTag);
       throw 2;
     }
@@ -1116,26 +1204,25 @@ GMSH_API void gmsh::model::mesh::getElement(const int elementTag,
   }
 }
 
-GMSH_API void gmsh::model::mesh::getElementByCoordinates(const double x,
-                                                         const double y,
-                                                         const double z,
-                                                         int &elementTag,
-                                                         int &elementType,
-                                                         std::vector<int> &nodeTags)
+GMSH_API void gmsh::model::mesh::getElementByCoordinates(
+  const double x, const double y, const double z, int &elementTag,
+  int &elementType, std::vector<int> &nodeTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   SPoint3 p(x, y, z);
   MElement *e = GModel::current()->getMeshElementByCoord(p);
-  if(!e){
+  if(!e) {
     Msg::Error("No element found at (%g, %g, %g)", x, y, z);
     throw 2;
   }
   elementTag = e->getNum();
   elementType = e->getTypeForMSH();
   nodeTags.clear();
-  for(std::size_t i = 0; i < e->getNumVertices(); i++){
+  for(std::size_t i = 0; i < e->getNumVertices(); i++) {
     MVertex *v = e->getVertex(i);
-    if(!v){
+    if(!v) {
       Msg::Error("Unknown node in element %d", elementTag);
       throw 2;
     }
@@ -1143,55 +1230,56 @@ GMSH_API void gmsh::model::mesh::getElementByCoordinates(const double x,
   }
 }
 
-template<class T>
-static void _addElements(int dim, int tag, const std::vector<MElement*> &src,
-                         std::vector<T*> &dst)
+template <class T>
+static void _addElements(int dim, int tag, const std::vector<MElement *> &src,
+                         std::vector<T *> &dst)
 {
   for(unsigned int i = 0; i < src.size(); i++)
-  dst.push_back(static_cast<T*>(src[i]));
+    dst.push_back(static_cast<T *>(src[i]));
 }
 
-GMSH_API void gmsh::model::mesh::setElements(const int dim,
-                                             const int tag,
-                                             const std::vector<int> &elementTypes,
-                                             const std::vector<std::vector<int> > &elementTags,
-                                             const std::vector<std::vector<int> > &nodeTags)
+GMSH_API void gmsh::model::mesh::setElements(
+  const int dim, const int tag, const std::vector<int> &elementTypes,
+  const std::vector<std::vector<int> > &elementTags,
+  const std::vector<std::vector<int> > &nodeTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(elementTypes.size() != elementTags.size()){
+  if(elementTypes.size() != elementTags.size()) {
     Msg::Error("Wrong number of element tags");
     throw 2;
   }
-  if(elementTypes.size() != nodeTags.size()){
+  if(elementTypes.size() != nodeTags.size()) {
     Msg::Error("Wrong number of node tags");
     throw 2;
   }
   // delete only elements; this will also delete the model mesh cache
   ge->deleteMesh(true);
-  for(unsigned int i = 0; i < elementTypes.size(); i++){
+  for(unsigned int i = 0; i < elementTypes.size(); i++) {
     int type = elementTypes[i];
     unsigned int numEle = elementTags[i].size();
     unsigned int numVertPerEle = MElement::getInfoMSH(type);
     if(!numEle) continue;
-    if(numEle * numVertPerEle != nodeTags[i].size()){
+    if(numEle * numVertPerEle != nodeTags[i].size()) {
       Msg::Error("Wrong number of node tags for element type %d", type);
       throw 2;
     }
-    std::vector<MElement*> elements(numEle);
-    std::vector<MVertex*> nodes(numVertPerEle);
-    for(unsigned int j = 0; j < numEle; j++){
+    std::vector<MElement *> elements(numEle);
+    std::vector<MVertex *> nodes(numVertPerEle);
+    for(unsigned int j = 0; j < numEle; j++) {
       int etag = elementTags[i][j];
       MElementFactory f;
-      for(unsigned int k = 0; k < numVertPerEle; k++){
+      for(unsigned int k = 0; k < numVertPerEle; k++) {
         int vtag = nodeTags[i][numVertPerEle * j + k];
         // this will rebuild the node cache if necessary
         nodes[k] = GModel::current()->getMeshVertexByTag(vtag);
-        if(!nodes[k]){
+        if(!nodes[k]) {
           Msg::Error("Unknown node %d", vtag);
           throw 2;
         }
@@ -1199,69 +1287,72 @@ GMSH_API void gmsh::model::mesh::setElements(const int dim,
       elements[j] = f.create(type, nodes, etag);
     }
     bool ok = true;
-    switch(dim){
+    switch(dim) {
     case 0:
       if(elements[0]->getType() == TYPE_PNT)
-        _addElements(dim, tag, elements, static_cast<GVertex*>(ge)->points);
+        _addElements(dim, tag, elements, static_cast<GVertex *>(ge)->points);
       else
         ok = false;
       break;
     case 1:
       if(elements[0]->getType() == TYPE_LIN)
-        _addElements(dim, tag, elements, static_cast<GEdge*>(ge)->lines);
+        _addElements(dim, tag, elements, static_cast<GEdge *>(ge)->lines);
       else
         ok = false;
       break;
     case 2:
       if(elements[0]->getType() == TYPE_TRI)
-        _addElements(dim, tag, elements, static_cast<GFace*>(ge)->triangles);
+        _addElements(dim, tag, elements, static_cast<GFace *>(ge)->triangles);
       else if(elements[0]->getType() == TYPE_QUA)
-        _addElements(dim, tag, elements, static_cast<GFace*>(ge)->quadrangles);
+        _addElements(dim, tag, elements, static_cast<GFace *>(ge)->quadrangles);
       else
         ok = false;
       break;
     case 3:
       if(elements[0]->getType() == TYPE_TET)
-        _addElements(dim, tag, elements, static_cast<GRegion*>(ge)->tetrahedra);
+        _addElements(dim, tag, elements,
+                     static_cast<GRegion *>(ge)->tetrahedra);
       else if(elements[0]->getType() == TYPE_HEX)
-        _addElements(dim, tag, elements, static_cast<GRegion*>(ge)->hexahedra);
+        _addElements(dim, tag, elements, static_cast<GRegion *>(ge)->hexahedra);
       else if(elements[0]->getType() == TYPE_PRI)
-        _addElements(dim, tag, elements, static_cast<GRegion*>(ge)->prisms);
+        _addElements(dim, tag, elements, static_cast<GRegion *>(ge)->prisms);
       else if(elements[0]->getType() == TYPE_PYR)
-        _addElements(dim, tag, elements, static_cast<GRegion*>(ge)->pyramids);
+        _addElements(dim, tag, elements, static_cast<GRegion *>(ge)->pyramids);
       else
         ok = false;
       break;
     }
-    if(!ok){
-      Msg::Error("Wrong type of element for %s", _getEntityName(dim, tag).c_str());
+    if(!ok) {
+      Msg::Error("Wrong type of element for %s",
+                 _getEntityName(dim, tag).c_str());
       throw 2;
     }
   }
 }
 
 GMSH_API void gmsh::model::mesh::getElementTypes(std::vector<int> &elementTypes,
-                                                 const int dim,
-                                                 const int tag)
+                                                 const int dim, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   elementTypes.clear();
-  std::map<int, std::vector<GEntity*> > typeMap;
+  std::map<int, std::vector<GEntity *> > typeMap;
   _getElementTypeMap(dim, tag, typeMap);
-  for(std::map<int, std::vector<GEntity*> >::const_iterator it = typeMap.begin();
-      it != typeMap.end(); it++){
+  for(std::map<int, std::vector<GEntity *> >::const_iterator it =
+        typeMap.begin();
+      it != typeMap.end(); it++) {
     elementTypes.push_back(it->first);
   }
 }
 
-GMSH_API void gmsh::model::mesh::getElementProperties(const int elementType,
-                                                      std::string &name,
-                                                      int &dim,
-                                                      int &order,
-                                                      int &numNodes,
-                                                      std::vector<double> &parametricCoord)
+GMSH_API void gmsh::model::mesh::getElementProperties(
+  const int elementType, std::string &name, int &dim, int &order, int &numNodes,
+  std::vector<double> &parametricCoord)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   const char *n;
   numNodes = MElement::getInfoMSH(elementType, &n);
   name = n;
@@ -1280,15 +1371,16 @@ GMSH_API void gmsh::model::mesh::getElementProperties(const int elementType,
   delete basis;
 }
 
-GMSH_API void gmsh::model::mesh::getElementsByType(const int elementType,
-                                                   std::vector<int> &elementTags,
-                                                   std::vector<int> &nodeTags,
-                                                   const int tag,
-                                                   const size_t task,
-                                                   const size_t numTasks)
+GMSH_API void
+gmsh::model::mesh::getElementsByType(const int elementType,
+                                     std::vector<int> &elementTags,
+                                     std::vector<int> &nodeTags, const int tag,
+                                     const size_t task, const size_t numTasks)
 {
-  if(!_isInitialized()){ throw -1; }
-  std::map<int, std::vector<GEntity*> > typeMap;
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  std::map<int, std::vector<GEntity *> > typeMap;
   int dim = ElementType::getDimension(elementType);
   _getElementTypeMap(dim, tag, typeMap);
   const std::size_t numElements = _getNumElementsByType(elementType, tag);
@@ -1298,35 +1390,35 @@ GMSH_API void gmsh::model::mesh::getElementsByType(const int elementType,
   // check arrays
   bool haveElementTags = elementTags.size();
   bool haveNodeTags = nodeTags.size();
-  if(!haveElementTags && !haveNodeTags){
+  if(!haveElementTags && !haveNodeTags) {
     if(numTasks > 1)
-    Msg::Error("ElementTags and nodeTags should be preallocated "
-               "if numTasks > 1");
+      Msg::Error("ElementTags and nodeTags should be preallocated "
+                 "if numTasks > 1");
     haveElementTags = haveNodeTags = true;
     preallocateElementsByType(elementType, haveElementTags, haveNodeTags,
                               elementTags, nodeTags);
   }
-  if(haveElementTags && (elementTags.size() < numElements)){
-    Msg::Error("Wrong size of elementTags array (%d < %d)",
-               elementTags.size(), numElements);
+  if(haveElementTags && (elementTags.size() < numElements)) {
+    Msg::Error("Wrong size of elementTags array (%d < %d)", elementTags.size(),
+               numElements);
     throw 4;
   }
-  if(haveNodeTags && (nodeTags.size() < numElements * numNodes)){
-    Msg::Error("Wrong size of nodeTags array (%d < %d)",
-               nodeTags.size(), numElements * numNodes);
+  if(haveNodeTags && (nodeTags.size() < numElements * numNodes)) {
+    Msg::Error("Wrong size of nodeTags array (%d < %d)", nodeTags.size(),
+               numElements * numNodes);
     throw 4;
   }
   size_t o = 0;
   size_t idx = begin * numNodes;
-  for(unsigned int i = 0; i < typeMap[elementType].size(); i++){
+  for(unsigned int i = 0; i < typeMap[elementType].size(); i++) {
     int familyType = ElementType::getParentType(elementType);
     GEntity *ge = typeMap[elementType][i];
-    for(unsigned int j = 0; j < ge->getNumMeshElementsByType(familyType); j++){
-      if(o >= begin && o < end){
+    for(unsigned int j = 0; j < ge->getNumMeshElementsByType(familyType); j++) {
+      if(o >= begin && o < end) {
         MElement *e = ge->getMeshElementByType(familyType, j);
         if(haveElementTags) elementTags[o] = e->getNum();
-        if(haveNodeTags){
-          for(std::size_t k = 0; k < e->getNumVertices(); k++){
+        if(haveNodeTags) {
+          for(std::size_t k = 0; k < e->getNumVertices(); k++) {
             nodeTags[idx++] = e->getVertex(k)->getNum();
           }
         }
@@ -1336,21 +1428,21 @@ GMSH_API void gmsh::model::mesh::getElementsByType(const int elementType,
   }
 }
 
-GMSH_API void gmsh::model::mesh::preallocateElementsByType(const int elementType,
-                                                           const bool elementTag,
-                                                           const bool nodeTag,
-                                                           std::vector<int> &elementTags,
-                                                           std::vector<int> &nodeTags,
-                                                           const int tag)
+GMSH_API void gmsh::model::mesh::preallocateElementsByType(
+  const int elementType, const bool elementTag, const bool nodeTag,
+  std::vector<int> &elementTags, std::vector<int> &nodeTags, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   const unsigned int numElements = _getNumElementsByType(elementType, tag);
-  const unsigned int numNodesByElements = ElementType::getNumVertices(elementType);
-  if(elementTag){
+  const unsigned int numNodesByElements =
+    ElementType::getNumVertices(elementType);
+  if(elementTag) {
     elementTags.clear();
     elementTags.resize(numElements, 0);
   }
-  if(nodeTag){
+  if(nodeTag) {
     nodeTags.clear();
     nodeTags.resize(numElements * numNodesByElements, 0);
   }
@@ -1359,7 +1451,7 @@ GMSH_API void gmsh::model::mesh::preallocateElementsByType(const int elementType
 static bool _getIntegrationInfo(const std::string &intType,
                                 std::string &intName, int &intOrder)
 {
-  if(intType.substr(0, 5) == "Gauss"){
+  if(intType.substr(0, 5) == "Gauss") {
     intName = "Gauss";
     intOrder = atoi(intType.substr(5).c_str());
     return true;
@@ -1368,21 +1460,22 @@ static bool _getIntegrationInfo(const std::string &intType,
 }
 
 static bool _getFunctionSpaceInfo(const std::string &fsType,
-                                  std::string &fsName, int &fsOrder, int &fsComp)
+                                  std::string &fsName, int &fsOrder,
+                                  int &fsComp)
 {
-  if(fsType.empty() || fsType == "None"){
+  if(fsType.empty() || fsType == "None") {
     fsName = "";
     fsOrder = 0;
     fsComp = 0;
     return true;
   }
-  if(fsType == "IsoParametric" || fsType == "Lagrange"){
+  if(fsType == "IsoParametric" || fsType == "Lagrange") {
     fsName = "Lagrange";
     fsOrder = -1;
     fsComp = 1;
     return true;
   }
-  if(fsType == "GradIsoParametric" || fsType == "GradLagrange"){
+  if(fsType == "GradIsoParametric" || fsType == "GradLagrange") {
     fsName = "GradLagrange";
     fsOrder = -1;
     fsComp = 3;
@@ -1391,23 +1484,22 @@ static bool _getFunctionSpaceInfo(const std::string &fsType,
   return false;
 }
 
-GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
-                                              const std::string &integrationType,
-                                              std::vector<double> &jacobians,
-                                              std::vector<double> &determinants,
-                                              std::vector<double> &points,
-                                              const int tag,
-                                              const size_t task,
-                                              const size_t numTasks)
+GMSH_API void gmsh::model::mesh::getJacobians(
+  const int elementType, const std::string &integrationType,
+  std::vector<double> &jacobians, std::vector<double> &determinants,
+  std::vector<double> &points, const int tag, const size_t task,
+  const size_t numTasks)
 {
-  if(!_isInitialized()){ throw -1; }
-  std::map<int, std::vector<GEntity*> > typeMap;
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  std::map<int, std::vector<GEntity *> > typeMap;
   int dim = ElementType::getDimension(elementType);
   _getElementTypeMap(dim, tag, typeMap);
-  const std::vector<GEntity*> &entities(typeMap[elementType]);
+  const std::vector<GEntity *> &entities(typeMap[elementType]);
   std::string intName = "";
   int intOrder = 0;
-  if(!_getIntegrationInfo(integrationType, intName, intOrder)){
+  if(!_getIntegrationInfo(integrationType, intName, intOrder)) {
     Msg::Error("Unknown quadrature type '%s'", integrationType.c_str());
     throw 2;
   }
@@ -1416,7 +1508,7 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
   fullMatrix<double> pts;
   fullVector<double> weights;
   gaussIntegration::get(familyType, intOrder, pts, weights);
-  if(pts.size1() != weights.size() || pts.size2() != 3){
+  if(pts.size1() != weights.size() || pts.size2() != 3) {
     Msg::Error("Wrong integration point format");
     throw 3;
   }
@@ -1425,54 +1517,56 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
   bool haveJacobians = jacobians.size();
   bool haveDeterminants = determinants.size();
   bool havePoints = points.size();
-  if(!haveDeterminants && !haveJacobians && !havePoints){
+  if(!haveDeterminants && !haveJacobians && !havePoints) {
     if(numTasks > 1)
       Msg::Error("Jacobians, determinants and points should be preallocated "
                  "if numTasks > 1");
     haveJacobians = haveDeterminants = havePoints = true;
-    preallocateJacobians(elementType, integrationType,
-                         haveJacobians, haveDeterminants, havePoints,
-                         jacobians, determinants, points, tag);
+    preallocateJacobians(elementType, integrationType, haveJacobians,
+                         haveDeterminants, havePoints, jacobians, determinants,
+                         points, tag);
   }
   // get data
   {
     int n = 0;
-    for(unsigned int i = 0; i < entities.size(); i++){
+    for(unsigned int i = 0; i < entities.size(); i++) {
       GEntity *ge = entities[i];
       n += ge->getNumMeshElementsByType(familyType);
     }
     const size_t begin = (task * n) / numTasks;
     const size_t end = ((task + 1) * n) / numTasks;
-    if(haveDeterminants && (end * numIntPoints > determinants.size())){
+    if(haveDeterminants && (end * numIntPoints > determinants.size())) {
       Msg::Error("Wrong size of determinants array (%d < %d)",
-                 determinants.size(), end*numIntPoints);
+                 determinants.size(), end * numIntPoints);
       throw 4;
     }
-    if(haveJacobians && (9 * end * numIntPoints > jacobians.size())){
-      Msg::Error("Wrong size of jacobians array (%d < %d)",
-                 jacobians.size(), 9 * end * numIntPoints);
+    if(haveJacobians && (9 * end * numIntPoints > jacobians.size())) {
+      Msg::Error("Wrong size of jacobians array (%d < %d)", jacobians.size(),
+                 9 * end * numIntPoints);
       throw 4;
     }
-    if(havePoints && (3 * end * numIntPoints > points.size())){
-      Msg::Error("Wrong size of points array (%d < %d)",
-                 points.size(), 3 * end * numIntPoints);
+    if(havePoints && (3 * end * numIntPoints > points.size())) {
+      Msg::Error("Wrong size of points array (%d < %d)", points.size(),
+                 3 * end * numIntPoints);
       throw 4;
     }
-    if(haveDeterminants && haveJacobians && havePoints){
-      std::vector< std::vector<SVector3> > gsf;
+    if(haveDeterminants && haveJacobians && havePoints) {
+      std::vector<std::vector<SVector3> > gsf;
       size_t o = 0;
       size_t idx = begin * numIntPoints;
-      for(unsigned int i = 0; i < entities.size(); i++){
+      for(unsigned int i = 0; i < entities.size(); i++) {
         GEntity *ge = entities[i];
-        const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-        for(unsigned int j = 0; j < numMeshElements; j++){
-          if(o >= begin && o < end){
+        const unsigned int numMeshElements =
+          ge->getNumMeshElementsByType(familyType);
+        for(unsigned int j = 0; j < numMeshElements; j++) {
+          if(o >= begin && o < end) {
             MElement *e = ge->getMeshElementByType(familyType, j);
-            if(gsf.size() == 0){
+            if(gsf.size() == 0) {
               gsf.resize(numIntPoints);
-              for(int k = 0; k < numIntPoints; k++){
+              for(int k = 0; k < numIntPoints; k++) {
                 double value[1256][3];
-                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2), value);
+                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2),
+                                         value);
                 gsf[k].resize(e->getNumShapeFunctions());
                 for(int l = 0; l < e->getNumShapeFunctions(); l++) {
                   gsf[k][l][0] = value[l][0];
@@ -1481,9 +1575,9 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
                 }
               }
             }
-            for(int k = 0; k < numIntPoints; k++){
-              e->pnt(pts(k, 0), pts(k, 1), pts(k, 2), &points[idx*3]);
-              determinants[idx] = e->getJacobian(gsf[k], &jacobians[idx*9]);
+            for(int k = 0; k < numIntPoints; k++) {
+              e->pnt(pts(k, 0), pts(k, 1), pts(k, 2), &points[idx * 3]);
+              determinants[idx] = e->getJacobian(gsf[k], &jacobians[idx * 9]);
               idx++;
             }
           }
@@ -1491,21 +1585,23 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
         }
       }
     }
-    else if(haveDeterminants && haveJacobians && !havePoints){
-      std::vector< std::vector<SVector3> > gsf;
+    else if(haveDeterminants && haveJacobians && !havePoints) {
+      std::vector<std::vector<SVector3> > gsf;
       size_t o = 0;
       size_t idx = begin * numIntPoints;
-      for(unsigned int i = 0; i < entities.size(); i++){
+      for(unsigned int i = 0; i < entities.size(); i++) {
         GEntity *ge = entities[i];
-        const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-        for(unsigned int j = 0; j < numMeshElements; j++){
-          if(o >= begin && o < end){
+        const unsigned int numMeshElements =
+          ge->getNumMeshElementsByType(familyType);
+        for(unsigned int j = 0; j < numMeshElements; j++) {
+          if(o >= begin && o < end) {
             MElement *e = ge->getMeshElementByType(familyType, j);
-            if(gsf.size() == 0){
+            if(gsf.size() == 0) {
               gsf.resize(numIntPoints);
-              for(int k = 0; k < numIntPoints; k++){
+              for(int k = 0; k < numIntPoints; k++) {
                 double value[1256][3];
-                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2), value);
+                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2),
+                                         value);
                 gsf[k].resize(e->getNumShapeFunctions());
                 for(int l = 0; l < e->getNumShapeFunctions(); l++) {
                   gsf[k][l][0] = value[l][0];
@@ -1514,8 +1610,8 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
                 }
               }
             }
-            for(int k = 0; k < numIntPoints; k++){
-              determinants[idx] = e->getJacobian(gsf[k], &jacobians[idx*9]);
+            for(int k = 0; k < numIntPoints; k++) {
+              determinants[idx] = e->getJacobian(gsf[k], &jacobians[idx * 9]);
               idx++;
             }
           }
@@ -1523,22 +1619,24 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
         }
       }
     }
-    else if(haveDeterminants && !haveJacobians && havePoints){
+    else if(haveDeterminants && !haveJacobians && havePoints) {
       std::vector<double> jac(9, 0.);
-      std::vector< std::vector<SVector3> > gsf;
+      std::vector<std::vector<SVector3> > gsf;
       size_t o = 0;
       size_t idx = begin * numIntPoints;
-      for(unsigned int i = 0; i < entities.size(); i++){
+      for(unsigned int i = 0; i < entities.size(); i++) {
         GEntity *ge = entities[i];
-        const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-        for(unsigned int j = 0; j < numMeshElements; j++){
-          if(o >= begin && o < end){
+        const unsigned int numMeshElements =
+          ge->getNumMeshElementsByType(familyType);
+        for(unsigned int j = 0; j < numMeshElements; j++) {
+          if(o >= begin && o < end) {
             MElement *e = ge->getMeshElementByType(familyType, j);
-            if(gsf.size() == 0){
+            if(gsf.size() == 0) {
               gsf.resize(numIntPoints);
-              for(int k = 0; k < numIntPoints; k++){
+              for(int k = 0; k < numIntPoints; k++) {
                 double value[1256][3];
-                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2), value);
+                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2),
+                                         value);
                 gsf[k].resize(e->getNumShapeFunctions());
                 for(int l = 0; l < e->getNumShapeFunctions(); l++) {
                   gsf[k][l][0] = value[l][0];
@@ -1547,8 +1645,8 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
                 }
               }
             }
-            for(int k = 0; k < numIntPoints; k++){
-              e->pnt(pts(k, 0), pts(k, 1), pts(k, 2), &points[idx*3]);
+            for(int k = 0; k < numIntPoints; k++) {
+              e->pnt(pts(k, 0), pts(k, 1), pts(k, 2), &points[idx * 3]);
               determinants[idx] = e->getJacobian(gsf[k], &jac[0]);
               idx++;
             }
@@ -1557,22 +1655,24 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
         }
       }
     }
-    else if(haveDeterminants && !haveJacobians && !havePoints){
+    else if(haveDeterminants && !haveJacobians && !havePoints) {
       std::vector<double> jac(9, 0.);
-      std::vector< std::vector<SVector3> > gsf;
+      std::vector<std::vector<SVector3> > gsf;
       size_t o = 0;
-      size_t idx = begin*numIntPoints;
-      for(unsigned int i = 0; i < entities.size(); i++){
+      size_t idx = begin * numIntPoints;
+      for(unsigned int i = 0; i < entities.size(); i++) {
         GEntity *ge = entities[i];
-        const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-        for(unsigned int j = 0; j < numMeshElements; j++){
-          if(o >= begin && o < end){
+        const unsigned int numMeshElements =
+          ge->getNumMeshElementsByType(familyType);
+        for(unsigned int j = 0; j < numMeshElements; j++) {
+          if(o >= begin && o < end) {
             MElement *e = ge->getMeshElementByType(familyType, j);
-            if(gsf.size() == 0){
+            if(gsf.size() == 0) {
               gsf.resize(numIntPoints);
-              for(int k = 0; k < numIntPoints; k++){
+              for(int k = 0; k < numIntPoints; k++) {
                 double value[1256][3];
-                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2), value);
+                e->getGradShapeFunctions(pts(k, 0), pts(k, 1), pts(k, 2),
+                                         value);
                 gsf[k].resize(e->getNumShapeFunctions());
                 for(int l = 0; l < e->getNumShapeFunctions(); l++) {
                   gsf[k][l][0] = value[l][0];
@@ -1581,7 +1681,7 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
                 }
               }
             }
-            for(int k = 0; k < numIntPoints; k++){
+            for(int k = 0; k < numIntPoints; k++) {
               determinants[idx] = e->getJacobian(gsf[k], &jac[0]);
               idx++;
             }
@@ -1594,21 +1694,19 @@ GMSH_API void gmsh::model::mesh::getJacobians(const int elementType,
   }
 }
 
-GMSH_API void gmsh::model::mesh::preallocateJacobians(const int elementType,
-                                                      const std::string &integrationType,
-                                                      const bool jacobian,
-                                                      const bool determinant,
-                                                      const bool point,
-                                                      std::vector<double> &jacobians,
-                                                      std::vector<double> &determinants,
-                                                      std::vector<double> &points,
-                                                      const int tag)
+GMSH_API void gmsh::model::mesh::preallocateJacobians(
+  const int elementType, const std::string &integrationType,
+  const bool jacobian, const bool determinant, const bool point,
+  std::vector<double> &jacobians, std::vector<double> &determinants,
+  std::vector<double> &points, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   const unsigned int numElements = _getNumElementsByType(elementType, tag);
   std::string intName = "";
   int intOrder = 0;
-  if(!_getIntegrationInfo(integrationType, intName, intOrder)){
+  if(!_getIntegrationInfo(integrationType, intName, intOrder)) {
     Msg::Error("Unknown quadrature type '%s'", integrationType.c_str());
     throw 2;
   }
@@ -1617,38 +1715,39 @@ GMSH_API void gmsh::model::mesh::preallocateJacobians(const int elementType,
   fullVector<double> weights;
   gaussIntegration::get(familyType, intOrder, pts, weights);
   const unsigned int numIntPoints = weights.size();
-  if(jacobian){
+  if(jacobian) {
     jacobians.clear();
     jacobians.resize(9 * numElements * numIntPoints, 0.);
   }
-  if(determinant){
+  if(determinant) {
     determinants.clear();
     determinants.resize(numElements * numIntPoints, 0.);
   }
-  if(point){
+  if(point) {
     points.clear();
     points.resize(3 * numElements * numIntPoints, 0.);
   }
 }
 
-GMSH_API void gmsh::model::mesh::getBasisFunctions(const int elementType,
-                                                   const std::string &integrationType,
-                                                   const std::string &functionSpaceType,
-                                                   std::vector<double> &integrationPoints,
-                                                   int &numComponents,
-                                                   std::vector<double> &basisFunctions)
+GMSH_API void gmsh::model::mesh::getBasisFunctions(
+  const int elementType, const std::string &integrationType,
+  const std::string &functionSpaceType, std::vector<double> &integrationPoints,
+  int &numComponents, std::vector<double> &basisFunctions)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   integrationPoints.clear();
   numComponents = 0;
   basisFunctions.clear();
   std::string intName = "", fsName = "";
   int intOrder = 0, fsOrder = 0;
-  if(!_getIntegrationInfo(integrationType, intName, intOrder)){
+  if(!_getIntegrationInfo(integrationType, intName, intOrder)) {
     Msg::Error("Unknown quadrature type '%s'", integrationType.c_str());
     throw 2;
   }
-  if(!_getFunctionSpaceInfo(functionSpaceType, fsName, fsOrder, numComponents)){
+  if(!_getFunctionSpaceInfo(functionSpaceType, fsName, fsOrder,
+                            numComponents)) {
     Msg::Error("Unknown function space type '%s'", functionSpaceType.c_str());
     throw 2;
   }
@@ -1657,11 +1756,11 @@ GMSH_API void gmsh::model::mesh::getBasisFunctions(const int elementType,
   fullMatrix<double> pts;
   fullVector<double> weights;
   gaussIntegration::get(familyType, intOrder, pts, weights);
-  if(pts.size1() != weights.size() || pts.size2() != 3){
+  if(pts.size1() != weights.size() || pts.size2() != 3) {
     Msg::Error("Wrong integration point format");
     throw 3;
   }
-  for(int i = 0; i < pts.size1(); i++){
+  for(int i = 0; i < pts.size1(); i++) {
     integrationPoints.push_back(pts(i, 0));
     integrationPoints.push_back(pts(i, 1));
     integrationPoints.push_back(pts(i, 2));
@@ -1669,31 +1768,30 @@ GMSH_API void gmsh::model::mesh::getBasisFunctions(const int elementType,
   }
   // get function space info
   const nodalBasis *basis = 0;
-  if(numComponents){
-    if(fsOrder == -1){ // isoparametric
+  if(numComponents) {
+    if(fsOrder == -1) { // isoparametric
       basis = BasisFactory::getNodalBasis(elementType);
     }
-    else{
+    else {
       int newType = ElementType::getType(familyType, fsOrder, false);
       basis = BasisFactory::getNodalBasis(newType);
     }
   }
-  if(basis){
+  if(basis) {
     int nq = weights.size();
     int n = basis->getNumShapeFunctions();
     basisFunctions.resize(n * numComponents * nq, 0.);
     double s[1256], ds[1256][3];
-    for(int i = 0; i < nq; i++){
+    for(int i = 0; i < nq; i++) {
       double u = pts(i, 0), v = pts(i, 1), w = pts(i, 2);
-      switch(numComponents){
+      switch(numComponents) {
       case 1:
         basis->f(u, v, w, s);
-        for(int j = 0; j < n; j++)
-          basisFunctions[n * i + j] = s[j];
+        for(int j = 0; j < n; j++) basisFunctions[n * i + j] = s[j];
         break;
       case 3:
         basis->df(u, v, w, ds);
-        for(int j = 0; j < n; j++){
+        for(int j = 0; j < n; j++) {
           basisFunctions[n * 3 * i + 3 * j] = ds[j][0];
           basisFunctions[n * 3 * i + 3 * j + 1] = ds[j][1];
           basisFunctions[n * 3 * i + 3 * j + 2] = ds[j][2];
@@ -1706,44 +1804,45 @@ GMSH_API void gmsh::model::mesh::getBasisFunctions(const int elementType,
 
 GMSH_API void gmsh::model::mesh::precomputeBasisFunctions(const int elementType)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   BasisFactory::getNodalBasis(elementType);
 }
 
-GMSH_API void gmsh::model::mesh::getBarycenters(const int elementType,
-                                                const int tag,
-                                                const bool fast,
-                                                const bool primary,
-                                                std::vector<double> &barycenters,
-                                                const size_t task,
-                                                const size_t numTasks)
+GMSH_API void gmsh::model::mesh::getBarycenters(
+  const int elementType, const int tag, const bool fast, const bool primary,
+  std::vector<double> &barycenters, const size_t task, const size_t numTasks)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int dim = ElementType::getDimension(elementType);
-  std::map<int, std::vector<GEntity*> > typeMap;
+  std::map<int, std::vector<GEntity *> > typeMap;
   _getElementTypeMap(dim, tag, typeMap);
 
   int familyType = ElementType::getParentType(elementType);
   int n = 0;
-  for(unsigned int i = 0; i < typeMap[elementType].size(); i++){
+  for(unsigned int i = 0; i < typeMap[elementType].size(); i++) {
     GEntity *ge = typeMap[elementType][i];
     n += ge->getNumMeshElementsByType(familyType);
   }
   const size_t begin = (task * n) / numTasks;
   const size_t end = ((task + 1) * n) / numTasks;
-  if(3 * end > barycenters.size()){
+  if(3 * end > barycenters.size()) {
     if(numTasks > 1)
       Msg::Error("Barycenters should be preallocated if numTasks > 1");
     barycenters.resize(3 * n);
   }
   size_t o = 0;
   size_t idx = 3 * begin;
-  if(fast){
-    for(unsigned int i = 0; i < typeMap[elementType].size(); i++){
+  if(fast) {
+    for(unsigned int i = 0; i < typeMap[elementType].size(); i++) {
       GEntity *ge = typeMap[elementType][i];
-      const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-      for(unsigned int j = 0; j < numMeshElements; j++){
-        if(o >= begin && o < end){
+      const unsigned int numMeshElements =
+        ge->getNumMeshElementsByType(familyType);
+      for(unsigned int j = 0; j < numMeshElements; j++) {
+        if(o >= begin && o < end) {
           MElement *e = ge->getMeshElementByType(familyType, j);
           SPoint3 p = e->fastBarycenter(primary);
           barycenters[idx++] = p[0];
@@ -1754,12 +1853,13 @@ GMSH_API void gmsh::model::mesh::getBarycenters(const int elementType,
       }
     }
   }
-  else{
-    for(unsigned int i = 0; i < typeMap[elementType].size(); i++){
+  else {
+    for(unsigned int i = 0; i < typeMap[elementType].size(); i++) {
       GEntity *ge = typeMap[elementType][i];
-      const unsigned int numMeshElements = ge->getNumMeshElementsByType(familyType);
-      for(unsigned int j = 0; j < numMeshElements; j++){
-        if(o >= begin && o < end){
+      const unsigned int numMeshElements =
+        ge->getNumMeshElementsByType(familyType);
+      for(unsigned int j = 0; j < numMeshElements; j++) {
+        if(o >= begin && o < end) {
           MElement *e = ge->getMeshElementByType(familyType, j);
           SPoint3 p = e->barycenter(primary);
           barycenters[idx++] = p[0];
@@ -1772,109 +1872,124 @@ GMSH_API void gmsh::model::mesh::getBarycenters(const int elementType,
   }
 }
 
-GMSH_API void gmsh::model::mesh::preallocateBarycenters(const int elementType,
-                                                        std::vector<double> &barycenters,
-                                                        const int tag)
+GMSH_API void gmsh::model::mesh::preallocateBarycenters(
+  const int elementType, std::vector<double> &barycenters, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   const unsigned int numElements = _getNumElementsByType(elementType, tag);
   barycenters.clear();
   barycenters.resize(3 * numElements, 0);
 }
 
 // TODO: give access to closures
-// GMSH_API void gmsh::model::mesh::getElementClosures(const int elementType, ...)
+// GMSH_API void gmsh::model::mesh::getElementClosures(const int elementType,
+// ...)
 // {
 // }
 
 GMSH_API void gmsh::model::mesh::setSize(const vectorpair &dimTags,
                                          const double size)
 {
-  if(!_isInitialized()){ throw -1; }
-  for(unsigned int i = 0; i < dimTags.size(); i++){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  for(unsigned int i = 0; i < dimTags.size(); i++) {
     int dim = dimTags[i].first, tag = dimTags[i].second;
-    if(dim == 0){
+    if(dim == 0) {
       GVertex *gv = GModel::current()->getVertexByTag(tag);
       if(gv) gv->setPrescribedMeshSizeAtVertex(size);
     }
   }
 }
 
-GMSH_API void gmsh::model::mesh::setTransfiniteCurve(const int tag,
-                                                     const int numNodes,
-                                                     const std::string &meshType,
-                                                     const double coef)
+GMSH_API void
+gmsh::model::mesh::setTransfiniteCurve(const int tag, const int numNodes,
+                                       const std::string &meshType,
+                                       const double coef)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GEdge *ge = GModel::current()->getEdgeByTag(tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(1, tag).c_str());
     throw 2;
   }
   ge->meshAttributes.method = MESH_TRANSFINITE;
   ge->meshAttributes.nbPointsTransfinite = numNodes;
   ge->meshAttributes.typeTransfinite =
-    (meshType == "Progression" || meshType == "Power") ? 1 :
-    (meshType == "Bump") ? 2 :
-    1;
+    (meshType == "Progression" || meshType == "Power") ?
+      1 :
+      (meshType == "Bump") ? 2 : 1;
   ge->meshAttributes.coeffTransfinite = std::abs(coef);
   // in .geo file we use a negative tag to do this trick; it's a bad idea
   if(coef < 0) ge->meshAttributes.typeTransfinite *= -1;
 }
 
-GMSH_API void gmsh::model::mesh::setTransfiniteSurface(const int tag,
-                                                       const std::string &arrangement,
-                                                       const std::vector<int> &cornerTags)
+GMSH_API void
+gmsh::model::mesh::setTransfiniteSurface(const int tag,
+                                         const std::string &arrangement,
+                                         const std::vector<int> &cornerTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GFace *gf = GModel::current()->getFaceByTag(tag);
-  if(!gf){
+  if(!gf) {
     Msg::Error("%s does not exist", _getEntityName(2, tag).c_str());
     throw 2;
   }
   gf->meshAttributes.method = MESH_TRANSFINITE;
   gf->meshAttributes.transfiniteArrangement =
-    (arrangement == "Right") ? 1 :
-    (arrangement == "Left") ? -1 :
-    (arrangement == "AlternateRight") ? 2 :
-    (arrangement == "AlternateLeft") ? -2 :
-    (arrangement == "Alternate") ? 2 :
-    -1;
-  if(cornerTags.empty() || cornerTags.size() == 3 || cornerTags.size() == 4){
-    for(unsigned int j = 0; j < cornerTags.size(); j++){
+    (arrangement == "Right") ?
+      1 :
+      (arrangement == "Left") ?
+      -1 :
+      (arrangement == "AlternateRight") ?
+      2 :
+      (arrangement == "AlternateLeft") ? -2 :
+                                         (arrangement == "Alternate") ? 2 : -1;
+  if(cornerTags.empty() || cornerTags.size() == 3 || cornerTags.size() == 4) {
+    for(unsigned int j = 0; j < cornerTags.size(); j++) {
       GVertex *gv = GModel::current()->getVertexByTag(cornerTags[j]);
-      if(gv)
-        gf->meshAttributes.corners.push_back(gv);
+      if(gv) gf->meshAttributes.corners.push_back(gv);
     }
   }
 }
 
-GMSH_API void gmsh::model::mesh::setTransfiniteVolume(const int tag,
-                                                      const std::vector<int> &cornerTags)
+GMSH_API void
+gmsh::model::mesh::setTransfiniteVolume(const int tag,
+                                        const std::vector<int> &cornerTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GRegion *gr = GModel::current()->getRegionByTag(tag);
-  if(!gr){
+  if(!gr) {
     Msg::Error("%s does not exist", _getEntityName(3, tag).c_str());
     throw 2;
   }
   gr->meshAttributes.method = MESH_TRANSFINITE;
-  if(cornerTags.empty() || cornerTags.size() == 6 || cornerTags.size() == 8){
-    for(unsigned int i = 0; i < cornerTags.size(); i++){
+  if(cornerTags.empty() || cornerTags.size() == 6 || cornerTags.size() == 8) {
+    for(unsigned int i = 0; i < cornerTags.size(); i++) {
       GVertex *gv = GModel::current()->getVertexByTag(cornerTags[i]);
-      if(gv)
-        gr->meshAttributes.corners.push_back(gv);
+      if(gv) gr->meshAttributes.corners.push_back(gv);
     }
   }
 }
 
-GMSH_API void gmsh::model::mesh::setRecombine(const int dim,
-                                              const int tag)
+GMSH_API void gmsh::model::mesh::setRecombine(const int dim, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(dim != 2){ throw 2; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(dim != 2) {
+    throw 2;
+  }
   GFace *gf = GModel::current()->getFaceByTag(tag);
-  if(!gf){
+  if(!gf) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
@@ -1882,36 +1997,40 @@ GMSH_API void gmsh::model::mesh::setRecombine(const int dim,
   gf->meshAttributes.recombineAngle = 45.;
 }
 
-GMSH_API void gmsh::model::mesh::setSmoothing(const int dim,
-                                              const int tag,
+GMSH_API void gmsh::model::mesh::setSmoothing(const int dim, const int tag,
                                               const int val)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(dim != 2){ throw 2; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(dim != 2) {
+    throw 2;
+  }
   GFace *gf = GModel::current()->getFaceByTag(tag);
-  if(!gf){
+  if(!gf) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
   gf->meshAttributes.transfiniteSmoothing = val;
 }
 
-GMSH_API void gmsh::model::mesh::setReverse(const int dim,
-                                            const int tag,
+GMSH_API void gmsh::model::mesh::setReverse(const int dim, const int tag,
                                             const bool val)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(dim == 1){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(dim == 1) {
     GEdge *ge = GModel::current()->getEdgeByTag(tag);
-    if(!ge){
+    if(!ge) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
     ge->meshAttributes.reverseMesh = val;
   }
-  else if(dim == 2){
+  else if(dim == 2) {
     GFace *gf = GModel::current()->getFaceByTag(tag);
-    if(!gf){
+    if(!gf) {
       Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
       throw 2;
     }
@@ -1921,9 +2040,11 @@ GMSH_API void gmsh::model::mesh::setReverse(const int dim,
 
 GMSH_API void gmsh::model::mesh::setOutwardOrientation(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GRegion *gr = GModel::current()->getRegionByTag(tag);
-  if(!gr){
+  if(!gr) {
     Msg::Error("%s does not exist", _getEntityName(3, tag).c_str());
     throw 2;
   }
@@ -1932,28 +2053,29 @@ GMSH_API void gmsh::model::mesh::setOutwardOrientation(const int tag)
 
 GMSH_API void gmsh::model::mesh::embed(const int dim,
                                        const std::vector<int> &tags,
-                                       const int inDim,
-                                       const int inTag)
+                                       const int inDim, const int inTag)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(inDim == 2){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(inDim == 2) {
     GFace *gf = GModel::current()->getFaceByTag(inTag);
-    if(!gf){
+    if(!gf) {
       Msg::Error("%s does not exist", _getEntityName(2, inTag).c_str());
       throw 2;
     }
-    for(unsigned int i = 0; i < tags.size(); i++){
-      if(dim == 0){
+    for(unsigned int i = 0; i < tags.size(); i++) {
+      if(dim == 0) {
         GVertex *gv = GModel::current()->getVertexByTag(tags[i]);
-        if(!gv){
+        if(!gv) {
           Msg::Error("%s does not exist", _getEntityName(0, tags[i]).c_str());
           throw 2;
         }
         gf->addEmbeddedVertex(gv);
       }
-      else if(dim == 1){
+      else if(dim == 1) {
         GEdge *ge = GModel::current()->getEdgeByTag(tags[i]);
-        if(!ge){
+        if(!ge) {
           Msg::Error("%s does not exist", _getEntityName(1, tags[i]).c_str());
           throw 2;
         }
@@ -1961,32 +2083,32 @@ GMSH_API void gmsh::model::mesh::embed(const int dim,
       }
     }
   }
-  else if(inDim == 3){
+  else if(inDim == 3) {
     GRegion *gr = GModel::current()->getRegionByTag(inTag);
-    if(!gr){
+    if(!gr) {
       Msg::Error("%s does not exist", _getEntityName(3, inTag).c_str());
       throw 2;
     }
-    for(unsigned int i = 0; i < tags.size(); i++){
-      if(dim == 0){
+    for(unsigned int i = 0; i < tags.size(); i++) {
+      if(dim == 0) {
         GVertex *gv = GModel::current()->getVertexByTag(tags[i]);
-        if(!gv){
+        if(!gv) {
           Msg::Error("%s does not exist", _getEntityName(0, tags[i]).c_str());
           throw 2;
         }
         gr->addEmbeddedVertex(gv);
       }
-      else if(dim == 1){
+      else if(dim == 1) {
         GEdge *ge = GModel::current()->getEdgeByTag(tags[i]);
-        if(!ge){
+        if(!ge) {
           Msg::Error("%s does not exist", _getEntityName(1, tags[i]).c_str());
           throw 2;
         }
         gr->addEmbeddedEdge(ge);
       }
-      else if(dim == 2){
+      else if(dim == 2) {
         GFace *gf = GModel::current()->getFaceByTag(tags[i]);
-        if(!gf){
+        if(!gf) {
           Msg::Error("%s does not exist", _getEntityName(2, tags[i]).c_str());
           throw 2;
         }
@@ -1996,19 +2118,21 @@ GMSH_API void gmsh::model::mesh::embed(const int dim,
   }
 }
 
-GMSH_API void gmsh::model::mesh::reorderElements(const int elementType,
-                                                 const int tag,
-                                                 const std::vector<int> &ordering)
+GMSH_API void
+gmsh::model::mesh::reorderElements(const int elementType, const int tag,
+                                   const std::vector<int> &ordering)
 {
-  if(!_isInitialized()){ throw -1; }
-  std::map<int, std::vector<GEntity*> > typeMap;
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  std::map<int, std::vector<GEntity *> > typeMap;
   int dim = ElementType::getDimension(elementType);
   _getElementTypeMap(dim, tag, typeMap);
-  if(typeMap[elementType].size() == 0){
+  if(typeMap[elementType].size() == 0) {
     Msg::Error("No elements to reorder");
     throw 2;
   }
-  if(!typeMap[elementType][0]->reorder(elementType, ordering)){
+  if(!typeMap[elementType][0]->reorder(elementType, ordering)) {
     Msg::Error("Could not reorder elements");
     throw 3;
   }
@@ -2016,54 +2140,62 @@ GMSH_API void gmsh::model::mesh::reorderElements(const int elementType,
 
 GMSH_API void gmsh::model::mesh::renumberNodes()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->renumberMeshVertices();
 }
 
 GMSH_API void gmsh::model::mesh::renumberElements()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->renumberMeshElements();
 }
 
-GMSH_API void gmsh::model::mesh::setPeriodic(const int dim,
-                                             const std::vector<int> &tags,
-                                             const std::vector<int> &tagsMaster,
-                                             const std::vector<double> &affineTransform)
+GMSH_API void
+gmsh::model::mesh::setPeriodic(const int dim, const std::vector<int> &tags,
+                               const std::vector<int> &tagsMaster,
+                               const std::vector<double> &affineTransform)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(tags.size() != tagsMaster.size()){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(tags.size() != tagsMaster.size()) {
     Msg::Error("Incompatible number of tags and master tags for periodic mesh");
     throw 2;
   }
-  if(affineTransform.size() != 16){
+  if(affineTransform.size() != 16) {
     Msg::Error("Wrong number of elements in affine transformation (%d != 16)",
                (int)affineTransform.size());
     throw 2;
   }
-  for(unsigned int i = 0; i < tags.size(); i++){
-    if(dim == 1){
+  for(unsigned int i = 0; i < tags.size(); i++) {
+    if(dim == 1) {
       GEdge *target = GModel::current()->getEdgeByTag(tags[i]);
-      if(!target){
+      if(!target) {
         Msg::Error("%s does not exist", _getEntityName(dim, tags[i]).c_str());
         throw 2;
       }
       GEdge *source = GModel::current()->getEdgeByTag(tagsMaster[i]);
-      if(!source){
-        Msg::Error("%s does not exist", _getEntityName(dim, tagsMaster[i]).c_str());
+      if(!source) {
+        Msg::Error("%s does not exist",
+                   _getEntityName(dim, tagsMaster[i]).c_str());
         throw 2;
       }
       target->setMeshMaster(source, affineTransform);
     }
-    else if(dim == 2){
+    else if(dim == 2) {
       GFace *target = GModel::current()->getFaceByTag(tags[i]);
-      if(!target){
+      if(!target) {
         Msg::Error("%s does not exist", _getEntityName(dim, tags[i]).c_str());
         throw 2;
       }
       GFace *source = GModel::current()->getFaceByTag(tagsMaster[i]);
-      if(!source){
-        Msg::Error("%s does not exist", _getEntityName(dim, tagsMaster[i]).c_str());
+      if(!source) {
+        Msg::Error("%s does not exist",
+                   _getEntityName(dim, tagsMaster[i]).c_str());
         throw 2;
       }
       target->setMeshMaster(source, affineTransform);
@@ -2071,25 +2203,29 @@ GMSH_API void gmsh::model::mesh::setPeriodic(const int dim,
   }
 }
 
-GMSH_API void gmsh::model::mesh::getPeriodicNodes(const int dim, const int tag,
-                                                  int &tagMaster,
-                                                  gmsh::vectorpair &nodes,
-                                                  std::vector<double> &affineTransform)
+GMSH_API void
+gmsh::model::mesh::getPeriodicNodes(const int dim, const int tag,
+                                    int &tagMaster, gmsh::vectorpair &nodes,
+                                    std::vector<double> &affineTransform)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GEntity *ge = GModel::current()->getEntityByTag(dim, tag);
-  if(!ge){
+  if(!ge) {
     Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
     throw 2;
   }
-  if(ge->meshMaster() != ge){
+  if(ge->meshMaster() != ge) {
     tagMaster = ge->meshMaster()->tag();
-    for(std::map<MVertex*,MVertex*>::iterator it = ge->correspondingVertices.begin();
+    for(std::map<MVertex *, MVertex *>::iterator it =
+          ge->correspondingVertices.begin();
         it != ge->correspondingVertices.end(); ++it)
-      nodes.push_back(std::pair<int, int>(it->first->getNum(), it->second->getNum()));
+      nodes.push_back(
+        std::pair<int, int>(it->first->getNum(), it->second->getNum()));
     affineTransform = ge->affineTransform;
   }
-  else{
+  else {
     tagMaster = tag;
     nodes.clear();
     affineTransform.clear();
@@ -2098,31 +2234,35 @@ GMSH_API void gmsh::model::mesh::getPeriodicNodes(const int dim, const int tag,
 
 GMSH_API void gmsh::model::mesh::removeDuplicateNodes()
 {
-  if(!_isInitialized()){ throw -1; }
-  GModel::current()->removeDuplicateMeshVertices(CTX::instance()->geom.tolerance);
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  GModel::current()->removeDuplicateMeshVertices(
+    CTX::instance()->geom.tolerance);
   CTX::instance()->mesh.changed = ENT_ALL;
 }
 
 GMSH_API void gmsh::model::mesh::homology(const std::vector<int> &domainTags,
-					  const std::vector<int> &subdomainTags,
-					  const std::vector<int> &dims)
+                                          const std::vector<int> &subdomainTags,
+                                          const std::vector<int> &dims)
 {
-  if(!_isInitialized()){ throw -1; }
-  GModel::current()->addHomologyRequest("Homology",
-					domainTags,
-					subdomainTags,
-					dims);
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  GModel::current()->addHomologyRequest("Homology", domainTags, subdomainTags,
+                                        dims);
 }
 
-GMSH_API void gmsh::model::mesh::cohomology(const std::vector<int> &domainTags,
-					    const std::vector<int> &subdomainTags,
-					    const std::vector<int> &dims)
+GMSH_API void
+gmsh::model::mesh::cohomology(const std::vector<int> &domainTags,
+                              const std::vector<int> &subdomainTags,
+                              const std::vector<int> &dims)
 {
-  if(!_isInitialized()){ throw -1; }
-  GModel::current()->addHomologyRequest("Cohomology",
-					domainTags,
-					subdomainTags,
-					dims);
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  GModel::current()->addHomologyRequest("Cohomology", domainTags, subdomainTags,
+                                        dims);
 }
 
 // gmsh::model::mesh::field
@@ -2130,13 +2270,15 @@ GMSH_API void gmsh::model::mesh::cohomology(const std::vector<int> &domainTags,
 GMSH_API int gmsh::model::mesh::field::add(const std::string &fieldType,
                                            const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
 #if defined(HAVE_MESH)
-  if(outTag < 0){
+  if(outTag < 0) {
     outTag = GModel::current()->getFields()->newId();
   }
-  if(!GModel::current()->getFields()->newField(outTag, fieldType)){
+  if(!GModel::current()->getFields()->newField(outTag, fieldType)) {
     Msg::Error("Cannot add Field %i of type '%s'", outTag, fieldType.c_str());
     throw 1;
   }
@@ -2145,14 +2287,16 @@ GMSH_API int gmsh::model::mesh::field::add(const std::string &fieldType,
 #endif
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
   return outTag;
 }
 
 GMSH_API void gmsh::model::mesh::field::remove(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   GModel::current()->getFields()->deleteField(tag);
 #if defined(HAVE_FLTK)
@@ -2160,7 +2304,7 @@ GMSH_API void gmsh::model::mesh::field::remove(const int tag)
 #endif
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -2168,12 +2312,12 @@ GMSH_API void gmsh::model::mesh::field::remove(const int tag)
 static FieldOption *_getFieldOption(const int tag, const std::string &option)
 {
   Field *field = GModel::current()->getFields()->get(tag);
-  if(!field){
+  if(!field) {
     Msg::Error("No field with id %i", tag);
     return 0;
   }
   FieldOption *o = field->options[option];
-  if(!o){
+  if(!o) {
     Msg::Error("Unknown option '%s' in field %i of type '%s'", option.c_str(),
                tag, field->getName());
     return 0;
@@ -2186,19 +2330,24 @@ GMSH_API void gmsh::model::mesh::field::setNumber(const int tag,
                                                   const std::string &option,
                                                   const double value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   FieldOption *o = _getFieldOption(tag, option);
-  if(!o){ throw 1; }
-  try { o->numericalValue(value); }
-  catch(...){
+  if(!o) {
+    throw 1;
+  }
+  try {
+    o->numericalValue(value);
+  } catch(...) {
     Msg::Error("Cannot set numerical value to option '%s' in field %i",
                option.c_str(), tag);
     throw 1;
   }
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -2206,30 +2355,39 @@ GMSH_API void gmsh::model::mesh::field::setString(const int tag,
                                                   const std::string &option,
                                                   const std::string &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   FieldOption *o = _getFieldOption(tag, option);
-  if(!o){ throw 1; }
-  try { o->string(value); }
-  catch(...){
+  if(!o) {
+    throw 1;
+  }
+  try {
+    o->string(value);
+  } catch(...) {
     Msg::Error("Cannot set string value to option '%s' in field %i",
                option.c_str(), tag);
     throw 1;
   }
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
-GMSH_API void gmsh::model::mesh::field::setNumbers(const int tag,
-                                                   const std::string &option,
-                                                   const std::vector<double> &value)
+GMSH_API void
+gmsh::model::mesh::field::setNumbers(const int tag, const std::string &option,
+                                     const std::vector<double> &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   FieldOption *o = _getFieldOption(tag, option);
-  if(!o){ throw 1; }
+  if(!o) {
+    throw 1;
+  }
   try {
     if(o->getType() == FIELD_OPTION_LIST) {
       std::list<int> vl;
@@ -2237,73 +2395,76 @@ GMSH_API void gmsh::model::mesh::field::setNumbers(const int tag,
         vl.push_back((int)value[i]);
       o->list(vl);
     }
-    else{
+    else {
       std::list<double> vl;
-      for(unsigned int i = 0; i < value.size(); i++)
-        vl.push_back(value[i]);
+      for(unsigned int i = 0; i < value.size(); i++) vl.push_back(value[i]);
       o->listdouble(vl);
     }
-  }
-  catch(...){
+  } catch(...) {
     Msg::Error("Cannot set numeric values to option '%s' in field %i",
                option.c_str(), tag);
     throw 1;
   }
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::model::mesh::field::setAsBackgroundMesh(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   GModel::current()->getFields()->setBackgroundFieldId(tag);
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::model::mesh::field::setAsBoundaryLayer(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_MESH)
   GModel::current()->getFields()->addBoundaryLayerFieldId(tag);
 #else
   Msg::Error("Fields require the mesh module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 // gmsh::model::geo
 
-GMSH_API int gmsh::model::geo::addPoint(const double x,
-                                        const double y,
-                                        const double z,
-                                        const double meshSize,
+GMSH_API int gmsh::model::geo::addPoint(const double x, const double y,
+                                        const double z, const double meshSize,
                                         const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
   double xx = CTX::instance()->geom.scalingFactor * x;
   double yy = CTX::instance()->geom.scalingFactor * y;
   double zz = CTX::instance()->geom.scalingFactor * z;
   double lc = CTX::instance()->geom.scalingFactor * meshSize;
-  if(!GModel::current()->getGEOInternals()->addVertex(outTag, xx, yy, zz, lc)){
+  if(!GModel::current()->getGEOInternals()->addVertex(outTag, xx, yy, zz, lc)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::geo::addLine(const int startTag,
-                                       const int endTag,
+GMSH_API int gmsh::model::geo::addLine(const int startTag, const int endTag,
                                        const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addLine(outTag, startTag, endTag)){
+  if(!GModel::current()->getGEOInternals()->addLine(outTag, startTag, endTag)) {
     throw 1;
   }
   return outTag;
@@ -2311,34 +2472,31 @@ GMSH_API int gmsh::model::geo::addLine(const int startTag,
 
 GMSH_API int gmsh::model::geo::addCircleArc(const int startTag,
                                             const int centerTag,
-                                            const int endTag,
-                                            const int tag,
-                                            const double nx,
-                                            const double ny,
+                                            const int endTag, const int tag,
+                                            const double nx, const double ny,
                                             const double nz)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addCircleArc
-     (outTag, startTag, centerTag, endTag, nx, ny, nz)){
+  if(!GModel::current()->getGEOInternals()->addCircleArc(
+       outTag, startTag, centerTag, endTag, nx, ny, nz)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::geo::addEllipseArc(const int startTag,
-                                             const int centerTag,
-                                             const int majorTag,
-                                             const int endTag,
-                                             const int tag,
-                                             const double nx,
-                                             const double ny,
-                                             const double nz)
-{
-  if(!_isInitialized()){ throw -1; }
+GMSH_API int gmsh::model::geo::addEllipseArc(
+  const int startTag, const int centerTag, const int majorTag, const int endTag,
+  const int tag, const double nx, const double ny, const double nz)
+{
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addEllipseArc
-     (outTag, startTag, centerTag, majorTag, endTag, nx, ny, nz)){
+  if(!GModel::current()->getGEOInternals()->addEllipseArc(
+       outTag, startTag, centerTag, majorTag, endTag, nx, ny, nz)) {
     throw 1;
   }
   return outTag;
@@ -2347,9 +2505,11 @@ GMSH_API int gmsh::model::geo::addEllipseArc(const int startTag,
 GMSH_API int gmsh::model::geo::addSpline(const std::vector<int> &pointTags,
                                          const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addSpline(outTag, pointTags)){
+  if(!GModel::current()->getGEOInternals()->addSpline(outTag, pointTags)) {
     throw 1;
   }
   return outTag;
@@ -2358,9 +2518,11 @@ GMSH_API int gmsh::model::geo::addSpline(const std::vector<int> &pointTags,
 GMSH_API int gmsh::model::geo::addBSpline(const std::vector<int> &pointTags,
                                           const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addBSpline(outTag, pointTags)){
+  if(!GModel::current()->getGEOInternals()->addBSpline(outTag, pointTags)) {
     throw 1;
   }
   return outTag;
@@ -2369,9 +2531,11 @@ GMSH_API int gmsh::model::geo::addBSpline(const std::vector<int> &pointTags,
 GMSH_API int gmsh::model::geo::addBezier(const std::vector<int> &pointTags,
                                          const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addBezier(outTag, pointTags)){
+  if(!GModel::current()->getGEOInternals()->addBezier(outTag, pointTags)) {
     throw 1;
   }
   return outTag;
@@ -2380,9 +2544,11 @@ GMSH_API int gmsh::model::geo::addBezier(const std::vector<int> &pointTags,
 GMSH_API int gmsh::model::geo::addCurveLoop(const std::vector<int> &curveTags,
                                             const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addLineLoop(outTag, curveTags)){
+  if(!GModel::current()->getGEOInternals()->addLineLoop(outTag, curveTags)) {
     throw 1;
   }
   return outTag;
@@ -2391,33 +2557,41 @@ GMSH_API int gmsh::model::geo::addCurveLoop(const std::vector<int> &curveTags,
 GMSH_API int gmsh::model::geo::addPlaneSurface(const std::vector<int> &wireTags,
                                                const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addPlaneSurface(outTag, wireTags)){
+  if(!GModel::current()->getGEOInternals()->addPlaneSurface(outTag, wireTags)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::geo::addSurfaceFilling(const std::vector<int> &wireTags,
-                                                 const int tag,
-                                                 const int sphereCenterTag)
+GMSH_API int
+gmsh::model::geo::addSurfaceFilling(const std::vector<int> &wireTags,
+                                    const int tag, const int sphereCenterTag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addSurfaceFilling
-     (outTag, wireTags, sphereCenterTag)){
+  if(!GModel::current()->getGEOInternals()->addSurfaceFilling(
+       outTag, wireTags, sphereCenterTag)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::geo::addSurfaceLoop(const std::vector<int> &surfaceTags,
-                                              const int tag)
+GMSH_API int
+gmsh::model::geo::addSurfaceLoop(const std::vector<int> &surfaceTags,
+                                 const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addSurfaceLoop(outTag, surfaceTags)){
+  if(!GModel::current()->getGEOInternals()->addSurfaceLoop(outTag,
+                                                           surfaceTags)) {
     throw 1;
   }
   return outTag;
@@ -2426,9 +2600,11 @@ GMSH_API int gmsh::model::geo::addSurfaceLoop(const std::vector<int> &surfaceTag
 GMSH_API int gmsh::model::geo::addVolume(const std::vector<int> &shellTags,
                                          const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getGEOInternals()->addVolume(outTag, shellTags)){
+  if(!GModel::current()->getGEOInternals()->addVolume(outTag, shellTags)) {
     throw 1;
   }
   return outTag;
@@ -2439,16 +2615,16 @@ static ExtrudeParams *_getExtrudeParams(const std::vector<int> &numElements,
                                         const bool recombine)
 {
   ExtrudeParams *e = 0;
-  if(numElements.size()){
+  if(numElements.size()) {
     e = new ExtrudeParams();
     e->mesh.ExtrudeMesh = true;
     e->mesh.NbElmLayer = numElements;
     e->mesh.hLayer = heights;
-    if(e->mesh.hLayer.empty()){
+    if(e->mesh.hLayer.empty()) {
       e->mesh.NbLayer = 1;
       e->mesh.hLayer.push_back(1.);
     }
-    else{
+    else {
       e->mesh.NbLayer = heights.size();
     }
     e->mesh.Recombine = recombine;
@@ -2457,121 +2633,106 @@ static ExtrudeParams *_getExtrudeParams(const std::vector<int> &numElements,
 }
 
 GMSH_API void gmsh::model::geo::extrude(const vectorpair &dimTags,
-                                        const double dx,
-                                        const double dy,
-                                        const double dz,
-                                        vectorpair &outDimTags,
+                                        const double dx, const double dy,
+                                        const double dz, vectorpair &outDimTags,
                                         const std::vector<int> &numElements,
                                         const std::vector<double> &heights,
                                         const bool recombine)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   outDimTags.clear();
-  if(!GModel::current()->getGEOInternals()->extrude
-     (dimTags, dx, dy, dz, outDimTags,
-      _getExtrudeParams(numElements, heights, recombine))){
+  if(!GModel::current()->getGEOInternals()->extrude(
+       dimTags, dx, dy, dz, outDimTags,
+       _getExtrudeParams(numElements, heights, recombine))) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::geo::revolve(const vectorpair &dimTags,
-                                        const double x,
-                                        const double y,
-                                        const double z,
-                                        const double ax,
-                                        const double ay,
-                                        const double az,
-                                        const double angle,
-                                        vectorpair &outDimTags,
-                                        const std::vector<int> &numElements,
-                                        const std::vector<double> &heights,
-                                        const bool recombine)
+GMSH_API void gmsh::model::geo::revolve(
+  const vectorpair &dimTags, const double x, const double y, const double z,
+  const double ax, const double ay, const double az, const double angle,
+  vectorpair &outDimTags, const std::vector<int> &numElements,
+  const std::vector<double> &heights, const bool recombine)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   outDimTags.clear();
-  if(!GModel::current()->getGEOInternals()->revolve
-     (dimTags, x, y, z, ax, ay, az, angle, outDimTags,
-      _getExtrudeParams(numElements, heights, recombine))){
-    throw 1;
-  }
-}
-
-GMSH_API void gmsh::model::geo::twist(const vectorpair &dimTags,
-                                      const double x,
-                                      const double y,
-                                      const double z,
-                                      const double dx,
-                                      const double dy,
-                                      const double dz,
-                                      const double ax,
-                                      const double ay,
-                                      const double az,
-                                      const double angle,
-                                      vectorpair &outDimTags,
-                                      const std::vector<int> &numElements,
-                                      const std::vector<double> &heights,
-                                      const bool recombine)
-{
-  if(!_isInitialized()){ throw -1; }
+  if(!GModel::current()->getGEOInternals()->revolve(
+       dimTags, x, y, z, ax, ay, az, angle, outDimTags,
+       _getExtrudeParams(numElements, heights, recombine))) {
+    throw 1;
+  }
+}
+
+GMSH_API void gmsh::model::geo::twist(
+  const vectorpair &dimTags, const double x, const double y, const double z,
+  const double dx, const double dy, const double dz, const double ax,
+  const double ay, const double az, const double angle, vectorpair &outDimTags,
+  const std::vector<int> &numElements, const std::vector<double> &heights,
+  const bool recombine)
+{
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   outDimTags.clear();
-  if(!GModel::current()->getGEOInternals()->twist
-     (dimTags, x, y, z, dx, dy, dz, ax, ay, az, angle, outDimTags,
-      _getExtrudeParams(numElements, heights, recombine))){
+  if(!GModel::current()->getGEOInternals()->twist(
+       dimTags, x, y, z, dx, dy, dz, ax, ay, az, angle, outDimTags,
+       _getExtrudeParams(numElements, heights, recombine))) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::geo::translate(const vectorpair &dimTags,
-                                          const double dx,
-                                          const double dy,
+                                          const double dx, const double dy,
                                           const double dz)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(!GModel::current()->getGEOInternals()->translate(dimTags, dx, dy, dz)){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(!GModel::current()->getGEOInternals()->translate(dimTags, dx, dy, dz)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::geo::rotate(const vectorpair &dimTags,
-                                       const double x,
-                                       const double y,
-                                       const double z,
-                                       const double ax,
-                                       const double ay,
-                                       const double az,
+                                       const double x, const double y,
+                                       const double z, const double ax,
+                                       const double ay, const double az,
                                        const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(!GModel::current()->getGEOInternals()->rotate
-     (dimTags, x, y, z, ax, ay, az, angle)){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(!GModel::current()->getGEOInternals()->rotate(dimTags, x, y, z, ax, ay, az,
+                                                   angle)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::geo::dilate(const vectorpair &dimTags,
-                                       const double x,
-                                       const double y,
-                                       const double z,
-                                       const double a,
-                                       const double b,
-                                       const double c)
+                                       const double x, const double y,
+                                       const double z, const double a,
+                                       const double b, const double c)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(!GModel::current()->getGEOInternals()->dilate
-     (dimTags, x, y, z, a, b, c)){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(!GModel::current()->getGEOInternals()->dilate(dimTags, x, y, z, a, b, c)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::geo::symmetry(const vectorpair &dimTags,
-                                         const double a,
-                                         const double b,
-                                         const double c,
-                                         const double d)
+                                         const double a, const double b,
+                                         const double c, const double d)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(!GModel::current()->getGEOInternals()->symmetry
-     (dimTags, a, b, c, d)){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(!GModel::current()->getGEOInternals()->symmetry(dimTags, a, b, c, d)) {
     throw 1;
   }
 }
@@ -2579,9 +2740,11 @@ GMSH_API void gmsh::model::geo::symmetry(const vectorpair &dimTags,
 GMSH_API void gmsh::model::geo::copy(const vectorpair &dimTags,
                                      vectorpair &outDimTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   outDimTags.clear();
-  if(!GModel::current()->getGEOInternals()->copy(dimTags, outDimTags)){
+  if(!GModel::current()->getGEOInternals()->copy(dimTags, outDimTags)) {
     throw 1;
   }
 }
@@ -2589,94 +2752,115 @@ GMSH_API void gmsh::model::geo::copy(const vectorpair &dimTags,
 GMSH_API void gmsh::model::geo::remove(const vectorpair &dimTags,
                                        const bool recursive)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(!GModel::current()->getGEOInternals()->remove(dimTags, recursive)){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(!GModel::current()->getGEOInternals()->remove(dimTags, recursive)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::geo::removeAllDuplicates()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->getGEOInternals()->removeAllDuplicates();
 }
 
 GMSH_API void gmsh::model::geo::synchronize()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->getGEOInternals()->synchronize(GModel::current());
 }
 
 // gmsh::model::geo::mesh
 
-GMSH_API void gmsh::model::geo::mesh::setTransfiniteCurve(const int tag,
-                                                          const int nPoints,
-                                                          const std::string &meshType,
-                                                          const double coef)
+GMSH_API void
+gmsh::model::geo::mesh::setTransfiniteCurve(const int tag, const int nPoints,
+                                            const std::string &meshType,
+                                            const double coef)
 {
-  if(!_isInitialized()){ throw -1; }
-  int t =
-    (meshType == "Progression" || meshType == "Power") ? 1 :
-    (meshType == "Bump") ? 2 :
-    1;
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  int t = (meshType == "Progression" || meshType == "Power") ?
+            1 :
+            (meshType == "Bump") ? 2 : 1;
   double c = std::abs(coef);
   // in .geo file we use a negative tag to do this trick; it's a bad idea
   if(coef < 0) t = -t;
   GModel::current()->getGEOInternals()->setTransfiniteLine(tag, nPoints, t, c);
 }
 
-GMSH_API void gmsh::model::geo::mesh::setTransfiniteSurface(const int tag,
-                                                            const std::string &arrangement,
-                                                            const std::vector<int> &cornerTags)
+GMSH_API void gmsh::model::geo::mesh::setTransfiniteSurface(
+  const int tag, const std::string &arrangement,
+  const std::vector<int> &cornerTags)
 {
-  if(!_isInitialized()){ throw -1; }
-  int t =
-    (arrangement == "Right") ? 1 :
-    (arrangement == "Left") ? -1 :
-    (arrangement == "AlternateRight") ? 2 :
-    (arrangement == "AlternateLeft") ? -2 :
-    (arrangement == "Alternate") ? 2 :
-    -1;
-  GModel::current()->getGEOInternals()->setTransfiniteSurface(tag, t, cornerTags);
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  int t = (arrangement == "Right") ?
+            1 :
+            (arrangement == "Left") ? -1 :
+                                      (arrangement == "AlternateRight") ?
+                                      2 :
+                                      (arrangement == "AlternateLeft") ?
+                                      -2 :
+                                      (arrangement == "Alternate") ? 2 : -1;
+  GModel::current()->getGEOInternals()->setTransfiniteSurface(tag, t,
+                                                              cornerTags);
 }
 
-GMSH_API void gmsh::model::geo::mesh::setTransfiniteVolume(const int tag,
-                                                           const std::vector<int> &cornerTags)
+GMSH_API void
+gmsh::model::geo::mesh::setTransfiniteVolume(const int tag,
+                                             const std::vector<int> &cornerTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->getGEOInternals()->setTransfiniteVolume(tag, cornerTags);
 }
 
-GMSH_API void gmsh::model::geo::mesh::setRecombine(const int dim,
-                                                   const int tag,
+GMSH_API void gmsh::model::geo::mesh::setRecombine(const int dim, const int tag,
                                                    const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->getGEOInternals()->setRecombine(dim, tag, angle);
 }
 
-GMSH_API void gmsh::model::geo::mesh::setSmoothing(const int dim,
-                                                   const int tag,
+GMSH_API void gmsh::model::geo::mesh::setSmoothing(const int dim, const int tag,
                                                    const int val)
 {
-  if(!_isInitialized()){ throw -1; }
-  if(dim != 2){ throw 2; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  if(dim != 2) {
+    throw 2;
+  }
   GModel::current()->getGEOInternals()->setSmoothing(tag, val);
 }
 
-GMSH_API void gmsh::model::geo::mesh::setReverse(const int dim,
-                                                 const int tag,
+GMSH_API void gmsh::model::geo::mesh::setReverse(const int dim, const int tag,
                                                  const bool val)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   GModel::current()->getGEOInternals()->setReverseMesh(dim, tag, val);
 }
 
 GMSH_API void gmsh::model::geo::mesh::setSize(const vectorpair &dimTags,
                                               const double size)
 {
-  if(!_isInitialized()){ throw -1; }
-  for(unsigned int i = 0; i < dimTags.size(); i++){
+  if(!_isInitialized()) {
+    throw - 1;
+  }
+  for(unsigned int i = 0; i < dimTags.size(); i++) {
     int dim = dimTags[i].first, tag = dimTags[i].second;
     GModel::current()->getGEOInternals()->setMeshSize(dim, tag, size);
   }
@@ -2686,32 +2870,35 @@ GMSH_API void gmsh::model::geo::mesh::setSize(const vectorpair &dimTags,
 
 static void _createOcc()
 {
-  if(!GModel::current()->getOCCInternals()) GModel::current()->createOCCInternals();
+  if(!GModel::current()->getOCCInternals())
+    GModel::current()->createOCCInternals();
 }
 
-GMSH_API int gmsh::model::occ::addPoint(const double x,
-                                        const double y,
-                                        const double z,
-                                        const double meshSize,
+GMSH_API int gmsh::model::occ::addPoint(const double x, const double y,
+                                        const double z, const double meshSize,
                                         const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addVertex(outTag, x, y, z, meshSize)){
+  if(!GModel::current()->getOCCInternals()->addVertex(outTag, x, y, z,
+                                                      meshSize)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addLine(const int startTag,
-                                       const int endTag,
+GMSH_API int gmsh::model::occ::addLine(const int startTag, const int endTag,
                                        const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addLine(outTag, startTag, endTag)){
+  if(!GModel::current()->getOCCInternals()->addLine(outTag, startTag, endTag)) {
     throw 1;
   }
   return outTag;
@@ -2719,32 +2906,32 @@ GMSH_API int gmsh::model::occ::addLine(const int startTag,
 
 GMSH_API int gmsh::model::occ::addCircleArc(const int startTag,
                                             const int centerTag,
-                                            const int endTag,
-                                            const int tag)
+                                            const int endTag, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addCircleArc
-     (outTag, startTag, centerTag, endTag)){
+  if(!GModel::current()->getOCCInternals()->addCircleArc(outTag, startTag,
+                                                         centerTag, endTag)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addCircle(const double x,
-                                         const double y,
-                                         const double z,
-                                         const double r,
-                                         const int tag,
-                                         const double angle1,
+GMSH_API int gmsh::model::occ::addCircle(const double x, const double y,
+                                         const double z, const double r,
+                                         const int tag, const double angle1,
                                          const double angle2)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addCircle
-     (outTag, x, y, z, r, angle1, angle2)){
+  if(!GModel::current()->getOCCInternals()->addCircle(outTag, x, y, z, r,
+                                                      angle1, angle2)) {
     throw 1;
   }
   return outTag;
@@ -2752,33 +2939,33 @@ GMSH_API int gmsh::model::occ::addCircle(const double x,
 
 GMSH_API int gmsh::model::occ::addEllipseArc(const int startTag,
                                              const int centerTag,
-                                             const int endTag,
-                                             const int tag)
+                                             const int endTag, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addEllipseArc
-     (outTag, startTag, centerTag, endTag)){
+  if(!GModel::current()->getOCCInternals()->addEllipseArc(outTag, startTag,
+                                                          centerTag, endTag)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addEllipse(const double x,
-                                          const double y,
-                                          const double z,
-                                          const double r1,
-                                          const double r2,
-                                          const int tag,
+GMSH_API int gmsh::model::occ::addEllipse(const double x, const double y,
+                                          const double z, const double r1,
+                                          const double r2, const int tag,
                                           const double angle1,
                                           const double angle2)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addEllipse
-     (outTag, x, y, z, r1, r2, angle1, angle2)){
+  if(!GModel::current()->getOCCInternals()->addEllipse(outTag, x, y, z, r1, r2,
+                                                       angle1, angle2)) {
     throw 1;
   }
   return outTag;
@@ -2787,51 +2974,57 @@ GMSH_API int gmsh::model::occ::addEllipse(const double x,
 GMSH_API int gmsh::model::occ::addSpline(const std::vector<int> &pointTags,
                                          const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addSpline(outTag, pointTags)){
+  if(!GModel::current()->getOCCInternals()->addSpline(outTag, pointTags)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addBSpline(const std::vector<int> &pointTags,
-                                          const int tag,
-                                          const int degree,
-                                          const std::vector<double> &weights,
-                                          const std::vector<double> &knots,
-                                          const std::vector<int> &multiplicities)
+GMSH_API int gmsh::model::occ::addBSpline(
+  const std::vector<int> &pointTags, const int tag, const int degree,
+  const std::vector<double> &weights, const std::vector<double> &knots,
+  const std::vector<int> &multiplicities)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addBSpline
-     (outTag, pointTags, degree, weights, knots, multiplicities)){
+  if(!GModel::current()->getOCCInternals()->addBSpline(
+       outTag, pointTags, degree, weights, knots, multiplicities)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addBezier(const std::vector<int> &pointTags, const int tag)
+GMSH_API int gmsh::model::occ::addBezier(const std::vector<int> &pointTags,
+                                         const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addBezier(outTag, pointTags)){
+  if(!GModel::current()->getOCCInternals()->addBezier(outTag, pointTags)) {
     throw 1;
   }
   return outTag;
 }
 
 GMSH_API int gmsh::model::occ::addWire(const std::vector<int> &curveTags,
-                                       const int tag,
-                                       const bool checkClosed)
+                                       const int tag, const bool checkClosed)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addWire
-     (outTag, curveTags, checkClosed)){
+  if(!GModel::current()->getOCCInternals()->addWire(outTag, curveTags,
+                                                    checkClosed)) {
     throw 1;
   }
   return outTag;
@@ -2840,45 +3033,45 @@ GMSH_API int gmsh::model::occ::addWire(const std::vector<int> &curveTags,
 GMSH_API int gmsh::model::occ::addCurveLoop(const std::vector<int> &curveTags,
                                             const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addLineLoop(outTag, curveTags)){
+  if(!GModel::current()->getOCCInternals()->addLineLoop(outTag, curveTags)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addRectangle(const double x,
-                                            const double y,
-                                            const double z,
-                                            const double dx,
-                                            const double dy,
-                                            const int tag,
+GMSH_API int gmsh::model::occ::addRectangle(const double x, const double y,
+                                            const double z, const double dx,
+                                            const double dy, const int tag,
                                             const double roundedRadius)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addRectangle
-     (outTag, x, y, z, dx, dy, roundedRadius)){
+  if(!GModel::current()->getOCCInternals()->addRectangle(outTag, x, y, z, dx,
+                                                         dy, roundedRadius)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addDisk(const double xc,
-                                       const double yc,
-                                       const double zc,
-                                       const double rx,
-                                       const double ry,
-                                       const int tag)
+GMSH_API int gmsh::model::occ::addDisk(const double xc, const double yc,
+                                       const double zc, const double rx,
+                                       const double ry, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addDisk
-     (outTag, xc, yc, zc, rx, ry)){
+  if(!GModel::current()->getOCCInternals()->addDisk(outTag, xc, yc, zc, rx,
+                                                    ry)) {
     throw 1;
   }
   return outTag;
@@ -2887,10 +3080,12 @@ GMSH_API int gmsh::model::occ::addDisk(const double xc,
 GMSH_API int gmsh::model::occ::addPlaneSurface(const std::vector<int> &wireTags,
                                                const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addPlaneSurface(outTag, wireTags)){
+  if(!GModel::current()->getOCCInternals()->addPlaneSurface(outTag, wireTags)) {
     throw 1;
   }
   return outTag;
@@ -2899,22 +3094,29 @@ GMSH_API int gmsh::model::occ::addPlaneSurface(const std::vector<int> &wireTags,
 GMSH_API int gmsh::model::occ::addSurfaceFilling(const int wireTag,
                                                  const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addSurfaceFilling(outTag, wireTag)){
+  if(!GModel::current()->getOCCInternals()->addSurfaceFilling(outTag,
+                                                              wireTag)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addSurfaceLoop(const std::vector<int> &surfaceTags,
-                                              const int tag)
+GMSH_API int
+gmsh::model::occ::addSurfaceLoop(const std::vector<int> &surfaceTags,
+                                 const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addSurfaceLoop(outTag, surfaceTags)){
+  if(!GModel::current()->getOCCInternals()->addSurfaceLoop(outTag,
+                                                           surfaceTags)) {
     throw 1;
   }
   return outTag;
@@ -2923,197 +3125,186 @@ GMSH_API int gmsh::model::occ::addSurfaceLoop(const std::vector<int> &surfaceTag
 GMSH_API int gmsh::model::occ::addVolume(const std::vector<int> &shellTags,
                                          const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addVolume(outTag, shellTags)){
+  if(!GModel::current()->getOCCInternals()->addVolume(outTag, shellTags)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addSphere(const double xc,
-                                         const double yc,
-                                         const double zc,
-                                         const double radius,
-                                         const int tag,
-                                         const double angle1,
+GMSH_API int gmsh::model::occ::addSphere(const double xc, const double yc,
+                                         const double zc, const double radius,
+                                         const int tag, const double angle1,
                                          const double angle2,
                                          const double angle3)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addSphere
-     (outTag, xc, yc, zc, radius, angle1, angle2, angle3)){
+  if(!GModel::current()->getOCCInternals()->addSphere(
+       outTag, xc, yc, zc, radius, angle1, angle2, angle3)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addBox(const double x,
-                                      const double y,
-                                      const double z,
-                                      const double dx,
-                                      const double dy,
-                                      const double dz,
+GMSH_API int gmsh::model::occ::addBox(const double x, const double y,
+                                      const double z, const double dx,
+                                      const double dy, const double dz,
                                       const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addBox
-     (outTag, x, y, z, dx, dy, dz)){
+  if(!GModel::current()->getOCCInternals()->addBox(outTag, x, y, z, dx, dy,
+                                                   dz)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addCylinder(const double x,
-                                           const double y,
-                                           const double z,
-                                           const double dx,
-                                           const double dy,
-                                           const double dz,
-                                           const double r,
-                                           const int tag,
+GMSH_API int gmsh::model::occ::addCylinder(const double x, const double y,
+                                           const double z, const double dx,
+                                           const double dy, const double dz,
+                                           const double r, const int tag,
                                            const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addCylinder
-     (outTag, x, y, z, dx, dy, dz, r, angle)){
+  if(!GModel::current()->getOCCInternals()->addCylinder(outTag, x, y, z, dx, dy,
+                                                        dz, r, angle)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addCone(const double x,
-                                       const double y,
-                                       const double z,
-                                       const double dx,
-                                       const double dy,
-                                       const double dz,
-                                       const double r1,
-                                       const double r2,
-                                       const int tag,
-                                       const double angle)
+GMSH_API int gmsh::model::occ::addCone(const double x, const double y,
+                                       const double z, const double dx,
+                                       const double dy, const double dz,
+                                       const double r1, const double r2,
+                                       const int tag, const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addCone
-     (outTag, x, y, z, dx, dy, dz, r1, r2, angle)){
+  if(!GModel::current()->getOCCInternals()->addCone(outTag, x, y, z, dx, dy, dz,
+                                                    r1, r2, angle)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addWedge(const double x,
-                                        const double y,
-                                        const double z,
-                                        const double dx,
-                                        const double dy,
-                                        const double dz,
-                                        const int tag,
-                                        const double ltx)
+GMSH_API int gmsh::model::occ::addWedge(const double x, const double y,
+                                        const double z, const double dx,
+                                        const double dy, const double dz,
+                                        const int tag, const double ltx)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addWedge
-     (outTag, x, y, z, dx, dy, dz, ltx)){
+  if(!GModel::current()->getOCCInternals()->addWedge(outTag, x, y, z, dx, dy,
+                                                     dz, ltx)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API int gmsh::model::occ::addTorus(const double x,
-                                        const double y,
-                                        const double z,
-                                        const double r1,
-                                        const double r2,
-                                        const int tag,
+GMSH_API int gmsh::model::occ::addTorus(const double x, const double y,
+                                        const double z, const double r1,
+                                        const double r2, const int tag,
                                         const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   int outTag = tag;
-  if(!GModel::current()->getOCCInternals()->addTorus
-     (outTag, x, y, z, r1, r2, angle)){
+  if(!GModel::current()->getOCCInternals()->addTorus(outTag, x, y, z, r1, r2,
+                                                     angle)) {
     throw 1;
   }
   return outTag;
 }
 
-GMSH_API void gmsh::model::occ::addThruSections(const std::vector<int> &wireTags,
-                                                vectorpair &outDimTags,
-                                                const int tag,
-                                                const bool makeSolid,
-                                                const bool makeRuled)
+GMSH_API void
+gmsh::model::occ::addThruSections(const std::vector<int> &wireTags,
+                                  vectorpair &outDimTags, const int tag,
+                                  const bool makeSolid, const bool makeRuled)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->addThruSections
-     (tag, wireTags, makeSolid, makeRuled, outDimTags)){
+  if(!GModel::current()->getOCCInternals()->addThruSections(
+       tag, wireTags, makeSolid, makeRuled, outDimTags)) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::occ::addThickSolid(const int volumeTag,
-                                              const std::vector<int> &excludeSurfaceTags,
-                                              const double offset,
-                                              vectorpair &outDimTags,
-                                              const int tag)
+GMSH_API void gmsh::model::occ::addThickSolid(
+  const int volumeTag, const std::vector<int> &excludeSurfaceTags,
+  const double offset, vectorpair &outDimTags, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->addThickSolid
-     (tag, volumeTag, excludeSurfaceTags, offset, outDimTags)){
+  if(!GModel::current()->getOCCInternals()->addThickSolid(
+       tag, volumeTag, excludeSurfaceTags, offset, outDimTags)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::extrude(const vectorpair &dimTags,
-                                        const double dx,
-                                        const double dy,
-                                        const double dz,
-                                        vectorpair &outDimTags,
+                                        const double dx, const double dy,
+                                        const double dz, vectorpair &outDimTags,
                                         const std::vector<int> &numElements,
                                         const std::vector<double> &heights,
                                         const bool recombine)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->extrude
-    (dimTags, dx, dy, dz, outDimTags,
-     _getExtrudeParams(numElements, heights, recombine))){
+  if(!GModel::current()->getOCCInternals()->extrude(
+       dimTags, dx, dy, dz, outDimTags,
+       _getExtrudeParams(numElements, heights, recombine))) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::occ::revolve(const vectorpair &dimTags,
-                                        const double x,
-                                        const double y,
-                                        const double z,
-                                        const double ax,
-                                        const double ay,
-                                        const double az,
-                                        const double angle, vectorpair &outDimTags,
-                                        const std::vector<int> &numElements,
-                                        const std::vector<double> &heights,
-                                        const bool recombine)
+GMSH_API void gmsh::model::occ::revolve(
+  const vectorpair &dimTags, const double x, const double y, const double z,
+  const double ax, const double ay, const double az, const double angle,
+  vectorpair &outDimTags, const std::vector<int> &numElements,
+  const std::vector<double> &heights, const bool recombine)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->revolve
-     (dimTags, x, y, z, ax, ay, az, angle, outDimTags,
-      _getExtrudeParams(numElements, heights, recombine))){
+  if(!GModel::current()->getOCCInternals()->revolve(
+       dimTags, x, y, z, ax, ay, az, angle, outDimTags,
+       _getExtrudeParams(numElements, heights, recombine))) {
     throw 1;
   }
 }
@@ -3122,11 +3313,13 @@ GMSH_API void gmsh::model::occ::addPipe(const vectorpair &dimTags,
                                         const int wireTag,
                                         vectorpair &outDimTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->addPipe
-     (dimTags, wireTag, outDimTags)){
+  if(!GModel::current()->getOCCInternals()->addPipe(dimTags, wireTag,
+                                                    outDimTags)) {
     throw 1;
   }
 }
@@ -3137,11 +3330,13 @@ GMSH_API void gmsh::model::occ::fillet(const std::vector<int> &volumeTags,
                                        vectorpair &outDimTags,
                                        const bool removeVolume)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->fillet
-     (volumeTags, curveTags, radii, outDimTags, removeVolume)){
+  if(!GModel::current()->getOCCInternals()->fillet(volumeTags, curveTags, radii,
+                                                   outDimTags, removeVolume)) {
     throw 1;
   }
 }
@@ -3153,11 +3348,14 @@ GMSH_API void gmsh::model::occ::chamfer(const std::vector<int> &volumeTags,
                                         vectorpair &outDimTags,
                                         const bool removeVolume)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->chamfer
-     (volumeTags, curveTags, surfaceTags, distances, outDimTags, removeVolume)){
+  if(!GModel::current()->getOCCInternals()->chamfer(volumeTags, curveTags,
+                                                    surfaceTags, distances,
+                                                    outDimTags, removeVolume)) {
     throw 1;
   }
 }
@@ -3166,36 +3364,36 @@ GMSH_API void gmsh::model::occ::fuse(const vectorpair &objectDimTags,
                                      const vectorpair &toolDimTags,
                                      vectorpair &outDimTags,
                                      std::vector<vectorpair> &outDimTagsMap,
-                                     const int tag,
-                                     const bool removeObject,
+                                     const int tag, const bool removeObject,
                                      const bool removeTool)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  if(!GModel::current()->getOCCInternals()->booleanUnion
-     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-      removeObject, removeTool)){
+  if(!GModel::current()->getOCCInternals()->booleanUnion(
+       tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap, removeObject,
+       removeTool)) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::occ::intersect(const vectorpair &objectDimTags,
-                                          const vectorpair &toolDimTags,
-                                          vectorpair &outDimTags,
-                                          std::vector<vectorpair> &outDimTagsMap,
-                                          const int tag,
-                                          const bool removeObject,
-                                          const bool removeTool)
+GMSH_API void gmsh::model::occ::intersect(
+  const vectorpair &objectDimTags, const vectorpair &toolDimTags,
+  vectorpair &outDimTags, std::vector<vectorpair> &outDimTagsMap, const int tag,
+  const bool removeObject, const bool removeTool)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  if(!GModel::current()->getOCCInternals()->booleanIntersection
-     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-      removeObject, removeTool)){
+  if(!GModel::current()->getOCCInternals()->booleanIntersection(
+       tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap, removeObject,
+       removeTool)) {
     throw 1;
   }
 }
@@ -3204,17 +3402,18 @@ GMSH_API void gmsh::model::occ::cut(const vectorpair &objectDimTags,
                                     const vectorpair &toolDimTags,
                                     vectorpair &outDimTags,
                                     std::vector<vectorpair> &outDimTagsMap,
-                                    const int tag,
-                                    const bool removeObject,
+                                    const int tag, const bool removeObject,
                                     const bool removeTool)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  if(!GModel::current()->getOCCInternals()->booleanDifference
-     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-      removeObject, removeTool)){
+  if(!GModel::current()->getOCCInternals()->booleanDifference(
+       tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap, removeObject,
+       removeTool)) {
     throw 1;
   }
 }
@@ -3223,75 +3422,74 @@ GMSH_API void gmsh::model::occ::fragment(const vectorpair &objectDimTags,
                                          const vectorpair &toolDimTags,
                                          vectorpair &outDimTags,
                                          std::vector<vectorpair> &outDimTagsMap,
-                                         const int tag,
-                                         const bool removeObject,
+                                         const int tag, const bool removeObject,
                                          const bool removeTool)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
   outDimTagsMap.clear();
-  if(!GModel::current()->getOCCInternals()->booleanFragments
-     (tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap,
-      removeObject, removeTool)){
+  if(!GModel::current()->getOCCInternals()->booleanFragments(
+       tag, objectDimTags, toolDimTags, outDimTags, outDimTagsMap, removeObject,
+       removeTool)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::translate(const vectorpair &dimTags,
-                                          const double dx,
-                                          const double dy,
+                                          const double dx, const double dy,
                                           const double dz)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  if(!GModel::current()->getOCCInternals()->translate(dimTags, dx, dy, dz)){
+  if(!GModel::current()->getOCCInternals()->translate(dimTags, dx, dy, dz)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::rotate(const vectorpair &dimTags,
-                                       const double x,
-                                       const double y,
-                                       const double z,
-                                       const double ax,
-                                       const double ay,
-                                       const double az,
+                                       const double x, const double y,
+                                       const double z, const double ax,
+                                       const double ay, const double az,
                                        const double angle)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  if(!GModel::current()->getOCCInternals()->rotate
-     (dimTags, x, y, z, ax, ay, az, angle)){
+  if(!GModel::current()->getOCCInternals()->rotate(dimTags, x, y, z, ax, ay, az,
+                                                   angle)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::dilate(const vectorpair &dimTags,
-                                       const double x,
-                                       const double y,
-                                       const double z,
-                                       const double a,
-                                       const double b,
-                                       const double c)
-{
-  if(!_isInitialized()){ throw -1; }
+                                       const double x, const double y,
+                                       const double z, const double a,
+                                       const double b, const double c)
+{
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  if(!GModel::current()->getOCCInternals()->dilate
-     (dimTags, x, y, z, a, b, c)){
+  if(!GModel::current()->getOCCInternals()->dilate(dimTags, x, y, z, a, b, c)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::symmetry(const vectorpair &dimTags,
-                                         const double a,
-                                         const double b,
-                                         const double c,
-                                         const double d)
+                                         const double a, const double b,
+                                         const double c, const double d)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  if(!GModel::current()->getOCCInternals()->symmetry(dimTags, a, b, c, d)){
+  if(!GModel::current()->getOCCInternals()->symmetry(dimTags, a, b, c, d)) {
     throw 1;
   }
 }
@@ -3299,10 +3497,12 @@ GMSH_API void gmsh::model::occ::symmetry(const vectorpair &dimTags,
 GMSH_API void gmsh::model::occ::copy(const vectorpair &dimTags,
                                      vectorpair &outDimTags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->copy(dimTags, outDimTags)){
+  if(!GModel::current()->getOCCInternals()->copy(dimTags, outDimTags)) {
     throw 1;
   }
 }
@@ -3310,16 +3510,20 @@ GMSH_API void gmsh::model::occ::copy(const vectorpair &dimTags,
 GMSH_API void gmsh::model::occ::remove(const vectorpair &dimTags,
                                        const bool recursive)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  if(!GModel::current()->getOCCInternals()->remove(dimTags, recursive)){
+  if(!GModel::current()->getOCCInternals()->remove(dimTags, recursive)) {
     throw 1;
   }
 }
 
 GMSH_API void gmsh::model::occ::removeAllDuplicates()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   GModel::current()->getOCCInternals()->removeAllDuplicates();
 }
@@ -3329,39 +3533,44 @@ GMSH_API void gmsh::model::occ::importShapes(const std::string &fileName,
                                              const bool highestDimOnly,
                                              const std::string &format)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
-  if(!GModel::current()->getOCCInternals()->importShapes
-     (fileName, highestDimOnly, outDimTags, format)){
+  if(!GModel::current()->getOCCInternals()->importShapes(
+       fileName, highestDimOnly, outDimTags, format)) {
     throw 1;
   }
 }
 
-GMSH_API void gmsh::model::occ::importShapesNativePointer(const void *shape,
-                                                          vectorpair &outDimTags,
-                                                          const bool highestDimOnly)
+GMSH_API void gmsh::model::occ::importShapesNativePointer(
+  const void *shape, vectorpair &outDimTags, const bool highestDimOnly)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   outDimTags.clear();
 #if defined(HAVE_OCC)
-  if(!GModel::current()->getOCCInternals()->importShapes
-     (static_cast<const TopoDS_Shape*>(shape), highestDimOnly, outDimTags)){
+  if(!GModel::current()->getOCCInternals()->importShapes(
+       static_cast<const TopoDS_Shape *>(shape), highestDimOnly, outDimTags)) {
     throw 1;
   }
 #else
   Msg::Error("Gmsh requires OpenCASCADE to import native shape");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::model::occ::setMeshSize(const vectorpair &dimTags,
                                             const double size)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
-  for(unsigned int i = 0; i < dimTags.size(); i++){
+  for(unsigned int i = 0; i < dimTags.size(); i++) {
     int dim = dimTags[i].first, tag = dimTags[i].second;
     GModel::current()->getOCCInternals()->setMeshSize(dim, tag, size);
   }
@@ -3369,17 +3578,20 @@ GMSH_API void gmsh::model::occ::setMeshSize(const vectorpair &dimTags,
 
 GMSH_API void gmsh::model::occ::synchronize()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
   _createOcc();
   GModel::current()->getOCCInternals()->synchronize(GModel::current());
 }
 
 // gmsh::view
 
-GMSH_API int gmsh::view::add(const std::string &name,
-                             const int tag)
+GMSH_API int gmsh::view::add(const std::string &name, const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = new PView(tag);
   view->getData()->setName(name);
@@ -3389,16 +3601,18 @@ GMSH_API int gmsh::view::add(const std::string &name,
   return view->getTag();
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::view::remove(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
@@ -3408,70 +3622,72 @@ GMSH_API void gmsh::view::remove(const int tag)
 #endif
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API int gmsh::view::getIndex(const int tag)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
   return view->getIndex();
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::view::getTags(std::vector<int> &tags)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   tags.clear();
   for(unsigned int i = 0; i < PView::list.size(); i++)
     tags.push_back(PView::list[i]->getTag());
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
-GMSH_API void gmsh::view::addModelData(const int tag,
-                                       const int step,
-                                       const std::string &modelName,
-                                       const std::string &dataType,
-                                       const std::vector<int> &tags,
-                                       const std::vector<std::vector<double> > &data,
-                                       const double time,
-                                       const int numComponents,
-                                       const int partition)
+GMSH_API void gmsh::view::addModelData(
+  const int tag, const int step, const std::string &modelName,
+  const std::string &dataType, const std::vector<int> &tags,
+  const std::vector<std::vector<double> > &data, const double time,
+  const int numComponents, const int partition)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
   GModel *model = GModel::current();
-  if(modelName.size()){
+  if(modelName.size()) {
     model = GModel::findByName(modelName);
-    if(!model){
+    if(!model) {
       Msg::Error("Unknown model '%s'", modelName.c_str());
       throw 2;
     }
   }
-  if(tags.size() != data.size()){
+  if(tags.size() != data.size()) {
     Msg::Error("Incompatible number of tags and data");
     throw 2;
   }
-  PViewDataGModel *d = dynamic_cast<PViewDataGModel*>(view->getData());
-  if(!d){ // change the view type
+  PViewDataGModel *d = dynamic_cast<PViewDataGModel *>(view->getData());
+  if(!d) { // change the view type
     std::string name = view->getData()->getName();
     delete view->getData();
     PViewDataGModel::DataType type;
@@ -3485,7 +3701,7 @@ GMSH_API void gmsh::view::addModelData(const int tag,
       type = PViewDataGModel::GaussPointData;
     else if(dataType == "Beam")
       type = PViewDataGModel::BeamData;
-    else{
+    else {
       Msg::Error("Unknown type of view to add '%s'", dataType.c_str());
       throw 2;
     }
@@ -3501,27 +3717,27 @@ GMSH_API void gmsh::view::addModelData(const int tag,
                         view->getOptions()->targetError);
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
-GMSH_API void gmsh::view::getModelData(const int tag,
-                                       const int step,
+GMSH_API void gmsh::view::getModelData(const int tag, const int step,
                                        std::string &dataType,
                                        std::vector<int> &tags,
                                        std::vector<std::vector<double> > &data,
-                                       double &time,
-                                       int &numComponents)
+                                       double &time, int &numComponents)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
-  PViewDataGModel *d = dynamic_cast<PViewDataGModel*>(view->getData());
-  if(!d){
+  PViewDataGModel *d = dynamic_cast<PViewDataGModel *>(view->getData());
+  if(!d) {
     Msg::Error("View with tag %d does not contain model data", tag);
     return;
   }
@@ -3538,9 +3754,9 @@ GMSH_API void gmsh::view::getModelData(const int tag,
   else
     dataType = "Unknown";
   stepData<double> *s = d->getStepData(step);
-  if(!s){
-    Msg::Error("View with tag %d does not contain model data for step %d",
-               tag, step);
+  if(!s) {
+    Msg::Error("View with tag %d does not contain model data for step %d", tag,
+               step);
     throw 2;
   }
   tags.clear();
@@ -3548,52 +3764,47 @@ GMSH_API void gmsh::view::getModelData(const int tag,
   time = s->getTime();
   numComponents = s->getNumComponents();
   int numEnt = 0;
-  for(int i = 0; i < s->getNumData(); i++){
+  for(int i = 0; i < s->getNumData(); i++) {
     if(s->getData(i)) numEnt++;
   }
   if(!numEnt) return;
   data.resize(numEnt);
   tags.resize(numEnt);
   int j = 0;
-  for(int i = 0; i < s->getNumData(); i++){
+  for(int i = 0; i < s->getNumData(); i++) {
     double *dd = s->getData(i);
-    if(dd){
+    if(dd) {
       tags[j] = i;
       int mult = s->getMult(i);
       data[j].resize(numComponents * mult);
-      for(int k = 0; k < numComponents * mult; k++)
-        data[j][k] = dd[k];
+      for(int k = 0; k < numComponents * mult; k++) data[j][k] = dd[k];
       j++;
     }
   }
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 // for better performance, manual C implementation of gmsh::view::getModelData
-GMSH_API void gmshViewGetModelData(const int tag,
-                                   const int step,
-                                   char ** dataType,
-                                   int ** tags,
-                                   size_t * tags_n,
-                                   double *** data,
-                                   size_t ** data_n,
-                                   size_t * data_nn,
-                                   double * time,
-                                   int * numComponents,
-                                   int * ierr)
-{
-  if(!_isInitialized()){ if(ierr) *ierr = -1; }
+GMSH_API void gmshViewGetModelData(const int tag, const int step,
+                                   char **dataType, int **tags, size_t *tags_n,
+                                   double ***data, size_t **data_n,
+                                   size_t *data_nn, double *time,
+                                   int *numComponents, int *ierr)
+{
+  if(!_isInitialized()) {
+    if(ierr) *ierr = -1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     if(ierr) *ierr = 2;
   }
-  PViewDataGModel *d = dynamic_cast<PViewDataGModel*>(view->getData());
-  if(!d){
+  PViewDataGModel *d = dynamic_cast<PViewDataGModel *>(view->getData());
+  if(!d) {
     Msg::Error("View with tag %d does not contain model data", tag);
     return;
   }
@@ -3610,9 +3821,9 @@ GMSH_API void gmshViewGetModelData(const int tag,
   else
     *dataType = strdup("Unknown");
   stepData<double> *s = d->getStepData(step);
-  if(!s){
-    Msg::Error("View with tag %d does not contain model data for step %d",
-               tag, step);
+  if(!s) {
+    Msg::Error("View with tag %d does not contain model data for step %d", tag,
+               step);
     if(ierr) *ierr = 2;
   }
   *tags_n = 0;
@@ -3620,21 +3831,20 @@ GMSH_API void gmshViewGetModelData(const int tag,
   *time = s->getTime();
   *numComponents = s->getNumComponents();
   int numEnt = 0;
-  for(int i = 0; i < s->getNumData(); i++){
+  for(int i = 0; i < s->getNumData(); i++) {
     if(s->getData(i)) numEnt++;
   }
   if(!numEnt) return;
-  *data = (double**)Malloc(numEnt * sizeof(double*));
-  *tags = (int*)Malloc(numEnt * sizeof(int));
+  *data = (double **)Malloc(numEnt * sizeof(double *));
+  *tags = (int *)Malloc(numEnt * sizeof(int));
   int j = 0;
-  for(int i = 0; i < s->getNumData(); i++){
+  for(int i = 0; i < s->getNumData(); i++) {
     double *dd = s->getData(i);
-    if(dd){
+    if(dd) {
       (*tags)[j] = i;
       int mult = s->getMult(i);
-      (*data)[j] = (double*)Malloc(*numComponents * mult * sizeof(double));
-      for(int k = 0; k < *numComponents * mult; k++)
-        (*data)[j][k] = dd[k];
+      (*data)[j] = (double *)Malloc(*numComponents * mult * sizeof(double));
+      for(int k = 0; k < *numComponents * mult; k++) (*data)[j][k] = dd[k];
       j++;
     }
   }
@@ -3649,15 +3859,17 @@ GMSH_API void gmsh::view::addListData(const int tag,
                                       const int numElements,
                                       const std::vector<double> &data)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
-  PViewDataList *d = dynamic_cast<PViewDataList*>(view->getData());
-  if(!d){ // change the view type
+  PViewDataList *d = dynamic_cast<PViewDataList *>(view->getData());
+  if(!d) { // change the view type
     std::string name = view->getData()->getName();
     delete view->getData();
     d = new PViewDataList();
@@ -3665,11 +3877,11 @@ GMSH_API void gmsh::view::addListData(const int tag,
     d->setFileName(name + ".pos");
     view->setData(d);
   }
-  const char *types[] = {"SP", "VP", "TP", "SL", "VL", "TL", "ST", "VT", "TT",
-                         "SQ", "VQ", "TQ", "SS", "VS", "TS", "SH", "VH", "TH",
-                         "SI", "VI", "TI", "SY", "VY", "TY"};
-  for(int idxtype = 0; idxtype < 24; idxtype++){
-    if(dataType == types[idxtype]){
+  const char *types[] = {"SP", "VP", "TP", "SL", "VL", "TL", "ST", "VT",
+                         "TT", "SQ", "VQ", "TQ", "SS", "VS", "TS", "SH",
+                         "VH", "TH", "SI", "VI", "TI", "SY", "VY", "TY"};
+  for(int idxtype = 0; idxtype < 24; idxtype++) {
+    if(dataType == types[idxtype]) {
       d->importList(idxtype, numElements, data, true);
       return;
     }
@@ -3678,7 +3890,7 @@ GMSH_API void gmsh::view::addListData(const int tag,
   throw 2;
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -3687,26 +3899,28 @@ GMSH_API void gmsh::view::getListData(const int tag,
                                       std::vector<int> &numElements,
                                       std::vector<std::vector<double> > &data)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
-  PViewDataList *d = dynamic_cast<PViewDataList*>(view->getData());
-  if(!d){
+  PViewDataList *d = dynamic_cast<PViewDataList *>(view->getData());
+  if(!d) {
     Msg::Error("View with tag %d does not contain list data", tag);
     return;
   }
-  const char *types[] = {"SP", "VP", "TP", "SL", "VL", "TL", "ST", "VT", "TT",
-                         "SQ", "VQ", "TQ", "SS", "VS", "TS", "SH", "VH", "TH",
-                         "SI", "VI", "TI", "SY", "VY", "TY"};
+  const char *types[] = {"SP", "VP", "TP", "SL", "VL", "TL", "ST", "VT",
+                         "TT", "SQ", "VQ", "TQ", "SS", "VS", "TS", "SH",
+                         "VH", "TH", "SI", "VI", "TI", "SY", "VY", "TY"};
   std::vector<int> N(24);
-  std::vector< std::vector<double>* > V(24);
+  std::vector<std::vector<double> *> V(24);
   d->getListPointers(&N[0], &V[0]);
-  for(int idxtype = 0; idxtype < 24; idxtype++){
-    if(N[idxtype]){
+  for(int idxtype = 0; idxtype < 24; idxtype++) {
+    if(N[idxtype]) {
       dataTypes.push_back(types[idxtype]);
       numElements.push_back(N[idxtype]);
       data.push_back(*V[idxtype]);
@@ -3714,32 +3928,31 @@ GMSH_API void gmsh::view::getListData(const int tag,
   }
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
-GMSH_API void gmsh::view::probe(const int tag,
-                                const double x,
-                                const double y,
-                                const double z,
-                                std::vector<double> &value,
-                                const int step,
-                                const int numComp,
-                                const bool gradient,
-                                const double tolerance,
+GMSH_API void gmsh::view::probe(const int tag, const double x, const double y,
+                                const double z, std::vector<double> &value,
+                                const int step, const int numComp,
+                                const bool gradient, const double tolerance,
                                 const std::vector<double> &xElemCoord,
                                 const std::vector<double> &yElemCoord,
                                 const std::vector<double> &zElemCoord)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
   PViewData *data = view->getData();
-  if(!data){ throw 2; }
+  if(!data) {
+    throw 2;
+  }
   value.clear();
   std::vector<double> val(9 * data->getNumTimeSteps());
   bool found = false;
@@ -3747,59 +3960,59 @@ GMSH_API void gmsh::view::probe(const int tag,
   double *qx = 0, *qy = 0, *qz = 0;
   if(xElemCoord.size() && yElemCoord.size() && zElemCoord.size() &&
      xElemCoord.size() == yElemCoord.size() &&
-     xElemCoord.size() == zElemCoord.size()){
+     xElemCoord.size() == zElemCoord.size()) {
     qn = xElemCoord.size();
-    qx = (double*)&xElemCoord[0];
-    qy = (double*)&yElemCoord[0];
-    qz = (double*)&zElemCoord[0];
+    qx = (double *)&xElemCoord[0];
+    qy = (double *)&yElemCoord[0];
+    qz = (double *)&zElemCoord[0];
   }
-  switch(numComp){
+  switch(numComp) {
   case 1:
-    found = data->searchScalarWithTol
-      (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+    found = data->searchScalarWithTol(x, y, z, &val[0], step, 0, tolerance, qn,
+                                      qx, qy, qz, gradient);
     break;
   case 3:
-    found = data->searchVectorWithTol
-      (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+    found = data->searchVectorWithTol(x, y, z, &val[0], step, 0, tolerance, qn,
+                                      qx, qy, qz, gradient);
     break;
   case 9:
-    found = data->searchTensorWithTol
-      (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+    found = data->searchTensorWithTol(x, y, z, &val[0], step, 0, tolerance, qn,
+                                      qx, qy, qz, gradient);
     break;
   default:
-    found = data->searchScalarWithTol
-      (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+    found = data->searchScalarWithTol(x, y, z, &val[0], step, 0, tolerance, qn,
+                                      qx, qy, qz, gradient);
     if(!found)
-      found = data->searchVectorWithTol
-        (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+      found = data->searchVectorWithTol(x, y, z, &val[0], step, 0, tolerance,
+                                        qn, qx, qy, qz, gradient);
     if(!found)
-      found = data->searchTensorWithTol
-        (x, y, z, &val[0], step, 0, tolerance, qn, qx, qy, qz, gradient);
+      found = data->searchTensorWithTol(x, y, z, &val[0], step, 0, tolerance,
+                                        qn, qx, qy, qz, gradient);
     break;
   }
-  if(found)
-    value.insert(value.end(), val.begin(), val.end());
+  if(found) value.insert(value.end(), val.begin(), val.end());
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
-GMSH_API void gmsh::view::write(const int tag,
-                                const std::string &fileName,
+GMSH_API void gmsh::view::write(const int tag, const std::string &fileName,
                                 const bool append)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_POST)
   PView *view = PView::getViewByTag(tag);
-  if(!view){
+  if(!view) {
     Msg::Error("Unknown view with tag %d", tag);
     throw 2;
   }
   view->write(fileName, 10, append);
 #else
   Msg::Error("Views require the post-processing module");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -3809,18 +4022,19 @@ GMSH_API void gmsh::plugin::setNumber(const std::string &name,
                                       const std::string &option,
                                       const double value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_PLUGINS)
   try {
     PluginManager::instance()->setPluginOption(name, option, value);
-  }
-  catch(...) {
+  } catch(...) {
     Msg::Error("Unknown plugin or plugin option");
     throw 2;
   }
 #else
   Msg::Error("Views require the post-processing and plugin modules");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -3828,35 +4042,37 @@ GMSH_API void gmsh::plugin::setString(const std::string &name,
                                       const std::string &option,
                                       const std::string &value)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_PLUGINS)
   try {
     PluginManager::instance()->setPluginOption(name, option, value);
-  }
-  catch(...) {
+  } catch(...) {
     Msg::Error("Unknown plugin or plugin option");
     throw 2;
   }
 #else
   Msg::Error("Views require the post-processing and plugin modules");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::plugin::run(const std::string &name)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_PLUGINS)
   try {
     PluginManager::instance()->action(name, "Run", 0);
-  }
-  catch(...) {
+  } catch(...) {
     Msg::Error("Unknown plugin or plugin action");
     throw 2;
   }
 #else
   Msg::Error("Views require the post-processing and plugin modules");
-  throw -1;
+  throw - 1;
 #endif
 }
 
@@ -3873,52 +4089,57 @@ GMSH_API void gmsh::graphics::draw()
 
 GMSH_API void gmsh::fltk::initialize()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_FLTK)
   FlGui::instance(_argc, _argv);
   FlGui::setFinishedProcessingCommandLine();
   FlGui::check();
 #else
   Msg::Error("Fltk not available");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::fltk::wait(const double time)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_FLTK)
-  if(!FlGui::available())
-    FlGui::instance(_argc, _argv);
+  if(!FlGui::available()) FlGui::instance(_argc, _argv);
   if(time >= 0)
     FlGui::wait(time);
   else
     FlGui::wait();
 #else
   Msg::Error("Fltk not available");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::fltk::run()
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_FLTK)
-  if(!FlGui::available())
-    FlGui::instance(_argc, _argv);
+  if(!FlGui::available()) FlGui::instance(_argc, _argv);
   FlGui::instance()->run(); // this calls draw() once
 #else
   Msg::Error("Fltk not available");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 // gmsh::onelab
 
-GMSH_API void gmsh::onelab::get(std::string &data,
-                                const std::string &format)
+GMSH_API void gmsh::onelab::get(std::string &data, const std::string &format)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_ONELAB)
   if(format == "json")
     ::onelab::server::instance()->toJSON(data, "Gmsh");
@@ -3926,14 +4147,16 @@ GMSH_API void gmsh::onelab::get(std::string &data,
     Msg::Error("Unknown data format");
 #else
   Msg::Error("Onelab not available");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::onelab::set(const std::string &data,
                                 const std::string &format)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_ONELAB)
   if(format == "json")
     ::onelab::server::instance()->fromJSON(data);
@@ -3941,14 +4164,16 @@ GMSH_API void gmsh::onelab::set(const std::string &data,
     Msg::Error("Unknown data format");
 #else
   Msg::Error("Onelab not available");
-  throw -1;
+  throw - 1;
 #endif
 }
 
 GMSH_API void gmsh::onelab::run(const std::string &name,
                                 const std::string &command)
 {
-  if(!_isInitialized()){ throw -1; }
+  if(!_isInitialized()) {
+    throw - 1;
+  }
 #if defined(HAVE_ONELAB)
   onelabUtils::runClient(name, command);
 #endif
diff --git a/Common/gmshLocalNetworkClient.cpp b/Common/gmshLocalNetworkClient.cpp
index d9bce6e687f915bb8d233aa37b04e4eb4553109b..20b1fe0ff1c6525fc3a8ee50d8f1ac2ca58c08e7 100644
--- a/Common/gmshLocalNetworkClient.cpp
+++ b/Common/gmshLocalNetworkClient.cpp
@@ -35,13 +35,16 @@ typedef unsigned long intptr_t;
 #include "metamodel.h"
 #endif
 
-class onelabGmshServer : public GmshServer{
- private:
+class onelabGmshServer : public GmshServer {
+private:
   onelab::localNetworkClient *_client;
- public:
+
+public:
   onelabGmshServer(onelab::localNetworkClient *client)
-    : GmshServer(), _client(client) {}
-  ~onelabGmshServer(){}
+    : GmshServer(), _client(client)
+  {
+  }
+  ~onelabGmshServer() {}
   int NonBlockingSystemCall(const std::string &exe, const std::string &args)
   {
     return SystemCallExe(exe, args);
@@ -49,40 +52,40 @@ class onelabGmshServer : public GmshServer{
   int NonBlockingWait(double waitint, double timeout, int socket)
   {
     double start = GetTimeInSeconds();
-    while(1){
+    while(1) {
       if(timeout > 0 && GetTimeInSeconds() - start > timeout)
         return 2; // timeout
-      if(_client->getPid() < 0 || (_client->getExecutable().empty() &&
-                                   !CTX::instance()->solver.listen))
+      if(_client->getPid() < 0 ||
+         (_client->getExecutable().empty() && !CTX::instance()->solver.listen))
         return 1; // process has been killed or we stopped listening
       int ret = 0;
 #if defined(HAVE_FLTK)
-      if(FlGui::available()){
+      if(FlGui::available()) {
         // if GUI available, check if there is data and return immediately (we
         // will wait for GUI events later - see below)
         ret = Select(0, 0, socket);
       }
-      else{
+      else {
         ret = Select(0, waitint * 1e6, socket);
       }
 #else
       ret = Select(0, waitint * 1e6, socket);
 #endif
-      if(ret == 0){ // nothing available
+      if(ret == 0) { // nothing available
 #if defined(HAVE_FLTK)
-        if(FlGui::available()){
-          if(timeout < 0){
-            // if asked, refresh the onelab GUI, but no more than every 1/4th of a
-            // second
+        if(FlGui::available()) {
+          if(timeout < 0) {
+            // if asked, refresh the onelab GUI, but no more than every 1/4th of
+            // a second
             static double lastRefresh = 0.;
-            if(start - lastRefresh > 0.25){
+            if(start - lastRefresh > 0.25) {
               std::vector<onelab::string> ps;
               onelab::server::instance()->get(ps, "Gmsh/Action");
-              if(ps.size() && ps[0].getValue() == "refresh"){
+              if(ps.size() && ps[0].getValue() == "refresh") {
                 ps[0].setVisible(false);
                 ps[0].setValue("");
                 onelab::server::instance()->set(ps[0]);
-                if(FlGui::available()) onelab_cb(0, (void*)"refresh");
+                if(FlGui::available()) onelab_cb(0, (void *)"refresh");
               }
               lastRefresh = start;
             }
@@ -92,12 +95,12 @@ class onelabGmshServer : public GmshServer{
         }
 #endif
         // return to caller (we will be back here soon again)
-	if(timeout < 0) return 3;
+        if(timeout < 0) return 3;
       }
-      else if(ret > 0){
+      else if(ret > 0) {
         return 0; // data is there!
       }
-      else{
+      else {
         // an error happened
         _client->setPid(-1);
         return 1;
@@ -109,17 +112,18 @@ class onelabGmshServer : public GmshServer{
     std::string sockname;
     std::ostringstream tmp;
     const char *port = strstr(CTX::instance()->solver.socketName.c_str(), ":");
-    if(!port){
+    if(!port) {
       // Unix socket
       tmp << CTX::instance()->homeDir << CTX::instance()->solver.socketName
           << _client->getId();
       sockname = FixWindowsPath(tmp.str());
     }
-    else{
+    else {
       // TCP/IP socket
       if(CTX::instance()->solver.socketName.size() &&
          CTX::instance()->solver.socketName[0] == ':')
-        tmp << GetHostName(); // prepend hostname if only the port number is given
+        tmp
+          << GetHostName(); // prepend hostname if only the port number is given
       tmp << CTX::instance()->solver.socketName;
       if(atoi(port + 1)) // nonzero port is given - append client id
         tmp << _client->getId();
@@ -128,28 +132,26 @@ class onelabGmshServer : public GmshServer{
 
     std::string exe = FixWindowsPath(_client->getExecutable());
     std::string args;
-    if(exe.size()){
-      if(_client->treatExecutableAsFullCommandLine()){
+    if(exe.size()) {
+      if(_client->treatExecutableAsFullCommandLine()) {
         args = exe;
         exe = "";
       }
-      else{
+      else {
         std::vector<std::string> cl = onelabUtils::getCommandLine(_client);
-        for(unsigned int i = 0; i < cl.size(); i++)
-          args.append(" " + cl[i]);
+        for(unsigned int i = 0; i < cl.size(); i++) args.append(" " + cl[i]);
       }
-      args.append(" " + _client->getSocketSwitch() +
-                  " \"" + _client->getName() + "\" %s");
+      args.append(" " + _client->getSocketSwitch() + " \"" +
+                  _client->getName() + "\" %s");
     }
-    else{
+    else {
       Msg::Info("Listening on socket '%s'", sockname.c_str());
     }
 
     int sock;
-    try{
+    try {
       sock = Start(exe, args, sockname, CTX::instance()->solver.timeout);
-    }
-    catch(const char *err){
+    } catch(const char *err) {
       Msg::Error("Abnormal server termination (%s on socket %s)", err,
                  sockname.c_str());
       sock = -1;
@@ -163,9 +165,9 @@ static std::string tryToGetGmshNumberOption(const std::string &name)
 {
   std::string reply;
   std::string::size_type dot = name.find('.');
-  if(dot != std::string::npos){
+  if(dot != std::string::npos) {
     double val;
-    if(GmshGetOption(name.substr(0, dot), name.substr(dot + 1), val)){
+    if(GmshGetOption(name.substr(0, dot), name.substr(dot + 1), val)) {
       onelab::number par(name, val);
       reply = par.toChar();
     }
@@ -177,9 +179,9 @@ static std::string tryToGetGmshStringOption(const std::string &name)
 {
   std::string reply;
   std::string::size_type dot = name.find('.');
-  if(dot != std::string::npos){
+  if(dot != std::string::npos) {
     std::string val;
-    if(GmshGetOption(name.substr(0, dot), name.substr(dot + 1), val)){
+    if(GmshGetOption(name.substr(0, dot), name.substr(dot + 1), val)) {
       onelab::string par(name, val);
       reply = par.toChar();
     }
@@ -191,7 +193,7 @@ static bool tryToSetGmshNumberOption(onelab::number &p)
 {
   const std::string &name = p.getName();
   std::string::size_type dot = name.find('.');
-  if(dot != std::string::npos){
+  if(dot != std::string::npos) {
     double val = p.getValue();
     return GmshSetOption(name.substr(0, dot), name.substr(dot + 1), val);
   }
@@ -202,7 +204,7 @@ static bool tryToSetGmshStringOption(onelab::string &p)
 {
   const std::string &name = p.getName();
   std::string::size_type dot = name.find('.');
-  if(dot != std::string::npos){
+  if(dot != std::string::npos) {
     const std::string &val = p.getValue();
     return GmshSetOption(name.substr(0, dot), name.substr(dot + 1), val);
   }
@@ -216,180 +218,186 @@ bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master)
 
   double timer = GetTimeInSeconds();
 
-  if(!getGmshServer()){
+  if(!getGmshServer()) {
     Msg::Error("Abnormal server termination (no valid server)");
     return false;
   }
 
   int type, length, swap;
-  if(!getGmshServer()->ReceiveHeader(&type, &length, &swap)){
+  if(!getGmshServer()->ReceiveHeader(&type, &length, &swap)) {
     Msg::Error("Abnormal server termination (did not receive message header)");
     return false;
   }
 
   std::string message(length, ' '), blank = message;
-  if(!getGmshServer()->ReceiveMessage(length, &message[0])){
+  if(!getGmshServer()->ReceiveMessage(length, &message[0])) {
     Msg::Error("Abnormal server termination (did not receive message body)");
     return false;
   }
 
-  if(message == blank && !(type == GmshSocket::GMSH_PROGRESS ||
-                           type == GmshSocket::GMSH_INFO ||
-                           type == GmshSocket::GMSH_WARNING ||
-                           type == GmshSocket::GMSH_ERROR)){
+  if(message == blank &&
+     !(type == GmshSocket::GMSH_PROGRESS || type == GmshSocket::GMSH_INFO ||
+       type == GmshSocket::GMSH_WARNING || type == GmshSocket::GMSH_ERROR)) {
     // we should still allow blank msg strings to be sent
-    Msg::Error("Abnormal server termination (blank message: client not stopped?)");
+    Msg::Error(
+      "Abnormal server termination (blank message: client not stopped?)");
     return false;
   }
 
-  switch (type) {
-  case GmshSocket::GMSH_START:
-    setPid(atoi(message.c_str()));
-    break;
+  switch(type) {
+  case GmshSocket::GMSH_START: setPid(atoi(message.c_str())); break;
   case GmshSocket::GMSH_STOP:
     setPid(-1);
-    if(getFather()){
+    if(getFather()) {
       std::string reply = getName(); // reply is dummy
-      getFather()->getGmshServer()->SendMessage
-        (GmshSocket::GMSH_STOP, reply.size(), &reply[0]);
+      getFather()->getGmshServer()->SendMessage(GmshSocket::GMSH_STOP,
+                                                reply.size(), &reply[0]);
     }
     break;
   case GmshSocket::GMSH_PARAMETER:
   case GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES:
-  case GmshSocket::GMSH_PARAMETER_UPDATE:
-    {
-      std::string version, ptype, name;
-      onelab::parameter::getInfoFromChar(message, version, ptype, name);
-      if(onelab::parameter::version() != version){
-        Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
-                   onelab::parameter::version().c_str(), version.c_str());
-      }
-      else if(ptype == "number"){
-        onelab::number p; p.fromChar(message);
-        if(!tryToSetGmshNumberOption(p)){
-          if(type == GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES){
-            // append value to any choices already on the server
-            std::vector<onelab::number> par; get(par, name);
-            std::vector<double> c;
-            if(par.size()) c = par[0].getChoices();
-            c.push_back(p.getValue());
-            p.setChoices(c);
-          }
-          if(type == GmshSocket::GMSH_PARAMETER_UPDATE){
-            std::vector<onelab::number> par; get(par, name);
-            if(par.size()) {
-              onelab::number y = p; p = par[0]; onelabUtils::updateNumber(p, y);
-            }
+  case GmshSocket::GMSH_PARAMETER_UPDATE: {
+    std::string version, ptype, name;
+    onelab::parameter::getInfoFromChar(message, version, ptype, name);
+    if(onelab::parameter::version() != version) {
+      Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
+                 onelab::parameter::version().c_str(), version.c_str());
+    }
+    else if(ptype == "number") {
+      onelab::number p;
+      p.fromChar(message);
+      if(!tryToSetGmshNumberOption(p)) {
+        if(type == GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES) {
+          // append value to any choices already on the server
+          std::vector<onelab::number> par;
+          get(par, name);
+          std::vector<double> c;
+          if(par.size()) c = par[0].getChoices();
+          c.push_back(p.getValue());
+          p.setChoices(c);
+        }
+        if(type == GmshSocket::GMSH_PARAMETER_UPDATE) {
+          std::vector<onelab::number> par;
+          get(par, name);
+          if(par.size()) {
+            onelab::number y = p;
+            p = par[0];
+            onelabUtils::updateNumber(p, y);
           }
-          set(p);
-          if(p.getName() == getName() + "/Progress"){
+        }
+        set(p);
+        if(p.getName() == getName() + "/Progress") {
 #if defined(HAVE_FLTK)
-            if(FlGui::available())
-              FlGui::instance()->setProgress(p.getLabel().c_str(), p.getValue(),
-                                             p.getMin(), p.getMax());
+          if(FlGui::available())
+            FlGui::instance()->setProgress(p.getLabel().c_str(), p.getValue(),
+                                           p.getMin(), p.getMax());
 #endif
-          }
         }
       }
-      else if(ptype == "string"){
-        onelab::string p; p.fromChar(message);
-        if(!tryToSetGmshStringOption(p)){
-          if(type == GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES){
-            // append value to any choices already on the server
-            std::vector<onelab::string> par; get(par, name);
-            std::vector<std::string> c;
-            if(par.size()) c = par[0].getChoices();
-            c.push_back(p.getValue());
-            p.setChoices(c);
-          }
-          else if(type == GmshSocket::GMSH_PARAMETER_UPDATE){
-            std::vector<onelab::string> par; get(par, name);
-            if(par.size()){
-              onelab::string y = p; p = par[0]; onelabUtils::updateString(p,y);
-            }
+    }
+    else if(ptype == "string") {
+      onelab::string p;
+      p.fromChar(message);
+      if(!tryToSetGmshStringOption(p)) {
+        if(type == GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES) {
+          // append value to any choices already on the server
+          std::vector<onelab::string> par;
+          get(par, name);
+          std::vector<std::string> c;
+          if(par.size()) c = par[0].getChoices();
+          c.push_back(p.getValue());
+          p.setChoices(c);
+        }
+        else if(type == GmshSocket::GMSH_PARAMETER_UPDATE) {
+          std::vector<onelab::string> par;
+          get(par, name);
+          if(par.size()) {
+            onelab::string y = p;
+            p = par[0];
+            onelabUtils::updateString(p, y);
           }
-          set(p);
         }
+        set(p);
       }
-      else
-        Msg::Error("Unknown ONELAB parameter type: %s", ptype.c_str());
     }
-    break;
+    else
+      Msg::Error("Unknown ONELAB parameter type: %s", ptype.c_str());
+  } break;
   case GmshSocket::GMSH_PARAMETER_QUERY:
-  case GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES:
-    {
-      std::string version, ptype, name, reply;
-      onelab::parameter::getInfoFromChar(message, version, ptype, name);
-      if(onelab::parameter::version() != version){
-        Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
-                   onelab::parameter::version().c_str(), version.c_str());
-      }
-      else if(ptype == "number"){
-        std::vector<onelab::number> par;
-        if(type == GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES)
-          getWithoutChoices(par, name);
-        else
-          get(par, name);
-        if(par.empty())
-          reply = tryToGetGmshNumberOption(name);
-        else
-          reply = par[0].toChar();
-      }
-      else if(ptype == "string"){
-        std::vector<onelab::string> par;
-        if(type == GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES)
-          getWithoutChoices(par, name);
-        else
-          get(par, name);
-        if(par.empty())
-          reply = tryToGetGmshStringOption(name);
-        else
-          reply = par[0].toChar();
-      }
+  case GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES: {
+    std::string version, ptype, name, reply;
+    onelab::parameter::getInfoFromChar(message, version, ptype, name);
+    if(onelab::parameter::version() != version) {
+      Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
+                 onelab::parameter::version().c_str(), version.c_str());
+    }
+    else if(ptype == "number") {
+      std::vector<onelab::number> par;
+      if(type == GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES)
+        getWithoutChoices(par, name);
       else
-        Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str());
-
-      if(reply.size()){
-        getGmshServer()->SendMessage
-          (GmshSocket::GMSH_PARAMETER, reply.size(), &reply[0]);
-      }
-      else{
-        reply = name;
-        getGmshServer()->SendMessage
-          (GmshSocket::GMSH_PARAMETER_NOT_FOUND, reply.size(), &reply[0]);
-      }
+        get(par, name);
+      if(par.empty())
+        reply = tryToGetGmshNumberOption(name);
+      else
+        reply = par[0].toChar();
     }
-    break;
-  case GmshSocket::GMSH_PARAMETER_QUERY_ALL:
-    {
-      std::string version, ptype, name, reply;
-      std::vector<std::string> replies;
-      onelab::parameter::getInfoFromChar(message, version, ptype, name);
-      if(onelab::parameter::version() != version){
-        Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
-                   onelab::parameter::version().c_str(), version.c_str());
-      }
-      else if(ptype == "number"){
-        std::vector<onelab::number> numbers; get(numbers);
-        for(std::vector<onelab::number>::iterator it = numbers.begin();
-            it != numbers.end(); it++) replies.push_back((*it).toChar());
-      }
-      else if(ptype == "string"){
-        std::vector<onelab::string> strings; get(strings);
-        for(std::vector<onelab::string>::iterator it = strings.begin();
-            it != strings.end(); it++) replies.push_back((*it).toChar());
-      }
+    else if(ptype == "string") {
+      std::vector<onelab::string> par;
+      if(type == GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES)
+        getWithoutChoices(par, name);
+      else
+        get(par, name);
+      if(par.empty())
+        reply = tryToGetGmshStringOption(name);
       else
-        Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str());
-
-      for(unsigned int i = 0; i < replies.size(); i++)
-        getGmshServer()->SendMessage
-          (GmshSocket::GMSH_PARAMETER_QUERY_ALL, replies[i].size(), &replies[i][0]);
-      reply = "Sent all ONELAB " + ptype + "s";
-      getGmshServer()->SendMessage
-        (GmshSocket::GMSH_PARAMETER_QUERY_END, reply.size(), &reply[0]);
+        reply = par[0].toChar();
     }
-    break;
+    else
+      Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str());
+
+    if(reply.size()) {
+      getGmshServer()->SendMessage(GmshSocket::GMSH_PARAMETER, reply.size(),
+                                   &reply[0]);
+    }
+    else {
+      reply = name;
+      getGmshServer()->SendMessage(GmshSocket::GMSH_PARAMETER_NOT_FOUND,
+                                   reply.size(), &reply[0]);
+    }
+  } break;
+  case GmshSocket::GMSH_PARAMETER_QUERY_ALL: {
+    std::string version, ptype, name, reply;
+    std::vector<std::string> replies;
+    onelab::parameter::getInfoFromChar(message, version, ptype, name);
+    if(onelab::parameter::version() != version) {
+      Msg::Error("ONELAB version mismatch (server: %s / client: %s)",
+                 onelab::parameter::version().c_str(), version.c_str());
+    }
+    else if(ptype == "number") {
+      std::vector<onelab::number> numbers;
+      get(numbers);
+      for(std::vector<onelab::number>::iterator it = numbers.begin();
+          it != numbers.end(); it++)
+        replies.push_back((*it).toChar());
+    }
+    else if(ptype == "string") {
+      std::vector<onelab::string> strings;
+      get(strings);
+      for(std::vector<onelab::string>::iterator it = strings.begin();
+          it != strings.end(); it++)
+        replies.push_back((*it).toChar());
+    }
+    else
+      Msg::Error("Unknown ONELAB parameter type in query: %s", ptype.c_str());
+
+    for(unsigned int i = 0; i < replies.size(); i++)
+      getGmshServer()->SendMessage(GmshSocket::GMSH_PARAMETER_QUERY_ALL,
+                                   replies[i].size(), &replies[i][0]);
+    reply = "Sent all ONELAB " + ptype + "s";
+    getGmshServer()->SendMessage(GmshSocket::GMSH_PARAMETER_QUERY_END,
+                                 reply.size(), &reply[0]);
+  } break;
   case GmshSocket::GMSH_PARAMETER_CLEAR:
     clear(message == "*" ? "" : message);
     break;
@@ -406,7 +414,7 @@ bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master)
     Msg::Error("%s - %s", _name.c_str(), message.c_str());
     break;
   case GmshSocket::GMSH_MERGE_FILE:
-    if(CTX::instance()->solver.autoMergeFile){
+    if(CTX::instance()->solver.autoMergeFile) {
       unsigned int n = PView::list.size();
       bool changedBeforeMerge = onelab::server::instance()->getChanged("Gmsh");
       MergePostProcessingFile(message, CTX::instance()->solver.autoShowViews,
@@ -414,98 +422,90 @@ bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master)
       onelab::server::instance()->setChanged(changedBeforeMerge, "Gmsh");
 #if defined(HAVE_FLTK)
       drawContext::global()->draw();
-      if(FlGui::available() && n != PView::list.size()){
+      if(FlGui::available() && n != PView::list.size()) {
         FlGui::instance()->rebuildTree(true);
         FlGui::instance()->openModule("Post-processing");
       }
 #endif
     }
     break;
-  case GmshSocket::GMSH_OPEN_PROJECT:
-    OpenProject(message);
+  case GmshSocket::GMSH_OPEN_PROJECT: OpenProject(message);
 #if defined(HAVE_FLTK)
     drawContext::global()->draw();
 #endif
     break;
-  case GmshSocket::GMSH_PARSE_STRING:
-    ParseString(message, true);
+  case GmshSocket::GMSH_PARSE_STRING: ParseString(message, true);
 #if defined(HAVE_FLTK)
     drawContext::global()->draw();
 #endif
     break;
   case GmshSocket::GMSH_SPEED_TEST:
-    Msg::Info("got %d Mb message in %g seconds",
-              length / 1024 / 1024, GetTimeInSeconds() - timer);
+    Msg::Info("got %d Mb message in %g seconds", length / 1024 / 1024,
+              GetTimeInSeconds() - timer);
     break;
-  case GmshSocket::GMSH_VERTEX_ARRAY:
-    {
-      int n = PView::list.size();
-      PView::fillVertexArray(this, length, &message[0], swap);
+  case GmshSocket::GMSH_VERTEX_ARRAY: {
+    int n = PView::list.size();
+    PView::fillVertexArray(this, length, &message[0], swap);
 #if defined(HAVE_FLTK)
-      if(FlGui::available())
-        FlGui::instance()->updateViews(n != (int)PView::list.size(), true);
-      drawContext::global()->draw();
+    if(FlGui::available())
+      FlGui::instance()->updateViews(n != (int)PView::list.size(), true);
+    drawContext::global()->draw();
 #endif
+  } break;
+  case GmshSocket::GMSH_CONNECT: {
+    std::string::size_type first = 0;
+    std::string clientName = onelab::parameter::getNextToken(message, first);
+    std::string command = onelab::parameter::getNextToken(message, first);
+    gmshLocalNetworkClient *subClient =
+      new gmshLocalNetworkClient(clientName, command, "", true);
+    onelabGmshServer *server = new onelabGmshServer(subClient);
+    subClient->setPid(0);
+    onelab::string o(subClient->getName() + "/Action", "compute");
+    o.setVisible(false);
+    o.setNeverChanged(true);
+    onelab::server::instance()->set(o);
+    int sock = server->LaunchClient();
+    if(sock < 0) { // could not establish the connection: aborting
+      server->Shutdown();
+      delete server;
+      Msg::Error("Could not connect client '%s'", subClient->getName().c_str());
     }
-    break;
-  case GmshSocket::GMSH_CONNECT:
-    {
-      std::string::size_type first = 0;
-      std::string clientName = onelab::parameter::getNextToken(message, first);
-      std::string command = onelab::parameter::getNextToken(message, first);
-      gmshLocalNetworkClient* subClient =
-        new gmshLocalNetworkClient(clientName, command, "", true);
-      onelabGmshServer *server = new onelabGmshServer(subClient);
-      subClient->setPid(0);
-      onelab::string o(subClient->getName() + "/Action", "compute");
-      o.setVisible(false);
-      o.setNeverChanged(true);
-      onelab::server::instance()->set(o);
-      int sock = server->LaunchClient();
-      if(sock < 0){ // could not establish the connection: aborting
-        server->Shutdown();
-        delete server;
-        Msg::Error("Could not connect client '%s'", subClient->getName().c_str());
-      }
-      else{
-        Msg::StatusBar(true, "Running '%s'...", subClient->getName().c_str());
-        subClient->setGmshServer(server);
-        subClient->setFather(this);
-        master->addClient(subClient);
-      }
+    else {
+      Msg::StatusBar(true, "Running '%s'...", subClient->getName().c_str());
+      subClient->setGmshServer(server);
+      subClient->setFather(this);
+      master->addClient(subClient);
     }
-    break;
-  case GmshSocket::GMSH_OLPARSE:
-    {
-      std::string reply = "unavailable";
+  } break;
+  case GmshSocket::GMSH_OLPARSE: {
+    std::string reply = "unavailable";
 #if defined(HAVE_ONELAB_METAMODEL)
-      std::string::size_type first = 0;
-      std::string clientName = onelab::parameter::getNextToken(message, first);
-      std::string fullName = onelab::parameter::getNextToken(message, first);
-      preProcess(clientName, fullName); // contrib/onelab/OnelabParser.cpp
-      Msg::Info("Done preprocessing file '%s'", fullName.c_str());
-      reply = onelab::server::instance()->getChanged(clientName) ? "true" : "false";
+    std::string::size_type first = 0;
+    std::string clientName = onelab::parameter::getNextToken(message, first);
+    std::string fullName = onelab::parameter::getNextToken(message, first);
+    preProcess(clientName, fullName); // contrib/onelab/OnelabParser.cpp
+    Msg::Info("Done preprocessing file '%s'", fullName.c_str());
+    reply =
+      onelab::server::instance()->getChanged(clientName) ? "true" : "false";
 #endif
-      getGmshServer()->SendMessage
-	(GmshSocket::GMSH_OLPARSE, reply.size(), &reply[0]);
+    getGmshServer()->SendMessage(GmshSocket::GMSH_OLPARSE, reply.size(),
+                                 &reply[0]);
+  } break;
+  case GmshSocket::GMSH_CLIENT_CHANGED: {
+    std::string::size_type first = 0;
+    std::string command = onelab::parameter::getNextToken(message, first);
+    std::string name = onelab::parameter::getNextToken(message, first);
+    if(command == "get") {
+      std::string reply =
+        onelab::server::instance()->getChanged(name) ? "true" : "false";
+      getGmshServer()->SendMessage(GmshSocket::GMSH_CLIENT_CHANGED,
+                                   reply.size(), &reply[0]);
     }
-    break;
-  case GmshSocket::GMSH_CLIENT_CHANGED:
-    {
-      std::string::size_type first = 0;
-      std::string command = onelab::parameter::getNextToken(message, first);
-      std::string name = onelab::parameter::getNextToken(message, first);
-      if(command == "get"){
-	std::string reply = onelab::server::instance()->getChanged(name) ? "true" : "false";
-	getGmshServer()->SendMessage
-	  (GmshSocket::GMSH_CLIENT_CHANGED, reply.size(), &reply[0]);
-      }
-      else if(command == "set"){
-	std::string changed = onelab::parameter::getNextToken(message, first);
-	onelab::server::instance()->setChanged(changed == "true" ? 31 : 0, name);
-      }
+    else if(command == "set") {
+      std::string changed = onelab::parameter::getNextToken(message, first);
+      onelab::server::instance()->setChanged(changed == "true" ? 31 : 0, name);
     }
-    break;
+  } break;
   default:
     Msg::Warning("Received unknown message type (%d)", type);
     return false;
@@ -517,14 +517,14 @@ bool gmshLocalNetworkClient::receiveMessage(gmshLocalNetworkClient *master)
 
 bool gmshLocalNetworkClient::run()
 {
- new_connection:
+new_connection:
   setPid(0); // dummy pid, should be non-negative
 
   onelabGmshServer *server = new onelabGmshServer(this);
 
   int sock = server->LaunchClient();
 
-  if(sock < 0){
+  if(sock < 0) {
     // could not establish the connection: aborting
     server->Shutdown();
     delete server;
@@ -536,7 +536,7 @@ bool gmshLocalNetworkClient::run()
   setGmshServer(server);
 
   while(1) {
-    if(getExecutable().empty() && !CTX::instance()->solver.listen){
+    if(getExecutable().empty() && !CTX::instance()->solver.listen) {
       // we stopped listening to the special "Listen" client
       break;
     }
@@ -545,21 +545,21 @@ bool gmshLocalNetworkClient::run()
     // spawned subclients) and check if data is available for one of them
     bool stop = false, haveData = false;
     gmshLocalNetworkClient *c = 0;
-    std::vector<gmshLocalNetworkClient*> toDelete;
-    for(int i = 0; i < getNumClients(); i++){
+    std::vector<gmshLocalNetworkClient *> toDelete;
+    for(int i = 0; i < getNumClients(); i++) {
       c = getClient(i);
-      if(c->getPid() < 0){
-        if(c == this){ // the "master" client stopped
+      if(c->getPid() < 0) {
+        if(c == this) { // the "master" client stopped
           stop = true;
           break;
         }
-        else{
+        else {
           // this subclient is not active anymore: shut down and delete its
           // server and mark the client for deletion
           GmshServer *s = c->getGmshServer();
           c->setGmshServer(0);
           c->setFather(0);
-          if(s){
+          if(s) {
             s->Shutdown();
             delete s;
           }
@@ -568,27 +568,27 @@ bool gmshLocalNetworkClient::run()
         }
       }
       GmshServer *s = c->getGmshServer();
-      if(!s){
+      if(!s) {
         Msg::Error("Abnormal server termination (no valid server)");
         stop = true;
         break;
       }
-      else{
+      else {
         int ret = s->NonBlockingWait(0.0001, -1.);
-        if(ret == 0){ // we have data from this particular client
+        if(ret == 0) { // we have data from this particular client
           haveData = true;
           break;
         }
-        else if(ret == 3){ // pass to the next client
+        else if(ret == 3) { // pass to the next client
           continue;
         }
-        else{ // an error occurred
+        else { // an error occurred
           stop = true;
           break;
         }
       }
     }
-    for(unsigned int i = 0; i < toDelete.size(); i++){
+    for(unsigned int i = 0; i < toDelete.size(); i++) {
       removeClient(toDelete[i]);
       delete toDelete[i];
     }
@@ -607,30 +607,31 @@ bool gmshLocalNetworkClient::run()
 
   // we are done running the (master) client: delete the servers and the
   // subclients, if any remain (they should have been deleted already).
-  std::vector<gmshLocalNetworkClient*> toDelete;
-  for(int i = 0; i < getNumClients(); i++){
+  std::vector<gmshLocalNetworkClient *> toDelete;
+  for(int i = 0; i < getNumClients(); i++) {
     gmshLocalNetworkClient *c = getClient(i);
     GmshServer *s = c->getGmshServer();
     c->setGmshServer(0);
     c->setFather(0);
-    if(s){
+    if(s) {
       s->Shutdown();
       delete s;
     }
-    if(c != this){
+    if(c != this) {
       if(c->getPid() > 0)
-        Msg::Error("Subclient %s was not stopped correctly", c->getName().c_str());
+        Msg::Error("Subclient %s was not stopped correctly",
+                   c->getName().c_str());
       toDelete.push_back(c);
     }
   }
-  for(unsigned int i = 0; i < toDelete.size(); i++){
+  for(unsigned int i = 0; i < toDelete.size(); i++) {
     removeClient(toDelete[i]);
     delete toDelete[i];
   }
 
   Msg::StatusBar(true, "Done running '%s'", _name.c_str());
 
-  if(getExecutable().empty()){
+  if(getExecutable().empty()) {
     Msg::Info("Client disconnected: starting new connection");
     goto new_connection;
   }
@@ -642,11 +643,10 @@ bool gmshLocalNetworkClient::kill()
 {
   // FIXME: we should kill all the clients in the list
   if(getPid() > 0) {
-    if(KillProcess(getPid())){
+    if(KillProcess(getPid())) {
       Msg::Info("Killed '%s' (pid %d)", _name.c_str(), getPid());
 #if defined(HAVE_FLTK)
-      if(FlGui::available())
-        FlGui::instance()->setProgress("Killed", 0, 0, 0);
+      if(FlGui::available()) FlGui::instance()->setProgress("Killed", 0, 0, 0);
 #endif
       setPid(-1);
       return true;
@@ -656,5 +656,4 @@ bool gmshLocalNetworkClient::kill()
   return false;
 }
 
-
 #endif
diff --git a/Common/gmshLocalNetworkClient.h b/Common/gmshLocalNetworkClient.h
index e2ac25b3a3fa91ce9cd48520b77f30bf99c4b5ad..ae2adf6165fa0e90f273e6ed78238b4869da782f 100644
--- a/Common/gmshLocalNetworkClient.h
+++ b/Common/gmshLocalNetworkClient.h
@@ -14,43 +14,36 @@
 
 #include "onelab.h"
 
-class gmshLocalNetworkClient : public onelab::localNetworkClient{
- private:
+class gmshLocalNetworkClient : public onelab::localNetworkClient {
+private:
   // a gmsh local network client can launch subclients (this is typical for a
   // metamodel that calls several underlying models); _clients keeps track of
   // the master (this) and the subclients.
-  std::vector<gmshLocalNetworkClient*> _clients;
+  std::vector<gmshLocalNetworkClient *> _clients;
   // client that launched this one (with GMSH_CONNECT); _father is zero for the
   // master client (the one created by Gmsh).
   gmshLocalNetworkClient *_father;
- public:
+
+public:
   gmshLocalNetworkClient(const std::string &name, const std::string &executable,
-                         const std::string &remoteLogin="",
-                         bool treatExecutableAsFullCommandLine=false)
+                         const std::string &remoteLogin = "",
+                         bool treatExecutableAsFullCommandLine = false)
     : onelab::localNetworkClient(name, executable, remoteLogin,
-                                 treatExecutableAsFullCommandLine), _father(0)
+                                 treatExecutableAsFullCommandLine),
+      _father(0)
   {
     addClient(this);
   }
-  void setFather(gmshLocalNetworkClient *father)
-  {
-    _father = father;
-  }
-  gmshLocalNetworkClient *getFather()
-  {
-    return _father;
-  }
-  void addClient(gmshLocalNetworkClient *client)
-  {
-    _clients.push_back(client);
-  }
+  void setFather(gmshLocalNetworkClient *father) { _father = father; }
+  gmshLocalNetworkClient *getFather() { return _father; }
+  void addClient(gmshLocalNetworkClient *client) { _clients.push_back(client); }
   void removeClient(gmshLocalNetworkClient *client)
   {
-    std::vector<gmshLocalNetworkClient*>::iterator it;
+    std::vector<gmshLocalNetworkClient *>::iterator it;
     it = std::find(_clients.begin(), _clients.end(), client);
     if(it != _clients.end()) _clients.erase(it);
   }
-  int getNumClients(){ return _clients.size(); }
+  int getNumClients() { return _clients.size(); }
   gmshLocalNetworkClient *getClient(int i)
   {
     if(i >= 0 && i < getNumClients()) return _clients[i];
@@ -59,7 +52,7 @@ class gmshLocalNetworkClient : public onelab::localNetworkClient{
   int getNumConnectedClients()
   {
     int n = 0;
-    for(int i = 0; i < getNumClients(); i++){
+    for(int i = 0; i < getNumClients(); i++) {
       if(_clients[i]->getPid() != -1) n++;
     }
     return n;
diff --git a/Common/gmshPopplerWrapper.cpp b/Common/gmshPopplerWrapper.cpp
index c31281fdcdd7e9577492522b2f4fd7787fd714c2..e5aad9fc3331b88494fe6277023356b97aa93300 100644
--- a/Common/gmshPopplerWrapper.cpp
+++ b/Common/gmshPopplerWrapper.cpp
@@ -15,10 +15,9 @@
 #include <FL/Fl_JPEG_Image.H>
 #endif
 
-
 gmshPopplerWrapper *gmshPopplerWrapper::_instance = 0;
-std::map <int, std::pair<GModel*, std::string>  > gmshPopplerWrapper::_macros;
-poppler::document  *gmshPopplerWrapper::_currentDoc = 0;
+std::map<int, std::pair<GModel *, std::string> > gmshPopplerWrapper::_macros;
+poppler::document *gmshPopplerWrapper::_currentDoc = 0;
 #if defined(HAVE_OPENGL)
 std::map<int, GLuint> gmshPopplerWrapper::_pages2textures;
 int gmshPopplerWrapper::_w = -1;
@@ -36,12 +35,12 @@ int gmshPopplerWrapper::loadFromFile(const std::string &fileName,
                                      const std::string &ownerPassword,
                                      const std::string &userPassword)
 {
-  if (_currentDoc) delete _currentDoc;
+  if(_currentDoc) delete _currentDoc;
 
   Msg::Info("Loading PDF file `%s'...", fileName.c_str());
-  _currentDoc = poppler::document::load_from_file(fileName, ownerPassword,
-                                                   userPassword);
-  if (!_currentDoc) return 0;
+  _currentDoc =
+    poppler::document::load_from_file(fileName, ownerPassword, userPassword);
+  if(!_currentDoc) return 0;
 
   Msg::Info("Loaded PDF file `%s'", fileName.c_str());
   //  createBitmap(1,72.,72.,-1,-1,-1,-1);
@@ -55,18 +54,16 @@ int gmshPopplerWrapper::getNumPages()
 }
 
 #if defined(HAVE_OPENGL)
-GLuint gmshPopplerWrapper::getTextureForPage(double xres,
-					     double yres)
+GLuint gmshPopplerWrapper::getTextureForPage(double xres, double yres)
 {
-
   int iPage = _currentPage;
   int numPages = getNumPages();
   if(iPage < 0) iPage = 0;
   if(iPage > numPages - 1) iPage = numPages - 1;
-  std::map<int,GLuint>::iterator it = _pages2textures.find(iPage);
-  if (it != _pages2textures.end()) return it->second;
-  if (!_currentDoc) return 0;
- 
+  std::map<int, GLuint>::iterator it = _pages2textures.find(iPage);
+  if(it != _pages2textures.end()) return it->second;
+  if(!_currentDoc) return 0;
+
   poppler::page *page = _currentDoc->create_page(iPage);
   poppler::page_renderer pr;
   pr.set_render_hint(poppler::page_renderer::text_antialiasing, true);
@@ -82,8 +79,8 @@ GLuint gmshPopplerWrapper::getTextureForPage(double xres,
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img->w(), img->h(), 0,
-	       (img->d() == 4) ? GL_RGBA : GL_RGB,
-	       GL_UNSIGNED_BYTE, img->array);
+               (img->d() == 4) ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE,
+               img->array);
 
   _w = img->w();
   _h = img->h();
diff --git a/Common/gmshPopplerWrapper.h b/Common/gmshPopplerWrapper.h
index d4e51fa915c346bf4cfceb0c36fed0782edebd08..e09fa0607ad8433ef688366b9258b415c2cee0e6 100644
--- a/Common/gmshPopplerWrapper.h
+++ b/Common/gmshPopplerWrapper.h
@@ -18,11 +18,11 @@
 #include <poppler/cpp/poppler-page.h>
 #include <poppler/cpp/poppler-image.h>
 #if defined(HAVE_OPENGL)
-#  if defined(__APPLE__) || defined(HAVE_OPENGL_GL_H)
-#    include <OpenGL/gl.h>
-#  else
-#    include <GL/gl.h>
-#  endif
+#if defined(__APPLE__) || defined(HAVE_OPENGL_GL_H)
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
 #endif
 
 class gmshPopplerWrapper {
@@ -30,60 +30,66 @@ private:
   static int _currentPage;
   static poppler::document *_currentDoc;
   static gmshPopplerWrapper *_instance;
-  static std::map <int, std::pair<GModel*, std::string> > _macros;
+  static std::map<int, std::pair<GModel *, std::string> > _macros;
   static int _w, _h;
 #if defined(HAVE_OPENGL)
-  static std::map<int,GLuint> _pages2textures; // map pages to textures
+  static std::map<int, GLuint> _pages2textures; // map pages to textures
 #endif
 
 public:
   static gmshPopplerWrapper *instance();
   static int loadFromFile(const std::string &file_name,
-                          const std::string &owner_password=std::string(),
-                          const std::string &user_password=std::string());
-  static int width(){ return _w; }
-  static int height(){ return _h; }
+                          const std::string &owner_password = std::string(),
+                          const std::string &user_password = std::string());
+  static int width() { return _w; }
+  static int height() { return _h; }
   static int getNumPages();
 
-  static void setMacroForPages(std::vector<int> &is, const std::string &s, const std::string &o ) {
+  static void setMacroForPages(std::vector<int> &is, const std::string &s,
+                               const std::string &o)
+  {
     GModel *gm = GModel::current();
-    if (_macros.empty()){
-      _macros [-1] = std::make_pair(gm, "NULL");
+    if(_macros.empty()) {
+      _macros[-1] = std::make_pair(gm, "NULL");
     }
     GModel *gmNew = new GModel(s);
     GModel::setCurrent(gmNew);
-    MergeFile (s, true);
-    for (size_t i=0; i< is.size(); i++)
-      _macros [is[i]] = std::make_pair(gmNew, o);
+    MergeFile(s, true);
+    for(size_t i = 0; i < is.size(); i++)
+      _macros[is[i]] = std::make_pair(gmNew, o);
     GModel::setCurrent(gm);
     gmNew->setVisibility(0);
   }
 
-  static void setCurrentPage(int num){
+  static void setCurrentPage(int num)
+  {
     _currentPage = num;
-    if (_currentPage >= getNumPages())_currentPage = getNumPages()-1; 
-    if (_currentPage < 0)_currentPage = 0; 
+    if(_currentPage >= getNumPages()) _currentPage = getNumPages() - 1;
+    if(_currentPage < 0) _currentPage = 0;
     CTX::instance()->bgImagePage = _currentPage;
-    std::map <int, std::pair<GModel*, std::string> > :: const_iterator it = _macros . find (_currentPage);
-    if (it == _macros.end())it = _macros.find (-1);
-    if (it != _macros.end()){
-      if ( GModel::current() != it->second.first) {
-	GModel::current()->setVisibility(0);
-	GModel::setCurrent(it->second.first);
-	if (it->second.second != "NULL")MergeFile (it->second.second, true);
-	it->second.first->setVisibility(1);      
+    std::map<int, std::pair<GModel *, std::string> >::const_iterator it =
+      _macros.find(_currentPage);
+    if(it == _macros.end()) it = _macros.find(-1);
+    if(it != _macros.end()) {
+      if(GModel::current() != it->second.first) {
+        GModel::current()->setVisibility(0);
+        GModel::setCurrent(it->second.first);
+        if(it->second.second != "NULL") MergeFile(it->second.second, true);
+        it->second.first->setVisibility(1);
       }
     }
   }
-  static int getCurrentPage(){ return _currentPage; }
-  static void setCurrentPageUp(){
+  static int getCurrentPage() { return _currentPage; }
+  static void setCurrentPageUp()
+  {
     ++_currentPage;
-    if (_currentPage >= getNumPages())_currentPage = getNumPages()-1; 
+    if(_currentPage >= getNumPages()) _currentPage = getNumPages() - 1;
     CTX::instance()->bgImagePage = _currentPage;
   }
-  static void setCurrentPageDown(){
+  static void setCurrentPageDown()
+  {
     --_currentPage;
-    if (_currentPage < 0)_currentPage = 0; 
+    if(_currentPage < 0) _currentPage = 0;
     CTX::instance()->bgImagePage = _currentPage;
   }
 #if defined(HAVE_OPENGL)
diff --git a/Common/onelab.h b/Common/onelab.h
index 6d12386209585e6ea6ad2df41c1e8a6d919c7d54..e39b7329184e92507491891132689c44e7670613 100644
--- a/Common/onelab.h
+++ b/Common/onelab.h
@@ -44,7 +44,7 @@
 #include "picojson.h"
 #endif
 
-namespace onelab{
+namespace onelab {
 
   // The base parameter class.
   class parameter {
@@ -74,40 +74,42 @@ namespace onelab{
     bool _visible;
     // sould the paramete be "read-only" (not settable by the user)
     bool _readOnly;
+
   protected:
     // optional additional attributes
     std::map<std::string, std::string> _attributes;
+
   public:
-    parameter(const std::string &name="", const std::string &label="",
-              const std::string &help="")
+    parameter(const std::string &name = "", const std::string &label = "",
+              const std::string &help = "")
       : _name(name), _label(label), _help(help), _visible(true),
         _readOnly(false)
     {
       _changedValue = defaultChangedValue();
     }
-    virtual ~parameter(){}
-    void setName(const std::string &name){ _name = name; }
-    void setLabel(const std::string &label){ _label = label; }
-    void setHelp(const std::string &help){ _help = help; }
-    void setChanged(int changed, const std::string &client="")
+    virtual ~parameter() {}
+    void setName(const std::string &name) { _name = name; }
+    void setLabel(const std::string &label) { _label = label; }
+    void setHelp(const std::string &help) { _help = help; }
+    void setChanged(int changed, const std::string &client = "")
     {
-      if(client.size()){
+      if(client.size()) {
         std::map<std::string, int>::iterator it = _clients.find(client);
         if(it != _clients.end()) it->second = changed;
       }
-      else{
+      else {
         for(std::map<std::string, int>::iterator it = _clients.begin();
             it != _clients.end(); it++)
           it->second = changed;
       }
     }
-    void setChangedValue(int value){ _changedValue = value; }
+    void setChangedValue(int value) { _changedValue = value; }
     void setNeverChanged(bool never)
     {
       _changedValue = never ? 0 : defaultChangedValue();
     }
-    void setVisible(bool visible){ _visible = visible; }
-    void setReadOnly(bool readOnly){ _readOnly = readOnly; }
+    void setVisible(bool visible) { _visible = visible; }
+    void setReadOnly(bool readOnly) { _readOnly = readOnly; }
     void setAttribute(const std::string &key, const std::string &value)
     {
       _attributes[key] = value;
@@ -116,11 +118,13 @@ namespace onelab{
     {
       _attributes = attributes;
     }
-    void setClients(const std::map<std::string, int> &clients){ _clients = clients; }
+    void setClients(const std::map<std::string, int> &clients)
+    {
+      _clients = clients;
+    }
     void addClient(const std::string &client, int changed)
     {
-      if(_clients.find(client) == _clients.end())
-        _clients[client] = changed;
+      if(_clients.find(client) == _clients.end()) _clients[client] = changed;
     }
     void addClients(const std::map<std::string, int> &clients)
     {
@@ -143,7 +147,7 @@ namespace onelab{
     std::string getShortName() const
     {
       std::string units = getAttribute("Units");
-      if(_label.size()){
+      if(_label.size()) {
         if(units.empty())
           return _label;
         else
@@ -152,35 +156,33 @@ namespace onelab{
       std::string s = _name;
       // remove path
       std::string::size_type last = _name.find_last_of('/');
-      if(last != std::string::npos)
-        s = _name.substr(last + 1);
+      if(last != std::string::npos) s = _name.substr(last + 1);
       // remove starting white space
-      while(s.size() && s[0] == ' ')
-        s = s.substr(1);
+      while(s.size() && s[0] == ' ') s = s.substr(1);
       // remove starting braces: can be used to order parameters 'from the end',
       // as the ASCII code is after numbers and letters
-      while(s.size() && (s[0] == '}' || s[0] == '{'))
-        s = s.substr(1);
+      while(s.size() && (s[0] == '}' || s[0] == '{')) s = s.substr(1);
       // remove starting numbers: can be used to order parameters 'from the
       // start'
-      while(s.size() && s[0] >= '0' && s[0] <= '9')
-        s = s.substr(1);
+      while(s.size() && s[0] >= '0' && s[0] <= '9') s = s.substr(1);
       if(units.empty())
         return s;
       else
         return s + " [" + units + "]";
     }
-    int getChanged(const std::string &client="") const
+    int getChanged(const std::string &client = "") const
     {
-      if(client.size()){
+      if(client.size()) {
         std::map<std::string, int>::const_iterator it = _clients.find(client);
-        if(it != _clients.end()) return it->second;
-        else return 0;
+        if(it != _clients.end())
+          return it->second;
+        else
+          return 0;
       }
-      else{
+      else {
         int changed = 0;
         for(std::map<std::string, int>::const_iterator it = _clients.begin();
-            it != _clients.end(); it++){
+            it != _clients.end(); it++) {
           changed = std::max(changed, it->second);
         }
         return changed;
@@ -192,7 +194,8 @@ namespace onelab{
     bool getReadOnly() const { return _readOnly; }
     std::string getAttribute(const std::string &key) const
     {
-      std::map<std::string, std::string>::const_iterator it = _attributes.find(key);
+      std::map<std::string, std::string>::const_iterator it =
+        _attributes.find(key);
       if(it != _attributes.end()) return it->second;
       return "";
     }
@@ -207,27 +210,27 @@ namespace onelab{
     static int defaultChangedValue() { return 31; }
     static std::string getNextToken(const std::string &msg,
                                     std::string::size_type &first,
-                                    char separator=charSep())
+                                    char separator = charSep())
     {
       if(first == std::string::npos) return "";
       std::string::size_type last = msg.find_first_of(separator, first);
       std::string next("");
-      if(last == std::string::npos){
+      if(last == std::string::npos) {
         next = msg.substr(first);
         first = last;
       }
-      else if(first == last){
+      else if(first == last) {
         next = "";
         first = last + 1;
       }
-      else{
+      else {
         next = msg.substr(first, last - first);
         first = last + 1;
       }
       return next;
     }
     static std::vector<std::string> split(const std::string &msg,
-                                          char separator=charSep())
+                                          char separator = charSep())
     {
       std::vector<std::string> out;
       std::string::size_type first = 0;
@@ -239,8 +242,7 @@ namespace onelab{
                             const std::string &whitespace = " \t\n")
     {
       std::string::size_type strBegin = str.find_first_not_of(whitespace);
-      if(strBegin == std::string::npos)
-        return ""; // no content
+      if(strBegin == std::string::npos) return ""; // no content
       std::string::size_type strEnd = str.find_last_not_of(whitespace);
       std::string::size_type strRange = strEnd - strBegin + 1;
       return str.substr(strBegin, strRange);
@@ -256,22 +258,21 @@ namespace onelab{
     {
       std::ostringstream sstream;
       sstream << version() << charSep() << getType() << charSep()
-              << sanitize(getName()) << charSep()
-              << sanitize(getLabel()) << charSep()
-              << sanitize(getHelp()) << charSep()
-              << getChangedValue() << charSep()
-              << (getVisible() ? 1 : 0) << charSep()
-              << (getReadOnly() ? 1 : 0) << charSep()
+              << sanitize(getName()) << charSep() << sanitize(getLabel())
+              << charSep() << sanitize(getHelp()) << charSep()
+              << getChangedValue() << charSep() << (getVisible() ? 1 : 0)
+              << charSep() << (getReadOnly() ? 1 : 0) << charSep()
               << _attributes.size() << charSep();
-      for(std::map<std::string, std::string>::const_iterator it = _attributes.begin();
+      for(std::map<std::string, std::string>::const_iterator it =
+            _attributes.begin();
           it != _attributes.end(); it++)
-        sstream << sanitize(it->first) << charSep()
-                << sanitize(it->second) << charSep();
+        sstream << sanitize(it->first) << charSep() << sanitize(it->second)
+                << charSep();
       sstream << getClients().size() << charSep();
       for(std::map<std::string, int>::const_iterator it = getClients().begin();
           it != getClients().end(); it++)
-        sstream << sanitize(it->first) << charSep()
-                << (it->second ? 1 : 0) << charSep();
+        sstream << sanitize(it->first) << charSep() << (it->second ? 1 : 0)
+                << charSep();
       return sstream.str();
     }
     virtual std::string::size_type fromChar(const std::string &msg)
@@ -286,12 +287,12 @@ namespace onelab{
       setVisible(atoi(getNextToken(msg, pos).c_str()));
       setReadOnly(atoi(getNextToken(msg, pos).c_str()));
       int numAttributes = atoi(getNextToken(msg, pos).c_str());
-      for(int i = 0; i < numAttributes; i++){
+      for(int i = 0; i < numAttributes; i++) {
         std::string key(getNextToken(msg, pos));
         setAttribute(key, getNextToken(msg, pos));
       }
       int numClients = atoi(getNextToken(msg, pos).c_str());
-      for(int i = 0; i < numClients; i++){
+      for(int i = 0; i < numClients; i++) {
         std::string client(getNextToken(msg, pos));
         int changed = atoi(getNextToken(msg, pos).c_str());
         addClient(client, changed);
@@ -311,13 +312,12 @@ namespace onelab{
       msg.clear();
       char tmp[1000];
       if(!fgets(tmp, sizeof(tmp), fp)) return false; // first line is comment
-      while(!feof(fp)){
+      while(!feof(fp)) {
         int numc = 0;
         if(!fscanf(fp, "%d ", &numc)) break; // space is important
         if(!numc) break;
         msg.push_back("");
-        for(int i = 0; i < numc; i++)
-          msg.back() += fgetc(fp);
+        for(int i = 0; i < numc; i++) msg.back() += fgetc(fp);
         if(!fgets(tmp, sizeof(tmp), fp)) break; // end of line
       }
       return true;
@@ -327,12 +327,11 @@ namespace onelab{
     {
       time_t now;
       time(&now);
-      fprintf(fp, "ONELAB database created by %s on %s",
-              creator.c_str(), ctime(&now));
-      for(unsigned int i = 0; i < msg.size(); i++){
+      fprintf(fp, "ONELAB database created by %s on %s", creator.c_str(),
+              ctime(&now));
+      for(unsigned int i = 0; i < msg.size(); i++) {
         fprintf(fp, "%d ", (int)msg[i].size());
-        for(unsigned int j = 0; j < msg[i].size(); j++)
-          fputc(msg[i][j], fp);
+        for(unsigned int j = 0; j < msg[i].size(); j++) fputc(msg[i][j], fp);
         fputc('\n', fp);
       }
       return true;
@@ -354,69 +353,75 @@ namespace onelab{
       sstream << ", \"changedValue\":" << getChangedValue()
               << ", \"visible\":" << (getVisible() ? "true" : "false")
               << ", \"readOnly\":" << (getReadOnly() ? "true" : "false");
-      if(_attributes.size()){
+      if(_attributes.size()) {
         sstream << ", \"attributes\":{ ";
-        for(std::map<std::string, std::string>::const_iterator it = _attributes.begin();
-            it != _attributes.end(); it++){
+        for(std::map<std::string, std::string>::const_iterator it =
+              _attributes.begin();
+            it != _attributes.end(); it++) {
           if(it != _attributes.begin()) sstream << ", ";
           sstream << "\"" << sanitizeJSON(it->first) << "\":\""
                   << sanitizeJSON(it->second) << "\"";
         }
         sstream << " }";
       }
-      if(getClients().size()){
+      if(getClients().size()) {
         sstream << ", \"clients\":{ ";
-        for(std::map<std::string, int>::const_iterator it = getClients().begin();
-            it != getClients().end(); it++){
+        for(std::map<std::string, int>::const_iterator it =
+              getClients().begin();
+            it != getClients().end(); it++) {
           if(it != getClients().begin()) sstream << ", ";
-          sstream << "\"" << sanitizeJSON(it->first) << "\":"
-                  << it->second;
+          sstream << "\"" << sanitizeJSON(it->first) << "\":" << it->second;
         }
         sstream << " }";
       }
       return sstream.str();
     }
 #if defined(HAVE_PICOJSON)
-    virtual bool fromJSON(const picojson::value::object& par)
+    virtual bool fromJSON(const picojson::value::object &par)
     {
-      for(picojson::value::object::const_iterator it = par.begin(); it != par.end(); ++it){
-        if(it->first == "name"){
+      for(picojson::value::object::const_iterator it = par.begin();
+          it != par.end(); ++it) {
+        if(it->first == "name") {
           if(!it->second.is<std::string>()) return false;
           setName(it->second.get<std::string>());
         }
-        else if(it->first == "label"){
+        else if(it->first == "label") {
           if(!it->second.is<std::string>()) return false;
           setLabel(it->second.get<std::string>());
         }
-        else if(it->first == "help"){
+        else if(it->first == "help") {
           if(!it->second.is<std::string>()) return false;
           setHelp(it->second.get<std::string>());
         }
-        else if(it->first == "changedValue"){
+        else if(it->first == "changedValue") {
           if(!it->second.is<double>()) return false;
           setChangedValue((int)it->second.get<double>());
         }
-        else if(it->first == "visible"){
+        else if(it->first == "visible") {
           if(!it->second.is<bool>()) return false;
           setVisible(it->second.get<bool>());
         }
-        else if(it->first == "readOnly"){
+        else if(it->first == "readOnly") {
           if(!it->second.is<bool>()) return false;
           setReadOnly(it->second.get<bool>());
         }
-        else if(it->first == "attributes"){
+        else if(it->first == "attributes") {
           if(!it->second.is<picojson::object>()) return false;
-          const picojson::value::object &obj = it->second.get<picojson::object>();
-          for (picojson::value::object::const_iterator i = obj.begin(); i != obj.end(); ++i) {
+          const picojson::value::object &obj =
+            it->second.get<picojson::object>();
+          for(picojson::value::object::const_iterator i = obj.begin();
+              i != obj.end(); ++i) {
             std::string key(i->first);
             if(!i->second.is<std::string>()) return false;
             setAttribute(key, i->second.get<std::string>());
           }
         }
-        else if(it->first == "clients"){
+        else if(it->first == "clients") {
           if(!it->second.is<picojson::object>()) return false;
-          const picojson::value::object &obj = it->second.get<picojson::object>();
-          for (picojson::value::object::const_iterator i = obj.begin(); i != obj.end(); ++i) {
+          const picojson::value::object &obj =
+            it->second.get<picojson::object>();
+          for(picojson::value::object::const_iterator i = obj.begin();
+              i != obj.end(); ++i) {
             std::string client(i->first);
             if(!i->second.is<double>()) return false;
             addClient(client, (int)i->second.get<double>());
@@ -428,7 +433,7 @@ namespace onelab{
 #endif
   };
 
-  class parameterLessThan{
+  class parameterLessThan {
   public:
     bool operator()(const parameter *p1, const parameter *p2) const
     {
@@ -438,7 +443,7 @@ namespace onelab{
 
   // The number class. Numbers are stored internally as double precision real
   // numbers.
-  class number : public parameter{
+  class number : public parameter {
   private:
     std::vector<double> _values, _choices;
     double _min, _max, _step;
@@ -446,22 +451,31 @@ namespace onelab{
     // when not in a loop
     int _index;
     std::map<double, std::string> _valueLabels;
+
   public:
-    number(const std::string &name="", double value=0.,
-           const std::string &label="", const std::string &help="")
+    number(const std::string &name = "", double value = 0.,
+           const std::string &label = "", const std::string &help = "")
       : parameter(name, label, help), _values(std::vector<double>(1, value)),
-        _min(-maxNumber()), _max(maxNumber()), _step(0.), _index(-1){}
+        _min(-maxNumber()), _max(maxNumber()), _step(0.), _index(-1)
+    {
+    }
     number(const std::string &name, const std::vector<double> &values,
-           const std::string &label="", const std::string &help="")
-      : parameter(name, label, help), _values(values),
-        _min(-maxNumber()), _max(maxNumber()), _step(0.), _index(-1){}
-    void setValue(double value){ _values.resize(1); _values[0] = value; }
-    void setValues(const std::vector<double> &values){ _values = values; }
-    void setMin(double min){ _min = min; }
-    void setMax(double max){ _max = max; }
-    void setStep(double step){ _step = step; }
-    void setIndex(int index){ _index = index; }
-    void setChoices(const std::vector<double> &choices){ _choices = choices; }
+           const std::string &label = "", const std::string &help = "")
+      : parameter(name, label, help), _values(values), _min(-maxNumber()),
+        _max(maxNumber()), _step(0.), _index(-1)
+    {
+    }
+    void setValue(double value)
+    {
+      _values.resize(1);
+      _values[0] = value;
+    }
+    void setValues(const std::vector<double> &values) { _values = values; }
+    void setMin(double min) { _min = min; }
+    void setMax(double max) { _max = max; }
+    void setStep(double step) { _step = step; }
+    void setIndex(int index) { _index = index; }
+    void setChoices(const std::vector<double> &choices) { _choices = choices; }
     void setChoiceLabels(const std::vector<std::string> &labels)
     {
       if(labels.size() != _choices.size()) return;
@@ -478,7 +492,11 @@ namespace onelab{
       _valueLabels[value] = label;
     }
     std::string getType() const { return "number"; }
-    double getValue() const { if(_values.empty()) return 0.; return _values[0]; }
+    double getValue() const
+    {
+      if(_values.empty()) return 0.;
+      return _values[0];
+    }
     const std::vector<double> &getValues() const { return _values; }
     unsigned int getNumValues() const { return _values.size(); }
     double getMin() const { return _min; }
@@ -492,7 +510,8 @@ namespace onelab{
     }
     std::string getValueLabel(double value) const
     {
-      std::map<double, std::string>::const_iterator it = _valueLabels.find(value);
+      std::map<double, std::string>::const_iterator it =
+        _valueLabels.find(value);
       if(it != _valueLabels.end()) return it->second;
       return "";
     }
@@ -505,13 +524,13 @@ namespace onelab{
       setReadOnly(p.getReadOnly());
       setAttributes(p.getAttributes());
       bool changed = false;
-      for(unsigned int i = 0; i < p.getValues().size(); i++){
-        if(p.getValues()[i] != getValues()[i]){
+      for(unsigned int i = 0; i < p.getValues().size(); i++) {
+        if(p.getValues()[i] != getValues()[i]) {
           changed = true;
           break;
         }
       }
-      if(changed){
+      if(changed) {
         setValues(p.getValues());
         setChanged(getChangedValue());
       }
@@ -527,22 +546,18 @@ namespace onelab{
     {
       std::ostringstream sstream;
       sstream.precision(16);
-      sstream << parameter::toChar()
-              << _values.size() << charSep();
+      sstream << parameter::toChar() << _values.size() << charSep();
       for(unsigned int i = 0; i < _values.size(); i++)
         sstream << _values[i] << charSep();
-      sstream << _min << charSep()
-              << _max << charSep()
-              << _step << charSep()
-	      << _index << charSep()
-              << _choices.size() << charSep();
+      sstream << _min << charSep() << _max << charSep() << _step << charSep()
+              << _index << charSep() << _choices.size() << charSep();
       for(unsigned int i = 0; i < _choices.size(); i++)
         sstream << _choices[i] << charSep();
       sstream << _valueLabels.size() << charSep();
-      for(std::map<double, std::string>::const_iterator it = _valueLabels.begin();
-          it != _valueLabels.end(); it++){
-        sstream << it->first << charSep()
-                << sanitize(it->second) << charSep();
+      for(std::map<double, std::string>::const_iterator it =
+            _valueLabels.begin();
+          it != _valueLabels.end(); it++) {
+        sstream << it->first << charSep() << sanitize(it->second) << charSep();
       }
       return sstream.str();
     }
@@ -561,7 +576,7 @@ namespace onelab{
       for(unsigned int i = 0; i < _choices.size(); i++)
         _choices[i] = atof(getNextToken(msg, pos).c_str());
       int numValueLabels = atoi(getNextToken(msg, pos).c_str());
-      for(int i = 0; i < numValueLabels; i++){
+      for(int i = 0; i < numValueLabels; i++) {
         double value = atof(getNextToken(msg, pos).c_str());
         _valueLabels[value] = getNextToken(msg, pos);
       }
@@ -571,29 +586,27 @@ namespace onelab{
     {
       std::ostringstream sstream;
       sstream.precision(16);
-      sstream << "{ " << parameter::toJSON()
-              << ", \"values\":[ ";
-      for(unsigned int i = 0; i < _values.size(); i++){
+      sstream << "{ " << parameter::toJSON() << ", \"values\":[ ";
+      for(unsigned int i = 0; i < _values.size(); i++) {
         if(i) sstream << ", ";
         sstream << _values[i];
       }
       sstream << " ]"
-              << ", \"min\":" << _min
-              << ", \"max\":" << _max
-              << ", \"step\":" << _step
-              << ", \"index\":" << _index;
-      if(_choices.size()){
+              << ", \"min\":" << _min << ", \"max\":" << _max
+              << ", \"step\":" << _step << ", \"index\":" << _index;
+      if(_choices.size()) {
         sstream << ", \"choices\":[ ";
-        for(unsigned int i = 0; i < _choices.size(); i++){
+        for(unsigned int i = 0; i < _choices.size(); i++) {
           if(i) sstream << ", ";
           sstream << _choices[i];
         }
         sstream << " ]";
       }
-      if(_valueLabels.size()){
+      if(_valueLabels.size()) {
         sstream << ", \"valueLabels\":{ ";
-        for(std::map<double, std::string>::const_iterator it = _valueLabels.begin();
-            it != _valueLabels.end(); it++){
+        for(std::map<double, std::string>::const_iterator it =
+              _valueLabels.begin();
+            it != _valueLabels.end(); it++) {
           if(it != _valueLabels.begin()) sstream << ", ";
           sstream << "\"" << sanitizeJSON(it->second) << "\":" << it->first;
         }
@@ -603,48 +616,51 @@ namespace onelab{
       return sstream.str();
     }
 #if defined(HAVE_PICOJSON)
-    bool fromJSON(const picojson::value::object& par)
+    bool fromJSON(const picojson::value::object &par)
     {
       if(!parameter::fromJSON(par)) return false;
-      for(picojson::value::object::const_iterator it = par.begin(); it != par.end(); ++it){
-        if(it->first == "values"){
+      for(picojson::value::object::const_iterator it = par.begin();
+          it != par.end(); ++it) {
+        if(it->first == "values") {
           if(!it->second.is<picojson::array>()) return false;
           const picojson::value::array &arr = it->second.get<picojson::array>();
           _values.resize(arr.size());
-          for(unsigned int i = 0; i < arr.size(); i++){
+          for(unsigned int i = 0; i < arr.size(); i++) {
             if(!arr[i].is<double>()) return false;
             _values[i] = arr[i].get<double>();
           }
         }
-        else if(it->first == "min"){
+        else if(it->first == "min") {
           if(!it->second.is<double>()) return false;
           setMin(it->second.get<double>());
         }
-        else if(it->first == "max"){
+        else if(it->first == "max") {
           if(!it->second.is<double>()) return false;
           setMax(it->second.get<double>());
         }
-        else if(it->first == "step"){
+        else if(it->first == "step") {
           if(!it->second.is<double>()) return false;
           setStep(it->second.get<double>());
         }
-        else if(it->first == "index"){
+        else if(it->first == "index") {
           if(!it->second.is<double>()) return false;
           setIndex((int)it->second.get<double>());
         }
-        else if(it->first == "choices"){
+        else if(it->first == "choices") {
           if(!it->second.is<picojson::array>()) return false;
           const picojson::value::array &arr = it->second.get<picojson::array>();
           _choices.resize(arr.size());
-          for(unsigned int i = 0; i < arr.size(); i++){
+          for(unsigned int i = 0; i < arr.size(); i++) {
             if(!arr[i].is<double>()) return false;
             _choices[i] = arr[i].get<double>();
           }
         }
-        else if(it->first == "valueLabels"){
+        else if(it->first == "valueLabels") {
           if(!it->second.is<picojson::object>()) return false;
-          const picojson::value::object &obj = it->second.get<picojson::object>();
-          for (picojson::value::object::const_iterator i = obj.begin(); i != obj.end(); ++i) {
+          const picojson::value::object &obj =
+            it->second.get<picojson::object>();
+          for(picojson::value::object::const_iterator i = obj.begin();
+              i != obj.end(); ++i) {
             if(!i->second.is<double>()) return false;
             _valueLabels[i->second.get<double>()] = i->first;
           }
@@ -657,28 +673,40 @@ namespace onelab{
 
   // The string class. A string has a mutable "kind", that can be changed at
   // runtime. Kinds leading to specific behavior in Gmsh are: "file".
-  class string : public parameter{
+  class string : public parameter {
   private:
     std::vector<std::string> _values, _choices;
     std::string _kind;
+
   public:
-    string(const std::string &name="", const std::string &value="",
-           const std::string &label="", const std::string &help="")
-      : parameter(name, label, help), _values(std::vector<std::string>(1, value)),
-        _kind("generic") {}
+    string(const std::string &name = "", const std::string &value = "",
+           const std::string &label = "", const std::string &help = "")
+      : parameter(name, label, help),
+        _values(std::vector<std::string>(1, value)), _kind("generic")
+    {
+    }
     string(const std::string &name, const std::vector<std::string> &values,
-           const std::string &label="", const std::string &help="")
-      : parameter(name, label, help), _values(values),
-        _kind("generic") {}
-    void setValue(const std::string &value){ _values.resize(1); _values[0] = value; }
-    void setValues(const std::vector<std::string> &values){ _values = values; }
-    void setKind(const std::string &kind){ _kind = kind; }
-    void setChoices(const std::vector<std::string> &choices){ _choices = choices; }
+           const std::string &label = "", const std::string &help = "")
+      : parameter(name, label, help), _values(values), _kind("generic")
+    {
+    }
+    void setValue(const std::string &value)
+    {
+      _values.resize(1);
+      _values[0] = value;
+    }
+    void setValues(const std::vector<std::string> &values) { _values = values; }
+    void setKind(const std::string &kind) { _kind = kind; }
+    void setChoices(const std::vector<std::string> &choices)
+    {
+      _choices = choices;
+    }
     std::string getType() const { return "string"; }
     const std::string &getValue() const
     {
       static std::string n("");
-      if(_values.empty()) return n; return _values[0];
+      if(_values.empty()) return n;
+      return _values[0];
     }
     const std::vector<std::string> &getValues() const { return _values; }
     unsigned int getNumValues() const { return _values.size(); }
@@ -693,17 +721,17 @@ namespace onelab{
       setReadOnly(p.getReadOnly());
       setAttributes(p.getAttributes());
       bool changed = false;
-      for(unsigned int i = 0; i < p.getValues().size(); i++){
-        if(p.getValues()[i] != getValues()[i]){
+      for(unsigned int i = 0; i < p.getValues().size(); i++) {
+        if(p.getValues()[i] != getValues()[i]) {
           changed = true;
           break;
         }
       }
-      if(changed){
+      if(changed) {
         setValues(p.getValues());
         setChanged(getChangedValue());
       }
-      if(p.getKind() != getKind()){
+      if(p.getKind() != getKind()) {
         setKind(p.getKind());
         setChanged(getChangedValue());
       }
@@ -713,12 +741,10 @@ namespace onelab{
     std::string toChar() const
     {
       std::ostringstream sstream;
-      sstream << parameter::toChar()
-              << _values.size() << charSep();
+      sstream << parameter::toChar() << _values.size() << charSep();
       for(unsigned int i = 0; i < _values.size(); i++)
         sstream << sanitize(_values[i]) << charSep();
-      sstream << sanitize(_kind) << charSep()
-              << _choices.size() << charSep();
+      sstream << sanitize(_kind) << charSep() << _choices.size() << charSep();
       for(unsigned int i = 0; i < _choices.size(); i++)
         sstream << sanitize(_choices[i]) << charSep();
       return sstream.str();
@@ -739,18 +765,17 @@ namespace onelab{
     std::string toJSON() const
     {
       std::ostringstream sstream;
-      sstream << "{ " << parameter::toJSON()
-              << ", \"values\":[ " ;
-      for(unsigned int i = 0; i < _values.size(); i++){
+      sstream << "{ " << parameter::toJSON() << ", \"values\":[ ";
+      for(unsigned int i = 0; i < _values.size(); i++) {
         if(i) sstream << ", ";
         sstream << "\"" << sanitizeJSON(_values[i]) << "\"";
       }
       sstream << " ] ";
       if(_kind.size())
-        sstream << ", \"kind\":\"" << sanitizeJSON(_kind) <<  "\"";
-      if(_choices.size()){
+        sstream << ", \"kind\":\"" << sanitizeJSON(_kind) << "\"";
+      if(_choices.size()) {
         sstream << ", \"choices\":[ ";
-        for(unsigned int i = 0; i < _choices.size(); i++){
+        for(unsigned int i = 0; i < _choices.size(); i++) {
           if(i) sstream << ", ";
           sstream << "\"" << sanitizeJSON(_choices[i]) << "\"";
         }
@@ -760,28 +785,29 @@ namespace onelab{
       return sstream.str();
     }
 #if defined(HAVE_PICOJSON)
-    bool fromJSON(const picojson::value::object& par)
+    bool fromJSON(const picojson::value::object &par)
     {
       if(!parameter::fromJSON(par)) return false;
-      for(picojson::value::object::const_iterator it = par.begin(); it != par.end(); ++it){
-        if(it->first == "values"){
+      for(picojson::value::object::const_iterator it = par.begin();
+          it != par.end(); ++it) {
+        if(it->first == "values") {
           if(!it->second.is<picojson::array>()) return false;
           const picojson::value::array &arr = it->second.get<picojson::array>();
           _values.resize(arr.size());
-          for(unsigned int i = 0; i < arr.size(); i++){
+          for(unsigned int i = 0; i < arr.size(); i++) {
             if(!arr[i].is<std::string>()) return false;
             _values[i] = arr[i].get<std::string>();
           }
         }
-        else if(it->first == "kind"){
+        else if(it->first == "kind") {
           if(!it->second.is<std::string>()) return false;
           setKind(it->second.get<std::string>());
         }
-        else if(it->first == "choices"){
+        else if(it->first == "choices") {
           if(!it->second.is<picojson::array>()) return false;
           const picojson::value::array &arr = it->second.get<picojson::array>();
           _choices.resize(arr.size());
-          for(unsigned int i = 0; i < arr.size(); i++){
+          for(unsigned int i = 0; i < arr.size(); i++) {
             if(!arr[i].is<std::string>()) return false;
             _choices[i] = arr[i].get<std::string>();
           }
@@ -794,35 +820,35 @@ namespace onelab{
 
   // The parameter space, i.e., the set of parameters stored and handled by the
   // onelab server.
-  class parameterSpace{
+  class parameterSpace {
   private:
-    std::set<number*, parameterLessThan> _numbers;
-    std::set<string*, parameterLessThan> _strings;
+    std::set<number *, parameterLessThan> _numbers;
+    std::set<string *, parameterLessThan> _strings;
     // delete a parameter from the parameter space
-    template <class T> bool _clear(const std::string &name,
-                                   const std::string &client,
-                                   std::set<T*, parameterLessThan> &ps)
-    {
-      if(name.empty() && client.size()){
-        std::vector<T*> toDelete;
-        for(typename std::set<T*, parameterLessThan>::iterator it = ps.begin();
-            it != ps.end(); ){
+    template <class T>
+    bool _clear(const std::string &name, const std::string &client,
+                std::set<T *, parameterLessThan> &ps)
+    {
+      if(name.empty() && client.size()) {
+        std::vector<T *> toDelete;
+        for(typename std::set<T *, parameterLessThan>::iterator it = ps.begin();
+            it != ps.end();) {
           T *p = *it;
-          if(p->hasClient(client)){
+          if(p->hasClient(client)) {
             ps.erase(it++); // to avoid invalid iterator
             delete p;
           }
-          else{
+          else {
             it++;
           }
         }
       }
-      else{
+      else {
         T tmp(name);
-        typename std::set<T*, parameterLessThan>::iterator it = ps.find(&tmp);
-        if(it != ps.end()){
+        typename std::set<T *, parameterLessThan>::iterator it = ps.find(&tmp);
+        if(it != ps.end()) {
           T *p = *it;
-          if(client.empty() || p->hasClient(client)){
+          if(client.empty() || p->hasClient(client)) {
             ps.erase(it);
             delete p;
             return true;
@@ -835,17 +861,20 @@ namespace onelab{
     // (adding new clients if necessary). This would need to be locked to avoid
     // race conditions when several clients try to set a parameter at the same
     // time.
-    template <class T> bool _set(const T &p, const std::string &client,
-                                 std::set<T*, parameterLessThan> &ps)
+    template <class T>
+    bool _set(const T &p, const std::string &client,
+              std::set<T *, parameterLessThan> &ps)
     {
-      typename std::set<T*, parameterLessThan>::iterator it = ps.find((T*)&p);
-      if(it != ps.end()){
+      typename std::set<T *, parameterLessThan>::iterator it = ps.find((T *)&p);
+      if(it != ps.end()) {
         (*it)->update(p);
-        if(client.size()) (*it)->addClient(client, parameter::defaultChangedValue());
+        if(client.size())
+          (*it)->addClient(client, parameter::defaultChangedValue());
       }
-      else{
-        T* newp = new T(p);
-        if(client.size()) newp->addClient(client, parameter::defaultChangedValue());
+      else {
+        T *newp = new T(p);
+        if(client.size())
+          newp->addClient(client, parameter::defaultChangedValue());
         ps.insert(newp);
       }
       return true;
@@ -854,71 +883,75 @@ namespace onelab{
     // category if no name is given. If we find a given parameter by name, we
     // add the client requesting the parameter to the list of clients for this
     // parameter. This would also need to be locked.
-    template <class T> bool _get(std::vector<T> &p, const std::string &name,
-                                 const std::string &client,
-                                 std::set<T*, parameterLessThan> &ps)
+    template <class T>
+    bool _get(std::vector<T> &p, const std::string &name,
+              const std::string &client, std::set<T *, parameterLessThan> &ps)
     {
       p.clear();
-      if(name.empty()){
-        for(typename std::set<T*, parameterLessThan>::iterator it = ps.begin();
+      if(name.empty()) {
+        for(typename std::set<T *, parameterLessThan>::iterator it = ps.begin();
             it != ps.end(); it++)
           p.push_back(**it);
       }
-      else{
+      else {
         T tmp(name);
-        typename std::set<T*, parameterLessThan>::iterator it = ps.find(&tmp);
-        if(it != ps.end()){
-          if(client.size()) (*it)->addClient(client, parameter::defaultChangedValue());
+        typename std::set<T *, parameterLessThan>::iterator it = ps.find(&tmp);
+        if(it != ps.end()) {
+          if(client.size())
+            (*it)->addClient(client, parameter::defaultChangedValue());
           p.push_back(**it);
         }
       }
       return true;
     }
-    template <class T> T* _getPtr(std::string name, const std::string client,
-                                  std::set<T*, parameterLessThan> ps)
+    template <class T>
+    T *_getPtr(std::string name, const std::string client,
+               std::set<T *, parameterLessThan> ps)
     {
       T tmp(name);
-      typename std::set<T*, parameterLessThan>::iterator it = ps.find(&tmp);
-      if(it != ps.end()){
-        if(client.size()) (*it)->addClient(client, parameter::defaultChangedValue());
+      typename std::set<T *, parameterLessThan>::iterator it = ps.find(&tmp);
+      if(it != ps.end()) {
+        if(client.size())
+          (*it)->addClient(client, parameter::defaultChangedValue());
         return *it;
       }
       return NULL;
     }
+
   public:
-    parameterSpace(){}
-    ~parameterSpace(){ clear(); }
-    void clear(const std::string &name="", const std::string &client="")
+    parameterSpace() {}
+    ~parameterSpace() { clear(); }
+    void clear(const std::string &name = "", const std::string &client = "")
     {
-      if(name.empty() && client.empty()){
-        std::set<parameter*, parameterLessThan> ps;
+      if(name.empty() && client.empty()) {
+        std::set<parameter *, parameterLessThan> ps;
         getAllParameters(ps);
-        for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
+        for(std::set<parameter *, parameterLessThan>::iterator it = ps.begin();
             it != ps.end(); it++)
           delete *it;
         _numbers.clear();
         _strings.clear();
       }
-      else{
+      else {
         bool done = _clear(name, client, _numbers);
         if(!done) done = _clear(name, client, _strings);
       }
     }
-    bool set(const number &p, const std::string &client="")
+    bool set(const number &p, const std::string &client = "")
     {
       return _set(p, client, _numbers);
     }
-    bool set(const string &p, const std::string &client="")
+    bool set(const string &p, const std::string &client = "")
     {
       return _set(p, client, _strings);
     }
-    bool get(std::vector<number> &ps, const std::string &name="",
-             const std::string &client="")
+    bool get(std::vector<number> &ps, const std::string &name = "",
+             const std::string &client = "")
     {
       return _get(ps, name, client, _numbers);
     }
-    bool get(std::vector<string> &ps, const std::string &name="",
-             const std::string &client="")
+    bool get(std::vector<string> &ps, const std::string &name = "",
+             const std::string &client = "")
     {
       return _get(ps, name, client, _strings);
     }
@@ -932,7 +965,7 @@ namespace onelab{
     {
       *ptr = _getPtr(name, client, _strings);
     }
-    void getAllParameters(std::set<parameter*, parameterLessThan> &ps) const
+    void getAllParameters(std::set<parameter *, parameterLessThan> &ps) const
     {
       ps.insert(_numbers.begin(), _numbers.end());
       ps.insert(_strings.begin(), _strings.end());
@@ -944,82 +977,87 @@ namespace onelab{
     // check if at least one parameter depends on the given client
     bool hasClient(const std::string &client) const
     {
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
-      for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
+      for(std::set<parameter *, parameterLessThan>::iterator it = ps.begin();
           it != ps.end(); it++)
         if((*it)->hasClient(client)) return true;
       return false;
     }
     // check if some parameters have changed (optionnally only check the
     // parameters that depend on a given client)
-    int getChanged(const std::string &client="") const
+    int getChanged(const std::string &client = "") const
     {
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
       int changed = 0;
-      for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
-          it != ps.end(); it++){
+      for(std::set<parameter *, parameterLessThan>::iterator it = ps.begin();
+          it != ps.end(); it++) {
         changed = std::max(changed, (*it)->getChanged(client));
       }
       return changed;
     }
     // set the changed flag for all the parameters that depend on the given
     // client (or for all parameters if no client name is provided)
-    void setChanged(int changed, const std::string &client="")
+    void setChanged(int changed, const std::string &client = "")
     {
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
-      for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
+      for(std::set<parameter *, parameterLessThan>::iterator it = ps.begin();
           it != ps.end(); it++)
         (*it)->setChanged(changed, client);
     }
-    void thresholdChanged(int threshold, const std::string &client="")
+    void thresholdChanged(int threshold, const std::string &client = "")
     {
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
-      for(std::set<parameter*, parameterLessThan>::iterator it = ps.begin();
-          it != ps.end(); it++){
+      for(std::set<parameter *, parameterLessThan>::iterator it = ps.begin();
+          it != ps.end(); it++) {
         int changed = (*it)->getChanged(client);
-        if(changed > threshold)
-          (*it)->setChanged(threshold, client);
+        if(changed > threshold) (*it)->setChanged(threshold, client);
       }
     }
     // serialize the parameter space (optionally only serialize those parameters
     // that depend on the given client)
-    std::vector<std::string> toChar(const std::string &client="") const
+    std::vector<std::string> toChar(const std::string &client = "") const
     {
       std::vector<std::string> s;
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
-      for(std::set<parameter*, parameterLessThan>::const_iterator it = ps.begin();
+      for(std::set<parameter *, parameterLessThan>::const_iterator it =
+            ps.begin();
           it != ps.end(); it++)
-        if(client.empty() || (*it)->hasClient(client)){
-	  if((*it)->getAttribute("NotInDb") != "True")
-	    s.push_back((*it)->toChar());
-	}
+        if(client.empty() || (*it)->hasClient(client)) {
+          if((*it)->getAttribute("NotInDb") != "True")
+            s.push_back((*it)->toChar());
+        }
       return s;
     }
     // unserialize the parameter space
-    bool fromChar(const std::vector<std::string> &msg, const std::string &client="")
+    bool fromChar(const std::vector<std::string> &msg,
+                  const std::string &client = "")
     {
-      for(unsigned int i = 0; i < msg.size(); i++){
+      for(unsigned int i = 0; i < msg.size(); i++) {
         std::string version, type, name;
         onelab::parameter::getInfoFromChar(msg[i], version, type, name);
         if(onelab::parameter::version() != version) return false;
-        if(type == "number"){
-          number p; p.fromChar(msg[i]); set(p, client);
+        if(type == "number") {
+          number p;
+          p.fromChar(msg[i]);
+          set(p, client);
         }
-        else if(type == "string"){
-          string p; p.fromChar(msg[i]); set(p, client);
+        else if(type == "string") {
+          string p;
+          p.fromChar(msg[i]);
+          set(p, client);
         }
         else
           return false;
       }
       return true;
     }
-    bool toJSON(std::string &json, const std::string &creator="",
-                const std::string &client="") const
+    bool toJSON(std::string &json, const std::string &creator = "",
+                const std::string &client = "") const
     {
       time_t now;
       time(&now);
@@ -1031,21 +1069,22 @@ namespace onelab{
       json += "  \"date\":\"" + t + "\",\n";
       json += "  \"version\":\"" + parameter::version() + "\",\n";
       json += "  \"parameters\":[\n";
-      std::set<parameter*, parameterLessThan> ps;
+      std::set<parameter *, parameterLessThan> ps;
       getAllParameters(ps);
-      for(std::set<parameter*, parameterLessThan>::const_iterator it = ps.begin();
-          it != ps.end(); it++){
+      for(std::set<parameter *, parameterLessThan>::const_iterator it =
+            ps.begin();
+          it != ps.end(); it++) {
         if(it != ps.begin()) json += ",\n";
-        if(client.empty() || (*it)->hasClient(client)){
-	  if((*it)->getAttribute("NotInDb") != "True"){
-	    json += "    " + (*it)->toJSON();
+        if(client.empty() || (*it)->hasClient(client)) {
+          if((*it)->getAttribute("NotInDb") != "True") {
+            json += "    " + (*it)->toJSON();
           }
-	}
+        }
       }
       json += "\n  ] }\n}\n";
       return true;
     }
-    bool fromJSON(const std::string &json, const std::string &client="")
+    bool fromJSON(const std::string &json, const std::string &client = "")
     {
 #if defined(HAVE_PICOJSON)
       picojson::value v;
@@ -1053,28 +1092,37 @@ namespace onelab{
       if(err.size()) return false;
       if(!v.is<picojson::object>()) return false;
       const picojson::value::object &obj = v.get<picojson::object>();
-      for (picojson::value::object::const_iterator i = obj.begin(); i != obj.end(); ++i) {
-        if(i->first == "onelab"){ // onelab database
+      for(picojson::value::object::const_iterator i = obj.begin();
+          i != obj.end(); ++i) {
+        if(i->first == "onelab") { // onelab database
           if(!i->second.is<picojson::object>()) return false;
           const picojson::value::object &db = i->second.get<picojson::object>();
-          for (picojson::value::object::const_iterator j = db.begin(); j != db.end(); ++j) {
-            if(j->first == "version"){
+          for(picojson::value::object::const_iterator j = db.begin();
+              j != db.end(); ++j) {
+            if(j->first == "version") {
               if(!j->second.is<std::string>()) return false;
-              if(j->second.get<std::string>() != parameter::version()) return false;
+              if(j->second.get<std::string>() != parameter::version())
+                return false;
             }
-            else if(j->first == "parameters"){
+            else if(j->first == "parameters") {
               if(!j->second.is<picojson::array>()) return false;
-              const picojson::value::array &arr = j->second.get<picojson::array>();
-              for(unsigned int k = 0; k < arr.size(); k++){
+              const picojson::value::array &arr =
+                j->second.get<picojson::array>();
+              for(unsigned int k = 0; k < arr.size(); k++) {
                 if(!arr[k].is<picojson::object>()) return false;
-                const picojson::value::object &par = arr[k].get<picojson::object>();
+                const picojson::value::object &par =
+                  arr[k].get<picojson::object>();
                 picojson::value::object::const_iterator it = par.find("type");
                 if(it == par.end()) return false;
-                if(it->second.to_str() == "number"){
-                  number p; p.fromJSON(par); set(p, client);
+                if(it->second.to_str() == "number") {
+                  number p;
+                  p.fromJSON(par);
+                  set(p, client);
                 }
-                else if(it->second.to_str() == "string"){
-                  string p; p.fromJSON(par); set(p, client);
+                else if(it->second.to_str() == "string") {
+                  string p;
+                  p.fromJSON(par);
+                  set(p, client);
                 }
               }
             }
@@ -1091,7 +1139,7 @@ namespace onelab{
   // The onelab client: a class that communicates with the onelab server. Each
   // client should be derived from this one. A client can be understood as "one
   // simulation step in a complex computation".
-  class client{
+  class client {
   protected:
     // the name of the client
     std::string _name;
@@ -1099,64 +1147,82 @@ namespace onelab{
     int _id;
     // the index of the client in an external client list (if any)
     int _index;
+
   public:
-    client(const std::string &name) : _name(name), _id(0), _index(-1){}
-    virtual ~client(){}
-    std::string getName(){ return _name; }
-    void setId(int id){ _id = id; }
-    int getId(){ return _id; }
-    void setIndex(int index){ _index = index; }
-    int getIndex(){ return _index; }
-    virtual bool run(){ return false; }
-    virtual bool isNetworkClient(){ return false; }
-    virtual bool kill(){ return false; }
-    virtual void sendInfo(const std::string &msg){ std::cout << msg << std::endl; }
-    virtual void sendWarning(const std::string &msg){ std::cerr << msg << std::endl; }
-    virtual void sendError(const std::string &msg){ std::cerr << msg << std::endl; }
-    virtual void sendProgress(const std::string &msg){ std::cout << msg << std::endl; }
-    virtual void sendMergeFileRequest(const std::string &msg){}
-    virtual void sendOpenProjectRequest(const std::string &msg){}
-    virtual void sendParseStringRequest(const std::string &msg){}
-    virtual void sendVertexArray(const std::string &msg){}
+    client(const std::string &name) : _name(name), _id(0), _index(-1) {}
+    virtual ~client() {}
+    std::string getName() { return _name; }
+    void setId(int id) { _id = id; }
+    int getId() { return _id; }
+    void setIndex(int index) { _index = index; }
+    int getIndex() { return _index; }
+    virtual bool run() { return false; }
+    virtual bool isNetworkClient() { return false; }
+    virtual bool kill() { return false; }
+    virtual void sendInfo(const std::string &msg)
+    {
+      std::cout << msg << std::endl;
+    }
+    virtual void sendWarning(const std::string &msg)
+    {
+      std::cerr << msg << std::endl;
+    }
+    virtual void sendError(const std::string &msg)
+    {
+      std::cerr << msg << std::endl;
+    }
+    virtual void sendProgress(const std::string &msg)
+    {
+      std::cout << msg << std::endl;
+    }
+    virtual void sendMergeFileRequest(const std::string &msg) {}
+    virtual void sendOpenProjectRequest(const std::string &msg) {}
+    virtual void sendParseStringRequest(const std::string &msg) {}
+    virtual void sendVertexArray(const std::string &msg) {}
     virtual bool clear(const std::string &name) = 0;
     virtual bool set(const number &p) = 0;
     virtual bool set(const string &p) = 0;
-    virtual bool get(std::vector<number> &ps, const std::string &name="") = 0;
-    virtual bool get(std::vector<string> &ps, const std::string &name="") = 0;
+    virtual bool get(std::vector<number> &ps, const std::string &name = "") = 0;
+    virtual bool get(std::vector<string> &ps, const std::string &name = "") = 0;
     virtual bool setAndAppendChoices(const number &p) = 0;
     virtual bool setAndAppendChoices(const string &p) = 0;
-    virtual bool getWithoutChoices(std::vector<number> &ps, const std::string &name="") = 0;
-    virtual bool getWithoutChoices(std::vector<string> &ps, const std::string &name="") = 0;
+    virtual bool getWithoutChoices(std::vector<number> &ps,
+                                   const std::string &name = "") = 0;
+    virtual bool getWithoutChoices(std::vector<string> &ps,
+                                   const std::string &name = "") = 0;
     std::vector<std::string> toChar()
     {
       std::vector<std::string> out;
-      std::vector<number> n; get(n);
+      std::vector<number> n;
+      get(n);
       for(unsigned int i = 0; i < n.size(); i++) out.push_back(n[i].toChar());
-      std::vector<string> s; get(s);
+      std::vector<string> s;
+      get(s);
       for(unsigned int i = 0; i < s.size(); i++) out.push_back(s[i].toChar());
       return out;
     }
     bool fromChar(const std::vector<std::string> &msg)
     {
-      for(unsigned int i = 0; i < msg.size(); i++){
+      for(unsigned int i = 0; i < msg.size(); i++) {
         std::string version, type, name;
         onelab::parameter::getInfoFromChar(msg[i], version, type, name);
         if(onelab::parameter::version() != version) return false;
-        if(type == "number"){
-          number p; p.fromChar(msg[i]); set(p);
+        if(type == "number") {
+          number p;
+          p.fromChar(msg[i]);
+          set(p);
         }
-        else if(type == "string"){
-          string p; p.fromChar(msg[i]); set(p);
+        else if(type == "string") {
+          string p;
+          p.fromChar(msg[i]);
+          set(p);
         }
         else
           return false;
       }
       return true;
     }
-    bool toFile(FILE *fp)
-    {
-      return parameter::toFile(toChar(), fp, getName());
-    }
+    bool toFile(FILE *fp) { return parameter::toFile(toChar(), fp, getName()); }
     bool fromFile(FILE *fp)
     {
       std::vector<std::string> msg;
@@ -1167,41 +1233,43 @@ namespace onelab{
 
   // The onelab server: a singleton that stores the parameter space and
   // interacts with onelab clients.
-  class server{
+  class server {
   private:
     // the unique server (singleton behaviour due to the "static" specifier)
     static server *_server;
     // the address of the server
     std::string _address;
     // the connected clients
-    std::set<client*> _clients;
+    std::set<client *> _clients;
     // the parameter space
     parameterSpace _parameterSpace;
+
   public:
-    server(const std::string &address="") : _address(address) {}
-    ~server(){}
-    static server *instance(const std::string &address="")
+    server(const std::string &address = "") : _address(address) {}
+    ~server() {}
+    static server *instance(const std::string &address = "")
     {
       if(!_server) _server = new server(address);
       return _server;
     }
     static void setInstance(server *s) { _server = s; }
-    void clear(const std::string &name="", const std::string &client="")
+    void clear(const std::string &name = "", const std::string &client = "")
     {
       _parameterSpace.clear(name, client);
     }
-    template <class T> bool set(const T &p, const std::string &client="")
+    template <class T> bool set(const T &p, const std::string &client = "")
     {
       return _parameterSpace.set(p, client);
     }
-    template <class T> bool get(std::vector<T> &ps, const std::string &name="",
-                                const std::string &client="")
+    template <class T>
+    bool get(std::vector<T> &ps, const std::string &name = "",
+             const std::string &client = "")
     {
       return _parameterSpace.get(ps, name, client);
     }
-    typedef std::set<client*>::iterator citer;
-    citer firstClient(){ return _clients.begin(); }
-    citer lastClient(){ return _clients.end(); }
+    typedef std::set<client *>::iterator citer;
+    citer firstClient() { return _clients.begin(); }
+    citer lastClient() { return _clients.end(); }
     int getNumClients() { return (int)_clients.size(); };
     citer findClient(const std::string &name)
     {
@@ -1214,89 +1282,96 @@ namespace onelab{
       _clients.insert(c);
       c->setId(_clients.size());
     }
-    void unregisterClient(client *c){ _clients.erase(c); }
-    void setChanged(int changed, const std::string &client="")
+    void unregisterClient(client *c) { _clients.erase(c); }
+    void setChanged(int changed, const std::string &client = "")
     {
       _parameterSpace.setChanged(changed, client);
     }
-    int getChanged(const std::string &client="")
+    int getChanged(const std::string &client = "")
     {
       return _parameterSpace.getChanged(client);
     }
-    void thresholdChanged(int value, const std::string &client="")
+    void thresholdChanged(int value, const std::string &client = "")
     {
       _parameterSpace.thresholdChanged(value, client);
     }
-    unsigned int getNumParameters(){ return _parameterSpace.getNumParameters(); }
-    std::vector<std::string> toChar(const std::string &client="")
+    unsigned int getNumParameters()
+    {
+      return _parameterSpace.getNumParameters();
+    }
+    std::vector<std::string> toChar(const std::string &client = "")
     {
       return _parameterSpace.toChar(client);
     }
-    bool fromChar(const std::vector<std::string> &msg, const std::string &client="")
+    bool fromChar(const std::vector<std::string> &msg,
+                  const std::string &client = "")
     {
       return _parameterSpace.fromChar(msg, client);
     }
-    bool toFile(FILE *fp, const std::string &client="")
+    bool toFile(FILE *fp, const std::string &client = "")
     {
       return parameter::toFile(toChar(client), fp, "onelab server");
     }
-    bool fromFile(FILE *fp, const std::string &client="")
+    bool fromFile(FILE *fp, const std::string &client = "")
     {
       std::vector<std::string> msg;
       if(parameter::fromFile(msg, fp)) return fromChar(msg, client);
       return false;
     }
-    bool toJSON(std::string &json, const std::string &client="")
+    bool toJSON(std::string &json, const std::string &client = "")
     {
       return _parameterSpace.toJSON(json, client);
     }
-    bool fromJSON(const std::string &json, const std::string &client="")
+    bool fromJSON(const std::string &json, const std::string &client = "")
     {
       return _parameterSpace.fromJSON(json, client);
     }
   };
 
   // A local client, which lives in the same memory space as the server.
-  class localClient : public client{
+  class localClient : public client {
   private:
     template <class T> bool _set(const T &p)
     {
       server::instance()->set(p, _name);
       return true;
     }
-    template <class T> bool _get(std::vector<T> &ps,
-                                 const std::string &name="")
+    template <class T>
+    bool _get(std::vector<T> &ps, const std::string &name = "")
     {
       server::instance()->get(ps, name, _name);
       return true;
     }
+
   public:
     localClient(const std::string &name) : client(name)
     {
       server::instance()->registerClient(this);
     }
-    virtual ~localClient()
-    {
-      server::instance()->unregisterClient(this);
-    }
-    virtual bool clear(const std::string &name="")
+    virtual ~localClient() { server::instance()->unregisterClient(this); }
+    virtual bool clear(const std::string &name = "")
     {
       server::instance()->clear(name);
       return true;
     }
-    virtual bool set(const number &p){ return _set(p); }
-    virtual bool set(const string &p){ return _set(p); }
-    virtual bool get(std::vector<number> &ps,
-                     const std::string &name=""){ return _get(ps, name); }
-    virtual bool get(std::vector<string> &ps,
-                     const std::string &name=""){ return _get(ps, name); }
+    virtual bool set(const number &p) { return _set(p); }
+    virtual bool set(const string &p) { return _set(p); }
+    virtual bool get(std::vector<number> &ps, const std::string &name = "")
+    {
+      return _get(ps, name);
+    }
+    virtual bool get(std::vector<string> &ps, const std::string &name = "")
+    {
+      return _get(ps, name);
+    }
     virtual bool setAndAppendChoices(const number &p)
     {
       std::vector<number> ps;
       _get(ps, _name);
       std::vector<double> choices;
       if(ps.size()) choices = ps[0].getChoices();
-      choices.insert(choices.end(), p.getChoices().begin(), p.getChoices().end());
+      choices.insert(choices.end(), p.getChoices().begin(),
+                     p.getChoices().end());
       number p2(p);
       p2.setChoices(choices);
       return _set(p2);
@@ -1307,13 +1382,14 @@ namespace onelab{
       _get(ps, _name);
       std::vector<std::string> choices;
       if(ps.size()) choices = ps[0].getChoices();
-      choices.insert(choices.end(), p.getChoices().begin(), p.getChoices().end());
+      choices.insert(choices.end(), p.getChoices().begin(),
+                     p.getChoices().end());
       string p2(p);
       p2.setChoices(choices);
       return _set(p2);
     }
     virtual bool getWithoutChoices(std::vector<number> &ps,
-                                   const std::string &name="")
+                                   const std::string &name = "")
     {
       bool ret = _get(ps, name);
       for(unsigned int i = 0; i < ps.size(); i++)
@@ -1321,7 +1397,7 @@ namespace onelab{
       return ret;
     }
     virtual bool getWithoutChoices(std::vector<string> &ps,
-                                   const std::string &name="")
+                                   const std::string &name = "")
     {
       bool ret = _get(ps, name);
       for(unsigned int i = 0; i < ps.size(); i++)
@@ -1331,7 +1407,7 @@ namespace onelab{
   };
 
   // The local part of a network client.
-  class localNetworkClient : public localClient{
+  class localNetworkClient : public localClient {
   private:
     // executable of the client (including filesystem path, if necessary)
     std::string _executable;
@@ -1347,36 +1423,39 @@ namespace onelab{
     int _pid;
     // underlying GmshServer
     GmshServer *_gmshServer;
+
   public:
     localNetworkClient(const std::string &name, const std::string &executable,
-                       const std::string &remoteLogin="",
-                       bool treatExecutableAsFullCommandLine=false)
+                       const std::string &remoteLogin = "",
+                       bool treatExecutableAsFullCommandLine = false)
       : localClient(name), _executable(executable),
         _treatExecutableAsFullCommandLine(treatExecutableAsFullCommandLine),
         _remoteLogin(remoteLogin), _socketSwitch("-onelab"), _pid(-1),
-        _gmshServer(0) {}
-    virtual ~localNetworkClient(){}
-    virtual bool isNetworkClient(){ return true; }
-    const std::string &getExecutable(){ return _executable; }
-    void setExecutable(const std::string &s){ _executable = s; }
-    const std::string &getRemoteLogin(){ return _remoteLogin; }
+        _gmshServer(0)
+    {
+    }
+    virtual ~localNetworkClient() {}
+    virtual bool isNetworkClient() { return true; }
+    const std::string &getExecutable() { return _executable; }
+    void setExecutable(const std::string &s) { _executable = s; }
+    const std::string &getRemoteLogin() { return _remoteLogin; }
     bool treatExecutableAsFullCommandLine() const
     {
       return _treatExecutableAsFullCommandLine;
     }
-    void setRemoteLogin(const std::string &s){ _remoteLogin = s; }
-    const std::string &getSocketSwitch(){ return _socketSwitch; }
-    void setSocketSwitch(const std::string &s){ _socketSwitch = s; }
-    int getPid(){ return _pid; }
-    void setPid(int pid){ _pid = pid; }
-    GmshServer *getGmshServer(){ return _gmshServer; }
-    void setGmshServer(GmshServer *server){ _gmshServer = server; }
+    void setRemoteLogin(const std::string &s) { _remoteLogin = s; }
+    const std::string &getSocketSwitch() { return _socketSwitch; }
+    void setSocketSwitch(const std::string &s) { _socketSwitch = s; }
+    int getPid() { return _pid; }
+    void setPid(int pid) { _pid = pid; }
+    GmshServer *getGmshServer() { return _gmshServer; }
+    void setGmshServer(GmshServer *server) { _gmshServer = server; }
     virtual bool run() = 0;
     virtual bool kill() = 0;
   };
 
   // The remote part of a network client.
-  class remoteNetworkClient : public client{
+  class remoteNetworkClient : public client {
   private:
     // address (inet:port or unix socket) of the server
     std::string _serverAddress;
@@ -1384,124 +1463,134 @@ namespace onelab{
     GmshClient *_gmshClient;
     // number of subclients
     int _numSubClients;
-    template <class T> bool _set(const T &p, bool withChoices=true)
+    template <class T> bool _set(const T &p, bool withChoices = true)
     {
       if(!_gmshClient) return false;
       std::string msg = p.toChar();
-      _gmshClient->SendMessage(withChoices ? GmshSocket::GMSH_PARAMETER :
-                               GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES,
+      _gmshClient->SendMessage(withChoices ?
+                                 GmshSocket::GMSH_PARAMETER :
+                                 GmshSocket::GMSH_PARAMETER_WITHOUT_CHOICES,
                                msg.size(), &msg[0]);
       return true;
     }
-    template <class T> bool _get(std::vector<T> &ps, const std::string &name="",
-                                 bool withChoices=true)
+    template <class T>
+    bool _get(std::vector<T> &ps, const std::string &name = "",
+              bool withChoices = true)
     {
       ps.clear();
       if(!_gmshClient) return false;
       T p(name);
       std::string msg = p.toChar();
       if(name.size())
-	_gmshClient->SendMessage(withChoices ? GmshSocket::GMSH_PARAMETER_QUERY :
-                                 GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES,
-                                 msg.size(), &msg[0]);
+        _gmshClient->SendMessage(
+          withChoices ? GmshSocket::GMSH_PARAMETER_QUERY :
+                        GmshSocket::GMSH_PARAMETER_QUERY_WITHOUT_CHOICES,
+          msg.size(), &msg[0]);
       else // get all parameters
-	_gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_QUERY_ALL, msg.size(), &msg[0]);
+        _gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_QUERY_ALL,
+                                 msg.size(), &msg[0]);
 
-      while(1){
+      while(1) {
         // stop if we have no communications for 5 minutes
         int ret = _gmshClient->Select(500, 0);
-        if(!ret){
+        if(!ret) {
           _gmshClient->Info("Timeout: aborting remote get");
           return false;
         }
-        else if(ret < 0){
+        else if(ret < 0) {
           _gmshClient->Error("Error on select: aborting remote get");
           return false;
         }
         int type, length, swap;
-        if(!_gmshClient->ReceiveHeader(&type, &length, &swap)){
-          _gmshClient->Error("Did not receive message header: aborting remote get");
+        if(!_gmshClient->ReceiveHeader(&type, &length, &swap)) {
+          _gmshClient->Error(
+            "Did not receive message header: aborting remote get");
           return false;
         }
         std::string msg(length, ' ');
-        if(!_gmshClient->ReceiveMessage(length, &msg[0])){
-          _gmshClient->Error("Did not receive message body: aborting remote get");
+        if(!_gmshClient->ReceiveMessage(length, &msg[0])) {
+          _gmshClient->Error(
+            "Did not receive message body: aborting remote get");
           return false;
         }
-        if(type == GmshSocket::GMSH_PARAMETER){
+        if(type == GmshSocket::GMSH_PARAMETER) {
           T p;
           p.fromChar(msg);
           ps.push_back(p);
           return true;
         }
-        if(type == GmshSocket::GMSH_PARAMETER_QUERY_ALL){
+        if(type == GmshSocket::GMSH_PARAMETER_QUERY_ALL) {
           T p;
           p.fromChar(msg);
           ps.push_back(p);
           // do NOT return until all parameters have been downloaded
         }
-        else if(type == GmshSocket::GMSH_PARAMETER_QUERY_END){
-	  // all parameters have been sent
+        else if(type == GmshSocket::GMSH_PARAMETER_QUERY_END) {
+          // all parameters have been sent
           return true;
         }
-        else if(type == GmshSocket::GMSH_PARAMETER_NOT_FOUND){
+        else if(type == GmshSocket::GMSH_PARAMETER_NOT_FOUND) {
           // parameter not found
           return true;
         }
-        else if(type == GmshSocket::GMSH_INFO){
+        else if(type == GmshSocket::GMSH_INFO) {
           return true;
         }
-        else{
+        else {
           _gmshClient->Error("Unknown message type: aborting remote get");
           return false;
         }
       }
       return true;
     }
+
   public:
     void waitOnSubClients()
     {
       if(!_gmshClient) return;
-      while(_numSubClients > 0){
+      while(_numSubClients > 0) {
         int ret = _gmshClient->Select(500, 0);
-        if(!ret){
+        if(!ret) {
           _gmshClient->Info("Timeout: aborting wait on subclients");
           return;
         }
-        else if(ret < 0){
+        else if(ret < 0) {
           _gmshClient->Error("Error on select: aborting wait on subclients");
           return;
         }
         int type, length, swap;
-        if(!_gmshClient->ReceiveHeader(&type, &length, &swap)){
-          _gmshClient->Error("Did not receive message header: aborting wait on subclients");
+        if(!_gmshClient->ReceiveHeader(&type, &length, &swap)) {
+          _gmshClient->Error(
+            "Did not receive message header: aborting wait on subclients");
           return;
         }
         std::string msg(length, ' ');
-        if(!_gmshClient->ReceiveMessage(length, &msg[0])){
-          _gmshClient->Error("Did not receive message body: aborting wait on subclients");
+        if(!_gmshClient->ReceiveMessage(length, &msg[0])) {
+          _gmshClient->Error(
+            "Did not receive message body: aborting wait on subclients");
           return;
         }
-        if(type == GmshSocket::GMSH_STOP)
-          _numSubClients -= 1;
+        if(type == GmshSocket::GMSH_STOP) _numSubClients -= 1;
       }
     }
+
   public:
-    remoteNetworkClient(const std::string &name, const std::string &serverAddress)
+    remoteNetworkClient(const std::string &name,
+                        const std::string &serverAddress)
       : client(name), _serverAddress(serverAddress), _numSubClients(0)
     {
       _gmshClient = new GmshClient();
-      if(_gmshClient->Connect(_serverAddress.c_str()) < 0){
+      if(_gmshClient->Connect(_serverAddress.c_str()) < 0) {
         delete _gmshClient;
         _gmshClient = 0;
       }
-      else{
+      else {
         _gmshClient->Start();
       }
     }
     virtual ~remoteNetworkClient()
     {
-      if(_gmshClient){
+      if(_gmshClient) {
         waitOnSubClients();
         _gmshClient->Stop();
         _gmshClient->Disconnect();
@@ -1509,33 +1598,36 @@ namespace onelab{
         _gmshClient = 0;
       }
     }
-    GmshClient *getGmshClient(){ return _gmshClient; }
-    virtual bool isNetworkClient(){ return true; }
-    virtual bool clear(const std::string &name="")
+    GmshClient *getGmshClient() { return _gmshClient; }
+    virtual bool isNetworkClient() { return true; }
+    virtual bool clear(const std::string &name = "")
     {
       if(!_gmshClient) return false;
       std::string msg = name;
       if(msg.empty()) msg = "*";
-      _gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_CLEAR, msg.size(), &msg[0]);
+      _gmshClient->SendMessage(GmshSocket::GMSH_PARAMETER_CLEAR, msg.size(),
+                               &msg[0]);
       return true;
     }
-    virtual bool set(const number &p){ return _set(p); }
-    virtual bool set(const string &p){ return _set(p); }
-    virtual bool get(std::vector<number> &ps, const std::string &name="")
+    virtual bool set(const number &p) { return _set(p); }
+    virtual bool set(const string &p) { return _set(p); }
+    virtual bool get(std::vector<number> &ps, const std::string &name = "")
     {
       return _get(ps, name);
     }
-    virtual bool get(std::vector<string> &ps, const std::string &name="")
+    virtual bool get(std::vector<string> &ps, const std::string &name = "")
     {
       return _get(ps, name);
     }
-    virtual bool setAndAppendChoices(const number &p){ return _set(p, false); }
-    virtual bool setAndAppendChoices(const string &p){ return _set(p, false); }
-    virtual bool getWithoutChoices(std::vector<number> &ps, const std::string &name="")
+    virtual bool setAndAppendChoices(const number &p) { return _set(p, false); }
+    virtual bool setAndAppendChoices(const string &p) { return _set(p, false); }
+    virtual bool getWithoutChoices(std::vector<number> &ps,
+                                   const std::string &name = "")
     {
       return _get(ps, name, false);
     }
-    virtual bool getWithoutChoices(std::vector<string> &ps, const std::string &name="")
+    virtual bool getWithoutChoices(std::vector<string> &ps,
+                                   const std::string &name = "")
     {
       return _get(ps, name, false);
     }
@@ -1567,12 +1659,13 @@ namespace onelab{
     {
       if(_gmshClient) _gmshClient->ParseString(msg.c_str());
     }
-    void runNonBlockingSubClient(const std::string &name, const std::string &command)
+    void runNonBlockingSubClient(const std::string &name,
+                                 const std::string &command)
     {
 #if !defined(BUILD_IOS)
-      if(!_gmshClient){
+      if(!_gmshClient) {
         int res = system(command.c_str());
-        if(res){
+        if(res) {
           // report error
         }
         return;
@@ -1589,6 +1682,6 @@ namespace onelab{
     }
   };
 
-}
+} // namespace onelab
 
 #endif
diff --git a/Common/onelabUtils.cpp b/Common/onelabUtils.cpp
index 0e478b819b89e8f82635c8301405c3f6a0460360..39b12ce449bd9014bcf44b6461ce029313fd5e7f 100644
--- a/Common/onelabUtils.cpp
+++ b/Common/onelabUtils.cpp
@@ -40,7 +40,7 @@ namespace onelabUtils {
     std::string name(c->getName());
     std::vector<onelab::number> n;
     c->get(n, name + "/Use command line");
-    if(n.size() && n[0].getValue()){
+    if(n.size() && n[0].getValue()) {
       std::vector<onelab::string> ps;
       c->get(ps, name + "/Action");
       std::string action = (ps.empty() ? "" : ps[0].getValue());
@@ -52,20 +52,22 @@ namespace onelabUtils {
       std::string computeCommand = (ps.empty() ? "" : ps[0].getValue());
       if(modelName.size()) args.push_back(" \"" + modelName + "\"");
       if(action == "check")
-        args.push_back(" " + checkCommand) ;
+        args.push_back(" " + checkCommand);
       else if(action == "compute")
         args.push_back(" " + computeCommand);
       // Propagate -setnumber/-setnumber gmsh option to the client. (Is this a
       // good idea?)
       std::ostringstream sstream;
       sstream.precision(16);
-      std::map<std::string, std::vector<double> > cln(Msg::GetCommandLineNumbers());
-      for(std::map<std::string, std::vector<double> >::iterator it = cln.begin();
-          it != cln.end(); it++){
-        if(it->second.size() == 1){
+      std::map<std::string, std::vector<double> > cln(
+        Msg::GetCommandLineNumbers());
+      for(std::map<std::string, std::vector<double> >::iterator it =
+            cln.begin();
+          it != cln.end(); it++) {
+        if(it->second.size() == 1) {
           sstream << " -setnumber " << it->first << " " << it->second[0];
         }
-        else{
+        else {
           sstream << " -setlistofnumbers " << it->first;
           for(unsigned int i = 0; i < it->second.size(); i++)
             sstream << " " << it->second[i];
@@ -85,12 +87,12 @@ namespace onelabUtils {
     std::string name;
     std::vector<onelab::string> ps;
     c->get(ps, "Gmsh/MshFileName");
-    if(ps.size()){
+    if(ps.size()) {
       name = ps[0].getValue();
     }
-    else{
+    else {
       name = CTX::instance()->outputFileName;
-      if(name.empty()){
+      if(name.empty()) {
         if(CTX::instance()->mesh.fileFormat == FORMAT_AUTO)
           name = GetDefaultFileName(FORMAT_MSH);
         else
@@ -117,10 +119,10 @@ namespace onelabUtils {
     std::string geo = GModel::current()->getFileName();
     std::vector<onelab::number> n;
     c->get(n, c->getName() + "/Guess model name");
-    if(n.size() && n[0].getValue()){
+    if(n.size() && n[0].getValue()) {
       std::vector<onelab::string> ps;
       c->get(ps, c->getName() + "/Model name");
-      if(ps.empty()){
+      if(ps.empty()) {
         std::vector<std::string> split = SplitFileName(geo);
         std::string ext = "";
         onelab::server::instance()->get(ps, c->getName() + "/File extension");
@@ -132,7 +134,7 @@ namespace onelabUtils {
         c->set(o);
         geo += std::string(" - ") + name;
       }
-      else{
+      else {
         geo += std::string(" - ") + ps[0].getValue();
       }
     }
@@ -144,30 +146,29 @@ namespace onelabUtils {
     bool changed = false;
     std::vector<onelab::number> numbers;
     onelab::server::instance()->get(numbers);
-    for(unsigned int i = 0; i < numbers.size(); i++){
-
-      if(numbers[i].getAttribute("Loop") == level){
-        if(numbers[i].getChoices().size() > 1){
-	  numbers[i].setIndex(0);
+    for(unsigned int i = 0; i < numbers.size(); i++) {
+      if(numbers[i].getAttribute("Loop") == level) {
+        if(numbers[i].getChoices().size() > 1) {
+          numbers[i].setIndex(0);
           numbers[i].setValue(numbers[i].getChoices()[0]);
           onelab::server::instance()->set(numbers[i]);
           changed = true;
         }
-        else if(numbers[i].getStep() > 0){
-          if(numbers[i].getMin() != -onelab::parameter::maxNumber()){
+        else if(numbers[i].getStep() > 0) {
+          if(numbers[i].getMin() != -onelab::parameter::maxNumber()) {
             numbers[i].setValue(numbers[i].getMin());
-	    numbers[i].setIndex(0); // indicates we are in a loop
-	    std::vector<double> choices;
-	    numbers[0].setChoices(choices);
+            numbers[i].setIndex(0); // indicates we are in a loop
+            std::vector<double> choices;
+            numbers[0].setChoices(choices);
             onelab::server::instance()->set(numbers[i]);
             changed = true;
           }
         }
-        else if(numbers[i].getStep() < 0){
-          if(numbers[i].getMax() != onelab::parameter::maxNumber()){
-	    numbers[i].setIndex(0); // indicates we are in a loop
-	    std::vector<double> choices;
-	    numbers[0].setChoices(choices);
+        else if(numbers[i].getStep() < 0) {
+          if(numbers[i].getMax() != onelab::parameter::maxNumber()) {
+            numbers[i].setIndex(0); // indicates we are in a loop
+            std::vector<double> choices;
+            numbers[0].setChoices(choices);
             numbers[i].setValue(numbers[i].getMax());
             onelab::server::instance()->set(numbers[i]);
             changed = true;
@@ -187,50 +188,50 @@ namespace onelabUtils {
     bool recompute = false, loop = false;
     std::vector<onelab::number> numbers;
     onelab::server::instance()->get(numbers);
-    for(unsigned int i = 0; i < numbers.size(); i++){
-      if(numbers[i].getAttribute("Loop") == level){
+    for(unsigned int i = 0; i < numbers.size(); i++) {
+      if(numbers[i].getAttribute("Loop") == level) {
         loop = true;
 
-        if(numbers[i].getChoices().size() > 1){
-	  int j = numbers[i].getIndex() + 1;
-	  if((j >= 0) && (j < (int) numbers[i].getChoices().size())){
-	    numbers[i].setValue(numbers[i].getChoices()[j]);
-	    numbers[i].setIndex(j);
-	    onelab::server::instance()->set(numbers[i]);
+        if(numbers[i].getChoices().size() > 1) {
+          int j = numbers[i].getIndex() + 1;
+          if((j >= 0) && (j < (int)numbers[i].getChoices().size())) {
+            numbers[i].setValue(numbers[i].getChoices()[j]);
+            numbers[i].setIndex(j);
+            onelab::server::instance()->set(numbers[i]);
             Msg::Info("Recomputing with %dth choice %s=%g", j,
-		      numbers[i].getName().c_str(), numbers[i].getValue());
-	    recompute = true;
-	  }
-	}
-        else if(numbers[i].getStep() > 0){
-	  int j = numbers[i].getIndex() + 1;
-	  double val = numbers[i].getValue() + numbers[i].getStep();
+                      numbers[i].getName().c_str(), numbers[i].getValue());
+            recompute = true;
+          }
+        }
+        else if(numbers[i].getStep() > 0) {
+          int j = numbers[i].getIndex() + 1;
+          double val = numbers[i].getValue() + numbers[i].getStep();
           if(numbers[i].getMax() != onelab::parameter::maxNumber() &&
-             val <= numbers[i].getMax() * (1 + eps)){
+             val <= numbers[i].getMax() * (1 + eps)) {
             numbers[i].setValue(val);
-	    numbers[i].setIndex(j);
+            numbers[i].setIndex(j);
             onelab::server::instance()->set(numbers[i]);
             Msg::Info("Recomputing with new step %s=%g",
                       numbers[i].getName().c_str(), numbers[i].getValue());
             recompute = true;
           }
-	  else
-	    numbers[i].setIndex(numbers[i].getMax());// FIXME makes sense?
+          else
+            numbers[i].setIndex(numbers[i].getMax()); // FIXME makes sense?
         }
-        else if(numbers[i].getStep() < 0){
-	  int j = numbers[i].getIndex() + 1;
-	  double val = numbers[i].getValue() + numbers[i].getStep();
+        else if(numbers[i].getStep() < 0) {
+          int j = numbers[i].getIndex() + 1;
+          double val = numbers[i].getValue() + numbers[i].getStep();
           if(numbers[i].getMin() != -onelab::parameter::maxNumber() &&
-             val >= numbers[i].getMin() * (1 - eps)){
+             val >= numbers[i].getMin() * (1 - eps)) {
             numbers[i].setValue(val);
-	    numbers[i].setIndex(j);
+            numbers[i].setIndex(j);
             onelab::server::instance()->set(numbers[i]);
             Msg::Info("Recomputing with new step %s=%g",
                       numbers[i].getName().c_str(), numbers[i].getValue());
             recompute = true;
           }
-	  else
-	    numbers[i].setIndex(numbers[i].getMin()); // FIXME makes sense?
+          else
+            numbers[i].setIndex(numbers[i].getMin()); // FIXME makes sense?
         }
       }
     }
@@ -245,17 +246,19 @@ namespace onelabUtils {
   {
     const double eps = 1.e-15; // for roundoff
     std::vector<double> v;
-    if(p.getChoices().size()){
+    if(p.getChoices().size()) {
       v = p.getChoices();
     }
     else if(p.getMin() != -onelab::parameter::maxNumber() &&
-            p.getMax() != onelab::parameter::maxNumber()){
-      if(p.getStep() > 0){
-        for(double d = p.getMin(); d <= p.getMax() * (1 + eps); d += p.getStep())
+            p.getMax() != onelab::parameter::maxNumber()) {
+      if(p.getStep() > 0) {
+        for(double d = p.getMin(); d <= p.getMax() * (1 + eps);
+            d += p.getStep())
           v.push_back(d);
       }
-      else if(p.getStep() < 0){
-        for(double d = p.getMin(); d <= p.getMax() * (1 + eps); d -= p.getStep())
+      else if(p.getStep() < 0) {
+        for(double d = p.getMin(); d <= p.getMax() * (1 + eps);
+            d -= p.getStep())
           v.push_back(d);
       }
     }
@@ -268,8 +271,8 @@ namespace onelabUtils {
 #if defined(HAVE_POST)
     PView *view = 0;
 
-    for(unsigned int i = 0; i < PView::list.size(); i++){
-      if(PView::list[i]->getData()->getFileName() == "ONELAB" + graphNum){
+    for(unsigned int i = 0; i < PView::list.size(); i++) {
+      if(PView::list[i]->getData()->getFileName() == "ONELAB" + graphNum) {
         view = PView::list[i];
         break;
       }
@@ -281,36 +284,36 @@ namespace onelabUtils {
     int graphType = 3;
     std::vector<onelab::number> numbers;
     onelab::server::instance()->get(numbers);
-    for(unsigned int i = 0; i < numbers.size(); i++){
+    for(unsigned int i = 0; i < numbers.size(); i++) {
       std::string v = numbers[i].getAttribute("Graph");
       v.resize(36, '0');
-      if(v[2 * num] != '0'){
+      if(v[2 * num] != '0') {
         x = getRange(numbers[i]);
         xName = numbers[i].getShortName();
       }
-      if(v[2 * num + 1] != '0'){
+      if(v[2 * num + 1] != '0') {
         y = getRange(numbers[i]);
         yName = numbers[i].getShortName();
         char t = v[2 * num + 1];
-        graphType = (t == '1') ? 1 : (t == '2') ? 2 : (t == '3') ? 3 :
-          (t == '4') ? 4 : 3;
+        graphType =
+          (t == '1') ? 1 : (t == '2') ? 2 : (t == '3') ? 3 : (t == '4') ? 4 : 3;
       }
     }
-    if(x.empty()){
+    if(x.empty()) {
       xName.clear();
       for(unsigned int i = 0; i < y.size(); i++) x.push_back(i);
     }
-    if(x.size() && y.size()){
+    if(x.size() && y.size()) {
       if(x.size() != y.size())
         Msg::Info("X-Y data series have different length (%d != %d)",
                   (int)x.size(), (int)y.size());
-      if(view){
+      if(view) {
         view->getData()->setXY(x, y);
         view->getData()->setName(yName);
         view->getOptions()->axesLabel[0] = xName;
         view->setChanged(true);
       }
-      else{
+      else {
         view = new PView(xName, yName, x, y);
         view->getData()->setFileName("ONELAB" + graphNum);
         view->getOptions()->intervalsType = graphType;
@@ -318,7 +321,7 @@ namespace onelabUtils {
       }
       changed = true;
     }
-    else if(view){
+    else if(view) {
       delete view;
       changed = true;
     }
@@ -327,8 +330,8 @@ namespace onelabUtils {
   }
 
   static bool _firstComputation = true;
-  void setFirstComputationFlag(bool val){ _firstComputation = val; }
-  bool getFirstComputationFlag(){ return _firstComputation; }
+  void setFirstComputationFlag(bool val) { _firstComputation = val; }
+  bool getFirstComputationFlag() { return _firstComputation; }
   bool runGmshClient(const std::string &action, int meshAuto)
   {
     bool redraw = false;
@@ -350,59 +353,60 @@ namespace onelabUtils {
     //    = 2: mesh and save mesh (e.g. if char length changed)
     //    > 2: reload geometry, mesh and save mesh (other things have changed)
 
-    if(meshAuto < 0){ // the geometry creates the mesh
+    if(meshAuto < 0) { // the geometry creates the mesh
       meshAuto = 0;
       if(changed) changed = 3;
     }
 
     Msg::SetOnelabAction(action);
 
-    if(action == "initialize"){
+    if(action == "initialize") {
       // nothing to do
     }
-    else if(action == "reset"){
+    else if(action == "reset") {
       setFirstComputationFlag(false);
       // nothing more to do: "check" will be called right afterwards
     }
-    else if(action == "check_always"){
+    else if(action == "check_always") {
       redraw = true;
       OpenProject(GModel::current()->getFileName());
       onelab::server::instance()->thresholdChanged(2, "Gmsh");
     }
-    else if(action == "check"){
-      if(changed > 2){
+    else if(action == "check") {
+      if(changed > 2) {
         redraw = true;
         OpenProject(GModel::current()->getFileName());
         onelab::server::instance()->thresholdChanged(2, "Gmsh");
       }
     }
-    else if(action == "compute"){
-      if(changed){
+    else if(action == "compute") {
+      if(changed) {
         redraw = true;
-        if(changed > 2){
+        if(changed > 2) {
           OpenProject(GModel::current()->getFileName());
         }
-        if(getFirstComputationFlag() && !StatFile(mshFileName) && meshAuto != 2){
+        if(getFirstComputationFlag() && !StatFile(mshFileName) &&
+           meshAuto != 2) {
           Msg::Info("Skipping mesh generation: assuming '%s' is up-to-date "
                     "(use Solver.AutoMesh=2 to force mesh generation)",
                     mshFileName.c_str());
         }
-        else if(!GModel::current()->empty() && meshAuto){
+        else if(!GModel::current()->empty() && meshAuto) {
           if(changed > 1 || StatFile(mshFileName) ||
-             (!StatFile(mshFileName) &&
-              GModel::current()->getMeshStatus() < GModel::current()->getDim())){
+             (!StatFile(mshFileName) && GModel::current()->getMeshStatus() <
+                                          GModel::current()->getDim())) {
             GModel::current()->deleteMesh();
             GModel::current()->mesh(3);
           }
           CreateOutputFile(mshFileName, CTX::instance()->mesh.fileFormat);
         }
       }
-      else if(StatFile(mshFileName)){
+      else if(StatFile(mshFileName)) {
         // mesh+save if the mesh file does not exist
-        if(meshAuto){
+        if(meshAuto) {
           redraw = true;
           if(changed > 1 ||
-             GModel::current()->getMeshStatus() < GModel::current()->getDim()){
+             GModel::current()->getMeshStatus() < GModel::current()->getDim()) {
             GModel::current()->deleteMesh();
             GModel::current()->mesh(3);
           }
@@ -420,41 +424,41 @@ namespace onelabUtils {
 
   void runClient(const std::string &name, const std::string &command)
   {
-    if(name.size()){
+    if(name.size()) {
       // try to run as a subclient of Gmsh; or if not as a new client
       onelab::remoteNetworkClient *c =
-        dynamic_cast<onelab::remoteNetworkClient*>(Msg::GetOnelabClient());
-      if(c){
+        dynamic_cast<onelab::remoteNetworkClient *>(Msg::GetOnelabClient());
+      if(c) {
         c->runSubClient(name, command);
       }
-      else{
+      else {
         gmshLocalNetworkClient client(name, command, "", true);
         client.run();
       }
     }
-    else{
+    else {
       // try to run a client that might have been selected previously, e.g. by
       // opening a file with known client extension (like ".pro")
       int num = CTX::instance()->launchSolverAtStartup;
       std::string name, exe, host;
-      if(num == -1){
+      if(num == -1) {
         // no client to run
         return;
       }
-      else if(num == -2){
+      else if(num == -2) {
         // just run local Gmsh client
       }
-      else if(num >= 0){
+      else if(num >= 0) {
         // run local Gmsh client + solver num
         name = opt_solver_name(num, GMSH_GET, "");
         exe = opt_solver_executable(num, GMSH_GET, "");
         host = opt_solver_remote_login(num, GMSH_GET, "");
-        if(exe.empty()){
+        if(exe.empty()) {
           Msg::Error("Solver executable name not provided");
           return;
         }
       }
-      else{
+      else {
         Msg::Error("Unknown client to run in batch mode (%d)", num);
         return;
       }
@@ -466,30 +470,32 @@ namespace onelabUtils {
       // create client
       onelab::localNetworkClient *c = 0;
       onelab::string o;
-      if(name.size()){
+      if(name.size()) {
         c = new gmshLocalNetworkClient(name, exe, host);
         c->setIndex(num);
         o = c->getName() + "/Action";
       }
 
       // initialize
-      onelabUtils::runGmshClient("initialize", CTX::instance()->solver.autoMesh);
-      if(c){
+      onelabUtils::runGmshClient("initialize",
+                                 CTX::instance()->solver.autoMesh);
+      if(c) {
         o.setValue("initialize");
         onelab::server::instance()->set(o);
         c->run();
       }
 
       // load db
-      if(CTX::instance()->solver.autoLoadDatabase){
-        std::vector<std::string> split = SplitFileName(GModel::current()->getFileName());
+      if(CTX::instance()->solver.autoLoadDatabase) {
+        std::vector<std::string> split =
+          SplitFileName(GModel::current()->getFileName());
         std::string db = split[0] + split[1] + ".db";
         if(!StatFile(db)) loadDb(db);
       }
 
       // check
       onelabUtils::runGmshClient("check", CTX::instance()->solver.autoMesh);
-      if(c){
+      if(c) {
         onelabUtils::guessModelName(c);
         o.setValue("check");
         onelab::server::instance()->set(o);
@@ -498,9 +504,9 @@ namespace onelabUtils {
 
       // compute
       initializeLoops();
-      do{
+      do {
         onelabUtils::runGmshClient("compute", CTX::instance()->solver.autoMesh);
-        if(c){
+        if(c) {
           onelabUtils::guessModelName(c);
           o.setValue("compute");
           onelab::server::instance()->set(o);
@@ -510,10 +516,12 @@ namespace onelabUtils {
       } while(incrementLoops());
 
       if(CTX::instance()->solver.autoSaveDatabase ||
-         CTX::instance()->solver.autoArchiveOutputFiles){
-        std::vector<std::string> split = SplitFileName(GModel::current()->getFileName());
+         CTX::instance()->solver.autoArchiveOutputFiles) {
+        std::vector<std::string> split =
+          SplitFileName(GModel::current()->getFileName());
         std::string db = split[0] + split[1] + ".db";
-        if(CTX::instance()->solver.autoArchiveOutputFiles) archiveOutputFiles(db);
+        if(CTX::instance()->solver.autoArchiveOutputFiles)
+          archiveOutputFiles(db);
         if(CTX::instance()->solver.autoSaveDatabase) saveDb(db);
       }
     }
@@ -521,12 +529,13 @@ namespace onelabUtils {
 
   // update x using y, giving priority to any settings in x that can be set in
   // the GUI. The value of x is only changed if y is read-only.
-  double updateNumber(onelab::number &x, onelab::number &y, const bool readOnlyRange)
+  double updateNumber(onelab::number &x, onelab::number &y,
+                      const bool readOnlyRange)
   {
     bool noRange = true, noChoices = true, noLoop = true;
     bool noGraph = true, noClosed = true;
 
-    if(y.getReadOnly()){
+    if(y.getReadOnly()) {
       x.setValue(y.getValue());
       x.setReadOnly(true);
     }
@@ -535,45 +544,45 @@ namespace onelabUtils {
     // keep track of these attributes, which can be changed server-side (unless,
     // for the range/choices, when explicitely setting these attributes as
     // ReadOnly)
-    if(!readOnlyRange){
+    if(!readOnlyRange) {
       if(x.getMin() != -onelab::parameter::maxNumber() ||
-	 x.getMax() != onelab::parameter::maxNumber() ||
-	 x.getStep() != 0.) noRange = false;
+         x.getMax() != onelab::parameter::maxNumber() || x.getStep() != 0.)
+        noRange = false;
       if(x.getChoices().size()) noChoices = false;
     }
     if(x.getAttribute("Loop").size()) noLoop = false;
     if(x.getAttribute("Graph").size()) noGraph = false;
     if(x.getAttribute("Closed").size()) noClosed = false;
 
-    if(noRange){
+    if(noRange) {
       bool noRangeEither = true;
       if(y.getMin() != -onelab::parameter::maxNumber() ||
-	 y.getMax() != onelab::parameter::maxNumber() ||
-	 y.getStep() != 0.) noRangeEither = false;
-      if(!noRangeEither){
-	x.setMin(y.getMin());
-	x.setMax(y.getMax());
+         y.getMax() != onelab::parameter::maxNumber() || y.getStep() != 0.)
+        noRangeEither = false;
+      if(!noRangeEither) {
+        x.setMin(y.getMin());
+        x.setMax(y.getMax());
       }
-      else{
-	// if no range/min/max/step info is provided, try to compute a reasonnable
-	// range and step (this makes the GUI much nicer to use)
-	bool isInteger = (floor(val) == val);
-	double fact = isInteger ? 5. : 20.;
-	if(val > 0){
-	  x.setMin(val / fact);
-	  x.setMax(val * fact);
-	  x.setStep((x.getMax() - x.getMin()) / 100.);
-	}
-	else if(val < 0){
-	  x.setMin(val * fact);
-	  x.setMax(val / fact);
-	  x.setStep((x.getMax() - x.getMin()) / 100.);
-	}
-	if(val && isInteger){
-	  x.setMin((int)x.getMin());
-	  x.setMax((int)x.getMax());
-	  x.setStep((int)x.getStep());
-	}
+      else {
+        // if no range/min/max/step info is provided, try to compute a
+        // reasonnable range and step (this makes the GUI much nicer to use)
+        bool isInteger = (floor(val) == val);
+        double fact = isInteger ? 5. : 20.;
+        if(val > 0) {
+          x.setMin(val / fact);
+          x.setMax(val * fact);
+          x.setStep((x.getMax() - x.getMin()) / 100.);
+        }
+        else if(val < 0) {
+          x.setMin(val * fact);
+          x.setMax(val / fact);
+          x.setStep((x.getMax() - x.getMin()) / 100.);
+        }
+        if(val && isInteger) {
+          x.setMin((int)x.getMin());
+          x.setMax((int)x.getMax());
+          x.setStep((int)x.getStep());
+        }
       }
     }
     if(noChoices) {
@@ -582,20 +591,19 @@ namespace onelabUtils {
     }
     if(noLoop) x.setAttribute("Loop", y.getAttribute("Loop"));
     if(noGraph) x.setAttribute("Graph", y.getAttribute("Graph"));
-    if(noClosed) x.setAttribute("Closed",  y.getAttribute("Closed"));
+    if(noClosed) x.setAttribute("Closed", y.getAttribute("Closed"));
     return val;
   }
 
   bool haveSolverToRun()
   {
     for(onelab::server::citer it = onelab::server::instance()->firstClient();
-	it != onelab::server::instance()->lastClient(); it++){
+        it != onelab::server::instance()->lastClient(); it++) {
       onelab::client *c = *it;
-      if(c->getName() != "Gmsh" &&
-	 c->getName() != "Listen" &&
-	 c->getName() != "GmshRemote" &&
+      if(c->getName() != "Gmsh" && c->getName() != "Listen" &&
+         c->getName() != "GmshRemote" &&
          c->getName().find("NoAutoRun") == std::string::npos)
-	return true;
+        return true;
     }
     return false;
   }
@@ -606,7 +614,7 @@ namespace onelabUtils {
   {
     bool noChoices = true, noClosed = true, noMultipleSelection = true;
 
-    if(y.getReadOnly()){
+    if(y.getReadOnly()) {
       x.setValue(y.getValue());
       x.setReadOnly(true);
     }
@@ -617,7 +625,7 @@ namespace onelabUtils {
     if(x.getAttribute("Closed").size()) noClosed = false;
     if(x.getAttribute("MultipleSelection").size()) noMultipleSelection = false;
 
-    //if(copt.count("Kind")) ps[0].setKind(copt["Kind"][0]);
+    // if(copt.count("Kind")) ps[0].setKind(copt["Kind"][0]);
     if(noChoices) x.setChoices(y.getChoices());
     if(noClosed) x.setAttribute("Closed", y.getAttribute("Closed"));
     if(noMultipleSelection)
@@ -641,12 +649,15 @@ namespace onelabUtils {
   bool incrementLoops()
   {
     bool ret = false;
-    if(onelabUtils::incrementLoop("3"))      ret = true;
-    else if(onelabUtils::incrementLoop("2")) ret = true;
-    else if(onelabUtils::incrementLoop("1")) ret = true;
-
-    //Define ONELAB parameter indicating whether or not in a loop
-    onelab::number n("0Metamodel/Loop",ret?1:0);
+    if(onelabUtils::incrementLoop("3"))
+      ret = true;
+    else if(onelabUtils::incrementLoop("2"))
+      ret = true;
+    else if(onelabUtils::incrementLoop("1"))
+      ret = true;
+
+    // Define ONELAB parameter indicating whether or not in a loop
+    onelab::number n("0Metamodel/Loop", ret ? 1 : 0);
     n.setVisible(false);
     onelab::server::instance()->set(n);
 
@@ -660,14 +671,14 @@ namespace onelabUtils {
   void updateGraphs()
   {
     bool redraw = false;
-    for(int i = 0; i < 18; i++){
+    for(int i = 0; i < 18; i++) {
       std::ostringstream tmp;
       tmp << i;
       bool ret = onelabUtils::updateGraph(tmp.str());
       redraw = redraw || ret;
     }
-    if(redraw){
-      // don't delete the widgets, as this is called in widget callbacks
+    if(redraw) {
+    // don't delete the widgets, as this is called in widget callbacks
 #if defined(HAVE_FLTK)
       FlGui::instance()->updateViews(true, false);
       drawContext::global()->draw();
@@ -690,7 +701,7 @@ namespace onelabUtils {
   void saveDb(const std::string &fileName)
   {
     FILE *fp = Fopen(fileName.c_str(), "wb");
-    if(fp){
+    if(fp) {
       Msg::StatusBar(true, "Saving database '%s'...", fileName.c_str());
       onelab::server::instance()->toFile(fp);
       fclose(fp);
@@ -714,7 +725,7 @@ namespace onelabUtils {
   {
     std::string stamp;
     std::vector<onelab::string> ps;
-    onelab::server::instance()->get(ps,"0Metamodel/9Tag");
+    onelab::server::instance()->get(ps, "0Metamodel/9Tag");
     if(ps.size() && ps[0].getValue().size())
       stamp.assign(timeStamp() + "_" + ps[0].getValue());
     else
@@ -723,16 +734,16 @@ namespace onelabUtils {
     // add time stamp in all output files in the db, and rename them on disk
     std::vector<onelab::string> strings;
     onelab::server::instance()->get(strings);
-    for(unsigned int i = 0; i < strings.size(); i++){
-      if(strings[i].getName().find("9Output files") != std::string::npos){
+    for(unsigned int i = 0; i < strings.size(); i++) {
+      if(strings[i].getName().find("9Output files") != std::string::npos) {
         std::vector<std::string> names = strings[i].getChoices();
         names.push_back(strings[i].getValue());
-        for(unsigned int j = 0; j < names.size(); j++){
+        for(unsigned int j = 0; j < names.size(); j++) {
           std::vector<std::string> split = SplitFileName(names[j]);
           int n = split[1].size();
           // if name is not already stamped
-          if(n < 18 || split[1][n-3] != '-' || split[1][n-6] != '-' ||
-             split[1][n-9] != '_'){
+          if(n < 18 || split[1][n - 3] != '-' || split[1][n - 6] != '-' ||
+             split[1][n - 9] != '_') {
             std::string old = names[j];
             CreateSingleDir(split[0] + "archive/");
             names[j] = split[0] + "archive/" + split[1] + stamp + split[2];
@@ -765,16 +776,16 @@ namespace onelabUtils {
     std::vector<std::string> split = SplitFileName(fileName);
     std::string dir = split[0] + "archive/";
     std::string tag = split[1];
-    if (!tag.compare(0,6,"onelab"))
+    if(!tag.compare(0, 6, "onelab"))
       tag.assign(tag.substr(6)); // cut off 'onelab' if present
 
     // add tag to all solution files in the db, and rename them on disk
     std::vector<onelab::string> strings;
-    onelab::server::instance()->get(strings,"0Metamodel/9Solution files");
-    if(strings.size()){
+    onelab::server::instance()->get(strings, "0Metamodel/9Solution files");
+    if(strings.size()) {
       std::vector<std::string> names = strings[0].getChoices();
-      if(names.size()){
-        for(unsigned int j = 0; j < names.size(); j++){
+      if(names.size()) {
+        for(unsigned int j = 0; j < names.size(); j++) {
           std::vector<std::string> split = SplitFileName(names[j]);
           std::string old = names[j];
           CreateSingleDir(dir);
@@ -796,7 +807,7 @@ namespace onelabUtils {
   {
     Msg::StatusBar(true, "Loading database '%s'...", name.c_str());
     FILE *fp = Fopen(name.c_str(), "rb");
-    if(fp){
+    if(fp) {
       onelab::server::instance()->fromFile(fp);
       fclose(fp);
       Msg::StatusBar(true, "Done loading database '%s'", name.c_str());
@@ -814,11 +825,11 @@ namespace onelabUtils {
     std::vector<onelab::string> allStrings, persistentStrings;
     onelab::server::instance()->get(allNumbers);
     onelab::server::instance()->get(allStrings);
-    for(unsigned int i = 0; i < allNumbers.size(); i++){
+    for(unsigned int i = 0; i < allNumbers.size(); i++) {
       if(allNumbers[i].getAttribute("Persistent") == "1")
         persistentNumbers.push_back(allNumbers[i]);
     }
-    for(unsigned int i = 0; i < allStrings.size(); i++){
+    for(unsigned int i = 0; i < allStrings.size(); i++) {
       if(allStrings[i].getAttribute("Persistent") == "1")
         persistentStrings.push_back(allStrings[i]);
     }
@@ -828,15 +839,15 @@ namespace onelabUtils {
 
     // run Gmsh client for non-python metamodels
     if(runGmshClient && onelab::server::instance()->findClient("Gmsh") !=
-       onelab::server::instance()->lastClient())
+                          onelab::server::instance()->lastClient())
       onelabUtils::runGmshClient("reset", CTX::instance()->solver.autoMesh);
 
-    for(unsigned int i = 0; i < persistentNumbers.size(); i++){
+    for(unsigned int i = 0; i < persistentNumbers.size(); i++) {
       Msg::Debug("Restoring persistent parameter %s",
                  persistentNumbers[i].getName().c_str());
       onelab::server::instance()->set(persistentNumbers[i]);
     }
-    for(unsigned int i = 0; i < persistentStrings.size(); i++){
+    for(unsigned int i = 0; i < persistentStrings.size(); i++) {
       Msg::Debug("Restoring persistent parameter %s",
                  persistentStrings[i].getName().c_str());
       onelab::server::instance()->set(persistentStrings[i]);
@@ -846,6 +857,6 @@ namespace onelabUtils {
     onelab::server::instance()->setChanged(3);
   }
 
-}
+} // namespace onelabUtils
 
 #endif
diff --git a/Common/onelabUtils.h b/Common/onelabUtils.h
index 4d0b7be09582a6969dc162b0328ce7d33b74674e..86026414099fe5f942dc268ff5d0c76cc8889602 100644
--- a/Common/onelabUtils.h
+++ b/Common/onelabUtils.h
@@ -24,7 +24,8 @@ namespace onelabUtils {
   bool getFirstComputationFlag();
   void setFirstComputationFlag(bool val);
   bool haveSolverToRun();
-  double updateNumber(onelab::number &x, onelab::number &y, const bool readOnlyRange=false);
+  double updateNumber(onelab::number &x, onelab::number &y,
+                      const bool readOnlyRange = false);
   std::string updateString(onelab::string &x, onelab::string &y);
   void initializeLoops();
   bool incrementLoops();
@@ -35,6 +36,6 @@ namespace onelabUtils {
   void archiveSolutionFiles(const std::string &fileName);
   void loadDb(const std::string &name);
   void resetDb(bool runGmshClient);
-}
+} // namespace onelabUtils
 
 #endif
diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp
index de244d6cb61b0c82e605bc2306aea24608821e42..9bfd50db4b552561d83b53acd6bc70c406823b6e 100644
--- a/Geo/GEdge.cpp
+++ b/Geo/GEdge.cpp
@@ -21,8 +21,8 @@
 #endif
 
 GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1)
-  : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(0),
-    v0(_v0), v1(_v1), masterOrientation(0), compound_edge(NULL)
+  : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(0), v0(_v0),
+    v1(_v1), masterOrientation(0), compound_edge(NULL)
 {
   if(v0) v0->addEdge(this);
   if(v1 && v1 != v0) v1->addEdge(this);
@@ -31,8 +31,8 @@ GEdge::GEdge(GModel *model, int tag, GVertex *_v0, GVertex *_v1)
 }
 
 GEdge::GEdge(GModel *model, int tag)
-: GEntity(model, tag), _length(0.), _tooSmall(false), _cp(0),
-v0(0), v1(0), masterOrientation(0), compound_edge(NULL)
+  : GEntity(model, tag), _length(0.), _tooSmall(false), _cp(0), v0(0), v1(0),
+    masterOrientation(0), compound_edge(NULL)
 {
   meshStatistics.status = GEdge::PENDING;
   resetMeshAttributes();
@@ -48,8 +48,9 @@ GEdge::~GEdge()
 
 void GEdge::deleteMesh(bool onlyDeleteElements)
 {
-  if(!onlyDeleteElements){
-    for(unsigned int i = 0; i < mesh_vertices.size(); i++) delete mesh_vertices[i];
+  if(!onlyDeleteElements) {
+    for(unsigned int i = 0; i < mesh_vertices.size(); i++)
+      delete mesh_vertices[i];
     mesh_vertices.clear();
   }
   for(unsigned int i = 0; i < lines.size(); i++) delete lines[i];
@@ -58,38 +59,38 @@ void GEdge::deleteMesh(bool onlyDeleteElements)
   model()->destroyMeshCaches();
 }
 
-void GEdge::setMeshMaster(GEdge* ge, int ori)
+void GEdge::setMeshMaster(GEdge *ge, int ori)
 {
   // FIXME: missing computation of affine transformation during setMeshMaster
 
   GEntity::setMeshMaster(ge);
   masterOrientation = ori > 0 ? 1 : -1;
 
-  if (ori < 0) {
+  if(ori < 0) {
     vertexCounterparts[getBeginVertex()] = ge->getEndVertex();
     vertexCounterparts[getEndVertex()] = ge->getBeginVertex();
     getBeginVertex()->setMeshMaster(ge->getEndVertex());
-    getEndVertex()  ->setMeshMaster(ge->getBeginVertex());
+    getEndVertex()->setMeshMaster(ge->getBeginVertex());
   }
   else {
     vertexCounterparts[getBeginVertex()] = ge->getBeginVertex();
     vertexCounterparts[getEndVertex()] = ge->getEndVertex();
     getBeginVertex()->setMeshMaster(ge->getBeginVertex());
-    getEndVertex()  ->setMeshMaster(ge->getEndVertex());
+    getEndVertex()->setMeshMaster(ge->getEndVertex());
   }
 }
 
-void GEdge::setMeshMaster(GEdge* ge, const std::vector<double> &tfo)
+void GEdge::setMeshMaster(GEdge *ge, const std::vector<double> &tfo)
 {
   SPoint3 oriXYZ0 = ge->getBeginVertex()->xyz();
   SPoint3 oriXYZ1 = ge->getEndVertex()->xyz();
 
-  SPoint3 tfoXYZ0(0,0,0);
-  SPoint3 tfoXYZ1(0,0,0);
+  SPoint3 tfoXYZ0(0, 0, 0);
+  SPoint3 tfoXYZ1(0, 0, 0);
 
   int idx = 0;
-  for (int i=0;i<3;i++,idx++) {
-    for (int j=0;j<3;j++,idx++) {
+  for(int i = 0; i < 3; i++, idx++) {
+    for(int j = 0; j < 3; j++, idx++) {
       tfoXYZ0[i] += tfo[idx] * oriXYZ0[j];
       tfoXYZ1[i] += tfo[idx] * oriXYZ1[j];
     }
@@ -107,44 +108,43 @@ void GEdge::setMeshMaster(GEdge* ge, const std::vector<double> &tfo)
 
   double tol = CTX::instance()->geom.tolerance * CTX::instance()->lc;
 
-  bool fwd = (d00.norm()*d11.norm() < d01.norm()*d10.norm());
+  bool fwd = (d00.norm() * d11.norm() < d01.norm() * d10.norm());
 
-  if ((d00.norm() < tol) && (d11.norm() < tol)) {
-    GEntity::setMeshMaster(ge,tfo);
+  if((d00.norm() < tol) && (d11.norm() < tol)) {
+    GEntity::setMeshMaster(ge, tfo);
     masterOrientation = 1;
     vertexCounterparts[getBeginVertex()] = ge->getBeginVertex();
-    vertexCounterparts[getEndVertex()]   = ge->getEndVertex();
-    getBeginVertex()->setMeshMaster(ge->getBeginVertex(),tfo);
-    getEndVertex()  ->setMeshMaster(ge->getEndVertex()  ,tfo);
+    vertexCounterparts[getEndVertex()] = ge->getEndVertex();
+    getBeginVertex()->setMeshMaster(ge->getBeginVertex(), tfo);
+    getEndVertex()->setMeshMaster(ge->getEndVertex(), tfo);
     return;
   }
 
-  if ((d01.norm() < tol) && (d10.norm() < tol)) {
-    GEntity::setMeshMaster(ge,tfo);
+  if((d01.norm() < tol) && (d10.norm() < tol)) {
+    GEntity::setMeshMaster(ge, tfo);
     masterOrientation = -1;
     vertexCounterparts[getBeginVertex()] = ge->getEndVertex();
     vertexCounterparts[getEndVertex()] = ge->getBeginVertex();
-    getBeginVertex()->setMeshMaster(ge->getEndVertex()  ,tfo);
-    getEndVertex()  ->setMeshMaster(ge->getBeginVertex(),tfo);
+    getBeginVertex()->setMeshMaster(ge->getEndVertex(), tfo);
+    getEndVertex()->setMeshMaster(ge->getBeginVertex(), tfo);
     return;
   }
 
   Msg::Info("Error in transformation from edge %d (%d-%d) to %d (%d-%d)"
             "(minimal transformed node distances %g %g, tolerance %g)",
-            ge->tag(),ge->getBeginVertex()->tag(),ge->getEndVertex()->tag(),
-            this->tag(),
-            this->getBeginVertex()->tag(),
-            this->getEndVertex()->tag(),
-            fwd ? d00.norm() : d01.norm(),
+            ge->tag(), ge->getBeginVertex()->tag(), ge->getEndVertex()->tag(),
+            this->tag(), this->getBeginVertex()->tag(),
+            this->getEndVertex()->tag(), fwd ? d00.norm() : d01.norm(),
             fwd ? d11.norm() : d10.norm(), tol);
 }
 
 void GEdge::reverse()
 {
-  GVertex* tmp = v0;
+  GVertex *tmp = v0;
   v0 = v1;
   v1 = tmp;
-  for(std::vector<MLine*>::iterator line = lines.begin(); line != lines.end(); line++)
+  for(std::vector<MLine *>::iterator line = lines.begin(); line != lines.end();
+      line++)
     (*line)->reverse();
 }
 
@@ -155,11 +155,12 @@ unsigned int GEdge::getNumMeshElementsByType(const int familyType) const
   return 0;
 }
 
-struct owns_parent
-{
+struct owns_parent {
   // TODO C++11 use lambda instead
-  template <class T>
-  bool operator()(T const* const line) const {return line->ownsParent();}
+  template <class T> bool operator()(T const *const line) const
+  {
+    return line->ownsParent();
+  }
 };
 
 unsigned int GEdge::getNumMeshParentElements()
@@ -180,12 +181,12 @@ MElement *const *GEdge::getStartElementType(int type) const
 
 MElement *GEdge::getMeshElement(unsigned int index) const
 {
-  if(index < lines.size())
-    return lines[index];
+  if(index < lines.size()) return lines[index];
   return 0;
 }
 
-MElement *GEdge::getMeshElementByType(const int familyType, const unsigned int index) const
+MElement *GEdge::getMeshElementByType(const int familyType,
+                                      const unsigned int index) const
 {
   if(familyType == TYPE_LIN) return lines[index];
 
@@ -212,7 +213,8 @@ void GEdge::addFace(GFace *f)
 
 void GEdge::delFace(GFace *f)
 {
-  std::vector<GFace*>::iterator it = std::find(l_faces.begin(), l_faces.end(), f);
+  std::vector<GFace *>::iterator it =
+    std::find(l_faces.begin(), l_faces.end(), f);
   if(it != l_faces.end()) l_faces.erase(it);
 }
 
@@ -220,11 +222,12 @@ SBoundingBox3d GEdge::bounds(bool fast) const
 {
   SBoundingBox3d bbox;
   if(geomType() != DiscreteCurve && geomType() != BoundaryLayerCurve &&
-     geomType() != PartitionCurve){
+     geomType() != PartitionCurve) {
     Range<double> tr = parBounds(0);
     const int N = 10;
-    for(int i = 0; i < N; i++){
-      double t = tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
+    for(int i = 0; i < N; i++) {
+      double t =
+        tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
       GPoint p = point(t);
       bbox += SPoint3(p.x(), p.y(), p.z());
     }
@@ -240,26 +243,29 @@ SBoundingBox3d GEdge::bounds(bool fast) const
 
 SOrientedBoundingBox GEdge::getOBB()
 {
-  if (!_obb) {
+  if(!_obb) {
     std::vector<SPoint3> vertices;
     if(getNumMeshVertices() > 0) {
       int N = getNumMeshVertices();
-      for (int i = 0; i < N; i++) {
-        MVertex* mv = getMeshVertex(i);
+      for(int i = 0; i < N; i++) {
+        MVertex *mv = getMeshVertex(i);
         vertices.push_back(mv->point());
       }
       // Don't forget to add the first and last vertices...
-      SPoint3 pt1(getBeginVertex()->x(), getBeginVertex()->y(), getBeginVertex()->z());
-      SPoint3 pt2(getEndVertex()->x(), getEndVertex()->y(), getEndVertex()->z());
+      SPoint3 pt1(getBeginVertex()->x(), getBeginVertex()->y(),
+                  getBeginVertex()->z());
+      SPoint3 pt2(getEndVertex()->x(), getEndVertex()->y(),
+                  getEndVertex()->z());
       vertices.push_back(pt1);
       vertices.push_back(pt2);
     }
-    else if(geomType() != DiscreteCurve && geomType() != BoundaryLayerCurve){
+    else if(geomType() != DiscreteCurve && geomType() != BoundaryLayerCurve) {
       Range<double> tr = this->parBounds(0);
       // N can be choosen arbitrarily, but 10 points seems reasonable
       int N = 10;
-      for (int i = 0; i < N; i++) {
-        double t = tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
+      for(int i = 0; i < N; i++) {
+        double t =
+          tr.low() + (double)i / (double)(N - 1) * (tr.high() - tr.low());
         GPoint p = point(t);
         SPoint3 pt(p.x(), p.y(), p.z());
         vertices.push_back(pt);
@@ -277,7 +283,7 @@ SOrientedBoundingBox GEdge::getOBB()
 void GEdge::setVisibility(char val, bool recursive)
 {
   GEntity::setVisibility(val);
-  if(recursive){
+  if(recursive) {
     if(v0) v0->setVisibility(val);
     if(v1) v1->setVisibility(val);
   }
@@ -286,7 +292,7 @@ void GEdge::setVisibility(char val, bool recursive)
 void GEdge::setColor(unsigned int val, bool recursive)
 {
   GEntity::setColor(val);
-  if(recursive){
+  if(recursive) {
     if(v0) v0->setColor(val);
     if(v1) v1->setColor(val);
   }
@@ -297,66 +303,67 @@ std::string GEdge::getAdditionalInfoString(bool multline)
   std::ostringstream sstream;
   sstream.precision(12);
 
-  if(v0 && v1){
+  if(v0 && v1) {
     sstream << "Boundary points: " << v0->tag() << ", " << v1->tag();
-    if(multline) sstream << "\n";
-    else sstream << " ";
+    if(multline)
+      sstream << "\n";
+    else
+      sstream << " ";
   }
 
   if(meshAttributes.method == MESH_TRANSFINITE || meshAttributes.extrude ||
-     meshAttributes.reverseMesh){
+     meshAttributes.reverseMesh) {
     sstream << "Mesh attributes:";
-    if(meshAttributes.method == MESH_TRANSFINITE){
+    if(meshAttributes.method == MESH_TRANSFINITE) {
       sstream << " transfinite " << meshAttributes.nbPointsTransfinite;
       int type = meshAttributes.typeTransfinite;
       if(std::abs(type) == 1)
-        sstream << ", progression " << gmsh_sign(type) * meshAttributes.coeffTransfinite;
+        sstream << ", progression "
+                << gmsh_sign(type) * meshAttributes.coeffTransfinite;
       else if(std::abs(type) == 2)
         sstream << ", bump " << meshAttributes.coeffTransfinite;
     }
-    if(meshAttributes.extrude)
-      sstream << " extruded";
-    if(meshAttributes.reverseMesh)
-      sstream << " reversed";
+    if(meshAttributes.extrude) sstream << " extruded";
+    if(meshAttributes.reverseMesh) sstream << " reversed";
   }
   std::string str = sstream.str();
-  if(str.size() && (str[str.size()-1] == '\n' || str[str.size()-1] == ' '))
-     str.resize(str.size() - 1);
+  if(str.size() && (str[str.size() - 1] == '\n' || str[str.size() - 1] == ' '))
+    str.resize(str.size() - 1);
   return str;
 }
 
 void GEdge::writeGEO(FILE *fp)
 {
-  if(!getBeginVertex() || !getEndVertex() || geomType() == DiscreteCurve) return;
+  if(!getBeginVertex() || !getEndVertex() || geomType() == DiscreteCurve)
+    return;
 
-  if(geomType() == Line){
-    fprintf(fp, "Line(%d) = {%d, %d};\n",
-            tag(), getBeginVertex()->tag(), getEndVertex()->tag());
+  if(geomType() == Line) {
+    fprintf(fp, "Line(%d) = {%d, %d};\n", tag(), getBeginVertex()->tag(),
+            getEndVertex()->tag());
   }
-  else{
+  else {
     // approximate other curves by splines
     Range<double> bounds = parBounds(0);
     double umin = bounds.low();
     double umax = bounds.high();
     fprintf(fp, "p%d = newp;\n", tag());
     int N = minimumDrawSegments();
-    for(int i = 1; i < N; i++){
+    for(int i = 1; i < N; i++) {
       double u = umin + (double)i / N * (umax - umin);
       GPoint p = point(u);
-      fprintf(fp, "Point(p%d + %d) = {%.16g, %.16g, %.16g};\n",
-              tag(), i, p.x(), p.y(), p.z());
+      fprintf(fp, "Point(p%d + %d) = {%.16g, %.16g, %.16g};\n", tag(), i, p.x(),
+              p.y(), p.z());
     }
     fprintf(fp, "Spline(%d) = {%d", tag(), getBeginVertex()->tag());
-    for(int i = 1; i < N; i++)
-      fprintf(fp, ", p%d + %d", tag(), i);
+    for(int i = 1; i < N; i++) fprintf(fp, ", p%d + %d", tag(), i);
     fprintf(fp, ", %d};\n", getEndVertex()->tag());
   }
 
-  if(meshAttributes.method == MESH_TRANSFINITE){
+  if(meshAttributes.method == MESH_TRANSFINITE) {
     fprintf(fp, "Transfinite Line {%d} = %d",
             tag() * (meshAttributes.typeTransfinite > 0 ? 1 : -1),
             meshAttributes.nbPointsTransfinite);
-    if(meshAttributes.typeTransfinite){
+    if(meshAttributes.typeTransfinite) {
       if(std::abs(meshAttributes.typeTransfinite) == 1)
         fprintf(fp, " Using Progression ");
       else
@@ -366,8 +373,7 @@ void GEdge::writeGEO(FILE *fp)
     fprintf(fp, ";\n");
   }
 
-  if(meshAttributes.reverseMesh)
-    fprintf(fp, "Reverse Line {%d};\n", tag());
+  if(meshAttributes.reverseMesh) fprintf(fp, "Reverse Line {%d};\n", tag());
 }
 
 bool GEdge::containsParam(double pt) const
@@ -381,13 +387,13 @@ SVector3 GEdge::secondDer(double par) const
   // use central differences
   const double eps = 1.e-3;
   Range<double> rg = parBounds(0);
-  if (par-eps <= rg.low()){
+  if(par - eps <= rg.low()) {
     SVector3 x1 = firstDer(par);
     SVector3 x2 = firstDer(par + eps);
     return 1000 * (x2 - x1);
   }
-  else if (par+eps >= rg.high()){
-    SVector3 x1 = firstDer(par-eps);
+  else if(par + eps >= rg.high()) {
+    SVector3 x1 = firstDer(par - eps);
     SVector3 x2 = firstDer(par);
     return 1000 * (x2 - x1);
   }
@@ -396,7 +402,7 @@ SVector3 GEdge::secondDer(double par) const
   return 500 * (x2 - x1);
 }
 
-SPoint2 GEdge::reparamOnFace(const GFace *face, double epar,int dir) const
+SPoint2 GEdge::reparamOnFace(const GFace *face, double epar, int dir) const
 {
   // reparametrize the point onto the given face.
   const GPoint p3 = point(epar);
@@ -538,13 +544,13 @@ bool GEdge::refineProjection(const SVector3 &Q, double &u, int MaxIter,
   return err <= maxDist;
 }
 
-bool GEdge::XYZToU(const double X, const double Y, const double Z,
-                   double &u, const double relax,bool first) const
+bool GEdge::XYZToU(const double X, const double Y, const double Z, double &u,
+                   const double relax, bool first) const
 {
   const int MaxIter = 25;
   const int NumInitGuess = 21;
 
-  std::map<double,double> errorVsParameter;
+  std::map<double, double> errorVsParameter;
 
   double err;
   double tol = 1e-8;
@@ -634,7 +640,8 @@ typedef struct {
   int next;
 } sortedPoint;
 
-static double sqDistPointSegment(const SPoint3 &p, const SPoint3 &s0, const SPoint3 &s1)
+static double sqDistPointSegment(const SPoint3 &p, const SPoint3 &s0,
+                                 const SPoint3 &s1)
 {
   SVector3 d(s1 - s0);
   SVector3 d0(p - s0);
@@ -645,7 +652,8 @@ static double sqDistPointSegment(const SPoint3 &p, const SPoint3 &s0, const SPoi
   return (dt2 + dn2) / d.normSq();
 }
 
-static void _discretize(double tol, GEdge * edge, std::vector<sortedPoint> &upts, int pos0)
+static void _discretize(double tol, GEdge *edge, std::vector<sortedPoint> &upts,
+                        int pos0)
 {
   const int pos1 = upts[pos0].next;
   const SPoint3 &p0 = upts[pos0].p;
@@ -666,31 +674,26 @@ static void _discretize(double tol, GEdge * edge, std::vector<sortedPoint> &upts
 
 void GEdge::addElement(int type, MElement *e)
 {
-  switch (type){
-  case TYPE_LIN:
-    addLine(reinterpret_cast<MLine*>(e));
-    break;
-  default:
-    Msg::Error("Trying to add unsupported element in edge");
+  switch(type) {
+  case TYPE_LIN: addLine(reinterpret_cast<MLine *>(e)); break;
+  default: Msg::Error("Trying to add unsupported element in edge");
   }
 }
 
 void GEdge::removeElement(int type, MElement *e)
 {
-  switch (type){
-  case TYPE_LIN:
-    {
-      std::vector<MLine*>::iterator it = std::find
-        (lines.begin(), lines.end(), reinterpret_cast<MLine*>(e));
-      if(it != lines.end()) lines.erase(it);
-    }
-    break;
-  default:
-    Msg::Error("Trying to remove unsupported element in edge");
+  switch(type) {
+  case TYPE_LIN: {
+    std::vector<MLine *>::iterator it =
+      std::find(lines.begin(), lines.end(), reinterpret_cast<MLine *>(e));
+    if(it != lines.end()) lines.erase(it);
+  } break;
+  default: Msg::Error("Trying to remove unsupported element in edge");
   }
 }
 
-void GEdge::discretize(double tol, std::vector<SPoint3> &dpts, std::vector<double> &ts)
+void GEdge::discretize(double tol, std::vector<SPoint3> &dpts,
+                       std::vector<double> &ts)
 {
   std::vector<sortedPoint> upts;
   sortedPoint pnt1 = {getBeginVertex()->xyz(), 0., 1};
@@ -702,24 +705,25 @@ void GEdge::discretize(double tol, std::vector<SPoint3> &dpts, std::vector<doubl
   dpts.reserve(upts.size());
   ts.clear();
   ts.reserve(upts.size());
-  for (int p = 0; p != -1; p = upts[p].next) {
+  for(int p = 0; p != -1; p = upts[p].next) {
     dpts.push_back(upts[p].p);
     ts.push_back(upts[p].t);
   }
 }
 
 #if defined(HAVE_MESH)
-static void meshCompound(GEdge* ge)
-{
-  std::vector<MLine*> lines;
-  for (unsigned int i = 0; i < ge->_compound.size(); i++){
-    GEdge *c = (GEdge*)ge->_compound[i];
-    for (unsigned int j = 0; j<c->lines.size(); j++){
-      lines.push_back(new MLine(c->lines[j]->getVertex(0),
-                                c->lines[j]->getVertex(1)));
+static void meshCompound(GEdge *ge)
+{
+  std::vector<MLine *> lines;
+  for(unsigned int i = 0; i < ge->_compound.size(); i++) {
+    GEdge *c = (GEdge *)ge->_compound[i];
+    for(unsigned int j = 0; j < c->lines.size(); j++) {
+      lines.push_back(
+        new MLine(c->lines[j]->getVertex(0), c->lines[j]->getVertex(1)));
     }
   }
-  discreteEdge *de = new discreteEdge(ge->model(), ge->tag() + 100000, NULL, NULL);
+  discreteEdge *de =
+    new discreteEdge(ge->model(), ge->tag() + 100000, NULL, NULL);
   ge->model()->add(de);
   de->lines = lines;
   de->createGeometry();
@@ -740,7 +744,9 @@ void GEdge::mesh(bool verbose)
         GEdge *ge = (GEdge *)_compound[i];
         ok &= (ge->meshStatistics.status == GEdge::DONE);
       }
-      if(!ok) { meshStatistics.status = GEdge::PENDING; }
+      if(!ok) {
+        meshStatistics.status = GEdge::PENDING;
+      }
       else {
         meshCompound(this);
         meshStatistics.status = GEdge::DONE;
@@ -753,7 +759,9 @@ void GEdge::mesh(bool verbose)
 
 bool GEdge::reorder(const int elementType, const std::vector<int> &ordering)
 {
-  if(lines.front()->getTypeForMSH() != elementType) { return false; }
+  if(lines.front()->getTypeForMSH() != elementType) {
+    return false;
+  }
 
   if(ordering.size() != lines.size()) return false;
 
@@ -776,10 +784,10 @@ bool GEdge::reorder(const int elementType, const std::vector<int> &ordering)
   return true;
 }
 
-std::vector<GVertex*> GEdge::vertices() const
+std::vector<GVertex *> GEdge::vertices() const
 {
-  std::vector<GVertex*> res;
-  if (getBeginVertex()) res.push_back(getBeginVertex());
-  if (getEndVertex())   res.push_back(getEndVertex());
+  std::vector<GVertex *> res;
+  if(getBeginVertex()) res.push_back(getBeginVertex());
+  if(getEndVertex()) res.push_back(getEndVertex());
   return res;
 }
diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp
index abb01f50bafd807c241c443033b6959eb58c5d4a..4e1483b160edd24f91b5164c2284f07bf498c138 100644
--- a/Geo/GFace.cpp
+++ b/Geo/GFace.cpp
@@ -33,7 +33,7 @@
 #endif
 
 // TODO C++11 remove macro
-#define SQU(a)      ((a)*(a))
+#define SQU(a) ((a) * (a))
 
 GFace::GFace(GModel *model, int tag)
   : GEntity(model, tag), r1(0), r2(0), va_geom_triangles(0)
@@ -44,24 +44,24 @@ GFace::GFace(GModel *model, int tag)
 
 GFace::~GFace()
 {
-  std::vector<GEdge*>::iterator it = l_edges.begin();
-  while (it != l_edges.end()){
+  std::vector<GEdge *>::iterator it = l_edges.begin();
+  while(it != l_edges.end()) {
     (*it)->delFace(this);
     ++it;
   }
 
-  if(va_geom_triangles)
-    delete va_geom_triangles;
+  if(va_geom_triangles) delete va_geom_triangles;
 
   deleteMesh();
 }
 
 int GFace::getCurvatureControlParameter() const
 {
-  std::map<int,int>::iterator it =
+  std::map<int, int>::iterator it =
     CTX::instance()->mesh.curvatureControlPerFace.find(tag());
   return it == CTX::instance()->mesh.curvatureControlPerFace.end() ?
-    CTX::instance()->mesh.minCircPoints : it->second ;
+           CTX::instance()->mesh.minCircPoints :
+           it->second;
 }
 
 void GFace::setCurvatureControlParameter(int n)
@@ -71,9 +71,11 @@ void GFace::setCurvatureControlParameter(int n)
 
 int GFace::getMeshingAlgo() const
 {
-  std::map<int,int>::iterator it = CTX::instance()->mesh.algo2dPerFace.find(tag());
+  std::map<int, int>::iterator it =
+    CTX::instance()->mesh.algo2dPerFace.find(tag());
   return it == CTX::instance()->mesh.algo2dPerFace.end() ?
-    CTX::instance()->mesh.algo2d : it->second ;
+           CTX::instance()->mesh.algo2d :
+           it->second;
 }
 
 void GFace::setMeshingAlgo(int algo)
@@ -84,11 +86,12 @@ void GFace::setMeshingAlgo(int algo)
 void GFace::delFreeEdge(GEdge *edge)
 {
   // delete the edge from the edge list and the orientation list
-  std::vector<GEdge*>::iterator ite = l_edges.begin();
+  std::vector<GEdge *>::iterator ite = l_edges.begin();
   std::vector<int>::iterator itd = l_dirs.begin();
-  while(ite != l_edges.end()){
-    if(edge == *ite){
-      Msg::Debug("Erasing edge %d from edge list in face %d", edge->tag(), tag());
+  while(ite != l_edges.end()) {
+    if(edge == *ite) {
+      Msg::Debug("Erasing edge %d from edge list in face %d", edge->tag(),
+                 tag());
       l_edges.erase(ite);
       if(itd != l_dirs.end()) l_dirs.erase(itd);
       break;
@@ -99,10 +102,11 @@ void GFace::delFreeEdge(GEdge *edge)
 
   // delete the edge from the edge loops
   for(std::list<GEdgeLoop>::iterator it = edgeLoops.begin();
-      it != edgeLoops.end(); it++){
-    for(GEdgeLoop::iter it2 = it->begin(); it2 != it->end(); it2++){
-      if(edge == it2->ge){
-        Msg::Debug("Erasing edge %d from edge loop in face %d", edge->tag(), tag());
+      it != edgeLoops.end(); it++) {
+    for(GEdgeLoop::iter it2 = it->begin(); it2 != it->end(); it2++) {
+      if(edge == it2->ge) {
+        Msg::Debug("Erasing edge %d from edge loop in face %d", edge->tag(),
+                   tag());
         it->erase(it2);
         break;
       }
@@ -110,13 +114,13 @@ void GFace::delFreeEdge(GEdge *edge)
   }
 }
 
-int GFace::delEdge(GEdge* edge)
+int GFace::delEdge(GEdge *edge)
 {
   // BUG If the iterator is equal to end() then the erase will be ill-formed
   // TODO C++11 fix this UB
-  std::vector<GEdge*>::iterator it;
+  std::vector<GEdge *>::iterator it;
   int pos = 0;
-  for(it = l_edges.begin(); it != l_edges.end(); ++it){
+  for(it = l_edges.begin(); it != l_edges.end(); ++it) {
     if(*it == edge) break;
     pos++;
   }
@@ -124,8 +128,8 @@ int GFace::delEdge(GEdge* edge)
 
   std::vector<int>::iterator itOri;
   int posOri = 0, orientation = 0;
-  for(itOri = l_dirs.begin(); itOri != l_dirs.end(); ++itOri){
-    if(posOri == pos){
+  for(itOri = l_dirs.begin(); itOri != l_dirs.end(); ++itOri) {
+    if(posOri == pos) {
       orientation = *itOri;
       break;
     }
@@ -138,8 +142,9 @@ int GFace::delEdge(GEdge* edge)
 
 void GFace::deleteMesh(bool onlyDeleteElements)
 {
-  if(!onlyDeleteElements){
-    for(unsigned int i = 0; i < mesh_vertices.size(); i++) delete mesh_vertices[i];
+  if(!onlyDeleteElements) {
+    for(unsigned int i = 0; i < mesh_vertices.size(); i++)
+      delete mesh_vertices[i];
     mesh_vertices.clear();
     transfinite_vertices.clear();
   }
@@ -160,9 +165,12 @@ std::size_t GFace::getNumMeshElements() const
 
 unsigned int GFace::getNumMeshElementsByType(const int familyType) const
 {
-  if(familyType == TYPE_TRI) return triangles.size();
-  else if(familyType == TYPE_QUA) return quadrangles.size();
-  else if(familyType == TYPE_POLYG) return polygons.size();
+  if(familyType == TYPE_TRI)
+    return triangles.size();
+  else if(familyType == TYPE_QUA)
+    return quadrangles.size();
+  else if(familyType == TYPE_POLYG)
+    return polygons.size();
 
   return 0;
 }
@@ -171,8 +179,7 @@ unsigned int GFace::getNumMeshParentElements()
 {
   unsigned int n = 0;
   for(unsigned int i = 0; i < polygons.size(); i++)
-    if(polygons[i]->ownsParent())
-      n++;
+    if(polygons[i]->ownsParent()) n++;
   return n;
 }
 
@@ -210,11 +217,15 @@ MElement *GFace::getMeshElement(unsigned int index) const
   return 0;
 }
 
-MElement *GFace::getMeshElementByType(const int familyType, const unsigned int index) const
+MElement *GFace::getMeshElementByType(const int familyType,
+                                      const unsigned int index) const
 {
-  if(familyType == TYPE_TRI) return triangles[index];
-  else if(familyType == TYPE_QUA) return quadrangles[index];
-  else if(familyType == TYPE_POLYG) return polygons[index];
+  if(familyType == TYPE_TRI)
+    return triangles[index];
+  else if(familyType == TYPE_QUA)
+    return quadrangles[index];
+  else if(familyType == TYPE_POLYG)
+    return polygons[index];
 
   return 0;
 }
@@ -234,13 +245,12 @@ void GFace::resetMeshAttributes()
 SBoundingBox3d GFace::bounds(bool fast) const
 {
   SBoundingBox3d res;
-  if(geomType() != DiscreteSurface && geomType() != PartitionSurface){
+  if(geomType() != DiscreteSurface && geomType() != PartitionSurface) {
     // TODO C++11 std::accumulate
-    std::vector<GEdge*>::const_iterator it = l_edges.begin();
-    for(; it != l_edges.end(); it++)
-      res += (*it)->bounds(fast);
+    std::vector<GEdge *>::const_iterator it = l_edges.begin();
+    for(; it != l_edges.end(); it++) res += (*it)->bounds(fast);
   }
-  else{
+  else {
     int ipp = getNumMeshElements() / 20;
     if(ipp < 1) ipp = 1;
     for(unsigned int i = 0; i < getNumMeshElements(); i += ipp)
@@ -252,27 +262,26 @@ SBoundingBox3d GFace::bounds(bool fast) const
 
 SOrientedBoundingBox GFace::getOBB()
 {
-  if (!_obb) {
+  if(!_obb) {
     std::vector<SPoint3> vertices;
     if(getNumMeshVertices() > 0) {
       int N = getNumMeshVertices();
-      for (int i = 0; i < N; i++) {
-        MVertex* mv = getMeshVertex(i);
+      for(int i = 0; i < N; i++) {
+        MVertex *mv = getMeshVertex(i);
         vertices.push_back(mv->point());
       }
-      std::vector<GEdge*> const& eds = edges();
-      for(std::vector<GEdge*>::const_iterator ed = eds.begin(); ed != eds.end(); ed++) {
+      std::vector<GEdge *> const &eds = edges();
+      for(std::vector<GEdge *>::const_iterator ed = eds.begin();
+          ed != eds.end(); ed++) {
         int N2 = (*ed)->getNumMeshVertices();
-        for (int i = 0; i < N2; i++) {
-          MVertex* mv = (*ed)->getMeshVertex(i);
+        for(int i = 0; i < N2; i++) {
+          MVertex *mv = (*ed)->getMeshVertex(i);
           vertices.push_back(mv->point());
         }
         // Don't forget to add the first and last vertices...
-        SPoint3 pt1((*ed)->getBeginVertex()->x(),
-                    (*ed)->getBeginVertex()->y(),
+        SPoint3 pt1((*ed)->getBeginVertex()->x(), (*ed)->getBeginVertex()->y(),
                     (*ed)->getBeginVertex()->z());
-        SPoint3 pt2((*ed)->getEndVertex()->x(),
-                    (*ed)->getEndVertex()->y(),
+        SPoint3 pt2((*ed)->getEndVertex()->x(), (*ed)->getEndVertex()->y(),
                     (*ed)->getEndVertex()->z());
         vertices.push_back(pt1);
         vertices.push_back(pt2);
@@ -284,13 +293,14 @@ SOrientedBoundingBox GFace::getOBB()
     else {
       // Fallback, if we can't make a STL triangulation of the surface, use its
       // edges..
-      std::vector<GEdge*> const& b_edges = edges();
+      std::vector<GEdge *> const &b_edges = edges();
       int N = 10;
-      for (std::vector<GEdge*>::const_iterator b_edge = b_edges.begin();
-           b_edge != b_edges.end(); b_edge++) {
+      for(std::vector<GEdge *>::const_iterator b_edge = b_edges.begin();
+          b_edge != b_edges.end(); b_edge++) {
         Range<double> tr = (*b_edge)->parBounds(0);
-        for (int j = 0; j < N; j++) {
-          double t = tr.low() + (double)j / (double)(N - 1) * (tr.high() - tr.low());
+        for(int j = 0; j < N; j++) {
+          double t =
+            tr.low() + (double)j / (double)(N - 1) * (tr.high() - tr.low());
           GPoint p = (*b_edge)->point(t);
           SPoint3 pt(p.x(), p.y(), p.z());
           vertices.push_back(pt);
@@ -302,11 +312,11 @@ SOrientedBoundingBox GFace::getOBB()
   return SOrientedBoundingBox(_obb);
 }
 
-std::vector<MVertex*> GFace::getEmbeddedMeshVertices() const
+std::vector<MVertex *> GFace::getEmbeddedMeshVertices() const
 {
-  std::set<MVertex*> tmp;
+  std::set<MVertex *> tmp;
   for(std::vector<GEdge *>::const_iterator it = embedded_edges.begin();
-      it != embedded_edges.end(); it++){
+      it != embedded_edges.end(); it++) {
     tmp.insert((*it)->mesh_vertices.begin(), (*it)->mesh_vertices.end());
     if((*it)->getBeginVertex())
       tmp.insert((*it)->getBeginVertex()->mesh_vertices.begin(),
@@ -316,31 +326,32 @@ std::vector<MVertex*> GFace::getEmbeddedMeshVertices() const
                  (*it)->getEndVertex()->mesh_vertices.end());
   }
   for(std::list<GVertex *>::const_iterator it = embedded_vertices.begin();
-      it != embedded_vertices.end(); it++){
+      it != embedded_vertices.end(); it++) {
     tmp.insert((*it)->mesh_vertices.begin(), (*it)->mesh_vertices.end());
   }
-  return std::vector<MVertex*>(tmp.begin(), tmp.end());
+  return std::vector<MVertex *>(tmp.begin(), tmp.end());
 }
 
-std::vector<GVertex*> GFace::vertices() const
+std::vector<GVertex *> GFace::vertices() const
 {
-  std::set<GVertex*> v;
-  for(std::vector<GEdge*>::const_iterator it = l_edges.begin();
-      it != l_edges.end(); ++it){
+  std::set<GVertex *> v;
+  for(std::vector<GEdge *>::const_iterator it = l_edges.begin();
+      it != l_edges.end(); ++it) {
     GVertex *const v1 = (*it)->getBeginVertex();
     if(v1) v.insert(v1);
 
     GVertex *const v2 = (*it)->getEndVertex();
     if(v2) v.insert(v2);
   }
-  return std::vector<GVertex*>(v.begin(), v.end());
+  return std::vector<GVertex *>(v.begin(), v.end());
 }
 
 void GFace::setVisibility(char val, bool recursive)
 {
   GEntity::setVisibility(val);
-  if(recursive){
-    for (std::vector<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it)
+  if(recursive) {
+    for(std::vector<GEdge *>::iterator it = l_edges.begin();
+        it != l_edges.end(); ++it)
       (*it)->setVisibility(val, recursive);
   }
 }
@@ -348,8 +359,9 @@ void GFace::setVisibility(char val, bool recursive)
 void GFace::setColor(unsigned int val, bool recursive)
 {
   GEntity::setColor(val);
-  if(recursive){
-    for (std::vector<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it)
+  if(recursive) {
+    for(std::vector<GEdge *>::iterator it = l_edges.begin();
+        it != l_edges.end(); ++it)
       (*it)->setColor(val, recursive);
   }
 }
@@ -357,59 +369,64 @@ void GFace::setColor(unsigned int val, bool recursive)
 std::string GFace::getAdditionalInfoString(bool multline)
 {
   std::ostringstream sstream;
-  if(l_edges.size() > 20){
-    sstream << "Boundary curves: " << l_edges.front()->tag()
-            << ", ...," << l_edges.back()->tag();
-    if(multline) sstream << "\n";
-    else sstream << " ";
+  if(l_edges.size() > 20) {
+    sstream << "Boundary curves: " << l_edges.front()->tag() << ", ...,"
+            << l_edges.back()->tag();
+    if(multline)
+      sstream << "\n";
+    else
+      sstream << " ";
   }
-  else if(l_edges.size()){
+  else if(l_edges.size()) {
     sstream << "Boundary curves: ";
-    for(std::vector<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it){
+    for(std::vector<GEdge *>::iterator it = l_edges.begin();
+        it != l_edges.end(); ++it) {
       if(it != l_edges.begin()) sstream << ", ";
       sstream << (*it)->tag();
     }
-    if(multline) sstream << "\n";
-    else sstream << " ";
+    if(multline)
+      sstream << "\n";
+    else
+      sstream << " ";
   }
 
-  if(embedded_edges.size()){
+  if(embedded_edges.size()) {
     sstream << "Embedded curves: ";
-    for(std::vector<GEdge*>::iterator it = embedded_edges.begin();
-        it != embedded_edges.end(); ++it){
+    for(std::vector<GEdge *>::iterator it = embedded_edges.begin();
+        it != embedded_edges.end(); ++it) {
       if(it != embedded_edges.begin()) sstream << ", ";
       sstream << (*it)->tag();
     }
-    if(multline) sstream << "\n";
-    else sstream << " ";
+    if(multline)
+      sstream << "\n";
+    else
+      sstream << " ";
   }
 
-  if(embedded_vertices.size()){
+  if(embedded_vertices.size()) {
     sstream << "Embedded points: ";
-    for(std::list<GVertex*>::iterator it = embedded_vertices.begin();
-        it != embedded_vertices.end(); ++it){
+    for(std::list<GVertex *>::iterator it = embedded_vertices.begin();
+        it != embedded_vertices.end(); ++it) {
       if(it != embedded_vertices.begin()) sstream << ", ";
       sstream << (*it)->tag();
     }
-    if(multline) sstream << "\n";
-    else sstream << " ";
+    if(multline)
+      sstream << "\n";
+    else
+      sstream << " ";
   }
 
   if(meshAttributes.recombine || meshAttributes.method == MESH_TRANSFINITE ||
-     meshAttributes.extrude || meshAttributes.reverseMesh){
+     meshAttributes.extrude || meshAttributes.reverseMesh) {
     sstream << "Mesh attributes:";
-    if(meshAttributes.recombine)
-      sstream << " recombined";
-    if(meshAttributes.method == MESH_TRANSFINITE)
-      sstream << " transfinite";
-    if(meshAttributes.extrude)
-      sstream << " extruded";
-    if(meshAttributes.reverseMesh)
-      sstream << " reverse";
+    if(meshAttributes.recombine) sstream << " recombined";
+    if(meshAttributes.method == MESH_TRANSFINITE) sstream << " transfinite";
+    if(meshAttributes.extrude) sstream << " extruded";
+    if(meshAttributes.reverseMesh) sstream << " reverse";
   }
   std::string str = sstream.str();
-  if(str.size() && (str[str.size()-1] == '\n' || str[str.size()-1] == ' '))
-     str.resize(str.size() - 1);
+  if(str.size() && (str[str.size() - 1] == '\n' || str[str.size() - 1] == ' '))
+    str.resize(str.size() - 1);
   return str;
 }
 
@@ -417,46 +434,48 @@ void GFace::writeGEO(FILE *fp)
 {
   if(geomType() == DiscreteSurface) return;
 
-  std::vector<GEdge*> const& edg = edges();
-  std::vector<int> const& dir = orientations();
-  if(edg.size() && dir.size() == edg.size()){
+  std::vector<GEdge *> const &edg = edges();
+  std::vector<int> const &dir = orientations();
+  if(edg.size() && dir.size() == edg.size()) {
     std::vector<int> num, ori;
-    for(std::vector<GEdge*>::const_iterator it = edg.begin(); it != edg.end(); it++)
+    for(std::vector<GEdge *>::const_iterator it = edg.begin(); it != edg.end();
+        it++)
       num.push_back((*it)->tag());
-    for(std::vector<int>::const_iterator it = dir.begin(); it != dir.end(); it++)
+    for(std::vector<int>::const_iterator it = dir.begin(); it != dir.end();
+        it++)
       ori.push_back((*it) > 0 ? 1 : -1);
     fprintf(fp, "Line Loop(%d) = ", tag());
-    for(unsigned int i = 0; i < num.size(); i++){
+    for(unsigned int i = 0; i < num.size(); i++) {
       if(i)
         fprintf(fp, ", %d", num[i] * ori[i]);
       else
         fprintf(fp, "{%d", num[i] * ori[i]);
     }
     fprintf(fp, "};\n");
-    if(geomType() == GEntity::Plane){
+    if(geomType() == GEntity::Plane) {
       fprintf(fp, "Plane Surface(%d) = {%d};\n", tag(), tag());
     }
-    else if(edg.size() == 3 || edg.size() == 4){
+    else if(edg.size() == 3 || edg.size() == 4) {
       fprintf(fp, "Surface(%d) = {%d};\n", tag(), tag());
     }
-    else{
+    else {
       Msg::Error("Skipping surface %d in export", tag());
     }
   }
 
-  for(std::vector<GEdge*>::iterator it = embedded_edges.begin();
+  for(std::vector<GEdge *>::iterator it = embedded_edges.begin();
       it != embedded_edges.end(); it++)
     fprintf(fp, "Line {%d} In Surface {%d};\n", (*it)->tag(), tag());
 
-  for(std::list<GVertex*>::iterator it = embedded_vertices.begin();
+  for(std::list<GVertex *>::iterator it = embedded_vertices.begin();
       it != embedded_vertices.end(); it++)
     fprintf(fp, "Point {%d} In Surface {%d};\n", (*it)->tag(), tag());
 
-  if(meshAttributes.method == MESH_TRANSFINITE){
+  if(meshAttributes.method == MESH_TRANSFINITE) {
     fprintf(fp, "Transfinite Surface {%d}", tag());
-    if(meshAttributes.corners.size()){
+    if(meshAttributes.corners.size()) {
       fprintf(fp, " = {");
-      for(unsigned int i = 0; i < meshAttributes.corners.size(); i++){
+      for(unsigned int i = 0; i < meshAttributes.corners.size(); i++) {
         if(i) fprintf(fp, ",");
         fprintf(fp, "%d", meshAttributes.corners[i]->tag());
       }
@@ -465,11 +484,9 @@ void GFace::writeGEO(FILE *fp)
     fprintf(fp, ";\n");
   }
 
-  if(meshAttributes.recombine)
-    fprintf(fp, "Recombine Surface {%d};\n", tag());
+  if(meshAttributes.recombine) fprintf(fp, "Recombine Surface {%d};\n", tag());
 
-  if(meshAttributes.reverseMesh)
-    fprintf(fp, "Reverse Surface {%d};\n", tag());
+  if(meshAttributes.reverseMesh) fprintf(fp, "Reverse Surface {%d};\n", tag());
 }
 
 void GFace::computeMeanPlane()
@@ -483,11 +500,12 @@ void GFace::computeMeanPlane()
     // and GFace::relocateMeshVertices(): after perturbation of the boundary, we
     // want a parametrization of the surface that is "close" to the original
     // one. If this fails, we fallback to the classical (SVD-based) algorithm.
-    std::vector<GEdge*> const& edg = edges();
-    for(std::vector<GEdge*>::const_iterator ite = edg.begin(); ite != edg.end(); ite++){
+    std::vector<GEdge *> const &edg = edges();
+    for(std::vector<GEdge *>::const_iterator ite = edg.begin();
+        ite != edg.end(); ite++) {
       const GEdge *e = *ite;
       if(e->geomType() == GEntity::DiscreteCurve ||
-         e->geomType() == GEntity::BoundaryLayerCurve){
+         e->geomType() == GEntity::BoundaryLayerCurve) {
         pts.clear();
         break;
       }
@@ -499,23 +517,28 @@ void GFace::computeMeanPlane()
     }
     bool ok = false;
     double res[4] = {0., 0., 0., 0.}, xm = 0., ym = 0., zm = 0.;
-    if(pts.size() >= 3){
+    if(pts.size() >= 3) {
       SVector3 d01(pts[0], pts[1]);
-      for(unsigned int i = 2; i < pts.size(); i++){
+      for(unsigned int i = 2; i < pts.size(); i++) {
         SVector3 d0i(pts[0], pts[i]);
         SVector3 n = crossprod(d01, d0i);
         // if too small, the points are almost colinear; tolerance is relatively
         // high so that we don't accept points on plane surfaces defined by
         // lines that are not exactly co-planar
-        if(norm(n) > sqrt(CTX::instance()->geom.tolerance) * CTX::instance()->lc){
-          res[0] = n.x(); res[1] = n.y(); res[2] = n.z();
-          xm = pts[0].x(); ym = pts[0].y(); zm = pts[0].z();
+        if(norm(n) >
+           sqrt(CTX::instance()->geom.tolerance) * CTX::instance()->lc) {
+          res[0] = n.x();
+          res[1] = n.y();
+          res[2] = n.z();
+          xm = pts[0].x();
+          ym = pts[0].y();
+          zm = pts[0].z();
           ok = true;
           break;
         }
       }
     }
-    if(ok){
+    if(ok) {
       double ex[3], t1[3], t2[3];
       ex[0] = ex[1] = ex[2] = 0.0;
       if(res[0] == 0.)
@@ -534,29 +557,31 @@ void GFace::computeMeanPlane()
     }
   }
 
-  std::vector<GVertex*> const& verts = vertices();
-  std::vector<GVertex*>::const_iterator itv = verts.begin();
-  for(; itv != verts.end(); itv++){
+  std::vector<GVertex *> const &verts = vertices();
+  std::vector<GVertex *>::const_iterator itv = verts.begin();
+  for(; itv != verts.end(); itv++) {
     const GVertex *v = *itv;
     pts.push_back(SPoint3(v->x(), v->y(), v->z()));
   }
 
   bool colinear = (pts.size() < 3);
-  if(pts.size() > 2){
+  if(pts.size() > 2) {
     SVector3 d01(pts[0], pts[1]), d02(pts[0], pts[2]);
     if(norm(crossprod(d01, d02)) < 1e-12) colinear = true;
   }
 
-  if(colinear){
-    Msg::Debug("Adding edge points (%d) to compute mean plane of face %d", pts.size(), tag());
-    std::vector<GEdge*> const& edg = edges();
-    for(std::vector<GEdge*>::const_iterator ite = edg.begin(); ite != edg.end(); ite++){
+  if(colinear) {
+    Msg::Debug("Adding edge points (%d) to compute mean plane of face %d",
+               pts.size(), tag());
+    std::vector<GEdge *> const &edg = edges();
+    for(std::vector<GEdge *>::const_iterator ite = edg.begin();
+        ite != edg.end(); ite++) {
       const GEdge *e = *ite;
-      if(e->mesh_vertices.size() > 1){
+      if(e->mesh_vertices.size() > 1) {
         for(unsigned int i = 0; i < e->mesh_vertices.size(); i++)
           pts.push_back(e->mesh_vertices[i]->point());
       }
-      else{
+      else {
         Range<double> b = e->parBounds(0);
         GPoint p1 = e->point(b.low() + 0.333 * (b.high() - b.low()));
         pts.push_back(SPoint3(p1.x(), p1.y(), p1.z()));
@@ -569,7 +594,7 @@ void GFace::computeMeanPlane()
   computeMeanPlane(pts);
 }
 
-void GFace::computeMeanPlane(const std::vector<MVertex*> &points)
+void GFace::computeMeanPlane(const std::vector<MVertex *> &points)
 {
   std::vector<SPoint3> pts;
   for(unsigned int i = 0; i < points.size(); i++)
@@ -617,7 +642,8 @@ void GFace::computeMeanPlane(const std::vector<SPoint3> &points)
   int min;
   if(std::abs(svd[0]) < std::abs(svd[1]) && std::abs(svd[0]) < std::abs(svd[2]))
     min = 0;
-  else if(std::abs(svd[1]) < std::abs(svd[0]) && std::abs(svd[1]) < std::abs(svd[2]))
+  else if(std::abs(svd[1]) < std::abs(svd[0]) &&
+          std::abs(svd[1]) < std::abs(svd[2]))
     min = 1;
   else
     min = 2;
@@ -683,38 +709,36 @@ end:
 
   Msg::Debug("Surface: %d", tag());
   Msg::Debug("SVD    : %g,%g,%g (min=%d)", svd[0], svd[1], svd[2], min);
-  Msg::Debug("Plane  : (%g x + %g y + %g z = %g)",
-             meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d);
-  Msg::Debug("Normal : (%g , %g , %g )",
-             meanPlane.a, meanPlane.b, meanPlane.c);
+  Msg::Debug("Plane  : (%g x + %g y + %g z = %g)", meanPlane.a, meanPlane.b,
+             meanPlane.c, meanPlane.d);
+  Msg::Debug("Normal : (%g , %g , %g )", meanPlane.a, meanPlane.b, meanPlane.c);
   Msg::Debug("t1     : (%g , %g , %g )", t1[0], t1[1], t1[2]);
   Msg::Debug("t2     : (%g , %g , %g )", t2[0], t2[1], t2[2]);
-  Msg::Debug("pt     : (%g , %g , %g )",
-             meanPlane.x, meanPlane.y, meanPlane.z);
+  Msg::Debug("pt     : (%g , %g , %g )", meanPlane.x, meanPlane.y, meanPlane.z);
 
-  //check coherence for plane surfaces
+  // check coherence for plane surfaces
   if(geomType() == Plane) {
     SBoundingBox3d bb = bounds();
     double lc = norm(SVector3(bb.max(), bb.min()));
-    std::vector<GVertex*> const& verts = vertices();
-    std::vector<GVertex*>::const_iterator itv = verts.begin();
-    for(; itv != verts.end(); itv++){
+    std::vector<GVertex *> const &verts = vertices();
+    std::vector<GVertex *>::const_iterator itv = verts.begin();
+    for(; itv != verts.end(); itv++) {
       const GVertex *v = *itv;
       double const d = meanPlane.a * v->x() + meanPlane.b * v->y() +
-        meanPlane.c * v->z() - meanPlane.d;
+                       meanPlane.c * v->z() - meanPlane.d;
       if(std::abs(d) > lc * 1.e-3) {
-        Msg::Debug("Plane surface %d (%gx+%gy+%gz=%g) is not plane!",
-                   tag(), meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d);
-        Msg::Debug("Control point %d = (%g,%g,%g), val=%g",
-                   v->tag(), v->x(), v->y(), v->z(), d);
+        Msg::Debug("Plane surface %d (%gx+%gy+%gz=%g) is not plane!", tag(),
+                   meanPlane.a, meanPlane.b, meanPlane.c, meanPlane.d);
+        Msg::Debug("Control point %d = (%g,%g,%g), val=%g", v->tag(), v->x(),
+                   v->y(), v->z(), d);
         break;
       }
     }
   }
 }
 
-void GFace::getMeanPlaneData(double VX[3], double VY[3],
-                             double &x, double &y, double &z) const
+void GFace::getMeanPlaneData(double VX[3], double VY[3], double &x, double &y,
+                             double &z) const
 {
   VX[0] = meanPlane.plan[0][0];
   VX[1] = meanPlane.plan[0][1];
@@ -730,16 +754,15 @@ void GFace::getMeanPlaneData(double VX[3], double VY[3],
 void GFace::getMeanPlaneData(double plan[3][3]) const
 {
   for(int i = 0; i < 3; i++)
-    for(int j = 0; j < 3; j++)
-      plan[i][j] = meanPlane.plan[i][j];
+    for(int j = 0; j < 3; j++) plan[i][j] = meanPlane.plan[i][j];
 }
 
-void GFace::computeMeshSizeFieldAccuracy(double &avg,double &max_e, double &min_e,
-					 int &nE, int &GS)
+void GFace::computeMeshSizeFieldAccuracy(double &avg, double &max_e,
+                                         double &min_e, int &nE, int &GS)
 {
 #if defined(HAVE_MESH)
   std::set<MEdge, Less_Edge> es;
-  for(unsigned int i = 0; i < getNumMeshElements(); i++){
+  for(unsigned int i = 0; i < getNumMeshElements(); i++) {
     MElement *e = getMeshElement(i);
     for(int j = 0; j < e->getNumEdges(); j++) es.insert(e->getEdge(j));
   }
@@ -751,21 +774,21 @@ void GFace::computeMeshSizeFieldAccuracy(double &avg,double &max_e, double &min_
   GS = 0;
   double oneoversqr2 = 1. / sqrt(2.);
   double sqr2 = sqrt(2.);
-  for (std::set<MEdge, Less_Edge>::const_iterator it = es.begin();
-       it != es.end(); ++it){
-    double u1,v1,u2,v2;
-    MVertex *vert1 =  it->getVertex(0);
+  for(std::set<MEdge, Less_Edge>::const_iterator it = es.begin();
+      it != es.end(); ++it) {
+    double u1, v1, u2, v2;
+    MVertex *vert1 = it->getVertex(0);
     vert1->getParameter(0, u1);
     vert1->getParameter(1, v1);
-    MVertex *vert2 =  it->getVertex(1);
+    MVertex *vert2 = it->getVertex(1);
     vert2->getParameter(0, u2);
     vert2->getParameter(1, v2);
     double l1 = BGM_MeshSize(this, u1, v1, vert1->x(), vert1->y(), vert1->z());
     double l2 = BGM_MeshSize(this, u2, v2, vert2->x(), vert2->y(), vert2->z());
-    double correctLC = 0.5*(l1+l2);
-    double lone = it->length()/correctLC;
-    if (lone > oneoversqr2 && lone < sqr2) GS++;
-    avg += lone >1 ? (1. / lone) - 1. : lone - 1.;
+    double correctLC = 0.5 * (l1 + l2);
+    double lone = it->length() / correctLC;
+    if(lone > oneoversqr2 && lone < sqr2) GS++;
+    avg += lone > 1 ? (1. / lone) - 1. : lone - 1.;
     max_e = std::max(max_e, lone);
     min_e = std::min(min_e, lone);
   }
@@ -774,8 +797,7 @@ void GFace::computeMeshSizeFieldAccuracy(double &avg,double &max_e, double &min_
 
 double GFace::curvatureDiv(const SPoint2 &param) const
 {
-
-  if (geomType() == Plane) return 0;
+  if(geomType() == Plane) return 0;
 
   // X=X(u,v) Y=Y(u,v) Z=Z(u,v)
   // curv = div n = dnx/dx + dny/dy + dnz/dz
@@ -796,20 +818,20 @@ double GFace::curvatureDiv(const SPoint2 &param) const
 
   SVector3 n1, n2, n3, n4;
   if(param.x() - eps < 0.0) {
-    n1 = normal(SPoint2(param.x(),       param.y()));
+    n1 = normal(SPoint2(param.x(), param.y()));
     n2 = normal(SPoint2(param.x() + eps, param.y()));
   }
   else {
     n1 = normal(SPoint2(param.x() - eps, param.y()));
-    n2 = normal(SPoint2(param.x(),       param.y()));
+    n2 = normal(SPoint2(param.x(), param.y()));
   }
   if(param.y() - eps < 0.0) {
-    n3 = normal(SPoint2(param.x(), param.y()      ));
+    n3 = normal(SPoint2(param.x(), param.y()));
     n4 = normal(SPoint2(param.x(), param.y() + eps));
   }
   else {
     n3 = normal(SPoint2(param.x(), param.y() - eps));
-    n4 = normal(SPoint2(param.x(), param.y()      ));
+    n4 = normal(SPoint2(param.x(), param.y()));
   }
 
   SVector3 dndu = 100000 * (n2 - n1);
@@ -828,7 +850,7 @@ double GFace::curvatureDiv(const SPoint2 &param) const
 
 double GFace::curvatureMax(const SPoint2 &param) const
 {
-  if (geomType() == Plane) return 0.;
+  if(geomType() == Plane) return 0.;
 
   double eigVal[2], eigVec[8];
   getMetricEigenVectors(param, eigVal, eigVec);
@@ -836,12 +858,13 @@ double GFace::curvatureMax(const SPoint2 &param) const
   return fabs(eigVal[1]);
 }
 
-double GFace::curvatures(const SPoint2 &param, SVector3 &dirMax, SVector3 &dirMin,
-                         double &curvMax, double &curvMin) const
+double GFace::curvatures(const SPoint2 &param, SVector3 &dirMax,
+                         SVector3 &dirMin, double &curvMax,
+                         double &curvMin) const
 {
   Pair<SVector3, SVector3> D1 = firstDer(param);
 
-  if(geomType() == Plane){
+  if(geomType() == Plane) {
     dirMax = D1.first();
     dirMin = D1.second();
     curvMax = 0.;
@@ -849,7 +872,7 @@ double GFace::curvatures(const SPoint2 &param, SVector3 &dirMax, SVector3 &dirMi
     return 0.;
   }
 
-  if(geomType() == Sphere){
+  if(geomType() == Sphere) {
     dirMax = D1.first();
     dirMin = D1.second();
     curvMax = curvatureDiv(param);
@@ -875,17 +898,17 @@ double GFace::getMetricEigenvalue(const SPoint2 &)
   return 0.;
 }
 
-// eigen values are absolute values and sorted from min to max of absolute values
-// eigen vectors are the corresponding COLUMNS of eigVec
-void GFace::getMetricEigenVectors(const SPoint2 &param,
-                                  double eigVal[2], double eigVec[4]) const
+// eigen values are absolute values and sorted from min to max of absolute
+// values eigen vectors are the corresponding COLUMNS of eigVec
+void GFace::getMetricEigenVectors(const SPoint2 &param, double eigVal[2],
+                                  double eigVec[4]) const
 {
-
   // first derivatives
-  Pair<SVector3,SVector3> D1 = firstDer(param);
+  Pair<SVector3, SVector3> D1 = firstDer(param);
   SVector3 du = D1.first();
   SVector3 dv = D1.second();
-  SVector3 nor = crossprod(du, dv); nor.normalize();
+  SVector3 nor = crossprod(du, dv);
+  nor.normalize();
 
   // second derivatives
   SVector3 dudu = SVector3();
@@ -897,17 +920,18 @@ void GFace::getMetricEigenVectors(const SPoint2 &param,
   double form1[2][2];
   form1[0][0] = normSq(du);
   form1[1][1] = normSq(dv);
-  form1[0][1] = form1[1][0] = dot(du,dv);
+  form1[0][1] = form1[1][0] = dot(du, dv);
 
   // second form
   double form2[2][2];
-  form2[0][0] = dot(nor,dudu);
-  form2[1][1] = dot(nor,dvdv);
-  form2[0][1] = form2[1][0] = dot(nor,dudv);
+  form2[0][0] = dot(nor, dudu);
+  form2[1][1] = dot(nor, dvdv);
+  form2[0][1] = form2[1][0] = dot(nor, dudv);
 
   // inverse of first form
   double inv_form1[2][2];
-  double inv_det_form1 = 1. / (form1[0][0] * form1[1][1] - form1[1][0] * form1[0][1]);
+  double inv_det_form1 =
+    1. / (form1[0][0] * form1[1][1] - form1[1][0] * form1[0][1]);
   inv_form1[0][0] = inv_det_form1 * form1[1][1];
   inv_form1[1][1] = inv_det_form1 * form1[0][0];
   inv_form1[1][0] = inv_form1[0][1] = -1 * inv_det_form1 * form1[0][1];
@@ -922,7 +946,7 @@ void GFace::getMetricEigenVectors(const SPoint2 &param,
   // eigen values and vectors of N
   fullMatrix<double> vl(2, 2), vr(2, 2);
   fullVector<double> dr(2), di(2);
-  if(N.eig(dr, di, vl, vr, true)){
+  if(N.eig(dr, di, vl, vr, true)) {
     eigVal[0] = fabs(dr(0));
     eigVal[1] = fabs(dr(1));
     eigVec[0] = vr(0, 0);
@@ -930,14 +954,14 @@ void GFace::getMetricEigenVectors(const SPoint2 &param,
     eigVec[1] = vr(0, 1);
     eigVec[3] = vr(1, 1);
   }
-  else{
+  else {
     Msg::Error("Problem in eigen vectors computation");
     Msg::Error(" N = [ %f %f ]", N(0, 0), N(0, 1));
     Msg::Error("     [ %f %f ]", N(1, 0), N(1, 1));
     for(int i = 0; i < 2; i++) eigVal[i] = 0.;
     for(int i = 0; i < 4; i++) eigVec[i] = 0.;
   }
-  if (fabs(di(0)) > 1.e-12 || fabs(di(1)) > 1.e-12) {
+  if(fabs(di(0)) > 1.e-12 || fabs(di(1)) > 1.e-12) {
     Msg::Error("Found imaginary eigenvalues");
   }
 }
@@ -964,15 +988,14 @@ void GFace::XYZtoUV(double X, double Y, double Z, double &U, double &V,
   vmin = rv.low();
   vmax = rv.high();
 
-  const double tol = Precision * (SQU(umax - umin) + SQU(vmax-vmin));
+  const double tol = Precision * (SQU(umax - umin) + SQU(vmax - vmin));
   for(int i = 0; i < NumInitGuess; i++) {
     initu[i] = umin + initu[i] * (umax - umin);
     initv[i] = vmin + initv[i] * (vmax - vmin);
   }
 
-  for(int i = 0; i < NumInitGuess; i++){
-    for(int j = 0; j < NumInitGuess; j++){
-
+  for(int i = 0; i < NumInitGuess; i++) {
+    for(int j = 0; j < NumInitGuess; j++) {
       U = initu[i];
       V = initv[j];
       err = 1.0;
@@ -980,7 +1003,7 @@ void GFace::XYZtoUV(double X, double Y, double Z, double &U, double &V,
 
       GPoint P = point(U, V);
       err2 = sqrt(SQU(X - P.x()) + SQU(Y - P.y()) + SQU(Z - P.z()));
-      if (err2 < 1.e-8 * CTX::instance()->lc) return;
+      if(err2 < 1.e-8 * CTX::instance()->lc) return;
 
       while(err > tol && iter < MaxIter) {
         P = point(U, V);
@@ -996,16 +1019,15 @@ void GFace::XYZtoUV(double X, double Y, double Z, double &U, double &V,
         mat[2][2] = 0.;
         invert_singular_matrix3x3(mat, jac);
 
-        Unew = U + relax *
-          (jac[0][0] * (X - P.x()) + jac[1][0] * (Y - P.y()) +
-           jac[2][0] * (Z - P.z()));
-        Vnew = V + relax *
-          (jac[0][1] * (X - P.x()) + jac[1][1] * (Y - P.y()) +
-           jac[2][1] * (Z - P.z()));
+        Unew = U + relax * (jac[0][0] * (X - P.x()) + jac[1][0] * (Y - P.y()) +
+                            jac[2][0] * (Z - P.z()));
+        Vnew = V + relax * (jac[0][1] * (X - P.x()) + jac[1][1] * (Y - P.y()) +
+                            jac[2][1] * (Z - P.z()));
 
         // don't remove this test: it is important
-        if((Unew > umax+tol || Unew < umin-tol) &&
-           (Vnew > vmax+tol || Vnew < vmin-tol)) break;
+        if((Unew > umax + tol || Unew < umin - tol) &&
+           (Vnew > vmax + tol || Vnew < vmin - tol))
+          break;
 
         err = SQU(Unew - U) + SQU(Vnew - V);
         err2 = sqrt(SQU(X - P.x()) + SQU(Y - P.y()) + SQU(Z - P.z()));
@@ -1015,25 +1037,22 @@ void GFace::XYZtoUV(double X, double Y, double Z, double &U, double &V,
         V = Vnew;
       }
 
-      if(iter < MaxIter && err <= tol &&
-         Unew <= umax && Vnew <= vmax &&
-         Unew >= umin && Vnew >= vmin){
-
-        if (onSurface && err2 > 1.e-4 * CTX::instance()->lc &&
-            !CTX::instance()->mesh.NewtonConvergenceTestXYZ){
+      if(iter < MaxIter && err <= tol && Unew <= umax && Vnew <= vmax &&
+         Unew >= umin && Vnew >= vmin) {
+        if(onSurface && err2 > 1.e-4 * CTX::instance()->lc &&
+           !CTX::instance()->mesh.NewtonConvergenceTestXYZ) {
           Msg::Warning("Converged for i=%d j=%d (err=%g iter=%d) BUT "
                        "xyz error = %g in point (%e,%e,%e) on surface %d",
                        i, j, err, iter, err2, X, Y, Z, tag());
         }
 
         if(onSurface && err2 > 1.e-4 * CTX::instance()->lc &&
-           CTX::instance()->mesh.NewtonConvergenceTestXYZ){
+           CTX::instance()->mesh.NewtonConvergenceTestXYZ) {
           // not converged in XYZ coordinates
         }
-        else{
+        else {
           return;
         }
-
       }
     }
   }
@@ -1057,47 +1076,55 @@ SPoint2 GFace::parFromPoint(const SPoint3 &p, bool onSurface) const
 
 #if defined(HAVE_BFGS)
 
-class data_wrapper{
- private:
-  const GFace* gf;
+class data_wrapper {
+private:
+  const GFace *gf;
   SPoint3 point;
- public:
-  data_wrapper() { gf = NULL; point = SPoint3(); }
+
+public:
+  data_wrapper()
+  {
+    gf = NULL;
+    point = SPoint3();
+  }
   ~data_wrapper() {}
-  const GFace* get_face() { return gf; }
-  void set_face(const GFace* face) { gf = face; }
+  const GFace *get_face() { return gf; }
+  void set_face(const GFace *face) { gf = face; }
   SPoint3 get_point() { return point; }
   void set_point(const SPoint3 &_point) { point = SPoint3(_point); }
 };
 
 // Callback function for BFGS
-void bfgs_callback(const alglib::real_1d_array& x, double& func,
-                   alglib::real_1d_array& grad, void* ptr)
+void bfgs_callback(const alglib::real_1d_array &x, double &func,
+                   alglib::real_1d_array &grad, void *ptr)
 {
-  data_wrapper* w = static_cast<data_wrapper*>(ptr);
+  data_wrapper *w = static_cast<data_wrapper *>(ptr);
   SPoint3 p = w->get_point();
-  const GFace* gf = w->get_face();
+  const GFace *gf = w->get_face();
 
   // Value of the objective
   GPoint pnt = gf->point(x[0], x[1]);
-  func = 0.5 *
-    ( p.x() - pnt.x() ) * ( p.x() - pnt.x() ) +
-    ( p.y() - pnt.y() ) * ( p.y() - pnt.y() ) +
-    ( p.z() - pnt.z() ) * ( p.z() - pnt.z() ) ;
-  //printf("func : %f\n", func);
+  func = 0.5 * (p.x() - pnt.x()) * (p.x() - pnt.x()) +
+         (p.y() - pnt.y()) * (p.y() - pnt.y()) +
+         (p.z() - pnt.z()) * (p.z() - pnt.z());
+  // printf("func : %f\n", func);
 
   // Value of the gradient
   Pair<SVector3, SVector3> der = gf->firstDer(SPoint2(x[0], x[1]));
-  grad[0] = -(p.x() - pnt.x()) * der.left().x()  - (p.y() - pnt.y()) * der.left().y()
-    - (p.z() - pnt.z()) * der.left().z();
-  grad[1] = -(p.x() - pnt.x()) * der.right().x() - (p.y() - pnt.y()) * der.right().y()
-    - (p.z() - pnt.z()) * der.right().z();
+  grad[0] = -(p.x() - pnt.x()) * der.left().x() -
+            (p.y() - pnt.y()) * der.left().y() -
+            (p.z() - pnt.z()) * der.left().z();
+  grad[1] = -(p.x() - pnt.x()) * der.right().x() -
+            (p.y() - pnt.y()) * der.right().y() -
+            (p.z() - pnt.z()) * der.right().z();
   //  printf("func %22.15E Gradients %22.15E %22.15E der %g %g %g\n",
-  //         func, grad[0], grad[1],der.left().x(),der.left().y(),der.left().z());
+  //         func, grad[0],
+  //         grad[1],der.left().x(),der.left().y(),der.left().z());
 }
 #endif
 
-GPoint GFace::closestPoint(const SPoint3 &queryPoint, const double initialGuess[2]) const
+GPoint GFace::closestPoint(const SPoint3 &queryPoint,
+                           const double initialGuess[2]) const
 {
 #if defined(HAVE_BFGS)
   // Test initial guess
@@ -1111,15 +1138,15 @@ GPoint GFace::closestPoint(const SPoint3 &queryPoint, const double initialGuess[
   const double nGuesses = 10.;
   const Range<double> uu = parBounds(0);
   const Range<double> vv = parBounds(1);
-  const double ru = uu.high()-uu.low(), rv = vv.high()-vv.low();
-  const double epsU = 1e-5*ru, epsV = 1e-5*rv;
-  const double du = ru/nGuesses, dv = rv/nGuesses;
+  const double ru = uu.high() - uu.low(), rv = vv.high() - vv.low();
+  const double epsU = 1e-5 * ru, epsV = 1e-5 * rv;
+  const double du = ru / nGuesses, dv = rv / nGuesses;
   for(double u = uu.low(); u <= uu.high() + epsU; u += du) {
     for(double v = vv.low(); v <= vv.high() + epsV; v += dv) {
       GPoint pnt = point(u, v);
       SPoint3 spnt(pnt.x(), pnt.y(), pnt.z());
       double dist = queryPoint.distance(spnt);
-      if (dist < min_dist) {
+      if(dist < min_dist) {
         min_dist = dist;
         min_u = u;
         min_v = v;
@@ -1175,7 +1202,7 @@ bool GFace::containsParam(const SPoint2 &pt)
 
 SVector3 GFace::normal(const SPoint2 &param) const
 {
-  Pair<SVector3,SVector3> der = firstDer(param);
+  Pair<SVector3, SVector3> der = firstDer(param);
   SVector3 n = crossprod(der.first(), der.second());
   n.normalize();
   return n;
@@ -1183,8 +1210,8 @@ SVector3 GFace::normal(const SPoint2 &param) const
 
 bool GFace::buildRepresentationCross(bool force)
 {
-  if(cross[0].size()){
-    if(force){
+  if(cross[0].size()) {
+    if(force) {
       cross[0].clear();
       cross[0].clear();
     }
@@ -1195,17 +1222,18 @@ bool GFace::buildRepresentationCross(bool force)
   Range<double> ubounds = parBounds(0);
   Range<double> vbounds = parBounds(1);
   // try to compute something better for Gmsh surfaces
-  if(getNativeType() == GmshModel && geomType() == Plane){
+  if(getNativeType() == GmshModel && geomType() == Plane) {
     SBoundingBox3d bb;
-    std::vector<GEdge*> ed = edges();
-    for(std::vector<GEdge*>::const_iterator it = ed.begin(); it != ed.end(); it++){
+    std::vector<GEdge *> ed = edges();
+    for(std::vector<GEdge *>::const_iterator it = ed.begin(); it != ed.end();
+        it++) {
       GEdge *ge = *it;
       if(ge->geomType() != DiscreteCurve &&
-         ge->geomType() != BoundaryLayerCurve){
+         ge->geomType() != BoundaryLayerCurve) {
         Range<double> t_bounds = ge->parBounds(0);
         const int N = 5;
         double t0 = t_bounds.low(), dt = t_bounds.high() - t_bounds.low();
-        for(int i = 0; i < N; i++){
+        for(int i = 0; i < N; i++) {
           double t = t0 + dt / (double)(N - 1) * i;
           GPoint p = ge->point(t);
           SPoint2 uv = parFromPoint(SPoint3(p.x(), p.y(), p.z()));
@@ -1213,7 +1241,7 @@ bool GFace::buildRepresentationCross(bool force)
         }
       }
     }
-    if(!bb.empty()){
+    if(!bb.empty()) {
       ubounds = Range<double>(bb.min().x(), bb.max().x());
       vbounds = Range<double>(bb.min().y(), bb.max().y());
     }
@@ -1223,7 +1251,7 @@ bool GFace::buildRepresentationCross(bool force)
   if(CTX::instance()->geom.oldRuledSurface) tri = false;
   double c = tri ? 0.75 : 0.5;
   double uav = c * (ubounds.high() + ubounds.low());
-  double vav = (1-c) * (vbounds.high() + vbounds.low());
+  double vav = (1 - c) * (vbounds.high() + vbounds.low());
   double u2 = 0.5 * (ubounds.high() + ubounds.low());
   double v2 = 0.5 * (vbounds.high() + vbounds.low());
   double ud = (ubounds.high() - ubounds.low());
@@ -1234,13 +1262,13 @@ bool GFace::buildRepresentationCross(bool force)
     for(int i = 0; i < N; i++) {
       double t = (double)i / (double)(N - 1);
       SPoint2 uv;
-      if(!dir){
+      if(!dir) {
         if(tri)
           uv.setPosition(u2 + u2 * t, vbounds.low() + v2 * t);
         else
           uv.setPosition(ubounds.low() + ud * t, vav);
       }
-      else{
+      else {
         if(tri)
           uv.setPosition(u2 + u2 * t, v2 - v2 * t);
         else
@@ -1248,18 +1276,20 @@ bool GFace::buildRepresentationCross(bool force)
       }
       GPoint p = point(uv);
       SPoint3 pt(p.x(), p.y(), p.z());
-      bool inside = (geomType() == Plane) ? containsPoint(pt) : containsParam(uv);
-      if(inside){
+      bool inside =
+        (geomType() == Plane) ? containsPoint(pt) : containsParam(uv);
+      if(inside) {
         cross[dir].back().push_back(pt);
       }
-      else{
-        if(cross[dir].back().size()) cross[dir].push_back(std::vector<SPoint3>());
+      else {
+        if(cross[dir].back().size())
+          cross[dir].push_back(std::vector<SPoint3>());
       }
     }
   }
   // if we couldn't determine a cross, add a dummy one so that we won't try
   // again unless we force the recomputation
-  if(cross[0].empty()){
+  if(cross[0].empty()) {
     cross[0].push_back(std::vector<SPoint3>());
     return false;
   }
@@ -1274,14 +1304,14 @@ bool GFace::buildSTLTriangulation(bool force)
   stl_triangles.clear();
 
   // Build a simple triangulation for surfaces which we know are not trimmed
-  if(geomType() == ParametricSurface || geomType() == ProjectionFace){
+  if(geomType() == ParametricSurface || geomType() == ProjectionFace) {
     const int nu = 64, nv = 64;
     Range<double> ubounds = parBounds(0);
     Range<double> vbounds = parBounds(1);
     double umin = ubounds.low(), umax = ubounds.high();
     double vmin = vbounds.low(), vmax = vbounds.high();
-    for(int i = 0; i < nu; i++){
-      for(int j = 0; j < nv; j++){
+    for(int i = 0; i < nu; i++) {
+      for(int j = 0; j < nv; j++) {
         double u = umin + (double)i / (double)(nu - 1) * (umax - umin);
         double v = vmin + (double)j / (double)(nv - 1) * (vmax - vmin);
         stl_vertices_uv.push_back(SPoint2(u, v));
@@ -1289,8 +1319,8 @@ bool GFace::buildSTLTriangulation(bool force)
         stl_vertices_xyz.push_back(SPoint3(gp.x(), gp.y(), gp.z()));
       }
     }
-    for(int i = 0; i < nu - 1; i++){
-      for(int j = 0; j < nv - 1; j++){
+    for(int i = 0; i < nu - 1; i++) {
+      for(int j = 0; j < nv - 1; j++) {
         stl_triangles.push_back(i * nv + j);
         stl_triangles.push_back((i + 1) * nv + j);
         stl_triangles.push_back((i + 1) * nv + j + 1);
@@ -1307,7 +1337,7 @@ bool GFace::buildSTLTriangulation(bool force)
 
 bool GFace::fillVertexArray(bool force)
 {
-  if(va_geom_triangles){
+  if(va_geom_triangles) {
     if(force)
       delete va_geom_triangles;
     else
@@ -1321,8 +1351,8 @@ bool GFace::fillVertexArray(bool force)
   unsigned int c = CTX::instance()->color.geom.surface;
   unsigned int col[4] = {c, c, c, c};
   if(stl_vertices_xyz.size() &&
-     (stl_vertices_xyz.size() == stl_normals.size())){
-    for (unsigned int i = 0; i < stl_triangles.size(); i += 3){
+     (stl_vertices_xyz.size() == stl_normals.size())) {
+    for(unsigned int i = 0; i < stl_triangles.size(); i += 3) {
       SPoint3 &p1(stl_vertices_xyz[stl_triangles[i]]);
       SPoint3 &p2(stl_vertices_xyz[stl_triangles[i + 1]]);
       SPoint3 &p3(stl_vertices_xyz[stl_triangles[i + 2]]);
@@ -1335,8 +1365,8 @@ bool GFace::fillVertexArray(bool force)
       va_geom_triangles->add(x, y, z, n, col);
     }
   }
-  else if(stl_vertices_uv.size()){
-    for (unsigned int i = 0; i < stl_triangles.size(); i += 3){
+  else if(stl_vertices_uv.size()) {
+    for(unsigned int i = 0; i < stl_triangles.size(); i += 3) {
       SPoint2 &p1(stl_vertices_uv[stl_triangles[i]]);
       SPoint2 &p2(stl_vertices_uv[stl_triangles[i + 1]]);
       SPoint2 &p3(stl_vertices_uv[stl_triangles[i + 2]]);
@@ -1357,28 +1387,29 @@ bool GFace::fillVertexArray(bool force)
 int GFace::genusGeom() const
 {
   int nSeams = 0;
-  std::set<GEdge*> single_seams;
-  for (std::vector<GEdge*>::const_iterator it = l_edges.begin();
-       it != l_edges.end(); ++it){
-    if ((*it)->isSeam(this)){
+  std::set<GEdge *> single_seams;
+  for(std::vector<GEdge *>::const_iterator it = l_edges.begin();
+      it != l_edges.end(); ++it) {
+    if((*it)->isSeam(this)) {
       nSeams++;
-      std::set<GEdge*>::iterator it2 = single_seams.find(*it);
-      if (it2 != single_seams.end()) single_seams.erase(it2);
-      else single_seams.insert(*it);
+      std::set<GEdge *>::iterator it2 = single_seams.find(*it);
+      if(it2 != single_seams.end())
+        single_seams.erase(it2);
+      else
+        single_seams.insert(*it);
     }
   }
   return nSeams - single_seams.size();
 }
 
-bool GFace::fillPointCloud(double maxDist,
-			   std::vector<SPoint3> *points,
-			   std::vector<SPoint2> *uvpoints,
+bool GFace::fillPointCloud(double maxDist, std::vector<SPoint3> *points,
+                           std::vector<SPoint2> *uvpoints,
                            std::vector<SVector3> *normals)
 {
   if(!points) return false;
 
-  if(buildSTLTriangulation() && stl_vertices_uv.size()){
-    for(unsigned int i = 0; i < stl_triangles.size(); i += 3){
+  if(buildSTLTriangulation() && stl_vertices_uv.size()) {
+    for(unsigned int i = 0; i < stl_triangles.size(); i += 3) {
       SPoint2 &p0(stl_vertices_uv[stl_triangles[i]]);
       SPoint2 &p1(stl_vertices_uv[stl_triangles[i + 1]]);
       SPoint2 &p2(stl_vertices_uv[stl_triangles[i + 2]]);
@@ -1386,33 +1417,33 @@ bool GFace::fillPointCloud(double maxDist,
       GPoint gp1 = point(p1);
       GPoint gp2 = point(p2);
       double maxEdge = std::max(gp0.distance(gp1),
-				std::max(gp1.distance(gp2), gp2.distance(gp0)));
+                                std::max(gp1.distance(gp2), gp2.distance(gp0)));
       int N = (int)(maxEdge / maxDist);
-      for(double u = 0.; u < 1.; u += 1. / N){
-	for(double v = 0.; v < 1 - u; v += 1. / N){
-	  SPoint2 p = p0 * (1. - u - v) + p1 * u + p2 * v;
-	  GPoint gp(point(p));
-	  points->push_back(SPoint3(gp.x(), gp.y(), gp.z()));
-	  if(uvpoints) uvpoints->push_back(p);
-	  if(normals) normals->push_back(normal(p));
-	}
+      for(double u = 0.; u < 1.; u += 1. / N) {
+        for(double v = 0.; v < 1 - u; v += 1. / N) {
+          SPoint2 p = p0 * (1. - u - v) + p1 * u + p2 * v;
+          GPoint gp(point(p));
+          points->push_back(SPoint3(gp.x(), gp.y(), gp.z()));
+          if(uvpoints) uvpoints->push_back(p);
+          if(normals) normals->push_back(normal(p));
+        }
       }
     }
   }
   else {
-    int N = 1000;//(int)(maxDX / maxDist);
+    int N = 1000; //(int)(maxDX / maxDist);
     Range<double> b1 = parBounds(0);
     Range<double> b2 = parBounds(1);
     for(int i = 0; i < N; i++) {
       for(int j = 0; j < N; j++) {
-	double u = (double)i / (N - 1);
-	double v = (double)j / (N - 1);
-	double t1 = b1.low() + u * (b1.high() - b1.low());
-	double t2 = b2.low() + v * (b2.high() - b2.low());
-	GPoint gp = point(t1, t2);
-	points->push_back(SPoint3(gp.x(), gp.y(), gp.z()));
-	if(uvpoints) uvpoints->push_back(SPoint2(t1, t2));
-	if(normals) normals->push_back(normal(SPoint2(t1, t2)));
+        double u = (double)i / (N - 1);
+        double v = (double)j / (N - 1);
+        double t1 = b1.low() + u * (b1.high() - b1.low());
+        double t2 = b2.low() + v * (b2.high() - b2.low());
+        GPoint gp = point(t1, t2);
+        points->push_back(SPoint3(gp.x(), gp.y(), gp.z()));
+        if(uvpoints) uvpoints->push_back(SPoint2(t1, t2));
+        if(normals) normals->push_back(normal(SPoint2(t1, t2)));
       }
     }
   }
@@ -1421,25 +1452,25 @@ bool GFace::fillPointCloud(double maxDist,
 
 #if defined(HAVE_MESH)
 
-static void meshCompound(GFace* gf, bool verbose)
+static void meshCompound(GFace *gf, bool verbose)
 {
   discreteFace *df = new discreteFace(gf->model(), gf->tag() + 100000);
 
-  std::vector< GFace* > triangles_tag;
-  std::vector< SPoint2 > triangles_uv;
+  std::vector<GFace *> triangles_tag;
+  std::vector<SPoint2> triangles_uv;
 
-  for (unsigned int i = 0; i < gf->_compound.size(); i++){
-    GFace *c = (GFace*)gf->_compound[i];
+  for(unsigned int i = 0; i < gf->_compound.size(); i++) {
+    GFace *c = (GFace *)gf->_compound[i];
     df->triangles.insert(df->triangles.end(), c->triangles.begin(),
-			 c->triangles.end());
+                         c->triangles.end());
     df->mesh_vertices.insert(df->mesh_vertices.end(), c->mesh_vertices.begin(),
-			     c->mesh_vertices.end());
-    for (unsigned int j=0;j<c->triangles.size();j++){
+                             c->mesh_vertices.end());
+    for(unsigned int j = 0; j < c->triangles.size(); j++) {
       triangles_tag.push_back(c);
-      for (int k = 0; k < 3; k++){
-	SPoint2 param;
-	reparamMeshVertexOnFace(c->triangles[j]->getVertex(k), c, param);
-	triangles_uv.push_back(param);
+      for(int k = 0; k < 3; k++) {
+        SPoint2 param;
+        reparamMeshVertexOnFace(c->triangles[j]->getVertex(k), c, param);
+        triangles_uv.push_back(param);
       }
     }
     c->triangles.clear();
@@ -1449,26 +1480,26 @@ static void meshCompound(GFace* gf, bool verbose)
   df->createGeometry();
   df->mesh(verbose);
 
-  for (GFace::size_type i = 0; i < df->mesh_vertices.size(); i++){
-    double u,v;
+  for(GFace::size_type i = 0; i < df->mesh_vertices.size(); i++) {
+    double u, v;
     df->mesh_vertices[i]->getParameter(0, u);
     df->mesh_vertices[i]->getParameter(1, v);
-    double U,V;
+    double U, V;
     int position = df->trianglePosition(u, v, U, V);
     if(position != -1) {
       triangles_tag[position]->mesh_vertices.push_back(df->mesh_vertices[i]);
       df->mesh_vertices[i]->setEntity(triangles_tag[position]);
-      if (0 && triangles_tag[position]->geomType() != GEntity::DiscreteSurface){
-	SPoint2 p0 = triangles_uv[3*position + 0];
-	SPoint2 p1 = triangles_uv[3*position + 1];
-	SPoint2 p2 = triangles_uv[3*position + 2];
-	SPoint2 p = p0 *(1-U-V) + p1 * U + p2 * V;
-	GPoint gp = triangles_tag[position]->point(p);
-	df->mesh_vertices[i]->setParameter(0,p.x());
-	df->mesh_vertices[i]->setParameter(1,p.y());
-	df->mesh_vertices[i]->x() = gp.x();
-	df->mesh_vertices[i]->y() = gp.y();
-	df->mesh_vertices[i]->z() = gp.z();
+      if(0 && triangles_tag[position]->geomType() != GEntity::DiscreteSurface) {
+        SPoint2 p0 = triangles_uv[3 * position + 0];
+        SPoint2 p1 = triangles_uv[3 * position + 1];
+        SPoint2 p2 = triangles_uv[3 * position + 2];
+        SPoint2 p = p0 * (1 - U - V) + p1 * U + p2 * V;
+        GPoint gp = triangles_tag[position]->point(p);
+        df->mesh_vertices[i]->setParameter(0, p.x());
+        df->mesh_vertices[i]->setParameter(1, p.y());
+        df->mesh_vertices[i]->x() = gp.x();
+        df->mesh_vertices[i]->y() = gp.y();
+        df->mesh_vertices[i]->z() = gp.z();
       }
     }
     else {
@@ -1477,15 +1508,16 @@ static void meshCompound(GFace* gf, bool verbose)
     }
   }
 
-  for (GFace::size_type i = 0; i < df->triangles.size(); i++){
+  for(GFace::size_type i = 0; i < df->triangles.size(); i++) {
     MTriangle *t = df->triangles[i];
-    if (t->getVertex(0)->onWhat()->dim() == 2)
-      ((GFace*)t->getVertex(0)->onWhat())->triangles.push_back(t);
-    else if (t->getVertex(1)->onWhat()->dim() == 2)
-      ((GFace*)t->getVertex(1)->onWhat())->triangles.push_back(t);
-    else if (t->getVertex(2)->onWhat()->dim() == 2)
-      ((GFace*)t->getVertex(2)->onWhat())->triangles.push_back(t);
-    else gf->triangles.push_back(t); // FIXME could be better!
+    if(t->getVertex(0)->onWhat()->dim() == 2)
+      ((GFace *)t->getVertex(0)->onWhat())->triangles.push_back(t);
+    else if(t->getVertex(1)->onWhat()->dim() == 2)
+      ((GFace *)t->getVertex(1)->onWhat())->triangles.push_back(t);
+    else if(t->getVertex(2)->onWhat()->dim() == 2)
+      ((GFace *)t->getVertex(2)->onWhat())->triangles.push_back(t);
+    else
+      gf->triangles.push_back(t); // FIXME could be better!
   }
   // gf->triangles = df->triangles;
   df->triangles.clear();
@@ -1499,20 +1531,20 @@ void GFace::mesh(bool verbose)
 #if defined(HAVE_MESH)
   meshGFace mesher;
   mesher(this, verbose);
-  if(_compound.size()){ // Some faces are meshed together
-    if(_compound[0] == this){ // I'm the one that makes the compound job
+  if(_compound.size()) { // Some faces are meshed together
+    if(_compound[0] == this) { // I'm the one that makes the compound job
       bool ok = true;
-      for(unsigned int i = 0; i < _compound.size(); i++){
-	GFace *gf = (GFace*)_compound[i];
-	ok &= (gf->meshStatistics.status == GFace::DONE);
+      for(unsigned int i = 0; i < _compound.size(); i++) {
+        GFace *gf = (GFace *)_compound[i];
+        ok &= (gf->meshStatistics.status == GFace::DONE);
       }
-      if(!ok){
+      if(!ok) {
         meshStatistics.status = GFace::PENDING;
       }
-      else{
-	meshCompound(this, verbose);
+      else {
+        meshCompound(this, verbose);
         meshStatistics.status = GFace::DONE;
-	return;
+        return;
       }
     }
   }
@@ -1522,24 +1554,24 @@ void GFace::mesh(bool verbose)
 void GFace::lloyd(int nbiter, int infn)
 {
 #if defined(HAVE_MESH) && defined(HAVE_BFGS)
-  smoothing s = smoothing(nbiter,infn);
+  smoothing s = smoothing(nbiter, infn);
   s.optimize_face(this);
 #endif
 }
 
-void GFace::replaceEdges(std::vector<GEdge*> &new_edges)
+void GFace::replaceEdges(std::vector<GEdge *> &new_edges)
 {
-  std::vector<GEdge*>::iterator it  = l_edges.begin();
-  std::vector<GEdge*>::iterator it2 = new_edges.begin();
+  std::vector<GEdge *>::iterator it = l_edges.begin();
+  std::vector<GEdge *>::iterator it2 = new_edges.begin();
   std::vector<int>::iterator it3 = l_dirs.begin();
 
   std::vector<int> newdirs;
   newdirs.reserve(l_edges.size());
 
-  for ( ; it != l_edges.end(); ++it, ++it2, ++it3){
+  for(; it != l_edges.end(); ++it, ++it2, ++it3) {
     (*it)->delFace(this);
     (*it2)->addFace(this);
-    if ((*it2)->getBeginVertex() == (*it)->getBeginVertex())
+    if((*it2)->getBeginVertex() == (*it)->getBeginVertex())
       newdirs.push_back(*it3);
     else
       newdirs.push_back(-(*it3));
@@ -1550,28 +1582,24 @@ void GFace::replaceEdges(std::vector<GEdge*> &new_edges)
 
 void GFace::moveToValidRange(SPoint2 &pt) const
 {
-  for(int i = 0; i < 2; i++){
-    if(periodic(i)){
+  for(int i = 0; i < 2; i++) {
+    if(periodic(i)) {
       Range<double> range = parBounds(i);
-      double tol = 1e-6*(range.high()-range.low());
-      if(pt[i] < range.low()-tol)
-	pt[i] += period(i);
-      if(pt[i] > range.high()+tol)
-	pt[i] -= period(i);
-      if(pt[i] < range.low())
-	pt[i] = range.low();
-      if(pt[i] > range.high())
-	pt[i] = range.high();
+      double tol = 1e-6 * (range.high() - range.low());
+      if(pt[i] < range.low() - tol) pt[i] += period(i);
+      if(pt[i] > range.high() + tol) pt[i] -= period(i);
+      if(pt[i] < range.low()) pt[i] = range.low();
+      if(pt[i] > range.high()) pt[i] = range.high();
     }
   }
 }
 
 void GFace::relocateMeshVertices()
 {
-  for(unsigned int i = 0; i < mesh_vertices.size(); i++){
+  for(unsigned int i = 0; i < mesh_vertices.size(); i++) {
     MVertex *v = mesh_vertices[i];
     double u0 = 0., u1 = 0.;
-    if(v->getParameter(0, u0) && v->getParameter(1, u1)){
+    if(v->getParameter(0, u0) && v->getParameter(1, u1)) {
       GPoint p = point(u0, u1);
       v->x() = p.x();
       v->y() = p.y();
@@ -1580,112 +1608,114 @@ void GFace::relocateMeshVertices()
   }
 }
 
-void GFace::setMeshMaster(GFace* master, const std::vector<double>& tfo)
+void GFace::setMeshMaster(GFace *master, const std::vector<double> &tfo)
 {
-  std::vector<GEdge*>::const_iterator eIter;
-  std::list<GVertex*>::iterator vIter;
+  std::vector<GEdge *>::const_iterator eIter;
+  std::list<GVertex *>::iterator vIter;
 
   Msg::Info("Setting mesh master using transformation ");
 
-  // list all vertices and construct vertex to edge correspondence for local edge
+  // list all vertices and construct vertex to edge correspondence for local
+  // edge
 
-  std::set<GVertex*> l_vertices;
-  std::map<std::pair<GVertex*,GVertex*>,GEdge* > l_vtxToEdge;
+  std::set<GVertex *> l_vertices;
+  std::map<std::pair<GVertex *, GVertex *>, GEdge *> l_vtxToEdge;
 
-  for (eIter=l_edges.begin();eIter!=l_edges.end(); ++eIter) {
-    GVertex* v0 = (*eIter)->getBeginVertex();
-    GVertex* v1 = (*eIter)->getEndVertex();
+  for(eIter = l_edges.begin(); eIter != l_edges.end(); ++eIter) {
+    GVertex *v0 = (*eIter)->getBeginVertex();
+    GVertex *v1 = (*eIter)->getEndVertex();
     l_vertices.insert(v0);
     l_vertices.insert(v1);
-    l_vtxToEdge[std::make_pair(v0,v1)] = (*eIter);
+    l_vtxToEdge[std::make_pair(v0, v1)] = (*eIter);
   }
 
-  for (eIter = embedded_edges.begin(); eIter != embedded_edges.end(); ++eIter) {
-    GVertex* v0 = (*eIter)->getBeginVertex();
-    GVertex* v1 = (*eIter)->getEndVertex();
+  for(eIter = embedded_edges.begin(); eIter != embedded_edges.end(); ++eIter) {
+    GVertex *v0 = (*eIter)->getBeginVertex();
+    GVertex *v1 = (*eIter)->getEndVertex();
     l_vertices.insert(v0);
     l_vertices.insert(v1);
-    l_vtxToEdge[std::make_pair(v0,v1)] = (*eIter);
+    l_vtxToEdge[std::make_pair(v0, v1)] = (*eIter);
   }
 
-  l_vertices.insert(embedded_vertices.begin(),embedded_vertices.end());
+  l_vertices.insert(embedded_vertices.begin(), embedded_vertices.end());
 
   // list all vertices and vertex to edge correspondence for remote edge
 
-  std::vector<GEdge*> const& m_edges = master->edges();
-  std::set<GVertex*> m_vertices;
-  std::map<std::pair<GVertex*,GVertex*>,GEdge* > m_vtxToEdge;
-  for (eIter=m_edges.begin();eIter!=m_edges.end(); ++eIter) {
-    GVertex* v0 = (*eIter)->getBeginVertex();
-    GVertex* v1 = (*eIter)->getEndVertex();
+  std::vector<GEdge *> const &m_edges = master->edges();
+  std::set<GVertex *> m_vertices;
+  std::map<std::pair<GVertex *, GVertex *>, GEdge *> m_vtxToEdge;
+  for(eIter = m_edges.begin(); eIter != m_edges.end(); ++eIter) {
+    GVertex *v0 = (*eIter)->getBeginVertex();
+    GVertex *v1 = (*eIter)->getEndVertex();
     m_vertices.insert(v0);
     m_vertices.insert(v1);
-    m_vtxToEdge[std::make_pair(v0,v1)] = (*eIter);
+    m_vtxToEdge[std::make_pair(v0, v1)] = (*eIter);
   }
 
-  std::vector<GEdge*> const& m_embedded_edges = master->embeddedEdges();
+  std::vector<GEdge *> const &m_embedded_edges = master->embeddedEdges();
 
-  for (eIter = m_embedded_edges.begin(); eIter != m_embedded_edges.end(); eIter++) {
-    GVertex* v0 = (*eIter)->getBeginVertex();
-    GVertex* v1 = (*eIter)->getEndVertex();
+  for(eIter = m_embedded_edges.begin(); eIter != m_embedded_edges.end();
+      eIter++) {
+    GVertex *v0 = (*eIter)->getBeginVertex();
+    GVertex *v1 = (*eIter)->getEndVertex();
     m_vertices.insert(v0);
     m_vertices.insert(v1);
-    m_vtxToEdge[std::make_pair(v0,v1)] = (*eIter);
+    m_vtxToEdge[std::make_pair(v0, v1)] = (*eIter);
   }
 
-  std::list<GVertex*> m_embedded_vertices = master->embeddedVertices();
+  std::list<GVertex *> m_embedded_vertices = master->embeddedVertices();
   m_vertices.insert(m_embedded_vertices.begin(), m_embedded_vertices.end());
 
   // check topological correspondence
 
-  if (l_vertices.size() != m_vertices.size()) {
-    Msg::Error("Periodic connection specified between topologically "
-               "incompatible surfaces %d and %d (that have %d vs %d model vertices)",
-               master->tag(),tag(),l_vertices.size(),m_vertices.size());
+  if(l_vertices.size() != m_vertices.size()) {
+    Msg::Error(
+      "Periodic connection specified between topologically "
+      "incompatible surfaces %d and %d (that have %d vs %d model vertices)",
+      master->tag(), tag(), l_vertices.size(), m_vertices.size());
     return;
   }
 
-  if (l_vtxToEdge.size() != m_vtxToEdge.size()) {
-    Msg::Error("Periodic connection specified between topologically "
-               "incompatible surfaces %d and %d (that have %d vs %d model edges)",
-               master->tag(),tag(),l_vtxToEdge.size(),m_vtxToEdge.size());
+  if(l_vtxToEdge.size() != m_vtxToEdge.size()) {
+    Msg::Error(
+      "Periodic connection specified between topologically "
+      "incompatible surfaces %d and %d (that have %d vs %d model edges)",
+      master->tag(), tag(), l_vtxToEdge.size(), m_vtxToEdge.size());
     return;
   }
 
   // compute corresponding vertices
 
-  std::map<GVertex*,GVertex*> gVertexCounterparts;
-
-  std::set<GVertex*>::iterator mvIter;
-  for (mvIter=m_vertices.begin();mvIter!=m_vertices.end(); ++mvIter) {
+  std::map<GVertex *, GVertex *> gVertexCounterparts;
 
-    GVertex* m_vertex = *mvIter;
+  std::set<GVertex *>::iterator mvIter;
+  for(mvIter = m_vertices.begin(); mvIter != m_vertices.end(); ++mvIter) {
+    GVertex *m_vertex = *mvIter;
 
-    SPoint3 xyzOri((*mvIter)->x(),(*mvIter)->y(),(*mvIter)->z());
-    SPoint3 xyzTfo(0,0,0);
+    SPoint3 xyzOri((*mvIter)->x(), (*mvIter)->y(), (*mvIter)->z());
+    SPoint3 xyzTfo(0, 0, 0);
 
     int idx = 0;
-    for (int i=0;i<3;i++) {
-      for (int j=0;j<3;j++) xyzTfo[i] += xyzOri[j] * tfo[idx++];
+    for(int i = 0; i < 3; i++) {
+      for(int j = 0; j < 3; j++) xyzTfo[i] += xyzOri[j] * tfo[idx++];
       xyzTfo[i] += tfo[idx++];
     }
 
-    GVertex* l_vertex = NULL;
+    GVertex *l_vertex = NULL;
 
     double dist_min = 1.e22;
-    std::set<GVertex*>::iterator lvIter = l_vertices.begin();
-    for (;lvIter!=l_vertices.end(); ++lvIter) {
-
-      SPoint3 xyz((*lvIter)->x(),(*lvIter)->y(),(*lvIter)->z());
+    std::set<GVertex *>::iterator lvIter = l_vertices.begin();
+    for(; lvIter != l_vertices.end(); ++lvIter) {
+      SPoint3 xyz((*lvIter)->x(), (*lvIter)->y(), (*lvIter)->z());
       SVector3 dist = xyz - xyzTfo;
-      dist_min = std::min(dist_min,dist.norm());
-      if (dist.norm() < CTX::instance()->geom.tolerance * CTX::instance()->lc) {
+      dist_min = std::min(dist_min, dist.norm());
+      if(dist.norm() < CTX::instance()->geom.tolerance * CTX::instance()->lc) {
         l_vertex = *lvIter;
         break;
       }
     }
 
-    if (l_vertex==NULL) {
+    if(l_vertex == NULL) {
       Msg::Error("Was not able to find corresponding node %d "
                  "for periodic connection of surface %d to %d "
                  "(min distance is %g with a tolerance of %g)",
@@ -1696,56 +1726,55 @@ void GFace::setMeshMaster(GFace* master, const std::vector<double>& tfo)
     gVertexCounterparts[l_vertex] = m_vertex;
   }
 
-  if (gVertexCounterparts.size() != m_vertices.size()) {
+  if(gVertexCounterparts.size() != m_vertices.size()) {
     Msg::Error("Could not find all node correspondances "
                "for the periodic connection from surface %d to %d",
-               master->tag(),tag());
+               master->tag(), tag());
     return;
   }
 
   // construct edge correspondence and update the edge masters
 
-  std::map<GEdge*,std::pair<GEdge*,int> > gEdgeCounterparts;
-
-  std::map<std::pair<GVertex*,GVertex*>,GEdge*>::iterator lv2eIter;
-  for (lv2eIter=l_vtxToEdge.begin();lv2eIter!=l_vtxToEdge.end();lv2eIter++) {
+  std::map<GEdge *, std::pair<GEdge *, int> > gEdgeCounterparts;
 
-    std::pair<GVertex*,GVertex*> lPair = lv2eIter->first;
-    GEdge* localEdge = lv2eIter->second;
+  std::map<std::pair<GVertex *, GVertex *>, GEdge *>::iterator lv2eIter;
+  for(lv2eIter = l_vtxToEdge.begin(); lv2eIter != l_vtxToEdge.end();
+      lv2eIter++) {
+    std::pair<GVertex *, GVertex *> lPair = lv2eIter->first;
+    GEdge *localEdge = lv2eIter->second;
 
-    std::pair<GVertex*,GVertex*> mPair(gVertexCounterparts[lPair.first],
-                                       gVertexCounterparts[lPair.second]);
+    std::pair<GVertex *, GVertex *> mPair(gVertexCounterparts[lPair.first],
+                                          gVertexCounterparts[lPair.second]);
     int sign = 1;
-    std::map<std::pair<GVertex*,GVertex*>,GEdge*>::iterator mv2eIter = m_vtxToEdge.find(mPair);
-    if (mv2eIter == m_vtxToEdge.end()) {
+    std::map<std::pair<GVertex *, GVertex *>, GEdge *>::iterator mv2eIter =
+      m_vtxToEdge.find(mPair);
+    if(mv2eIter == m_vtxToEdge.end()) {
       sign *= -1;
-      std::pair<GVertex*,GVertex*> backward(mPair.second,mPair.first);
+      std::pair<GVertex *, GVertex *> backward(mPair.second, mPair.first);
       mv2eIter = m_vtxToEdge.find(backward);
     }
 
-    if (mv2eIter == m_vtxToEdge.end()) {
+    if(mv2eIter == m_vtxToEdge.end()) {
       Msg::Error("Could not find periodic copy of edge %d-%d "
                  "(corresponding to vertices %d %d) in face %d",
-                 lPair.first->tag(),lPair.second->tag(),
-                 mPair.first->tag(),mPair.second->tag(),
-                 master->tag());
+                 lPair.first->tag(), lPair.second->tag(), mPair.first->tag(),
+                 mPair.second->tag(), master->tag());
       return;
     }
-    GEdge* masterEdge = mv2eIter->second;
+    GEdge *masterEdge = mv2eIter->second;
 
-    if (masterEdge->meshMaster() != localEdge) {
-      localEdge->setMeshMaster(masterEdge,tfo);
-      Msg::Info("Setting edge master %d - %d",
-                localEdge->tag(),
+    if(masterEdge->meshMaster() != localEdge) {
+      localEdge->setMeshMaster(masterEdge, tfo);
+      Msg::Info("Setting edge master %d - %d", localEdge->tag(),
                 masterEdge->tag());
     }
-    gEdgeCounterparts[localEdge] = std::make_pair(masterEdge,sign);
+    gEdgeCounterparts[localEdge] = std::make_pair(masterEdge, sign);
   }
 
   // complete the information at the edge level
   edgeCounterparts = gEdgeCounterparts;
   vertexCounterparts = gVertexCounterparts;
-  GEntity::setMeshMaster(master,tfo);
+  GEntity::setMeshMaster(master, tfo);
 }
 
 inline double myAngle(const SVector3 &a, const SVector3 &b, const SVector3 &d)
@@ -1760,14 +1789,12 @@ struct myPlane {
   SVector3 n;
   double a;
   // nx x + ny y + nz z + a = 0
-  myPlane(const SPoint3 &_p, const SVector3 &_n)
-    : p(_p)
-    , n(_n)
+  myPlane(const SPoint3 &_p, const SVector3 &_n) : p(_p), n(_n)
   {
     n.normalize();
-    a = -(n.x()*p.x()+n.y()*p.y()+n.z()*p.z());
+    a = -(n.x() * p.x() + n.y() * p.y() + n.z() * p.z());
   }
-  double eval (double x, double y, double z)
+  double eval(double x, double y, double z)
   {
     return n.x() * x + n.y() * y + n.z() * z + a;
   }
@@ -1776,11 +1803,11 @@ struct myPlane {
 struct myLine {
   SPoint3 p;
   SVector3 t;
-  myLine() : p(0,0,0) , t (0,0,1) {}
+  myLine() : p(0, 0, 0), t(0, 0, 1) {}
   myLine(myPlane &p1, myPlane &p2)
   {
     t = crossprod(p1.n, p2.n);
-    if (t.norm() == 0.0){
+    if(t.norm() == 0.0) {
       Msg::Error("parallel planes do not intersect");
     }
     else
@@ -1788,55 +1815,58 @@ struct myLine {
     // find a point, assume z = 0
     double a[2][2] = {{p1.n.x(), p1.n.y()}, {p2.n.x(), p2.n.y()}};
     double b[2] = {-p1.a, -p2.a}, x[2];
-    if (!sys2x2(a, b, x)){
+    if(!sys2x2(a, b, x)) {
       // assume x = 0
       double az[2][2] = {{p1.n.y(), p1.n.z()}, {p2.n.y(), p2.n.z()}};
       double bz[2] = {-p1.a, -p2.a};
-      if (!sys2x2(az, bz, x)){
-	// assume y = 0
-	double ay[2][2] = {{p1.n.x(), p1.n.z()}, {p2.n.x(), p2.n.z()}};
-	double by[2] = {-p1.a, -p2.a};
-	if (!sys2x2(ay,by,x)){
-	  Msg::Error("parallel planes do not intersect");
-	}
-	else {
-	  p = SPoint3(x[0], 0., x[1]);
-	}
+      if(!sys2x2(az, bz, x)) {
+        // assume y = 0
+        double ay[2][2] = {{p1.n.x(), p1.n.z()}, {p2.n.x(), p2.n.z()}};
+        double by[2] = {-p1.a, -p2.a};
+        if(!sys2x2(ay, by, x)) {
+          Msg::Error("parallel planes do not intersect");
+        }
+        else {
+          p = SPoint3(x[0], 0., x[1]);
+        }
       }
-      else{
-	p = SPoint3(0., x[0], x[1]);
+      else {
+        p = SPoint3(0., x[0], x[1]);
       }
     }
-    else{
+    else {
       p = SPoint3(x[0], x[1], 0.);
     }
   }
-  SPoint3 orthogonalProjection (SPoint3 &a)
+  SPoint3 orthogonalProjection(SPoint3 &a)
   {
     // (x - a) * t = 0 -->
     // x = p + u t --> (p + ut - a) * t = 0 --> u = (a-p) * t
     const double u = dot(a - p, t);
-    return SPoint3(p.x() + t.x() * u,p.y() + t.y() * u,p.z() + t.z() * u);
+    return SPoint3(p.x() + t.x() * u, p.y() + t.y() * u, p.z() + t.z() * u);
   }
 };
 
-void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
+void GFace::setMeshMaster(GFace *master, const std::map<int, int> &edgeCopies)
 {
-  std::map<GVertex*,GVertex*> vs2vt;
+  std::map<GVertex *, GVertex *> vs2vt;
 
-  for (std::vector<GEdge*>::iterator it = l_edges.begin(); it != l_edges.end(); ++it){
+  for(std::vector<GEdge *>::iterator it = l_edges.begin(); it != l_edges.end();
+      ++it) {
     // slave edge
-    GEdge* le = *it;
+    GEdge *le = *it;
 
     int sign = 1;
-    std::map<int,int>::const_iterator adnksd = edgeCopies.find(le->tag());
+    std::map<int, int>::const_iterator adnksd = edgeCopies.find(le->tag());
     int source_e;
-    if (adnksd != edgeCopies.end()) source_e = adnksd->second;
-    else{
+    if(adnksd != edgeCopies.end())
+      source_e = adnksd->second;
+    else {
       sign = -1;
       adnksd = edgeCopies.find(-(*it)->tag());
-      if(adnksd != edgeCopies.end()) source_e = adnksd->second;
-      else{
+      if(adnksd != edgeCopies.end())
+        source_e = adnksd->second;
+      else {
         Msg::Error("Could not find edge counterpart %d in slave surface %d",
                    (*it)->tag(), master->tag());
         return;
@@ -1846,13 +1876,13 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
     // master edge
     GEdge *me = master->model()->getEdgeByTag(abs(source_e));
 
-    if (source_e * sign > 0){
+    if(source_e * sign > 0) {
       vs2vt[me->getBeginVertex()] = le->getBeginVertex();
-      vs2vt[me->getEndVertex()]   = le->getEndVertex();
+      vs2vt[me->getEndVertex()] = le->getEndVertex();
     }
     else {
       vs2vt[me->getBeginVertex()] = le->getEndVertex();
-      vs2vt[me->getEndVertex()]   = le->getBeginVertex();
+      vs2vt[me->getEndVertex()] = le->getBeginVertex();
     }
   }
 
@@ -1862,44 +1892,44 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
   SVector3 DX;
 
   int count = 0;
-  for (std::map<GVertex*, GVertex*>::iterator it = vs2vt.begin();
-       it != vs2vt.end() ; ++it){
+  for(std::map<GVertex *, GVertex *>::iterator it = vs2vt.begin();
+      it != vs2vt.end(); ++it) {
     GVertex *vs = it->first;
     GVertex *vt = it->second;
-    if (count == 0)
-      DX = SVector3(vt->x()-vs->x(),vt->y()-vs->y(),vt->z()-vs->z());
+    if(count == 0)
+      DX = SVector3(vt->x() - vs->x(), vt->y() - vs->y(), vt->z() - vs->z());
     else {
-      SVector3 DX2(vt->x()-vs->x(),vt->y()-vs->y(),vt->z()-vs->z());
+      SVector3 DX2(vt->x() - vs->x(), vt->y() - vs->y(), vt->z() - vs->z());
       SVector3 DDX(DX2 - DX);
-      if (DDX.norm() > DX.norm() * 1.e-5) translation = false;
+      if(DDX.norm() > DX.norm() * 1.e-5) translation = false;
     }
-    count ++;
+    count++;
   }
 
   std::vector<double> tfo(16);
 
-  if (translation) {
-    Msg::Info("Periodic mesh translation found between %d and %d: dx = (%g,%g,%g)",
-              tag(),master->tag(),DX.x(), DX.y(), DX.z());
+  if(translation) {
+    Msg::Info(
+      "Periodic mesh translation found between %d and %d: dx = (%g,%g,%g)",
+      tag(), master->tag(), DX.x(), DX.y(), DX.z());
 
-    for (size_t i=0;i<16;i++) tfo[i] = 0;
-    for (size_t i=0;i<4;i++)  tfo[i*4+i] = 1;
-    tfo[3]  = DX.x();
-    tfo[7]  = DX.y();
+    for(size_t i = 0; i < 16; i++) tfo[i] = 0;
+    for(size_t i = 0; i < 4; i++) tfo[i * 4 + i] = 1;
+    tfo[3] = DX.x();
+    tfo[7] = DX.y();
     tfo[11] = DX.z();
   }
 
   else {
-
     bool rotation = false;
     myLine LINE;
-    double ANGLE=0;
+    double ANGLE = 0;
 
     count = 0;
     rotation = true;
     std::vector<SPoint3> mps, mpt;
-    for (std::map<GVertex*, GVertex*>::iterator it = vs2vt.begin();
-         it != vs2vt.end() ; ++it){
+    for(std::map<GVertex *, GVertex *>::iterator it = vs2vt.begin();
+        it != vs2vt.end(); ++it) {
       GVertex *vs = it->first;
       GVertex *vt = it->second;
       mps.push_back(SPoint3(vs->x(), vs->y(), vs->z()));
@@ -1909,18 +1939,18 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
     computeMeanPlaneSimple(mps, mean_source);
     computeMeanPlaneSimple(mpt, mean_target);
 
-    myPlane PLANE_SOURCE(SPoint3(mean_source.x,mean_source.y,mean_source.z),
-                         SVector3(mean_source.a,mean_source.b,mean_source.c));
-    myPlane PLANE_TARGET(SPoint3(mean_target.x,mean_target.y,mean_target.z),
-                         SVector3(mean_target.a,mean_target.b,mean_target.c));
+    myPlane PLANE_SOURCE(SPoint3(mean_source.x, mean_source.y, mean_source.z),
+                         SVector3(mean_source.a, mean_source.b, mean_source.c));
+    myPlane PLANE_TARGET(SPoint3(mean_target.x, mean_target.y, mean_target.z),
+                         SVector3(mean_target.a, mean_target.b, mean_target.c));
 
     LINE = myLine(PLANE_SOURCE, PLANE_TARGET);
 
     // LINE is the axis of rotation
     // let us compute the angle of rotation
     count = 0;
-    for (std::map<GVertex*, GVertex*>::iterator it = vs2vt.begin();
-         it != vs2vt.end(); ++it){
+    for(std::map<GVertex *, GVertex *>::iterator it = vs2vt.begin();
+        it != vs2vt.end(); ++it) {
       GVertex *vs = it->first;
       GVertex *vt = it->second;
       // project both points on the axis: that should be the same point !
@@ -1930,18 +1960,18 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
       SPoint3 p_pt = LINE.orthogonalProjection(pt);
       SVector3 dist1 = ps - pt;
       SVector3 dist2 = p_ps - p_pt;
-      if (dist1.norm() > CTX::instance()->geom.tolerance){
-        if (dist2.norm() > 1.e-8 * dist1.norm()){
+      if(dist1.norm() > CTX::instance()->geom.tolerance) {
+        if(dist2.norm() > 1.e-8 * dist1.norm()) {
           rotation = false;
         }
         SVector3 t1 = ps - p_ps;
         SVector3 t2 = pt - p_pt;
-        if (t1.norm() > 1.e-8 * dist1.norm()){
-          if (count == 0)
+        if(t1.norm() > 1.e-8 * dist1.norm()) {
+          if(count == 0)
             ANGLE = myAngle(t1, t2, LINE.t);
           else {
             double ANGLE2 = myAngle(t1, t2, LINE.t);
-            if (fabs (ANGLE2 - ANGLE) > 1.e-8){
+            if(fabs(ANGLE2 - ANGLE) > 1.e-8) {
               rotation = false;
             }
           }
@@ -1950,34 +1980,35 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
       }
     }
 
-    if (rotation){
-      Msg::Info("Periodic mesh rotation found: axis (%g,%g,%g) point (%g %g %g) angle %g",
-                LINE.t.x(), LINE.t.y(), LINE.t.z(), LINE.p.x(), LINE.p.y(), LINE.p.z(),
-                ANGLE * 180 / M_PI);
+    if(rotation) {
+      Msg::Info("Periodic mesh rotation found: axis (%g,%g,%g) point (%g %g "
+                "%g) angle %g",
+                LINE.t.x(), LINE.t.y(), LINE.t.z(), LINE.p.x(), LINE.p.y(),
+                LINE.p.z(), ANGLE * 180 / M_PI);
 
       double ux = LINE.t.x();
       double uy = LINE.t.y();
       double uz = LINE.t.z();
 
-      tfo[0*4+0] = cos (ANGLE) + ux*ux*(1.-cos(ANGLE));
-      tfo[0*4+1] = ux*uy*(1.-cos(ANGLE)) - uz * sin(ANGLE);
-      tfo[0*4+2] = ux*uz*(1.-cos(ANGLE)) + uy * sin(ANGLE);
+      tfo[0 * 4 + 0] = cos(ANGLE) + ux * ux * (1. - cos(ANGLE));
+      tfo[0 * 4 + 1] = ux * uy * (1. - cos(ANGLE)) - uz * sin(ANGLE);
+      tfo[0 * 4 + 2] = ux * uz * (1. - cos(ANGLE)) + uy * sin(ANGLE);
 
-      tfo[1*4+0] = ux*uy*(1.-cos(ANGLE)) + uz * sin(ANGLE);
-      tfo[1*4+1] = cos (ANGLE) + uy*uy*(1.-cos(ANGLE));
-      tfo[1*4+2] = uy*uz*(1.-cos(ANGLE)) - ux * sin(ANGLE);
+      tfo[1 * 4 + 0] = ux * uy * (1. - cos(ANGLE)) + uz * sin(ANGLE);
+      tfo[1 * 4 + 1] = cos(ANGLE) + uy * uy * (1. - cos(ANGLE));
+      tfo[1 * 4 + 2] = uy * uz * (1. - cos(ANGLE)) - ux * sin(ANGLE);
 
-      tfo[2*4+0] = ux*uz*(1.-cos(ANGLE)) - uy * sin(ANGLE);
-      tfo[2*4+1] = uy*uz*(1.-cos(ANGLE)) + ux * sin(ANGLE);
-      tfo[2*4+2] = cos (ANGLE) + uz*uz*(1.-cos(ANGLE));
+      tfo[2 * 4 + 0] = ux * uz * (1. - cos(ANGLE)) - uy * sin(ANGLE);
+      tfo[2 * 4 + 1] = uy * uz * (1. - cos(ANGLE)) + ux * sin(ANGLE);
+      tfo[2 * 4 + 2] = cos(ANGLE) + uz * uz * (1. - cos(ANGLE));
 
-      double origin[3] = {LINE.p.x(),LINE.p.y(),LINE.p.z()};
+      double origin[3] = {LINE.p.x(), LINE.p.y(), LINE.p.z()};
 
-      for (int i=0;i<3;i++) tfo[i*4+3] =  origin[i];
-      for (int i=0;i<3;i++) for (int j=0;j<3;j++) tfo[i*4+3] -= tfo[i*4+j] * origin[j];
-      for (int i=0;i<3;i++) tfo[12+i] = 0;
+      for(int i = 0; i < 3; i++) tfo[i * 4 + 3] = origin[i];
+      for(int i = 0; i < 3; i++)
+        for(int j = 0; j < 3; j++) tfo[i * 4 + 3] -= tfo[i * 4 + j] * origin[j];
+      for(int i = 0; i < 3; i++) tfo[12 + i] = 0;
       tfo[15] = 1;
-
     }
     else {
       Msg::Error("Only rotations or translations can currently be computed "
@@ -1995,62 +2026,49 @@ void GFace::setMeshMaster(GFace* master,const std::map<int,int>& edgeCopies)
 
 void GFace::addElement(int type, MElement *e)
 {
-  switch (type){
-  case TYPE_TRI:
-    addTriangle(reinterpret_cast<MTriangle*>(e));
-    break;
-  case TYPE_QUA:
-    addQuadrangle(reinterpret_cast<MQuadrangle*>(e));
-    break;
-  case TYPE_POLYG:
-    addPolygon(reinterpret_cast<MPolygon*>(e));
-    break;
-  default:
-    Msg::Error("Trying to add unsupported element in face");
+  switch(type) {
+  case TYPE_TRI: addTriangle(reinterpret_cast<MTriangle *>(e)); break;
+  case TYPE_QUA: addQuadrangle(reinterpret_cast<MQuadrangle *>(e)); break;
+  case TYPE_POLYG: addPolygon(reinterpret_cast<MPolygon *>(e)); break;
+  default: Msg::Error("Trying to add unsupported element in face");
   }
 }
 
 void GFace::removeElement(int type, MElement *e)
 {
-  switch (type){
-  case TYPE_TRI:
-    {
-      std::vector<MTriangle*>::iterator it = std::find
-        (triangles.begin(), triangles.end(), reinterpret_cast<MTriangle*>(e));
-      if(it != triangles.end()) triangles.erase(it);
-    }
-    break;
-  case TYPE_QUA:
-    {
-      std::vector<MQuadrangle*>::iterator it = std::find
-        (quadrangles.begin(), quadrangles.end(), reinterpret_cast<MQuadrangle*>(e));
-      if(it != quadrangles.end()) quadrangles.erase(it);
-    }
-    break;
-  case TYPE_POLYG:
-    {
-      std::vector<MPolygon*>::iterator it = std::find
-        (polygons.begin(), polygons.end(), reinterpret_cast<MPolygon*>(e));
-      if(it != polygons.end()) polygons.erase(it);
-    }
-    break;
-  default:
-    Msg::Error("Trying to remove unsupported element in face");
+  switch(type) {
+  case TYPE_TRI: {
+    std::vector<MTriangle *>::iterator it = std::find(
+      triangles.begin(), triangles.end(), reinterpret_cast<MTriangle *>(e));
+    if(it != triangles.end()) triangles.erase(it);
+  } break;
+  case TYPE_QUA: {
+    std::vector<MQuadrangle *>::iterator it =
+      std::find(quadrangles.begin(), quadrangles.end(),
+                reinterpret_cast<MQuadrangle *>(e));
+    if(it != quadrangles.end()) quadrangles.erase(it);
+  } break;
+  case TYPE_POLYG: {
+    std::vector<MPolygon *>::iterator it = std::find(
+      polygons.begin(), polygons.end(), reinterpret_cast<MPolygon *>(e));
+    if(it != polygons.end()) polygons.erase(it);
+  } break;
+  default: Msg::Error("Trying to remove unsupported element in face");
   }
 }
 
 bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
 {
-  if(triangles.front()->getTypeForMSH() == elementType){
+  if(triangles.front()->getTypeForMSH() == elementType) {
     if(ordering.size() != triangles.size()) return false;
 
     for(std::vector<int>::const_iterator it = ordering.begin();
-        it != ordering.end(); ++it){
+        it != ordering.end(); ++it) {
       if(*it < 0 || *it >= static_cast<int>(triangles.size())) return false;
     }
 
-    std::vector<MTriangle*> newTrianglesOrder(triangles.size());
-    for(unsigned int i = 0; i < ordering.size(); i++){
+    std::vector<MTriangle *> newTrianglesOrder(triangles.size());
+    for(unsigned int i = 0; i < ordering.size(); i++) {
       newTrianglesOrder[i] = triangles[ordering[i]];
     }
 #if __cplusplus >= 201103L
@@ -2062,16 +2080,16 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
     return true;
   }
 
-  if(quadrangles.front()->getTypeForMSH() == elementType){
+  if(quadrangles.front()->getTypeForMSH() == elementType) {
     if(ordering.size() != quadrangles.size()) return false;
 
     for(std::vector<int>::const_iterator it = ordering.begin();
-        it != ordering.end(); ++it){
+        it != ordering.end(); ++it) {
       if(*it < 0 || *it >= static_cast<int>(quadrangles.size())) return false;
     }
 
-    std::vector<MQuadrangle*> newQuadranglesOrder(quadrangles.size());
-    for(unsigned int i = 0; i < ordering.size(); i++){
+    std::vector<MQuadrangle *> newQuadranglesOrder(quadrangles.size());
+    for(unsigned int i = 0; i < ordering.size(); i++) {
       newQuadranglesOrder[i] = quadrangles[ordering[i]];
     }
 #if __cplusplus >= 201103L
@@ -2083,16 +2101,16 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
     return true;
   }
 
-  if(polygons.front()->getTypeForMSH() == elementType){
+  if(polygons.front()->getTypeForMSH() == elementType) {
     if(ordering.size() != polygons.size()) return false;
 
     for(std::vector<int>::const_iterator it = ordering.begin();
-        it != ordering.end(); ++it){
+        it != ordering.end(); ++it) {
       if(*it < 0 || *it >= static_cast<int>(polygons.size())) return false;
     }
 
-    std::vector<MPolygon*> newPolygonsOrder(polygons.size());
-    for(unsigned int i = 0; i < ordering.size(); i++){
+    std::vector<MPolygon *> newPolygonsOrder(polygons.size());
+    for(unsigned int i = 0; i < ordering.size(); i++) {
       newPolygonsOrder[i] = polygons[ordering[i]];
     }
 #if __cplusplus >= 201103L
@@ -2109,11 +2127,10 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
 
 void GFace::alignElementsWithMaster()
 {
-  GEntity* master = meshMaster();
-
-  if (master != this) {
+  GEntity *master = meshMaster();
 
-    std::set<MFace,Less_Face> srcFaces;
+  if(master != this) {
+    std::set<MFace, Less_Face> srcFaces;
 
     for(std::size_t i = 0; i < master->getNumMeshElements(); i++) {
       MElement *face = master->getMeshElement(i);
@@ -2125,46 +2142,40 @@ void GFace::alignElementsWithMaster()
       srcFaces.insert(MFace(vtcs));
     }
 
-    for (std::size_t i=0;i<getNumMeshElements();i++) {
-
-      MElement* face = getMeshElement(i);
-      std::vector<MVertex*> vtcs;
-      for (std::size_t j=0;j<face->getNumVertices();j++) {
-        MVertex* tv = face->getVertex(j);
+    for(std::size_t i = 0; i < getNumMeshElements(); i++) {
+      MElement *face = getMeshElement(i);
+      std::vector<MVertex *> vtcs;
+      for(std::size_t j = 0; j < face->getNumVertices(); j++) {
+        MVertex *tv = face->getVertex(j);
 
-        std::map<MVertex*,MVertex*>::iterator cIter = correspondingVertices.find(tv);
-        if (cIter != correspondingVertices.end())
-          vtcs.push_back(cIter->second);
+        std::map<MVertex *, MVertex *>::iterator cIter =
+          correspondingVertices.find(tv);
+        if(cIter != correspondingVertices.end()) vtcs.push_back(cIter->second);
       }
 
       MFace mf(vtcs);
 
-      std::set<MFace,Less_Face>::iterator sIter = srcFaces.find(mf);
+      std::set<MFace, Less_Face>::iterator sIter = srcFaces.find(mf);
 
-      if (sIter == srcFaces.end()) continue;
+      if(sIter == srcFaces.end()) continue;
 
       MFace of = *sIter;
 
       int orientation;
       bool swap;
-      mf.computeCorrespondence(of,orientation,swap);
+      mf.computeCorrespondence(of, orientation, swap);
 
-      switch (face->getNumVertices()) {
-
-      case 3:
-        {
-          MTriangle* tri = dynamic_cast<MTriangle*>(face);
-          if (tri)
-            tri->reorient(orientation,swap);
-          break;
-        }
-      case 4:
-        {
-          MQuadrangle* qua = dynamic_cast<MQuadrangle*>(face);
-          if (qua)
-            qua->reorient(orientation,swap);
-          break;
-        }
+      switch(face->getNumVertices()) {
+      case 3: {
+        MTriangle *tri = dynamic_cast<MTriangle *>(face);
+        if(tri) tri->reorient(orientation, swap);
+        break;
+      }
+      case 4: {
+        MQuadrangle *qua = dynamic_cast<MQuadrangle *>(face);
+        if(qua) qua->reorient(orientation, swap);
+        break;
+      }
       }
     }
   }