From: eap Date: Wed, 19 Feb 2020 16:22:33 +0000 (+0300) Subject: #18723 [CEA 18597] GMSH Hypothesis and groups as compounds X-Git-Tag: V9_5_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=201d3c7871210b7a4788f3c7da70b54fede55808;p=plugins%2Fgmshplugin.git #18723 [CEA 18597] GMSH Hypothesis and groups as compounds --- diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index ea00aaf..2578639 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -20,7 +20,8 @@ IF(SALOME_BUILD_GUI) SET(GMSHPLUGIN_RESOURCES_FILES_WITH_GUI - gmsh.png + gmsh.png + gmsh_small.png ) ENDIF(SALOME_BUILD_GUI) diff --git a/resources/gmsh_small.png b/resources/gmsh_small.png new file mode 100644 index 0000000..2e2aa76 Binary files /dev/null and b/resources/gmsh_small.png differ diff --git a/src/GMSHPlugin/GMSHPlugin_GMSH_2D.cxx b/src/GMSHPlugin/GMSHPlugin_GMSH_2D.cxx index 1450824..259b8b4 100644 --- a/src/GMSHPlugin/GMSHPlugin_GMSH_2D.cxx +++ b/src/GMSHPlugin/GMSHPlugin_GMSH_2D.cxx @@ -108,7 +108,7 @@ bool GMSHPlugin_GMSH_2D::CheckHypothesis //============================================================================= bool GMSHPlugin_GMSH_2D::Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape) + const TopoDS_Shape& aShape) { GMSHPlugin_Mesher mesher(&aMesh, aShape); mesher.SetParameters(dynamic_cast(_hypothesis)); diff --git a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx index ea995e2..6df94ea 100644 --- a/src/GMSHPlugin/GMSHPlugin_Mesher.cxx +++ b/src/GMSHPlugin/GMSHPlugin_Mesher.cxx @@ -209,6 +209,7 @@ void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp) _secondOrder = false; _useIncomplElem = true; _is2d = false; + _compounds.clear(); } } @@ -306,14 +307,17 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() CORBA::Object_var obj = SMESH_Gen_i::getStudyServant()->ConvertIORToObject(aVal); aGeomObj = GEOM::GEOM_Object::_narrow(obj); } - if ( !aGeomObj->_is_nil() ) - geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); + geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() ); + if ( geomShape.IsNull() ) + continue; 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); + if ( !it.More() ) + continue; TopAbs_ShapeEnum shapeType = it.Value().ShapeType(); #if GMSH_MAJOR_VERSION >=4 std::vector< std::pair< int, int > > dimTags; @@ -321,7 +325,16 @@ void GMSHPlugin_Mesher::CreateGmshCompounds() { const TopoDS_Shape& topoShape = it.Value(); ASSERT(topoShape.ShapeType() == shapeType); - occgeo->importShapes( &topoShape, false, dimTags ); + if ( _mesh->GetMeshDS()->ShapeToIndex( topoShape ) > 0 ) + occgeo->importShapes( &topoShape, false, dimTags ); + else + { + TopoDS_Shape face = TopExp_Explorer( _shape, shapeType ).Current(); + SMESH_subMesh* sm = _mesh->GetSubMesh( face ); + sm->GetComputeError() = + SMESH_ComputeError::New + ( COMPERR_WARNING, "Compound shape does not belong to the main geometry. Ingnored"); + } } std::vector tags; int dim = ( shapeType == TopAbs_EDGE ) ? 1 : 2; diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx index 66b46f2..6db0203 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.cxx @@ -110,6 +110,7 @@ bool GMSHPluginGUI_HypothesisCreator::checkParams(QString& msg) const readParamsFromHypo( data_old ); readParamsFromWidgets( data_new ); bool res = storeParamsToHypo( data_new ); + msg = data_new.myErrorMsg; storeParamsToHypo( data_old ); return res; } @@ -282,7 +283,7 @@ void GMSHPluginGUI_HypothesisCreator::onAddCompound() SALOME_ListIO ListSelectedObjects; mySel->selectedObjects(ListSelectedObjects, NULL, false ); SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects); - for (Object_It ; Object_It.More() ; Object_It.Next()) + for ( ; Object_It.More() ; Object_It.Next()) { Handle(SALOME_InteractiveObject) anObject = Object_It.Value(); std::string entry, shapeName; @@ -439,7 +440,7 @@ bool GMSHPluginGUI_HypothesisCreator::readParamsFromHypo( GmshHypothesisData& h_ GMSHPluginGUI_HypothesisCreator* that = (GMSHPluginGUI_HypothesisCreator*)this; GMSHPlugin::string_array_var myEntries = h->GetCompoundOnEntries(); - for ( int i=0 ; ilength() ; i++ ) + for ( CORBA::ULong i=0 ; ilength() ; i++ ) { QString entry = myEntries[i].in(); that->myCompoundSet.insert(entry); @@ -478,10 +479,19 @@ bool GMSHPluginGUI_HypothesisCreator::storeParamsToHypo( const GmshHypothesisDat h->SetSecondOrder( h_data.mySecondOrder ); h->SetUseIncomplElem( h_data.myUseIncomplElem ); h->SetIs2d( myIs2D ); - + + QString mainEntry = getMainShapeEntry(); for (QSet::const_iterator i = myCompoundSet.begin(); i != myCompoundSet.end(); ++i) { - const QString entry = *i; + QString entry = *i; + if ( myCompoundToRemove.contains( entry )) + continue; + if ( !mainEntry.isEmpty() && !entry.startsWith( mainEntry )) + { + h_data.myErrorMsg = "Compound group is not defined on the main geometry"; + ok = false; + break; + } h->SetCompoundOnEntry(entry.toLatin1().constData()); } for (QSet::const_iterator i = myCompoundToRemove.begin(); i != myCompoundToRemove.end(); ++i) diff --git a/src/GUI/GMSHPluginGUI_HypothesisCreator.h b/src/GUI/GMSHPluginGUI_HypothesisCreator.h index cab51c9..968273c 100644 --- a/src/GUI/GMSHPluginGUI_HypothesisCreator.h +++ b/src/GUI/GMSHPluginGUI_HypothesisCreator.h @@ -45,6 +45,7 @@ typedef struct bool mySecondOrder; double mySizeFactor,myMaxSize, myMinSize; QString myMaxSizeVar, myMinSizeVar, mySmouthStepsVar, mySizeFactorVar; + mutable QString myErrorMsg; } GmshHypothesisData; /*! diff --git a/src/GUI/GMSHPlugin_images.ts b/src/GUI/GMSHPlugin_images.ts index 2d83112..a298c5d 100644 --- a/src/GUI/GMSHPlugin_images.ts +++ b/src/GUI/GMSHPlugin_images.ts @@ -11,5 +11,21 @@ ICON_DLG_GMSH_PARAMETERS_2D gmsh.png + + ICON_SMESH_TREE_ALGO_GMSH + gmsh_small.png + + + ICON_SMESH_TREE_ALGO_GMSH_2D + gmsh_small.png + + + ICON_SMESH_TREE_HYPO_GMSH_Parameters_2D + gmsh_small.png + + + ICON_SMESH_TREE_HYPO_GMSH_Parameters_2D + gmsh_small.png +