From: eap Date: Thu, 24 Feb 2022 10:05:01 +0000 (+0300) Subject: bos #16292 [CEA 6719] MGCADSurf: option SetEnforced1D mesh X-Git-Tag: V9_9_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=488f48ca143d9bdb109acf0922c6d4d89f1df924;p=plugins%2Fblsurfplugin.git bos #16292 [CEA 6719] MGCADSurf: option SetEnforced1D mesh Add dependency of an enforced mesh --- diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index abb3dfb..cd4eef4 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -45,6 +45,7 @@ extern "C"{ #include #include #include +#include #include #include @@ -91,8 +92,6 @@ extern "C"{ #include #include #include -#include -#include #ifndef WIN32 #include @@ -2969,6 +2968,14 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, error(_comment); } + // Set event listeners + if ( _hypothesis ) + for ( int iF = 1; iF <= fmap.Size(); ++iF ) + { + const TopoDS_Shape& face = fmap( iF ); + SetEventListener( aMesh.GetSubMesh( face )); + } + // Issue 0019864. On DebianSarge, FE signals do not obey to OSD::SetSignal(false) #ifndef WIN32 if ( oldFEFlags > 0 ) @@ -3678,3 +3685,52 @@ void BLSURFPlugin_BLSURF::FillEntryToShape( const BLSURFPlugin_Hypothesis* entryToShape.insert({ entry, shape }); } } + +//================================================================================ +/*! + * \brief Sets event listener to submeshes if enforced mesh is defined + * \param subMesh - submesh where algo is set + * + * This method is called when a submesh gets HYP_OK algo_state. + * After being set, event listener is notified on each event of a submesh. + * By default none listener is set + */ +//================================================================================ + +void BLSURFPlugin_BLSURF::SetEventListener(SMESH_subMesh* faceSubMesh) +{ + if ( !_hypothesis ) + return; + + for ( const BLSURFPlugin_Hypothesis::EnforcedMesh& enfMesh : _hypothesis->GetEnforcedMeshes() ) + { + SMESH_Mesh* mesh1D; + _hypothesis->GetEnforcedSegments( enfMesh, mesh1D ); + if ( !mesh1D ) + continue; + + TopExp_Explorer edgeExp( mesh1D->GetShapeToMesh(), TopAbs_EDGE ); + if ( edgeExp.More() ) + StdMeshers_ProjectionUtils::SetEventListener( faceSubMesh, + edgeExp.Current(), + mesh1D ); + // StdMeshers_ProjectionUtils::SetEventListener( faceSubMesh, + // mesh1D->GetShapeToMesh(), + // mesh1D ); + } + return; +} + +//================================================================================ +/*! + * \brief Allow algo to do something after persistent restoration + * \param subMesh - restored submesh + * + * This method is called only if a submesh has HYP_OK algo_state. + */ +//================================================================================ + +void BLSURFPlugin_BLSURF::SubmeshRestored(SMESH_subMesh* subMesh) +{ + SetEventListener( subMesh ); +} diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx index 936bdd3..4c045a4 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx @@ -98,6 +98,11 @@ public: static void FillEntryToShape( const BLSURFPlugin_Hypothesis* hyp, std::map< std::string, TopoDS_Shape > & s2eMap ); + virtual void SetEventListener(SMESH_subMesh* subMesh) override; + virtual void SubmeshRestored(SMESH_subMesh* subMesh) override; + + + // List of ids typedef std::vector TListOfIDs; diff --git a/src/BLSURFPlugin/BLSURFPlugin_EnforcedMesh1D.cxx b/src/BLSURFPlugin/BLSURFPlugin_EnforcedMesh1D.cxx index 45a302b..1268ccb 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_EnforcedMesh1D.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_EnforcedMesh1D.cxx @@ -101,8 +101,6 @@ namespace * \param [in] braNodes - nodes of the branch * \param [in] nodeIndex - index of a node of the branch * \param [inout] mesh - mesh holding the nodes and segments - * - * */ //================================================================================ @@ -336,7 +334,7 @@ copyEnforcedMesh( const BLSURFPlugin_Hypothesis::EnforcedMesh& theEnfMesh, SMESH_Mesh* mesh1D; SMDS_ElemIteratorPtr segIt = theHyp->GetEnforcedSegments( theEnfMesh, mesh1D ); if ( !segIt->more() ) - return; + throw SALOME_Exception("No edges in an enforced mesh"); // setup predicates to detect nodes on FACE boundary setupPredicates( theShape );