]> SALOME platform Git repositories - plugins/gmshplugin.git/commitdiff
Salome HOME
Enable Backward Compatability and Correct Mappings 3D meshing
authorAfeef <afeef.badri@gmail.com>
Fri, 3 Sep 2021 08:57:05 +0000 (10:57 +0200)
committereap <eap@opencascade.com>
Fri, 17 Sep 2021 11:18:30 +0000 (14:18 +0300)
- NEW 1: New algorithms for quad meshing (simple, blossom,
simplefullquad, and blossomfullquad)

- CHANGES 1: This commit allows compilation of Gmsh 4.1 &
Gmsh 4.8

src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx
src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx
src/GMSHPlugin/GMSHPlugin_Mesher.cxx
src/GUI/CMakeLists.txt
src/GUI/GMSHPluginGUI_HypothesisCreator.cxx
src/GUI/GMSHPluginGUI_HypothesisCreator.h
src/GUI/GMSHPlugin_msg_en.ts
src/GUI/GMSHPlugin_msg_fr.ts

index ccbabdedd9d155846c07eb860e7d883d8190fadc..1b3f36271518e3262ba759ed960ff73a73aaa8f5 100644 (file)
@@ -33,7 +33,11 @@ GMSHPlugin_Hypothesis::GMSHPlugin_Hypothesis (int hypId,
   : SMESH_Hypothesis(hypId, gen),
     _algo2d         (automatic),
     _algo3d         (delaunay3),
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+    _recomb2DAlgo   (simple),
+#else
     _recomb2DAlgo   (standard),
+#endif
     _recombineAll   (false),
     _subdivAlgo     (none),
     _remeshAlgo     (nosplit),
@@ -206,12 +210,12 @@ std::ostream & GMSHPlugin_Hypothesis::SaveTo(std::ostream & save)
           " " << _minSize              <<
           " " << (int)_secondOrder     <<
           " " << (int)_useIncomplElem  ;
-  
+
   save << " " << "__COMPOUNDS_BEGIN__";
   for (TCompound::const_iterator it = _compounds.begin();  it != _compounds.end(); ++it )
     save << " " << *it << " ";
   save << " " << "__COMPOUNDS_END__";
-  
+
   return save;
 }
 
@@ -226,13 +230,13 @@ std::istream & GMSHPlugin_Hypothesis::LoadFrom(std::istream & load)
     _is2d = (bool)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _algo2d = (Algo2D)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   if (!_is2d)
   {
     isOK = static_cast<bool>(load >> is);
@@ -241,74 +245,74 @@ std::istream & GMSHPlugin_Hypothesis::LoadFrom(std::istream & load)
     else
       load.clear(ios::badbit | load.rdstate());
   }
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _recomb2DAlgo = (Recomb2DAlgo)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _recombineAll = (bool)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _subdivAlgo = (SubdivAlgo)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _remeshAlgo = (RemeshAlgo)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _remeshPara = (RemeshPara)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> val);
   if (isOK)
     _smouthSteps = val;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> val);
   if (isOK)
     _sizeFactor = val;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> val);
   if (isOK)
     _maxSize = val;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> val);
   if (isOK)
     _minSize = val;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _secondOrder = (bool)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
+
   isOK = static_cast<bool>(load >> is);
   if (isOK)
     _useIncomplElem = (bool)is;
   else
     load.clear(ios::badbit | load.rdstate());
-  
-  
+
+
   std::string entry;
   isOK = static_cast<bool>(load >> entry);
   if (isOK && entry == "__COMPOUNDS_BEGIN__")
index dcd0bac7abde6fb57c7eb2e959bc6593fd12e870..cf413e0bbe17bc2d1ea069ff45d53b74337b95d5 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef _GMSHPlugin_Hypothesis_HXX_
 #define _GMSHPlugin_Hypothesis_HXX_
 
+#include "GmshVersion.h"
 #include "GMSHPlugin_Defs.hxx"
 
 #include "SMESH_Hypothesis.hxx"
