]> SALOME platform Git repositories - modules/filter.git/commitdiff
Salome HOME
improvement to catch filtoo errors
authorsecher <secher>
Fri, 11 May 2007 09:21:41 +0000 (09:21 +0000)
committersecher <secher>
Fri, 11 May 2007 09:21:41 +0000 (09:21 +0000)
idl/FILTER_Gen.idl
src/FILTER/Filter_Gen_i.cxx
src/FILTER/Filter_Gen_i.hxx
src/FILTERGUI/SelectParams.cxx

index c676771f50b2890224c536fd5d5c1971b932c17a..7b43f52943dd7e437f5161bb9f9dd1fb6334e03f 100644 (file)
@@ -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);
   };
index bd774035787d92e3185d26db09b17e3801f87fd7..4e30125cf3cbb7ae3416fe70dc8eea3631626894 100755 (executable)
@@ -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<int>(sup,1);
-
-  _criteria->setName("Criteria");
-
-  // read number of nodes
-  int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS);
-
-  for (int i=1; i<NumberOf+1; i++){
-
-    // if reference field is on elements get reference field on nodes
-    switch(typ){
-    case MED_CELL:
-      throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on cells");
-      break;
-    case MED_FACE:
-      throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on faces");
-      break;
-    case MED_EDGE:
-      throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on edges");
-      break;
-    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);
+  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<int>(sup,1);
+
+    _criteria->setName("Criteria");
+
+    // read number of nodes
+    int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS);
+
+    for (int i=1; i<NumberOf+1; i++){
+
+      // if reference field is on elements get reference field on nodes
+      switch(typ){
+      case MED_CELL:
+       throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on cells");
+       break;
+      case MED_FACE:
+       throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on faces");
+       break;
+      case MED_EDGE:
+       throw SALOME_FILTER::FILTER_Gen::FilterError("Filter doesn't run on reference field on edges");
        break;
-      case F_GRAD:
-       val = _myGradient->getValueIJ(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<int> 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<int> 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.*";
index 87b3694bcc56fce50badaec82707b4c0eea4af8f..3005f27c2af28909ddc6224d4d86d631f30e0c7e 100644 (file)
@@ -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);
 
index 7163eb76fa3c892184bdecd9cab04aa743884df1..742cc31712000055d340aeac4d0f271e9a38a902 100644 (file)
@@ -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();