Fix crash after 'Belong to' filter creation if there are no mesh in the study

This commit is contained in:
jfa 2005-10-04 07:35:48 +00:00
parent 694e1d2360
commit 8ad9cef463
2 changed files with 100 additions and 98 deletions

View File

@ -805,8 +805,8 @@ SalomeApp_Module( "SMESH" )
myComponentSMESH = SMESH::SMESH_Gen::_narrow( comp );
}
myActiveDialogBox = 0 ;
myState = -1 ;
myActiveDialogBox = 0;
myState = -1;
myDisplayer = 0;
SMESH::GetFilterManager();
@ -1059,6 +1059,10 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if( !mgr )
return false;
if (CORBA::is_nil(GetSMESHGen()->GetCurrentStudy())) {
GetSMESHGen()->SetCurrentStudy(_CAST(Study,aStudy)->GetStudy());
}
SUIT_ViewWindow* view = application()->desktop()->activeWindow();
SVTK_ViewWindow* vtkwnd = dynamic_cast<SVTK_ViewWindow*>( view );
@ -2754,8 +2758,8 @@ void SMESHGUI::initialize( CAM_Application* app )
QString anActiveVTK = QString("activeView = '%1'").arg(VTKViewer_Viewer::Type());
QString aSelCount = QString( "%1 > 0" ).arg( QtxPopupMgr::Selection::defSelCountParam() );
QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " + aType + " and " + aSelCount +
" and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
QString aRule = "$component={'SMESH'} and ( type='Component' or (" + aClient + " and " +
aType + " and " + aSelCount + " and " + anActiveVTK + " and " + isNotEmpty + " %1 ) )";
popupMgr()->insert( action( 301 ), -1, -1 ); // DISPLAY
popupMgr()->setRule( action( 301 ), aRule.arg( "and (not isVisible)" ), true);

View File

@ -276,10 +276,10 @@ GetMeshDS() const
}
bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
TopAbs_ShapeEnum theAvoidShapeEnum )
const TopoDS_Shape& theShape,
const SMDS_MeshElement* theElem,
TopAbs_ShapeEnum theFindShapeEnum,
TopAbs_ShapeEnum theAvoidShapeEnum )
{
if (IsContains(theMeshDS, theShape, theElem, theFindShapeEnum, theAvoidShapeEnum))
return true;
@ -288,27 +288,27 @@ bool Controls::LyingOnGeom::Contains( const SMESHDS_Mesh* theMeshDS,
TopExp::MapShapes( theShape, aSubShapes );
for (int i = 1; i <= aSubShapes.Extent(); i++)
{
const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
{
const TopoDS_Shape& aShape = aSubShapes.FindKey(i);
if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
if( aSubMesh->Contains( theElem ) )
return true;
if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){
if( aSubMesh->Contains( theElem ) )
return true;
SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
while ( aNodeIt->more() )
{
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
while ( anElemIt->more() )
{
const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
if (anElement == theElem)
return true;
}
}
SMDS_NodeIteratorPtr aNodeIt = aSubMesh->GetNodes();
while ( aNodeIt->more() )
{
const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(aNodeIt->next());
SMDS_ElemIteratorPtr anElemIt = aNode->GetInverseElementIterator();
while ( anElemIt->more() )
{
const SMDS_MeshElement* anElement = static_cast<const SMDS_MeshElement*>(anElemIt->next());
if (anElement == theElem)
return true;
}
}
}
}
return false;
}
@ -376,7 +376,7 @@ static TopoDS_Shape getShapeByName( const char* theName )
{
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy();
if ( aStudy != 0 )
if (!CORBA::is_nil(aStudy))
{
SALOMEDS::Study::ListOfSObject_var aList =
aStudy->FindObjectByName( theName, "GEOM" );
@ -385,7 +385,7 @@ static TopoDS_Shape getShapeByName( const char* theName )
GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() );
if ( !aGeomObj->_is_nil() )
{
GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj );
return aLocShape;
}
@ -614,7 +614,6 @@ SMESH::Length2D::Values* Length2D_i::GetValues()
aValue.myLength = aVal.myLength;
aValue.myPnt1 = aVal.myPntId[ 0 ];
aValue.myPnt2 = aVal.myPntId[ 1 ];
}
INFOS("Length2D_i::GetValuess~");
@ -670,7 +669,6 @@ SMESH::MultiConnection2D::Values* MultiConnection2D_i::GetValues()
aValue.myPnt1 = aVal.myPntId[ 0 ];
aValue.myPnt2 = aVal.myPntId[ 1 ];
aValue.myNbConnects = (*anIter).second;
}
INFOS("Multiconnection2D_i::GetValuess~");
@ -1645,8 +1643,8 @@ GetIDs()
void
Filter_i::
GetElementsId( Predicate_i* thePredicate,
const SMDS_Mesh* theMesh,
Controls::Filter::TIdSequence& theSequence )
const SMDS_Mesh* theMesh,
Controls::Filter::TIdSequence& theSequence )
{
Controls::Filter::GetElementsId(theMesh,thePredicate->GetPredicate(),theSequence);
}
@ -1654,8 +1652,8 @@ GetElementsId( Predicate_i* thePredicate,
void
Filter_i::
GetElementsId( Predicate_i* thePredicate,
SMESH_Mesh_ptr theMesh,
Controls::Filter::TIdSequence& theSequence )
SMESH_Mesh_ptr theMesh,
Controls::Filter::TIdSequence& theSequence )
{
if(const SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh))
Controls::Filter::GetElementsId(aMesh,thePredicate->GetPredicate(),theSequence);
@ -1881,8 +1879,8 @@ CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria
aFunctor = aFilterMgr->CreateMultiConnection();
break;
case SMESH::FT_MultiConnection2D:
aFunctor = aFilterMgr->CreateMultiConnection2D();
break;
aFunctor = aFilterMgr->CreateMultiConnection2D();
break;
case SMESH::FT_Length:
aFunctor = aFilterMgr->CreateLength();
break;