1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // ------------------------------------------------------------------
24 #include "SMESH_TryCatch.hxx"
26 void SMESH::throwSalomeEx(const char* txt)
28 throw SALOME_Exception( txt );
31 void SMESH::doNothing(const char* txt)
33 (void)txt; // unused in release mode
34 MESSAGE( txt << " " << __FILE__ << ": " << __LINE__ );
37 const char* SMESH::returnError(const char* txt)
42 void SMESH::printErrorInDebugMode(const char* txt)
45 std::cerr << txt << " " << __FILE__ << ": " << __LINE__ << std::endl;
47 (void)txt; // unused in release mode
51 // ------------------------------------------------------------------
53 #include "SMESH_ComputeError.hxx"
54 #include "SMDS_SetIterator.hxx"
55 #include <boost/make_shared.hpp>
57 #define _case2char(err) case err: return #err;
59 // Return SMESH_ComputeError::myName as text, to be used to dump errors in terminal
60 std::string SMESH_ComputeError::CommonName() const
63 _case2char(COMPERR_OK );
64 _case2char(COMPERR_BAD_INPUT_MESH );
65 _case2char(COMPERR_STD_EXCEPTION );
66 _case2char(COMPERR_OCC_EXCEPTION );
67 _case2char(COMPERR_SLM_EXCEPTION );
68 _case2char(COMPERR_EXCEPTION );
69 _case2char(COMPERR_MEMORY_PB );
70 _case2char(COMPERR_ALGO_FAILED );
71 _case2char(COMPERR_BAD_SHAPE );
72 _case2char(COMPERR_WARNING );
73 _case2char(COMPERR_CANCELED );
74 _case2char(COMPERR_NO_MESH_ON_SHAPE);
75 _case2char(COMPERR_BAD_PARMETERS );
81 // Return the most severe error
82 SMESH_ComputeErrorPtr SMESH_ComputeError::Worst( SMESH_ComputeErrorPtr er1,
83 SMESH_ComputeErrorPtr er2 )
85 if ( !er1 ) return er2;
86 if ( !er2 ) return er1;
88 if ( er1->IsOK() ) return er2;
89 if ( er2->IsOK() ) return er1;
91 if ( !er1->IsKO() ) return er2;
92 if ( !er2->IsKO() ) return er1;
94 bool hasInfo1 = er1->myComment.size() || er1->HasBadElems();
95 bool hasInfo2 = er2->myComment.size() || er2->HasBadElems();
96 if ( er1->myName == er2->myName ||
97 hasInfo1 != hasInfo2 )
98 return hasInfo1 < hasInfo2 ? er2 : er1;
100 return er1->myName == COMPERR_CANCELED ? er2 : er1;
103 // Return bad elements
104 SMDS_ElemIteratorPtr SMESH_BadInputElements::getElements()
106 typedef SMDS_SetIterator< const SMDS_MeshElement*,
107 std::list< const SMDS_MeshElement* >::const_iterator> TIterator;
108 return boost::make_shared< TIterator >( myBadElements.begin(), myBadElements.end() );
111 // Temporary remove its elements before the mesh compacting
112 void SMESH_BadInputElements::tmpClear()
114 myBadElements.clear();
117 // Re-add elements after the mesh compacting
118 void SMESH_BadInputElements::add( const SMDS_MeshElement* element )
120 myBadElements.push_back( element );