1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "SelectParams.h"
24 #include "MEDMEM_MedMeshDriver.hxx"
25 #include "MEDMEM_EnsightMeshDriver.hxx"
27 #include <SUIT_FileDlg.h>
29 #include "Utils_SALOME_Exception.hxx"
30 #include <SalomeApp_Tools.h>
33 #include <qgroupbox.h>
36 #include <qlineedit.h>
37 #include <qbuttongroup.h>
38 #include <qradiobutton.h>
39 #include <qpushbutton.h>
40 #include <qfiledialog.h>
41 #include <qmessagebox.h>
44 SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel,
46 bool modal, WFlags fl) throw(SALOME_Exception)
47 : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),_size(1024),_sel(sel),_criteria(NULL),_myGradient(NULL)
51 // read reference field values
54 // Get reference field and time step
55 _inputFile = sel->getFile();
56 _inputMesh = sel->getMesh();
57 _inputField = sel->getField();
58 _inputTS = sel->getTimeStep();
60 // if no reference field selection: throw exception
61 if( _inputMesh.isNull() || _inputField.isNull() ){
62 MESSAGE("Select an input Field in MED file before filtering!!");
64 throw SALOME_Exception("Salome Exception");
68 _mesh = _med->getMesh(_inputMesh);
71 // read of input field
72 deque<DT_IT_> myIteration = _med->getFieldIteration (_inputField);
73 MEDMEM::FIELD_* field = _med->getField(_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it);
74 if (dynamic_cast<MEDMEM::FIELD<double>*>(field)){
75 _myDField = (MEDMEM::FIELD<double>*)field;
80 _myIField = (MEDMEM::FIELD<int>*)field;
88 // if no reference field selection: throw exception
90 MESSAGE("Select an input Field in MED file before filtering!!");
91 throw SALOME_Exception("Salome Exception");
94 // Allocate histogram arrays
95 _x = new double[_size];
96 _y = new double[_size];
100 SelectParams::~SelectParams()
102 cout << "SelectParams: destructor called" << endl;
104 // destrcution of histogram arrays
108 // destruction of gradient field
112 // destruction of support of reference field: reference field is destroyed
113 // by destruction of med object in _sel destruction
115 delete _myIField->getSupport();
117 delete _myDField->getSupport();
119 // destruction of criteria: support and field
121 delete _criteria->getSupport();
125 // destruction of SelectField object and MED object in it
129 void SelectParams::buildFrame()
131 // build widgets for select filtering parameters
132 QGridLayout* _lay = new QGridLayout( this, 1, 2 );
134 QGroupBox* _GroupC1 = new QGroupBox( this, "GroupC1" );
135 _lay->addWidget( _GroupC1,0,0 );
137 _GroupC1->setTitle( tr( "FILTER_PARAMS" ) );
138 _GroupC1->setColumnLayout(0, Qt::Vertical );
139 _GroupC1->layout()->setSpacing( 0 );
140 _GroupC1->layout()->setMargin( 0 );
141 _myGroupLayout = new QGridLayout( _GroupC1->layout() );
142 _myGroupLayout->setAlignment( Qt::AlignTop );
143 _myGroupLayout->setSpacing( 6 );
144 _myGroupLayout->setMargin( 11 );
145 _myGroupLayout->setColStretch( 0, 0 );
146 _myGroupLayout->setColStretch( 1, 1 );
150 QString qs1(tr("FILTER_INPUT_FILE"));
151 qs1.append(basename(_inputFile));
152 _myGroupLayout->addWidget( new QLabel( qs1, _GroupC1 ), row, 0 );
155 QString qs2(tr("FILTER_INPUT_MESH"));
156 qs2.append(_inputMesh);
157 _myGroupLayout->addWidget( new QLabel( qs2, _GroupC1 ), row, 0 );
160 QString qs3(tr("FILTER_INPUT_FIELD"));
161 qs3.append(_inputField);
162 _myGroupLayout->addWidget( new QLabel( qs3, _GroupC1 ), row, 0 );
165 QString qs4(tr("FILTER_INPUT_TS"));
167 sprintf(strTS,"%d\0",_inputTS);
169 _myGroupLayout->addWidget( new QLabel( qs4, _GroupC1 ), row, 0 );
172 // 0) field function to calculate histogram (radiogroup)
173 _myFunc = new QButtonGroup( tr("FILTER_SELECT_FUNC"), _GroupC1 );
174 _myFunc->setExclusive( true );
175 _myFunc->setColumnLayout( 0, Qt::Horizontal );
177 _myFieldB = new QRadioButton( tr("FILTER_FIELD"), _myFunc );
178 _myFieldB->setChecked(true);
180 QGridLayout* convLay = new QGridLayout( _myFunc->layout() );
181 convLay->addWidget( _myFieldB, 0, 0 );
182 convLay->addWidget( _myGradB = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 );
183 _myGroupLayout->addWidget( _myFunc, row, 0 );
186 // 01) histogram size (line edit)
187 _myHSize = new QButtonGroup( tr(""), _GroupC1 );
188 _myHSize->setExclusive( true );
189 _myHSize->setColumnLayout( 0, Qt::Horizontal );
190 QGridLayout* shLay = new QGridLayout( _myHSize->layout() );
191 shLay->addWidget( _myLSH = new QLabel( tr("FILTER_SIZE_HISTO") , _myHSize ), 0, 0 );
192 shLay->addWidget( _myLESH = new QLineEdit( "1024", _myHSize ), 0, 1 );
193 _myGroupLayout->addWidget( _myHSize, row, 0 );
196 // 1) display histogram button (pushbutton)
197 _myHisto = new QPushButton( "", _GroupC1 );
198 _myHisto->setText(tr("FILTER_DISPLAY_HISTO"));
199 _myHisto->setAutoDefault(TRUE);
200 _myHisto->setDefault(TRUE);
201 _myGroupLayout->addWidget( _myHisto, row, 0 );
204 // 2) scale of histogram (radiogroup)
205 _myFScale = new QButtonGroup( tr("FILTER_TYPE_DISPLAY"), _GroupC1 );
206 _myFScale->setExclusive( true );
207 _myFScale->setColumnLayout( 0, Qt::Horizontal );
209 _myLinear = new QRadioButton( tr("FILTER_LINEAR"), _myFScale );
210 _myLinear->setChecked(true);
211 _myLog = new QRadioButton( tr("FILTER_LOG"), _myFScale );
212 _myFScale->setDisabled(true);
214 QGridLayout* scaleLay = new QGridLayout( _myFScale->layout() );
215 scaleLay->addWidget( _myLinear, 0, 0 );
216 scaleLay->addWidget( _myLog, 0, 1 );
217 _myGroupLayout->addWidget( _myFScale, row, 0 );
220 // 3) number of thresholds (radiogroup)
221 _myNbThresh = new QButtonGroup( tr("FILTER_SEL_THRESH"), _GroupC1 );
222 _myNbThresh->setExclusive( true );
223 _myNbThresh->setColumnLayout( 0, Qt::Horizontal );
224 QGridLayout* nbtLay = new QGridLayout( _myNbThresh->layout() );
225 nbtLay->addWidget( _myOneThresh = new QRadioButton( tr("FILTER_ONE_THRESH"), _myNbThresh ), 0, 0 );
226 nbtLay->addWidget( _myTwoThresh = new QRadioButton( tr("FILTER_TWO_THRESH"), _myNbThresh ), 0, 1 );
227 _myGroupLayout->addWidget( _myNbThresh, row, 0 );
229 _myOneThresh->setChecked(true);
230 _myNbThresh->setDisabled(true);
233 // 4) reference area on thresholds (radiogroup)
234 _myArea = new QButtonGroup( tr("FILTER_REF_AREA"), _GroupC1 );
235 _myArea->setExclusive( true );
236 _myArea->setColumnLayout( 0, Qt::Horizontal );
237 QGridLayout* areaLay = new QGridLayout( _myArea->layout() );
238 areaLay->addWidget( _myInt = new QRadioButton( tr("FILTER_BOTTOM"), _myArea ), 0, 0 );
239 areaLay->addWidget( _myExt = new QRadioButton( tr("FILTER_UP"), _myArea ), 0, 1 );
240 _myGroupLayout->addWidget( _myArea, row, 0 );
242 _myExt->setChecked(true);
243 _myArea->setDisabled(true);
246 // 5) threshold values (line edit)
247 _myVThresh = new QButtonGroup( tr("FILTER_TRESH_VAL"), _GroupC1 );
248 _myVThresh->setExclusive( true );
249 _myVThresh->setColumnLayout( 0, Qt::Horizontal );
250 QGridLayout* ftLay = new QGridLayout( _myVThresh->layout() );
251 ftLay->addWidget( _myLFT = new QLabel( tr("FILTER_VAL_TRESH") , _myVThresh ), 0, 0 );
252 ftLay->addWidget( _myLEFT = new QLineEdit( "", _myVThresh ), 0, 1 );
253 ftLay->addWidget( _myLST = new QLabel( tr("FILTER_VAL_2_TRESH") , _myVThresh ), 1, 0 );
254 ftLay->addWidget( _myLEST = new QLineEdit( "", _myVThresh ), 1, 1 );
255 _myGroupLayout->addWidget( _myVThresh, row, 0 );
257 _myVThresh->setDisabled(true);
262 // 6) output file name (line edit)
263 _myOutFile = new QButtonGroup( tr("FILTER_OUT_FILE"), _GroupC1 );
264 _myOutFile->setExclusive( true );
265 _myOutFile->setColumnLayout( 0, Qt::Horizontal );
267 _myOFB = new QPushButton( "", _myOutFile );
268 _myOFB->setText(tr("FILTER_BROWSE"));
269 _myOFB->setAutoDefault(TRUE);
271 QGridLayout* outLay = new QGridLayout( _myOutFile->layout() );
272 outLay->addWidget( _myOFB, 0, 0 );
273 outLay->addWidget( _myOFN = new QLineEdit( "", _myOutFile ), 0, 1 );
274 _myGroupLayout->addWidget( _myOutFile, row, 0 );
276 _myOutFile->setDisabled(true);
279 // 8) buttons Process, Close and Help
280 _GroupButtons = new QGroupBox(_GroupC1, "GroupButtons");
281 _GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, _GroupButtons->sizePolicy().hasHeightForWidth()));
282 _GroupButtons->setTitle(tr("" ));
283 _GroupButtons->setColumnLayout(0, Qt::Vertical);
284 _GroupButtons->layout()->setSpacing(0);
285 _GroupButtons->layout()->setMargin(0);
286 _GroupButtonsLayout = new QGridLayout(_GroupButtons->layout());
287 _GroupButtonsLayout->setAlignment(Qt::AlignTop);
288 _GroupButtonsLayout->setSpacing(6);
289 _GroupButtonsLayout->setMargin(11);
290 _myProc = new QPushButton(_GroupButtons, "buttonProcess");
291 _myProc->setText(tr("FILTER_PROCESS"));
292 _myProc->setAutoDefault(TRUE);
293 _GroupButtonsLayout->addWidget(_myProc, 0, 0);
294 _buttonHelp = new QPushButton(_GroupButtons, "buttonHelp");
295 _buttonHelp->setText(tr("FILTER_BUT_HELP" ));
296 _buttonHelp->setAutoDefault(TRUE);
297 _GroupButtonsLayout->addWidget(_buttonHelp, 0, 2);
298 _buttonCancel = new QPushButton(_GroupButtons, "buttonCancel");
299 _buttonCancel->setText(tr("FILTER_BUT_CANCEL" ));
300 _buttonCancel->setAutoDefault(TRUE);
301 _GroupButtonsLayout->addWidget(_buttonCancel, 0, 1);
302 _myGroupLayout->addWidget( _GroupButtons, row, 0 );
303 _GroupButtons->setDisabled(true);
306 _GroupC2 = new QGroupBox( this, "GroupC2" );
307 _lay->addWidget( _GroupC2,0,1 );
309 _GroupC2->setTitle( tr( "FILTER_HISTO" ) );
310 _GroupC2->setColumnLayout(0, Qt::Vertical );
311 _GroupC2->layout()->setSpacing( 0 );
312 _GroupC2->layout()->setMargin( 0 );
313 _myGroupLayout2 = new QGridLayout( _GroupC2->layout() );
315 // 9) histogram curve
316 _myPlot = new QwtPlot(_GroupC2);
317 _myHistoCurve = _myPlot->insertCurve( QString() );
318 _myPlot->setCurvePen( _myHistoCurve, QPen( Qt::red, 1 ) );
319 _myPlot->setCurveTitle( _myHistoCurve, "Histogram" );
321 _myGroupLayout2->addWidget( _myPlot, 0, 0 );
323 // 10) reduction rate (label)
324 QString qs5(tr("FILTER_RED_RATE"));
325 qs5.append(" = 0.5");
326 _myLRR = new QLabel( qs5, _GroupC2 );
327 _myGroupLayout2->addWidget( _myLRR, 1, 0 );
331 _myHistoFThresh = _myPlot->insertCurve( QString() );
332 _myPlot->setCurvePen( _myHistoFThresh, QPen( Qt::black, 1 ) );
333 _myHistoSThresh = _myPlot->insertCurve( QString() );
334 _myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) );
336 connect( _myGradB, SIGNAL(clicked()), this, SLOT(gradSelected()));
337 connect( _myLESH, SIGNAL(returnPressed()), this, SLOT(enterSHisto()));
338 connect( _myHisto, SIGNAL(clicked()), this, SLOT(updateHisto()));
339 connect( _myLinear, SIGNAL(clicked()), this, SLOT(scaleSelected()));
340 connect( _myLog, SIGNAL(clicked()), this, SLOT(scaleSelected()));
341 connect( _myOneThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
342 connect( _myTwoThresh, SIGNAL(clicked()), this, SLOT(nbThreshSelected()));
343 connect( _myInt, SIGNAL(clicked()), this, SLOT(areaSelected()));
344 connect( _myExt, SIGNAL(clicked()), this, SLOT(areaSelected()));
345 connect( _myLEFT, SIGNAL(returnPressed()), this, SLOT(enterFThresh()));
346 connect( _myLEST, SIGNAL(returnPressed()), this, SLOT(enterSThresh()));
347 connect( _myPlot, SIGNAL(plotMouseMoved(const QMouseEvent &)), this, SLOT(moveThresh(const QMouseEvent &)));
348 connect( _myOFB, SIGNAL(clicked()), this, SLOT(getOutFileName()));
349 connect( _myProc, SIGNAL(clicked()), this, SLOT(process()));
350 connect(_buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()));
351 connect(_buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
353 _GroupC2->setMinimumSize( 500, 500 );
354 _GroupC2->setMaximumSize( 500, 500 );
355 setMinimumSize( 750, 500 );
356 setMaximumSize( 750, 500 );
360 void SelectParams::gradSelected()
363 FIELD<double> * gradient;
366 gradient = _myDField->buildGradient();
368 gradient = _myIField->buildGradient();
369 _myGradient = gradient->buildNorm2Field();
372 catch(MEDEXCEPTION& Mex){
373 _myFieldB->setChecked(true);
374 QMessageBox::information( this,
376 "Unable to calculate gradient on vector field.\n"
377 "You must select a reference scalar field." );
382 void SelectParams::enterSHisto()
384 // Deallocate old histogram arrays
388 // get new histogram size
389 _size = atoi(_myLESH->text());
391 // Allocate new histogram arrays
392 _x = new double[_size];
393 _y = new double[_size];
396 void SelectParams::scaleSelected()
398 // draw linear or log Y scale depend on user
399 if( _myLinear->isChecked() ){
401 _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
404 // set min to 0.1 for log scale
406 _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
408 _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
412 void SelectParams::nbThreshSelected()
414 if( _myOneThresh->isChecked() ){
415 // if one threshold choice between bottom and up for reference area
416 _myInt->setText(tr("FILTER_BOTTOM"));
417 _myExt->setText(tr("FILTER_UP"));
418 _myLFT->setText(tr("FILTER_VAL_TRESH"));
421 // draw first threshold
423 // erase second threshold
427 // if two thresholds choice between interior and exterior fir reference area
428 _myInt->setText(tr("FILTER_INT"));
429 _myExt->setText(tr("FILTER_EXT"));
430 _myLFT->setText(tr("FILTER_VAL_1_TRESH"));
431 if(_myLST->isHidden())
433 if(_myLEST->isHidden())
435 // draw two thresholds
442 void SelectParams::areaSelected()
444 // calculate reduction rate after thresholds selection
448 void SelectParams::enterFThresh()
454 void SelectParams::enterSThresh()
460 void SelectParams::calcHisto()
465 if( _myFieldB->isChecked() ){
466 // calculate histogram values on field
468 _myDField->getMinMax(_xmin,_xmax);
469 myh = _myDField->getHistogram(_size);
473 _myIField->getMinMax(xmin,xmax);
474 _xmin = (double)xmin;
475 _xmax = (double)xmax;
476 myh = _myIField->getHistogram(_size);
480 // calculate histogram values on gradient
481 _myGradient->getMinMax(_xmin,_xmax);
482 myh = _myGradient->getHistogram(_size);
484 if( _myLinear->isChecked() )
490 for(int i=0;i<_size;i++){
491 // calculate absisses for histogram values
492 _x[i]=_xmin+(i*(_xmax-_xmin))/_size;
493 // set zero to 0.01 because pb of zeros in log display with qwt
495 _y[i]=(double)myh[i];
502 // init thresholds values
503 _fthresh = (_xmin + _xmax)/2.0;
504 _sthresh = (_xmin + 3.*_xmax)/4.0;
505 sprintf(strth,"%g",_fthresh);
506 _myLEFT->setText(QString(strth));
507 sprintf(strth,"%g",_sthresh);
508 _myLEST->setText(QString(strth));
511 void SelectParams::displayHisto()
513 // associate values to curve
514 _myPlot->setCurveData( _myHistoCurve, _x, _y, _size );
515 // give extrema values for each axis
516 _myPlot->setAxisScale( _myPlot->curveXAxis( _myHistoCurve ), _xmin, _xmax );
517 _myPlot->setAxisScale( _myPlot->curveYAxis( _myHistoCurve ), _ymin, _ymax );
518 if( _myLinear->isChecked() )
519 _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::None );
521 _myPlot->setAxisOptions(_myPlot->curveYAxis( _myHistoCurve ), QwtAutoScale::Logarithmic );
522 // associate mapping to plot to move thresholds on display
523 _qmap = _myPlot->canvasMap(_myPlot->curveXAxis( _myHistoCurve ));
524 _qmap.setDblRange(_xmin,_xmax);
528 void SelectParams::enableWidgets()
530 if(_GroupC2->isHidden()){
531 _myFScale->setEnabled(true);
532 _myNbThresh->setEnabled(true);
533 _myArea->setEnabled(true);
534 _myVThresh->setEnabled(true);
535 _myOutFile->setEnabled(true);
536 _GroupButtons->setEnabled(true);
541 void SelectParams::updateHisto()
546 if( _myTwoThresh->isChecked() )
552 void SelectParams::displayFThresh()
554 _fthresh = atof(_myLEFT->text());
556 // draw first threshold curve
557 for(int i=0;i<100;i++){
559 _yft[i]=((i-1)*_ymax)/100.0;
561 _myPlot->setCurveData( _myHistoFThresh, _xft, _yft, 100 );
565 void SelectParams::displaySThresh()
567 _sthresh = atof(_myLEST->text());
569 // draw second threshold curve
570 for(int i=0;i<100;i++){
572 _yst[i]=((i-1)*_ymax)/100.0;
574 _myPlot->setCurveData( _myHistoSThresh, _xst, _yst, 100 );
578 void SelectParams::clearSThresh()
580 _sthresh = atof(_myLEST->text());
582 // erase second threshold curve
583 for(int i=0;i<100;i++){
587 _myPlot->setCurveData( _myHistoSThresh, _xst, _yst, 100 );
591 void SelectParams::moveThresh(const QMouseEvent &e)
595 // move threshold curve with mouse
596 int delta = abs(e.x()-_qmap.transform(_fthresh));
598 // moving first threshold curve
599 sprintf(strth,"%g",_qmap.invTransform(e.x()));
600 _myLEFT->setText(QString(strth));
603 else if( _myTwoThresh->isChecked() ){
604 delta = abs(e.x()-_qmap.transform(_sthresh));
606 // moving second threshold curve
607 sprintf(strth,"%g",_qmap.invTransform(e.x()));
608 _myLEST->setText(QString(strth));
615 void SelectParams::getOutFileName()
617 // get output MED file name
618 QString file = QFileDialog::getSaveFileName("",
622 "Choose a file to save" );
624 _myOFN->setText(file);
626 // Selection du Fichier
627 // file = SUIT_FileDlg::getFileName(application()->desktop(),
630 // "Output MED file name",
634 void SelectParams::process()
638 MESSAGE("Input MED File : "<<_inputFile);
639 MESSAGE("Input Mesh : "<<_inputMesh);
640 MESSAGE("Input Field : "<<_inputField);
641 MESSAGE("Input Time Step : "<<_inputTS);
642 MESSAGE("Output file name: " << _myOFN->text() );
644 setCursor(QCursor(Qt::WaitCursor));
646 // generate MED integer field (0 or 1) for filtoo input
650 catch ( SALOME_Exception& S_ex ){
651 QMessageBox::information( this,
653 "Unable to process filtering.\n"
654 "You must select a reference field on nodes." );
659 // generate MED boundary of geometry
660 SUPPORT *supB = _mesh->getBoundaryElements(MED_FACE);
662 // call ensight driver MED to generate input ensight mesh ,
663 // input ensight boundary mesh and input criteria ensight field for filtoo
666 ENSIGHT_MESH_DRIVER myMeshDriver("/tmp/input.geom",_mesh);
667 myMeshDriver.addSupport(supB);
668 id=_mesh->addDriver(myMeshDriver);
670 ENSIGHT_FIELD_DRIVER<int> myFieldDriver("/tmp/input.data",_criteria);
671 id=_criteria->addDriver(myFieldDriver);
672 _criteria->write(id);
674 // send filtoo command
675 command = "cd /tmp;filtoo -f input -o output > /tmp/filter.log";
677 system(command.c_str());
679 // destroy filtoo input files
680 // command = "cd /tmp;rm -f input.*";
682 // system(command.c_str());
684 // have to call ensight driver MED to generate output MED file from filtoo output
686 // create fields on new mesh
687 // if new nodes on new mesh: interpolation
688 // if input fields on cell, transform it on nodes
690 // destroy filtoo output files
692 // create new MED file with new mesh and fields
699 void SelectParams::generateCriteria() throw(SALOME_Exception)
701 double val, min, max;
703 MED_EN::medEntityMesh typ;
705 // if reference field is on elements create reference field on nodes
707 typ = _myDField->getSupport()->getEntity();
709 typ = _myIField->getSupport()->getEntity();
713 MESSAGE("REFERENCE FIELD ON CELL");
714 throw SALOME_Exception("Filter run only on reference field on nodes");
717 MESSAGE("REFERENCE FIELD ON FACE");
718 throw SALOME_Exception("Filter run only on reference field on nodes");
721 MESSAGE("REFERENCE FIELD ON EDGE");
722 throw SALOME_Exception("Filter run only on reference field on nodes");
725 MESSAGE("REFERENCE FIELD ON NODES");
727 case MED_ALL_ENTITIES:
728 MESSAGE("REFERENCE FIELD ON ALL ELEMENTS");
729 throw SALOME_Exception("Filter run only on reference field on nodes");
733 // create support on nodes
734 SUPPORT *sup = new SUPPORT(_mesh,"Support",MED_NODE);
736 // create integer field on nodes
737 _criteria = new FIELD<int>(sup,1);
739 _criteria->setName("Criteria");
741 // read number of nodes
742 int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS);
744 for (int i=1; i<NumberOf+1; i++){
746 // read reference field value
748 val = _myDField->getValueIJ(i,1);
750 val = (double)_myIField->getValueIJ(i,1);
752 // set criteria field value
753 if( _myOneThresh->isChecked() ){
754 if( _myExt->isChecked() )
755 if( val >= _fthresh ) isGVal = true;
758 if( val <= _fthresh ) isGVal = true;
764 if(_sthresh < _fthresh){
768 if( _myExt->isChecked() )
769 if( (val <= min) || (val >= max) ) isGVal = true;
772 if( (val >= min) && (val <= max) ) isGVal = true;
776 _criteria->setValueIJ(i,1,1);
778 _criteria->setValueIJ(i,1,0);
782 void SelectParams::calcRateRed()
785 int atot=0, asel=0, atot1;
788 // calculate reduction rate depend on reference area defined by threshold values
789 i1 = (int)((double)_size * ( _fthresh - _xmin ) / ( _xmax - _xmin ));
790 if( _myOneThresh->isChecked() ){
794 for(i=i1;i<_size;i++)
796 if( _myExt->isChecked() )
800 i2 = (int)((double)_size * ( _sthresh - _xmin ) / ( _xmax - _xmin ));
812 for(i=i2;i<_size;i++)
814 if( _myExt->isChecked() )
817 rateRed = (double)asel / (double) atot;
819 // display reduction rate value
820 QString qs(tr("FILTER_RED_RATE"));
822 sprintf(str," = %4.2g",rateRed);
824 _myLRR->setText( qs );
828 void SelectParams::ClickOnCancel()
830 MESSAGE("click on Cancel");
834 void SelectParams::ClickOnHelp()
836 MESSAGE("click on Help");