From 6263cab87b01a77511df1679269867c6cd26379a Mon Sep 17 00:00:00 2001 From: secher Date: Thu, 15 Feb 2007 15:03:43 +0000 Subject: [PATCH] gradient calculation on field --- src/FILTERGUI/SelectParams.cxx | 72 ++++++++++++++++++++++++++-------- src/FILTERGUI/SelectParams.h | 4 +- 2 files changed, 59 insertions(+), 17 deletions(-) diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 388b71b..08a0beb 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -23,8 +23,6 @@ #include "SelectParams.h" #include "MEDMEM_MedMeshDriver.hxx" #include "MEDMEM_EnsightMeshDriver.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" #include @@ -46,7 +44,7 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, const char* name, bool modal, WFlags fl) throw(SALOME_Exception) - : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024),_sel(sel),_criteria(NULL) + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),_size(1024),_sel(sel),_criteria(NULL),_myGradient(NULL) { if(sel){ @@ -107,14 +105,18 @@ SelectParams::~SelectParams() delete _x; delete _y; - // destruction of support of reference field: reference filed is destroyed + // destruction of gradient field + if(_myGradient) + delete _myGradient; + + // destruction of support of reference field: reference field is destroyed // by destruction of med object in _sel destruction if(_myIField) delete _myIField->getSupport(); if(_myDField) delete _myDField->getSupport(); - // destruction of criteria: support and field + // destruction of criteria: support and field if(_criteria){ delete _criteria->getSupport(); delete _criteria; @@ -177,7 +179,7 @@ void SelectParams::buildFrame() QGridLayout* convLay = new QGridLayout( _myFunc->layout() ); convLay->addWidget( _myFieldB, 0, 0 ); - convLay->addWidget( _myCutNeg = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 ); + convLay->addWidget( _myGradB = new QRadioButton( tr("FILTER_GRADIENT"), _myFunc ), 0, 1 ); _myGroupLayout->addWidget( _myFunc, row, 0 ); row++; @@ -331,6 +333,7 @@ void SelectParams::buildFrame() _myHistoSThresh = _myPlot->insertCurve( QString() ); _myPlot->setCurvePen( _myHistoSThresh, QPen( Qt::black, 1 ) ); + connect( _myGradB, SIGNAL(clicked()), this, SLOT(gradSelected())); connect( _myLESH, SIGNAL(returnPressed()), this, SLOT(enterSHisto())); connect( _myHisto, SIGNAL(clicked()), this, SLOT(updateHisto())); connect( _myLinear, SIGNAL(clicked()), this, SLOT(scaleSelected())); @@ -354,6 +357,28 @@ void SelectParams::buildFrame() } +void SelectParams::gradSelected() +{ + if(!_myGradient){ + FIELD * gradient; + try{ + if(_myDField) + gradient = _myDField->buildGradient(); + else + gradient = _myIField->buildGradient(); + _myGradient = gradient->buildNorm2Field(); + delete gradient; + } + catch(MEDEXCEPTION& Mex){ + _myFieldB->setChecked(true); + QMessageBox::information( this, + "Filtering", + "Unable to calculate gradient on vector field.\n" + "You must select a reference scalar field." ); + } + } +} + void SelectParams::enterSHisto() { // Deallocate old histogram arrays @@ -437,18 +462,25 @@ void SelectParams::calcHisto() char strth[128]; vector myh; - // calculate histogram values - if (_myDField){ - _myDField->getMinMax(_xmin,_xmax); - myh = _myDField->getHistogram(_size); + if( _myFieldB->isChecked() ){ + // calculate histogram values on field + if (_myDField){ + _myDField->getMinMax(_xmin,_xmax); + myh = _myDField->getHistogram(_size); + } + else{ + int xmin, xmax; + _myIField->getMinMax(xmin,xmax); + _xmin = (double)xmin; + _xmax = (double)xmax; + myh = _myIField->getHistogram(_size); + } } else{ - int xmin, xmax; - _myIField->getMinMax(xmin,xmax); - _xmin = (double)xmin; - _xmax = (double)xmax; - myh = _myIField->getHistogram(_size); - } + // calculate histogram values on gradient + _myGradient->getMinMax(_xmin,_xmax); + myh = _myGradient->getHistogram(_size); + } if( _myLinear->isChecked() ) _ymin = 0.0; else @@ -651,6 +683,14 @@ void SelectParams::process() // have to call ensight driver MED to generate output MED file from filtoo output + // create fields on new mesh + // if new nodes on new mesh: interpolation + // if input fields on cell, transform it on nodes + + // destroy filtoo output files + + // create new MED file with new mesh and fields + // close the window accept(); diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index fe32287..d561ee6 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -67,6 +67,7 @@ protected: virtual void generateCriteria() throw(SALOME_Exception); protected slots: + virtual void gradSelected(); virtual void enterSHisto(); virtual void updateHisto(); virtual void scaleSelected(); @@ -93,7 +94,7 @@ private: QLineEdit *_myLESH, *_myFThresh, *_myExpr, *_myLEST, *_myLEFT, *_myOFN; QButtonGroup *_myHSize, *_myFunc, *_myFScale, *_myNbThresh, *_myArea, *_myVThresh, *_myOutFile; QGridLayout *_myGroupLayout, *_myGroupLayout2, *_lay, *_GroupButtonsLayout; - QRadioButton *_myCutNeg, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myFieldB, *_myLinear, *_myLog; + QRadioButton *_myFieldB, *_myGradB, *_myInt, *_myExt, *_myOneThresh, *_myTwoThresh, *_myLinear, *_myLog; QPushButton *_myHisto, *_myOFB, *_myProc, * _buttonCancel, * _buttonHelp; QGroupBox* _GroupC1, *_GroupC2, *_GroupButtons; QwtPlot *_myPlot; @@ -105,6 +106,7 @@ private: SelectField *_sel; ::MEDMEM::MED *_med; MESH* _mesh; + FIELD * _myGradient; FIELD * _myDField; FIELD * _myIField; FIELD *_criteria; -- 2.39.2