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;
// 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.*";
void SelectParams::gradSelected()
{
try{
+ setCursor(QCursor(Qt::WaitCursor));
_filter->buildGradient();
+ setCursor(QCursor(Qt::ArrowCursor));
}
catch(SALOME_FILTER::FILTER_Gen::FilterError){
_myFieldB->setChecked(true);
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{
// create new MED file with new mesh and fields
_filter->createMedOutputFile(_myOFN->text());
+ QMessageBox::information( this,
+ "Filtering",
+ "Filtering done.\n"
+ "" );
// close the window
accept();