From: gdd Date: Thu, 13 Sep 2012 15:12:32 +0000 (+0000) Subject: [NEW] Add the volumic gradation parameter. X-Git-Tag: V6_6_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=93bc8657b3f771b58fc71ff385f759db580df8fe;p=plugins%2Fghs3dplugin.git [NEW] Add the volumic gradation parameter. [FIX] In GUI, replace myEnforcedTableWidget->clear() by myEnforcedTableWidget->clearContents() (header labels were erased) --- diff --git a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png index 74b2be1..e99409e 100644 Binary files a/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png and b/doc/salome/gui/GHS3DPLUGIN/images/ghs3d_parameters_advanced.png differ diff --git a/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc index 88f50c4..9cececf 100644 --- a/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc +++ b/doc/salome/gui/GHS3DPLUGIN/input/ghs3d_hypo.doc @@ -107,6 +107,9 @@ Note: when using this option, the speed of the meshing process may decrease, quality may change, and the smallest volume may be smaller. By default, the FEM correction is not used. +- Volumic gradation - Defines the volumic ratio between 2 consecutive elements. +WARNING: Changing the default value of this parameter may dramatically decrease the quality of the resulting mesh. + - Option as text - allows to input in the command line any text for ghs3d, for example, advanced options. diff --git a/idl/GHS3DPlugin_Algorithm.idl b/idl/GHS3DPlugin_Algorithm.idl index 0a4fbf2..6bb10d8 100644 --- a/idl/GHS3DPlugin_Algorithm.idl +++ b/idl/GHS3DPlugin_Algorithm.idl @@ -141,6 +141,11 @@ module GHS3DPlugin */ void SetTextOption(in string option); string GetTextOption(); + /*! + * To define the volumic gradation + */ + void SetGradation(in double gradation); + double GetGradation(); /*! * To set an enforced vertex */ diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx index 6910f8c..4deccaa 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.cxx @@ -52,6 +52,7 @@ GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()), myToUseFemCorrection(DefaultToUseFEMCorrection()), myToRemoveCentralPoint(DefaultToRemoveCentralPoint()), + myGradation(DefaultGradation()), _enfVertexList(DefaultGHS3DEnforcedVertexList()), _enfVertexCoordsSizeList(DefaultGHS3DEnforcedVertexCoordsValues()), _enfVertexEntrySizeList(DefaultGHS3DEnforcedVertexEntryValues()), @@ -328,6 +329,27 @@ std::string GHS3DPlugin_Hypothesis::GetTextOption() const return myTextOption; } +//======================================================================= +//function : SetGradation +//======================================================================= + +void GHS3DPlugin_Hypothesis::SetGradation(double gradation) +{ + if ( myGradation != gradation ) { + myGradation = gradation; + NotifySubMeshesHypothesisModification(); + } +} + +//======================================================================= +//function : GetGradation +//======================================================================= + +double GHS3DPlugin_Hypothesis::GetGradation() const +{ + return myGradation; +} + //======================================================================= //function : SetEnforcedVertex //======================================================================= @@ -839,6 +861,15 @@ bool GHS3DPlugin_Hypothesis::DefaultToRemoveCentralPoint() return false; } +//======================================================================= +//function : DefaultGradation +//======================================================================= + +double GHS3DPlugin_Hypothesis::DefaultGradation() +{ + return 1.05; +} + // //======================================================================= // //function : DefaultID2SizeMap // //======================================================================= @@ -866,6 +897,7 @@ std::ostream & GHS3DPlugin_Hypothesis::SaveTo(std::ostream & save) save << (int)myToUseBoundaryRecoveryVersion << " "; save << (int)myToUseFemCorrection << " "; save << (int)myToRemoveCentralPoint << " "; + save << myGradation << " "; if (!myTextOption.empty()) { save << "__OPTIONS_BEGIN__ "; save << myTextOption << " "; @@ -949,6 +981,7 @@ std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load) { bool isOK = true; int i; + double d; isOK = (load >> i); if (isOK) @@ -1026,6 +1059,12 @@ std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load) else load.clear(ios::badbit | load.rdstate()); + isOK = (load >> d); + if (isOK) + myGradation = d; + else + load.clear(ios::badbit | load.rdstate()); + std::string separator; bool hasOptions = false; bool hasEnforcedVertices = false; @@ -1271,7 +1310,7 @@ bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& /*dflts*/ //================================================================================ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp, - const bool hasShapeToMesh) + const bool hasShapeToMesh) { TCollection_AsciiString cmd; if (hasShapeToMesh) @@ -1288,6 +1327,7 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h bool v = hyp ? ( hyp->myTextOption.find("-v") == std::string::npos ) : true; bool fem = hyp ? ( hyp->myTextOption.find("-FEM")== std::string::npos ) : true; bool rem = hyp ? ( hyp->myTextOption.find("-no_initial_central_point")== std::string::npos ) : true; + bool gra = hyp ? ( hyp->myTextOption.find("-Dcpropa")== std::string::npos ) : true; // if use boundary recovery version, few options are allowed bool useBndRecovery = !C; @@ -1370,6 +1410,12 @@ std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* h cmd += (char*) hyp->myTextOption.c_str(); } + // to define volumic gradation. + if ( gra && hyp) { + cmd += " -Dcpropa="; + cmd += hyp->myGradation; + } + #ifdef WNT cmd += " < NUL"; #endif diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx index db3830d..2e1acc5 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis.hxx @@ -191,6 +191,11 @@ public: */ void SetTextOption(const std::string& option); std::string GetTextOption() const; + /*! + * To define the volumic gradation + */ + void SetGradation(double gradation); + double GetGradation() const ; // struct TEnforcedEdge { @@ -269,6 +274,7 @@ public: static bool DefaultToUseBoundaryRecoveryVersion(); static bool DefaultToUseFEMCorrection(); static bool DefaultToRemoveCentralPoint(); + static double DefaultGradation(); static TGHS3DEnforcedVertex DefaultGHS3DEnforcedVertex() {return TGHS3DEnforcedVertex();} static TGHS3DEnforcedVertexList DefaultGHS3DEnforcedVertexList() {return TGHS3DEnforcedVertexList();} @@ -316,6 +322,7 @@ private: bool myToUseFemCorrection; bool myToRemoveCentralPoint; std::string myTextOption; + double myGradation; TGHS3DEnforcedVertexList _enfVertexList; TGHS3DEnforcedVertexCoordsValues _enfVertexCoordsSizeList; diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx index 2e7a37e..9129727 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.cxx @@ -354,6 +354,31 @@ char* GHS3DPlugin_Hypothesis_i::GetTextOption() return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() ); } +//======================================================================= +//function : SetToRemoveCentralPoint +//======================================================================= + +void GHS3DPlugin_Hypothesis_i::SetGradation(CORBA::Double gradation) +{ + if (gradation <= 1) + THROW_SALOME_CORBA_EXCEPTION( "The volumic gradation must be > 1",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); + if (gradation != GetGradation()) { + this->GetImpl()->SetGradation(gradation); + SMESH::TPythonDump() << _this() << ".SetGradation( " << gradation << " )"; + } +} + +//======================================================================= +//function : GetToRemoveCentralPoint +//======================================================================= + +CORBA::Double GHS3DPlugin_Hypothesis_i::GetGradation() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetGradation(); +} + //======================================================================= //function : SetEnforcedVertex //======================================================================= diff --git a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx index 62ae16e..6b1539c 100644 --- a/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx +++ b/src/GHS3DPlugin/GHS3DPlugin_Hypothesis_i.hxx @@ -122,6 +122,11 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i: */ void SetTextOption(const char* option); char* GetTextOption(); + /*! + * To define the volumic gradation + */ + void SetGradation(CORBA::Double gradation); + CORBA::Double GetGradation(); /*! * To set an enforced vertex */ diff --git a/src/GUI/GHS3DPluginGUI_Enums.h b/src/GUI/GHS3DPluginGUI_Enums.h index 2a2aca8..87c2563 100644 --- a/src/GUI/GHS3DPluginGUI_Enums.h +++ b/src/GUI/GHS3DPluginGUI_Enums.h @@ -58,7 +58,7 @@ enum { // Enforced vertices widget inputs enum { ENF_VER_WARNING = 0, - ENF_VER_VERTEX /*= 0*/, + ENF_VER_VERTEX,// = 0, ENF_VER_X_COORD, ENF_VER_Y_COORD, ENF_VER_Z_COORD, diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx index 46a0776..4f32cba 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx @@ -445,28 +445,35 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myBoundaryRecoveryCheck = new QCheckBox( tr( "RECOVERY_VERSION" ), myAdvGroup ); myFEMCorrectionCheck = new QCheckBox( tr( "FEM_CORRECTION" ), myAdvGroup ); + + QLabel* myGradationLabel = new QLabel( tr( "GHS3D_GRADATION" ), myAdvGroup ); + myGradation = new SMESHGUI_SpinBox(myAdvGroup); + myGradation->RangeStepAndValidator(1.05, 5.0, 0.05, "length_precision"); QLabel* aTextOptionLabel = new QLabel( tr( "TEXT_OPTION" ), myAdvGroup ); myTextOption = new QLineEdit( myAdvGroup ); - anAdvLayout->addWidget( myMaximumMemoryCheck, 0, 0, 1, 1 ); - anAdvLayout->addWidget( myMaximumMemorySpin, 0, 1, 1, 1 ); - anAdvLayout->addWidget( aMegabyteLabel, 0, 2, 1, 1 ); - anAdvLayout->addWidget( myInitialMemoryCheck, 1, 0, 1, 1 ); - anAdvLayout->addWidget( myInitialMemorySpin, 1, 1, 1, 1 ); - anAdvLayout->addWidget( aMegabyteLabel2, 1, 2, 1, 1 ); - anAdvLayout->addWidget( aWorkinDirLabel, 2, 0, 1, 1 ); - anAdvLayout->addWidget( myWorkingDir, 2, 1, 1, 2 ); - anAdvLayout->addWidget( dirBtn, 2, 3, 1, 1 ); - anAdvLayout->addWidget( myKeepFiles, 3, 0, 1, 4 ); - anAdvLayout->addWidget( aVerboseLevelLabel, 4, 0, 1, 1 ); - anAdvLayout->addWidget( myVerboseLevelSpin, 4, 1, 1, 1 ); - anAdvLayout->addWidget( myToCreateNewNodesCheck, 5, 0, 1, 4 ); - anAdvLayout->addWidget( myRemoveInitialCentralPointCheck, 6, 0, 1, 4 ); - anAdvLayout->addWidget( myBoundaryRecoveryCheck, 7, 0, 1, 4 ); - anAdvLayout->addWidget( myFEMCorrectionCheck, 8, 0, 1, 4 ); - anAdvLayout->addWidget( aTextOptionLabel, 9, 0, 1, 1 ); - anAdvLayout->addWidget( myTextOption, 9, 1, 1, 2 ); + row = 0; + anAdvLayout->addWidget( myMaximumMemoryCheck, row, 0, 1, 1 ); + anAdvLayout->addWidget( myMaximumMemorySpin, row, 1, 1, 1 ); + anAdvLayout->addWidget( aMegabyteLabel, row++, 2, 1, 1 ); + anAdvLayout->addWidget( myInitialMemoryCheck, row, 0, 1, 1 ); + anAdvLayout->addWidget( myInitialMemorySpin, row, 1, 1, 1 ); + anAdvLayout->addWidget( aMegabyteLabel2, row++, 2, 1, 1 ); + anAdvLayout->addWidget( aWorkinDirLabel, row, 0, 1, 1 ); + anAdvLayout->addWidget( myWorkingDir, row, 1, 1, 2 ); + anAdvLayout->addWidget( dirBtn, row++, 3, 1, 1 ); + anAdvLayout->addWidget( myKeepFiles, row++, 0, 1, 4 ); + anAdvLayout->addWidget( aVerboseLevelLabel, row, 0, 1, 1 ); + anAdvLayout->addWidget( myVerboseLevelSpin, row++, 1, 1, 2 ); + anAdvLayout->addWidget( myToCreateNewNodesCheck, row++, 0, 1, 4 ); + anAdvLayout->addWidget( myRemoveInitialCentralPointCheck, row++, 0, 1, 4 ); + anAdvLayout->addWidget( myBoundaryRecoveryCheck, row++, 0, 1, 4 ); + anAdvLayout->addWidget( myFEMCorrectionCheck, row++, 0, 1, 4 ); + anAdvLayout->addWidget( myGradationLabel, row, 0, 1, 1 ); + anAdvLayout->addWidget( myGradation, row++, 1, 1, 2 ); + anAdvLayout->addWidget( aTextOptionLabel, row, 0, 1, 1 ); + anAdvLayout->addWidget( myTextOption, row++, 1, 1, 2 ); // Enforced vertices parameters myEnfGroup = new QWidget(); @@ -478,10 +485,10 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame() myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS ); myEnforcedTableWidget->setSortingEnabled(true); QStringList enforcedHeaders; - enforcedHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) - << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) + enforcedHeaders << tr( "GHS3D_ENF_NAME_COLUMN" ) + << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN") << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" ); - + myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders); myEnforcedTableWidget->verticalHeader()->hide(); myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true); @@ -1431,11 +1438,12 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const myRemoveInitialCentralPointCheck ->setChecked ( data.myRemoveInitialCentralPoint ); myBoundaryRecoveryCheck ->setChecked ( data.myBoundaryRecovery ); myFEMCorrectionCheck ->setChecked ( data.myFEMCorrection ); + myGradation ->setValue ( data.myGradation ); myTextOption ->setText ( data.myTextOption ); TEnfVertexList::const_iterator it; int rowCount = 0; - myEnforcedTableWidget->clear(); + myEnforcedTableWidget->clearContents(); myEnforcedTableWidget->setSortingEnabled(false); myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ ) @@ -1515,7 +1523,7 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const // Update Enforced meshes QTableWidget TEnfMeshList::const_iterator itMesh; rowCount = 0; - myEnforcedMeshTableWidget->clear(); + myEnforcedMeshTableWidget->clearContents(); myEnforcedMeshTableWidget->setSortingEnabled(false); // myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *))); for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ ) @@ -1619,6 +1627,11 @@ QString GHS3DPluginGUI_HypothesisCreator::storeParams() const if ( data.myFEMCorrection ) valStr += " -FEM"; + if ( data.myGradation != 1.05 ) { + valStr += " -Dcpropa="; + valStr += QString::number( data.myGradation ); + } + valStr += " "; valStr += data.myTextOption; @@ -1666,6 +1679,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data.myRemoveInitialCentralPoint = h->GetToRemoveCentralPoint(); h_data.myBoundaryRecovery = h->GetToUseBoundaryRecoveryVersion(); h_data.myFEMCorrection = h->GetFEMCorrection(); + h_data.myGradation = h->GetGradation(); h_data.myTextOption = h->GetTextOption(); GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices(); @@ -1749,6 +1763,8 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery ); if ( h->GetFEMCorrection() != h_data.myFEMCorrection ) h->SetFEMCorrection( h_data.myFEMCorrection ); + if ( h->GetGradation() != h_data.myGradation ) + h->SetGradation ( h_data.myGradation ); if ( h->GetTextOption() != h_data.myTextOption ) h->SetTextOption ( h_data.myTextOption.toLatin1().constData() ); @@ -1848,6 +1864,7 @@ bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisDat h_data.myRemoveInitialCentralPoint = myRemoveInitialCentralPointCheck->isChecked(); h_data.myBoundaryRecovery = myBoundaryRecoveryCheck->isChecked(); h_data.myFEMCorrection = myFEMCorrectionCheck->isChecked(); + h_data.myGradation = myGradation->value(); h_data.myTextOption = myTextOption->text(); // Enforced vertices diff --git a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h index 0aab3e9..5e311ec 100644 --- a/src/GUI/GHS3DPluginGUI_HypothesisCreator.h +++ b/src/GUI/GHS3DPluginGUI_HypothesisCreator.h @@ -143,6 +143,7 @@ typedef struct bool myToMeshHoles,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint; int myMaximumMemory,myInitialMemory,myOptimizationLevel; QString myName,myWorkingDir,myTextOption; + double myGradation; short myVerboseLevel; TEnfVertexList myEnforcedVertices; TEnfMeshList myEnforcedMeshes; @@ -222,6 +223,7 @@ private: QCheckBox* myRemoveInitialCentralPointCheck; QCheckBox* myBoundaryRecoveryCheck; QCheckBox* myFEMCorrectionCheck; + SMESHGUI_SpinBox* myGradation; QLineEdit* myTextOption; QWidget* myEnfGroup; diff --git a/src/GUI/GHS3DPlugin_msg_en.ts b/src/GUI/GHS3DPlugin_msg_en.ts index 65569d8..9c8884b 100644 --- a/src/GUI/GHS3DPlugin_msg_en.ts +++ b/src/GUI/GHS3DPlugin_msg_en.ts @@ -79,6 +79,10 @@ FEM_CORRECTION To use FEM correction + + GHS3D_GRADATION + Volumic gradation + SELECT_DIR ... diff --git a/src/GUI/GHS3DPlugin_msg_fr.ts b/src/GUI/GHS3DPlugin_msg_fr.ts index 86452f3..922e2cc 100755 --- a/src/GUI/GHS3DPlugin_msg_fr.ts +++ b/src/GUI/GHS3DPlugin_msg_fr.ts @@ -79,6 +79,10 @@ FEM_CORRECTION Utiliser correction FEM + + GHS3D_GRADATION + Gradation volumique + SELECT_DIR ...