bos #35165 [CEA] Clear the mesh when an hypothesis is added to an algorithm

- Call Update after add hypothesis
- Fix problem, when after change hypothesis mesh in VTKViewer not clears automatically
This commit is contained in:
asozinov 2023-05-21 22:13:48 +01:00 committed by Christophe Bourcier
parent fd3745e6c2
commit c8dfd88621
4 changed files with 27 additions and 11 deletions

View File

@ -645,6 +645,7 @@ namespace SMESH
try { try {
CORBA::String_var error; CORBA::String_var error;
res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out()); res = aMesh->AddHypothesis(aShapeObject, aHyp, error.out());
UpdateViewer(aMesh);
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.suspend(); wc.suspend();
processHypothesisStatus(res, aHyp, true, error.in() ); processHypothesisStatus(res, aHyp, true, error.in() );
@ -676,6 +677,7 @@ namespace SMESH
{ {
CORBA::String_var error; CORBA::String_var error;
res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() ); res = aMesh->AddHypothesis( aShapeObject, aHyp, error.out() );
UpdateViewer(aMesh);
if (res > SMESH::HYP_OK) { if (res > SMESH::HYP_OK) {
wc.suspend(); wc.suspend();
processHypothesisStatus( res, aHyp, true, error.in() ); processHypothesisStatus( res, aHyp, true, error.in() );
@ -764,12 +766,7 @@ namespace SMESH
processHypothesisStatus(res, anHyp, false); processHypothesisStatus(res, anHyp, false);
wc.resume(); wc.resume();
} }
if ( _PTR(SObject) meshSO = SMESH::FindSObject(aMesh) ) UpdateViewer(aMesh);
{
if ( SMESH_Actor* actor = SMESH::FindActorByEntry( meshSO->GetID().c_str() ))
if( actor->GetVisibility() )
actor->Update();
}
} }
} catch(const SALOME::SALOME_Exception& S_ex) { } catch(const SALOME::SALOME_Exception& S_ex) {
wc.suspend(); wc.suspend();
@ -780,6 +777,16 @@ namespace SMESH
return res < SMESH::HYP_UNKNOWN_FATAL; return res < SMESH::HYP_UNKNOWN_FATAL;
} }
void UpdateViewer(SMESH::SMESH_Mesh_ptr theMesh)
{
if (_PTR(SObject) meshSO = SMESH::FindSObject(theMesh))
{
if (SMESH_Actor* actor = SMESH::FindActorByEntry(meshSO->GetID().c_str()))
if (actor->GetVisibility())
actor->Update();
}
}
SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp) SObjectList GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp)
{ {
SObjectList listSOmesh; SObjectList listSOmesh;

View File

@ -115,6 +115,8 @@ namespace SMESH
bool RemoveHypothesisOrAlgorithmOnMesh( _PTR(SObject), bool RemoveHypothesisOrAlgorithmOnMesh( _PTR(SObject),
SMESH::SMESH_Hypothesis_ptr ); SMESH::SMESH_Hypothesis_ptr );
SMESHGUI_EXPORT void UpdateViewer(SMESH::SMESH_Mesh_ptr);
typedef std::vector<_PTR(SObject)> SObjectList; typedef std::vector<_PTR(SObject)> SObjectList;
SMESHGUI_EXPORT SMESHGUI_EXPORT
SObjectList GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr ); SObjectList GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr );

View File

@ -158,7 +158,7 @@ bool SMESHGUI_MeshOp::onApply()
if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh ) if (( myToCreate && !myIsMesh ) || myIsInvalidSubMesh )
aResult = createSubMesh( aMess, anEntryList ); aResult = createSubMesh( aMess, anEntryList );
else if ( !myToCreate ) else if ( !myToCreate )
aResult = editMeshOrSubMesh( aMess ); aResult = editMeshOrSubMesh( aMess, anEntryList );
if ( aResult ) if ( aResult )
{ {
SMESHGUI::Modified(); SMESHGUI::Modified();
@ -2577,13 +2577,14 @@ int SMESHGUI_MeshOp::find( const SMESH::SMESH_Hypothesis_var& theHyp,
//================================================================================ //================================================================================
/*! /*!
* \brief Edits mesh or sub-mesh * \brief Edits mesh or sub-mesh
* \param theMess - Output parameter intended for returning error message * \param theMess - Output parameter intended for returning error message
* \retval bool - TRUE if mesh is edited successfully, FALSE otherwise * \param theEntryList - List of entries of published objects
* \retval bool - TRUE if mesh is edited successfully, FALSE otherwise
* *
* Assigns new name hypotheses and algorithms to the mesh or sub-mesh * Assigns new name hypotheses and algorithms to the mesh or sub-mesh
*/ */
//================================================================================ //================================================================================
bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess ) bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess, QStringList& theEntryList)
{ {
theMess = ""; theMess = "";
@ -2628,6 +2629,12 @@ bool SMESHGUI_MeshOp::editMeshOrSubMesh( QString& theMess )
if ( !isMesh && !aSubMeshVar->_is_nil() ) if ( !isMesh && !aSubMeshVar->_is_nil() )
aMesh = aSubMeshVar->GetFather(); aMesh = aSubMeshVar->GetFather();
_PTR(SObject) aMeshSO = SMESH::FindSObject(aMesh.in());
if (aMeshSO) {
SMESH::SetName(aMeshSO, myDlg->objectText(SMESHGUI_MeshDlg::Obj));
theEntryList.append(aMeshSO->GetID().c_str());
}
// Assign new algorithms and hypotheses // Assign new algorithms and hypotheses
for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ ) for ( int dim = aDim; dim <= SMESH::DIM_3D; dim++ )
{ {

View File

@ -120,7 +120,7 @@ private:
bool createMesh( QString&, QStringList& ); bool createMesh( QString&, QStringList& );
bool createSubMesh( QString&, QStringList& ); bool createSubMesh( QString&, QStringList& );
bool editMeshOrSubMesh( QString& ); bool editMeshOrSubMesh( QString&, QStringList& );
void createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh, void createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh,
GEOM::GEOM_Object_ptr mainShape ); GEOM::GEOM_Object_ptr mainShape );
bool checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr mesh, bool checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr mesh,