- GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
-
- if (geomGen->_is_nil() || !aStudy)
- return;
-
- GEOM::GEOM_IShapesOperations_var aShapesOp =
- geomGen->GetIShapesOperations(aStudy->StudyId());
- if (aShapesOp->_is_nil() )
- return;
-
- TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
-
- std::map<double, GEOM::GEOM_Object_var> aGeomObjectsMap;
- GEOM::GEOM_Object_var aGeomObject;
-
- GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
-
- for ( int i = 0; i < aListId.count(); i++ )
- {
- aGeomObject =
- SMESHGUI::GetSMESHGen()->FindGeometryByMeshElement(myMesh.in(), aListId[i].toInt());
-
- if (aGeomObject->_is_nil()) continue;
-
- double anId = aShapesOp->GetSubShapeIndex(aMeshShape, aGeomObject);
- if (aShapesOp->IsDone() && aGeomObjectsMap.find(anId) == aGeomObjectsMap.end())
- {
- 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)
- myGeomObj = (*aGeomObjectsMap.begin()).second;
- else if (aNumberOfGO > 1)
- {
- GEOM::GEOM_IGroupOperations_var 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<double, GEOM::GEOM_Object_var>::iterator anIter;
- for (anIter = aGeomObjectsMap.begin(); anIter!=aGeomObjectsMap.end(); anIter++)
- aGeomObjects[i++] = (*anIter).second;
-
- //create geometry group
- myGeomObj = aGroupOp->CreateGroup(aMeshShape, aGroupType);
- aGroupOp->UnionList(myGeomObj, aGeomObjects);
-
- if (!aGroupOp->IsDone())
- return;
- }
-
- // publish the GEOM object in study
- QString aNewGeomGroupName ( myDlg->myGeomName->text().latin1() );
-
- SALOMEDS::SObject_var aNewGroupSO =
- geomGen->AddInStudy(SMESHGUI::GetSMESHGen()->GetCurrentStudy(), myGeomObj, aNewGeomGroupName, aMeshShape);
+ GEOM::GEOM_IGroupOperations_wrap aGroupOp = geomGen->GetIGroupOperations();
+ 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;