From: yoann.audouin Date: Thu, 21 Mar 2024 14:25:31 +0000 (+0100) Subject: Update of CheckDone X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=HEAD Update of CheckDone Removed the isDone argument using cxx isComputedOK instead (now in the idl) Corrected a bug when doing multiple compute checkCompute was not properly removed. --- diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index 0f9da0ec4..fabf32343 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -436,6 +436,12 @@ module SMESH void RemoveGroupWithContents( in SMESH_GroupBase aGroup ) raises (SALOME::SALOME_Exception); + /*! + * Return True if all the submeshes are computed + */ + boolean IsComputedOK() + raises (SALOME::SALOME_Exception); + /*! * Get the list of groups existing in the mesh */ diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 8f140341d..1e73de97a 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1016,7 +1016,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) // Concatenate( [mesh1, ...], ... ) // CreateHypothesis( theHypType, theLibName ) // Compute( mesh, geom ) - // CheckCompute( mesh, isDone ) + // CheckCompute( mesh ) // Evaluate( mesh, geom ) // mesh creation TCollection_AsciiString method = theCommand->GetMethod(); @@ -1095,15 +1095,13 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) if ( id_mesh != myMeshes.end() ) { theCommand->SetObject( meshID ); theCommand->RemoveArgs(); - std::cout << "command: " << theCommand->GetString() << std::endl; id_mesh->second->Process( theCommand ); id_mesh->second->AddProcessedCmd( theCommand ); - std::cout << "command processed: " << theCommand->GetString() << std::endl; return; } } - // smeshgen.CheckCompute( mesh, isDone ) --> mesh.CheckCompute(isDone) + // smeshgen.CheckCompute( mesh ) --> mesh.CheckCompute() if ( method == "CheckCompute" ) { const _pyID& meshID = theCommand->GetArg( 1 ); @@ -1111,7 +1109,6 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand ) if ( id_mesh != myMeshes.end() ) { theCommand->SetObject( meshID ); theCommand->RemoveArgs(); - theCommand->SetArg(1, "isDone"); id_mesh->second->Process( theCommand ); id_mesh->second->AddProcessedCmd( theCommand ); return; @@ -1928,6 +1925,31 @@ void _pyMesh::Process( const Handle(_pyCommand)& theCommand ) } Flush(); } + // in snapshot mode, clear the previous CheckCompute() + else if ( method == "CheckCompute" ) + { + if ( !theGen->IsToKeepAllCommands() ) // !historical + { + if ( !myLastCheckCmd.IsNull() ) + { + // check if the previously computed mesh has been edited, + // if so then we do not clear the previous Compute() + bool toClear = true; + list< Handle(_pyMeshEditor)>::iterator e = myEditors.begin(); + for ( ; e != myEditors.end() && toClear; ++e ) + { + list< Handle(_pyCommand)>& cmds = (*e)->GetProcessedCmds(); + list< Handle(_pyCommand) >::reverse_iterator cmd = cmds.rbegin(); + if ( cmd != cmds.rend() && + (*cmd)->GetOrderNb() > myLastCheckCmd->GetOrderNb() ) + toClear = false; + } + if ( toClear ) + myLastCheckCmd->Clear(); + } + myLastCheckCmd = theCommand; + } + } // ---------------------------------------------------------------------- else if ( method == "Clear" ) // in snapshot mode, clear all previous commands { diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index 45fdd4065..b5363cc4e 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -53,7 +53,7 @@ * The creation reason is that smeshBuilder.py commands defining hypotheses encapsulate * several SMESH engine method calls. As well, the dependencies between smeshBuilder.py * classes differ from ones between corresponding SMESH IDL interfaces. - * + * * Everything here is for internal usage by SMESH_2smeshpy::ConvertScript() * declared in SMESH_PythonDump.hxx */ @@ -350,6 +350,7 @@ class _pyMesh: public _pyObject std::list< Handle(_pyMesh) > myChildMeshes; // depending on me bool myGeomNotInStudy; Handle(_pyCommand) myLastComputeCmd; + Handle(_pyCommand) myLastCheckCmd; public: _pyMesh(const Handle(_pyCommand) creationCmd); _pyMesh(const Handle(_pyCommand) theCreationCmd, const _pyID & id); @@ -373,7 +374,7 @@ private: DEFINE_STANDARD_RTTIEXT(_pyMesh,_pyObject) }; -#undef _pyMesh_ACCESS_METHOD +#undef _pyMesh_ACCESS_METHOD // ------------------------------------------------------------------------------------- /*! diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 57573399d..265be5074 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -2080,7 +2080,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, TPythonDump(this) << "isDone = " << this << ".Compute( " << theMesh << ", " << theShapeObject << ")"; TPythonDump(this) << this << ".CheckCompute( " - << theMesh << ", isDone" << ")"; + << theMesh << ")"; try { // get mesh servant diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 3cffbc46c..13c602d92 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -5954,7 +5954,7 @@ void SMESH_Mesh_i::CreateGroupServants() */ //============================================================================= -bool SMESH_Mesh_i::IsComputedOK() +CORBA::Boolean SMESH_Mesh_i::IsComputedOK() { return _impl->IsComputedOK(); } diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index bd9531244..d56f4e28a 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -424,15 +424,15 @@ public: */ void CreateGroupServants(); - /*! - * \brief Return true if all sub-meshes are computed OK - to update an icon - */ - bool IsComputedOK(); // ==================================== // SMESH_Mesh interface (continuation) // ==================================== + /*! + * \brief Return true if all sub-meshes are computed OK - to update an icon + */ + CORBA::Boolean IsComputedOK(); /*! * \brief Return groups cantained in _mapGroups by their IDs diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 42b88e78e..2401ed74c 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -2001,11 +2001,11 @@ class Mesh(metaclass = MeshMeta): return ok - def CheckCompute(self, isDone): + def CheckCompute(self): """ Check if the mesh was properly compute """ - if not isDone: + if not self.mesh.IsComputedOK(): raise Exception("Could not compute {}".format(self.GetName())) def GetComputeErrors(self, shape=0 ):