From: secher Date: Fri, 11 May 2007 09:21:41 +0000 (+0000) Subject: improvement to catch filtoo errors X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ecbd71a0f265e593ba0cf7248865ca38e7ec6549;p=modules%2Ffilter.git improvement to catch filtoo errors --- diff --git a/idl/FILTER_Gen.idl b/idl/FILTER_Gen.idl index c676771..7b43f52 100644 --- a/idl/FILTER_Gen.idl +++ b/idl/FILTER_Gen.idl @@ -62,8 +62,8 @@ module SALOME_FILTER void getMinMax(out double min,out double max,in ref_func rf); LongSeq getHistogram(in long size,in ref_func rf); void generateCriteria(in long nbthresh,in double fthresh,in double sthresh,in boolean areaFlag,in ref_func rf) raises(FilterError); - void createEnsightInputFiles(); - void filtering(); + void createEnsightInputFiles() raises(FilterError); + void filtering() raises(FilterError); void projectFieldsOnDecimateMesh() raises(FilterError); void createMedOutputFile(in string outMedFile); }; diff --git a/src/FILTER/Filter_Gen_i.cxx b/src/FILTER/Filter_Gen_i.cxx index bd77403..4e30125 100755 --- a/src/FILTER/Filter_Gen_i.cxx +++ b/src/FILTER/Filter_Gen_i.cxx @@ -303,107 +303,117 @@ void Filter_Gen_i::generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,C bool isGVal; MED_EN::medEntityMesh typ; - if(_myDField) - typ = _myDField->getSupport()->getEntity(); - else - typ = _myIField->getSupport()->getEntity(); - - // create support on nodes - SUPPORT *sup = new SUPPORT(_mesh,"Support",MED_NODE); - - // create integer field on nodes - _criteria = new FIELD(sup,1); - - _criteria->setName("Criteria"); - - // read number of nodes - int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS); - - for (int i=1; igetValueIJ(i,1); - else - val = (double)_myIField->getValueIJ(i,1); + try{ + if(_myDField) + typ = _myDField->getSupport()->getEntity(); + else + typ = _myIField->getSupport()->getEntity(); + + // create support on nodes + SUPPORT *sup = new SUPPORT(_mesh,"Support",MED_NODE); + + // create integer field on nodes + _criteria = new FIELD(sup,1); + + _criteria->setName("Criteria"); + + // read number of nodes + int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS); + + for (int i=1; igetValueIJ(i,1); + case MED_NODE: + // read reference field value + switch(rf){ + case F_FIELD: + if(_myDField) + val = _myDField->getValueIJ(i,1); + else + val = (double)_myIField->getValueIJ(i,1); + break; + case F_GRAD: + val = _myGradient->getValueIJ(i,1); + break; + } + break; + case MED_ALL_ENTITIES: + throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on all entities"); break; } - break; - case MED_ALL_ENTITIES: - throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on all entities"); - break; - } - // set criteria field value - if( nbthresh == 1 ){ - if( areaFlag ) - if( val >= fthresh ) isGVal = true; - else isGVal = false; - else - if( val <= fthresh ) isGVal = true; - else isGVal = false; - } - else{ - min = fthresh; - max = sthresh; - if(sthresh < fthresh){ - min = sthresh; - max = fthresh; + // set criteria field value + if( nbthresh == 1 ){ + if( areaFlag ) + if( val >= fthresh ) isGVal = true; + else isGVal = false; + else + if( val <= fthresh ) isGVal = true; + else isGVal = false; } - if( areaFlag ) - if( (val <= min) || (val >= max) ) isGVal = true; - else isGVal = false; + else{ + min = fthresh; + max = sthresh; + if(sthresh < fthresh){ + min = sthresh; + max = fthresh; + } + if( areaFlag ) + if( (val <= min) || (val >= max) ) isGVal = true; + else isGVal = false; + else + if( (val >= min) && (val <= max) ) isGVal = true; + else isGVal = false; + } + if( isGVal ) + _criteria->setValueIJ(i,1,1); else - if( (val >= min) && (val <= max) ) isGVal = true; - else isGVal = false; + _criteria->setValueIJ(i,1,0); } - if( isGVal ) - _criteria->setValueIJ(i,1,1); - else - _criteria->setValueIJ(i,1,0); + } + catch(SALOME_Exception& ex){ + throw SALOME_FILTER::FILTER_Gen::FilterError(ex.what()); } } -void Filter_Gen_i::createEnsightInputFiles() +void Filter_Gen_i::createEnsightInputFiles() throw(SALOME_FILTER::FILTER_Gen::FilterError) { - MESSAGE("Calculate boundary"); - // generate MED boundary of geometry - SUPPORT *supB = _mesh->getBoundaryElements(MED_FACE); - - // call ensight driver MED to generate input ensight mesh , - // input ensight boundary mesh and input criteria ensight field for filtoo - MESSAGE("Create ensight mesh"); - ENSIGHT_MESH_WRONLY_DRIVER myMeshDriver("/tmp/input.case",_mesh); - myMeshDriver.addSupport(supB); - myMeshDriver.open(); - myMeshDriver.write(); - myMeshDriver.close(); - - MESSAGE("Create ensight field"); - ENSIGHT_FIELD_WRONLY_DRIVER myFieldDriver("/tmp/input.case",_criteria); - myFieldDriver.open(); - myFieldDriver.write(); - myFieldDriver.close(); + try{ + MESSAGE("Calculate boundary"); + // generate MED boundary of geometry + SUPPORT *supB = _mesh->getBoundaryElements(MED_FACE); + + // call ensight driver MED to generate input ensight mesh , + // input ensight boundary mesh and input criteria ensight field for filtoo + MESSAGE("Create ensight mesh"); + ENSIGHT_MESH_WRONLY_DRIVER myMeshDriver("/tmp/input.case",_mesh); + myMeshDriver.addSupport(supB); + myMeshDriver.open(); + myMeshDriver.write(); + myMeshDriver.close(); + + MESSAGE("Create ensight field"); + ENSIGHT_FIELD_WRONLY_DRIVER myFieldDriver("/tmp/input.case",_criteria); + myFieldDriver.open(); + myFieldDriver.write(); + myFieldDriver.close(); + } + catch(SALOME_Exception& ex){ + throw SALOME_FILTER::FILTER_Gen::FilterError(ex.what()); + } } -void Filter_Gen_i::filtering() +void Filter_Gen_i::filtering() throw(SALOME_FILTER::FILTER_Gen::FilterError) { string command; @@ -411,7 +421,9 @@ void Filter_Gen_i::filtering() // send filtoo command command = "cd /tmp;filtoo -f input -o output > /tmp/filter.log"; MESSAGE(command); - system(command.c_str()); + int status = system(command.c_str()); + if(status != 0) + throw SALOME_FILTER::FILTER_Gen::FilterError("filtoo error"); // destroy filtoo input files command = "cd /tmp;rm -f input.*"; diff --git a/src/FILTER/Filter_Gen_i.hxx b/src/FILTER/Filter_Gen_i.hxx index 87b3694..3005f27 100644 --- a/src/FILTER/Filter_Gen_i.hxx +++ b/src/FILTER/Filter_Gen_i.hxx @@ -67,8 +67,8 @@ public: void getMinMax(CORBA::Double& imin, CORBA::Double& imax,SALOME_FILTER::ref_func rf); SALOME_FILTER::LongSeq* getHistogram(CORBA::Long size,SALOME_FILTER::ref_func rf); void generateCriteria(CORBA::Long nbthresh,CORBA::Double fthresh,CORBA::Double thresh,CORBA::Boolean areaFlag,SALOME_FILTER::ref_func rf) throw(SALOME_FILTER::FILTER_Gen::FilterError); - void createEnsightInputFiles(); - void filtering(); + void createEnsightInputFiles() throw(SALOME_FILTER::FILTER_Gen::FilterError); + void filtering() throw(SALOME_FILTER::FILTER_Gen::FilterError); void projectFieldsOnDecimateMesh() throw(SALOME_FILTER::FILTER_Gen::FilterError); void createMedOutputFile(const char* outMedFile); diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 7163eb7..742cc31 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -320,7 +320,9 @@ void SelectParams::buildFrame() void SelectParams::gradSelected() { try{ + setCursor(QCursor(Qt::WaitCursor)); _filter->buildGradient(); + setCursor(QCursor(Qt::ArrowCursor)); } catch(SALOME_FILTER::FILTER_Gen::FilterError){ _myFieldB->setChecked(true); @@ -616,16 +618,31 @@ void SelectParams::process() throw(SALOME_Exception) QMessageBox::information( this, "Filtering", "Unable to process filtering.\n" - "You must select a reference field on nodes or on cells." ); + "You must select a reference field on nodes." ); reject(); return; } // create ensight input files to filtoo - _filter->createEnsightInputFiles(); + try{ + _filter->createEnsightInputFiles(); + } + catch (SALOME_FILTER::FILTER_Gen::FilterError& ex){ + throw SALOME_Exception(ex.error_msg); + } // call filtoo - _filter->filtering(); + try{ + _filter->filtering(); + } + catch (SALOME_FILTER::FILTER_Gen::FilterError){ + QMessageBox::information( this, + "Filtering", + "Unable to process filtering.\n" + "FILTOO ERROR see /tmp/filter.log file." ); + reject(); + return; + } // project input fields on new mesh try{ @@ -638,6 +655,10 @@ void SelectParams::process() throw(SALOME_Exception) // create new MED file with new mesh and fields _filter->createMedOutputFile(_myOFN->text()); + QMessageBox::information( this, + "Filtering", + "Filtering done.\n" + "" ); // close the window accept();