From: Afeef Date: Fri, 3 Sep 2021 08:57:05 +0000 (+0200) Subject: Enable Backward Compatability and Correct Mappings 3D meshing X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a98398e02f928bce33a423ec1eddba20a98ba82b;p=plugins%2Fgmshplugin.git Enable Backward Compatability and Correct Mappings 3D meshing - 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 --- diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx index ccbabde..1b3f362 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.cxx @@ -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(load >> is); if (isOK) _algo2d = (Algo2D)is; else load.clear(ios::badbit | load.rdstate()); - + if (!_is2d) { isOK = static_cast(load >> is); @@ -241,74 +245,74 @@ std::istream & GMSHPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(ios::badbit | load.rdstate()); } - + isOK = static_cast(load >> is); if (isOK) _recomb2DAlgo = (Recomb2DAlgo)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _recombineAll = (bool)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _subdivAlgo = (SubdivAlgo)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _remeshAlgo = (RemeshAlgo)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _remeshPara = (RemeshPara)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> val); if (isOK) _smouthSteps = val; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> val); if (isOK) _sizeFactor = val; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> val); if (isOK) _maxSize = val; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> val); if (isOK) _minSize = val; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _secondOrder = (bool)is; else load.clear(ios::badbit | load.rdstate()); - + isOK = static_cast(load >> is); if (isOK) _useIncomplElem = (bool)is; else load.clear(ios::badbit | load.rdstate()); - - + + std::string entry; isOK = static_cast(load >> entry); if (isOK && entry == "__COMPOUNDS_BEGIN__") diff --git a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx index dcd0bac..cf413e0 100644 --- a/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx +++ b/src/GMSHPlugin/GMSHPlugin_Hypothesis.hxx @@ -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; } diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index 292db78..e95b91c 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -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 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 gFaces = ((GFaceCompound*)gFace)->getCompounds(); - for ( std::list::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 diff --git a/src/GUI/CMakeLists.txt b/src/GUI/CMakeLists.txt index 58990dc..35bd66b 100644 --- a/src/GUI/CMakeLists.txt +++ b/src/GUI/CMakeLists.txt @@ -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 diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx index ac0bd8d..61f634d 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx @@ -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++; diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.h b/src/GUI/GMSHPluginGUI_HypothesisCreator.h index 5f8225d..d073566 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.h +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.h @@ -21,6 +21,7 @@ #ifndef GMSHPLUGINGUI_HypothesisCreator_HeaderFile #define GMSHPLUGINGUI_HypothesisCreator_HeaderFile +#include "GmshVersion.h" #include "GMSHPluginGUI.h" #include diff --git a/src/GUI/GMSHPlugin_msg_en.ts b/src/GUI/GMSHPlugin_msg_en.ts index b252726..e852885 100644 --- a/src/GUI/GMSHPlugin_msg_en.ts +++ b/src/GUI/GMSHPlugin_msg_en.ts @@ -87,10 +87,18 @@ GMSH_DELAUNAY3 Delaunay + + GMSH_FRONTAL3 + Frontal + GMSH_FRONTAL_DELAUNAY Frontal Delaunay + + GMSH_FRONTAL_HEX + Frontal Hex + GMSH_MMG3D MMG3D @@ -103,6 +111,10 @@ GMSH_2D_RECOMB_ALGO 2D recombination algorithm + + GMSH_SIMPLE + Simple + GMSH_STANDARD Standard @@ -111,6 +123,14 @@ GMSH_BLOSSOM Blossom + + GMSH_SIMPLE_FULL_QUADS + Simple full-quad + + + GMSH_BLOSSOM_FULL_QUADS + Blossom full-quad + GMSH_RECOMBINE_ALL Recombine all triangular meshes diff --git a/src/GUI/GMSHPlugin_msg_fr.ts b/src/GUI/GMSHPlugin_msg_fr.ts index f119c82..00b0e94 100644 --- a/src/GUI/GMSHPlugin_msg_fr.ts +++ b/src/GUI/GMSHPlugin_msg_fr.ts @@ -87,6 +87,10 @@ GMSH_3D_ALGO Algorithme 3D + + GMSH_FRONTAL3 + Frontal + GMSH_DELAUNAY3 Delaunay @@ -95,6 +99,10 @@ GMSH_FRONTAL_DELAUNAY Frontal Delaunay + + GMSH_FRONTAL_HEX + Frontal Hex + GMSH_MMG3D MMG3D @@ -107,6 +115,10 @@ GMSH_2D_RECOMB_ALGO Algorithme de recombinaison 2D + + GMSH_SIMPLE + Simple + GMSH_STANDARD Standard @@ -115,6 +127,14 @@ GMSH_BLOSSOM Blossom + + GMSH_SIMPLE_FULL_QUADS + Simple quads uniquement + + + GMSH_BLOSSOM_FULL_QUADS + Blossom quads uniquement + GMSH_RECOMBINE_ALL Recombiner tous les triangles