Salome HOME
BUG: SMESH::GetGEOMGen() returns GEOM_Engine instead of SHAPERSTUDY
authoreap <eap@opencascade.com>
Wed, 15 Jan 2020 13:12:51 +0000 (16:12 +0300)
committereap <eap@opencascade.com>
Wed, 15 Jan 2020 13:12:51 +0000 (16:12 +0300)
1) GetGEOMGen() -> GetGEOMGen( GEOM::GEOM_Object_ptr go )
2) some formatting (whitespace changes)

src/SMESHGUI/SMESHGUI_ComputeDlg.cxx
src/SMESHGUI/SMESHGUI_FieldSelectorWdg.cxx
src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx
src/SMESHGUI/SMESHGUI_GEOMGenUtils.h
src/SMESHGUI/SMESHGUI_GroupDlg.cxx
src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx
src/SMESHGUI/SMESHGUI_MeshOp.cxx
src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx

index 10e4b196f3c757253c0dd509f7931277ee8706aa..14e05427db392f2712158ad90e0c4d7ab9ba4a4d 100644 (file)
@@ -1251,8 +1251,8 @@ void SMESHGUI_BaseComputeOp::stopOperation()
 
 void SMESHGUI_BaseComputeOp::onPublishShape()
 {
-  GEOM::GEOM_Gen_var      geomGen = SMESH::GetGEOMGen();
   GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
+  GEOM::GEOM_Gen_var      geomGen = SMESH::GetGEOMGen( meshShape );
 
   QStringList entryList;
   QList<int> rows;
index a9d6ad8910ecd7d5aa64612dc1657ee957ac9d0f..e7f05170ec47f05e1ca1b1001e8b2509d1592fed 100644 (file)
@@ -91,9 +91,6 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
 {
   myFields = & fields;
   myTree->clear();
-  
-  GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
-  GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
 
   for ( int iM = 0; iM < meshes.count(); ++iM )
   {
@@ -109,6 +106,9 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
         QTreeWidgetItem* meshItem = createItem( myTree, meshes[iM].second, iM );
 
         GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
+        GEOM::GEOM_Gen_var  geomGen = SMESH::GetGEOMGen( shape );
+        GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
+
         fields = fieldOp->GetFields( shape );
         for ( size_t iF = 0; iF < fields->length(); ++iF )
         {
index 05a9125820f604732f18aa7449b428187ab38e18..8be766f2f308815ffc9661aa4bcd3d80e7afd610 100644 (file)
 
 namespace SMESH
 {
-  GEOM::GEOM_Gen_var GetGEOMGen()
+  GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go )
   {
-    static GEOM::GEOM_Gen_var aGEOMGen;
-
-    if(CORBA::is_nil(aGEOMGen)) {
-      if ( GeometryGUI::GetGeomGen()->_is_nil() )
-        GeometryGUI::InitGeomGen();
-      aGEOMGen = GeometryGUI::GetGeomGen();
-    }
-    return aGEOMGen;
+    GEOM::GEOM_Gen_ptr gen;
+    if ( !CORBA::is_nil( go ))
+      gen = go->GetGen();
+    return gen;
   }
 
   GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh,
@@ -155,14 +151,18 @@ namespace SMESH
   GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
                                      long                  theID)
   {
-    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+    if ( CORBA::is_nil( theMainShape ))
+      return GEOM::GEOM_Object::_nil();
+
+    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( theMainShape );
     if (geomGen->_is_nil())
       return GEOM::GEOM_Object::_nil();
-    GEOM::GEOM_IShapesOperations_wrap aShapesOp =
-      geomGen->GetIShapesOperations();
+
+    GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
     if (aShapesOp->_is_nil())
       return GEOM::GEOM_Object::_nil();
-    GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape (theMainShape,theID);
+
+    GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape( theMainShape, theID );
     return subShape._retn();
   }
 
index 08b643d519d879a9f6dbb981ebb236ee62ca541a..8afed3981667d45fd035ff170492bb1c51338699 100644 (file)
@@ -45,7 +45,7 @@ class QString;
 
 namespace SMESH
 {
-  SMESHGUI_EXPORT GEOM::GEOM_Gen_var    GetGEOMGen();
+  SMESHGUI_EXPORT GEOM::GEOM_Gen_var    GetGEOMGen( GEOM::GEOM_Object_ptr go );
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh( _PTR(SObject), bool* isMesh=0 );
 
@@ -53,7 +53,7 @@ namespace SMESH
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_var GetGeom( Handle(SALOME_InteractiveObject) io );
 
-  SMESHGUI_EXPORT char* GetGeomName( _PTR(SObject) smeshSO );
+  SMESHGUI_EXPORT char*                 GetGeomName( _PTR(SObject) smeshSO );
 
   SMESHGUI_EXPORT GEOM::GEOM_Object_ptr GetSubShape( GEOM::GEOM_Object_ptr, long );
 
index ad5bddd51eafc5e4f9960e6d54abac059b3c5b14..62666c97ff45ceaf4d0d68f2668d3ecc28fd56c8 100644 (file)
@@ -1055,12 +1055,11 @@ bool SMESHGUI_GroupDlg::onApply()
       }
       else {
         SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
-        if ( aSMESHGen->_is_nil() )
+        if ( aSMESHGen->_is_nil() || myGeomObjects->length() == 0 )
           return false;
 
         // create a geometry group
-        GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
-
+        GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( myGeomObjects[0] );
         if (geomGen->_is_nil())
           return false;
 
@@ -1071,11 +1070,12 @@ bool SMESHGUI_GroupDlg::onApply()
         // check and add all selected GEOM objects: they must be
         // a sub-shapes of the main GEOM and must be of one type
         TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
-        for ( int i =0; i < (int)myGeomObjects->length(); i++) {
+        for ( CORBA::ULong i =0; i < myGeomObjects->length(); i++)
+        {
           TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
-          if (i == 0)
+          if ( i == 0 )
             aGroupType = aSubShapeType;
-          else if (aSubShapeType != aGroupType) {
+          else if ( aSubShapeType != aGroupType ) {
             aGroupType = TopAbs_SHAPE;
             break;
           }
@@ -1106,7 +1106,7 @@ bool SMESHGUI_GroupDlg::onApply()
 
       resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroupOnGeom );
       isCreation = false;
-    }      
+    }
     anIsOk = true;
   }
   if (myGrpTypeId == 2) // group on filter
@@ -1410,13 +1410,15 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
 
         // The main shape of the group
         GEOM::GEOM_Object_var aGroupMainShape;
-        if (aGeomGroup->GetType() == 37) {
+        if (aGeomGroup->GetType() == 37)
+        {
           GEOM::GEOM_IGroupOperations_ptr anOp =
-            SMESH::GetGEOMGen()->GetIGroupOperations();
-          aGroupMainShape = anOp->GetMainShape(aGeomGroup);
+            SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations();
+          aGroupMainShape = anOp->GetMainShape( aGeomGroup );
           // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
         }
-        else {
+        else
+        {
           aGroupMainShape = aGeomGroup;
           aGroupMainShape->Register();
         }
@@ -1867,7 +1869,8 @@ void SMESHGUI_GroupDlg::onAdd()
   QListWidgetItem* anItem = 0;
   QList<QListWidgetItem*> listItemsToSel;
 
-  if (myCurrentLineEdit == 0) {
+  if ( myCurrentLineEdit == 0 )
+  {
     //if (aNbSel != 1) { myIsBusy = false; return; }
     QString aListStr = "";
     int aNbItems = 0;
@@ -1910,7 +1913,9 @@ void SMESHGUI_GroupDlg::onAdd()
       onListSelectionChanged();
       listItemsToSel.clear();
     }
-  } else if (myCurrentLineEdit == mySubMeshLine) {
+  }
+  else if ( myCurrentLineEdit == mySubMeshLine )
+  {
     //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
 
     SALOME_ListIO aList;
@@ -1958,7 +1963,9 @@ void SMESHGUI_GroupDlg::onAdd()
     myIsBusy = false;
     onListSelectionChanged();
 
-  } else if (myCurrentLineEdit == myGroupLine) {
+  }
+  else if ( myCurrentLineEdit == myGroupLine )
+  {
     //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
     SALOME_ListIO aList;
     mySelectionMgr->selectedObjects( aList );
@@ -2000,9 +2007,11 @@ void SMESHGUI_GroupDlg::onAdd()
     myIsBusy = false;
     onListSelectionChanged();
 
-  } else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) {
+  }
+  else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 )
+  {
     GEOM::GEOM_IGroupOperations_ptr aGroupOp =
-      SMESH::GetGEOMGen()->GetIGroupOperations();
+      SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations();
 
     SMESH::ElementType aGroupType = SMESH::ALL;
     switch(aGroupOp->GetType(myGeomObjects[0])) {
index be3d90ff4f7e3cba60e60c394f92dd5a863d6fcc..f7be40487a1ee486f0f779afc512c054f7f432eb 100644 (file)
@@ -220,12 +220,12 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom)
     case GEOM::COMPOUND: break;
     default:             return SMESH::ALL;
     }
-    GEOM::GEOM_IShapesOperations_wrap aShapeOp =
-      SMESH::GetGEOMGen()->GetIShapesOperations();
+    GEOM::GEOM_Gen_var                 geomGen = SMESH::GetGEOMGen( geom );
+    GEOM::GEOM_IShapesOperations_wrap aShapeOp = geomGen->GetIShapesOperations();
 
-    if ( geom->GetType() == 37 ) // geom group
-      GEOM::GEOM_IGroupOperations_ptr aGroupOp =
-        SMESH::GetGEOMGen()->GetIGroupOperations();
+    if ( geom->GetType() == 37 ) // geom group
+    {
+      GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
       if ( !aGroupOp->_is_nil() ) {
         // mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
         GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom );
@@ -236,7 +236,8 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom)
         }
       }
     }