@@ -49,7 +50,7 @@ public:
 
   void Set2DAlgo(Algo2D the2DAlgo);
   Algo2D Get2DAlgo() const { return _algo2d; }
-  
+
   enum Algo3D
   {
    delaunay3,
@@ -58,14 +59,25 @@ public:
    rtree
   };
 
+
   void Set3DAlgo(Algo3D the3DAlgo);
   Algo3D Get3DAlgo() const { return _algo3d; }
 
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+  enum Recomb2DAlgo
+  {
+   simple,
+   blossom,
+   simplefullquads,
+   blossomfullquads
+  };
+#else
   enum Recomb2DAlgo
   {
    standard,
    blossom
   };
+#endif
 
   void SetRecomb2DAlgo(Recomb2DAlgo theRecomb2DAlgo);
   Recomb2DAlgo GetRecomb2DAlgo() const { return _recomb2DAlgo; }
index 292db786f540bc14292a2f3d3128ea358e7d311a..e95b91c08bb4054b464f3dd922a482e66bf014de 100644 (file)
@@ -83,30 +83,18 @@ namespace
                           std::vector< ShapeBounds > & topoEdges )
   {
     topoEdges.clear();
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     for ( size_t i = 0; i < gEdge->compound.size(); ++i )
     {
       GEdge* gE = static_cast< GEdge* >( gEdge->compound[ i ]);
       topoEdges.push_back( ShapeBounds{ gE->bounds(), *((TopoDS_Edge*)gE->getNativePtr()) });
     }
-#endif
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION <3
+#else
     for ( size_t i = 0; i < gEdge->_compound.size(); ++i )
     {
       GEdge* gE = static_cast< GEdge* >( gEdge->_compound[ i ]);
       topoEdges.push_back( ShapeBounds{ gE->bounds(), *((TopoDS_Edge*)gE->getNativePtr()) });
     }
-#endif
-#if GMSH_MAJOR_VERSION <4
-    if ( gEdge->geomType() == GEntity::CompoundCurve )
-    {
-      std::vector<GEdge*> gEdges = ((GEdgeCompound*)gEdge)->getCompounds();
-      for ( size_t i = 0; i < gEdges.size(); ++i )
-      {
-        GEdge* gE = gEdges[ i ];
-        topoEdges.push_back( ShapeBounds{ gE->bounds(), *((TopoDS_Edge*)gE->getNativePtr()) });
-      }
-    }
 #endif
     return topoEdges.size();
   }
@@ -121,30 +109,18 @@ namespace
                           std::vector< ShapeBounds > & topoFaces )
   {
     topoFaces.clear();
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     for ( size_t i = 0; i < gFace->compound.size(); ++i )
     {
       GFace* gF = static_cast< GFace* >( gFace->compound[ i ]);
       topoFaces.push_back( ShapeBounds{ gF->bounds(), *((TopoDS_Face*)gF->getNativePtr()) });
     }
-#endif
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION <3
+#else
     for ( size_t i = 0; i < gFace->_compound.size(); ++i )
     {
       GFace* gF = static_cast< GFace* >( gFace->_compound[ i ]);
       topoFaces.push_back( ShapeBounds{ gF->bounds(), *((TopoDS_Face*)gF->getNativePtr()) });
     }
-#endif
-#if GMSH_MAJOR_VERSION <4
-    if ( gFace->geomType() == GEntity::CompoundSurface )
-    {
-      std::list<GFace*> gFaces = ((GFaceCompound*)gFace)->getCompounds();
-      for ( std::list<GFace*>::const_iterator itl = gFaces.begin();itl != gFaces.end(); ++itl )
-      {
-        GFace* gF = *itl;
-        topoFaces.push_back( ShapeBounds{ gF->bounds(), *((TopoDS_Face*)gF->getNativePtr()) });
-      }
-    }
 #endif
     return topoFaces.size();
   }
@@ -290,12 +266,21 @@ void GMSHPlugin_Mesher::SetGmshOptions()
   //ASSERT(ok);
   ok = GmshSetOption("Mesh", "Smoothing"                , (double)_smouthSteps)  ;
   //ASSERT(ok);
