X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH_I%2FSMESH_Gen_i.cxx;fp=src%2FSMESH_I%2FSMESH_Gen_i.cxx;h=944251e83f1d0e31bdf2af7efd0a35fd98dfbce9;hp=2634540158055a32282a0217e706235199bd9e4a;hb=fa95110a3b64cb8323176103200e3dd17f0ed67e;hpb=9ec3f92f476a3bcae72b418f5d9c0c9ece69a9bc diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 263454015..944251e83 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -161,12 +161,6 @@ using SMESH::TVar; #define NUM_TMP_FILES 2 -#ifdef _DEBUG_ -static int MYDEBUG = 0; -#else -static int MYDEBUG = 0; -#endif - // Static variables definition GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen; CORBA::ORB_var SMESH_Gen_i::myOrb; @@ -455,7 +449,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp thePlatformLibName = aPlatformLibName; Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "Create Hypothesis <" << theHypName << "> from " << aPlatformLibName); + MESSAGE( "Create Hypothesis <" << theHypName << "> from " << aPlatformLibName); typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* ); GenericHypothesisCreator_i* aCreator; @@ -465,7 +459,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp if (myHypCreatorMap.find(string(theHypName)) == myHypCreatorMap.end()) { // load plugin library - if(MYDEBUG) MESSAGE("Loading server meshers plugin library ..."); + MESSAGE("Loading server meshers plugin library ..."); #ifdef WIN32 # ifdef UNICODE const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName); @@ -491,7 +485,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp } // get method, returning hypothesis creator - if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ..."); + MESSAGE("Find GetHypothesisCreator() method ..."); GetHypothesisCreator procHandle = (GetHypothesisCreator)GetProc( libHandle, "GetHypothesisCreator" ); if (!procHandle) @@ -502,7 +496,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp } // get hypothesis creator - if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << theHypName); + MESSAGE("Get Hypothesis Creator for " << theHypName); aCreator = procHandle(theHypName); if (!aCreator) { @@ -553,8 +547,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName // activate the CORBA servant of hypothesis hypothesis_i = myHypothesis_i->_this(); int nextId = RegisterObject( hypothesis_i ); - if(MYDEBUG) { MESSAGE( "Add hypo to map with id = "<< nextId ); } - else { (void)nextId; } // avoid "unused variable" warning in release mode + MESSAGE( "Add hypo to map with id = "<< nextId ); } return hypothesis_i._retn(); } @@ -570,21 +563,21 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::createMesh" ); + MESSAGE( "SMESH_Gen_i::createMesh" ); // Get or create the GEOM_Client instance try { // create a new mesh object servant, store it in a map in study context SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this ); // create a new mesh object - if(MYDEBUG) MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); + MESSAGE("myIsEmbeddedMode " << myIsEmbeddedMode); meshServant->SetImpl( myGen.CreateMesh( myIsEmbeddedMode )); // activate the CORBA servant of Mesh SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); int nextId = RegisterObject( mesh ); - if(MYDEBUG) { MESSAGE( "Add mesh to map with id = "<< nextId); } - else { (void)nextId; } // avoid "unused variable" warning in release mode + MESSAGE( "Add mesh to map with id = "<< nextId); + return mesh._retn(); } catch (SALOME_Exception& S_ex) { @@ -641,14 +634,19 @@ void SMESH_Gen_i::SetEmbeddedMode( CORBA::Boolean theMode ) if (!envNoCatchSignals || !atoi(envNoCatchSignals)) { bool raiseFPE; -#ifdef _DEBUG_ - raiseFPE = true; - char* envDisableFPE = getenv("DISABLE_FPE"); - if (envDisableFPE && atoi(envDisableFPE)) + + if (SALOME::VerbosityActivated()) + { + raiseFPE = true; + char* envDisableFPE = getenv("DISABLE_FPE"); + if (envDisableFPE && atoi(envDisableFPE)) + raiseFPE = false; + } + else + { raiseFPE = false; -#else - raiseFPE = false; -#endif + } + OSD::SetSignal( raiseFPE ); } // else OSD::SetSignal() is called in GUI @@ -1200,7 +1198,7 @@ char* SMESH_Gen_i::GetOption(const char* name) SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObject ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" ); + MESSAGE( "SMESH_Gen_i::CreateMesh" ); // create mesh SMESH::SMESH_Mesh_var mesh = this->createMesh(); // set shape @@ -1234,7 +1232,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObj SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateEmptyMesh() { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" ); + MESSAGE( "SMESH_Gen_i::CreateMesh" ); // create mesh SMESH::SMESH_Mesh_var mesh = this->createMesh(); @@ -1586,7 +1584,7 @@ CORBA::Boolean SMESH_Gen_i::IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IsReadyToCompute" ); + MESSAGE( "SMESH_Gen_i::IsReadyToCompute" ); if ( CORBA::is_nil( theShapeObject ) ) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", @@ -1660,7 +1658,7 @@ SMESH::compute_error_array* SMESH_Gen_i::GetComputeErrors( SMESH::SMESH_Mesh_ptr GEOM::GEOM_Object_ptr theSubObject ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetComputeErrors()" ); + MESSAGE( "SMESH_Gen_i::GetComputeErrors()" ); if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); @@ -1734,7 +1732,7 @@ SMESH_Gen_i::GetBadInputElements( SMESH::SMESH_Mesh_ptr theMesh, CORBA::Short theSubShapeID ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetBadInputElements()" ); + MESSAGE( "SMESH_Gen_i::GetBadInputElements()" ); if ( CORBA::is_nil( theMesh ) ) THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference",SALOME::BAD_PARAM ); @@ -1855,7 +1853,7 @@ SMESH::algo_error_array* SMESH_Gen_i::GetAlgoState( SMESH::SMESH_Mesh_ptr theMes GEOM::GEOM_Object_ptr theSubObject ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetAlgoState()" ); + MESSAGE( "SMESH_Gen_i::GetAlgoState()" ); if ( CORBA::is_nil( theSubObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); @@ -1916,7 +1914,7 @@ SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Object_ptr theMainShapeObject, const SMESH::object_array& theListOfSubShapeObject ) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetSubShapesId" ); + MESSAGE( "SMESH_Gen_i::GetSubShapesId" ); SMESH::long_array_var shapesId = new SMESH::long_array; set setId; @@ -1943,19 +1941,19 @@ SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Object_ptr theMainShapeObject, { const TopoDS_Face& F = TopoDS::Face(exp.Current()); setId.insert(myIndexToShape.FindIndex(F)); - if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(F)); + SCRUTE(myIndexToShape.FindIndex(F)); } for (TopExp_Explorer exp(locShape,TopAbs_EDGE); exp.More(); exp.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); setId.insert(myIndexToShape.FindIndex(E)); - if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(E)); + SCRUTE(myIndexToShape.FindIndex(E)); } for (TopExp_Explorer exp(locShape,TopAbs_VERTEX); exp.More(); exp.Next()) { const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current()); setId.insert(myIndexToShape.FindIndex(V)); - if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(V)); + SCRUTE(myIndexToShape.FindIndex(V)); } } shapesId->length(setId.size()); @@ -1963,9 +1961,9 @@ SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Object_ptr theMainShapeObject, int i=0; for (iind = setId.begin(); iind != setId.end(); iind++) { - if(MYDEBUG) SCRUTE((*iind)); + SCRUTE((*iind)); shapesId[i] = (*iind); - if(MYDEBUG) SCRUTE(shapesId[i]); + SCRUTE(shapesId[i]); i++; } } @@ -1990,7 +1988,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, { //MEMOSTAT; Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" ); + MESSAGE( "SMESH_Gen_i::Compute" ); if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", @@ -2085,7 +2083,7 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh SMESH::long_array& theShapesId) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Precompute" ); + MESSAGE( "SMESH_Gen_i::Precompute" ); if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", @@ -2271,7 +2269,7 @@ SMESH::smIdType_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh, GEOM::GEOM_Object_ptr theShapeObject) { Unexpect aCatch(SALOME_SalomeException); - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Evaluate" ); + MESSAGE( "SMESH_Gen_i::Evaluate" ); if ( CORBA::is_nil( theShapeObject ) && theMesh->HasShapeToMesh()) THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); @@ -2872,16 +2870,16 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh if (PyErr_Occurred()) { // Restrieving python error - MESSAGE("Catching error") + MESSAGE("Catching error"); PyObject *errtype, *errvalue, *traceback; PyErr_Fetch(&errtype, &errvalue, &traceback); if(errvalue != NULL) { - MESSAGE("Error has a value") + MESSAGE("Error has a value"); PyObject *s = PyObject_Str(errvalue); Py_ssize_t size; std::string msg = PyUnicode_AsUTF8AndSize(s, &size); msg = "Issue with the execution of create_dual_mesh:\n"+msg; - MESSAGE("throwing exception") + MESSAGE("throwing exception"); // We need to deactivate the GIL before throwing the exception PyGILState_Release(gstate); THROW_SALOME_CORBA_EXCEPTION(msg.c_str(), SALOME::INTERNAL_ERROR ); @@ -5221,7 +5219,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ) { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SaveASCII" ); + MESSAGE( "SMESH_Gen_i::SaveASCII" ); SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile ); return aStreamFile._retn(); @@ -5361,7 +5359,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* libname_str = new char[ size ]; aDataset->ReadFromDisk( libname_str ); - if(MYDEBUG) SCRUTE( libname_str ); + SCRUTE( libname_str ); libname = string( libname_str ); delete [] libname_str; aDataset->CloseOnDisk(); @@ -5383,7 +5381,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // --> restore hypothesis from data if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty - if(MYDEBUG) MESSAGE("VSR - load hypothesis : id = " << id << + MESSAGE("VSR - load hypothesis : id = " << id << ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str()); SMESH::SMESH_Hypothesis_var myHyp; @@ -5403,7 +5401,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myStudyContext->mapOldToNew( id, newId ); } else - if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); + MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); } } } @@ -5460,7 +5458,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* libname_str = new char[ size ]; aDataset->ReadFromDisk( libname_str ); - if(MYDEBUG) SCRUTE( libname_str ); + SCRUTE( libname_str ); libname = string( libname_str ); delete [] libname_str; aDataset->CloseOnDisk(); @@ -5472,7 +5470,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* hypdata_str = new char[ size ]; aDataset->ReadFromDisk( hypdata_str ); - if(MYDEBUG) SCRUTE( hypdata_str ); + SCRUTE( hypdata_str ); hypdata = string( hypdata_str ); delete [] hypdata_str; aDataset->CloseOnDisk(); @@ -5483,7 +5481,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // --> restore algorithm from data if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty - if(MYDEBUG) MESSAGE("VSR - load algo : id = " << id << + MESSAGE("VSR - load algo : id = " << id << ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str()); SMESH::SMESH_Hypothesis_var myHyp; @@ -5507,7 +5505,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myStudyContext->mapOldToNew( id, newId ); } else - if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); + MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); } } } @@ -5536,7 +5534,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, int aNbObjects = aTopGroup->nInternalObjects(); if ( aNbObjects > 0 ) { // create mesh - if(MYDEBUG) MESSAGE( "VSR - load mesh : id = " << id ); + MESSAGE( "VSR - load mesh : id = " << id ); SMESH::SMESH_Mesh_var myNewMesh = this->createMesh(); SMESH_Mesh_i* myNewMeshImpl = dynamic_cast( GetServant( myNewMesh ).in() ); if ( !myNewMeshImpl ) @@ -5672,7 +5670,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, aGroup->OpenOnDisk(); // get number of applied algorithms int aNbSubObjects = aGroup->nInternalObjects(); - if(MYDEBUG) MESSAGE( "VSR - number of applied algos " << aNbSubObjects ); + MESSAGE( "VSR - number of applied algos " << aNbSubObjects ); for ( int j = 0; j < aNbSubObjects; j++ ) { char name_dataset[ HDF_NAME_MAX_LEN+1 ]; aGroup->InternalObjectIndentify( j, name_dataset ); @@ -6175,7 +6173,7 @@ bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile ) { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LoadASCII" ); + MESSAGE( "SMESH_Gen_i::LoadASCII" ); return Load( theComponent, theStream, theURL, isMultiFile ); //before call main ::Load method it's need for decipher text format to @@ -6212,7 +6210,7 @@ bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent, void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent ) { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" ); + MESSAGE( "SMESH_Gen_i::Close" ); // Clear study contexts data myStudyContext->Clear(); @@ -6236,7 +6234,7 @@ void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent ) char* SMESH_Gen_i::ComponentDataType() { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::ComponentDataType" ); + MESSAGE( "SMESH_Gen_i::ComponentDataType" ); return CORBA::string_dup( "SMESH" ); } @@ -6254,12 +6252,12 @@ char* SMESH_Gen_i::IORToLocalPersistentID( SALOMEDS::SObject_ptr /*theSObject*/, CORBA::Boolean /*isMultiFile*/, CORBA::Boolean /*isASCII*/ ) { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" ); + MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" ); if ( myStudyContext && strcmp( IORString, "" ) != 0 ) { int anId = myStudyContext->findId( IORString ); if ( anId ) { - if(MYDEBUG) MESSAGE( "VSR " << anId ) + MESSAGE( "VSR " << anId ); char strId[ 20 ]; sprintf( strId, "%d", anId ); return CORBA::string_dup( strId ); @@ -6281,7 +6279,7 @@ char* SMESH_Gen_i::LocalPersistentIDToIOR( SALOMEDS::SObject_ptr /*theSObject*/, CORBA::Boolean /*isMultiFile*/, CORBA::Boolean /*isASCII*/ ) { - if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID ); + MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID ); if ( myStudyContext && strcmp( aLocalPersistentID, "" ) != 0 ) { int anId = atoi( aLocalPersistentID ); @@ -6645,8 +6643,8 @@ CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char* theAlgoType, SMESH_CATCH( SMESH::doNothing ); -#ifdef _DEBUG_ - cout << "SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : "") << endl; -#endif + if (SALOME::VerbosityActivated()) + cout << "SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : "") << endl; + return true; }