-    else if ( !aShapeOp->_is_nil() ) { // just a compoud shape
+    else if ( !aShapeOp->_is_nil() ) // just a compoud shape
+    {
       GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false );
       if ( ids->length() ) {
         GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] );
index 9e30fe25af9c7727f6db73a69dee26e2802b9569..36b530a391a342b0a4d0d9af2fece78bb2f98a2f 100644 (file)
@@ -1854,11 +1854,11 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
   else if (aGEOMs.count() > 1)
   {
     // create a GEOM group
-    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
-    if (!geomGen->_is_nil()) {
-      GEOM::GEOM_IGroupOperations_ptr op =
-        geomGen->GetIGroupOperations();
-      if (!op->_is_nil()) {
+    GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( mainGeom );
+    if ( !geomGen->_is_nil() ) {
+      GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
+      if ( !op->_is_nil() )
+      {
         // check and add all selected GEOM objects: they must be
         // a sub-shapes of the main GEOM and must be of one type
         int iSubSh = 0;
index 4ce31d65ba68560f29605bde16c161f44f6aa11d..19397b87116d7b7c2c329581793e80b563d23304 100644 (file)
@@ -318,14 +318,14 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
     }
     else
     {
-      GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
+      GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
 
-      if (geomGen->_is_nil())
+      GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( aMeshShape );
+      if ( geomGen->_is_nil() )
         return;
 
-      GEOM::GEOM_IShapesOperations_wrap aShapesOp =
-        geomGen->GetIShapesOperations();
-      if (aShapesOp->_is_nil() )
+      GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
+      if ( aShapesOp->_is_nil() )
         return;
 
       TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
@@ -333,8 +333,6 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
       std::map<int, GEOM::GEOM_Object_wrap> aGeomObjectsMap;
       GEOM::GEOM_Object_wrap aGeomObject;
 
-      GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
-
       for ( int i = 0; i < aListId.count(); i++ )
       {
         aGeomObject = // received object need UnRegister()!
@@ -362,9 +360,8 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
       }
       else if (aNumberOfGO > 1)
       {
-        GEOM::GEOM_IGroupOperations_ptr aGroupOp =
-          geomGen->GetIGroupOperations();
-        if(aGroupOp->_is_nil())
+        GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
+        if ( aGroupOp->_is_nil() )
           return;
 
         GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
@@ -379,7 +376,7 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
         aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType);
         aGroupOp->UnionList(aGeomObject, aGeomObjects);
 
-        if (!aGroupOp->IsDone())
+        if ( !aGroupOp->IsDone() )
           return;
       }
 
@@ -419,7 +416,7 @@ void SMESHGUI_ShapeByMeshOp::onSelectionDone()
   try {
     SALOME_ListIO aList;
     selectionMgr()->selectedObjects(aList);
-    if (!myIsMultipleAllowed && aList.Extent() != 1)
+    if ( aList.IsEmpty() || ( !myIsMultipleAllowed && aList.Extent() != 1) )
       return;
 
     SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());