X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_CompositeSegment_1D.cxx;h=5a830c208a46d75158c56663f1ec61f6cf9f3b6e;hp=c71c9dfc02ba1e1e047f5f60aeb95d1450aba7eb;hb=80fe1ddefc561a7a571ac08807f7d173f45d8080;hpb=e57d64d3910c1a5f0eca72ee7244d32873495517 diff --git a/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx b/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx index c71c9dfc0..5a830c208 100644 --- a/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx +++ b/src/StdMeshers/StdMeshers_CompositeSegment_1D.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -63,6 +63,8 @@ using namespace std; namespace { + void careOfSubMeshes( StdMeshers_FaceSide& side ); + //================================================================================ /*! * \brief Search for an edge conjunct to the given one by the vertex @@ -104,43 +106,6 @@ namespace { 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 @@ -151,17 +116,19 @@ namespace { struct VertexNodesRestoringListener : public SMESH_subMeshEventListener { VertexNodesRestoringListener(): - SMESH_subMeshEventListener(0, // won't be deleted by submesh + SMESH_subMeshEventListener(1, // will be deleted by sub-mesh "StdMeshers_CompositeSegment_1D::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) - * \param subMesh - the submesh where the event occures - * \param data - listener data stored in the subMesh - * \param hyp - hypothesis, if eventType is algo_event - */ + 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) + * \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, const int eventType, SMESH_subMesh* subMesh, @@ -210,7 +177,7 @@ namespace { ( StdMeshers_CompositeSegment_1D::GetFaceSide(*subMesh->GetFather(), edge, face, false )); if ( side->NbEdges() > 1 && side->NbSegments() ) - careOfSubMeshes( *side, this ); + careOfSubMeshes( *side ); } } } @@ -229,6 +196,43 @@ namespace { } } }; // 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"); _name = AlgoName(); - _EventListener = new VertexNodesRestoringListener(); } //======================================================================= @@ -256,16 +259,6 @@ std::string StdMeshers_CompositeSegment_1D::AlgoName() { 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 - subMesh->SetEventListener( _EventListener, 0, subMesh); + subMesh->SetEventListener( new VertexNodesRestoringListener(), 0, 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, // make them look computed even if none edge or node is set on them - careOfSubMeshes( *side, _EventListener ); + careOfSubMeshes( *side ); return true; }