1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SMESH_Hypothesis.hxx
21 // Author : Edward AGAPOV (eap)
24 #ifndef SMESH_ComputeError_HeaderFile
25 #define SMESH_ComputeError_HeaderFile
29 #include <boost/shared_ptr.hpp>
32 class SMDS_MeshElement;
33 struct SMESH_ComputeError;
35 typedef boost::shared_ptr<SMESH_ComputeError> SMESH_ComputeErrorPtr;
37 // =============================================================
39 enum SMESH_ComputeErrorName
41 // If you modify it, pls update SMESH_ComputeError::CommonName() below.
42 // Positive values are for algo specific errors
44 COMPERR_BAD_INPUT_MESH = -2, //!< wrong mesh on lower submesh
45 COMPERR_STD_EXCEPTION = -3, //!< some std exception raised
46 COMPERR_OCC_EXCEPTION = -4, //!< OCC exception raised
47 COMPERR_SLM_EXCEPTION = -5, //!< SALOME exception raised
48 COMPERR_EXCEPTION = -6, //!< other exception raised
49 COMPERR_MEMORY_PB = -7, //!< std::bad_alloc exception
50 COMPERR_ALGO_FAILED = -8, //!< algo failed for some reason
51 COMPERR_BAD_SHAPE = -9, //!< bad geometry
52 COMPERR_WARNING = -10, //!< algo reports error but sub-mesh is computed anyway
53 COMPERR_CANCELED = -11, //!< compute canceled
54 COMPERR_NO_MESH_ON_SHAPE = -12, //!< no mesh elements assigned to sub-shape
55 COMPERR_LAST_ALGO_ERROR = -100,//!< terminator of mesh computation errors
56 // Errors of SMESH_MeshEditor follow
57 EDITERR_NO_MEDIUM_ON_GEOM= -101 /* during conversion to quadratic,
58 some medium nodes not placed on geometry
59 to avoid distorting elements, which are
60 stored in SMESH_ComputeError::myBadElements */
63 // =============================================================
65 * \brief Contains an algorithm and description of an occured error
67 // =============================================================
69 struct SMESH_ComputeError
71 int myName; //!< SMESH_ComputeErrorName or anything algo specific
72 std::string myComment;
73 const SMESH_Algo* myAlgo;
75 std::list<const SMDS_MeshElement*> myBadElements; //!< to explain COMPERR_BAD_INPUT_MESH
77 static SMESH_ComputeErrorPtr New( int error = COMPERR_OK,
78 std::string comment = "",
79 const SMESH_Algo* algo = 0)
80 { return SMESH_ComputeErrorPtr( new SMESH_ComputeError( error, comment, algo )); }
82 SMESH_ComputeError(int error = COMPERR_OK,
83 std::string comment = "",
84 const SMESH_Algo* algo = 0)
85 :myName(error),myComment(comment),myAlgo(algo) {}
87 bool IsOK() const { return myName == COMPERR_OK; }
88 bool IsKO() const { return myName != COMPERR_OK && myName != COMPERR_WARNING; }
89 bool IsCommon() const { return myName < 0 && myName > COMPERR_LAST_ALGO_ERROR; }
90 bool HasBadElems() const { return !myBadElements.empty(); }
91 inline std::string CommonName() const;
95 #define _case2char(err) case err: return #err;
97 // Return myName as text, to be used to dump errors in terminal
98 std::string SMESH_ComputeError::CommonName() const
101 _case2char(COMPERR_OK );
102 _case2char(COMPERR_BAD_INPUT_MESH );
103 _case2char(COMPERR_STD_EXCEPTION );
104 _case2char(COMPERR_OCC_EXCEPTION );
105 _case2char(COMPERR_SLM_EXCEPTION );
106 _case2char(COMPERR_EXCEPTION );
107 _case2char(COMPERR_MEMORY_PB );
108 _case2char(COMPERR_ALGO_FAILED );
109 _case2char(COMPERR_BAD_SHAPE );
110 _case2char(COMPERR_WARNING );
111 _case2char(COMPERR_CANCELED );
112 _case2char(COMPERR_NO_MESH_ON_SHAPE);