Salome HOME
Compute also dump a check on isDone through function CheckCompute
authorYOANN AUDOUIN <B61570@dsp1062659>
Mon, 11 Sep 2023 06:09:40 +0000 (08:09 +0200)
committeryoann.audouin <yoann.audouin@edf.fr>
Fri, 15 Mar 2024 13:40:50 +0000 (14:40 +0100)
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Gen_i.cxx
src/SMESH_SWIG/smeshBuilder.py

index 5d6fbc10f571c72a28ff4ee9bc7cbe2136d22729..8f140341dc497006a45516f357bc7008372c6ab3 100644 (file)
@@ -700,6 +700,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
   if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName())
   {
     this->Process( aCommand );
+
     //addFilterUser( aCommand, theGen ); // protect filters from clearing
     return aCommand;
   }
@@ -1015,6 +1016,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
   // Concatenate( [mesh1, ...], ... )
   // CreateHypothesis( theHypType, theLibName )
   // Compute( mesh, geom )
+  // CheckCompute( mesh, isDone )
   // Evaluate( mesh, geom )
   // mesh creation
   TCollection_AsciiString method = theCommand->GetMethod();
@@ -1093,12 +1095,30 @@ 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)
+  if ( method == "CheckCompute" )
+  {
+    const _pyID& meshID = theCommand->GetArg( 1 );
+    map< _pyID, Handle(_pyMesh) >::iterator id_mesh = myMeshes.find( meshID );
+    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;
     }
   }
 
+
   // smeshgen.Evaluate( mesh, geom ) --> mesh.Evaluate(geom)
   if ( method == "Evaluate" )
   {
@@ -2224,7 +2244,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
         "GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes",
         "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
         "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder",
-        "SetNbThreads"
+        "SetNbThreads", "CheckCompute"
         ,"" }; // <- mark of end
     sameMethods.Insert( names );
   }
@@ -3134,7 +3154,7 @@ void _pyHypothesis::rememberCmdOfParameter( const Handle(_pyCommand) & theComman
 
 //================================================================================
 /*!
- * \brief Return true if a setting parameter command ha been used to compute mesh
+ * \brief Return true if a setting parameter command has been used to compute mesh
  */
 //================================================================================
 
index f1180652ea7fe3446f749fa77fd40e005f867e49..57573399df05d20168e655563f62139cf5a9700a 100644 (file)
@@ -2078,7 +2078,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
 
   // Update Python script
   TPythonDump(this) << "isDone = " << this << ".Compute( "
-                << theMesh << ", " << theShapeObject << ")";
+                    << theMesh << ", " << theShapeObject << ")";
+  TPythonDump(this) << this << ".CheckCompute( "
+                    << theMesh << ", isDone" << ")";
 
   try {
     // get mesh servant
index 1bb9a251bb4d0fa662a8fc079ed3dad6e83b453b..42b88e78e6b257834ddcdfee3754cce14a12a57b 100644 (file)
@@ -2001,6 +2001,13 @@ class Mesh(metaclass = MeshMeta):
 
         return ok
 
+    def CheckCompute(self, isDone):
+        """
+        Check if the mesh was properly compute
+        """
+        if not isDone:
+            raise Exception("Could not compute {}".format(self.GetName()))
+
     def GetComputeErrors(self, shape=0 ):
         """
         Return a list of error messages (:class:`SMESH.ComputeError`) of the last :meth:`Compute`