diff --git a/CMakeLists.txt b/CMakeLists.txt
index 837a6eedf10a429026c5245e1223b99afabe4898..52da613f77038e293ae5aa5dd832e0179c9d4513 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,7 @@ option(ENABLE_POPPLER "Enable POPPLER package for displaying PDF documents" OFF)
 option(ENABLE_QT "Build proof-of-concept QT GUI" OFF)
 option(ENABLE_RTREE "Enable RTREE" ${DEFAULT})
 option(ENABLE_SALOME "Enable Salome routines for CAD healing" ${DEFAULT})
+option(ENABLE_SGEOM "Enable SGEOM interface to OCC" OFF)
 option(ENABLE_SLEPC "Enable SLEPc eigensolvers" ${DEFAULT})
 option(ENABLE_SOLVER "Enable solver components" ${DEFAULT})
 option(ENABLE_TAUCS "Enable Taucs linear algebra solver" ${DEFAULT})
@@ -938,6 +939,14 @@ if(ENABLE_OCC)
       TKBRep TKGeomBase TKG3d TKG2d
       # FoundationClasses
       TKAdvTools TKMath TKernel)
+  if(ENABLE_SGEOM)
+    set(OCC_LIBS_REQUIRED ${OCC_LIBS_REQUIRED}
+      # For SGEOM
+      TKBin TKBinL TKBinTObj TKBinXCAF TKCAF TKCDF TKLCAF TKPLCAF TKMeshVS 
+      TKNIS TKOpenGl TKPCAF TKPShape TKSTL TKService TKShapeSchema TKStdSchema
+      TKTObj TKV2d TKV3d TKVRML TKVoxel TKXCAF TKXCAFSchema TKXDEIGES TKXDESTEP
+      TKXMesh TKXSBase TKXml TKXmkL TKXmlTObj)
+  endif(ENABLE_SGEOM)
   list(LENGTH OCC_LIBS_REQUIRED NUM_OCC_LIBS_REQUIRED)
   set(OCC_LIBS)
   foreach(OCC ${OCC_LIBS_REQUIRED})
@@ -973,12 +982,19 @@ if(ENABLE_OCC)
       endif(NOT OCC_CONFIG_H)
     endif(OCC_INC)
   endif(NUM_OCC_LIBS EQUAL NUM_OCC_LIBS_REQUIRED)
-  if(HAVE_OCC AND ENABLE_SALOME)
-    add_subdirectory(contrib/Salome)
-    include_directories(contrib/Salome)
-    add_definitions(-DOCCGEOMETRY)
-    set_config_option(HAVE_SALOME "Salome")
-  endif(HAVE_OCC AND ENABLE_SALOME)
+  if(HAVE_OCC)
+    if(ENABLE_SGEOM)
+      add_subdirectory(contrib/SGEOM)
+      include_directories(contrib/SGEOM)
+      add_definitions(-DSGEOMGEOMETRY)
+      set_config_option(HAVE_SGEOM "SGEOM")
+    elseif(ENABLE_SALOME)
+      add_subdirectory(contrib/Salome)
+      include_directories(contrib/Salome)
+      add_definitions(-DOCCGEOMETRY)
+      set_config_option(HAVE_SALOME "Salome")
+    endif(ENABLE_SGEOM)
+  endif(HAVE_OCC)
 endif(ENABLE_OCC)
 
 if(ENABLE_ACIS)
diff --git a/Common/GmshConfig.h.in b/Common/GmshConfig.h.in
index 597232e57da2a58a22120d54e81571b2e3f898fe..3ce389e68cff078ff89b82c060fcb37e4819603e 100644
--- a/Common/GmshConfig.h.in
+++ b/Common/GmshConfig.h.in
@@ -56,6 +56,7 @@
 #cmakedefine HAVE_QT
 #cmakedefine HAVE_RTREE
 #cmakedefine HAVE_SALOME
+#cmakedefine HAVE_SGEOM
 #cmakedefine HAVE_SLEPC
 #cmakedefine HAVE_SOLVER
 #cmakedefine HAVE_TAUCS
diff --git a/Geo/CMakeLists.txt b/Geo/CMakeLists.txt
index baaa04f621e6cd8ea7cc9eb18cdadff2a3fc10e8..07ac19e7ebf3d5b4cc413ea711c8757f2fceafca 100644
--- a/Geo/CMakeLists.txt
+++ b/Geo/CMakeLists.txt
@@ -26,7 +26,7 @@ set(SRC
       GModelIO_CGNS.cpp GModelIO_MED.cpp GModelIO_MESH.cpp GModelIO_STL.cpp 
       GModelIO_PLY.cpp GModelIO_VRML.cpp GModelIO_UNV.cpp GModelIO_BDF.cpp 
       GModelIO_IR3.cpp GModelIO_DIFF.cpp GModelIO_GEOM.cpp GModelIO_INP.cpp
-      GModelIO_MAIL.cpp GModelIO_P3D.cpp 
+      GModelIO_MAIL.cpp GModelIO_P3D.cpp GModelIO_SGEOM.cpp
   ExtrudeParams.cpp
   Geo.cpp
   GeoStringInterface.cpp GeoInterpolation.cpp
diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp
index c051fe1031982d71fb8c93766caea6ea68a04004..afaab071ee8e911eb33a5a445f442ca3bf02a906 100644
--- a/Geo/GModel.cpp
+++ b/Geo/GModel.cpp
@@ -78,7 +78,9 @@ GModel::GModel(std::string name)
   // at the moment we always create (at least an empty) GEO model
   _createGEOInternals();
 
-#if defined(HAVE_OCC)
+#if defined(HAVE_OCC) && defined(HAVE_SGEOM)
+  setFactory("SGEOM");
+#elif defined(HAVE_OCC)
   setFactory("OpenCASCADE");
 #else
   setFactory("Gmsh");
@@ -139,7 +141,15 @@ int GModel::setCurrent(GModel *m)
 void GModel::setFactory(std::string name)
 {
   if(_factory) delete _factory;
-  if(name == "OpenCASCADE"){
+  if(name == "SGEOM"){
+#if defined(HAVE_OCC) && defined(HAVE_SGEOM)
+    _factory = new SGEOMFactory();
+#else
+    Msg::Error("Missing OpenCASCADE or SGEOM support: using Gmsh GEO factory instead");
+    _factory = new GeoFactory();
+#endif
+  }
+  else if(name == "OpenCASCADE"){
 #if defined(HAVE_OCC)
     _factory = new OCCFactory();
 #else
diff --git a/Geo/GModel.h b/Geo/GModel.h
index f72da346edb64a5d4053be0332228c7ca899eaf4..d6d8ab132a655b1939cabcae1272076835e73627 100644
--- a/Geo/GModel.h
+++ b/Geo/GModel.h
@@ -24,6 +24,7 @@ template <class scalar> class simpleFunction;
 class FM_Internals;
 class GEO_Internals;
 class OCC_Internals;
+class SGEOM_Internals;
 class ACIS_Internals;
 class smooth_normals;
 class FieldManager;
@@ -39,6 +40,7 @@ class GModel
 {
  private:
   friend class OCCFactory;
+  friend class SGEOMFactory;
   std::multimap<std::pair<std::vector<int>, std::vector<int> >,
                 std::pair<std::string, std::vector<int> > > _homologyRequests;
   std::set<GRegion*, GEntityLessThan> _chainRegions;
@@ -91,7 +93,11 @@ class GModel
   OCC_Internals *_occ_internals;
   void _deleteOCCInternals();
 
-  // OpenCascade model internal data
+  // SGEOM model internal data
+  SGEOM_Internals *_sgeom_internals;
+  void _deleteSGEOMInternals();
+
+  // ACIS model internal data
   ACIS_Internals *_acis_internals;
   void _deleteACISInternals();
 
@@ -205,6 +211,7 @@ class GModel
   // access internal CAD representations
   GEO_Internals *getGEOInternals(){ return _geo_internals; }
   OCC_Internals *getOCCInternals(){ return _occ_internals; }
+  SGEOM_Internals *getSGEOMInternals(){ return _sgeom_internals; }
   FM_Internals *getFMInternals() { return _fm_internals; }
   ACIS_Internals *getACISInternals(){ return _acis_internals; }
 
@@ -533,16 +540,16 @@ class GModel
   GModel *computeBooleanUnion(GModel *tool, int createNewModel=0);
   GModel *computeBooleanIntersection(GModel *tool, int createNewModel=0);
   GModel *computeBooleanDifference(GModel *tool, int createNewModel=0);
-  void    salomeconnect(); 
+  void    salomeconnect();
   void    occconnect();
-	
+
 	// do stuff for all entities inside a bounding box
   void    setPeriodicAllFaces(std::vector<double> FaceTranslationVector);
-  void    setPeriodicPairOfFaces(int numFaceMaster, std::vector<int> EdgeListMaster, 
+  void    setPeriodicPairOfFaces(int numFaceMaster, std::vector<int> EdgeListMaster,
 																 int numFaceSlave, std::vector<int> EdgeListSlave);
-  void    setPhysicalNumToEntitiesInBox(int EntityType, int PhysicalGroupNumber, 
+  void    setPhysicalNumToEntitiesInBox(int EntityType, int PhysicalGroupNumber,
 																				std::vector<double> p1,std::vector<double> p2);
-	
+
 
   // build a new GModel by cutting the elements crossed by the levelset ls
   // if cutElem is set to false, split the model without cutting the elements
diff --git a/Geo/GModelFactory.cpp b/Geo/GModelFactory.cpp
index 070a8b5de49bcb4249bb3ed9d88068916c3878f2..fe47299f4b21a472b01ba4e103e15e53aec82f66 100644
--- a/Geo/GModelFactory.cpp
+++ b/Geo/GModelFactory.cpp
@@ -1546,4 +1546,45 @@ GEntity *OCCFactory::addPipe(GModel *gm, GEntity *base, std::vector<GEdge *> wir
   return ret;
 }
 
+//Prepare SGEOM integration
+#if defined(HAVE_SGEOM) && defined(HAVE_OCC)
+
+#include "SGEOMIncludes.h"
+
+GVertex* SGEOMFactory::addVertex(GModel *gm,double x, double y, double z, double lc)
+{
+  //if (!gm->_sgeom_internals)
+  //  gm->_sgeom_internals = new SGEOM_Internals;
+
+  //gp_Pnt aPnt;
+  //aPnt = gp_Pnt(x, y, z);
+  //BRepBuilderAPI_MakeVertex mkVertex(aPnt);
+  //TopoDS_Vertex occv = mkVertex.Vertex();
+
+  //return gm->_occ_internals->addVertexToModel(gm, occv);
+
+  Msg::Error("addVertex not implemented yet for SGEOMFactory");
+  return 0;
+}
+
+GEdge* SGEOMFactory::addLine(GModel *gm,GVertex *v1, GVertex *v2)
+{
+  Msg::Error("addLine not implemented yet for SGEOMFactory");
+  return 0;
+}
+
+GFace* SGEOMFactory::addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges)
+{
+  Msg::Error("addPlanarFace not implemented yet for SGEOMFactory");
+  return 0;
+}
+
+GRegion* SGEOMFactory::addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces)
+{
+  Msg::Error("addVolume not implemented yet for SGEOMFactory");
+  return 0;
+}
+
+#endif
+
 #endif
diff --git a/Geo/GModelFactory.h b/Geo/GModelFactory.h
index 90433e8bd038e60aac55561b47e666dfc5b7dac1..f9004c3a286406b92ca0c082be10361aef24d245 100644
--- a/Geo/GModelFactory.h
+++ b/Geo/GModelFactory.h
@@ -80,12 +80,12 @@ class GModelFactory {
   {
     Msg::Error("add2Drect not implemented yet");
     return 0;
-  }  
+  }
   virtual GFace *add2Dellips(GModel *gm,double xc, double yc, double rx, double ry)
   {
     Msg::Error("add2Dellips not implemented yet");
     return 0;
-  }  
+  }
 
   // sweep stuff
   virtual GEntity *revolve(GModel *gm, GEntity*, std::vector<double> p1,
@@ -100,7 +100,9 @@ class GModelFactory {
     Msg::Error("extrude not implemented yet");
     return 0;
   }
-  virtual std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e, int nbLayers, double hLayers, int dir, int view)
+  virtual std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e,
+                                                     int nbLayers, double hLayers,
+                                                     int dir, int view)
   {
     Msg::Error("extrude normals not implemented yet");
     std::vector<GEntity*> empty;
@@ -131,7 +133,7 @@ class GModelFactory {
   {
     Msg::Error("addTorus not implemented yet");
     return 0;
-  } 
+  }
   virtual GEntity *addBlock(GModel *gm, std::vector<double> p1,
                             std::vector<double> p2)
   {
@@ -188,7 +190,7 @@ class GModelFactory {
     Msg::Error("computeBooleanDifference not implemented yet");
     return 0;
   }
-  
+
 	virtual void salomeconnect(GModel *gm)
   {
     Msg::Error("salomeconnect not implemented yet");
@@ -200,16 +202,20 @@ class GModelFactory {
   virtual void setPeriodicAllFaces(GModel *gm, std::vector<double> FaceTranslationVector)
   {
     Msg::Error("findperiodic not implemented yet");
-  }  
-  virtual void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, std::vector<int> EdgeListMaster, int numFaceSlave, std::vector<int> EdgeListSlave)
+  }
+  virtual void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster,
+                                      std::vector<int> EdgeListMaster,
+                                      int numFaceSlave, std::vector<int> EdgeListSlave)
   {
     Msg::Error("setPeriodicPairOfFaces not implemented yet");
-  }  
+  }
   ;
-  virtual void setPhysicalNumToEntitiesInBox(GModel *gm, int EntityType, int PhysicalGroupNumber, std::vector<double> p1,std::vector<double> p2)
+  virtual void setPhysicalNumToEntitiesInBox(GModel *gm, int EntityType,
+                                             int PhysicalGroupNumber,
+                                             std::vector<double> p1,std::vector<double> p2)
   {
     Msg::Error("setPhysicalNumToEntitiesInBox not implemented yet");
-  }  
+  }
 
 };
 
@@ -222,10 +228,10 @@ class GeoFactory : public GModelFactory {
   GRegion *addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces);
   GEdge *addCircleArc(GModel *gm,GVertex *begin, GVertex *center, GVertex *end);
   std::vector<GFace *> addRuledFaces(GModel *gm, std::vector<std::vector<GEdge *> > edges);
-  std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e, int nbLayers, double hLayers, int dir, int view);
+  std::vector<GEntity*> extrudeBoundaryLayer(GModel *gm, GEntity *e, int nbLayers,
+                                             double hLayers, int dir, int view);
 };
 