-  ok = GmshSetOption("Mesh", "CharacteristicLengthFactor", _sizeFactor)          ;
-  //ASSERT(ok);
-  ok = GmshSetOption("Mesh", "CharacteristicLengthMin"   , _minSize)        ;
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+  ok = GmshSetOption("Mesh", "MeshSizeFactor"              , _sizeFactor)     ;
+  ASSERT(ok);
+  ok = GmshSetOption("Mesh", "MeshSizeMin"                 , _minSize)        ;
   ASSERT(ok);
-  ok = GmshSetOption("Mesh", "CharacteristicLengthMax"   , _maxSize)        ;
+  ok = GmshSetOption("Mesh", "MeshSizeMax"                 , _maxSize)        ;
+  ASSERT(ok);
+#else
+  ok = GmshSetOption("Mesh", "CharacteristicLengthFactor"  , _sizeFactor)     ;
   ASSERT(ok);
+  ok = GmshSetOption("Mesh", "CharacteristicLengthMin"     , _minSize)        ;
+  ASSERT(ok);
+  ok = GmshSetOption("Mesh", "CharacteristicLengthMax"     , _maxSize)        ;
+  ASSERT(ok);
+#endif
   ok = GmshSetOption("Mesh", "ElementOrder"             , (_secondOrder)?2.:1.)  ;
   ASSERT(ok);
   if (_secondOrder)
@@ -345,7 +330,6 @@ void GMSHPlugin_Mesher::CreateGmshCompounds()
       if ( !it.More() )
         continue;
       TopAbs_ShapeEnum shapeType = it.Value().ShapeType();
-#if GMSH_MAJOR_VERSION >=4
       std::vector< std::pair< int, int > > dimTags;
       for ( ; it.More(); it.Next())
       {
@@ -374,39 +358,6 @@ void GMSHPlugin_Mesher::CreateGmshCompounds()
         _gModel->getGEOInternals()->setCompoundMesh( dim, tags );
         toSynchronize = true;
       }
-#else
-      // compound of edges
-      if (shapeType == TopAbs_EDGE)
-      {
-        MESSAGE("    shapeType == TopAbs_EDGE :");
-        int num = _gModel->getNumEdges()+1;
-        Curve *curve = CreateCurve(num, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.);
-        for ( ; it.More(); it.Next())
-        {
-          TopoDS_Shape topoShape = it.Value();
-          ASSERT(topoShape.ShapeType() == shapeType);
-          curve->compound.push_back(occgeo->addEdgeToModel(_gModel, (TopoDS_Edge&)topoShape)->tag());
-        }
-        toSynchronize = true;
-        Tree_Add(_gModel->getGEOInternals()->Curves, &curve);
-        //_gModel->importGEOInternals();
-      }
-      // compound of faces
-      else if (shapeType == TopAbs_FACE)
-      {
-        MESSAGE("    shapeType == TopAbs_FACE :");
-        int num = _gModel->getNumFaces()+1;
-        Surface *surface = CreateSurface(num, MSH_SURF_COMPOUND);
-        for ( ; it.More(); it.Next())
-        {
-          TopoDS_Shape topoShape = it.Value();
-          ASSERT(topoShape.ShapeType() == shapeType);
-          surface->compound.push_back(occgeo->addFaceToModel(_gModel, (TopoDS_Face&)topoShape)->tag());
-        }
-        toSynchronize = true;
-        Tree_Add(_gModel->getGEOInternals()->Surfaces, &surface);
-      }
-#endif
       if ( toSynchronize )
         _gModel->getGEOInternals()->synchronize(_gModel);
     }
