X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_GroupOnShapeDlg.cxx;h=f7dccaff45c6304e29d3f6a81d9533a6d885f68c;hb=bdd574724272e16b782e6b8347ed21ba477df585;hp=294c3c6b20cfd1438164103c3a4208ea7541b39a;hpb=560f8b2d0c2a7fdb4047f981cfac56ed3629bc1a;p=modules%2Fsmesh.git diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index 294c3c6b2..f7dccaff4 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -206,11 +206,11 @@ LightApp_Dialog* SMESHGUI_GroupOnShapeOp::dlg() const */ //================================================================================ -static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom) +SMESH::ElementType SMESHGUI_GroupOnShapeOp::ElementType(GEOM::GEOM_Object_var geom) { if ( !geom->_is_nil() ) { switch ( geom->GetShapeType() ) { - case GEOM::VERTEX: return SMESH::NODE; + case GEOM::VERTEX: return SMESH::ELEM0D; // NODE; -- 0023613 case GEOM::EDGE: return SMESH::EDGE; case GEOM::WIRE: return SMESH::EDGE; case GEOM::FACE: return SMESH::FACE; @@ -220,27 +220,28 @@ 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_wrap aGroupOp = - SMESH::GetGEOMGen()->GetIGroupOperations(); + if ( geom->GetType() == 37 ) // geom group + { + GEOM::GEOM_IGroupOperations_wrap 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 ); GEOM::ListOfLong_var ids = aGroupOp->GetObjects( geom ); if ( ids->length() && !mainShape->_is_nil() && !aShapeOp->_is_nil() ) { GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( mainShape, ids[0] ); - return elementType( member ); + return ElementType( member ); } } } - 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] ); - return elementType( member ); + return ElementType( member ); } } } @@ -335,7 +336,7 @@ bool SMESHGUI_GroupOnShapeOp::onApply() if ( geom->_is_nil() ) continue; // group type - SMESH::ElementType elemType = isNode ? SMESH::NODE : elementType( geom ); + SMESH::ElementType elemType = isNode ? SMESH::NODE : ElementType( geom ); if ( elemType == SMESH::ALL ) continue; @@ -462,29 +463,23 @@ void SMESHGUI_GroupOnShapeOp::selectionDone() // study if (_PTR(Study) aStudy = SMESH::getStudy()) { // mesh - if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) { + if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) + { // shape to mesh - _PTR(SObject) anObj, shapeToMesh; - if (meshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(shapeToMesh)) { - // loop on selected - QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end(); - for (; id != idEnd; ++id, ++name ) { - // shape SO - if (_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() )) { - // check if shape SO is a child of shape to mesh - while ( shapeSO && shapeSO->GetID() != shapeToMesh->GetID() ) - if ( shapeSO->Depth() < 2 ) - shapeSO.reset(); - else - shapeSO = shapeSO->GetFather(); - if ( shapeSO ) { - //printf( "selectionDone() %s %s\n", (*id).latin1(), (*name).latin1() ); - if ( !goodIds.contains( *id )) { - goodIds.append( *id ); - goodNames.append( *name ); - } - } - } + GEOM::GEOM_Object_var mainGeom = SMESH::GetGeom( meshSO ); + // loop on selected + QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end(); + for (; id != idEnd; ++id, ++name ) + { + if ( goodIds.contains( *id )) + continue; + // shape SO + _PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() ); + GEOM::GEOM_Object_var subGeom = SMESH::GetGeom( shapeSO ); + if ( SMESH::ContainsSubShape( mainGeom, subGeom )) + { + goodIds.append( *id ); + goodNames.append( *name ); } } }