Salome HOME
Update of CheckDone master
authoryoann.audouin <yoann.audouin@edf.fr>
Thu, 21 Mar 2024 14:25:31 +0000 (15:25 +0100)
committeryoann.audouin <yoann.audouin@edf.fr>
Thu, 21 Mar 2024 14:25:31 +0000 (15:25 +0100)
Removed the isDone argument using cxx isComputedOK instead (now in the
idl)
Corrected a bug when doing multiple compute checkCompute was not
properly removed.

idl/SMESH_Mesh.idl
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_2smeshpy.hxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index 0f9da0ec4a0d4293d397863ac92429e1ef61dafd..fabf323432f2c69feac607a4d34e25e88411fae8 100644 (file)
@@ -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
      */
index 8f140341dc497006a45516f357bc7008372c6ab3..1e73de97a1f8ebe7d98ca501f1d9bfc6b3f015d3 100644 (file)
@@ -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
   {
index 45fdd40655c620f583e90af6102fc9bdc2d508ad..b5363cc4e7d53ec0db1d7646ea037518fc13af28 100644 (file)
@@ -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
 
 // -------------------------------------------------------------------------------------
 /*!
index 57573399df05d20168e655563f62139cf5a9700a..265be507473ab82b1f5f1ecc164b383210631467 100644 (file)
@@ -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
index 3cffbc46c103df198c458ff931c63a15283f14cd..13c602d92236e2149961b4aad33e877a31a5106c 100644 (file)
@@ -5954,7 +5954,7 @@ void SMESH_Mesh_i::CreateGroupServants()
  */
 //=============================================================================
 
-bool SMESH_Mesh_i::IsComputedOK()
+CORBA::Boolean SMESH_Mesh_i::IsComputedOK()
 {
   return _impl->IsComputedOK();
 }
index bd95312443e1ce385bbbcfc51c5926556590280e..d56f4e28aabd9643f47f7893dbb3c1c2248bf276 100644 (file)
@@ -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
index 42b88e78e6b257834ddcdfee3754cce14a12a57b..2401ed74cfcc7be98c4e92706c120e297250a1c7 100644 (file)
@@ -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 ):