X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHUtils%2FSMESH_TryCatch.cxx;h=b808a791bdcbeda74fe4b1f56a43d109c6ac0c35;hp=486ec24ad7ce2b025e03d33427e88c32863f1d72;hb=499f29d24922cec66e41b41a0039a954993bc6df;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESHUtils/SMESH_TryCatch.cxx b/src/SMESHUtils/SMESH_TryCatch.cxx index 486ec24ad..b808a791b 100644 --- a/src/SMESHUtils/SMESH_TryCatch.cxx +++ b/src/SMESHUtils/SMESH_TryCatch.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,6 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// ------------------------------------------------------------------ #include "SMESH_TryCatch.hxx" void SMESH::throwSalomeEx(const char* txt) @@ -29,6 +30,92 @@ void SMESH::throwSalomeEx(const char* txt) void SMESH::doNothing(const char* txt) { + (void)txt; // unused in release mode MESSAGE( txt << " " << __FILE__ << ": " << __LINE__ ); } +const char* SMESH::returnError(const char* txt) +{ + return txt; +} + +void SMESH::printErrorInDebugMode(const char* txt) +{ +#ifdef _DEBUG_ + std::cerr << txt << " " << __FILE__ << ": " << __LINE__ << std::endl; +#else + (void)txt; // unused in release mode +#endif +} + +// ------------------------------------------------------------------ + +#include "SMESH_ComputeError.hxx" +#include "SMDS_SetIterator.hxx" +#include + +#define _case2char(err) case err: return #err; + +// Return SMESH_ComputeError::myName as text, to be used to dump errors in terminal +std::string SMESH_ComputeError::CommonName() const +{ + switch( myName ) { + _case2char(COMPERR_OK ); + _case2char(COMPERR_BAD_INPUT_MESH ); + _case2char(COMPERR_STD_EXCEPTION ); + _case2char(COMPERR_OCC_EXCEPTION ); + _case2char(COMPERR_SLM_EXCEPTION ); + _case2char(COMPERR_EXCEPTION ); + _case2char(COMPERR_MEMORY_PB ); + _case2char(COMPERR_ALGO_FAILED ); + _case2char(COMPERR_BAD_SHAPE ); + _case2char(COMPERR_WARNING ); + _case2char(COMPERR_CANCELED ); + _case2char(COMPERR_NO_MESH_ON_SHAPE); + _case2char(COMPERR_BAD_PARMETERS ); + default:; + } + return ""; +} + +// Return the most severe error +SMESH_ComputeErrorPtr SMESH_ComputeError::Worst( SMESH_ComputeErrorPtr er1, + SMESH_ComputeErrorPtr er2 ) +{ + if ( !er1 ) return er2; + if ( !er2 ) return er1; + // both not NULL + if ( er1->IsOK() ) return er2; + if ( er2->IsOK() ) return er1; + // both not OK + if ( !er1->IsKO() ) return er2; + if ( !er2->IsKO() ) return er1; + // both KO + bool hasInfo1 = er1->myComment.size() || er1->HasBadElems(); + bool hasInfo2 = er2->myComment.size() || er2->HasBadElems(); + if ( er1->myName == er2->myName || + hasInfo1 != hasInfo2 ) + return hasInfo1 < hasInfo2 ? er2 : er1; + + return er1->myName == COMPERR_CANCELED ? er2 : er1; +} + +// Return bad elements +SMDS_ElemIteratorPtr SMESH_BadInputElements::getElements() +{ + typedef SMDS_SetIterator< const SMDS_MeshElement*, + std::list< const SMDS_MeshElement* >::const_iterator> TIterator; + return boost::make_shared< TIterator >( myBadElements.begin(), myBadElements.end() ); +} + +// Temporary remove its elements before the mesh compacting +void SMESH_BadInputElements::tmpClear() +{ + myBadElements.clear(); +} + +// Re-add elements after the mesh compacting +void SMESH_BadInputElements::add( const SMDS_MeshElement* element ) +{ + myBadElements.push_back( element ); +}