Version: 6.3.1

src/SMESH/SMESH_ComputeError.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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 //  SMESH SMESH : implementaion of SMESH idl descriptions
00021 //  File   : SMESH_Hypothesis.hxx
00022 //  Author : Edward AGAPOV (eap)
00023 //  Module : SMESH
00024 //  $Header: 
00025 //
00026 #ifndef SMESH_ComputeError_HeaderFile
00027 #define SMESH_ComputeError_HeaderFile
00028 
00029 #include <string>
00030 #include <list>
00031 #include <boost/shared_ptr.hpp>
00032 
00033 class SMESH_Algo;
00034 class SMDS_MeshElement;
00035 struct SMESH_ComputeError;
00036 
00037 typedef boost::shared_ptr<SMESH_ComputeError> SMESH_ComputeErrorPtr;
00038 
00039 // =============================================================
00040 
00041 enum SMESH_ComputeErrorName
00042 {
00043   // If you modify it, pls update SMESH_ComputeError::CommonName() below.
00044   // Positive values are for algo specific errors
00045   COMPERR_OK             = -1,
00046   COMPERR_BAD_INPUT_MESH = -2,  
00047   COMPERR_STD_EXCEPTION  = -3,  
00048   COMPERR_OCC_EXCEPTION  = -4,  
00049   COMPERR_SLM_EXCEPTION  = -5,  
00050   COMPERR_EXCEPTION      = -6,  
00051   COMPERR_MEMORY_PB      = -7,  
00052   COMPERR_ALGO_FAILED    = -8,  
00053   COMPERR_BAD_SHAPE      = -9   
00054 };
00055 
00056 // =============================================================
00060 // =============================================================
00061 
00062 struct SMESH_ComputeError
00063 {
00064   int               myName; 
00065   std::string       myComment;
00066   const SMESH_Algo* myAlgo;
00067 
00068   std::list<const SMDS_MeshElement*> myBadElements; 
00069 
00070   static SMESH_ComputeErrorPtr New( int               error   = COMPERR_OK,
00071                                     std::string       comment = "",
00072                                     const SMESH_Algo* algo    = 0)
00073   { return SMESH_ComputeErrorPtr( new SMESH_ComputeError( error, comment, algo )); }
00074 
00075   SMESH_ComputeError(int               error   = COMPERR_OK,
00076                      std::string       comment = "",
00077                      const SMESH_Algo* algo    = 0)
00078     :myName(error),myComment(comment),myAlgo(algo) {}
00079 
00080   bool IsOK()     { return myName == COMPERR_OK; }
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   default:;
00101   }
00102   return "";
00103 }
00104 
00105 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS