X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Algo.cxx;h=5ec1240b00bdcb9c8fd007e413b47c2d9b18a589;hp=8f071e7838dca925a575c8739e0986300fc63547;hb=f488c3c07d53aacb42ff2a143fb4a0cbfe8d5fc0;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 8f071e783..5ec1240b0 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -178,6 +178,7 @@ const SMESH_Algo::Features& SMESH_Algo::GetFeatures( const std::string& algoType SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen) : SMESH_Hypothesis(hypId, studyId, gen) { + _compatibleAllHypFilter = _compatibleNoAuxHypFilter = NULL; _onlyUnaryInput = _requireDiscreteBoundary = _requireShape = true; _quadraticMesh = _supportSubmeshes = false; _error = COMPERR_OK; @@ -193,6 +194,8 @@ SMESH_Algo::SMESH_Algo (int hypId, int studyId, SMESH_Gen * gen) SMESH_Algo::~SMESH_Algo() { + delete _compatibleNoAuxHypFilter; + // delete _compatibleAllHypFilter; -- _compatibleNoAuxHypFilter does it!!! } //============================================================================= @@ -263,10 +266,9 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh, { SMESH_Algo* me = const_cast< SMESH_Algo* >( this ); me->_usedHypList.clear(); - SMESH_HypoFilter filter; - if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary )) + if ( const SMESH_HypoFilter* filter = GetCompatibleHypoFilter( ignoreAuxiliary )) { - aMesh.GetHypotheses( aShape, filter, me->_usedHypList, true ); + aMesh.GetHypotheses( aShape, *filter, me->_usedHypList, true ); if ( ignoreAuxiliary && _usedHypList.size() > 1 ) me->_usedHypList.clear(); //only one compatible hypothesis allowed } @@ -288,9 +290,8 @@ SMESH_Algo::GetAppliedHypothesis(SMESH_Mesh & aMesh, { SMESH_Algo* me = const_cast< SMESH_Algo* >( this ); me->_appliedHypList.clear(); - SMESH_HypoFilter filter; - if ( InitCompatibleHypoFilter( filter, ignoreAuxiliary )) - aMesh.GetHypotheses( aShape, filter, me->_appliedHypList, false ); + if ( const SMESH_HypoFilter* filter = GetCompatibleHypoFilter( ignoreAuxiliary )) + aMesh.GetHypotheses( aShape, *filter, me->_appliedHypList, false ); return _appliedHypList; } @@ -410,7 +411,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM return false; SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge ); - if ( !eSubMesh || ( eSubMesh->NbElements()==0 && eSubMesh->NbNodes() == 0)) + if ( !eSubMesh || ( eSubMesh->NbElements()==0 && eSubMesh->NbNodes() == 0)) return false; // edge is not meshed int nbNodes = 0; @@ -457,27 +458,35 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM //================================================================================ /*! - * \brief Make filter recognize only compatible hypotheses - * \param theFilter - the filter to initialize - * \param ignoreAuxiliary - make filter ignore compatible auxiliary hypotheses + * \brief Returns the filter recognizing only compatible hypotheses + * \param ignoreAuxiliary - make filter ignore auxiliary hypotheses + * \retval SMESH_HypoFilter* - the filter that can be NULL */ //================================================================================ -bool SMESH_Algo::InitCompatibleHypoFilter( SMESH_HypoFilter & theFilter, - const bool ignoreAuxiliary) const +const SMESH_HypoFilter* +SMESH_Algo::GetCompatibleHypoFilter(const bool ignoreAuxiliary) const { if ( !_compatibleHypothesis.empty() ) { - theFilter.Init( theFilter.HasName( _compatibleHypothesis[0] )); - for ( int i = 1; i < _compatibleHypothesis.size(); ++i ) - theFilter.Or( theFilter.HasName( _compatibleHypothesis[ i ] )); - - if ( ignoreAuxiliary ) - theFilter.AndNot( theFilter.IsAuxiliary() ); - - return true; + if ( !_compatibleAllHypFilter ) + { + SMESH_HypoFilter* filter = new SMESH_HypoFilter(); + filter->Init( filter->HasName( _compatibleHypothesis[0] )); + for ( int i = 1; i < _compatibleHypothesis.size(); ++i ) + filter->Or( filter->HasName( _compatibleHypothesis[ i ] )); + + SMESH_HypoFilter* filterNoAux = new SMESH_HypoFilter( filter ); + filterNoAux->AndNot( filterNoAux->IsAuxiliary() ); + + // _compatibleNoAuxHypFilter will detele _compatibleAllHypFilter!!! + SMESH_Algo* me = const_cast< SMESH_Algo* >( this ); + me->_compatibleAllHypFilter = filter; + me->_compatibleNoAuxHypFilter = filterNoAux; + } + return ignoreAuxiliary ? _compatibleNoAuxHypFilter : _compatibleAllHypFilter; } - return false; + return 0; } //================================================================================ @@ -513,9 +522,7 @@ GeomAbs_Shape SMESH_Algo::Continuity(TopoDS_Edge E1, Standard_Real tol = BRep_Tool::Tolerance( V ); Standard_Real angTol = 2e-3; try { -#if OCC_VERSION_LARGE > 0x06010000 OCC_CATCH_SIGNALS; -#endif return BRepLProp::Continuity(C1, C2, u1, u2, tol, angTol); } catch (Standard_Failure) { @@ -594,6 +601,7 @@ bool SMESH_Algo::isDegenerated( const TopoDS_Edge & E ) * \param V - the vertex * \param meshDS - mesh * \retval const SMDS_MeshNode* - found node or NULL + * \sa SMESH_MesherHelper::GetSubShapeByNode( const SMDS_MeshNode*, SMESHDS_Mesh* ) */ //================================================================================