-
 #if defined(HAVE_OCC)
 
 class OCCFactory : public GModelFactory {
@@ -274,14 +280,30 @@ class OCCFactory : public GModelFactory {
   GModel *computeBooleanDifference(GModel *obj, GModel *tool, int createNewModel);
   void    salomeconnect(GModel *gm);
   void    occconnect(GModel *gm);
-	
+
   void setPeriodicAllFaces(GModel *gm, std::vector<double> FaceTranslationVector);
-  void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, std::vector<int> EdgeListMaster, int numFaceSlave, std::vector<int> EdgeListSlave);
-  void setPhysicalNumToEntitiesInBox(GModel *gm, int EntityType, int PhysicalGroupNumber, std::vector<double> p1, std::vector<double> p2);
-	
+  void setPeriodicPairOfFaces(GModel *gm, int numFaceMaster, std::vector<int> EdgeListMaster,
+                              int numFaceSlave, std::vector<int> EdgeListSlave);
+  void setPhysicalNumToEntitiesInBox(GModel *gm, int EntityType, int PhysicalGroupNumber,
+                                     std::vector<double> p1, std::vector<double> p2);
+
   void fillet(GModel *gm, std::vector<int> edges, double radius);
 };
 
 #endif
 
+#if defined(HAVE_SGEOM) && defined(HAVE_OCC)
+
+class SGEOMFactory : public GModelFactory {
+ public:
+  SGEOMFactory(){}
+  GVertex *addVertex(GModel *gm,double x, double y, double z, double lc);
+  GEdge *addLine(GModel *gm,GVertex *v1, GVertex *v2);
+  GFace *addPlanarFace(GModel *gm, std::vector<std::vector<GEdge *> > edges);
+  GRegion *addVolume(GModel *gm, std::vector<std::vector<GFace *> > faces);
+};
+
+#endif
+
+
 #endif
