From 58f17329c51815989f1ad7bfe8a3c1909a52f58e Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 21 Jul 2008 09:41:11 +0000 Subject: [PATCH] [SALOME platform 0019316]: Need to have a better interface with GHS3D diagnostics store bad input elements and nodes --- src/SMESH/SMESH_Algo.cxx | 25 ++++++++++++++++++++++++- src/SMESH/SMESH_Algo.hxx | 7 +++++++ src/SMESH/SMESH_ComputeError.hxx | 22 +++++++++++++--------- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 47346f2da..fea326576 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -502,6 +502,7 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error) if ( error ) { _error = error->myName; _comment = error->myComment; + _badInputElements = error->myBadElements; return error->IsOK(); } return true; @@ -515,7 +516,11 @@ bool SMESH_Algo::error(SMESH_ComputeErrorPtr error) SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const { - return SMESH_ComputeError::New( _error, _comment, this ); + SMESH_ComputeErrorPtr err = SMESH_ComputeError::New( _error, _comment, this ); + // hope this method is called by only SMESH_subMesh after this->Compute() + err->myBadElements.splice( err->myBadElements.end(), + (list&) _badInputElements ); + return err; } //================================================================================ @@ -528,5 +533,23 @@ void SMESH_Algo::InitComputeError() { _error = COMPERR_OK; _comment.clear(); + list::iterator elem = _badInputElements.begin(); + for ( ; elem != _badInputElements.end(); ++elem ) + if ( (*elem)->GetID() < 1 ) + delete *elem; + _badInputElements.clear(); } +//================================================================================ +/*! + * \brief store a bad input element preventing computation, + * which may be a temporary one i.e. not residing the mesh, + * then it will be deleted by InitComputeError() + */ +//================================================================================ + +void SMESH_Algo::addBadInputElement(const SMDS_MeshElement* elem) +{ + if ( elem ) + _badInputElements.push_back( elem ); +} diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index f08fd85e7..1a47fa291 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -293,6 +293,12 @@ protected: * \brief store error and return error->IsOK() */ bool error(SMESH_ComputeErrorPtr error); + /*! + * \brief store a bad input element preventing computation, + * which may be a temporary one i.e. not residing the mesh, + * then it will be deleted by InitComputeError() + */ + void addBadInputElement(const SMDS_MeshElement* elem); protected: @@ -310,6 +316,7 @@ protected: int _error; //!< SMESH_ComputeErrorName or anything algo specific std::string _comment; //!< any text explaining what is wrong in Compute() + std::list _badInputElements; //!< to explain COMPERR_BAD_INPUT_MESH }; #endif diff --git a/src/SMESH/SMESH_ComputeError.hxx b/src/SMESH/SMESH_ComputeError.hxx index 91f2712c2..07c6116b1 100644 --- a/src/SMESH/SMESH_ComputeError.hxx +++ b/src/SMESH/SMESH_ComputeError.hxx @@ -30,9 +30,11 @@ #define SMESH_ComputeError_HeaderFile #include +#include #include class SMESH_Algo; +class SMDS_MeshElement; struct SMESH_ComputeError; typedef boost::shared_ptr SMESH_ComputeErrorPtr; @@ -66,6 +68,8 @@ struct SMESH_ComputeError std::string myComment; const SMESH_Algo* myAlgo; + std::list myBadElements; //!< to explain COMPERR_BAD_INPUT_MESH + static SMESH_ComputeErrorPtr New( int error = COMPERR_OK, std::string comment = "", const SMESH_Algo* algo = 0) @@ -82,19 +86,19 @@ struct SMESH_ComputeError }; -#define case2char(err) case err: return #err; +#define _case2char(err) case err: return #err; std::string SMESH_ComputeError::CommonName() const { switch( myName ) { - case2char(COMPERR_OK ); - case2char(COMPERR_BAD_INPUT_MESH); - case2char(COMPERR_STD_EXCEPTION ); - case2char(COMPERR_OCC_EXCEPTION ); - case2char(COMPERR_SLM_EXCEPTION ); - case2char(COMPERR_EXCEPTION ); - case2char(COMPERR_MEMORY_PB ); - case2char(COMPERR_ALGO_FAILED ); + _case2char(COMPERR_OK ); + _case2char(COMPERR_BAD_INPUT_MESH); + _case2char(COMPERR_STD_EXCEPTION ); + _case2char(COMPERR_OCC_EXCEPTION ); + _case2char(COMPERR_SLM_EXCEPTION ); + _case2char(COMPERR_EXCEPTION ); + _case2char(COMPERR_MEMORY_PB ); + _case2char(COMPERR_ALGO_FAILED ); default:; } return ""; -- 2.30.2