From 127761db37b8866d7d3125f2a3cbfbdcf2cdb740 Mon Sep 17 00:00:00 2001 From: YOANN AUDOUIN Date: Mon, 11 Sep 2023 08:09:40 +0200 Subject: [PATCH] Compute also dump a check on isDone through function CheckCompute --- src/SMESH_I/SMESH_2smeshpy.cxx | 24 ++++++++++++++++++++++-- src/SMESH_I/SMESH_Gen_i.cxx | 4 +++- src/SMESH_SWIG/smeshBuilder.py | 7 +++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 5d6fbc10f..8f140341d 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -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 */ //================================================================================ diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index f1180652e..57573399d 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -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 diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 1bb9a251b..42b88e78e 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -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` -- 2.30.2