@@ -419,7 +370,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds()
  */
 //================================================================================
 
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
 void GMSHPlugin_Mesher::SetCompoundMeshVisibility()
 {
 
@@ -525,7 +476,7 @@ void GMSHPlugin_Mesher::FillSMesh()
     // GET topoEdge CORRESPONDING TO gEdge
     TopoDS_Edge topoEdge;
     std::vector< ShapeBounds > topoEdges;
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     if(gEdge->haveParametrization())
 #else
     if ( gEdge->geomType() != GEntity::CompoundCurve )
@@ -617,7 +568,7 @@ void GMSHPlugin_Mesher::FillSMesh()
   {
     GFace *gFace = *it;
 
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     // Gmsh since version 4.3 is now producing extra surface and mesh when
     // compounds are involved. Since in Gmsh meshing procedure needs acess
     // to each of the original topology and the meshed topology. Hence  we
@@ -631,7 +582,7 @@ void GMSHPlugin_Mesher::FillSMesh()
     TopoDS_Face topoFace;
     std::vector< ShapeBounds > topoFaces;
 
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     if(gFace->haveParametrization())
 #else
     if ( gFace->geomType() != GEntity::CompoundSurface )
@@ -668,7 +619,7 @@ void GMSHPlugin_Mesher::FillSMesh()
   {
     GFace *gFace = *it;
 
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     if ( _compounds.size() && gFace->geomType() == GEntity::DiscreteSurface )
       continue;
 
@@ -1046,7 +997,7 @@ void  GMSHPlugin_Mesher::mymsg::operator()(std::string level, std::string msg)
         throw oss.str();
     }
     else
-        printf(oss.str().c_str());
+        printf("%s\n", oss.str().c_str());
   }
 }
 
