Back to index

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