Add missing try/catch using SMESH_TryCatch.hxx

This commit is contained in:
eap 2012-12-17 15:39:30 +00:00
parent c3597c66f0
commit bd7cecec9a
2 changed files with 467 additions and 385 deletions

View File

@ -81,6 +81,8 @@
#include <sstream> #include <sstream>
#include <limits> #include <limits>
#include "SMESH_TryCatch.hxx" // include after OCCT headers!
#define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem ) #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
using namespace std; using namespace std;
@ -856,6 +858,8 @@ CORBA::Long SMESH_MeshEditor_i::AddBall(CORBA::Long IDOfNode, CORBA::Double diam
if ( diameter < std::numeric_limits<double>::min() ) if ( diameter < std::numeric_limits<double>::min() )
THROW_SALOME_CORBA_EXCEPTION("Invalid diameter", SALOME::BAD_PARAM); THROW_SALOME_CORBA_EXCEPTION("Invalid diameter", SALOME::BAD_PARAM);
SMESH_TRY;
const SMDS_MeshNode* aNode = getMeshDS()->FindNode(IDOfNode); const SMDS_MeshNode* aNode = getMeshDS()->FindNode(IDOfNode);
SMDS_MeshElement* elem = getMeshDS()->AddBall(aNode, diameter); SMDS_MeshElement* elem = getMeshDS()->AddBall(aNode, diameter);
@ -869,6 +873,8 @@ CORBA::Long SMESH_MeshEditor_i::AddBall(CORBA::Long IDOfNode, CORBA::Double diam
if (elem) if (elem)
return elem->GetID(); return elem->GetID();
SMESH_CATCH( SMESH::throwCorbaException );
return 0; return 0;
} }
@ -1137,6 +1143,8 @@ SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObje
SMESH::SMESH_IDSource_var result; SMESH::SMESH_IDSource_var result;
TPythonDump pyDump; TPythonDump pyDump;
SMESH_TRY;
TIDSortedElemSet elements, elems0D; TIDSortedElemSet elements, elems0D;
if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1)) if ( idSourceToSet( theObject, getMeshDS(), elements, SMDSAbs_All, /*emptyIfIsMesh=*/1))
getEditor().Create0DElementsOnAllNodes( elements, elems0D ); getEditor().Create0DElementsOnAllNodes( elements, elems0D );
@ -1183,6 +1191,8 @@ SMESH_MeshEditor_i::Create0DElementsOnAllNodes(SMESH::SMESH_IDSource_ptr theObje
pyDump << " = " << this << ".Create0DElementsOnAllNodes( " pyDump << " = " << this << ".Create0DElementsOnAllNodes( "
<< theObject << ", '" << theGroupName << "' )"; << theObject << ", '" << theGroupName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return result._retn(); return result._retn();
} }
@ -6192,8 +6202,10 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li
CORBA::Boolean createJointElems ) CORBA::Boolean createJointElems )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
initData(); bool aResult = false;
SMESH_TRY;
initData();
SMESHDS_Mesh* aMeshDS = getMeshDS(); SMESHDS_Mesh* aMeshDS = getMeshDS();
@ -6215,7 +6227,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li
} }
} }
bool aResult = getEditor().DoubleNodesOnGroupBoundaries( domains, createJointElems ); aResult = getEditor().DoubleNodesOnGroupBoundaries( domains, createJointElems );
// TODO publish the groups of flat elements in study // TODO publish the groups of flat elements in study
myMesh->GetMeshDS()->Modified(); myMesh->GetMeshDS()->Modified();
@ -6223,6 +6235,9 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li
// Update Python script // Update Python script
TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains
<< ", " << createJointElems << " )"; << ", " << createJointElems << " )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResult; return aResult;
} }
@ -6284,6 +6299,8 @@ void SMESH_MeshEditor_i::CreateHoleSkin(CORBA::Double radius,
SMESH::array_of_long_array_out GroupsOfNodes) SMESH::array_of_long_array_out GroupsOfNodes)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH_TRY;
initData(); initData();
std::vector<std::vector<int> > aListOfListOfNodes; std::vector<std::vector<int> > aListOfListOfNodes;
::SMESH_MeshEditor aMeshEditor( myMesh ); ::SMESH_MeshEditor aMeshEditor( myMesh );
@ -6299,7 +6316,8 @@ throw (SALOME::SALOME_Exception)
} }
TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape ); TopoDS_Shape aShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theShape );
aMeshEditor.CreateHoleSkin(radius, aShape, theNodeSearcher, groupName, nodesCoords, aListOfListOfNodes); aMeshEditor.CreateHoleSkin(radius, aShape, theNodeSearcher, groupName,
nodesCoords, aListOfListOfNodes);
GroupsOfNodes = new SMESH::array_of_long_array; GroupsOfNodes = new SMESH::array_of_long_array;
GroupsOfNodes->length( aListOfListOfNodes.size() ); GroupsOfNodes->length( aListOfListOfNodes.size() );
@ -6314,7 +6332,12 @@ throw (SALOME::SALOME_Exception)
aGroup[ j ] = (*lIt); aGroup[ j ] = (*lIt);
} }
TPythonDump() << "lists_nodes = " << this << ".CreateHoleSkin( " TPythonDump() << "lists_nodes = " << this << ".CreateHoleSkin( "
<< radius << ", " << theShape << ", " << ", " << groupName << ", " << theNodesCoords << " )"; << radius << ", "
<< theShape
<< ", '" << groupName << "', "
<< theNodesCoords << " )";
SMESH_CATCH( SMESH::throwCorbaException );
} }

