From: secher Date: Tue, 13 Feb 2007 15:12:23 +0000 (+0000) Subject: call to ensight write driver X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5f5dd3e56fb311a873bc418850fb798c9bb20951;p=modules%2Ffilter.git call to ensight write driver --- diff --git a/src/FILTERGUI/FilterGUI.cxx b/src/FILTERGUI/FilterGUI.cxx index 2526e15..a723e63 100644 --- a/src/FILTERGUI/FilterGUI.cxx +++ b/src/FILTERGUI/FilterGUI.cxx @@ -57,6 +57,8 @@ // QT Includes #include +#include +#include //VRV: porting on Qt 3.0.5 #if QT_VERSION >= 0x030005 @@ -138,7 +140,7 @@ void FilterGUI::initialize( CAM_Application* app ) { SalomeApp_Module::initialize( app ); - QWidget* parent = application()->desktop(); +// QWidget* parent = application()->desktop(); createFilterAction( 111, "OPEN" ); @@ -283,15 +285,26 @@ bool FilterGUI::OnGUIEvent (int theCommandID) if(_sel){ SelectParams *filter; try { + application()->desktop()->setCursor(QCursor(Qt::WaitCursor)); filter = new SelectParams(this,_sel); filter->exec(); + application()->desktop()->setCursor(QCursor(Qt::ArrowCursor)); _sel = NULL; } catch ( SALOME_Exception& S_ex ) { + QMessageBox::information( application()->desktop(), + "Filtering", + "Unable to select parameters for filtering.\n" + "You must select a reference field in a MED file before." ); } } - else + else{ MESSAGE("Select an input Field in MED file before filtering!!"); + QMessageBox::information( application()->desktop(), + "Filtering", + "Unable to select parameters for filtering.\n" + "You must select a reference field in a MED file before." ); + } break; } case 111: diff --git a/src/FILTERGUI/SelectParams.cxx b/src/FILTERGUI/SelectParams.cxx index b52824a..388b71b 100644 --- a/src/FILTERGUI/SelectParams.cxx +++ b/src/FILTERGUI/SelectParams.cxx @@ -22,6 +22,9 @@ #include #include "SelectParams.h" #include "MEDMEM_MedMeshDriver.hxx" +#include "MEDMEM_EnsightMeshDriver.hxx" +#include "MEDMEM_Family.hxx" +#include "MEDMEM_Group.hxx" #include @@ -37,11 +40,13 @@ #include #include #include +#include +#include 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),_criteria(NULL),_boundary(NULL) + 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) { if(sel){ @@ -115,10 +120,6 @@ SelectParams::~SelectParams() delete _criteria; } - // destruction of criteria: support and field - if(_boundary) - delete _boundary; - // destruction of SelectField object and MED object in it delete _sel; } @@ -608,20 +609,46 @@ void SelectParams::process() MESSAGE("Input Time Step : "<<_inputTS); MESSAGE("Output file name: " << _myOFN->text() ); + setCursor(QCursor(Qt::WaitCursor)); + // generate MED integer field (0 or 1) for filtoo input - generateCriteria(); + try{ + generateCriteria(); + } + catch ( SALOME_Exception& S_ex ){ + QMessageBox::information( this, + "Filtering", + "Unable to process filtering.\n" + "You must select a reference field on nodes." ); + reject(); + return; + } // generate MED boundary of geometry - generateBoundary(); + SUPPORT *supB = _mesh->getBoundaryElements(MED_FACE); - // have to call ensight driver MED to generate input ensight mesh , + // call ensight driver MED to generate input ensight mesh , // input ensight boundary mesh and input criteria ensight field for filtoo + int id; + ENSIGHT_MESH_DRIVER myMeshDriver("/tmp/input.geom",_mesh); + myMeshDriver.addSupport(supB); + id=_mesh->addDriver(myMeshDriver); + _mesh->write(id); + ENSIGHT_FIELD_DRIVER myFieldDriver("/tmp/input.data",_criteria); + id=_criteria->addDriver(myFieldDriver); + _criteria->write(id); + // send filtoo command - command = "cd /export/home/secher/filtoo/example;filtoo -f s -o sf > /tmp/filter.log"; + command = "cd /tmp;filtoo -f input -o output > /tmp/filter.log"; MESSAGE(command); system(command.c_str()); + // destroy filtoo input files +// command = "cd /tmp;rm -f input.*"; +// MESSAGE(command); +// system(command.c_str()); + // have to call ensight driver MED to generate output MED file from filtoo output // close the window @@ -629,206 +656,7 @@ 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() +void SelectParams::generateCriteria() throw(SALOME_Exception) { double val, min, max; bool isGVal; @@ -843,19 +671,23 @@ void SelectParams::generateCriteria() switch(typ){ case MED_CELL: MESSAGE("REFERENCE FIELD ON CELL"); - return; + throw SALOME_Exception("Filter run only on reference field on nodes"); + break; case MED_FACE: MESSAGE("REFERENCE FIELD ON FACE"); - return; + throw SALOME_Exception("Filter run only on reference field on nodes"); + break; case MED_EDGE: MESSAGE("REFERENCE FIELD ON EDGE"); - return; + throw SALOME_Exception("Filter run only on reference field on nodes"); + break; case MED_NODE: MESSAGE("REFERENCE FIELD ON NODES"); break; case MED_ALL_ENTITIES: MESSAGE("REFERENCE FIELD ON ALL ELEMENTS"); - return; + throw SALOME_Exception("Filter run only on reference field on nodes"); + break; } // create support on nodes @@ -864,6 +696,8 @@ void SelectParams::generateCriteria() // create integer field on nodes _criteria = new FIELD(sup,1); + _criteria->setName("Criteria"); + // read number of nodes int NumberOf = sup->getNumberOfElements(MED_ALL_ELEMENTS); diff --git a/src/FILTERGUI/SelectParams.h b/src/FILTERGUI/SelectParams.h index d43aa03..fe32287 100644 --- a/src/FILTERGUI/SelectParams.h +++ b/src/FILTERGUI/SelectParams.h @@ -52,7 +52,7 @@ public: SelectParams(FilterGUI*,SelectField *sel, const char* name = 0, bool modal = FALSE, - WFlags fl = 0); + WFlags fl = 0) throw(SALOME_Exception); virtual ~SelectParams(); protected: @@ -64,8 +64,7 @@ protected: virtual void displayFThresh(); virtual void displaySThresh(); virtual void enableWidgets(); - virtual void generateCriteria(); - virtual void generateBoundary(); + virtual void generateCriteria() throw(SALOME_Exception); protected slots: virtual void enterSHisto(); @@ -105,11 +104,10 @@ private: int _inputTS; SelectField *_sel; ::MEDMEM::MED *_med; - MEDMEM::MESH* _mesh; + MESH* _mesh; FIELD * _myDField; FIELD * _myIField; FIELD *_criteria; - MESHING* _boundary; }; #endif