@@ -1090,10 +1041,7 @@ bool GMSHPlugin_Mesher::Compute()
 
   if (!err)
   {
-#if GMSH_MAJOR_VERSION < 4
-    if (_compounds.size() > 0) _gModel->setCompoundVisibility();
-#endif
-#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=3
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
     if (_compounds.size() > 0)
       SetCompoundMeshVisibility();
 #endif
index 58990dc6c808be59f7863b64874f312513579fdd..35bd66bbfeed1eb30b7824cfa1422f428cc41576 100644 (file)
@@ -32,6 +32,7 @@ INCLUDE_DIRECTORIES(
   ${SMESH_INCLUDE_DIRS}
   ${Boost_INCLUDE_DIRS}
   ${OMNIORB_INCLUDE_DIR}
+  ${GMSH_INCLUDE_DIRS}
   ${CMAKE_CURRENT_BINARY_DIR}
   ${PROJECT_BINARY_DIR}/idl
   ${PROJECT_SOURCE_DIR}/src/GMSHPlugin
index ac0bd8d1a938d4624ee39d3c049676c2c59dcac2..61f634dbdad9c926bf62f4e0a2dec3a73743cb95 100644 (file)
@@ -56,7 +56,7 @@ enum Algo2D
    packingparallelograms
   };
 
-enum Algo3D
+  enum Algo3D
   {
    delaunay3,
    frontal3,
@@ -64,11 +64,21 @@ enum Algo3D
    rtree
   };
 
-enum Recomb2DAlgo
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+  enum Recomb2DAlgo
+  {
+   simple,
+   blossom,
+   simplefullquads,
+   blossomfullquads
+  };
+#else
+  enum Recomb2DAlgo
   {
    standard,
    blossom
   };
+#endif
 
 enum SubdivAlgo
   {
@@ -170,7 +180,11 @@ QFrame* GMSHPluginGUI_HypothesisCreator::buildFrame()
   aGroupLayout->addWidget( new QLabel( tr( "GMSH_2D_RECOMB_ALGO" ), GroupC1 ), row, 0 );
   myRecomb2DAlgo = new QComboBox( GroupC1 );
   QStringList typesRecomb2DAlgo;
+#if GMSH_MAJOR_VERSION >=4 && GMSH_MINOR_VERSION >=8
+  typesRecomb2DAlgo << tr( "GMSH_SIMPLE" ) << tr( "GMSH_BLOSSOM" ) << tr( "GMSH_SIMPLE_FULL_QUADS" ) << tr( "GMSH_BLOSSOM_FULL_QUADS" );
+#else
   typesRecomb2DAlgo << tr( "GMSH_STANDARD" ) << tr( "GMSH_BLOSSOM" );
+#endif
   myRecomb2DAlgo->addItems( typesRecomb2DAlgo );
   aGroupLayout->addWidget( myRecomb2DAlgo, row, 1 );
   row++;
index 5f8225d23fac96dc762c916d6511f087433f9032..d0735660e272f5767981ba7927718f45015a5ef8 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef GMSHPLUGINGUI_HypothesisCreator_HeaderFile
 #define GMSHPLUGINGUI_HypothesisCreator_HeaderFile
 
+#include "GmshVersion.h"
 #include "GMSHPluginGUI.h"
 
 #include <SMESHGUI_Hypotheses.h>
index b25272639c4c6ffd2f2960995ed33cd6b9d5fb10..e8528856787b0792e842196433bc90e1b0b24184 100644 (file)
         <source>GMSH_DELAUNAY3</source>
         <translation>Delaunay</translation>
     </message>
+    <message>
+        <source>GMSH_FRONTAL3</source>
+        <translation>Frontal</translation>
+    </message>
     <message>
         <source>GMSH_FRONTAL_DELAUNAY</source>
         <translation>Frontal Delaunay</translation>
     </message>
+    <message>
+        <source>GMSH_FRONTAL_HEX</source>
+        <translation>Frontal Hex</translation>
+    </message>
     <message>
         <source>GMSH_MMG3D</source>
         <translation>MMG3D</translation>
         <source>GMSH_2D_RECOMB_ALGO</source>
         <translation>2D recombination algorithm</translation>
     </message>
+    <message>
+        <source>GMSH_SIMPLE</source>
+        <translation>Simple</translation>
+    </message>
     <message>
         <source>GMSH_STANDARD</source>
         <translation>Standard</translation>
         <source>GMSH_BLOSSOM</source>
         <translation>Blossom</translation>
     </message>
+    <message>
+        <source>GMSH_SIMPLE_FULL_QUADS</source>
+        <translation>Simple full-quad</translation>
+    </message>
+    <message>
+        <source>GMSH_BLOSSOM_FULL_QUADS</source>
+        <translation>Blossom full-quad</translation>
+    </message>
     <message>
         <source>GMSH_RECOMBINE_ALL</source>
         <translation>Recombine all triangular meshes</translation>
index f119c8221392f7dde88aed3d77ea121c13c5b3c2..00b0e94d66024aa1d94ba1b2ac34915a68679450 100644 (file)
         <source>GMSH_3D_ALGO</source>
         <translation>Algorithme 3D</translation>
     </message>
+    <message>
+        <source>GMSH_FRONTAL3</source>
+        <translation>Frontal</translation>
+    </message>
     <message>
         <source>GMSH_DELAUNAY3</source>
         <translation>Delaunay</translation>
         <source>GMSH_FRONTAL_DELAUNAY</source>
         <translation>Frontal Delaunay</translation>
     </message>
+    <message>
+        <source>GMSH_FRONTAL_HEX</source>
+        <translation>Frontal Hex</translation>
+    </message>
     <message>
         <source>GMSH_MMG3D</source>
         <translation>MMG3D</translation>
         <source>GMSH_2D_RECOMB_ALGO</source>
         <translation>Algorithme de recombinaison 2D</translation>
     </message>
+    <message>
+        <source>GMSH_SIMPLE</source>
+        <translation>Simple</translation>
+    </message>
     <message>
         <source>GMSH_STANDARD</source>
         <translation>Standard</translation>
         <source>GMSH_BLOSSOM</source>
         <translation>Blossom</translation>
     </message>
+    <message>
+        <source>GMSH_SIMPLE_FULL_QUADS</source>
+        <translation>Simple quads uniquement</translation>
+    </message>
+    <message>
+        <source>GMSH_BLOSSOM_FULL_QUADS</source>
+        <translation>Blossom quads uniquement</translation>
+    </message>
     <message>
         <source>GMSH_RECOMBINE_ALL</source>
         <translation>Recombiner tous les triangles</translation>