View File

@ -55,7 +55,6 @@
#include <SALOMEDS_Attributes_wrap.hxx> #include <SALOMEDS_Attributes_wrap.hxx>
#include <SALOMEDS_wrap.hxx> #include <SALOMEDS_wrap.hxx>
#include <SALOME_NamingService.hxx> #include <SALOME_NamingService.hxx>
#include <Utils_CorbaException.hxx>
#include <Utils_ExceptHandlers.hxx> #include <Utils_ExceptHandlers.hxx>
#include <Utils_SINGLETON.hxx> #include <Utils_SINGLETON.hxx>
#include <utilities.h> #include <utilities.h>
@ -80,11 +79,14 @@
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
#include "SMESH_TryCatch.hxx" // include after OCCT headers!
// STL Includes // STL Includes
#include <algorithm> #include <algorithm>
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <sys/stat.h> #include <sys/stat.h>
#ifdef _DEBUG_ #ifdef _DEBUG_
@ -98,7 +100,6 @@ using SMESH::TPythonDump;
int SMESH_Mesh_i::_idGenerator = 0; int SMESH_Mesh_i::_idGenerator = 0;
//============================================================================= //=============================================================================
/*! /*!
* Constructor * Constructor
@ -449,11 +450,15 @@ char* SMESH_Mesh_i::GetVersionString(SMESH::MED_VERSION version, CORBA::Short nb
int SMESH_Mesh_i::ImportUNVFile( const char* theFileName ) int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
SMESH_TRY;
// Read mesh with name = <theMeshName> into SMESH_Mesh // Read mesh with name = <theMeshName> into SMESH_Mesh
_impl->UNVToMesh( theFileName ); _impl->UNVToMesh( theFileName );
CreateGroupServants(); CreateGroupServants();
SMESH_CATCH( SMESH::throwCorbaException );
return 1; return 1;
} }
@ -467,12 +472,30 @@ int SMESH_Mesh_i::ImportUNVFile( const char* theFileName )
int SMESH_Mesh_i::ImportSTLFile( const char* theFileName ) int SMESH_Mesh_i::ImportSTLFile( const char* theFileName )
throw ( SALOME::SALOME_Exception ) throw ( SALOME::SALOME_Exception )
{ {
SMESH_TRY;
// Read mesh with name = <theMeshName> into SMESH_Mesh // Read mesh with name = <theMeshName> into SMESH_Mesh
_impl->STLToMesh( theFileName ); _impl->STLToMesh( theFileName );
SMESH_CATCH( SMESH::throwCorbaException );
return 1; return 1;
} }
//================================================================================
/*!
* \brief Function used in SMESH_CATCH by ImportGMFFile()
*/
//================================================================================
namespace
{
SMESH_ComputeErrorPtr exceptionToComputeError(const char* excText)
{
return SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, excText );
}
}
//================================================================================ //================================================================================
/*! /*!
* \brief Imports data from a GMF file and returns an error description * \brief Imports data from a GMF file and returns an error description
@ -484,29 +507,16 @@ SMESH::ComputeError* SMESH_Mesh_i::ImportGMFFile( const char* theFileName,
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH_ComputeErrorPtr error; SMESH_ComputeErrorPtr error;
try {
#undef SMESH_CAUGHT
#define SMESH_CAUGHT error =
SMESH_TRY;
error = _impl->GMFToMesh( theFileName, theMakeRequiredGroups ); error = _impl->GMFToMesh( theFileName, theMakeRequiredGroups );
}
catch ( std::bad_alloc& exc ) { SMESH_CATCH( exceptionToComputeError );
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "std::bad_alloc raised" ); #undef SMESH_CAUGHT
} #define SMESH_CAUGHT
catch ( Standard_OutOfMemory& exc ) {
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Standard_OutOfMemory raised" );
}
catch (Standard_Failure& ex) {
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, ex.DynamicType()->Name() );
if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
error->myComment += string(": ") + ex.GetMessageString();
}
catch ( SALOME_Exception& S_ex ) {
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, S_ex.what() );
}
catch ( std::exception& exc ) {
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, exc.what() );
}
catch (...) {
error = SMESH_ComputeError::New( Driver_Mesh::DRS_FAIL, "Unknown exception" );
}
CreateGroupServants(); CreateGroupServants();
@ -846,7 +856,8 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShap
void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
if(MYDEBUG) MESSAGE("SMESH_Mesh_i::RemoveSubMesh"); SMESH_TRY;
if ( theSubMesh->_is_nil() ) if ( theSubMesh->_is_nil() )
return; return;
@ -878,6 +889,8 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh )
if ( removeSubMesh( theSubMesh, aSubShapeObject.in() )) if ( removeSubMesh( theSubMesh, aSubShapeObject.in() ))
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->ForgetOrLoad(); _preMeshInfo->ForgetOrLoad();
SMESH_CATCH( SMESH::throwCorbaException );
} }
//============================================================================= //=============================================================================
@ -1010,6 +1023,8 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
if ( theGroup->_is_nil() ) if ( theGroup->_is_nil() )
return; return;
SMESH_TRY;
SMESH_GroupBase_i* aGroup = SMESH_GroupBase_i* aGroup =
dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() ); dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
if ( !aGroup ) if ( !aGroup )
@ -1031,6 +1046,8 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
// Remove the group from SMESH data structures // Remove the group from SMESH data structures
removeGroup( aGroup->GetLocalID() ); removeGroup( aGroup->GetLocalID() );
SMESH_CATCH( SMESH::throwCorbaException );
} }
//============================================================================= //=============================================================================
@ -1042,6 +1059,7 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup )
void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup ) void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -1069,6 +1087,8 @@ void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup
// Remove group // Remove group
RemoveGroup( theGroup ); RemoveGroup( theGroup );
SMESH_CATCH( SMESH::throwCorbaException );
} }
//================================================================================ //================================================================================
@ -1137,11 +1157,12 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
try
{
if ( theGroup1->_is_nil() || theGroup2->_is_nil() || if ( theGroup1->_is_nil() || theGroup2->_is_nil() ||
theGroup1->GetType() != theGroup2->GetType() ) theGroup1->GetType() != theGroup2->GetType() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1149,7 +1170,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
TPythonDump pyDump; TPythonDump pyDump;
// Create Union // Create Union
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); aResGrp = CreateGroup( theGroup1->GetType(), theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1179,13 +1200,10 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr the
<< theGroup1 << ", " << theGroup2 << ", '" << theGroup1 << ", " << theGroup2 << ", '"
<< theName << "' )"; << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
catch( ... )
{
return SMESH::SMESH_Group::_nil();
}
}
//============================================================================= //=============================================================================
/*! /*!
@ -1206,8 +1224,10 @@ throw (SALOME::SALOME_Exception)
if ( !theName ) if ( !theName )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
try SMESH::SMESH_Group_var aResGrp;
{
SMESH_TRY;
vector< int > anIds; vector< int > anIds;
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
for ( int g = 0, n = theGroups.length(); g < n; g++ ) for ( int g = 0, n = theGroups.length(); g < n; g++ )
@ -1238,7 +1258,7 @@ throw (SALOME::SALOME_Exception)
TPythonDump pyDump; TPythonDump pyDump;
// Create group // Create group
SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName ); aResGrp = CreateGroup( aType, theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1254,13 +1274,10 @@ throw (SALOME::SALOME_Exception)
pyDump << aResGrp << " = " << _this() << ".UnionListOfGroups( " pyDump << aResGrp << " = " << _this() << ".UnionListOfGroups( "
<< &theGroups << ", '" << theName << "' )"; << &theGroups << ", '" << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
catch( ... )
{
return SMESH::SMESH_Group::_nil();
}
}
//============================================================================= //=============================================================================
/*! IntersectGroups /*! IntersectGroups
@ -1273,6 +1290,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -1283,7 +1303,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
TPythonDump pyDump; TPythonDump pyDump;
// Create Intersection // Create Intersection
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); aResGrp = CreateGroup( theGroup1->GetType(), theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return aResGrp; return aResGrp;
@ -1310,6 +1330,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr
pyDump << aResGrp << " = " << _this() << ".IntersectGroups( " pyDump << aResGrp << " = " << _this() << ".IntersectGroups( "
<< theGroup1 << ", " << theGroup2 << ", '" << theName << "')"; << theGroup1 << ", " << theGroup2 << ", '" << theName << "')";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
@ -1327,14 +1349,15 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups,
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
if ( !theName ) if ( !theName )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
try
{
NCollection_DataMap< int, int > anIdToCount; NCollection_DataMap< int, int > anIdToCount;
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
for ( int g = 0, n = theGroups.length(); g < n; g++ ) for ( int g = 0, n = theGroups.length(); g < n; g++ )
@ -1380,7 +1403,7 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups,
TPythonDump pyDump; TPythonDump pyDump;
// Create group // Create group
SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName ); aResGrp = CreateGroup( aType, theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1396,13 +1419,10 @@ SMESH_Mesh_i::IntersectListOfGroups(const SMESH::ListOfGroups& theGroups,
pyDump << aResGrp << " = " << _this() << ".IntersectListOfGroups( " pyDump << aResGrp << " = " << _this() << ".IntersectListOfGroups( "
<< &theGroups << ", '" << theName << "' )"; << &theGroups << ", '" << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
catch( ... )
{
return SMESH::SMESH_Group::_nil();
}
}
//============================================================================= //=============================================================================
/*! CutGroups /*! CutGroups
@ -1415,6 +1435,9 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -1425,7 +1448,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
TPythonDump pyDump; TPythonDump pyDump;
// Perform Cutting // Perform Cutting
SMESH::SMESH_Group_var aResGrp = CreateGroup( theGroup1->GetType(), theName ); aResGrp = CreateGroup( theGroup1->GetType(), theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return aResGrp; return aResGrp;
@ -1454,6 +1477,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGr
<< theGroup1 << ", " << theGroup2 << ", '" << theGroup1 << ", " << theGroup2 << ", '"
<< theName << "' )"; << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
@ -1473,14 +1498,15 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
if ( !theName ) if ( !theName )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
try
{
set< int > aToolIds; set< int > aToolIds;
SMESH::ElementType aType = SMESH::ALL; SMESH::ElementType aType = SMESH::ALL;
int g, n; int g, n;
@ -1542,7 +1568,7 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
TPythonDump pyDump; TPythonDump pyDump;
// Create group // Create group
SMESH::SMESH_Group_var aResGrp = CreateGroup( aType, theName ); aResGrp = CreateGroup( aType, theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1559,13 +1585,10 @@ SMESH_Mesh_i::CutListOfGroups(const SMESH::ListOfGroups& theMainGroups,
<< &theMainGroups << ", " << &theToolGroups << ", '" << &theMainGroups << ", " << &theToolGroups << ", '"
<< theName << "' )"; << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
catch( ... )
{
return SMESH::SMESH_Group::_nil();
}
}
//============================================================================= //=============================================================================
/*! /*!
@ -1588,6 +1611,9 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
const char* theName ) const char* theName )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aResGrp;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -1602,7 +1628,7 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
TPythonDump pyDump; TPythonDump pyDump;
SMESH::SMESH_Group_var aResGrp = CreateGroup( theElemType, theName ); aResGrp = CreateGroup( theElemType, theName );
if ( aResGrp->_is_nil() ) if ( aResGrp->_is_nil() )
return SMESH::SMESH_Group::_nil(); return SMESH::SMESH_Group::_nil();
@ -1610,8 +1636,6 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
SMESH::DownCast<SMESH_GroupBase_i*>( aResGrp )->GetGroupDS(); SMESH::DownCast<SMESH_GroupBase_i*>( aResGrp )->GetGroupDS();
SMDS_MeshGroup& resGroupCore = static_cast< SMESHDS_Group* >( groupBaseDS )->SMDSGroup(); SMDS_MeshGroup& resGroupCore = static_cast< SMESHDS_Group* >( groupBaseDS )->SMDSGroup();
try
{
for ( int g = 0, n = theGroups.length(); g < n; g++ ) // loop on theGroups for ( int g = 0, n = theGroups.length(); g < n; g++ ) // loop on theGroups
{ {
SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ]; SMESH::SMESH_GroupBase_var aGrp = theGroups[ g ];
@ -1664,13 +1688,10 @@ SMESH_Mesh_i::CreateDimGroup(const SMESH::ListOfGroups& theGroups,
pyDump << aResGrp << " = " << _this() << ".CreateDimGroup( " pyDump << aResGrp << " = " << _this() << ".CreateDimGroup( "
<< &theGroups << ", " << theElemType << ", '" << theName << "' )"; << &theGroups << ", " << theElemType << ", '" << theName << "' )";
SMESH_CATCH( SMESH::throwCorbaException );
return aResGrp._retn(); return aResGrp._retn();
} }
catch( ... )
{
return SMESH::SMESH_Group::_nil();
}
}
//================================================================================ //================================================================================
/*! /*!
@ -2034,16 +2055,18 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
//============================================================================= //=============================================================================
SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroup ) SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase_ptr theGroup )
throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_Group_var aGroup;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
SMESH::SMESH_Group_var aGroup;
if ( theGroup->_is_nil() ) if ( theGroup->_is_nil() )
return aGroup._retn(); return aGroup._retn();
Unexpect aCatch(SALOME_SalomeException);
SMESH_GroupBase_i* aGroupToRem = SMESH_GroupBase_i* aGroupToRem =
dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() ); dynamic_cast<SMESH_GroupBase_i*>( SMESH_Gen_i::GetServant( theGroup ).in() );
if ( !aGroupToRem ) if ( !aGroupToRem )
@ -2105,6 +2128,8 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::ConvertToStandalone( SMESH::SMESH_GroupBase
CORBA::String_var ior = _gen_i->GetORB()->object_to_string( aGroup ); CORBA::String_var ior = _gen_i->GetORB()->object_to_string( aGroup );
builder->SetIOR( aGroupSO, ior.in() ); builder->SetIOR( aGroupSO, ior.in() );
SMESH_CATCH( SMESH::throwCorbaException );
return aGroup._retn(); return aGroup._retn();
} }
@ -2289,11 +2314,12 @@ void SMESH_Mesh_i::removeGroup( const int theId )
SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet) SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet)
throw(SALOME::SALOME_Exception) throw(SALOME::SALOME_Exception)
{ {
SMESH::log_array_var aLog;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
SMESH::log_array_var aLog;
try{
list < SMESHDS_Command * >logDS = _impl->GetLog(); list < SMESHDS_Command * >logDS = _impl->GetLog();
aLog = new SMESH::log_array; aLog = new SMESH::log_array;
int indexLog = 0; int indexLog = 0;
@ -2334,10 +2360,9 @@ throw(SALOME::SALOME_Exception)
} }
if(clearAfterGet) if(clearAfterGet)
_impl->ClearLog(); _impl->ClearLog();
}
catch(SALOME_Exception & S_ex){ SMESH_CATCH( SMESH::throwCorbaException );
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
}
return aLog._retn(); return aLog._retn();
} }
@ -2350,8 +2375,9 @@ throw(SALOME::SALOME_Exception)
void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception) void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
{ {
if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog"); SMESH_TRY;
_impl->ClearLog(); _impl->ClearLog();
SMESH_CATCH( SMESH::throwCorbaException );
} }
//============================================================================= //=============================================================================
@ -2362,7 +2388,6 @@ void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception)
CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception)
{ {
if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId");
return _id; return _id;
} }
@ -2438,18 +2463,24 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl)
//============================================================================= //=============================================================================
SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_MeshEditor_var aMeshEdVar;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
// Create MeshEditor // Create MeshEditor
SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( this, false ); SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( this, false );
SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); aMeshEdVar = aMeshEditor->_this();
// Update Python script // Update Python script
TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()"; TPythonDump() << aMeshEditor << " = " << _this() << ".GetMeshEditor()";
return aMesh._retn(); SMESH_CATCH( SMESH::throwCorbaException );
return aMeshEdVar._retn();
} }
//============================================================================= //=============================================================================
@ -2459,13 +2490,20 @@ SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor()
//============================================================================= //=============================================================================
SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditPreviewer() SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditPreviewer()
throw (SALOME::SALOME_Exception)
{ {
SMESH::SMESH_MeshEditor_var aMeshEdVar;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( this, true ); SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( this, true );
SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); aMeshEdVar = aMeshEditor->_this();
return aMesh._retn();
SMESH_CATCH( SMESH::throwCorbaException );
return aMeshEdVar._retn();
} }
//================================================================================ //================================================================================
@ -3374,10 +3412,17 @@ SMESH::long_array* SMESH_Mesh_i::GetNodesId()
SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const bool iselem ) SMESH::ElementType SMESH_Mesh_i::GetElementType( const CORBA::Long id, const bool iselem )
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::ElementType type;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
return ( SMESH::ElementType )_impl->GetElementType( id, iselem ); type = ( SMESH::ElementType ) _impl->GetElementType( id, iselem );
SMESH_CATCH( SMESH::throwCorbaException );
return type;
} }
//============================================================================= //=============================================================================
@ -3407,11 +3452,12 @@ SMESH::EntityType SMESH_Mesh_i::GetElementGeomType( const CORBA::Long id )
SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID) SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::long_array_var aResult = new SMESH::long_array();
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID); SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
if(!SM) return aResult._retn(); if(!SM) return aResult._retn();
@ -3426,6 +3472,8 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshElementsId(const CORBA::Long ShapeID)
aResult[i++] = eIt->next()->GetID(); aResult[i++] = eIt->next()->GetID();
} }
SMESH_CATCH( SMESH::throwCorbaException );
return aResult._retn(); return aResult._retn();
} }
@ -3441,11 +3489,12 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID,
CORBA::Boolean all) CORBA::Boolean all)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::long_array_var aResult = new SMESH::long_array();
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
SMESH::long_array_var aResult = new SMESH::long_array();
SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID); SMESH_subMesh* SM = _impl->GetSubMeshContaining(ShapeID);
if(!SM) return aResult._retn(); if(!SM) return aResult._retn();
@ -3478,6 +3527,8 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID,
for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ )
aResult[i++] = *itElem; aResult[i++] = *itElem;
SMESH_CATCH( SMESH::throwCorbaException );
return aResult._retn(); return aResult._retn();
} }
@ -3490,6 +3541,9 @@ SMESH::long_array* SMESH_Mesh_i::GetSubMeshNodesId(const CORBA::Long ShapeID,
SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID) SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID)
throw (SALOME::SALOME_Exception) throw (SALOME::SALOME_Exception)
{ {
SMESH::ElementType type;
SMESH_TRY;
if ( _preMeshInfo ) if ( _preMeshInfo )
_preMeshInfo->FullLoadFromFile(); _preMeshInfo->FullLoadFromFile();
@ -3504,7 +3558,12 @@ SMESH::ElementType SMESH_Mesh_i::GetSubMeshElementType(const CORBA::Long ShapeID
SMDS_ElemIteratorPtr eIt = SDSM->GetElements(); SMDS_ElemIteratorPtr eIt = SDSM->GetElements();
const SMDS_MeshElement* anElem = eIt->next(); const SMDS_MeshElement* anElem = eIt->next();
return ( SMESH::ElementType ) anElem->GetType();
type = ( SMESH::ElementType ) anElem->GetType();
SMESH_CATCH( SMESH::throwCorbaException );
return type;
} }