+ // re-assign global hypotheses to the new shape
+ _mainShapeTick = geomChanged ? -1 : theNewGeom->GetTick();
+ CheckGeomModif( true );
+
+ if ( !geomChanged )
+ {
+ // restore positions of elements on geometry
+ for ( int isNode = 0; isNode < 2; ++isNode )
+ {
+ std::vector< TRange > & ranges = isNode ? nodeRanges : elemRanges;
+ for ( size_t i = 1; i < ranges.size(); ++i )
+ {
+ int elemID = ranges[ i ].fromID;
+ int toID = ranges[ i ].toID;
+ SMESHDS_SubMesh * smDS = meshDS->NewSubMesh( ranges[ i ].shapeID );
+ if ( isNode )
+ for ( ; elemID < toID; ++elemID )
+ smDS->AddNode( meshDS->FindNode( elemID ));
+ else
+ for ( ; elemID < toID; ++elemID )
+ smDS->AddElement( meshDS->FindElement( elemID ));
+
+ if ( SMESH_subMesh* sm = _impl->GetSubMeshContaining( ranges[ i ].shapeID ))
+ sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
+ }
+ }
+ for ( unsigned int nodeID = 1; nodeID < positions.size(); ++nodeID )
+ if ( positions[ nodeID ])
+ if ( SMDS_MeshNode* n = const_cast< SMDS_MeshNode*>( meshDS->FindNode( nodeID )))
+ n->SetPosition( positions[ nodeID ], n->GetShapeID() );
+
+ // restore icons
+ _gen_i->UpdateIcons( SMESH::SMESH_Mesh_var( _this() ));
+ }
+
+ TPythonDump() << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject("
+ << me <<".GetMesh()), " << entry.in() << ")";
+
+ TPythonDump() << me << ".ReplaceShape( " << entry.in() << " )";
+
+}
+
+//================================================================================
+/*!
+ * \brief Return new group contents if it has been changed and update group data
+ */
+//================================================================================
+
+enum { ONLY_IF_CHANGED, IS_BREAK_LINK, MAIN_TRANSFORMED };
+
+TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData, int how )
+{
+ TopoDS_Shape newShape;
+ SALOMEDS::SObject_wrap groupSO;
+
+ if ( how == IS_BREAK_LINK )
+ {
+ SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( groupData._smeshObject );
+ SALOMEDS::SObject_wrap geomRefSO;
+ if ( !meshSO->_is_nil() &&
+ meshSO->FindSubObject( SMESH::Tag_RefOnShape, geomRefSO.inout() ))
+ {
+ geomRefSO->ReferencedObject( groupSO.inout() );
+ }
+ }
+ else
+ {
+ // get geom group
+ groupSO = _gen_i->getStudyServant()->FindObjectID( groupData._groupEntry.c_str() );
+ }
+
+ if ( groupSO->_is_nil() )
+ return newShape;
+
+ CORBA::Object_var groupObj = _gen_i->SObjectToObject( groupSO );
+ GEOM::GEOM_Object_var geomGroup = GEOM::GEOM_Object::_narrow( groupObj );
+ if ( geomGroup->_is_nil() )
+ return newShape;
+
+ // get indices of group items
+ set<int> curIndices;
+ GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( geomGroup );
+ GEOM::GEOM_IGroupOperations_wrap groupOp = geomGen->GetIGroupOperations();
+ GEOM::ListOfLong_var ids = groupOp->GetObjects( geomGroup );
+ for ( CORBA::ULong i = 0; i < ids->length(); ++i )
+ curIndices.insert( ids[i] );
+
+ bool sameIndices = ( groupData._indices == curIndices );
+ if ( how == ONLY_IF_CHANGED && sameIndices )
+ return newShape; // group not changed
+
+ // update data
+ CORBA::String_var entry = geomGroup->GetStudyEntry();
+ groupData._groupEntry = entry.in();
+ groupData._indices = curIndices;
+
+ newShape = _gen_i->GeomObjectToShape( geomGroup );
+
+ // check if newShape is up-to-date
+ if ( !newShape.IsNull() && ids->length() > 0 )
+ {
+ bool toUpdate = ! _impl->GetMeshDS()->IsGroupOfSubShapes( newShape );
+ if ( !toUpdate )
+ {
+ TopExp_Explorer exp( newShape, (TopAbs_ShapeEnum)( groupOp->GetType( geomGroup )));
+ for ( ; exp.More() && !toUpdate; exp.Next() )
+ {
+ int ind = _impl->GetMeshDS()->ShapeToIndex( exp.Current() );
+ toUpdate = ( curIndices.erase( ind ) == 0 );
+ }
+ if ( !curIndices.empty() )
+ toUpdate = true;
+ }
+ if ( toUpdate )
+ {
+ GEOM_Client* geomClient = _gen_i->GetShapeReader();
+ CORBA::String_var groupIOR = geomGen->GetStringFromIOR( geomGroup );
+ geomClient->RemoveShapeFromBuffer( groupIOR.in() );
+ newShape = _gen_i->GeomObjectToShape( geomGroup );
+ }
+ }
+ else
+ {
+ // geom group becomes empty - return empty compound
+ TopoDS_Compound compound;