diff --git a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx index 10e4b196f..14e05427d 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ComputeDlg.cxx @@ -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 rows; diff --git a/src/SMESHGUI/SMESHGUI_FieldSelectorWdg.cxx b/src/SMESHGUI/SMESHGUI_FieldSelectorWdg.cxx index a9d6ad891..e7f05170e 100644 --- a/src/SMESHGUI/SMESHGUI_FieldSelectorWdg.cxx +++ b/src/SMESHGUI/SMESHGUI_FieldSelectorWdg.cxx @@ -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 ) { diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx index 05a912582..8be766f2f 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -44,16 +44,12 @@ 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(); } diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h index 08b643d51..8afed3981 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -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 ); diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index ad5bddd51..62666c97f 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -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 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])) { diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index be3d90ff4..f7be40487 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -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] ); diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 9e30fe25a..36b530a39 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -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; diff --git a/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx index 4ce31d65b..19397b871 100644 --- a/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ShapeByMeshDlg.cxx @@ -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 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());