From: eap Date: Wed, 6 Mar 2019 10:42:07 +0000 (+0300) Subject: Port Compound feature X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=40f05dc9a3226729e5716c8357a0484a383d35d8;p=plugins%2Fgmshplugin.git Port Compound feature --- diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index 4c397d9..b925bb1 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -58,7 +58,8 @@ #include #if GMSH_MAJOR_VERSION >=4 -#include "GmshGlobal.h" +#include +#include #endif using namespace std; @@ -198,6 +199,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen(); OCC_Internals* occgeo = _gModel->getOCCInternals(); + bool toSynchronize = false; for(std::set::const_iterator its = _compounds.begin();its != _compounds.end(); ++its ) { @@ -214,13 +216,34 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() } if ( !aGeomObj->_is_nil() ) geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); - + TopAbs_ShapeEnum geomType = geomShape.ShapeType(); if ( geomType == TopAbs_COMPOUND)// voir s'il ne faut pas mettre une erreur dans le cas contraire { MESSAGE("shapeType == TopAbs_COMPOUND"); TopoDS_Iterator it(geomShape); TopAbs_ShapeEnum shapeType = it.Value().ShapeType(); +#if GMSH_MAJOR_VERSION >=4 + std::vector< std::pair< int, int > > dimTags; + for ( ; it.More(); it.Next()) + { + const TopoDS_Shape& topoShape = it.Value(); + ASSERT(topoShape.ShapeType() == shapeType); + occgeo->importShapes( &topoShape, false, dimTags ); + } + std::vector tags; + int dim = ( shapeType == TopAbs_EDGE ) ? 1 : 2; + for ( size_t i = 0; i < dimTags.size(); ++i ) + { + if ( dimTags[i].first == dim ) + tags.push_back( dimTags[i].second ); + } + if ( !tags.empty() ) + { + _gModel->getGEOInternals()->setCompoundMesh( dim, tags ); + toSynchronize = true; + } +#else // compound of edges if (shapeType == TopAbs_EDGE) { @@ -233,6 +256,7 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() 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(); } @@ -248,9 +272,12 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() ASSERT(topoShape.ShapeType() == shapeType); surface->compound.push_back(occgeo->addFaceToModel(_gModel, (TopoDS_Face&)topoShape)->tag()); } + toSynchronize = true; Tree_Add(_gModel->getGEOInternals()->Surfaces, &surface); - _gModel->getGEOInternals()->synchronize(_gModel); } +#endif + if ( toSynchronize ) + _gModel->getGEOInternals()->synchronize(_gModel); } } } @@ -307,7 +334,8 @@ void GMSHPlugin_Mesher::FillSMesh() } // ADD 1D ELEMENTS - for(GModel::eiter it = _gModel->firstEdge(); it != _gModel->lastEdge(); ++it){ + for(GModel::eiter it = _gModel->firstEdge(); it != _gModel->lastEdge(); ++it) + { GEdge *gEdge = *it; // GET topoEdge CORRESPONDING TO gEdge (map if compound) @@ -324,6 +352,13 @@ void GMSHPlugin_Mesher::FillSMesh() continue; } } +#if GMSH_MAJOR_VERSION >=4 + for ( size_t i = 0; i < gEdge->_compound.size(); ++i ) + { + GEdge* gE = static_cast< GEdge* >( gEdge->_compound[ i ]); + topoEdges.insert( std::make_pair( gE, *((TopoDS_Edge*)gE->getNativePtr())) ); + } +#else else { // compound case, map construction GEdge/TopoDS_Edge @@ -333,7 +368,8 @@ void GMSHPlugin_Mesher::FillSMesh() topoEdges.insert( pair(*itv,*((TopoDS_Edge*)(*itv)->getNativePtr())) ); } } - +#endif + // FILL SMESH FOR topoEdge //nodes for(unsigned int i = 0; i < gEdge->mesh_vertices.size(); i++) @@ -442,15 +478,23 @@ void GMSHPlugin_Mesher::FillSMesh() continue; } } +#if GMSH_MAJOR_VERSION >=4 + for ( size_t i = 0; i < gFace->_compound.size(); ++i ) + { + GFace* gF = static_cast< GFace* >( gFace->_compound[ i ]); + topoFaces.insert( std::make_pair( gF, *((TopoDS_Face*)gF->getNativePtr())) ); + } +#else else { // compound case, map construction GFace/TopoDS_Face std::list gFaces = ((GFaceCompound*)gFace)->getCompounds(); for(std::list::const_iterator itl = gFaces.begin();itl != gFaces.end(); ++itl) { - topoFaces.insert( pair(*itl,*((TopoDS_Face*)(*itl)->getNativePtr())) ); + topoFaces.insert( std::make_pair( *itl, *((TopoDS_Face*)(*itl)->getNativePtr())) ); } } +#endif // FILL SMESH FOR topoFace //nodes @@ -901,7 +945,9 @@ bool GMSHPlugin_Mesher::Compute() if (!err) { +#if GMSH_MAJOR_VERSION < 4 if (_compounds.size() > 0) _gModel->setCompoundVisibility(); +#endif FillSMesh(); } delete _gModel;