From 82e34f118335786cb9dbabfaea8e8574e47081ce Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 10 Apr 2007 14:02:42 +0000 Subject: [PATCH] PAL13330( When mesh generation does not success, trace where ) Add methods and members to store compute errors --- src/SMESH/SMESH_Algo.cxx | 59 ++++++++++++++++++++++++++++++++++++++-- src/SMESH/SMESH_Algo.hxx | 45 ++++++++++++++++++++++++------ 2 files changed, 94 insertions(+), 10 deletions(-) diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index a13d31fdc..16d3a99dd 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -27,6 +27,7 @@ // $Header$ #include "SMESH_Algo.hxx" +#include "SMESH_Comment.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_HypoFilter.hxx" @@ -77,6 +78,7 @@ SMESH_Algo::SMESH_Algo(int hypId, int studyId, _onlyUnaryInput = _requireDescretBoundary = _requireShape = true; _quadraticMesh = false; + _error = COMPERR_OK; } //============================================================================= @@ -469,7 +471,60 @@ void SMESH_Algo::SubmeshRestored(SMESH_subMesh* /*subMesh*/) */ //================================================================================ -bool SMESH_Algo::Compute(SMESH_Mesh & /*aMesh*/, SMESH_MesherHelper* aHelper) +bool SMESH_Algo::Compute(SMESH_Mesh & /*aMesh*/, SMESH_MesherHelper* /*aHelper*/) { - return false; + return error( COMPERR_BAD_INPUT_MESH, "Mesh built on shape expected"); +} + +//================================================================================ +/*! + * \brief store error and comment and then return ( error == COMPERR_OK ) + */ +//================================================================================ + +bool SMESH_Algo::error(int error, const SMESH_Comment& comment) +{ + _error = error; + _comment = comment; + return ( error == COMPERR_OK ); +} + +//================================================================================ +/*! + * \brief store error and return ( error == COMPERR_OK ) + */ +//================================================================================ + +bool SMESH_Algo::error(SMESH_ComputeErrorPtr error) +{ + if ( error ) { + _error = error->myName; + _comment = error->myComment; + return error->IsOK(); + } + return true; } + +//================================================================================ +/*! + * \brief return compute error + */ +//================================================================================ + +SMESH_ComputeErrorPtr SMESH_Algo::GetComputeError() const +{ + return SMESH_ComputeError::New( _error, _comment, this ); +} + +//================================================================================ +/*! + * \brief initialize compute error + */ +//================================================================================ + +void SMESH_Algo::InitComputeError() +{ + _error = COMPERR_OK; + _comment.clear(); +} + diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index 675264e36..02c76d253 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -30,16 +30,15 @@ #define _SMESH_ALGO_HXX_ #include "SMESH_Hypothesis.hxx" +#include "SMESH_ComputeError.hxx" #include #include -#include #include #include #include #include -#include class SMESH_Gen; class SMESH_Mesh; @@ -51,6 +50,8 @@ class SMESHDS_Mesh; class SMDS_MeshNode; class SMESH_subMesh; class SMESH_MesherHelper; +class SMESH_Comment; + class SMESH_Algo:public SMESH_Hypothesis { @@ -102,6 +103,10 @@ public: * \param aMesh - the mesh * \param aShape - the shape * \retval bool - is a success + * + * Algorithms that !NeedDescretBoundary() || !OnlyUnaryInput() are + * to set SMESH_ComputeError returned by SMESH_submesh::GetComputeError() + * to report problematic subshapes */ virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0; @@ -157,15 +162,19 @@ public: const bool ignoreAuxiliary) const; /*! * \brief Initialize my parameter values by the mesh built on the geometry - * \param theMesh - the built mesh - * \param theShape - the geometry of interest - * \retval bool - true if parameter values have been successfully defined * * Just return false as the algorithm does not hold parameters values */ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); - + /*! + * \brief return compute error + */ + SMESH_ComputeErrorPtr GetComputeError() const; + /*! + * \brief initialize compute error + */ + void InitComputeError(); public: // ================================================================== @@ -262,7 +271,23 @@ public: SMESHDS_Mesh* meshDS); protected: - std::vector _compatibleHypothesis; + + /*! + * \brief store error and comment and then return ( error == COMPERR_OK ) + */ + bool error(int error, const SMESH_Comment& comment = ""); + /*! + * \brief To be used as error in previous method + */ + SMESH_ComputeErrorName dfltErr() const { return COMPERR_ALGO_FAILED; } + /*! + * \brief store error and return error->IsOK() + */ + bool error(SMESH_ComputeErrorPtr error); + +protected: + + std::vector _compatibleHypothesis; std::list _appliedHypList; std::list _usedHypList; @@ -270,8 +295,12 @@ protected: bool _requireDescretBoundary; bool _requireShape; - // quadratic mesh creation required + // quadratic mesh creation required, + // is usually set trough SMESH_MesherHelper::IsQuadraticSubMesh() bool _quadraticMesh; + + int _error; //!< SMESH_ComputeErrorName or anything algo specific + std::string _comment; //!< any text explaining what is wrong in Compute() }; #endif -- 2.39.2