Compute also dump a check on isDone through function CheckCompute

This commit is contained in:
YOANN AUDOUIN 2023-09-11 08:09:40 +02:00 committed by yoann.audouin
parent 42e25f073b
commit 127761db37
3 changed files with 32 additions and 3 deletions

View File

@ -700,6 +700,7 @@ Handle(_pyCommand) _pyGen::AddCommand( const TCollection_AsciiString& theCommand
if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName()) if ( objID == this->GetID() || objID == SMESH_2smeshpy::GenName())
{ {
this->Process( aCommand ); this->Process( aCommand );
//addFilterUser( aCommand, theGen ); // protect filters from clearing //addFilterUser( aCommand, theGen ); // protect filters from clearing
return aCommand; return aCommand;
} }
@ -1015,6 +1016,7 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
// Concatenate( [mesh1, ...], ... ) // Concatenate( [mesh1, ...], ... )
// CreateHypothesis( theHypType, theLibName ) // CreateHypothesis( theHypType, theLibName )
// Compute( mesh, geom ) // Compute( mesh, geom )
// CheckCompute( mesh, isDone )
// Evaluate( mesh, geom ) // Evaluate( mesh, geom )
// mesh creation // mesh creation
TCollection_AsciiString method = theCommand->GetMethod(); TCollection_AsciiString method = theCommand->GetMethod();
@ -1093,12 +1095,30 @@ void _pyGen::Process( const Handle(_pyCommand)& theCommand )
if ( id_mesh != myMeshes.end() ) { if ( id_mesh != myMeshes.end() ) {
theCommand->SetObject( meshID ); theCommand->SetObject( meshID );
theCommand->RemoveArgs(); 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->Process( theCommand );
id_mesh->second->AddProcessedCmd( theCommand ); id_mesh->second->AddProcessedCmd( theCommand );
return; return;
} }
} }
// smeshgen.Evaluate( mesh, geom ) --> mesh.Evaluate(geom) // smeshgen.Evaluate( mesh, geom ) --> mesh.Evaluate(geom)
if ( method == "Evaluate" ) if ( method == "Evaluate" )
{ {
@ -2224,7 +2244,7 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
"GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes", "GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes",
"IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor", "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
"Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder", "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder",
"SetNbThreads" "SetNbThreads", "CheckCompute"
,"" }; // <- mark of end ,"" }; // <- mark of end
sameMethods.Insert( names ); 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
*/ */
//================================================================================ //================================================================================

View File

@ -2078,7 +2078,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
// Update Python script // Update Python script
TPythonDump(this) << "isDone = " << this << ".Compute( " TPythonDump(this) << "isDone = " << this << ".Compute( "
<< theMesh << ", " << theShapeObject << ")"; << theMesh << ", " << theShapeObject << ")";
TPythonDump(this) << this << ".CheckCompute( "
<< theMesh << ", isDone" << ")";
try { try {
// get mesh servant // get mesh servant

View File

@ -2001,6 +2001,13 @@ class Mesh(metaclass = MeshMeta):
return ok 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 ): def GetComputeErrors(self, shape=0 ):
""" """
Return a list of error messages (:class:`SMESH.ComputeError`) of the last :meth:`Compute` Return a list of error messages (:class:`SMESH.ComputeError`) of the last :meth:`Compute`