IPAL13617 NbSubMesh() method works wrong

Fix removeSubMesh() for the case of not published subshape
This commit is contained in:
eap 2009-11-18 08:50:59 +00:00
parent a657a15f5f
commit 30de27ee11

View File

@ -522,41 +522,40 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aS
*/ */
//============================================================================= //=============================================================================
SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH_Hypothesis::Hypothesis_Status
SMESH::SMESH_Hypothesis_ptr anHyp) SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject,
SMESH::SMESH_Hypothesis_ptr anHyp)
{ {
if(MYDEBUG) MESSAGE("removeHypothesis()"); if(MYDEBUG) MESSAGE("removeHypothesis()");
// **** proposer liste de subShape (selection multiple) // **** proposer liste de subShape (selection multiple)
if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh()) if (CORBA::is_nil(aSubShapeObject) && HasShapeToMesh())
THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM);
SALOME::BAD_PARAM);
SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp); SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp);
if (CORBA::is_nil(myHyp)) if (CORBA::is_nil(myHyp))
THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", SALOME::BAD_PARAM);
SALOME::BAD_PARAM);
SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK;
try try
{ {
TopoDS_Shape myLocSubShape; TopoDS_Shape myLocSubShape;
//use PseudoShape in case if mesh has no shape //use PseudoShape in case if mesh has no shape
if(HasShapeToMesh()) if(HasShapeToMesh())
myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject); myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject);
else else
myLocSubShape = _impl->GetShapeToMesh(); myLocSubShape = _impl->GetShapeToMesh();
int hypId = myHyp->GetId(); int hypId = myHyp->GetId();
status = _impl->RemoveHypothesis(myLocSubShape, hypId); status = _impl->RemoveHypothesis(myLocSubShape, hypId);
if ( !SMESH_Hypothesis::IsStatusFatal(status) ) // if ( !SMESH_Hypothesis::IsStatusFatal(status) ) EAP: hyp can be used on many subshapes
_mapHypo.erase( hypId ); // _mapHypo.erase( hypId );
} }
catch(SALOME_Exception & S_ex) catch(SALOME_Exception & S_ex)
{ {
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
} }
return status; return status;
} }
//============================================================================= //=============================================================================
@ -572,8 +571,7 @@ throw(SALOME::SALOME_Exception)
Unexpect aCatch(SALOME_SalomeException); Unexpect aCatch(SALOME_SalomeException);
if (MYDEBUG) MESSAGE("GetHypothesisList"); if (MYDEBUG) MESSAGE("GetHypothesisList");
if (_impl->HasShapeToMesh() && CORBA::is_nil(aSubShapeObject)) if (_impl->HasShapeToMesh() && CORBA::is_nil(aSubShapeObject))
THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM);
SALOME::BAD_PARAM);
SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis(); SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis();
@ -669,6 +667,9 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) ) if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) )
aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() ); aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() );
// if ( aSubShapeObject->_is_nil() ) // not published shape (IPAL13617)
// aSubShapeObject = theSubMesh->GetSubShape();
aStudy->NewBuilder()->RemoveObjectWithChildren( anSO ); aStudy->NewBuilder()->RemoveObjectWithChildren( anSO );
// Update Python script // Update Python script
@ -1976,20 +1977,37 @@ void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh,
GEOM::GEOM_Object_ptr theSubShapeObject ) GEOM::GEOM_Object_ptr theSubShapeObject )
{ {
MESSAGE("SMESH_Mesh_i::removeSubMesh()"); MESSAGE("SMESH_Mesh_i::removeSubMesh()");
if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() ) if ( theSubMesh->_is_nil() /*|| theSubShapeObject->_is_nil()*/ )
return; return;
try { if ( theSubShapeObject->_is_nil() ) // not published shape (IPAL13617)
SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject ); {
for ( int i = 0, n = aHypList->length(); i < n; i++ ) { CORBA::Long shapeId = theSubMesh->GetId();
removeHypothesis( theSubShapeObject, aHypList[i] ); if ( _mapSubMesh.find( shapeId ) != _mapSubMesh.end())
{
TopoDS_Shape S = _mapSubMesh[ shapeId ]->GetSubShape();
if ( !S.IsNull() )
{
list<const SMESHDS_Hypothesis*> hyps = _impl->GetHypothesisList( S );
list<const SMESHDS_Hypothesis*>::const_iterator hyp = hyps.begin();
for ( ; hyp != hyps.end(); ++hyp )
_impl->RemoveHypothesis(S, (*hyp)->GetID());
}
} }
} }
catch( const SALOME::SALOME_Exception& ) { else
INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!"); {
try {
SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject );
for ( int i = 0, n = aHypList->length(); i < n; i++ ) {
removeHypothesis( theSubShapeObject, aHypList[i] );
}
}
catch( const SALOME::SALOME_Exception& ) {
INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!");
}
removeGeomGroupData( theSubShapeObject );
} }
removeGeomGroupData( theSubShapeObject );
int subMeshId = theSubMesh->GetId(); int subMeshId = theSubMesh->GetId();
_mapSubMesh.erase(subMeshId); _mapSubMesh.erase(subMeshId);