BUG: SMESH::GetGEOMGen() returns GEOM_Engine instead of SHAPERSTUDY

1) GetGEOMGen() -> GetGEOMGen( GEOM::GEOM_Object_ptr go )
2) some formatting (whitespace changes)
This commit is contained in:
eap 2020-01-15 16:12:51 +03:00
parent 2b3c553f4f
commit 07ac4da8b2
8 changed files with 65 additions and 58 deletions

View File

@ -1251,8 +1251,8 @@ void SMESHGUI_BaseComputeOp::stopOperation()
void SMESHGUI_BaseComputeOp::onPublishShape() void SMESHGUI_BaseComputeOp::onPublishShape()
{ {
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh(); GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( meshShape );
QStringList entryList; QStringList entryList;
QList<int> rows; QList<int> rows;

View File

@ -92,9 +92,6 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
myFields = & fields; myFields = & fields;
myTree->clear(); myTree->clear();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
for ( int iM = 0; iM < meshes.count(); ++iM ) for ( int iM = 0; iM < meshes.count(); ++iM )
{ {
GEOM::ListOfFields_var fields; GEOM::ListOfFields_var fields;
@ -109,6 +106,9 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
QTreeWidgetItem* meshItem = createItem( myTree, meshes[iM].second, iM ); QTreeWidgetItem* meshItem = createItem( myTree, meshes[iM].second, iM );
GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh(); 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 ); fields = fieldOp->GetFields( shape );
for ( size_t iF = 0; iF < fields->length(); ++iF ) for ( size_t iF = 0; iF < fields->length(); ++iF )
{ {

View File

@ -44,16 +44,12 @@
namespace SMESH namespace SMESH
{ {
GEOM::GEOM_Gen_var GetGEOMGen() GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go )
{ {
static GEOM::GEOM_Gen_var aGEOMGen; GEOM::GEOM_Gen_ptr gen;
if ( !CORBA::is_nil( go ))
if(CORBA::is_nil(aGEOMGen)) { gen = go->GetGen();
if ( GeometryGUI::GetGeomGen()->_is_nil() ) return gen;
GeometryGUI::InitGeomGen();
aGEOMGen = GeometryGUI::GetGeomGen();
}
return aGEOMGen;
} }
GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh, GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh,
@ -155,14 +151,18 @@ namespace SMESH
GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
long theID) 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()) if (geomGen->_is_nil())
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
GEOM::GEOM_IShapesOperations_wrap aShapesOp =
geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
if (aShapesOp->_is_nil()) if (aShapesOp->_is_nil())
return GEOM::GEOM_Object::_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(); return subShape._retn();
} }

View File

@ -45,7 +45,7 @@ class QString;
namespace SMESH 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 ); SMESHGUI_EXPORT GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh( _PTR(SObject), bool* isMesh=0 );

View File

@ -1055,12 +1055,11 @@ bool SMESHGUI_GroupDlg::onApply()
} }
else { else {
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
if ( aSMESHGen->_is_nil() ) if ( aSMESHGen->_is_nil() || myGeomObjects->length() == 0 )
return false; return false;
// create a geometry group // create a geometry group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( myGeomObjects[0] );
if (geomGen->_is_nil()) if (geomGen->_is_nil())
return false; return false;
@ -1071,11 +1070,12 @@ bool SMESHGUI_GroupDlg::onApply()
// check and add all selected GEOM objects: they must be // check and add all selected GEOM objects: they must be
// a sub-shapes of the main GEOM and must be of one type // a sub-shapes of the main GEOM and must be of one type
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; 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(); TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
if (i == 0) if ( i == 0 )
aGroupType = aSubShapeType; aGroupType = aSubShapeType;
else if (aSubShapeType != aGroupType) { else if ( aSubShapeType != aGroupType ) {
aGroupType = TopAbs_SHAPE; aGroupType = TopAbs_SHAPE;
break; break;
} }
@ -1410,13 +1410,15 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
// The main shape of the group // The main shape of the group
GEOM::GEOM_Object_var aGroupMainShape; GEOM::GEOM_Object_var aGroupMainShape;
if (aGeomGroup->GetType() == 37) { if (aGeomGroup->GetType() == 37)
{
GEOM::GEOM_IGroupOperations_ptr anOp = GEOM::GEOM_IGroupOperations_ptr anOp =
SMESH::GetGEOMGen()->GetIGroupOperations(); SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations();
aGroupMainShape = anOp->GetMainShape(aGeomGroup); aGroupMainShape = anOp->GetMainShape( aGeomGroup );
// aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
} }
else { else
{
aGroupMainShape = aGeomGroup; aGroupMainShape = aGeomGroup;
aGroupMainShape->Register(); aGroupMainShape->Register();
} }
@ -1867,7 +1869,8 @@ void SMESHGUI_GroupDlg::onAdd()
QListWidgetItem* anItem = 0; QListWidgetItem* anItem = 0;
QList<QListWidgetItem*> listItemsToSel; QList<QListWidgetItem*> listItemsToSel;
if (myCurrentLineEdit == 0) { if ( myCurrentLineEdit == 0 )
{
//if (aNbSel != 1) { myIsBusy = false; return; } //if (aNbSel != 1) { myIsBusy = false; return; }
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
@ -1910,7 +1913,9 @@ void SMESHGUI_GroupDlg::onAdd()
onListSelectionChanged(); onListSelectionChanged();
listItemsToSel.clear(); listItemsToSel.clear();
} }
} else if (myCurrentLineEdit == mySubMeshLine) { }
else if ( myCurrentLineEdit == mySubMeshLine )
{
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
SALOME_ListIO aList; SALOME_ListIO aList;
@ -1958,7 +1963,9 @@ void SMESHGUI_GroupDlg::onAdd()
myIsBusy = false; myIsBusy = false;
onListSelectionChanged(); onListSelectionChanged();
} else if (myCurrentLineEdit == myGroupLine) { }
else if ( myCurrentLineEdit == myGroupLine )
{
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
SALOME_ListIO aList; SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList ); mySelectionMgr->selectedObjects( aList );
@ -2000,9 +2007,11 @@ void SMESHGUI_GroupDlg::onAdd()
myIsBusy = false; myIsBusy = false;
onListSelectionChanged(); onListSelectionChanged();
} else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) { }
else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 )
{
GEOM::GEOM_IGroupOperations_ptr aGroupOp = GEOM::GEOM_IGroupOperations_ptr aGroupOp =
SMESH::GetGEOMGen()->GetIGroupOperations(); SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations();
SMESH::ElementType aGroupType = SMESH::ALL; SMESH::ElementType aGroupType = SMESH::ALL;
switch(aGroupOp->GetType(myGeomObjects[0])) { switch(aGroupOp->GetType(myGeomObjects[0])) {

View File

@ -220,12 +220,12 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom)
case GEOM::COMPOUND: break; case GEOM::COMPOUND: break;
default: return SMESH::ALL; default: return SMESH::ALL;
} }
GEOM::GEOM_IShapesOperations_wrap aShapeOp = GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( geom );
SMESH::GetGEOMGen()->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap aShapeOp = geomGen->GetIShapesOperations();
if ( geom->GetType() == 37 ) { // geom group if ( geom->GetType() == 37 ) // geom group
GEOM::GEOM_IGroupOperations_ptr aGroupOp = {
SMESH::GetGEOMGen()->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
if ( !aGroupOp->_is_nil() ) { if ( !aGroupOp->_is_nil() ) {
// mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap // mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom ); 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 ); GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false );
if ( ids->length() ) { if ( ids->length() ) {
GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] ); GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] );

View File

@ -1854,11 +1854,11 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
else if (aGEOMs.count() > 1) else if (aGEOMs.count() > 1)
{ {
// create a GEOM group // create a GEOM group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( mainGeom );
if (!geomGen->_is_nil()) { if ( !geomGen->_is_nil() ) {
GEOM::GEOM_IGroupOperations_ptr op = GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations(); if ( !op->_is_nil() )
if (!op->_is_nil()) { {
// check and add all selected GEOM objects: they must be // check and add all selected GEOM objects: they must be
// a sub-shapes of the main GEOM and must be of one type // a sub-shapes of the main GEOM and must be of one type
int iSubSh = 0; int iSubSh = 0;

View File

@ -318,14 +318,14 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
} }
else 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; return;
GEOM::GEOM_IShapesOperations_wrap aShapesOp = GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
geomGen->GetIShapesOperations(); if ( aShapesOp->_is_nil() )
if (aShapesOp->_is_nil() )
return; return;
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
@ -333,8 +333,6 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
std::map<int, GEOM::GEOM_Object_wrap> aGeomObjectsMap; std::map<int, GEOM::GEOM_Object_wrap> aGeomObjectsMap;
GEOM::GEOM_Object_wrap aGeomObject; GEOM::GEOM_Object_wrap aGeomObject;
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
for ( int i = 0; i < aListId.count(); i++ ) for ( int i = 0; i < aListId.count(); i++ )
{ {
aGeomObject = // received object need UnRegister()! aGeomObject = // received object need UnRegister()!
@ -362,9 +360,8 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
} }
else if (aNumberOfGO > 1) else if (aNumberOfGO > 1)
{ {
GEOM::GEOM_IGroupOperations_ptr aGroupOp = GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations(); if ( aGroupOp->_is_nil() )
if(aGroupOp->_is_nil())
return; return;
GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO(); GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
@ -379,7 +376,7 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType); aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType);
aGroupOp->UnionList(aGeomObject, aGeomObjects); aGroupOp->UnionList(aGeomObject, aGeomObjects);
if (!aGroupOp->IsDone()) if ( !aGroupOp->IsDone() )
return; return;
} }
@ -419,7 +416,7 @@ void SMESHGUI_ShapeByMeshOp::onSelectionDone()
try { try {
SALOME_ListIO aList; SALOME_ListIO aList;
selectionMgr()->selectedObjects(aList); selectionMgr()->selectedObjects(aList);
if (!myIsMultipleAllowed && aList.Extent() != 1) if ( aList.IsEmpty() || ( !myIsMultipleAllowed && aList.Extent() != 1) )
return; return;
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());