Usage of CASCatch with old OCCT versions.

This commit is contained in:
jfa 2006-08-29 08:03:27 +00:00
parent 12cf1a48c8
commit b64c8b0f51
4 changed files with 128 additions and 46 deletions

View File

@ -44,8 +44,17 @@
#include <gp_Ax2.hxx> #include <gp_Ax2.hxx>
#include <gp_Vec.hxx> #include <gp_Vec.hxx>
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
#define NO_CAS_CATCH
#endif
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#else
#include "CASCatch.hxx"
#endif
#include <sstream> #include <sstream>
@ -1054,18 +1063,20 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
myLastCreatedElems = new SMESH::long_array(); myLastCreatedElems = new SMESH::long_array();
myLastCreatedNodes = new SMESH::long_array(); myLastCreatedNodes = new SMESH::long_array();
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
SMESHDS_Mesh* aMesh = GetMeshDS(); SMESHDS_Mesh* aMesh = GetMeshDS();
map<int,const SMDS_MeshElement*> elements; map<int,const SMDS_MeshElement*> elements;
ToMap(theIDsOfElements, aMesh, elements); ToMap(theIDsOfElements, aMesh, elements);
const SMESH::PointStruct * P = &theStepVector.PS; const SMESH::PointStruct * P = &theStepVector.PS;
gp_Vec stepVec( P->x, P->y, P->z ); gp_Vec stepVec( P->x, P->y, P->z );
TElemOfElemListMap aHystory; TElemOfElemListMap aHystory;
::SMESH_MeshEditor anEditor( _myMesh ); ::SMESH_MeshEditor anEditor( _myMesh );
anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory); anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory);
@ -1075,10 +1086,13 @@ void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElemen
// Update Python script // Update Python script
TPythonDump() << "stepVector = " << theStepVector; TPythonDump() << "stepVector = " << theStepVector;
TPythonDump() << this << ".ExtrusionSweep( " TPythonDump() << this << ".ExtrusionSweep( "
<< theIDsOfElements << ", stepVector, " << theNbOfSteps << " )"; << theIDsOfElements << ", stepVector, " << theNbOfSteps << " )";
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) { } catch(Standard_Failure) {
#else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() ); INFOS( "SMESH_MeshEditor_i::ExtrusionSweep fails - "<< aFail->GetMessageString() );
} }

View File

