1 // Copyright (C) 2007-2020 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, or (at your option) any later version.
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_ComputeError.hxx
21 // Author : Edward AGAPOV (eap)
24 #ifndef SMESH_ComputeError_HeaderFile
25 #define SMESH_ComputeError_HeaderFile
27 #include "SMESH_Utils.hxx"
28 #include "SMDS_ElementHolder.hxx"
32 #include <boost/shared_ptr.hpp>
35 class SMDS_MeshElement;
36 struct SMESH_ComputeError;
38 typedef boost::shared_ptr<SMESH_ComputeError> SMESH_ComputeErrorPtr;
40 // =============================================================
42 enum SMESH_ComputeErrorName
44 // If you modify it, pls update SMESH_ComputeError::CommonName() below.
45 // Positive values are for algo specific errors
47 COMPERR_BAD_INPUT_MESH = -2, //!< wrong mesh on lower submesh
48 COMPERR_STD_EXCEPTION = -3, //!< some std exception raised
49 COMPERR_OCC_EXCEPTION = -4, //!< OCC exception raised
50 COMPERR_SLM_EXCEPTION = -5, //!< SALOME exception raised
51 COMPERR_EXCEPTION = -6, //!< other exception raised
52 COMPERR_MEMORY_PB = -7, //!< std::bad_alloc exception
53 COMPERR_ALGO_FAILED = -8, //!< algo failed for some reason
54 COMPERR_BAD_SHAPE = -9, //!< bad geometry
55 COMPERR_WARNING = -10, //!< algo reports error but sub-mesh is computed anyway
56 COMPERR_CANCELED = -11, //!< compute canceled
57 COMPERR_NO_MESH_ON_SHAPE = -12, //!< no mesh elements assigned to sub-shape
58 COMPERR_BAD_PARMETERS = -13, //!< incorrect hypotheses parameters
59 COMPERR_LAST_ALGO_ERROR = -100,//!< terminator of mesh computation errors
60 // Errors of SMESH_MeshEditor follow
61 EDITERR_NO_MEDIUM_ON_GEOM= -101 /* during conversion to quadratic,
62 some medium nodes not placed on geometry
63 to avoid distorting elements, which are
64 stored in SMESH_ComputeError::myBadElements */
67 // =============================================================
69 * \brief Contains an algorithm and description of an occurred error
71 // =============================================================
73 struct SMESHUtils_EXPORT SMESH_ComputeError
75 int myName; //!< SMESH_ComputeErrorName or anything algo specific
76 std::string myComment;
77 const SMESH_Algo* myAlgo;
79 static SMESH_ComputeErrorPtr New( int error = COMPERR_OK,
80 std::string comment = "",
81 const SMESH_Algo* algo = 0)
82 { return SMESH_ComputeErrorPtr( new SMESH_ComputeError( error, comment, algo )); }
84 SMESH_ComputeError( int error = COMPERR_OK,
85 std::string comment = "",
86 const SMESH_Algo* algo = 0)
87 : myName(error), myComment(comment), myAlgo(algo) {}
89 bool IsOK() const { return myName == COMPERR_OK; }
90 bool IsKO() const { return myName != COMPERR_OK && myName != COMPERR_WARNING; }
91 bool IsCommon() const { return myName < 0 && myName > COMPERR_LAST_ALGO_ERROR; }
92 virtual bool HasBadElems() const { return false; }
94 // not inline methods are implemented in src/SMESHUtils/SMESH_TryCatch.cxx
96 // Return myName as text, to be used to dump errors in terminal
97 std::string CommonName() const;
99 // Return the most severe error
100 static SMESH_ComputeErrorPtr Worst( SMESH_ComputeErrorPtr er1,
101 SMESH_ComputeErrorPtr er2 );
103 virtual ~SMESH_ComputeError() {}
106 struct SMESHUtils_EXPORT SMESH_BadInputElements : public SMESH_ComputeError, SMDS_ElementHolder
108 typedef std::list<const SMDS_MeshElement*> TElemList;
109 TElemList myBadElements; //!< to explain COMPERR_BAD_INPUT_MESH
111 SMESH_BadInputElements(const SMDS_Mesh* mesh,
112 int error = COMPERR_OK,
113 std::string comment = "",
114 const SMESH_Algo* algo = 0)
115 :SMESH_ComputeError(error, comment ,algo), SMDS_ElementHolder(mesh) {}
117 const SMDS_Mesh* GetMesh() const { return myMesh; }
118 const TElemList& GetElements() { return myBadElements; }
120 virtual bool HasBadElems() const { return !myBadElements.empty(); }
122 // methods of SMDS_ElementHolder
123 virtual SMDS_ElemIteratorPtr getElements();
124 virtual void tmpClear();
125 virtual void add( const SMDS_MeshElement* element );
126 virtual void compact() { }