diff --git a/Geo/GModelIO_SGEOM.cpp b/Geo/GModelIO_SGEOM.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4788dd6fc5b0f76b4f9dc4ce36cbc011005df71e
--- /dev/null
+++ b/Geo/GModelIO_SGEOM.cpp
@@ -0,0 +1,1120 @@
+// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to the public mailing list <gmsh@geuz.org>.
+
+#include "GmshConfig.h"
+#include "GmshMessage.h"
+#include "GModelIO_SGEOM.h"
+#include "Context.h"
+// #include "OCCVertex.h"
+// #include "OCCEdge.h"
+// #include "OCCFace.h"
+// #include "OCCRegion.h"
+#include "MElement.h"
+#include "MLine.h"
+#include "OpenFile.h"
+// #include "OCC_Connect.h"
+
+#if defined(HAVE_SGEOM) && defined(HAVE_OCC)
+
+// #if defined(HAVE_SALOME)
+// #include "Partition_Spliter.hxx"
+// #endif
+
+// void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList);
+// 
+// void SGEOM_Internals::buildLists()
+// {
+//   somap.Clear();
+//   shmap.Clear();
+//   fmap.Clear();
+//   wmap.Clear();
+//   emap.Clear();
+//   vmap.Clear();
+//   addShapeToLists(shape);
+// }
+// 
+// void SGEOM_Internals::buildShapeFromLists(TopoDS_Shape _shape)
+// {
+//   BRep_Builder B;
+//   TopoDS_Compound C;
+//   B.MakeCompound(C);
+// 
+//   TopTools_ListOfShape theList;
+//   addSimpleShapes(_shape, theList);
+//   TopTools_ListIteratorOfListOfShape itSub1(theList);
+//   for (; itSub1.More(); itSub1.Next()) B.Add(C, itSub1.Value());
+// 
+//   for(int i = 1; i <= vmap.Extent(); i++) B.Add(C, vmap(i));
+//   for(int i = 1; i <= emap.Extent(); i++) B.Add(C, emap(i));
+//   for(int i = 1; i <= wmap.Extent(); i++) B.Add(C, wmap(i));
+//   for(int i = 1; i <= fmap.Extent(); i++) B.Add(C, fmap(i));
+//   for(int i = 1; i <= shmap.Extent(); i++) B.Add(C, shmap(i));
+//   for(int i = 1; i <= somap.Extent(); i++) B.Add(C, somap(i));
+//   shape = C;
+// }
+// 
+// void SGEOM_Internals::addShapeToLists(TopoDS_Shape _shape)
+// {
+//   // Solids
+//   TopExp_Explorer exp0, exp1, exp2, exp3, exp4, exp5;
+//   for(exp0.Init(_shape, TopAbs_SOLID); exp0.More(); exp0.Next()){
+//     TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
+//     if(somap.FindIndex(solid) < 1){
+//       somap.Add(solid);
+// 
+//       for(exp1.Init(solid, TopAbs_SHELL); exp1.More(); exp1.Next()){
+//         TopoDS_Shell shell = TopoDS::Shell(exp1.Current());
+//         if(shmap.FindIndex(shell) < 1){
+//           shmap.Add(shell);
+// 
+//           for(exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()){
+//             TopoDS_Face face = TopoDS::Face(exp2.Current());
+//             if(fmap.FindIndex(face) < 1){
+//               fmap.Add(face);
+// 
+//               for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){
+//                 TopoDS_Wire wire = TopoDS::Wire(exp3.Current());
+//                 if(wmap.FindIndex(wire) < 1){
+//                   wmap.Add(wire);
+// 
+//                   for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){
+//                     TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
+//                     if(emap.FindIndex(edge) < 1){
+//                       emap.Add(edge);
+// 
+//                       for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){
+//                         TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//                         if(vmap.FindIndex(vertex) < 1)
+//                           vmap.Add(vertex);
+//                       }
+//                     }
+//                   }
+//                 }
+//               }
+//             }
+//           }
+//         }
+//       }
+//     }
+//   }
+// 
+//   // Free Shells
+//   for(exp1.Init(exp0.Current(), TopAbs_SHELL, TopAbs_SOLID); exp1.More(); exp1.Next()){
+//     TopoDS_Shape shell = exp1.Current();
+//     if(shmap.FindIndex(shell) < 1){
+//       shmap.Add(shell);
+// 
+//       for(exp2.Init(shell, TopAbs_FACE); exp2.More(); exp2.Next()){
+//         TopoDS_Face face = TopoDS::Face(exp2.Current());
+//         if(fmap.FindIndex(face) < 1){
+//           fmap.Add(face);
+// 
+//           for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){
+//             TopoDS_Wire wire = TopoDS::Wire(exp3.Current());
+//             if(wmap.FindIndex(wire) < 1){
+//               wmap.Add(wire);
+// 
+//               for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){
+//                 TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
+//                 if(emap.FindIndex(edge) < 1){
+//                   emap.Add(edge);
+// 
+//                   for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){
+//                     TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//                     if(vmap.FindIndex(vertex) < 1)
+//                       vmap.Add(vertex);
+//                   }
+//                 }
+//               }
+//             }
+//           }
+//         }
+//       }
+//     }
+//   }
+// 
+//   // Free Faces
+//   for(exp2.Init(_shape, TopAbs_FACE, TopAbs_SHELL); exp2.More(); exp2.Next()){
+//     TopoDS_Face face = TopoDS::Face(exp2.Current());
+//     if(fmap.FindIndex(face) < 1){
+//       fmap.Add(face);
+// 
+//       for(exp3.Init(exp2.Current(), TopAbs_WIRE); exp3.More(); exp3.Next()){
+//         TopoDS_Wire wire = TopoDS::Wire(exp3.Current());
+//         if(wmap.FindIndex(wire) < 1){
+//           wmap.Add(wire);
+// 
+//           for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){
+//             TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
+//             if(emap.FindIndex(edge) < 1){
+//               emap.Add(edge);
+// 
+//               for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){
+//                 TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//                 if(vmap.FindIndex(vertex) < 1)
+//                   vmap.Add(vertex);
+//               }
+//             }
+//           }
+//         }
+//       }
+//     }
+//   }
+// 
+//   // Free Wires
+//   for(exp3.Init(_shape, TopAbs_WIRE, TopAbs_FACE); exp3.More(); exp3.Next()){
+//     TopoDS_Wire wire = TopoDS::Wire(exp3.Current());
+//     if(wmap.FindIndex(wire) < 1){
+//       wmap.Add(wire);
+// 
+//       for(exp4.Init(exp3.Current(), TopAbs_EDGE); exp4.More(); exp4.Next()){
+//         TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
+//         if(emap.FindIndex(edge) < 1){
+//           emap.Add(edge);
+// 
+//           for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){
+//             TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//             if(vmap.FindIndex(vertex) < 1)
+//               vmap.Add(vertex);
+//           }
+//         }
+//       }
+//     }
+//   }
+// 
+//   // Free Edges
+//   for(exp4.Init(_shape, TopAbs_EDGE, TopAbs_WIRE); exp4.More(); exp4.Next()){
+//     TopoDS_Edge edge = TopoDS::Edge(exp4.Current());
+//     if(emap.FindIndex(edge) < 1){
+//       emap.Add(edge);
+// 
+//       for(exp5.Init(exp4.Current(), TopAbs_VERTEX); exp5.More(); exp5.Next()){
+//         TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//         if(vmap.FindIndex(vertex) < 1)
+//           vmap.Add(vertex);
+//       }
+//     }
+//   }
+// 
+//   // Free Vertices
+//   for(exp5.Init(_shape, TopAbs_VERTEX, TopAbs_EDGE); exp5.More(); exp5.Next()){
+//     TopoDS_Vertex vertex = TopoDS::Vertex(exp5.Current());
+//     if(vmap.FindIndex(vertex) < 1)
+//       vmap.Add(vertex);
+//   }
+// 
+// }
+// 
+// void SGEOM_Internals::healGeometry(double tolerance, bool fixdegenerated,
+//                                  bool fixsmalledges, bool fixspotstripfaces,
+//                                  bool sewfaces, bool makesolids, bool connect)
+// {
+//   if(!fixdegenerated && !fixsmalledges && !fixspotstripfaces &&
+//      !sewfaces && !makesolids && !connect) return;
+// 
+//   Msg::Info("Starting geometry healing procedure (tolerance: %g)", tolerance);
+// 
+//   buildLists();
+//   TopExp_Explorer exp0, exp1;
+//   int nrc = 0, nrcs = 0;
+//   int nrso = somap.Extent(), nrsh = shmap.Extent(), nrf = fmap.Extent();
+//   int nrw = wmap.Extent(), nre = emap.Extent(), nrv = vmap.Extent();
+//   for(exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nrc++;
+//   for(exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nrcs++;
+// 
+//   double surfacecont = 0;
+//   for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){
+//     TopoDS_Face face = TopoDS::Face(exp0.Current());
+//     GProp_GProps system;
+//     BRepGProp::SurfaceProperties(face, system);
+//     surfacecont += system.Mass();
+//   }
+// 
+//   if(fixdegenerated){
+//     Msg::Info("- fix degenerated edges and faces");
+// 
+//     {
+//       Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//       rebuild->Apply(shape);
+//       for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){
+//         TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
+//         if(BRep_Tool::Degenerated(edge))
+//           rebuild->Remove(edge, false);
+//       }
+//       shape = rebuild->Apply(shape);
+//     }
+//     buildLists();
+// 
+//     {
+//       Handle(ShapeFix_Face) sff;
+//       Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//       rebuild->Apply(shape);
+// 
+//       for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){
+//         TopoDS_Face face = TopoDS::Face(exp0.Current());
+// 
+//         sff = new ShapeFix_Face(face);
+//         sff->FixAddNaturalBoundMode() = Standard_True;
+//         sff->FixSmallAreaWireMode() = Standard_True;
+//         sff->Perform();
+// 
+//         if(sff->Status(ShapeExtend_DONE1) ||
+//            sff->Status(ShapeExtend_DONE2) ||
+//            sff->Status(ShapeExtend_DONE3) ||
+//            sff->Status(ShapeExtend_DONE4) ||
+//            sff->Status(ShapeExtend_DONE5))
+//           {
+//             Msg::Info("  repaired face %d", fmap.FindIndex(face));
+//             if(sff->Status(ShapeExtend_DONE1))
+//               Msg::Info("  (some wires are fixed)");
+//             else if(sff->Status(ShapeExtend_DONE2))
+//               Msg::Info("  (orientation of wires fixed)");
+//             else if(sff->Status(ShapeExtend_DONE3))
+//               Msg::Info("  (missing seam added)");
+//             else if(sff->Status(ShapeExtend_DONE4))
+//               Msg::Info("  (small area wire removed)");
+//             else if(sff->Status(ShapeExtend_DONE5))
+//               Msg::Info("  (natural bounds added)");
+//             TopoDS_Face newface = sff->Face();
+// 
+//             rebuild->Replace(face, newface, Standard_False);
+//           }
+//       }
+//       shape = rebuild->Apply(shape);
+//     }
+// 
+//     {
+//       Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//       rebuild->Apply(shape);
+//       for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){
+//         TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
+//         if(BRep_Tool::Degenerated(edge))
+//           rebuild->Remove(edge, false);
+//       }
+//       shape = rebuild->Apply(shape);
+//     }
+//   }
+// 
+//   if(fixsmalledges){
+//     Msg::Info("- fixing small edges");
+// 
+//     Handle(ShapeFix_Wire) sfw;
+//     Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//     rebuild->Apply(shape);
+// 
+//     for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){
+//       TopoDS_Face face = TopoDS::Face(exp0.Current());
+// 
+//       for(exp1.Init(face, TopAbs_WIRE); exp1.More(); exp1.Next()){
+//         TopoDS_Wire oldwire = TopoDS::Wire(exp1.Current());
+//         sfw = new ShapeFix_Wire(oldwire, face ,tolerance);
+//         sfw->ModifyTopologyMode() = Standard_True;
+// 
+//         sfw->ClosedWireMode() = Standard_True;
+// 
+//         bool replace = false;
+//         replace = sfw->FixReorder() || replace;
+//         replace = sfw->FixConnected() || replace;
+// 
+//         if(sfw->FixSmall(Standard_False, tolerance) &&
+//            ! (sfw->StatusSmall(ShapeExtend_FAIL1) ||
+//               sfw->StatusSmall(ShapeExtend_FAIL2) ||
+//               sfw->StatusSmall(ShapeExtend_FAIL3))){
+//           Msg::Info("  fixed small edge in wire %d", wmap.FindIndex(oldwire));
+//           replace = true;
+//         }
+//         else if(sfw->StatusSmall(ShapeExtend_FAIL1))
+//           Msg::Warning("Failed to fix small edge in wire %d, edge cannot be checked "
+//                        "(no 3d curve and no pcurve)", wmap.FindIndex(oldwire));
+//         else if(sfw->StatusSmall(ShapeExtend_FAIL2))
+//           Msg::Warning("Failed to fix small edge in wire %d, "
+//                        "edge is null-length and has different vertives at begin and "
+//                        "end, and lockvtx is True or ModifiyTopologyMode is False",
+//                        wmap.FindIndex(oldwire));
+//         else if(sfw->StatusSmall(ShapeExtend_FAIL3))
+//           Msg::Warning("Failed to fix small edge in wire, CheckConnected has failed",
+//                        wmap.FindIndex(oldwire));
+// 
+//         replace = sfw->FixEdgeCurves() || replace;
+//         replace = sfw->FixDegenerated() || replace;
+//         replace = sfw->FixSelfIntersection() || replace;
+//         replace = sfw->FixLacking(Standard_True) || replace;
+//         if(replace){
+//           TopoDS_Wire newwire = sfw->Wire();
+//           rebuild->Replace(oldwire, newwire, Standard_False);
+//         }
+//       }
+//     }
+// 
+//     shape = rebuild->Apply(shape);
+// 
+//     {
+//       buildLists();
+//       Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//       rebuild->Apply(shape);
+// 
+//       for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){
+//         TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
+//         if(vmap.FindIndex(TopExp::FirstVertex(edge)) ==
+//            vmap.FindIndex(TopExp::LastVertex(edge))){
+//           GProp_GProps system;
+//           BRepGProp::LinearProperties(edge, system);
+//           if(system.Mass() < tolerance){
+//             Msg::Info("  removing degenerated edge %d from vertex %d to vertex %d",
+//                       emap.FindIndex(edge), vmap.FindIndex(TopExp::FirstVertex(edge)),
+//                       vmap.FindIndex(TopExp::LastVertex(edge)));
+//             rebuild->Remove(edge, false);
+//           }
+//         }
+//       }
+//       shape = rebuild->Apply(shape);
+//     }
+// 
+//     {
+//       Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//       rebuild->Apply(shape);
+//       for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){
+//         TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
+//         if(BRep_Tool::Degenerated(edge) )
+//           rebuild->Remove(edge, false);
+//       }
+//       shape = rebuild->Apply(shape);
+//     }
+// 
+//     Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe;
+//     sfwf->SetPrecision(tolerance);
+//     sfwf->Load(shape);
+//     sfwf->ModeDropSmallEdges() = Standard_True;
+// 
+//     if(sfwf->FixWireGaps()){
+//       Msg::Info("- fixing wire gaps");
+//       if(sfwf->StatusWireGaps(ShapeExtend_OK))
+//         Msg::Info("  no gaps found");
+//       if(sfwf->StatusWireGaps(ShapeExtend_DONE1))
+//         Msg::Info("  some 2D gaps fixed");
+//       if(sfwf->StatusWireGaps(ShapeExtend_DONE2))
+//         Msg::Info("  some 3D gaps fixed");
+//       if(sfwf->StatusWireGaps(ShapeExtend_FAIL1))
+//         Msg::Info("  failed to fix some 2D gaps");
+//       if(sfwf->StatusWireGaps(ShapeExtend_FAIL2))
+//         Msg::Info("  failed to fix some 3D gaps");
+//     }
+// 
+//     sfwf->SetPrecision(tolerance);
+// 
+//     if(sfwf->FixSmallEdges()){
+//       Msg::Info("- fixing wire frames");
+//       if(sfwf->StatusSmallEdges(ShapeExtend_OK))
+//         Msg::Info("  no small edges found");
+//       if(sfwf->StatusSmallEdges(ShapeExtend_DONE1))
+//         Msg::Info("  some small edges fixed");
+//       if(sfwf->StatusSmallEdges(ShapeExtend_FAIL1))
+//         Msg::Info("  failed to fix some small edges");
+//     }
+// 
+//     shape = sfwf->Shape();
+//   }
+// 
+//   if(fixspotstripfaces){
+//     Msg::Info("- fixing spot and strip faces");
+//     Handle(ShapeFix_FixSmallFace) sffsm = new ShapeFix_FixSmallFace();
+//     sffsm->Init(shape);
+//     sffsm->SetPrecision(tolerance);
+//     sffsm->Perform();
+// 
+//     shape = sffsm->FixShape();
+//   }
+// 
+//   if(sewfaces){
+//     Msg::Info("- sewing faces");
+// 
+//     BRepOffsetAPI_Sewing sewedObj(tolerance);
+// 
+//     for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){
+//       TopoDS_Face face = TopoDS::Face(exp0.Current());
+//       sewedObj.Add(face);
+//     }
+// 
+//     sewedObj.Perform();
+// 
+//     if(!sewedObj.SewedShape().IsNull())
+//       shape = sewedObj.SewedShape();
+//     else
+//       Msg::Info("  not possible");
+//   }
+// 
+//   {
+//     Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//     rebuild->Apply(shape);
+//     for(exp1.Init(shape, TopAbs_EDGE); exp1.More(); exp1.Next()){
+//       TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
+//       if(BRep_Tool::Degenerated(edge))
+//         rebuild->Remove(edge, false);
+//     }
+//     shape = rebuild->Apply(shape);
+//   }
+// 
+//   if(makesolids){
+//     Msg::Info("- making solids");
+// 
+//     BRepBuilderAPI_MakeSolid ms;
+//     int count = 0;
+//     for(exp0.Init(shape, TopAbs_SHELL); exp0.More(); exp0.Next()){
+//       count++;
+//       ms.Add(TopoDS::Shell(exp0.Current()));
+//     }
+// 
+//     if(!count){
+//       Msg::Info("  not possible (no shells)");
+//     }
+//     else{
+//       BRepCheck_Analyzer ba(ms);
+//       if(ba.IsValid()){
+//         Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape;
+//         sfs->Init(ms);
+//         sfs->SetPrecision(tolerance);
+//         sfs->SetMaxTolerance(tolerance);
+//         sfs->Perform();
+//         shape = sfs->Shape();
+// 
+//         for(exp0.Init(shape, TopAbs_SOLID); exp0.More(); exp0.Next()){
+//           TopoDS_Solid solid = TopoDS::Solid(exp0.Current());
+//           TopoDS_Solid newsolid = solid;
+//           BRepLib::OrientClosedSolid(newsolid);
+//           Handle_ShapeBuild_ReShape rebuild = new ShapeBuild_ReShape;
+//           //		  rebuild->Apply(shape);
+//           rebuild->Replace(solid, newsolid, Standard_False);
+//           TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_COMPSOLID);//, 1);
+//           //		  TopoDS_Shape newshape = rebuild->Apply(shape);
+//           shape = newshape;
+//         }
+//       }
+//       else
+//         Msg::Info("  not possible");
+//     }
+//   }
+// 
+//   if(connect){
+// #if defined(HAVE_SALOME)
+//     Msg::Info("- cutting and connecting faces with Salome's Partition_Spliter");
+//     TopExp_Explorer e2;
+//     Partition_Spliter ps;
+//     for(e2.Init(shape, TopAbs_SOLID); e2.More(); e2.Next())
+//       ps.AddShape(e2.Current());
+//     try{
+//       ps.Compute();
+//       shape = ps.Shape();
+//     }
+//     catch(Standard_Failure &err){
+//       Msg::Error("%s", err.GetMessageString());
+//     }
+// #else
+//     Msg::Info("- cutting and connecting faces with OCC_Connect");
+//     OCC_Connect connect(1);
+//     for(TopExp_Explorer p(shape, TopAbs_SOLID); p.More(); p.Next())
+//       connect.Add(p.Current());
+//     connect.Connect();
+//     shape = connect;
+// #endif
+//   }
+// 
+//   double newsurfacecont = 0;
+//   for(exp0.Init(shape, TopAbs_FACE); exp0.More(); exp0.Next()){
+//     TopoDS_Face face = TopoDS::Face(exp0.Current());
+//     GProp_GProps system;
+//     BRepGProp::SurfaceProperties(face, system);
+//     newsurfacecont += system.Mass();
+//   }
+// 
+//   buildLists();
+//   int nnrc = 0, nnrcs = 0;
+//   int nnrso = somap.Extent(), nnrsh = shmap.Extent(), nnrf = fmap.Extent();
+//   int nnrw = wmap.Extent(), nnre = emap.Extent(), nnrv = vmap.Extent();
+//   for(exp0.Init(shape, TopAbs_COMPOUND); exp0.More(); exp0.Next()) nnrc++;
+//   for(exp0.Init(shape, TopAbs_COMPSOLID); exp0.More(); exp0.Next()) nnrcs++;
+// 
+//   Msg::Info("-----------------------------------");
+//   Msg::Info("Compounds          : %d (%d)", nnrc, nrc);
+//   Msg::Info("Composite solids   : %d (%d)", nnrcs, nrcs);
+//   Msg::Info("Solids             : %d (%d)", nnrso, nrso);
+//   Msg::Info("Shells             : %d (%d)", nnrsh, nrsh);
+//   Msg::Info("Wires              : %d (%d)", nnrw, nrw);
+//   Msg::Info("Faces              : %d (%d)", nnrf, nrf);
+//   Msg::Info("Edges              : %d (%d)", nnre, nre);
+//   Msg::Info("Vertices           : %d (%d)", nnrv, nrv );
+//   Msg::Info("Totol surface area : %g (%g)", newsurfacecont, surfacecont);
+//   Msg::Info("-----------------------------------");
+// }
+// 
+// void SGEOM_Internals::loadBREP(const char *fn)
+// {
+//   BRep_Builder aBuilder;
+//   BRepTools::Read(shape, (char*)fn, aBuilder);
+//   BRepTools::Clean(shape);
+//   healGeometry(CTX::instance()->geom.tolerance,
+//                CTX::instance()->geom.occFixDegenerated,
+//                CTX::instance()->geom.occFixSmallEdges,
+//                CTX::instance()->geom.occFixSmallFaces,
+//                CTX::instance()->geom.occSewFaces,
+//                false,
+//                CTX::instance()->geom.occConnectFaces);
+//   BRepTools::Clean(shape);
+//   buildLists();
+// }
+// 
+// void SGEOM_Internals::writeBREP(const char *fn)
+// {
+//   std::ofstream myFile;
+//   myFile.open(fn);
+//   try {
+//     BRepTools::Write(shape, myFile);
+//   }
+//   catch(Standard_Failure &err){
+//     Msg::Error("%s", err.GetMessageString());
+//   }
+//   myFile.close();
+// }
+// 
+// void SGEOM_Internals::loadSTEP(const char *fn)
+// {
+//   STEPControl_Reader reader;
+//   reader.ReadFile((char*)fn);
+//   reader.NbRootsForTransfer();
+//   reader.TransferRoots();
+//   shape = reader.OneShape();
+//   BRepTools::Clean(shape);
+//   healGeometry(CTX::instance()->geom.tolerance,
+//                CTX::instance()->geom.occFixDegenerated,
+//                CTX::instance()->geom.occFixSmallEdges,
+//                CTX::instance()->geom.occFixSmallFaces,
+//                CTX::instance()->geom.occSewFaces,
+//                false,
+//                CTX::instance()->geom.occConnectFaces);
+//   BRepTools::Clean(shape);
+//   buildLists();
+// }
+// 
+// void SGEOM_Internals::writeSTEP(const char *fn)
+// {
+//   STEPControl_Writer writer;
+//   IFSelect_ReturnStatus status = writer.Transfer(shape, STEPControl_ManifoldSolidBrep);
+//   if(status == IFSelect_RetDone)
+//     status = writer.Write((char*)fn);
+// }
+// 
+// void SGEOM_Internals::loadIGES(const char *fn)
+// {
+//   IGESControl_Reader reader;
+//   reader.ReadFile((char*)fn);
+//   reader.NbRootsForTransfer();
+//   reader.TransferRoots();
+//   shape = reader.OneShape();
+//   BRepTools::Clean(shape);
+//   healGeometry(CTX::instance()->geom.tolerance,
+//                CTX::instance()->geom.occFixDegenerated,
+//                CTX::instance()->geom.occFixSmallEdges,
+//                CTX::instance()->geom.occFixSmallFaces,
+//                CTX::instance()->geom.occSewFaces,
+//                false,
+//                CTX::instance()->geom.occConnectFaces);
+//   BRepTools::Clean(shape);
+//   buildLists();
+// }
+// 
+// void SGEOM_Internals::loadShape(const TopoDS_Shape *s)
+// {
+//   shape = *s;
+//   BRepTools::Clean(shape);
+//   buildLists();
+// }
+// 
+// GVertex *SGEOM_Internals::getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind)
+// {
+//   if(gvNumCache.IsBound(toFind))
+//     return model->getVertexByTag(gvNumCache.Find(toFind));
+//   return 0;
+// }
+// 
+// GEdge *SGEOM_Internals::getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind)
+// {
+//   if(geNumCache.IsBound(toFind))
+//     return model->getEdgeByTag(geNumCache.Find(toFind));
+//   return 0;
+// }
+// 
+// GFace *SGEOM_Internals::getOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind)
+// {
+//   if(gfNumCache.IsBound(toFind))
+//     return model->getFaceByTag(gfNumCache.Find(toFind));
+//   return 0;
+// }
+// 
+// GRegion *SGEOM_Internals::getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFind)
+// {
+//   if(grNumCache.IsBound(toFind))
+//     return model->getRegionByTag(grNumCache.Find(toFind));
+//   return 0;
+// }
+// 
+// GVertex *SGEOM_Internals::addVertexToModel(GModel *model, TopoDS_Vertex vertex)
+// {
+//   GVertex *gv = getOCCVertexByNativePtr(model, vertex);
+//   if(gv) return gv;
+//   addShapeToLists(vertex);
+//   buildShapeFromLists(vertex);
+//   buildGModel(model);
+//   return getOCCVertexByNativePtr(model, vertex);
+// }
+// 
+// GEdge *SGEOM_Internals::addEdgeToModel(GModel *model, TopoDS_Edge edge)
+// {
+//   GEdge *ge = getOCCEdgeByNativePtr(model, edge);
+//   if(ge) return ge;
+//   addShapeToLists(edge);
+//   buildShapeFromLists(edge);
+//   buildGModel(model);
+//   return getOCCEdgeByNativePtr(model, edge);
+// }
+// 
+// GFace* SGEOM_Internals::addFaceToModel(GModel *model, TopoDS_Face face)
+// {
+//   GFace *gf = getOCCFaceByNativePtr(model, face);
+//   if(gf) return gf;
+//   addShapeToLists(face);
+//   buildShapeFromLists(face);
+//   buildGModel(model);
+//   return getOCCFaceByNativePtr(model, face);
+// }
+// 
+// GRegion* SGEOM_Internals::addRegionToModel(GModel *model, TopoDS_Solid region)
+// {
+//   GRegion *gr  = getOCCRegionByNativePtr(model, region);
+//   if(gr) return gr;
+//   addShapeToLists(region);
+//   buildShapeFromLists(region);
+//   buildGModel(model);
+//   return getOCCRegionByNativePtr(model, region);
+// }
+// 
+// /* I needed getGTagOfOCC*ByNativePtr whithin setPhysicalNumToEntitiesInBox */
+// int SGEOM_Internals::getGTagOfOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind)
+// {
+// 	if(gvNumCache.IsBound(toFind))
+// 		return (int)gvNumCache.Find(toFind);
+// 	return 0;	
+// }
+// 
+// int SGEOM_Internals::getGTagOfOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind)
+// {
+// 	if(gfNumCache.IsBound(toFind))
+// 		return (int)gfNumCache.Find(toFind);
+// 	return 0;
+// }
+// 
+// int SGEOM_Internals::getGTagOfOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind)
+// {
+// 	if(geNumCache.IsBound(toFind))
+// 		return (int)geNumCache.Find(toFind);
+// 	return 0;
+// }
+// 
+// int SGEOM_Internals::getGTagOfOCCSolidByNativePtr(GModel *model, TopoDS_Solid toFind)
+// {
+// 	if(grNumCache.IsBound(toFind))
+// 		return (int)grNumCache.Find(toFind);
+// 	return 0;	
+// }
+// 
+// void SGEOM_Internals::buildGModel(GModel *model)
+// {
+//   // building geom vertices
+//   int numv = model->getMaxElementaryNumber(0) + 1;
+//   for(int i = 1; i <= vmap.Extent(); i++){
+//     TopoDS_Vertex vertex = TopoDS::Vertex(vmap(i));
+//     if(!getOCCVertexByNativePtr(model, vertex)){
+//       model->add(new OCCVertex(model, numv, vertex));
+//       numv++;
+//     }
+//   }
+// 
+//   // building geom edges
+//   int nume = model->getMaxElementaryNumber(1) + 1;
+//   for(int i = 1; i <= emap.Extent(); i++){
+//     int i1 = vmap.FindIndex(TopExp::FirstVertex(TopoDS::Edge(emap(i))));
+//     int i2 = vmap.FindIndex(TopExp::LastVertex(TopoDS::Edge(emap(i))));
+//     if(!getOCCEdgeByNativePtr(model, TopoDS::Edge(emap(i)))){
+//       GVertex *v1 = getOCCVertexByNativePtr(model, TopoDS::Vertex(vmap(i1)));
+//       GVertex *v2 = getOCCVertexByNativePtr(model, TopoDS::Vertex(vmap(i2)));
+//       model->add(new OCCEdge(model, TopoDS::Edge(emap(i)), nume, v1, v2));
+//       nume++;
+//     }
+//   }
+// 
+//   // building geom faces
+//   int numf = model->getMaxElementaryNumber(2) + 1;
+//   for(int i = 1; i <= fmap.Extent(); i++){
+//     if(!getOCCFaceByNativePtr(model, TopoDS::Face(fmap(i)))){
+//       model->add(new OCCFace(model, TopoDS::Face(fmap(i)), numf));
+//       numf++;
+//     }
+//   }
+// 
+//   // building geom regions
+//   int numr = model->getMaxElementaryNumber(3) + 1;
+//   for(int i = 1; i <= somap.Extent(); i++){
+//     if(!getOCCRegionByNativePtr(model, TopoDS::Solid(somap(i)))){
+//       model->add(new OCCRegion(model, TopoDS::Solid(somap(i)), numr));
+//       numr++;
+//     }
+//   }
+// }
+// 
+// void addSimpleShapes(TopoDS_Shape theShape, TopTools_ListOfShape &theList)
+// {
+//   if(theShape.ShapeType() != TopAbs_COMPOUND &&
+//       theShape.ShapeType() != TopAbs_COMPSOLID) {
+//     theList.Append(theShape);
+//     return;
+//   }
+// 
+//   TopTools_MapOfShape mapShape;
+//   TopoDS_Iterator It(theShape, Standard_True, Standard_True);
+// 
+//   for(; It.More(); It.Next()) {
+//     TopoDS_Shape aShape_i = It.Value();
+//     if(mapShape.Add(aShape_i)) {
+//       if(aShape_i.ShapeType() == TopAbs_COMPOUND ||
+//          aShape_i.ShapeType() == TopAbs_COMPSOLID) {
+//         addSimpleShapes(aShape_i, theList);
+//       }
+//       else {
+//         theList.Append(aShape_i);
+//       }
+//     }
+//   }
+// }
+// 
+// void SGEOM_Internals::applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op)
+// {
+//   if(tool.IsNull()) return;
+//   if(shape.IsNull()) shape = tool;
+//   else{
+//     switch(op){
+//     case SGEOM_Internals::Intersection :
+//       {
+//         TopoDS_Shape theNewShape;
+//         BRep_Builder B;
+//         TopoDS_Compound C;
+//         B.MakeCompound(C);
+//         TopTools_ListOfShape listShape1, listShape2;
+//         addSimpleShapes(shape, listShape1);
+//         addSimpleShapes(tool, listShape2);
+//         Standard_Boolean isCompound =
+//           (listShape1.Extent() > 1 || listShape2.Extent() > 1);
+// 
+//         TopTools_ListIteratorOfListOfShape itSub1(listShape1);
+//         for(; itSub1.More(); itSub1.Next()) {
+//           TopoDS_Shape aValue1 = itSub1.Value();
+//           TopTools_ListIteratorOfListOfShape itSub2(listShape2);
+//           for(; itSub2.More(); itSub2.Next()) {
+//             TopoDS_Shape aValue2 = itSub2.Value();
+//             BRepAlgoAPI_Common BO(aValue1, aValue2);
+//             if(!BO.IsDone()) {
+//               Msg::Error("Boolean Intersection Operator can not be performed");
+//             }
+//             if(isCompound) {
+//               TopoDS_Shape aStepResult = BO.Shape();
+//               if(aStepResult.ShapeType() == TopAbs_COMPOUND) {
+//                 TopoDS_Iterator aCompIter(aStepResult);
+//                 for(; aCompIter.More(); aCompIter.Next()) {
+//                   B.Add(C, aCompIter.Value());
+//                 }
+//               }
+//               else {
+//                 B.Add(C, aStepResult);
+//               }
+//             }
+//             else
+//               theNewShape = BO.Shape();
+//           }
+//         }
+//         if(isCompound) {
+//           TopTools_ListOfShape listShapeC;
+//           addSimpleShapes(C, listShapeC);
+//           TopTools_ListIteratorOfListOfShape itSubC(listShapeC);
+//           //bool isOnlySolids = true;
+//           for(; itSubC.More(); itSubC.Next()) {
+//             TopoDS_Shape aValueC = itSubC.Value();
+//             //if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false;
+//           }
+// 	  // if(isOnlySolids)
+// 	  //   theNewShape = GlueFaces(C, Precision::Confusion());
+// 	  // else
+//                theNewShape = C;
+//         }
+//         shape = theNewShape;
+//       }
+//       break;
+//     case SGEOM_Internals::Cut :
+//       {
+//         TopoDS_Shape theNewShape;
+//         BRep_Builder B;
+//         TopoDS_Compound C;
+//         B.MakeCompound(C);
+// 
+//         TopTools_ListOfShape listShapes, listTools;
+//         addSimpleShapes(shape, listShapes);
+//         addSimpleShapes(tool, listTools);
+// 
+//         Standard_Boolean isCompound = (listShapes.Extent() > 1);
+// 
+//         TopTools_ListIteratorOfListOfShape itSub1(listShapes);
+//         for(; itSub1.More(); itSub1.Next()) {
+//           TopoDS_Shape aCut = itSub1.Value();
+//           // tools
+//           TopTools_ListIteratorOfListOfShape itSub2(listTools);
+//           for(; itSub2.More(); itSub2.Next()) {
+//             TopoDS_Shape aTool = itSub2.Value();
+//             BRepAlgoAPI_Cut BO(aCut, aTool);
+//             if(!BO.IsDone()) {
+//               Msg::Error("Cut operation can not be performed on the given shapes");
+//               return;
+//             }
+//             aCut = BO.Shape();
+//           }
+//           if(isCompound) {
+//             if(aCut.ShapeType() == TopAbs_COMPOUND) {
+//               TopoDS_Iterator aCompIter(aCut);
+//               for(; aCompIter.More(); aCompIter.Next()) {
+//                 B.Add(C, aCompIter.Value());
+//               }
+//             }
+//             else {
+//               B.Add(C, aCut);
+//             }
+//           }
+//           else
+//             theNewShape = aCut;
+//         }
+// 
+//         if(isCompound) {
+//           TopTools_ListOfShape listShapeC;
+//           addSimpleShapes(C, listShapeC);
+//           TopTools_ListIteratorOfListOfShape itSubC(listShapeC);
+//           //bool isOnlySolids = true;
+//           for(; itSubC.More(); itSubC.Next()) {
+//             TopoDS_Shape aValueC = itSubC.Value();
+//             //if(aValueC.ShapeType() != TopAbs_SOLID) isOnlySolids = false;
+//           }
+// 	  // if(isOnlySolids)
+// 	  //   theNewShape = GlueFaces(C, Precision::Confusion());
+// 	  // else
+// 	       theNewShape = C;
+//         }
+//         shape = theNewShape;
+//       }
+//       break;
+//     case SGEOM_Internals::Fuse :
+//       {
+//         BRepAlgoAPI_Fuse BO(tool, shape);
+//         if(!BO.IsDone()) {
+//           Msg::Error("Fuse operation can not be performed on the given shapes");
+//         }
+//         shape = BO.Shape();
+//       }
+//       break;
+//     case SGEOM_Internals::Section :
+//       {
+//         TopoDS_Shape theNewShape;
+//         BRep_Builder B;
+//         TopoDS_Compound C;
+//         B.MakeCompound(C);
+// 
+//         TopTools_ListOfShape listShapes, listTools;
+//         addSimpleShapes(shape, listShapes);
+//         addSimpleShapes(tool, listTools);
+// 
+//         Standard_Boolean isCompound = (listShapes.Extent() > 1);
+//         TopTools_ListIteratorOfListOfShape itSub1(listShapes);
+//         for(; itSub1.More(); itSub1.Next()) {
+//           TopoDS_Shape aValue1 = itSub1.Value();
+//           TopTools_ListIteratorOfListOfShape itSub2(listTools);
+//           for(; itSub2.More(); itSub2.Next()) {
+//             TopoDS_Shape aValue2 = itSub2.Value();
+//             BRepAlgoAPI_Section BO(aValue1, aValue2, Standard_False);
+//             BO.Approximation(Standard_True);
+//             BO.Build();
+//             if(!BO.IsDone()) {
+//               Msg::Error("Section operation can not be performed on the given shapes");
+//               return;
+//             }
+//           if(isCompound) {
+//             TopoDS_Shape aStepResult = BO.Shape();
+//             if(aStepResult.ShapeType() == TopAbs_COMPOUND) {
+//               TopoDS_Iterator aCompIter(aStepResult);
+//               for(; aCompIter.More(); aCompIter.Next()) {
+//                 B.Add(C, aCompIter.Value());
+//               }
+//             }
+//             else {
+//               B.Add(C, aStepResult);
+//             }
+//           }
+//           else
+//             theNewShape = BO.Shape();
+//           }
+//         }
+//         if(isCompound)
+//           theNewShape = C;
+//         shape = theNewShape;
+//       }
+//       break;
+//     default :
+//       Msg::Error("Requested boolean operation not implemented");
+//       break;
+//     }
+//   }
+// }
+// 
+// void SGEOM_Internals::fillet(std::vector<TopoDS_Edge> &edgesToFillet,
+//                            double Radius)
+// {
+//   // create a tool for fillet
+//   BRepFilletAPI_MakeFillet fill(shape);
+//   for(unsigned int i = 0; i < edgesToFillet.size(); ++i){
+//     fill.Add(edgesToFillet[i]);
+//   }
+//   for(int i = 1; i <= fill.NbContours(); i++){
+//     fill.SetRadius(Radius, i, 1);
+//   }
+//   fill.Build();
+//   if(!fill.IsDone()) {
+//     Msg::Error("Fillet can't be computed on the given shape with the given radius");
+//     return;
+//   }
+//   shape = fill.Shape();
+// 
+//   if(shape.IsNull()) return;
+// 
+//   // Check shape validity
+//   BRepCheck_Analyzer ana(shape, false);
+//   if(!ana.IsValid()) {
+//     Msg::Error("Fillet algorithm have produced an invalid shape result");
+//   }
+// }
+// 
+// void GModel::_deleteOCCInternals()
+// {
+//   if(_occ_internals) delete _occ_internals;
+//   _occ_internals = 0;
+// }
+// 
+// int GModel::readOCCBREP(const std::string &fn)
+// {
+//   _occ_internals = new SGEOM_Internals;
+//   _occ_internals->loadBREP(fn.c_str());
+//   _occ_internals->buildGModel(this);
+//   snapVertices();
+//   return 1;
+// }
+// 
+// int GModel::readOCCSTEP(const std::string &fn)
+// {
+//   _occ_internals = new SGEOM_Internals;
+//   _occ_internals->loadSTEP(fn.c_str());
+//   _occ_internals->buildGModel(this);
+//   //snapVertices();
+//   return 1;
+// }
+// 
+// int GModel::readOCCIGES(const std::string &fn)
+// {
+//   _occ_internals = new SGEOM_Internals;
+//   _occ_internals->loadIGES(fn.c_str());
+//   _occ_internals->buildGModel(this);
+//   return 1;
+// }
+// 
+// int GModel::writeOCCBREP(const std::string &fn)
+// {
+//   if(!_occ_internals){
+//     Msg::Error("No OpenCASCADE model found");
+//     return 0;
+//   }
+//   else
+//     _occ_internals->writeBREP(fn.c_str());
+//   return 1;
+// }
+// 
+// int GModel::writeOCCSTEP(const std::string &fn)
+// {
+//   if(!_occ_internals){
+//     Msg::Error("No OpenCASCADE model found");
+//     return 0;
+//   }
+//   else
+//     _occ_internals->writeSTEP(fn.c_str());
+//   return 1;
+// }
+// 
+// int GModel::importOCCShape(const void *shape)
+// {
+//   _occ_internals = new SGEOM_Internals;
+//   _occ_internals->loadShape((TopoDS_Shape*)shape);
+//   _occ_internals->buildGModel(this);
+//   snapVertices();
+//   SetBoundingBox();
+//   return 1;
+// }
+// 
+// #else
+// 
+// void GModel::_deleteOCCInternals()
+// {
+// }
+// 
+// int GModel::readOCCBREP(const std::string &fn)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to load '%s'",
+//              fn.c_str());
+//   return 0;
+// }
+// 
+// int GModel::readOCCSTEP(const std::string &fn)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to load '%s'",
+//              fn.c_str());
+//   return 0;
+// }
+// 
+// int GModel::readOCCIGES(const std::string &fn)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to load '%s'",
+//              fn.c_str());
+//   return 0;
+// }
+// 
+// int GModel::writeOCCBREP(const std::string &fn)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to write '%s'",
+//              fn.c_str());
+//   return 0;
+// }
+// 
+// int GModel::writeOCCSTEP(const std::string &fn)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to write '%s'",
+//              fn.c_str());
+//   return 0;
+// }
+// 
+// int GModel::importOCCShape(const void *shape)
+// {
+//   Msg::Error("Gmsh must be compiled with Open CASCADE support to import "
+//              "a TopoDS_Shape");
+//   return 0;
+// }
+
+#endif
diff --git a/Geo/GModelIO_SGEOM.h b/Geo/GModelIO_SGEOM.h
new file mode 100644
index 0000000000000000000000000000000000000000..75fc4d22c58fc81f4875d46e8b760a5ac2848ad7
--- /dev/null
+++ b/Geo/GModelIO_SGEOM.h
@@ -0,0 +1,68 @@
+// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to the public mailing list <gmsh@geuz.org>.
+
+#ifndef _GMODELIO_SGEOM_H_
+#define _GMODELIO_SGEOM_H_
+
+#include "GmshConfig.h"
+#include "GModel.h"
+#include "SGEOMIncludes.h"
+
+#if defined(HAVE_SGEOM) && defined(HAVE_OCC)
+#include <vector>
+
+class SGEOM_Internals {
+ protected :
+  // // the shape
+  // TopoDS_Shape shape;
+  // // all the (sub) TopoDS_Shapes in 'shape'
+  // TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
+  // // cache mapping TopoDS_Shapes to their corresponding GEntity tags
+  // TopTools_DataMapOfShapeInteger gvNumCache, geNumCache, gfNumCache, grNumCache;
+ public:
+  // enum BooleanOperator { Intersection, Cut, Section, Fuse };
+  // OCC_Internals(){}
+  // TopoDS_Shape getShape () { return shape; }
+  // void buildLists();
+  // void buildShapeFromLists(TopoDS_Shape _shape);
+  // void addShapeToLists(TopoDS_Shape shape);
+  // void healGeometry(double tolerance, bool fixdegenerated,
+  //                   bool fixsmalledges, bool fixspotstripfaces,
+  //                   bool sewfaces, bool makesolids=false,
+  //                   bool connect=false);
+  // void loadBREP(const char *);
+  // void writeBREP(const char *);
+  // void loadSTEP(const char *);
+  // void writeSTEP(const char *);
+  // void loadIGES(const char *);
+  // void loadShape(const TopoDS_Shape *);
+  // void buildGModel(GModel *gm);
+  // void bind(TopoDS_Vertex vertex, int num){ gvNumCache.Bind(vertex, num); }
+  // void bind(TopoDS_Edge edge, int num){ geNumCache.Bind(edge, num); }
+  // void bind(TopoDS_Face face, int num){ gfNumCache.Bind(face, num); }
+  // void bind(TopoDS_Solid solid, int num){ grNumCache.Bind(solid, num); }
+  // void unbind(TopoDS_Vertex vertex){ gvNumCache.UnBind(vertex); }
+  // void unbind(TopoDS_Edge edge){ geNumCache.UnBind(edge); }
+  // void unbind(TopoDS_Face face){ gfNumCache.UnBind(face); }
+  // void unbind(TopoDS_Solid solid){ grNumCache.UnBind(solid); }
+  // GVertex *getOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind);
+  // GEdge *getOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind);
+  // GFace *getOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind);
+  // GRegion *getOCCRegionByNativePtr(GModel *model, TopoDS_Solid toFind);
+  // GVertex *addVertexToModel(GModel *model, TopoDS_Vertex v);
+  // GEdge *addEdgeToModel(GModel *model, TopoDS_Edge e);
+  // GFace *addFaceToModel(GModel *model, TopoDS_Face f);
+  // GRegion *addRegionToModel(GModel *model, TopoDS_Solid r);
+  // void fillet(std::vector<TopoDS_Edge> &shapes, double radius);
+  // void applyBooleanOperator(TopoDS_Shape tool, const BooleanOperator &op);
+  //
+  // int getGTagOfOCCVertexByNativePtr(GModel *model, TopoDS_Vertex toFind);
+  // int getGTagOfOCCFaceByNativePtr(GModel *model, TopoDS_Face toFind);
+  // int getGTagOfOCCEdgeByNativePtr(GModel *model, TopoDS_Edge toFind);
+  // int getGTagOfOCCSolidByNativePtr(GModel *model, TopoDS_Solid toFind);
+};
+
+#endif
+#endif
diff --git a/Geo/SGEOMIncludes.h b/Geo/SGEOMIncludes.h
new file mode 100644
index 0000000000000000000000000000000000000000..c6936f48db39ec152b36b2d4d801ddbc18b08426
--- /dev/null
+++ b/Geo/SGEOMIncludes.h
@@ -0,0 +1,337 @@
+// Gmsh - Copyright (C) 1997-2013 C. Geuzaine, J.-F. Remacle
+//
+// See the LICENSE.txt file for license information. Please report all
+// bugs and problems to the public mailing list <gmsh@geuz.org>.
+
+#ifndef _SGEOM_INCLUDES_
+#define _SGEOM_INCLUDES_
+
+#include "GmshConfig.h"
+
+#if defined(HAVE_SGEOM) && defined(HAVE_OCC)
+
+#include <iostream>
+using std::iostream;
+
+#if !defined(HAVE_NO_OCC_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <Archimede_VolumeSection.hxx>
+#include <Basics_OCCTVersion.hxx>
+#include <Basics_Utils.hxx>
+#include <BlockFix.hxx>
+#include <BlockFix_BlockFixAPI.hxx>
+#include <BlockFix_CheckTool.hxx>
+#include <BlockFix_PeriodicSurfaceModifier.hxx>
+#include <BlockFix_SphereSpaceModifier.hxx>
+#include <BlockFix_UnionEdges.hxx>
+#include <BlockFix_UnionFaces.hxx>
+#include <GEOMAlgo_Algo.hxx>
+#include <GEOMAlgo_Builder.hxx>
+#include <GEOMAlgo_BuilderArea.hxx>
+#include <GEOMAlgo_BuilderFace.hxx>
+#include <GEOMAlgo_BuilderShape.hxx>
+#include <GEOMAlgo_BuilderSolid.hxx>
+#include <GEOMAlgo_BuilderTools.hxx>
+#include <GEOMAlgo_Clsf.hxx>
+#include <GEOMAlgo_ClsfBox.hxx>
+#include <GEOMAlgo_ClsfSolid.hxx>
+#include <GEOMAlgo_ClsfSurf.hxx>
+#include <GEOMAlgo_CoupleOfShapes.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfOrientedShapeShape.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyInteger.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfPassKeyShapeShape.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfRealListOfShape.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeMapOfShape.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapePnt.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeReal.hxx>
+#include <GEOMAlgo_DataMapIteratorOfDataMapOfShapeShapeSet.hxx>
+#include <GEOMAlgo_DataMapOfOrientedShapeShape.hxx>
+#include <GEOMAlgo_DataMapOfPassKeyInteger.hxx>
+#include <GEOMAlgo_DataMapOfPassKeyShapeShape.hxx>
+#include <GEOMAlgo_DataMapOfRealListOfShape.hxx>
+#include <GEOMAlgo_DataMapOfShapeMapOfShape.hxx>
+#include <GEOMAlgo_DataMapOfShapePnt.hxx>
+#include <GEOMAlgo_DataMapOfShapeReal.hxx>
+#include <GEOMAlgo_DataMapOfShapeShapeSet.hxx>
+#include <GEOMAlgo_FinderShapeOn.hxx>
+#include <GEOMAlgo_FinderShapeOn1.hxx>
+#include <GEOMAlgo_FinderShapeOn2.hxx>
+#include <GEOMAlgo_FinderShapeOnQuad.hxx>
+#include <GEOMAlgo_GetInPlace.hxx>
+#include <GEOMAlgo_GlueAnalyser.hxx>
+#include <GEOMAlgo_GlueDetector.hxx>
+#include <GEOMAlgo_Gluer.hxx>
+#include <GEOMAlgo_Gluer2.hxx>
+#include <GEOMAlgo_GluerAlgo.hxx>
+#include <GEOMAlgo_HAlgo.hxx>
+#include <GEOMAlgo_IndexedDataMapOfIntegerShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfPassKeyShapeListOfShape.hxx>
+#include <GEOMAlgo_IndexedDataMapOfShapeBox.hxx>
+#include <GEOMAlgo_IndexedDataMapOfShapeShapeInfo.hxx>
+#include <GEOMAlgo_IndexedDataMapOfShapeState.hxx>
+#include <GEOMAlgo_KindOfBounds.hxx>
+#include <GEOMAlgo_KindOfClosed.hxx>
+#include <GEOMAlgo_KindOfName.hxx>
+#include <GEOMAlgo_KindOfShape.hxx>
+#include <GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx>
+#include <GEOMAlgo_ListIteratorOfListOfPnt.hxx>
+#include <GEOMAlgo_ListOfCoupleOfShapes.hxx>
+#include <GEOMAlgo_ListOfPnt.hxx>
+#include <GEOMAlgo_PWireEdgeSet.hxx>
+#include <GEOMAlgo_PassKey.hxx>
+#include <GEOMAlgo_PassKeyMapHasher.hxx>
+#include <GEOMAlgo_PassKeyShape.hxx>
+#include <GEOMAlgo_PassKeyShapeMapHasher.hxx>
+#include <GEOMAlgo_ShapeAlgo.hxx>
+#include <GEOMAlgo_ShapeInfo.hxx>
+#include <GEOMAlgo_ShapeInfoFiller.hxx>
+#include <GEOMAlgo_ShapeSet.hxx>
+#include <GEOMAlgo_ShapeSolid.hxx>
+#include <GEOMAlgo_ShellSolid.hxx>
+#include <GEOMAlgo_SolidSolid.hxx>
+#include <GEOMAlgo_Splitter.hxx>
+#include <GEOMAlgo_State.hxx>
+#include <GEOMAlgo_StateCollector.hxx>
+#include <GEOMAlgo_SurfaceTools.hxx>
+#include <GEOMAlgo_Tools.hxx>
+#include <GEOMAlgo_Tools3D.hxx>
+#include <GEOMAlgo_VertexSolid.hxx>
+#include <GEOMAlgo_WESCorrector.hxx>
+#include <GEOMAlgo_WESScaler.hxx>
+#include <GEOMAlgo_WireEdgeSet.hxx>
+#include <GEOMAlgo_WireSolid.hxx>
+#include <GEOMAlgo_WireSplitter.hxx>
+#include <GEOMImpl_3DSketcherDriver.hxx>
+#include <GEOMImpl_ArcDriver.hxx>
+#include <GEOMImpl_ArchimedeDriver.hxx>
+#include <GEOMImpl_Block6Explorer.hxx>
+#include <GEOMImpl_BlockDriver.hxx>
+#include <GEOMImpl_BooleanDriver.hxx>
+#include <GEOMImpl_BoxDriver.hxx>
+#include <GEOMImpl_ChamferDriver.hxx>
+#include <GEOMImpl_CircleDriver.hxx>
+#include <GEOMImpl_ConeDriver.hxx>
+#include <GEOMImpl_CopyDriver.hxx>
+#include <GEOMImpl_CylinderDriver.hxx>
+#include <GEOMImpl_DiskDriver.hxx>
+#include <GEOMImpl_DividedDiskDriver.hxx>
+#include <GEOMImpl_EllipseDriver.hxx>
+#include <GEOMImpl_ExportDriver.hxx>
+#include <GEOMImpl_FaceDriver.hxx>
+#include <GEOMImpl_Fillet1d.hxx>
+#include <GEOMImpl_Fillet1dDriver.hxx>
+#include <GEOMImpl_Fillet2dDriver.hxx>
+#include <GEOMImpl_FilletDriver.hxx>
+#include <GEOMImpl_FillingDriver.hxx>
+#include <GEOMImpl_Gen.hxx>
+#include <GEOMImpl_GlueDriver.hxx>
+#include <GEOMImpl_HealingDriver.hxx>
+#include <GEOMImpl_I3DPrimOperations.hxx>
+#include <GEOMImpl_I3DSketcher.hxx>
+#include <GEOMImpl_IAdvancedOperations.hxx>
+#include <GEOMImpl_IArc.hxx>
+#include <GEOMImpl_IArchimede.hxx>
+#include <GEOMImpl_IBasicOperations.hxx>
+#include <GEOMImpl_IBlockTrsf.hxx>
+#include <GEOMImpl_IBlocks.hxx>
+#include <GEOMImpl_IBlocksOperations.hxx>
+#include <GEOMImpl_IBoolean.hxx>
+#include <GEOMImpl_IBooleanOperations.hxx>
+#include <GEOMImpl_IBox.hxx>
+#include <GEOMImpl_IChamfer.hxx>
+#include <GEOMImpl_ICircle.hxx>
+#include <GEOMImpl_ICone.hxx>
+#include <GEOMImpl_ICopy.hxx>
+#include <GEOMImpl_ICurvesOperations.hxx>
+#include <GEOMImpl_ICylinder.hxx>
+#include <GEOMImpl_IDisk.hxx>
+#include <GEOMImpl_IDividedDisk.hxx>
+#include <GEOMImpl_IEllipse.hxx>
+#include <GEOMImpl_IFace.hxx>
+#include <GEOMImpl_IFillet.hxx>
+#include <GEOMImpl_IFillet1d.hxx>
+#include <GEOMImpl_IFillet2d.hxx>
+#include <GEOMImpl_IFilling.hxx>
+#include <GEOMImpl_IGlue.hxx>
+#include <GEOMImpl_IGroupOperations.hxx>
+#include <GEOMImpl_IHealing.hxx>
+#include <GEOMImpl_IHealingOperations.hxx>
+#include <GEOMImpl_IImportExport.hxx>
+#include <GEOMImpl_IInsertOperations.hxx>
+#include <GEOMImpl_ILine.hxx>
+#include <GEOMImpl_ILocalOperations.hxx>
+#include <GEOMImpl_IMarker.hxx>
+#include <GEOMImpl_IMeasure.hxx>
+#include <GEOMImpl_IMeasureOperations.hxx>
+#include <GEOMImpl_IMirror.hxx>
+#include <GEOMImpl_IOffset.hxx>
+#include <GEOMImpl_IPartition.hxx>
+#include <GEOMImpl_IPipe.hxx>
+#include <GEOMImpl_IPipeBiNormal.hxx>
+#include <GEOMImpl_IPipeDiffSect.hxx>
+#include <GEOMImpl_IPipePath.hxx>
+#include <GEOMImpl_IPipeShellSect.hxx>
+#include <GEOMImpl_IPipeTShape.hxx>
+#include <GEOMImpl_IPlane.hxx>
+#include <GEOMImpl_IPoint.hxx>
+#include <GEOMImpl_IPolyline.hxx>
+#include <GEOMImpl_IPosition.hxx>
+#include <GEOMImpl_IPrism.hxx>
+#include <GEOMImpl_IRevolution.hxx>
+#include <GEOMImpl_IRotate.hxx>
+#include <GEOMImpl_IScale.hxx>
+#include <GEOMImpl_IShapes.hxx>
+#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMImpl_ISketcher.hxx>
+#include <GEOMImpl_ISphere.hxx>
+#include <GEOMImpl_ISpline.hxx>
+#include <GEOMImpl_IThruSections.hxx>
+#include <GEOMImpl_ITorus.hxx>
+#include <GEOMImpl_ITransformOperations.hxx>
+#include <GEOMImpl_ITranslate.hxx>
+#include <GEOMImpl_IVector.hxx>
+#include <GEOMImpl_ImportDriver.hxx>
+#include <GEOMImpl_LineDriver.hxx>
+#include <GEOMImpl_MarkerDriver.hxx>
+#include <GEOMImpl_MeasureDriver.hxx>
+#include <GEOMImpl_MirrorDriver.hxx>
+#include <GEOMImpl_OffsetDriver.hxx>
+#include <GEOMImpl_PartitionDriver.hxx>
+#include <GEOMImpl_PipeDriver.hxx>
+#include <GEOMImpl_PipePathDriver.hxx>
+#include <GEOMImpl_PipeTShapeDriver.hxx>
+#include <GEOMImpl_PlaneDriver.hxx>
+#include <GEOMImpl_PointDriver.hxx>
+#include <GEOMImpl_PolylineDriver.hxx>
+#include <GEOMImpl_PositionDriver.hxx>
+#include <GEOMImpl_PrismDriver.hxx>
+#include <GEOMImpl_ProjectionDriver.hxx>
+#include <GEOMImpl_RevolutionDriver.hxx>
+#include <GEOMImpl_RotateDriver.hxx>
+#include <GEOMImpl_ScaleDriver.hxx>
+#include <GEOMImpl_ShapeDriver.hxx>
+#include <GEOMImpl_SketcherDriver.hxx>
+#include <GEOMImpl_SphereDriver.hxx>
+#include <GEOMImpl_SplineDriver.hxx>
+#include <GEOMImpl_ThruSectionsDriver.hxx>
+#include <GEOMImpl_TorusDriver.hxx>
+#include <GEOMImpl_TranslateDriver.hxx>
+#include <GEOMImpl_Types.hxx>
+#include <GEOMImpl_VectorDriver.hxx>
+#include <GEOMUtils.hxx>
+#include <GEOM_Application.hxx>
+#include <GEOM_Application.ixx>
+#include <GEOM_Application.jxx>
+#include <GEOM_DataMapIteratorOfDataMapOfAsciiStringTransient.hxx>
+#include <GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx>
+#include <GEOM_DataMapOfAsciiStringTransient.hxx>
+#include <GEOM_Engine.hxx>
+#include <GEOM_Function.hxx>
+#include <GEOM_GEOMImpl.hxx>
+#include <GEOM_IOperations.hxx>
+#include <GEOM_ISubShape.hxx>
+#include <GEOM_Object.hxx>
+#include <GEOM_PythonDump.hxx>
+#include <GEOM_Solver.hxx>
+#include <GEOM_SubShapeDriver.hxx>
+#include <GUID.txt>
+#include <Handle_GEOM_Application.hxx>
+#include <Handle_GEOM_DataMapNodeOfDataMapOfAsciiStringTransient.hxx>
+#include <NMTDS_BndSphere.hxx>
+#include <NMTDS_BndSphere.lxx>
+#include <NMTDS_BndSphereTree.hxx>
+#include <NMTDS_BoxBndTree.hxx>
+#include <NMTDS_CArray1OfIndexRange.hxx>
+#include <NMTDS_DataMapIteratorOfDataMapOfIntegerMapOfInteger.hxx>
+#include <NMTDS_DataMapOfIntegerMapOfInteger.hxx>
+#include <NMTDS_IndexRange.hxx>
+#include <NMTDS_IndexedDataMapOfIntegerShape.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBndSphere.hxx>
+#include <NMTDS_IndexedDataMapOfShapeBox.hxx>
+#include <NMTDS_InterfPool.hxx>
+#include <NMTDS_InterfType.hxx>
+#include <NMTDS_Iterator.hxx>
+#include <NMTDS_IteratorCheckerSI.hxx>
+#include <NMTDS_ListIteratorOfListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <NMTDS_ListIteratorOfListOfPair.hxx>
+#include <NMTDS_ListIteratorOfListOfPairBoolean.hxx>
+#include <NMTDS_ListIteratorOfListOfPassKey.hxx>
+#include <NMTDS_ListIteratorOfListOfPassKeyBoolean.hxx>
+#include <NMTDS_ListOfIndexedDataMapOfShapeAncestorsSuccessors.hxx>
+#include <NMTDS_ListOfPair.hxx>
+#include <NMTDS_ListOfPairBoolean.hxx>
+#include <NMTDS_ListOfPassKey.hxx>
+#include <NMTDS_ListOfPassKeyBoolean.hxx>
+#include <NMTDS_MapIteratorOfMapOfPairBoolean.hxx>
+#include <NMTDS_MapIteratorOfMapOfPassKey.hxx>
+#include <NMTDS_MapIteratorOfMapOfPassKeyBoolean.hxx>
+#include <NMTDS_MapOfPairBoolean.hxx>
+#include <NMTDS_MapOfPassKey.hxx>
+#include <NMTDS_MapOfPassKeyBoolean.hxx>
+#include <NMTDS_PInterfPool.hxx>
+#include <NMTDS_PIterator.hxx>
+#include <NMTDS_PShapesDataStructure.hxx>
+#include <NMTDS_Pair.hxx>
+#include <NMTDS_PairBoolean.hxx>
+#include <NMTDS_PairMapHasher.hxx>
+#include <NMTDS_PassKey.hxx>
+#include <NMTDS_PassKeyBoolean.hxx>
+#include <NMTDS_PassKeyMapHasher.hxx>
+#include <NMTDS_PassKeyShape.hxx>
+#include <NMTDS_PassKeyShapeMapHasher.hxx>
+#include <NMTDS_ShapesDataStructure.hxx>
+#include <NMTDS_Tools.hxx>
+#include <NMTTools_CheckerSI.hxx>
+#include <NMTTools_CommonBlock.hxx>
+#include <NMTTools_CommonBlockAPI.hxx>
+#include <NMTTools_CommonBlockPool.hxx>
+#include <NMTTools_CoupleOfShape.hxx>
+#include <NMTTools_DEProcessor.hxx>
+#include <NMTTools_DataMapIteratorOfDataMapOfIntegerFaceInfo.hxx>
+#include <NMTTools_DataMapIteratorOfDataMapOfIntegerListOfPaveBlock.hxx>
+#include <NMTTools_DataMapOfIntegerFaceInfo.hxx>
+#include <NMTTools_DataMapOfIntegerListOfPaveBlock.hxx>
+#include <NMTTools_FaceInfo.hxx>
+#include <NMTTools_FaceInfo.lxx>
+#include <NMTTools_IndexedDataMapOfIndexedMapOfInteger.hxx>
+#include <NMTTools_IndexedDataMapOfShapeIndexedMapOfShape.hxx>
+#include <NMTTools_IndexedDataMapOfShapePaveBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCommonBlock.hxx>
+#include <NMTTools_ListIteratorOfListOfCoupleOfShape.hxx>
+#include <NMTTools_ListOfCommonBlock.hxx>
+#include <NMTTools_ListOfCoupleOfShape.hxx>
+#include <NMTTools_MapIteratorOfMapOfPaveBlock.hxx>
+#include <NMTTools_MapOfPaveBlock.hxx>
+#include <NMTTools_PPaveFiller.hxx>
+#include <NMTTools_PaveFiller.hxx>
+#include <NMTTools_Tools.hxx>
+#include <OpUtil.hxx>
+#include <SALOME_Basics.hxx>
+#include <SALOME_Utils.hxx>
+#include <ShHealOper_ChangeOrientation.hxx>
+#include <ShHealOper_CloseContour.hxx>
+#include <ShHealOper_EdgeDivide.hxx>
+#include <ShHealOper_FillHoles.hxx>
+#include <ShHealOper_RemoveFace.hxx>
+#include <ShHealOper_RemoveInternalWires.hxx>
+#include <ShHealOper_Sewing.hxx>
+#include <ShHealOper_ShapeProcess.hxx>
+#include <ShHealOper_SpiltCurve2d.hxx>
+#include <ShHealOper_SplitCurve2d.hxx>
+#include <ShHealOper_SplitCurve3d.hxx>
+#include <ShHealOper_Tool.hxx>
+#include <Sketcher_Profile.hxx>
+#include <Utils_ExceptHandlers.hxx>
+#include <Utils_SALOME_Exception.hxx>
+#include <utilities.h>
+
+#endif
+
+#if defined(WIN32)
+#undef min
+#undef max
+#endif
+
+#endif
diff --git a/utils/misc/package_gmsh_getdp.sh b/utils/misc/package_gmsh_getdp.sh
index cc5b8cea7a996f93980ca49b0b83a1531a25d2d1..bd38599b6077f2de84892068858f2b90863e257e 100755
--- a/utils/misc/package_gmsh_getdp.sh
+++ b/utils/misc/package_gmsh_getdp.sh
@@ -14,8 +14,8 @@ up-to-date versions, documentation and examples." > /tmp/README.txt
 GMSH=svn
 GETDP=svn
 
-#GMSH=2.8.1
-#GETDP=2.4.0
+GMSH=2.8.2
+GETDP=2.4.1
 
 rm -rf gmsh-getdp-Windows64
 mkdir gmsh-getdp-Windows64