SALOME - SMESH
|
00001 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE 00002 // 00003 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, 00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 00005 // 00006 // This library is free software; you can redistribute it and/or 00007 // modify it under the terms of the GNU Lesser General Public 00008 // License as published by the Free Software Foundation; either 00009 // version 2.1 of the License. 00010 // 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 // Lesser General Public License for more details. 00015 // 00016 // You should have received a copy of the GNU Lesser General Public 00017 // License along with this library; if not, write to the Free Software 00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 // 00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com 00021 // 00022 // SMESH SMESH : implementaion of SMESH idl descriptions 00023 // File : SMESH_Hypothesis.hxx 00024 // Author : Edward AGAPOV (eap) 00025 // Module : SMESH 00026 // $Header: 00027 // 00028 #ifndef SMESH_ComputeError_HeaderFile 00029 #define SMESH_ComputeError_HeaderFile 00030 00031 #include <string> 00032 #include <list> 00033 #include <boost/shared_ptr.hpp> 00034 00035 class SMESH_Algo; 00036 class SMDS_MeshElement; 00037 struct SMESH_ComputeError; 00038 00039 typedef boost::shared_ptr<SMESH_ComputeError> SMESH_ComputeErrorPtr; 00040 00041 // ============================================================= 00042 00043 enum SMESH_ComputeErrorName 00044 { 00045 // If you modify it, pls update SMESH_ComputeError::CommonName() below. 00046 // Positive values are for algo specific errors 00047 COMPERR_OK = -1, 00048 COMPERR_BAD_INPUT_MESH = -2, 00049 COMPERR_STD_EXCEPTION = -3, 00050 COMPERR_OCC_EXCEPTION = -4, 00051 COMPERR_SLM_EXCEPTION = -5, 00052 COMPERR_EXCEPTION = -6, 00053 COMPERR_MEMORY_PB = -7, 00054 COMPERR_ALGO_FAILED = -8, 00055 COMPERR_BAD_SHAPE = -9 00056 }; 00057 00058 // ============================================================= 00062 // ============================================================= 00063 00064 struct SMESH_ComputeError 00065 { 00066 int myName; 00067 std::string myComment; 00068 const SMESH_Algo* myAlgo; 00069 00070 std::list<const SMDS_MeshElement*> myBadElements; 00071 00072 static SMESH_ComputeErrorPtr New( int error = COMPERR_OK, 00073 std::string comment = "", 00074 const SMESH_Algo* algo = 0) 00075 { return SMESH_ComputeErrorPtr( new SMESH_ComputeError( error, comment, algo )); } 00076 00077 SMESH_ComputeError(int error = COMPERR_OK, 00078 std::string comment = "", 00079 const SMESH_Algo* algo = 0) 00080 :myName(error),myComment(comment),myAlgo(algo) {} 00081 00082 bool IsOK() { return myName == COMPERR_OK; } 00083 bool IsCommon() { return myName < 0; } 00084 inline std::string CommonName() const; 00085 00086 }; 00087 00088 #define _case2char(err) case err: return #err; 00089 00090 std::string SMESH_ComputeError::CommonName() const 00091 { 00092 switch( myName ) { 00093 _case2char(COMPERR_OK ); 00094 _case2char(COMPERR_BAD_INPUT_MESH); 00095 _case2char(COMPERR_STD_EXCEPTION ); 00096 _case2char(COMPERR_OCC_EXCEPTION ); 00097 _case2char(COMPERR_SLM_EXCEPTION ); 00098 _case2char(COMPERR_EXCEPTION ); 00099 _case2char(COMPERR_MEMORY_PB ); 00100 _case2char(COMPERR_ALGO_FAILED ); 00101 default:; 00102 } 00103 return ""; 00104 } 00105 00106 #endif