@ -31,8 +31,17 @@
#include <math_GaussSingleIntegration.hxx> #include <math_GaussSingleIntegration.hxx>
#include <utilities.h> #include <utilities.h>
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
#define NO_CAS_CATCH
#endif
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#else
#include "CASCatch.hxx"
#endif
Function::Function( const int conv ) Function::Function( const int conv )
: myConv( conv ) : myConv( conv )
@ -46,16 +55,19 @@ Function::~Function()
bool Function::value( const double, double& f ) const bool Function::value( const double, double& f ) const
{ {
bool ok = true; bool ok = true;
if( myConv==0 ) if (myConv == 0) {
{ #ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
f = pow( 10, f ); f = pow( 10, f );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
f = 0.0; f = 0.0;
ok = false; ok = false;
@ -174,15 +186,19 @@ FunctionExpr::FunctionExpr( const char* str, const int conv )
myValues( 1, 1 ) myValues( 1, 1 )
{ {
bool ok = true; bool ok = true;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
myExpr = ExprIntrp_GenExp::Create(); myExpr = ExprIntrp_GenExp::Create();
myExpr->Process( ( Standard_CString )str ); myExpr->Process( ( Standard_CString )str );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
ok = false; ok = false;
} }
@ -212,13 +228,18 @@ bool FunctionExpr::value( const double t, double& f ) const
( ( TColStd_Array1OfReal& )myValues ).ChangeValue( 1 ) = t; ( ( TColStd_Array1OfReal& )myValues ).ChangeValue( 1 ) = t;
bool ok = true; bool ok = true;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
f = myExpr->Expression()->Evaluate( myVars, myValues ); f = myExpr->Expression()->Evaluate( myVars, myValues );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) { } catch(Standard_Failure) {
#else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
f = 0.0; f = 0.0;
ok = false; ok = false;
@ -231,16 +252,20 @@ bool FunctionExpr::value( const double t, double& f ) const
double FunctionExpr::integral( const double a, const double b ) const double FunctionExpr::integral( const double a, const double b ) const
{ {
double res = 0.0; double res = 0.0;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
math_GaussSingleIntegration _int( ( math_Function& )*this, a, b, 20 ); math_GaussSingleIntegration _int( ( math_Function& )*this, a, b, 20 );
if( _int.IsDone() ) if( _int.IsDone() )
res = _int.Value(); res = _int.Value();
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
res = 0.0; res = 0.0;
MESSAGE( "Exception in integral calculating" ); MESSAGE( "Exception in integral calculating" );
} }

View File

@ -41,8 +41,17 @@
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
#define NO_CAS_CATCH
#endif
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#else
#include "CASCatch.hxx"
#endif
using namespace std; using namespace std;
@ -219,14 +228,18 @@ void StdMeshers_NumberOfSegments::SetTableFunction(const std::vector<double>& ta
double val = table[i*2+1]; double val = table[i*2+1];
if( _convMode==0 ) if( _convMode==0 )
{ {
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
val = pow( 10.0, val ); val = pow( 10.0, val );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
throw SALOME_Exception( LOCALIZED( "invalid value")); throw SALOME_Exception( LOCALIZED( "invalid value"));
return; return;
@ -315,15 +328,19 @@ bool process( const TCollection_AsciiString& str, int convMode,
{ {
bool parsed_ok = true; bool parsed_ok = true;
Handle( ExprIntrp_GenExp ) myExpr; Handle( ExprIntrp_GenExp ) myExpr;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
myExpr = ExprIntrp_GenExp::Create(); myExpr = ExprIntrp_GenExp::Create();
myExpr->Process( str.ToCString() ); myExpr->Process( str.ToCString() );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
parsed_ok = false; parsed_ok = false;
} }

View File

@ -23,8 +23,17 @@
#include <Expr_NamedUnknown.hxx> #include <Expr_NamedUnknown.hxx>
#include <Expr_GeneralExpression.hxx> #include <Expr_GeneralExpression.hxx>
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
#define NO_CAS_CATCH
#endif
#include <Standard_Failure.hxx> #include <Standard_Failure.hxx>
#ifdef NO_CAS_CATCH
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
#else
#include "CASCatch.hxx"
#endif
StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::StdMeshers_NumberOfSegments_ptr h ) StdMeshersGUI_DistrPreview::StdMeshersGUI_DistrPreview( QWidget* p, StdMeshers::StdMeshers_NumberOfSegments_ptr h )
: QwtPlot( p ), : QwtPlot( p ),
@ -242,14 +251,18 @@ void StdMeshersGUI_DistrPreview::update()
delete[] y; delete[] y;
x = y = 0; x = y = 0;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
replot(); replot();
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
} }
} }
@ -289,15 +302,19 @@ bool isCorrectArg( const Handle( Expr_GeneralExpression )& expr )
bool StdMeshersGUI_DistrPreview::init( const QString& str ) bool StdMeshersGUI_DistrPreview::init( const QString& str )
{ {
bool parsed_ok = true; bool parsed_ok = true;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
myExpr = ExprIntrp_GenExp::Create(); myExpr = ExprIntrp_GenExp::Create();
myExpr->Process( ( Standard_CString ) str.latin1() ); myExpr->Process( ( Standard_CString ) str.latin1() );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
parsed_ok = false; parsed_ok = false;
} }
@ -333,13 +350,18 @@ double StdMeshersGUI_DistrPreview::calc( bool& ok )
double res = 0.0; double res = 0.0;
ok = true; ok = true;
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
res = myExpr->Expression()->Evaluate( myVars, myValues ); res = myExpr->Expression()->Evaluate( myVars, myValues );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) { } catch(Standard_Failure) {
#else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
ok = false; ok = false;
res = 0.0; res = 0.0;
@ -360,18 +382,22 @@ bool StdMeshersGUI_DistrPreview::convert( double& v ) const
{ {
case EXPONENT: case EXPONENT:
{ {
#ifdef NO_CAS_CATCH
try { try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS; OCC_CATCH_SIGNALS;
#else
CASCatch_TRY {
#endif #endif
// in StdMeshers_NumberOfSegments.cc // in StdMeshers_NumberOfSegments.cc
// const double PRECISION = 1e-7; // const double PRECISION = 1e-7;
// //
if(v < -7) v = -7.0; if(v < -7) v = -7.0;
v = pow( 10.0, v ); v = pow( 10.0, v );
} #ifdef NO_CAS_CATCH
catch(Standard_Failure) } catch(Standard_Failure) {
{ #else
} CASCatch_CATCH(Standard_Failure) {
#endif
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
v = 0.0; v = 0.0;
ok = false; ok = false;