]> SALOME platform Git repositories - plugins/gmshplugin.git/commitdiff
Salome HOME
#18723 [CEA 18597] GMSH Hypothesis and groups as compounds
authoreap <eap@opencascade.com>
Wed, 19 Feb 2020 16:22:33 +0000 (19:22 +0300)
committereap <eap@opencascade.com>
Wed, 19 Feb 2020 16:22:33 +0000 (19:22 +0300)
resources/CMakeLists.txt
resources/gmsh_small.png [new file with mode: 0644]
src/GMSHPlugin/GMSHPlugin_GMSH_2D.cxx
src/GMSHPlugin/GMSHPlugin_Mesher.cxx
src/GUI/GMSHPluginGUI_HypothesisCreator.cxx
src/GUI/GMSHPluginGUI_HypothesisCreator.h
src/GUI/GMSHPlugin_images.ts

index ea00aaf797768c3c1dc2cf5e66e80c33e72c5f3c..2578639e3a81e1d0d187f898b38d96ecf0162a8f 100644 (file)
@@ -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 (file)
index 0000000..2e2aa76
Binary files /dev/null and b/resources/gmsh_small.png differ
index 1450824ef6e4249b7feed9373cf50a6d75fbd786..259b8b499a5a2fd57b76edd7c13fe669f6d46a46 100644 (file)
@@ -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<const GMSHPlugin_Hypothesis*>(_hypothesis));
index ea995e2b49be1328a8f02883e2c1d9e254f5eaf7..6df94eaf19a7db357a627d11bed24c14250df7ce 100644 (file)
@@ -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<int> tags;
       int dim = ( shapeType == TopAbs_EDGE ) ? 1 : 2;
index 66b46f28366e8f361c198ddb3cb6ce34440e2b87..6db02032157ad24dfa969adde2ddf32da63f4093 100644 (file)
@@ -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 ; i<myEntries->length() ; i++ )
+  for ( CORBA::ULong i=0 ; i<myEntries->length() ; 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<QString>::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<QString>::const_iterator i = myCompoundToRemove.begin(); i != myCompoundToRemove.end(); ++i)
index cab51c9ca7eed4253f1287e9ac29d08c7b7d2120..968273c6eef623101f4745d52b783232753d07ec 100644 (file)
@@ -45,6 +45,7 @@ typedef struct
   bool                mySecondOrder;
   double              mySizeFactor,myMaxSize, myMinSize;
   QString             myMaxSizeVar, myMinSizeVar, mySmouthStepsVar, mySizeFactorVar;
+  mutable QString     myErrorMsg;
 } GmshHypothesisData;
 
 /*!
index 2d83112c13a197a5bfc538f70e2ad8bbd28fba7c..a298c5de7bf1b9a996f10dbab30ef10c21a3d9aa 100644 (file)
             <source>ICON_DLG_GMSH_PARAMETERS_2D</source>
             <translation>gmsh.png</translation>
         </message>
+        <message>
+            <source>ICON_SMESH_TREE_ALGO_GMSH</source>
+            <translation>gmsh_small.png</translation>
+        </message>
+        <message>
+            <source>ICON_SMESH_TREE_ALGO_GMSH_2D</source>
+            <translation>gmsh_small.png</translation>
+        </message>
+        <message>
+            <source>ICON_SMESH_TREE_HYPO_GMSH_Parameters_2D</source>
+            <translation>gmsh_small.png</translation>
+        </message>
+        <message>
+            <source>ICON_SMESH_TREE_HYPO_GMSH_Parameters_2D</source>
+            <translation>gmsh_small.png</translation>
+        </message>
     </context>
 </TS>