+ GEOM::GEOM_IShapesOperations_wrap aShapesOp =
+ geomGen->GetIShapesOperations(aStudy->StudyId());
+ if (aShapesOp->_is_nil() )
+ return;
+
+ TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
+
+ 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()!
+ SMESHGUI::GetSMESHGen()->FindGeometryByMeshElement(myMesh.in(), aListId[i].toInt());
+
+ if (aGeomObject->_is_nil()) continue;
+
+ int anId = aShapesOp->GetSubShapeIndex(aMeshShape, aGeomObject);
+ if (aShapesOp->IsDone() && !aGeomObjectsMap.count(anId) )
+ {
+ aGeomObjectsMap[anId] = aGeomObject;
+
+ TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)aGeomObject->GetShapeType();
+ if (i == 0)
+ aGroupType = aSubShapeType;
+ else if (aSubShapeType != aGroupType)
+ aGroupType = TopAbs_SHAPE;
+ }
+ }
+
+ int aNumberOfGO = aGeomObjectsMap.size();
+ if (aNumberOfGO == 1)
+ {
+ aGeomObject = (*aGeomObjectsMap.begin()).second;
+ }
+ else if (aNumberOfGO > 1)
+ {
+ GEOM::GEOM_IGroupOperations_wrap aGroupOp =
+ geomGen->GetIGroupOperations(aStudy->StudyId());
+ if(aGroupOp->_is_nil())
+ return;
+
+ GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
+ aGeomObjects->length( aNumberOfGO );
+
+ int i = 0;
+ std::map<int, GEOM::GEOM_Object_wrap>::iterator anIter;
+ for (anIter = aGeomObjectsMap.begin(); anIter!=aGeomObjectsMap.end(); anIter++)
+ aGeomObjects[i++] = GEOM::GEOM_Object::_duplicate( (*anIter).second.in() );
+
+ //create geometry group
+ aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType);
+ aGroupOp->UnionList(aGeomObject, aGeomObjects);
+
+ if (!aGroupOp->IsDone())
+ return;
+ }
+
+ // publish the GEOM object in study
+ QString aNewGeomGroupName ( myDlg->myGeomName->text() );
+ SALOMEDS::Study_var aStudyVar = _CAST(Study,aStudy)->GetStudy();
+ SALOMEDS::SObject_wrap aNewGroupSO =
+ geomGen->AddInStudy( aStudyVar, aGeomObject,
+ aNewGeomGroupName.toLatin1().data(), aMeshShape);
+
+ // get a GEOM_Object already published, which doesn't need UnRegister()
+ CORBA::Object_var obj = aNewGroupSO->GetObject();
+ myGeomObj = GEOM::GEOM_Object::_narrow( obj );
+ }