Fix SIGSEGV at closing a study

This commit is contained in:
eap 2013-11-25 10:39:28 +00:00
parent a004160516
commit b2f41043c8
2 changed files with 53 additions and 63 deletions

View File

@ -63,6 +63,8 @@ using namespace std;
namespace { namespace {
void careOfSubMeshes( StdMeshers_FaceSide& side );
//================================================================================ //================================================================================
/*! /*!
* \brief Search for an edge conjunct to the given one by the vertex * \brief Search for an edge conjunct to the given one by the vertex
@ -104,43 +106,6 @@ namespace {
return TopoDS_Edge(); return TopoDS_Edge();
} }
//================================================================================
/*!
* \brief Update submeshes state for all edges and internal vertices,
* make them look computed even if none edge or node is set on them
*/
//================================================================================
void careOfSubMeshes( StdMeshers_FaceSide& side, EventListener* eListener)
{
if ( side.NbEdges() < 2)
return;
for ( int iE = 0; iE < side.NbEdges(); ++iE )
{
// set listener and its data
EventListenerData * listenerData = new EventListenerData(true);
const TopoDS_Edge& edge = side.Edge( iE );
SMESH_subMesh * sm = side.GetMesh()->GetSubMesh( edge );
sm->SetEventListener( eListener, listenerData, sm );
// add edge submesh to the data
sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
if ( sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK ) {
sm->SetIsAlwaysComputed( true );
listenerData->mySubMeshes.push_back( sm );
}
// add internal vertex submesh to the data
if ( iE )
{
TopoDS_Vertex V = side.FirstVertex( iE );
sm = side.GetMesh()->GetSubMesh( V );
sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
if ( sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK )
sm->SetIsAlwaysComputed( true );
listenerData->mySubMeshes.push_back( sm );
}
}
}
//================================================================================ //================================================================================
/*! /*!
* \brief Class used to restore nodes on internal vertices of a complex side * \brief Class used to restore nodes on internal vertices of a complex side
@ -151,17 +116,19 @@ namespace {
struct VertexNodesRestoringListener : public SMESH_subMeshEventListener struct VertexNodesRestoringListener : public SMESH_subMeshEventListener
{ {
VertexNodesRestoringListener(): VertexNodesRestoringListener():
SMESH_subMeshEventListener(0, // won't be deleted by submesh SMESH_subMeshEventListener(1, // will be deleted by sub-mesh
"StdMeshers_CompositeSegment_1D::VertexNodesRestoringListener") "StdMeshers_CompositeSegment_1D::VertexNodesRestoringListener")
{} {}
/*! static VertexNodesRestoringListener* New() { return new VertexNodesRestoringListener(); }
* \brief Restore nodes on internal vertices of a complex side
* \param event - algo_event or compute_event itself (of SMESH_subMesh) /*!
* \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh) * \brief Restore nodes on internal vertices of a complex side
* \param subMesh - the submesh where the event occures * \param event - algo_event or compute_event itself (of SMESH_subMesh)
* \param data - listener data stored in the subMesh * \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
* \param hyp - hypothesis, if eventType is algo_event * \param subMesh - the submesh where the event occures
*/ * \param data - listener data stored in the subMesh
* \param hyp - hypothesis, if eventType is algo_event
*/
void ProcessEvent(const int event, void ProcessEvent(const int event,
const int eventType, const int eventType,
SMESH_subMesh* subMesh, SMESH_subMesh* subMesh,
@ -210,7 +177,7 @@ namespace {
( StdMeshers_CompositeSegment_1D::GetFaceSide(*subMesh->GetFather(), ( StdMeshers_CompositeSegment_1D::GetFaceSide(*subMesh->GetFather(),
edge, face, false )); edge, face, false ));
if ( side->NbEdges() > 1 && side->NbSegments() ) if ( side->NbEdges() > 1 && side->NbSegments() )
careOfSubMeshes( *side, this ); careOfSubMeshes( *side );
} }
} }
} }
@ -229,6 +196,43 @@ namespace {
} }
} }
}; // struct VertexNodesRestoringListener }; // struct VertexNodesRestoringListener
//================================================================================
/*!
* \brief Update submeshes state for all edges and internal vertices,
* make them look computed even if none edge or node is set on them
*/
//================================================================================
void careOfSubMeshes( StdMeshers_FaceSide& side )
{
if ( side.NbEdges() < 2)
return;
for ( int iE = 0; iE < side.NbEdges(); ++iE )
{
// set listener and its data
EventListenerData * listenerData = new EventListenerData(true);
const TopoDS_Edge& edge = side.Edge( iE );
SMESH_subMesh * sm = side.GetMesh()->GetSubMesh( edge );
sm->SetEventListener( new VertexNodesRestoringListener(), listenerData, sm );
// add edge submesh to the data
sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
if ( sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK ) {
sm->SetIsAlwaysComputed( true );
listenerData->mySubMeshes.push_back( sm );
}
// add internal vertex submesh to the data
if ( iE )
{
TopoDS_Vertex V = side.FirstVertex( iE );
sm = side.GetMesh()->GetSubMesh( V );
sm->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
if ( sm->GetComputeState() != SMESH_subMesh::COMPUTE_OK )
sm->SetIsAlwaysComputed( true );
listenerData->mySubMeshes.push_back( sm );
}
}
}
} }
//============================================================================= //=============================================================================
@ -244,7 +248,6 @@ StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D(int hypId
{ {
MESSAGE("StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D"); MESSAGE("StdMeshers_CompositeSegment_1D::StdMeshers_CompositeSegment_1D");
_name = AlgoName(); _name = AlgoName();
_EventListener = new VertexNodesRestoringListener();
} }
//======================================================================= //=======================================================================
@ -256,16 +259,6 @@ std::string StdMeshers_CompositeSegment_1D::AlgoName()
{ {
return "CompositeSegment_1D"; return "CompositeSegment_1D";
} }
//=============================================================================
/*!
*
*/
//=============================================================================
StdMeshers_CompositeSegment_1D::~StdMeshers_CompositeSegment_1D()
{
delete _EventListener;
}
//============================================================================= //=============================================================================
/*! /*!
@ -308,7 +301,7 @@ void StdMeshers_CompositeSegment_1D::SetEventListener(SMESH_subMesh* subMesh)
} }
} }
// set listener that will remove _alwaysComputed from submeshes at algorithm change // set listener that will remove _alwaysComputed from submeshes at algorithm change
subMesh->SetEventListener( _EventListener, 0, subMesh); subMesh->SetEventListener( new VertexNodesRestoringListener(), 0, subMesh);
StdMeshers_Regular_1D::SetEventListener( subMesh ); StdMeshers_Regular_1D::SetEventListener( subMesh );
} }
@ -480,7 +473,7 @@ bool StdMeshers_CompositeSegment_1D::Compute(SMESH_Mesh & aMesh,
// Update submeshes state for all edges and internal vertices, // Update submeshes state for all edges and internal vertices,
// make them look computed even if none edge or node is set on them // make them look computed even if none edge or node is set on them
careOfSubMeshes( *side, _EventListener ); careOfSubMeshes( *side );
return true; return true;
} }

View File

@ -40,7 +40,6 @@ class STDMESHERS_EXPORT StdMeshers_CompositeSegment_1D: public StdMeshers_Regula
{ {
public: public:
StdMeshers_CompositeSegment_1D(int hypId, int studyId, SMESH_Gen* gen); StdMeshers_CompositeSegment_1D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~StdMeshers_CompositeSegment_1D();
virtual bool Compute(SMESH_Mesh& aMesh, virtual bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape); const TopoDS_Shape& aShape);
@ -66,8 +65,6 @@ public:
*/ */
static std::string AlgoName(); static std::string AlgoName();
protected:
SMESH_subMeshEventListener* _EventListener;
}; };
#endif #endif