From: secher Date: Mon, 5 Feb 2007 09:50:22 +0000 (+0000) Subject: create boundary 2D mesh and integer criteria field (0 or 1), for filtoo X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Ffilter.git;a=commitdiff_plain;h=056c3a33acf2065e49077d4d0df2abee25668845 create boundary 2D mesh and integer criteria field (0 or 1), for filtoo --- diff --git a/src/FILTERGUI/FILTER_msg_en.po b/src/FILTERGUI/FILTER_msg_en.po index bb1788d..8f05252 100644 --- a/src/FILTERGUI/FILTER_msg_en.po +++ b/src/FILTERGUI/FILTER_msg_en.po @@ -180,6 +180,14 @@ msgstr "Name" msgid "FILTER_TYPE" msgstr "Type" +#: SelectField.cxx:74 +msgid "FILTER_SEL_3D" +msgstr "Select a reference field on a 3D mesh" + +#: SelectField.cxx:78 +msgid "FILTER_DIM" +msgstr "Dimension" + #: SelectField.cxx:91 msgid "FILTER_MESH" msgstr "Mesh" diff --git a/src/FILTERGUI/SelectField.cxx b/src/FILTERGUI/SelectField.cxx index 2e2e5b0..a3368a5 100644 --- a/src/FILTERGUI/SelectField.cxx +++ b/src/FILTERGUI/SelectField.cxx @@ -35,7 +35,8 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _file(file), _mesh(0), _field(0), - _ts(0) + _ts(0), + _dimMesh(-1) { QListViewItem *element; @@ -68,24 +69,35 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, int row = 0; - // 0) tree to visualize meshes and fields + // 0) label to select field on 3D mesh + _myGroupLayout->addWidget( new QLabel(tr("FILTER_SEL_3D"),_GroupC1), row, 0 ); + row++; + + // 1) tree to visualize meshes and fields _myList = new QListView( _GroupC1, "List of fields" ); _myList->setMinimumSize( 400, 400 ); _myList->setMaximumSize( 400, 400 ); _myList->setRootIsDecorated(true); _myList->addColumn(tr("FILTER_NAME")); _myList->addColumn(tr("FILTER_TYPE")); + _myList->addColumn(tr("FILTER_DIM")); for(int i=0;igetMesh(meshesNames[i])->getMeshDimension(); + char strd[4]; + sprintf(strd,"%dD\0",_dimMesh); + element = new QListViewItem( _myList, meshesNames[i], tr("FILTER_MESH") ,strd); element->setExpandable(true); _myList->setOpen(element,true); for (int j=0; j myIteration = _med->getFieldIteration (fieldsNames[j]); string meshName = _med->getField(fieldsNames[j],myIteration[0].dt,myIteration[0].it)->getSupport()->getMesh()->getName(); - if( strcmp(meshName.c_str(),meshesNames[i].c_str()) == 0) - new QListViewItem( element, fieldsNames[j], tr("FILTER_FIELD") ); + if( strcmp(meshName.c_str(),meshesNames[i].c_str()) == 0){ + QListViewItem *elem = new QListViewItem( element, fieldsNames[j], tr("FILTER_FIELD") ); + if(_dimMesh != 3) + elem->setSelectable(false); + } } element->setSelectable(false); @@ -93,13 +105,13 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _myGroupLayout->addWidget( _myList, row, 0 ); row++; - // 1) label for time steps + // 2) label for time steps _myLab = new QLabel(tr("FILTER_SEL_TS"),_GroupC1); _myLab->hide(); _myGroupLayout->addWidget( _myLab, row, 0 ); row++; - // 2) slider to visualize time steps + // 3) slider to visualize time steps _mySlider = new QSlider(_GroupC1); _mySlider->setOrientation(Qt::Horizontal); _mySlider->setTickmarks(QSlider::Below); @@ -108,7 +120,7 @@ SelectField::SelectField(FilterGUI* theModule,const QString& file, _mySlider->hide(); row++; - // 3) buttons Close and Help + // 4) buttons Ok, Cancel and Help _GroupButtons = new QGroupBox(_GroupC1, "GroupButtons"); _GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, _GroupButtons->sizePolicy().hasHeightForWidth())); // _GroupButtons->setGeometry(QRect(10, 10, 281, 48)); @@ -153,7 +165,7 @@ SelectField::~SelectField() void SelectField::fieldSelected(QListViewItem *lvi) { if(lvi){ - if( strcmp(lvi->text(1),"Field") == 0){ + if( (strcmp(lvi->text(1),"Field") == 0) && (_dimMesh == 3) ){ _field = lvi->text(0); _mesh = lvi->parent()->text(0); deque myIteration = _med->getFieldIteration (lvi->text(0)); diff --git a/src/FILTERGUI/SelectField.h b/src/FILTERGUI/SelectField.h index 35eeba8..2ee4979 100644 --- a/src/FILTERGUI/SelectField.h +++ b/src/FILTERGUI/SelectField.h @@ -69,7 +69,7 @@ protected slots: virtual void ClickOnHelp(); private: - int _ts; + int _ts, _dimMesh; QGridLayout *_myGroupLayout, *_GroupButtonsLayout, *_lay; QGroupBox* _GroupC1, *_GroupButtons; QFrame *_fr; diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index 60ddc54..b52824a 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -21,7 +21,7 @@ #include #include #include "SelectParams.h" -#include "utilities.h" +#include "MEDMEM_MedMeshDriver.hxx" #include @@ -41,12 +41,12 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, const char* name, bool modal, WFlags fl) - : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024),_sel(sel) + : QDialog(FILTER::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose), _size(1024),_sel(sel),_criteria(NULL),_boundary(NULL) { if(sel){ // read reference field values - ::MEDMEM::MED *med = sel->getMED(); + _med = sel->getMED(); // Get reference field and time step _inputFile = sel->getFile(); @@ -61,16 +61,25 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, throw SALOME_Exception("Salome Exception"); } - deque myIteration = med->getFieldIteration (_inputField); - MEDMEM::FIELD_* field = med->getField(_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it); + // read of input mesh + _mesh = _med->getMesh(_inputMesh); + _mesh->read(); + + // read of input field + deque myIteration = _med->getFieldIteration (_inputField); + MEDMEM::FIELD_* field = _med->getField(_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it); if (dynamic_cast*>(field)){ - _myDField = new MEDMEM::FIELD(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it); + _myDField = (MEDMEM::FIELD*)field; + _myDField->read(); _myIField = NULL; } else{ - _myIField = new MEDMEM::FIELD(MEDMEM::MED_DRIVER,_inputFile,_inputField,myIteration[_inputTS].dt,myIteration[_inputTS].it); + _myIField = (MEDMEM::FIELD*)field; + _myIField->read(); _myDField = NULL; } + + // Build QT widgets buildFrame(); } // if no reference field selection: throw exception @@ -88,16 +97,29 @@ SelectParams::SelectParams(FilterGUI* theModule,SelectField *sel, SelectParams::~SelectParams() { cout << "SelectParams: destructor called" << endl; + + // destrcution of histogram arrays delete _x; delete _y; - if(_myIField){ + + // destruction of support of reference field: reference filed is destroyed + // by destruction of med object in _sel destruction + if(_myIField) delete _myIField->getSupport(); - delete _myIField; - } - if(_myDField){ + if(_myDField) delete _myDField->getSupport(); - delete _myDField; + + // destruction of criteria: support and field + if(_criteria){ + delete _criteria->getSupport(); + delete _criteria; } + + // destruction of criteria: support and field + if(_boundary) + delete _boundary; + + // destruction of SelectField object and MED object in it delete _sel; } @@ -328,7 +350,7 @@ void SelectParams::buildFrame() _GroupC2->setMaximumSize( 500, 500 ); setMinimumSize( 750, 500 ); setMaximumSize( 750, 500 ); -// this->show(); /* displays Dialog */ + } void SelectParams::enterSHisto() @@ -580,14 +602,21 @@ void SelectParams::process() { string command; - // have to call ensight driver MED to generate input for filtoo - MESSAGE("Input MED File : "<<_inputFile); MESSAGE("Input Mesh : "<<_inputMesh); MESSAGE("Input Field : "<<_inputField); MESSAGE("Input Time Step : "<<_inputTS); MESSAGE("Output file name: " << _myOFN->text() ); + // generate MED integer field (0 or 1) for filtoo input + generateCriteria(); + + // generate MED boundary of geometry + generateBoundary(); + + // have to call ensight driver MED to generate input ensight mesh , + // input ensight boundary mesh and input criteria ensight field for filtoo + // send filtoo command command = "cd /export/home/secher/filtoo/example;filtoo -f s -o sf > /tmp/filter.log"; MESSAGE(command); @@ -600,6 +629,282 @@ void SelectParams::process() } +void SelectParams::generateBoundary() +{ + int nbTria3=0; + int nbQuad4=0; + int nbTria6=0; + int nbQuad8=0; + const int *faces3, *faces4, *faces6, *faces8; + + // get support of faces on boundary + MEDMEM::SUPPORT *supF = _mesh->getBoundaryElements(MED_EN::MED_FACE); + + // get support of nodes on boundary + MEDMEM::SUPPORT *supN = _mesh->getBoundaryElements(MED_EN::MED_NODE); + + // number of faces on boundary + int nbFaces = supF->getNumberOfElements(MED_ALL_ELEMENTS); + + // type of face on boundary + const MED_EN::medGeometryElement* geotype = supF->getTypes(); + + // number of type of face on boundary + int nbTypes = supF->getNumberOfTypes(); + for(int i=0;igetNumberOfElements(MED_TRIA3); + // array of number of tria6 of boundary + faces3 = supF->getNumber(MED_TRIA3); + break; + case MED_QUAD4: + // number of quad4 on boundary + nbQuad4 = supF->getNumberOfElements(MED_QUAD4); + // array of number of tria6 of boundary + faces4 = supF->getNumber(MED_QUAD4); + break; + case MED_TRIA6: + // number of tria6 on boundary + nbTria6 = supF->getNumberOfElements(MED_TRIA6); + // array of number of tria6 of boundary + faces6 = supF->getNumber(MED_TRIA6); + break; + case MED_QUAD8: + // number of quad8 on boundary + nbQuad8 = supF->getNumberOfElements(MED_QUAD8); + // array of number of tria6 of boundary + faces8 = supF->getNumber(MED_QUAD8); + break; + default: + MESSAGE("OTHER FACE THAN TRIA3 OR QUAD4 : " << geotype[i]); + throw SALOME_Exception("Salome Exception"); + break; + } + } + + // number of nodes on boundary + int nbNodes = supN->getNumberOfElements(MED_ALL_ELEMENTS); + + MESSAGE(nbFaces<< " FACES " << nbTria3 << " TRIA3 " << nbQuad4 << " QUAD4 " << nbTria6 << " TRIA6 " << nbQuad8 << " QUAD8 " << nbNodes << " NODES on BOUNDARY"); + + // array of number of faces of boundary + const int *faces = supF->getNumber(MED_ALL_ELEMENTS); + // array of number of nodes of boundary + const int *nodes = supN->getNumber(MED_ALL_ELEMENTS); + + // array of coordinates of nodes in input 3D mesh + const double *coord = _mesh->getCoordinates(MED_FULL_INTERLACE); + + // space dimension of input mesh + int spaceDim = _mesh->getSpaceDimension(); + + // array of coordinates of nodes in boundary + double *coordB = new double[spaceDim*nbNodes]; + + map ONNodes; + for(int i=0;i 0 ){ + const int *conn3 = _mesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_TRIA3); + for(int i=0;i 0 ){ + const int *conn4 = _mesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_QUAD4); + for(int i=0;i 0 ){ + const int *conn6 = _mesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_TRIA6); + for(int i=0;i 0 ){ + const int *conn8 = _mesh->getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_QUAD8); + for(int i=0;isetName( "Boundary" ); + + int nbOfClassicalTypesFace[4]; + medGeometryElement classicalTypesFace[4]; + ind=0; + if( nbTria3 > 0 ){ + nbOfClassicalTypesFace[ind] = nbTria3; + classicalTypesFace[ind] = MED_EN::MED_TRIA3; + ind++; + } + if( nbQuad4 > 0 ){ + nbOfClassicalTypesFace[ind] = nbQuad4; + classicalTypesFace[ind] = MED_EN::MED_QUAD4; + ind++; + } + if( nbTria6 > 0 ){ + nbOfClassicalTypesFace[ind] = nbTria6; + classicalTypesFace[ind] = MED_EN::MED_TRIA6; + ind++; + } + if( nbQuad8 > 0 ){ + nbOfClassicalTypesFace[ind] = nbQuad8; + classicalTypesFace[ind] = MED_EN::MED_QUAD8; + ind++; + } + + _boundary->setNumberOfTypes(ind, MED_EN::MED_CELL) ; + _boundary->setTypes( classicalTypesFace, MED_EN::MED_CELL) ; + _boundary->setNumberOfElements(nbOfClassicalTypesFace, MED_EN::MED_CELL); + + if( nbTria3 > 0 ) + _boundary->setConnectivity( connB, MED_EN::MED_CELL, MED_EN::MED_TRIA3); + if( nbQuad4 > 0 ) + _boundary->setConnectivity( connB+3*nbTria3, MED_EN::MED_CELL, MED_EN::MED_QUAD4); + if( nbTria6 > 0 ) + _boundary->setConnectivity( connB+3*nbTria3+4*nbQuad4, MED_EN::MED_CELL, MED_EN::MED_TRIA6); + if( nbQuad8 > 0 ) + _boundary->setConnectivity( connB+3*nbTria3+4*nbQuad4+6*nbTria6, MED_EN::MED_CELL, MED_EN::MED_QUAD8); + + _boundary->setMeshDimension(3); + _boundary->setSpaceDimension(3); + _boundary->setNumberOfNodes(nbNodes); + _boundary->setCoordinates(3, nbNodes, coordB, "CARTESIAN", + MED_EN::MED_FULL_INTERLACE); + + // Set coordinates names + string coordname[3] = { "x", "y", "z" } ; + _boundary->setCoordinatesNames(coordname) ; + + // Set coordinates units + string coordunit[3] = { "m", "m", "m" } ; + _boundary->setCoordinatesUnits(coordunit) ; + + // write the boundary mesh in a MED file for test +// MED_MESH_WRONLY_DRIVER myMeshDriver("/home/secher/mymesh.med",_boundary); +// int current=_boundary->addDriver(myMeshDriver); +// _boundary->write(current); + + // support destruction + delete supF; + delete supN; + + // connectivity destruction + delete [] connB; + + // coordinate destruction + delete [] coordB; + +} + +void SelectParams::generateCriteria() +{ + double val, min, max; + bool isGVal; + MED_EN::medEntityMesh typ; + + // if reference field is on elements create reference field on nodes + if(_myDField) + typ = _myDField->getSupport()->getEntity(); + else + typ = _myIField->getSupport()->getEntity(); + + switch(typ){ + case MED_CELL: + MESSAGE("REFERENCE FIELD ON CELL"); + return; + case MED_FACE: + MESSAGE("REFERENCE FIELD ON FACE"); + return; + case MED_EDGE: + MESSAGE("REFERENCE FIELD ON EDGE"); + return; + case MED_NODE: + MESSAGE("REFERENCE FIELD ON NODES"); + break; + case MED_ALL_ENTITIES: + MESSAGE("REFERENCE FIELD ON ALL ELEMENTS"); + return; + } + + // create support on nodes + SUPPORT *sup = new SUPPORT(_mesh,"Support",MED_NODE); + + // create integer field on nodes + _criteria = new FIELD(sup,1); + + // 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); + + // set criteria field value + if( _myOneThresh->isChecked() ){ + if( _myExt->isChecked() ) + 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; + } + if( _myExt->isChecked() ) + 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 + _criteria->setValueIJ(i,1,0); + } +} + void SelectParams::calcRateRed() { int i1, i2, i; diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index d1898eb..d43aa03 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -23,6 +23,7 @@ #include "utilities.h" #include "MEDMEM_Med.hxx" +#include "MEDMEM_Meshing.hxx" #include "SelectField.h" #include @@ -63,6 +64,8 @@ protected: virtual void displayFThresh(); virtual void displaySThresh(); virtual void enableWidgets(); + virtual void generateCriteria(); + virtual void generateBoundary(); protected slots: virtual void enterSHisto(); @@ -99,11 +102,14 @@ private: QwtDiMap _qmap; QFrame *_fr; QString _inputFile, _inputMesh, _inputField; - FIELD * _myDField; - FIELD * _myIField; int _inputTS; SelectField *_sel; - + ::MEDMEM::MED *_med; + MEDMEM::MESH* _mesh; + FIELD * _myDField; + FIELD * _myIField; + FIELD *_criteria; + MESHING* _boundary; }; #endif